|
|
@ -272,7 +272,7 @@ namespace CppSharp.Generators.CSharp |
|
|
|
|
|
|
|
|
|
|
|
public override bool VisitClassDecl(Class @class) |
|
|
|
public override bool VisitClassDecl(Class @class) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (@class.IsIncomplete) |
|
|
|
if (@class.IsIncomplete && !@class.IsOpaque) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
if (@class.IsInterface) |
|
|
|
if (@class.IsInterface) |
|
|
@ -308,63 +308,59 @@ namespace CppSharp.Generators.CSharp |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
PushBlock(BlockKind.Class); |
|
|
|
PushBlock(BlockKind.Class); |
|
|
|
GenerateDeclarationCommon(@class); |
|
|
|
GenerateDeclarationCommon(@class); |
|
|
|
|
|
|
|
|
|
|
|
GenerateClassSpecifier(@class); |
|
|
|
GenerateClassSpecifier(@class); |
|
|
|
|
|
|
|
|
|
|
|
NewLine(); |
|
|
|
NewLine(); |
|
|
|
WriteStartBraceIndent(); |
|
|
|
WriteStartBraceIndent(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!@class.IsAbstractImpl) |
|
|
|
|
|
|
|
GenerateClassInternals(@class); |
|
|
|
|
|
|
|
|
|
|
|
if (!@class.IsOpaque) |
|
|
|
VisitDeclContext(@class); |
|
|
|
{ |
|
|
|
|
|
|
|
if (!@class.IsAbstractImpl) |
|
|
|
|
|
|
|
GenerateClassInternals(@class); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VisitDeclContext(@class); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (@class.IsDependent || !@class.IsGenerated) |
|
|
|
if (@class.IsDependent || !@class.IsGenerated) |
|
|
|
goto exit; |
|
|
|
goto exit; |
|
|
|
|
|
|
|
|
|
|
|
if (ShouldGenerateClassNativeField(@class)) |
|
|
|
if (ShouldGenerateClassNativeField(@class)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
PushBlock(BlockKind.Field); |
|
|
|
|
|
|
|
if (@class.IsValueType) |
|
|
|
{ |
|
|
|
{ |
|
|
|
PushBlock(BlockKind.Field); |
|
|
|
WriteLine("private {0}.{1} {2};", @class.Name, Helpers.InternalStruct, |
|
|
|
if (@class.IsValueType) |
|
|
|
Helpers.InstanceField); |
|
|
|
{ |
|
|
|
WriteLine("internal {0}.{1} {2} {{ get {{ return {3}; }} }}", @class.Name, |
|
|
|
WriteLine("private {0}.{1} {2};", @class.Name, Helpers.InternalStruct, |
|
|
|
Helpers.InternalStruct, Helpers.InstanceIdentifier, Helpers.InstanceField); |
|
|
|
Helpers.InstanceField); |
|
|
|
} |
|
|
|
WriteLine("internal {0}.{1} {2} {{ get {{ return {3}; }} }}", @class.Name, |
|
|
|
else |
|
|
|
Helpers.InternalStruct, Helpers.InstanceIdentifier, Helpers.InstanceField); |
|
|
|
{ |
|
|
|
} |
|
|
|
WriteLine("public {0} {1} {{ get; protected set; }}", |
|
|
|
else |
|
|
|
CSharpTypePrinter.IntPtrType, Helpers.InstanceIdentifier); |
|
|
|
{ |
|
|
|
|
|
|
|
WriteLine("public {0} {1} {{ get; protected set; }}", |
|
|
|
|
|
|
|
CSharpTypePrinter.IntPtrType, Helpers.InstanceIdentifier); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
|
|
|
|
|
|
|
|
PushBlock(BlockKind.Field); |
|
|
|
PushBlock(BlockKind.Field); |
|
|
|
|
|
|
|
|
|
|
|
WriteLine("protected int {0};", Helpers.PointerAdjustmentIdentifier); |
|
|
|
WriteLine("protected int {0};", Helpers.PointerAdjustmentIdentifier); |
|
|
|
|
|
|
|
|
|
|
|
// use interfaces if any - derived types with a secondary base this class must be compatible with the map
|
|
|
|
// use interfaces if any - derived types with a secondary base this class must be compatible with the map
|
|
|
|
var @interface = @class.Namespace.Classes.Find(c => c.OriginalClass == @class); |
|
|
|
var @interface = @class.Namespace.Classes.Find(c => c.OriginalClass == @class); |
|
|
|
var dict = string.Format("global::System.Collections.Concurrent.ConcurrentDictionary<IntPtr, {0}>", |
|
|
|
var dict = string.Format("global::System.Collections.Concurrent.ConcurrentDictionary<IntPtr, {0}>", |
|
|
|
(@interface ?? @class).Visit(TypePrinter)); |
|
|
|
(@interface ?? @class).Visit(TypePrinter)); |
|
|
|
WriteLine("internal static readonly {0} NativeToManagedMap = new {0}();", dict); |
|
|
|
WriteLine("internal static readonly {0} NativeToManagedMap = new {0}();", dict); |
|
|
|
WriteLine("protected void*[] __OriginalVTables;"); |
|
|
|
WriteLine("protected void*[] __OriginalVTables;"); |
|
|
|
} |
|
|
|
|
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GenerateClassConstructors(@class); |
|
|
|
GenerateClassConstructors(@class); |
|
|
|
|
|
|
|
|
|
|
|
GenerateClassMethods(@class.Methods); |
|
|
|
GenerateClassMethods(@class.Methods); |
|
|
|
GenerateClassVariables(@class); |
|
|
|
GenerateClassVariables(@class); |
|
|
|
GenerateClassProperties(@class); |
|
|
|
GenerateClassProperties(@class); |
|
|
|
|
|
|
|
|
|
|
|
if (@class.IsDynamic) |
|
|
|
if (@class.IsDynamic) |
|
|
|
GenerateVTable(@class); |
|
|
|
GenerateVTable(@class); |
|
|
|
} |
|
|
|
|
|
|
|
exit: |
|
|
|
exit: |
|
|
|
WriteCloseBraceIndent(); |
|
|
|
WriteCloseBraceIndent(); |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|