|
|
@ -91,8 +91,8 @@ namespace CppSharp.Generators.CSharp |
|
|
|
get { return "cs"; } |
|
|
|
get { return "cs"; } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public CSharpTextTemplate(Driver driver, TranslationUnit unit, CSharpTypePrinter typePrinter, CSharpExpressionPrinter expressionPrinter) |
|
|
|
public CSharpTextTemplate(Driver driver, IEnumerable<TranslationUnit> units, CSharpTypePrinter typePrinter, CSharpExpressionPrinter expressionPrinter) |
|
|
|
: base(driver, unit) |
|
|
|
: base(driver, units) |
|
|
|
{ |
|
|
|
{ |
|
|
|
TypePrinter = typePrinter; |
|
|
|
TypePrinter = typePrinter; |
|
|
|
ExpressionPrinter = expressionPrinter; |
|
|
|
ExpressionPrinter = expressionPrinter; |
|
|
@ -126,39 +126,36 @@ namespace CppSharp.Generators.CSharp |
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
public override void Process(Order order) |
|
|
|
public override void Process() |
|
|
|
{ |
|
|
|
{ |
|
|
|
GenerateHeader(); |
|
|
|
GenerateHeader(); |
|
|
|
|
|
|
|
|
|
|
|
if (!Options.GenerateSingleCSharpFile || order.HasFlag(Order.First)) |
|
|
|
PushBlock(CSharpBlockKind.Usings); |
|
|
|
|
|
|
|
WriteLine("using System;"); |
|
|
|
|
|
|
|
WriteLine("using System.Runtime.InteropServices;"); |
|
|
|
|
|
|
|
WriteLine("using System.Security;"); |
|
|
|
|
|
|
|
foreach (var customUsingStatement in Options.DependentNameSpaces) |
|
|
|
{ |
|
|
|
{ |
|
|
|
PushBlock(CSharpBlockKind.Usings); |
|
|
|
WriteLine(string.Format("using {0};", customUsingStatement)); |
|
|
|
WriteLine("using System;"); |
|
|
|
} |
|
|
|
WriteLine("using System.Runtime.InteropServices;"); |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
WriteLine("using System.Security;"); |
|
|
|
|
|
|
|
foreach (var customUsingStatement in Options.DependentNameSpaces) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
WriteLine(string.Format("using {0};", customUsingStatement)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Options.GenerateLibraryNamespace) |
|
|
|
if (Options.GenerateLibraryNamespace) |
|
|
|
{ |
|
|
|
{ |
|
|
|
PushBlock(CSharpBlockKind.Namespace); |
|
|
|
PushBlock(CSharpBlockKind.Namespace); |
|
|
|
WriteLine("namespace {0}", Driver.Options.OutputNamespace); |
|
|
|
WriteLine("namespace {0}", Driver.Options.OutputNamespace); |
|
|
|
WriteStartBraceIndent(); |
|
|
|
WriteStartBraceIndent(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GenerateDeclContext(TranslationUnit); |
|
|
|
foreach (var unit in TranslationUnits) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
GenerateDeclContext(unit); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!Options.GenerateSingleCSharpFile || order.HasFlag(Order.Last)) |
|
|
|
if (Options.GenerateLibraryNamespace) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (Options.GenerateLibraryNamespace) |
|
|
|
WriteCloseBraceIndent(); |
|
|
|
{ |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
WriteCloseBraceIndent(); |
|
|
|
|
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -217,7 +214,7 @@ namespace CppSharp.Generators.CSharp |
|
|
|
{ |
|
|
|
{ |
|
|
|
PushBlock(CSharpBlockKind.Functions); |
|
|
|
PushBlock(CSharpBlockKind.Functions); |
|
|
|
WriteLine("public unsafe partial class {0}", |
|
|
|
WriteLine("public unsafe partial class {0}", |
|
|
|
TranslationUnit.FileNameWithoutExtension); |
|
|
|
TranslationUnits[0].FileNameWithoutExtension); |
|
|
|
WriteStartBraceIndent(); |
|
|
|
WriteStartBraceIndent(); |
|
|
|
|
|
|
|
|
|
|
|
PushBlock(CSharpBlockKind.InternalsClass); |
|
|
|
PushBlock(CSharpBlockKind.InternalsClass); |
|
|
@ -459,14 +456,17 @@ namespace CppSharp.Generators.CSharp |
|
|
|
typePrinter.PushContext(CSharpTypePrinterContextKind.Native); |
|
|
|
typePrinter.PushContext(CSharpTypePrinterContextKind.Native); |
|
|
|
|
|
|
|
|
|
|
|
GenerateClassFields(@class, GenerateClassInternalsField, true); |
|
|
|
GenerateClassFields(@class, GenerateClassInternalsField, true); |
|
|
|
if (Options.GenerateVirtualTables && @class.IsDynamic) |
|
|
|
if (@class.IsGenerated) |
|
|
|
GenerateVTablePointers(@class); |
|
|
|
{ |
|
|
|
|
|
|
|
if (Options.GenerateVirtualTables && @class.IsDynamic) |
|
|
|
|
|
|
|
GenerateVTablePointers(@class); |
|
|
|
|
|
|
|
|
|
|
|
var functions = GatherClassInternalFunctions(@class); |
|
|
|
var functions = GatherClassInternalFunctions(@class); |
|
|
|
|
|
|
|
|
|
|
|
foreach (var function in functions) |
|
|
|
foreach (var function in functions) |
|
|
|
{ |
|
|
|
{ |
|
|
|
GenerateInternalFunction(function); |
|
|
|
GenerateInternalFunction(function); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
typePrinter.PopContext(); |
|
|
|
typePrinter.PopContext(); |
|
|
@ -583,7 +583,7 @@ namespace CppSharp.Generators.CSharp |
|
|
|
if (@class != null && @class.HasBaseClass) |
|
|
|
if (@class != null && @class.HasBaseClass) |
|
|
|
Write("new "); |
|
|
|
Write("new "); |
|
|
|
|
|
|
|
|
|
|
|
WriteLine("struct Internal"); |
|
|
|
WriteLine("partial struct Internal"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void GenerateStructMarshalingProperties(Class @class) |
|
|
|
private void GenerateStructMarshalingProperties(Class @class) |
|
|
|