|
|
|
@ -672,32 +672,32 @@ namespace CppSharp.Generators.CSharp |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void GenerateStructInternalMarshalingProperty(Property field, string marshalVar) |
|
|
|
private void GenerateStructInternalMarshalingProperty(Property property, string marshalVar) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var marshalCtx = new CSharpMarshalContext(Driver) |
|
|
|
var marshalCtx = new CSharpMarshalContext(Driver) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ArgName = field.Name, |
|
|
|
ArgName = property.Name, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var marshal = new CSharpMarshalManagedToNativePrinter(marshalCtx); |
|
|
|
var marshal = new CSharpMarshalManagedToNativePrinter(marshalCtx); |
|
|
|
field.Visit(marshal); |
|
|
|
property.Visit(marshal); |
|
|
|
|
|
|
|
|
|
|
|
Type type; |
|
|
|
Type type; |
|
|
|
Class @class; |
|
|
|
Class @class; |
|
|
|
var isRef = field.Type.IsPointerTo(out type) && |
|
|
|
var isRef = property.Type.IsPointerTo(out type) && |
|
|
|
!(type.IsTagDecl(out @class) && @class.IsValueType) && |
|
|
|
!(type.IsTagDecl(out @class) && @class.IsValueType) && |
|
|
|
!type.IsPrimitiveType(); |
|
|
|
!type.IsPrimitiveType(); |
|
|
|
|
|
|
|
|
|
|
|
if (isRef) |
|
|
|
if (isRef) |
|
|
|
{ |
|
|
|
{ |
|
|
|
WriteLine("if ({0} != null)", field.Name); |
|
|
|
WriteLine("if ({0} != null)", property.Name); |
|
|
|
WriteStartBraceIndent(); |
|
|
|
WriteStartBraceIndent(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(marshal.Context.SupportBefore)) |
|
|
|
if (!string.IsNullOrWhiteSpace(marshal.Context.SupportBefore)) |
|
|
|
WriteLine(marshal.Context.SupportBefore); |
|
|
|
WriteLine(marshal.Context.SupportBefore); |
|
|
|
|
|
|
|
|
|
|
|
WriteLine("{0}.{1} = {2};", marshalVar, field.OriginalName, marshal.Context.Return); |
|
|
|
WriteLine("{0}.{1} = {2};", marshalVar, property.OriginalName, marshal.Context.Return); |
|
|
|
|
|
|
|
|
|
|
|
if (isRef) |
|
|
|
if (isRef) |
|
|
|
WriteCloseBraceIndent(); |
|
|
|
WriteCloseBraceIndent(); |
|
|
|
@ -797,7 +797,7 @@ namespace CppSharp.Generators.CSharp |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void GenerateClassField(Field field) |
|
|
|
private void GenerateClassField(Field field, bool @public = false) |
|
|
|
{ |
|
|
|
{ |
|
|
|
PushBlock(CSharpBlockKind.Field); |
|
|
|
PushBlock(CSharpBlockKind.Field); |
|
|
|
|
|
|
|
|
|
|
|
@ -807,7 +807,8 @@ namespace CppSharp.Generators.CSharp |
|
|
|
if (@class.IsUnion) |
|
|
|
if (@class.IsUnion) |
|
|
|
WriteLine("[FieldOffset({0})]", field.Offset); |
|
|
|
WriteLine("[FieldOffset({0})]", field.Offset); |
|
|
|
|
|
|
|
|
|
|
|
WriteLine("private {0} {1};", field.Type, SafeIdentifier(field.Name)); |
|
|
|
WriteLine("{0} {1} {2};", @public ? "public" : "private", |
|
|
|
|
|
|
|
field.Type, SafeIdentifier(field.Name)); |
|
|
|
|
|
|
|
|
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -913,6 +914,7 @@ namespace CppSharp.Generators.CSharp |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
WriteStartBraceIndent(); |
|
|
|
WriteStartBraceIndent(); |
|
|
|
var field = decl as Field; |
|
|
|
var field = decl as Field; |
|
|
|
|
|
|
|
|
|
|
|
@ -1006,6 +1008,7 @@ namespace CppSharp.Generators.CSharp |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
NewLine(); |
|
|
|
NewLine(); |
|
|
|
WriteStartBraceIndent(); |
|
|
|
WriteStartBraceIndent(); |
|
|
|
var field = decl as Field; |
|
|
|
var field = decl as Field; |
|
|
|
@ -1108,24 +1111,29 @@ namespace CppSharp.Generators.CSharp |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void GenerateClassProperties(Class @class, bool onlyFieldProperties = false) |
|
|
|
private void GenerateClassProperties(Class @class) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (@class.IsValueType) |
|
|
|
if (@class.IsValueType) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (var @base in @class.Bases.Where(b => b.IsClass && !b.Class.Ignore)) |
|
|
|
foreach (var @base in @class.Bases.Where(b => b.IsClass && !b.Class.Ignore)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
GenerateClassProperties(@base.Class, true); |
|
|
|
GenerateClassProperties(@base.Class); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GenerateProperties(@class, onlyFieldProperties); |
|
|
|
GenerateProperties(@class); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void GenerateProperties(Class @class, bool onlyFieldProperties = false) |
|
|
|
private void GenerateProperties(Class @class) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (var prop in @class.Properties.Where( |
|
|
|
foreach (var prop in @class.Properties.Where(p => !p.Ignore)) |
|
|
|
p => !p.Ignore && (!onlyFieldProperties || p.Field != null))) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (prop.IsBackedByValueClassField()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
GenerateClassField(prop.Field, true); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
PushBlock(CSharpBlockKind.Property); |
|
|
|
PushBlock(CSharpBlockKind.Property); |
|
|
|
|
|
|
|
|
|
|
|
// If this is an indexer that returns an address use the real type
|
|
|
|
// If this is an indexer that returns an address use the real type
|
|
|
|
|