Browse Source

Merge pull request #352 from ddobrev/master

Fixed warnings about hidden methods in generated code
pull/353/head
João Matos 11 years ago
parent
commit
b2eb4722b8
  1. 12
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs

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

@ -43,7 +43,7 @@ namespace CppSharp.Generators.CSharp
public const string InstanceIdentifier = "__Instance"; public const string InstanceIdentifier = "__Instance";
public const string AllocatedWithHGlobalIdentifier = "__allocatedWithHGlobal"; public const string OwnsNativeInstanceIdentifier = "__ownsNativeInstance";
public const string CreateInstanceIdentifier = "__CreateInstance"; public const string CreateInstanceIdentifier = "__CreateInstance";
@ -1870,7 +1870,7 @@ namespace CppSharp.Generators.CSharp
if (@class.IsRefType) if (@class.IsRefType)
{ {
WriteLine("if ({0})", Helpers.AllocatedWithHGlobalIdentifier); WriteLine("if ({0})", Helpers.OwnsNativeInstanceIdentifier);
WriteStartBraceIndent(); WriteStartBraceIndent();
WriteLine("Marshal.FreeHGlobal({0});", Helpers.InstanceIdentifier); WriteLine("Marshal.FreeHGlobal({0});", Helpers.InstanceIdentifier);
WriteCloseBraceIndent(); WriteCloseBraceIndent();
@ -1888,7 +1888,7 @@ namespace CppSharp.Generators.CSharp
if (@class.IsRefType) if (@class.IsRefType)
{ {
PushBlock(CSharpBlockKind.Field); PushBlock(CSharpBlockKind.Field);
WriteLine("private readonly bool {0};", Helpers.AllocatedWithHGlobalIdentifier); WriteLine("private readonly bool {0};", Helpers.OwnsNativeInstanceIdentifier);
PopBlock(NewLineKind.BeforeNextBlock); PopBlock(NewLineKind.BeforeNextBlock);
} }
@ -1903,7 +1903,7 @@ namespace CppSharp.Generators.CSharp
if (!@class.IsAbstract) if (!@class.IsAbstract)
{ {
PushBlock(CSharpBlockKind.Method); PushBlock(CSharpBlockKind.Method);
WriteLine("public static {0} {1}(global::System.IntPtr native)", safeIdentifier, Helpers.CreateInstanceIdentifier); WriteLine("public static new {0} {1}(global::System.IntPtr native)", safeIdentifier, Helpers.CreateInstanceIdentifier);
WriteStartBraceIndent(); WriteStartBraceIndent();
WriteLine("return new {0}(({1}.Internal*) native);", safeIdentifier, className); WriteLine("return new {0}(({1}.Internal*) native);", safeIdentifier, className);
WriteCloseBraceIndent(); WriteCloseBraceIndent();
@ -1999,7 +1999,7 @@ namespace CppSharp.Generators.CSharp
WriteStartBraceIndent(); WriteStartBraceIndent();
if (@class.IsRefType) if (@class.IsRefType)
{ {
WriteLine("{0} = true;", Helpers.AllocatedWithHGlobalIdentifier); WriteLine("{0} = true;", Helpers.OwnsNativeInstanceIdentifier);
} }
WriteCloseBraceIndent(); WriteCloseBraceIndent();
PopBlock(NewLineKind.BeforeNextBlock); PopBlock(NewLineKind.BeforeNextBlock);
@ -2266,7 +2266,7 @@ namespace CppSharp.Generators.CSharp
{ {
WriteLine("{0} = Marshal.AllocHGlobal({1});", Helpers.InstanceIdentifier, WriteLine("{0} = Marshal.AllocHGlobal({1});", Helpers.InstanceIdentifier,
@class.Layout.Size); @class.Layout.Size);
WriteLine("{0} = true;", Helpers.AllocatedWithHGlobalIdentifier); WriteLine("{0} = true;", Helpers.OwnsNativeInstanceIdentifier);
if (method.IsCopyConstructor) if (method.IsCopyConstructor)
{ {

Loading…
Cancel
Save