|
|
|
@ -129,8 +129,7 @@ namespace CppSharp.Passes
@@ -129,8 +129,7 @@ namespace CppSharp.Passes
|
|
|
|
|
Class @class; |
|
|
|
|
if (desugared.GetFinalPointee().TryGetClass(out @class) && @class.IsValueType) |
|
|
|
|
{ |
|
|
|
|
result = string.Format("new {0}()", |
|
|
|
|
new CSharpTypePrinter(Context).VisitClassDecl(@class)); |
|
|
|
|
result = $"new {@class.Visit(new CSharpTypePrinter(Context))}()"; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -253,15 +252,40 @@ namespace CppSharp.Passes
@@ -253,15 +252,40 @@ namespace CppSharp.Passes
|
|
|
|
|
if (call != null && statement.String != "0") |
|
|
|
|
{ |
|
|
|
|
var @params = regexFunctionParams.Match(statement.String).Groups[1].Value; |
|
|
|
|
result = TranslateEnumExpression(call, desugared, @params); |
|
|
|
|
result = TranslateEnumExpression(desugared, @params); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (desugared.TryGetEnum(out Enumeration @enum) && |
|
|
|
|
int.TryParse(statement.String, out int value)) |
|
|
|
|
{ |
|
|
|
|
var typePrinter = new CSharpTypePrinter(Context); |
|
|
|
|
var printedEnum = @enum.Visit(typePrinter); |
|
|
|
|
if (value < 0) |
|
|
|
|
switch (@enum.BuiltinType.Type) |
|
|
|
|
{ |
|
|
|
|
case PrimitiveType.UShort: |
|
|
|
|
case PrimitiveType.UInt: |
|
|
|
|
case PrimitiveType.ULong: |
|
|
|
|
case PrimitiveType.ULongLong: |
|
|
|
|
case PrimitiveType.UInt128: |
|
|
|
|
result = $@"({printedEnum}) unchecked(({
|
|
|
|
|
@enum.BuiltinType.Visit(typePrinter)}) { |
|
|
|
|
statement.String})";
|
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
result = $"({printedEnum}) ({statement.String})"; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
result = $"({printedEnum}) {statement.String}"; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private string TranslateEnumExpression(Function function, |
|
|
|
|
Type desugared, string @params) |
|
|
|
|
private string TranslateEnumExpression(Type desugared, string @params) |
|
|
|
|
{ |
|
|
|
|
if (@params.Contains("::")) |
|
|
|
|
return regexDoubleColon.Replace(@params, desugared + "."); |
|
|
|
|