|
|
@ -314,7 +314,7 @@ namespace CppSharp.Generators.CSharp |
|
|
|
#region Classes
|
|
|
|
#region Classes
|
|
|
|
|
|
|
|
|
|
|
|
public void GenerateClass(Class @class) |
|
|
|
public void GenerateClass(Class @class) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (@class.IsIncomplete) |
|
|
|
if (@class.IsIncomplete) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
@ -661,7 +661,7 @@ namespace CppSharp.Generators.CSharp |
|
|
|
Type type; |
|
|
|
Type type; |
|
|
|
Class @class; |
|
|
|
Class @class; |
|
|
|
var isRef = property.Type.IsPointerTo(out type) && |
|
|
|
var isRef = property.Type.IsPointerTo(out type) && |
|
|
|
!(type.IsTagDecl(out @class) && @class.IsValueType) && |
|
|
|
!(type.TryGetClass(out @class) && @class.IsValueType) && |
|
|
|
!type.IsPrimitiveType(); |
|
|
|
!type.IsPrimitiveType(); |
|
|
|
|
|
|
|
|
|
|
|
if (isRef) |
|
|
|
if (isRef) |
|
|
@ -704,9 +704,9 @@ namespace CppSharp.Generators.CSharp |
|
|
|
public void GenerateClassProlog(Class @class) |
|
|
|
public void GenerateClassProlog(Class @class) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (@class.IsUnion) |
|
|
|
if (@class.IsUnion) |
|
|
|
WriteLine("[StructLayout(LayoutKind.Explicit)]"); |
|
|
|
WriteLine("[StructLayout(LayoutKind.Explicit)]"); |
|
|
|
|
|
|
|
|
|
|
|
Write(!@class.IsGenerated ? "internal " : Helpers.GetAccess(@class.Access)); |
|
|
|
Write(!@class.IsGenerated ? "internal " : Helpers.GetAccess(@class.Access)); |
|
|
|
Write("unsafe "); |
|
|
|
Write("unsafe "); |
|
|
|
|
|
|
|
|
|
|
|
if (Driver.Options.GenerateAbstractImpls && @class.IsAbstract) |
|
|
|
if (Driver.Options.GenerateAbstractImpls && @class.IsAbstract) |
|
|
@ -766,12 +766,12 @@ namespace CppSharp.Generators.CSharp |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void GenerateClassInternalsField(Field field) |
|
|
|
private void GenerateClassInternalsField(Field field) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// we do not support dependent fields yet, see https://github.com/mono/CppSharp/issues/197
|
|
|
|
// we do not support dependent fields yet, see https://github.com/mono/CppSharp/issues/197
|
|
|
|
Class @class; |
|
|
|
Class @class; |
|
|
|
if (field.Type.IsDependent && !field.Type.IsPointer() && |
|
|
|
if (field.Type.IsDependent && !field.Type.IsPointer() && |
|
|
|
!(field.Type.IsTagDecl(out @class) && @class.IsUnion)) |
|
|
|
!(field.Type.TryGetClass(out @class) && @class.IsUnion)) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
var safeIdentifier = Helpers.SafeIdentifier(field.OriginalName); |
|
|
|
var safeIdentifier = Helpers.SafeIdentifier(field.OriginalName); |
|
|
@ -787,14 +787,14 @@ namespace CppSharp.Generators.CSharp |
|
|
|
|
|
|
|
|
|
|
|
if (field.Expression != null) |
|
|
|
if (field.Expression != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var fieldValuePrinted = field.Expression.CSharpValue(ExpressionPrinter); |
|
|
|
var fieldValuePrinted = field.Expression.CSharpValue(ExpressionPrinter); |
|
|
|
Write("{0} {1} {2} = {3};", !field.IsGenerated ? "internal" : "public", |
|
|
|
Write("{0} {1} {2} = {3};", !field.IsGenerated ? "internal" : "public", |
|
|
|
fieldTypePrinted.Type, safeIdentifier, fieldValuePrinted); |
|
|
|
fieldTypePrinted.Type, safeIdentifier, fieldValuePrinted); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
Write("{0} {1} {2};", !field.IsGenerated ? "internal" : "public", |
|
|
|
Write("{0} {1} {2};", !field.IsGenerated ? "internal" : "public", |
|
|
|
fieldTypePrinted.Type, safeIdentifier); |
|
|
|
fieldTypePrinted.Type, safeIdentifier); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
|
PopBlock(NewLineKind.BeforeNextBlock); |
|
|
@ -2226,15 +2226,15 @@ namespace CppSharp.Generators.CSharp |
|
|
|
|
|
|
|
|
|
|
|
var @params = GenerateFunctionParamsMarshal(parameters, function); |
|
|
|
var @params = GenerateFunctionParamsMarshal(parameters, function); |
|
|
|
|
|
|
|
|
|
|
|
var originalFunction = function.OriginalFunction ?? function; |
|
|
|
var originalFunction = function.OriginalFunction ?? function; |
|
|
|
|
|
|
|
|
|
|
|
if (originalFunction.HasIndirectReturnTypeParameter) |
|
|
|
if (originalFunction.HasIndirectReturnTypeParameter) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var indirectRetType = originalFunction.Parameters.First( |
|
|
|
var indirectRetType = originalFunction.Parameters.First( |
|
|
|
parameter => parameter.Kind == ParameterKind.IndirectReturnType); |
|
|
|
parameter => parameter.Kind == ParameterKind.IndirectReturnType); |
|
|
|
|
|
|
|
|
|
|
|
Class retClass; |
|
|
|
Class retClass; |
|
|
|
indirectRetType.Type.Desugar().IsTagDecl(out retClass); |
|
|
|
indirectRetType.Type.Desugar().TryGetClass(out retClass); |
|
|
|
|
|
|
|
|
|
|
|
WriteLine("var {0} = new {1}.Internal();", GeneratedIdentifier("ret"), |
|
|
|
WriteLine("var {0} = new {1}.Internal();", GeneratedIdentifier("ret"), |
|
|
|
QualifiedIdentifier(retClass.OriginalClass ?? retClass)); |
|
|
|
QualifiedIdentifier(retClass.OriginalClass ?? retClass)); |
|
|
@ -2337,7 +2337,7 @@ namespace CppSharp.Generators.CSharp |
|
|
|
pointee = pointee.Desugar(); |
|
|
|
pointee = pointee.Desugar(); |
|
|
|
string @null; |
|
|
|
string @null; |
|
|
|
Class @class; |
|
|
|
Class @class; |
|
|
|
if (pointee.IsTagDecl(out @class) && @class.IsValueType) |
|
|
|
if (pointee.TryGetClass(out @class) && @class.IsValueType) |
|
|
|
{ |
|
|
|
{ |
|
|
|
@null = string.Format("new {0}()", pointee); |
|
|
|
@null = string.Format("new {0}()", pointee); |
|
|
|
} |
|
|
|
} |
|
|
@ -2468,7 +2468,7 @@ namespace CppSharp.Generators.CSharp |
|
|
|
var paramType = param.Type; |
|
|
|
var paramType = param.Type; |
|
|
|
|
|
|
|
|
|
|
|
Class @class; |
|
|
|
Class @class; |
|
|
|
if (paramType.Desugar().IsTagDecl(out @class) && @class.IsRefType) |
|
|
|
if (paramType.Desugar().TryGetClass(out @class) && @class.IsRefType) |
|
|
|
{ |
|
|
|
{ |
|
|
|
WriteLine("{0} = new {1}();", param.Name, paramType); |
|
|
|
WriteLine("{0} = new {1}();", param.Name, paramType); |
|
|
|
} |
|
|
|
} |
|
|
|