Browse Source

Fixed warnings in the generated code by properly using "new".

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/563/head
Dimitar Dobrev 10 years ago
parent
commit
4584ae7485
  1. 5
      src/AST/Class.cs
  2. 8
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs

5
src/AST/Class.cs

@ -174,6 +174,11 @@ namespace CppSharp.AST @@ -174,6 +174,11 @@ namespace CppSharp.AST
}
}
public bool NeedsBase
{
get { return HasNonIgnoredBase && IsGenerated; }
}
// When we have an interface, this is the class mapped to that interface.
public Class OriginalClass { get; set; }

8
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -645,7 +645,7 @@ namespace CppSharp.Generators.CSharp @@ -645,7 +645,7 @@ namespace CppSharp.Generators.CSharp
{
Write("public ");
if (@class != null && @class.HasBaseClass)
if (@class != null && @class.NeedsBase && !@class.BaseClass.IsInterface)
Write("new ");
WriteLine("partial struct Internal");
@ -680,9 +680,7 @@ namespace CppSharp.Generators.CSharp @@ -680,9 +680,7 @@ namespace CppSharp.Generators.CSharp
var bases = new List<string>();
var needsBase = @class.HasNonIgnoredBase && @class.IsGenerated;
if (needsBase)
if (@class.NeedsBase)
{
bases.AddRange(
from @base in @class.Bases
@ -1907,7 +1905,7 @@ namespace CppSharp.Generators.CSharp @@ -1907,7 +1905,7 @@ namespace CppSharp.Generators.CSharp
{
PushBlock(CSharpBlockKind.Method);
WriteLine("public static {0}{1} {2}(global::System.IntPtr native{3})",
@class.HasNonIgnoredBase && !@class.BaseClass.IsAbstract ? "new " : string.Empty,
@class.NeedsBase && !@class.BaseClass.IsInterface ? "new " : string.Empty,
@class.Name, Helpers.CreateInstanceIdentifier,
@class.IsRefType ? ", bool ownsNativeInstance = false" : string.Empty);
WriteStartBraceIndent();

Loading…
Cancel
Save