Browse Source

Extract the native constructor generation code to its own method.

pull/1/head
triton 13 years ago
parent
commit
866628f955
  1. 34
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs

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

@ -580,21 +580,7 @@ namespace Cxxi.Generators.CSharp @@ -580,21 +580,7 @@ namespace Cxxi.Generators.CSharp
public void GenerateClassConstructors(Class @class)
{
// Output a default constructor that takes the native pointer.
WriteLine("{0}(System.IntPtr native)", SafeIdentifier(@class.Name));
WriteStartBraceIndent();
if (@class.IsRefType)
{
if (ShouldGenerateClassNativeField(@class))
WriteLine("Instance = native;");
}
else
{
GenerateStructMarshaling(@class);
}
WriteCloseBraceIndent();
NewLine();
GenerateNativeConstructor(@class);
foreach (var ctor in @class.Constructors)
{
@ -622,6 +608,24 @@ namespace Cxxi.Generators.CSharp @@ -622,6 +608,24 @@ namespace Cxxi.Generators.CSharp
}
}
private void GenerateNativeConstructor(Class @class)
{
WriteLine("internal {0}(System.IntPtr native)", SafeIdentifier(@class.Name));
WriteStartBraceIndent();
if (@class.IsRefType)
{
if (ShouldGenerateClassNativeField(@class))
WriteLine("Instance = native;");
}
else
{
GenerateStructMarshaling(@class);
}
WriteCloseBraceIndent();
}
private bool GenerateClassConstructorBase(Class @class, Method method)
{
var hasBase = @class.HasBase && !@class.Bases[0].Class.Ignore;

Loading…
Cancel
Save