|
|
@ -1,5 +1,6 @@ |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Linq; |
|
|
|
|
|
|
|
using System.Text; |
|
|
|
using System.Text.RegularExpressions; |
|
|
|
using System.Text.RegularExpressions; |
|
|
|
using CppSharp.AST; |
|
|
|
using CppSharp.AST; |
|
|
|
using CppSharp.AST.Extensions; |
|
|
|
using CppSharp.AST.Extensions; |
|
|
@ -14,7 +15,6 @@ namespace CppSharp.Passes |
|
|
|
private static readonly Regex regexFunctionParams = new Regex(@"\(?(.+)\)?", RegexOptions.Compiled); |
|
|
|
private static readonly Regex regexFunctionParams = new Regex(@"\(?(.+)\)?", RegexOptions.Compiled); |
|
|
|
private static readonly Regex regexDoubleColon = new Regex(@"\w+::", RegexOptions.Compiled); |
|
|
|
private static readonly Regex regexDoubleColon = new Regex(@"\w+::", RegexOptions.Compiled); |
|
|
|
private static readonly Regex regexName = new Regex(@"(\w+)", RegexOptions.Compiled); |
|
|
|
private static readonly Regex regexName = new Regex(@"(\w+)", RegexOptions.Compiled); |
|
|
|
private static readonly Regex regexCtor = new Regex(@"^([\w<,>:]+)\s*(\([\w, ]*\))$", RegexOptions.Compiled); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private readonly Dictionary<DeclarationContext, List<Function>> overloads = |
|
|
|
private readonly Dictionary<DeclarationContext, List<Function>> overloads = |
|
|
|
new Dictionary<DeclarationContext, List<Function>>(); |
|
|
|
new Dictionary<DeclarationContext, List<Function>>(); |
|
|
@ -43,33 +43,10 @@ namespace CppSharp.Passes |
|
|
|
var overloadIndices = new List<int>(function.Parameters.Count); |
|
|
|
var overloadIndices = new List<int>(function.Parameters.Count); |
|
|
|
foreach (var parameter in function.Parameters.Where(p => p.DefaultArgument != null)) |
|
|
|
foreach (var parameter in function.Parameters.Where(p => p.DefaultArgument != null)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Type desugared = parameter.Type.Desugar(); |
|
|
|
var result = parameter.DefaultArgument.String; |
|
|
|
|
|
|
|
if (PrintExpression(parameter.Type, parameter.DefaultArgument, ref result) == null) |
|
|
|
if (CheckForDefaultPointer(desugared, parameter)) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CheckFloatSyntax(desugared, parameter); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool? defaultConstruct = CheckForDefaultConstruct(desugared, |
|
|
|
|
|
|
|
parameter.DefaultArgument, parameter.QualifiedType.Qualifiers); |
|
|
|
|
|
|
|
if (defaultConstruct == null || |
|
|
|
|
|
|
|
(!Driver.Options.MarshalCharAsManagedChar && |
|
|
|
|
|
|
|
parameter.Type.Desugar().IsPrimitiveType(PrimitiveType.UChar)) || |
|
|
|
|
|
|
|
parameter.IsPrimitiveParameterConvertibleToRef()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
overloadIndices.Add(function.Parameters.IndexOf(parameter)); |
|
|
|
overloadIndices.Add(function.Parameters.IndexOf(parameter)); |
|
|
|
continue; |
|
|
|
parameter.DefaultArgument.String = result; |
|
|
|
} |
|
|
|
|
|
|
|
if (defaultConstruct == true) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CheckForBinaryOperator(parameter.DefaultArgument, desugared)) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CheckForEnumValue(parameter.DefaultArgument, desugared)) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CheckForDefaultEmptyChar(parameter, desugared); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GenerateOverloads(function, overloadIndices); |
|
|
|
GenerateOverloads(function, overloadIndices); |
|
|
@ -77,164 +54,207 @@ namespace CppSharp.Passes |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void CheckFloatSyntax(Type desugared, Parameter parameter) |
|
|
|
private bool? PrintExpression(Type type, Expression expression, ref string result) |
|
|
|
{ |
|
|
|
|
|
|
|
var builtin = desugared as BuiltinType; |
|
|
|
|
|
|
|
if (builtin != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
switch (builtin.Type) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
case PrimitiveType.Float: |
|
|
|
var desugared = type.Desugar(); |
|
|
|
if (parameter.DefaultArgument.String.EndsWith(".F")) |
|
|
|
|
|
|
|
parameter.DefaultArgument.String = |
|
|
|
if ((!Driver.Options.MarshalCharAsManagedChar && |
|
|
|
parameter.DefaultArgument.String.Replace(".F", ".0F"); |
|
|
|
desugared.IsPrimitiveType(PrimitiveType.UChar)) || |
|
|
|
break; |
|
|
|
type.IsPrimitiveTypeConvertibleToRef()) |
|
|
|
case PrimitiveType.Double: |
|
|
|
return null; |
|
|
|
if (parameter.DefaultArgument.String.EndsWith(".")) |
|
|
|
|
|
|
|
parameter.DefaultArgument.String += '0'; |
|
|
|
if (CheckForDefaultPointer(desugared, ref result)) |
|
|
|
break; |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
var defaultConstruct = CheckForDefaultConstruct(desugared, expression, ref result); |
|
|
|
|
|
|
|
if (defaultConstruct != false) |
|
|
|
|
|
|
|
return defaultConstruct; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return CheckFloatSyntax(desugared, expression, ref result) || |
|
|
|
|
|
|
|
CheckForBinaryOperator(desugared, expression, ref result) || |
|
|
|
|
|
|
|
CheckForEnumValue(desugared, expression, ref result) || |
|
|
|
|
|
|
|
CheckForDefaultEmptyChar(desugared, expression, ref result); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private bool CheckForDefaultPointer(Type desugared, Parameter parameter) |
|
|
|
private bool CheckForDefaultPointer(Type desugared, ref string result) |
|
|
|
{ |
|
|
|
|
|
|
|
if (desugared.IsPointer()) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (!desugared.IsPointer()) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
// IntPtr.Zero is not a constant
|
|
|
|
// IntPtr.Zero is not a constant
|
|
|
|
if (desugared.IsPointerToPrimitiveType(PrimitiveType.Void)) |
|
|
|
if (desugared.IsPointerToPrimitiveType(PrimitiveType.Void)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
parameter.DefaultArgument.String = "new global::System.IntPtr()"; |
|
|
|
result = "new global::System.IntPtr()"; |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
if (parameter.IsPrimitiveParameterConvertibleToRef()) |
|
|
|
|
|
|
|
|
|
|
|
if (desugared.IsPrimitiveTypeConvertibleToRef()) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
Class @class; |
|
|
|
Class @class; |
|
|
|
if (desugared.GetFinalPointee().TryGetClass(out @class) && @class.IsValueType) |
|
|
|
if (desugared.GetFinalPointee().TryGetClass(out @class) && @class.IsValueType) |
|
|
|
{ |
|
|
|
{ |
|
|
|
parameter.DefaultArgument.String = string.Format("new {0}()", |
|
|
|
result = string.Format("new {0}()", |
|
|
|
new CSharpTypePrinter(Driver).VisitClassDecl(@class)); |
|
|
|
new CSharpTypePrinter(Driver).VisitClassDecl(@class)); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
parameter.DefaultArgument.String = "null"; |
|
|
|
|
|
|
|
|
|
|
|
result = "null"; |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private bool? CheckForDefaultConstruct(Type desugared, Statement arg, |
|
|
|
private bool? CheckForDefaultConstruct(Type desugared, Statement statement, |
|
|
|
TypeQualifiers qualifiers) |
|
|
|
ref string result) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Unwrapping the underlying type behind a possible pointer/reference
|
|
|
|
var type = desugared.GetFinalPointee() ?? desugared; |
|
|
|
Type type = desugared.GetFinalPointee() ?? desugared; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Class decl; |
|
|
|
Class decl; |
|
|
|
if (!type.TryGetClass(out decl)) |
|
|
|
if (!type.TryGetClass(out decl)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
var ctor = arg.Declaration as Method; |
|
|
|
var ctor = statement as CXXConstructExpr; |
|
|
|
|
|
|
|
|
|
|
|
TypeMap typeMap; |
|
|
|
TypeMap typeMap; |
|
|
|
var typePrinterContext = new CSharpTypePrinterContext |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
CSharpKind = CSharpTypePrinterContextKind.DefaultExpression, |
|
|
|
|
|
|
|
Type = type |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string typePrinterResult = null; |
|
|
|
var typePrinter = new CSharpTypePrinter(Driver); |
|
|
|
|
|
|
|
typePrinter.PushContext(CSharpTypePrinterContextKind.DefaultExpression); |
|
|
|
|
|
|
|
var typePrinterResult = type.Visit(typePrinter).Type; |
|
|
|
if (Driver.TypeDatabase.FindTypeMap(decl, type, out typeMap)) |
|
|
|
if (Driver.TypeDatabase.FindTypeMap(decl, type, out typeMap)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var typeInSignature = typeMap.CSharpSignatureType( |
|
|
|
var typeInSignature = typeMap.CSharpSignatureType( |
|
|
|
typePrinterContext).SkipPointerRefs().Desugar(); |
|
|
|
typePrinter.Context).SkipPointerRefs().Desugar(); |
|
|
|
Enumeration @enum; |
|
|
|
Enumeration @enum; |
|
|
|
if (typeInSignature.TryGetEnum(out @enum)) |
|
|
|
if (typeInSignature.TryGetEnum(out @enum)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (ctor != null && |
|
|
|
|
|
|
|
(ctor.Arguments.Count == 0 || |
|
|
|
|
|
|
|
HasSingleZeroArgExpression((Function) ctor.Declaration))) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
result = "0"; |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (ctor == null || !ctor.IsConstructor) |
|
|
|
if (ctor != null && typePrinterResult == "string" && ctor.Arguments.Count == 0) |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typePrinterResult = typeMap.CSharpSignature(typePrinterContext); |
|
|
|
|
|
|
|
if (typePrinterResult == "string" && ctor.Parameters.Count == 0) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
arg.String = "\"\""; |
|
|
|
result = "\"\""; |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var match = regexCtor.Match(arg.String); |
|
|
|
if (ctor == null) |
|
|
|
if (match.Success) |
|
|
|
return decl.IsValueType ? (bool?) false : null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var method = (Method) statement.Declaration; |
|
|
|
|
|
|
|
var expressionSupported = decl.IsValueType && method.Parameters.Count == 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (statement.String.Contains('(')) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (ctor != null) |
|
|
|
var argsBuilder = new StringBuilder("new "); |
|
|
|
|
|
|
|
argsBuilder.Append(typePrinterResult); |
|
|
|
|
|
|
|
argsBuilder.Append('('); |
|
|
|
|
|
|
|
for (var i = 0; i < ctor.Arguments.Count; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var templateSpecializationType = type as TemplateSpecializationType; |
|
|
|
var argument = ctor.Arguments[i]; |
|
|
|
var typePrinter = new CSharpTypePrinter(Driver); |
|
|
|
var argResult = argument.String; |
|
|
|
typePrinterResult = typePrinterResult ?? (templateSpecializationType != null |
|
|
|
expressionSupported &= PrintExpression(method.Parameters[i].Type.Desugar(), |
|
|
|
? typePrinter.VisitTemplateSpecializationType( |
|
|
|
argument, ref argResult) ?? false; |
|
|
|
templateSpecializationType, qualifiers) |
|
|
|
argsBuilder.Append(argResult); |
|
|
|
: typePrinter.VisitClassDecl((Class) ctor.Namespace)).Type; |
|
|
|
if (i < ctor.Arguments.Count - 1) |
|
|
|
|
|
|
|
argsBuilder.Append(", "); |
|
|
|
arg.String = string.Format("new {0}{1}", typePrinterResult, |
|
|
|
|
|
|
|
match.Groups[2].Value); |
|
|
|
|
|
|
|
if (ctor.Parameters.Count > 0 && ctor.Parameters[0].Type.IsAddress()) |
|
|
|
|
|
|
|
arg.String = arg.String.Replace("(0)", "()"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
argsBuilder.Append(')'); |
|
|
|
arg.String = string.Format("new {0}", arg.String); |
|
|
|
result = argsBuilder.ToString(); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (ctor != null && ctor.Parameters.Count > 0) |
|
|
|
if (method.Parameters.Count > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var finalPointee = ctor.Parameters[0].Type.SkipPointerRefs().Desugar(); |
|
|
|
var paramType = method.Parameters[0].Type.SkipPointerRefs().Desugar(); |
|
|
|
Enumeration @enum; |
|
|
|
Enumeration @enum; |
|
|
|
if (finalPointee.TryGetEnum(out @enum)) |
|
|
|
if (paramType.TryGetEnum(out @enum)) |
|
|
|
TranslateEnumExpression(ctor, arg, finalPointee, arg.String); |
|
|
|
result = TranslateEnumExpression(method, paramType, statement.String); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return expressionSupported ? true : (bool?) null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return decl.IsValueType ? true : (bool?) null; |
|
|
|
private static bool CheckFloatSyntax(Type desugared, Statement statement, ref string result) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var builtin = desugared as BuiltinType; |
|
|
|
|
|
|
|
if (builtin != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
switch (builtin.Type) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
case PrimitiveType.Float: |
|
|
|
|
|
|
|
if (statement.String.EndsWith(".F")) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
result = statement.String.Replace(".F", ".0F"); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case PrimitiveType.Double: |
|
|
|
|
|
|
|
if (statement.String.EndsWith(".")) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
result = statement.String + '0'; |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private bool CheckForBinaryOperator(Expression arg, Type desugared) |
|
|
|
private bool CheckForBinaryOperator(Type desugared, Expression expression, |
|
|
|
|
|
|
|
ref string result) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (arg.Class != StatementClass.BinaryOperator) return false; |
|
|
|
if (expression.Class != StatementClass.BinaryOperator) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var binaryOperator = (BinaryOperator) expression; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var lhsResult = binaryOperator.LHS.String; |
|
|
|
|
|
|
|
CheckForEnumValue(desugared, binaryOperator.LHS, ref lhsResult); |
|
|
|
|
|
|
|
|
|
|
|
var binaryOperator = (BinaryOperator) arg; |
|
|
|
var rhsResult = binaryOperator.RHS.String; |
|
|
|
CheckForEnumValue(binaryOperator.LHS, desugared); |
|
|
|
CheckForEnumValue(desugared, binaryOperator.RHS, ref rhsResult); |
|
|
|
CheckForEnumValue(binaryOperator.RHS, desugared); |
|
|
|
|
|
|
|
arg.String = string.Format("{0} {1} {2}", binaryOperator.LHS.String, |
|
|
|
result = string.Format("{0} {1} {2}", lhsResult, |
|
|
|
binaryOperator.OpcodeStr, binaryOperator.RHS.String); |
|
|
|
binaryOperator.OpcodeStr, rhsResult); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private bool CheckForEnumValue(Expression arg, Type desugared) |
|
|
|
private bool CheckForEnumValue(Type desugared, Statement statement, |
|
|
|
|
|
|
|
ref string result) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var enumItem = arg.Declaration as Enumeration.Item; |
|
|
|
var enumItem = statement.Declaration as Enumeration.Item; |
|
|
|
if (enumItem != null) |
|
|
|
if (enumItem != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
arg.String = string.Format("{0}{1}.{2}", |
|
|
|
result = string.Format("{0}{1}.{2}", |
|
|
|
desugared.IsPrimitiveType() ? "(int) " : string.Empty, |
|
|
|
desugared.IsPrimitiveType() ? "(int) " : string.Empty, |
|
|
|
new CSharpTypePrinter(Driver).VisitEnumDecl( |
|
|
|
new CSharpTypePrinter(Driver).VisitEnumDecl( |
|
|
|
(Enumeration) enumItem.Namespace), enumItem.Name); |
|
|
|
(Enumeration) enumItem.Namespace), enumItem.Name); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var call = arg.Declaration as Function; |
|
|
|
var call = statement.Declaration as Function; |
|
|
|
if (call != null && arg.String != "0") |
|
|
|
if (call != null && statement.String != "0") |
|
|
|
{ |
|
|
|
{ |
|
|
|
string @params = regexFunctionParams.Match(arg.String).Groups[1].Value; |
|
|
|
var @params = regexFunctionParams.Match(statement.String).Groups[1].Value; |
|
|
|
TranslateEnumExpression(call, arg, desugared, @params); |
|
|
|
result = TranslateEnumExpression(call, desugared, @params); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void TranslateEnumExpression(Function function, Statement arg, |
|
|
|
private string TranslateEnumExpression(Function function, |
|
|
|
Type desugared, string @params) |
|
|
|
Type desugared, string @params) |
|
|
|
{ |
|
|
|
{ |
|
|
|
TypeMap typeMap; |
|
|
|
TypeMap typeMap; |
|
|
|
if ((function.Parameters.Count == 0 || |
|
|
|
if ((function.Parameters.Count == 0 || |
|
|
|
HasSingleZeroExpression(function)) && |
|
|
|
HasSingleZeroArgExpression(function)) && |
|
|
|
Driver.TypeDatabase.FindTypeMap(desugared, out typeMap)) |
|
|
|
Driver.TypeDatabase.FindTypeMap(desugared, out typeMap)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var typeInSignature = typeMap.CSharpSignatureType(new CSharpTypePrinterContext |
|
|
|
var typeInSignature = typeMap.CSharpSignatureType(new CSharpTypePrinterContext |
|
|
@ -244,18 +264,16 @@ namespace CppSharp.Passes |
|
|
|
}).SkipPointerRefs().Desugar(); |
|
|
|
}).SkipPointerRefs().Desugar(); |
|
|
|
Enumeration @enum; |
|
|
|
Enumeration @enum; |
|
|
|
if (typeInSignature.TryGetEnum(out @enum)) |
|
|
|
if (typeInSignature.TryGetEnum(out @enum)) |
|
|
|
{ |
|
|
|
return "0"; |
|
|
|
arg.String = "0"; |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (@params.Contains("::")) |
|
|
|
if (@params.Contains("::")) |
|
|
|
arg.String = regexDoubleColon.Replace(@params, desugared + "."); |
|
|
|
return regexDoubleColon.Replace(@params, desugared + "."); |
|
|
|
else |
|
|
|
|
|
|
|
arg.String = regexName.Replace(@params, desugared + ".$1"); |
|
|
|
return regexName.Replace(@params, desugared + ".$1"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static bool HasSingleZeroExpression(Function function) |
|
|
|
private static bool HasSingleZeroArgExpression(Function function) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (function.Parameters.Count != 1) |
|
|
|
if (function.Parameters.Count != 1) |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -265,14 +283,18 @@ namespace CppSharp.Passes |
|
|
|
((BuiltinTypeExpression) defaultArgument).Value == 0; |
|
|
|
((BuiltinTypeExpression) defaultArgument).Value == 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void CheckForDefaultEmptyChar(Parameter parameter, Type desugared) |
|
|
|
private bool CheckForDefaultEmptyChar(Type desugared, Statement statement, |
|
|
|
|
|
|
|
ref string result) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (parameter.DefaultArgument.String == "0" && |
|
|
|
if (statement.String == "0" && |
|
|
|
Driver.Options.MarshalCharAsManagedChar && |
|
|
|
Driver.Options.MarshalCharAsManagedChar && |
|
|
|
desugared.IsPrimitiveType(PrimitiveType.Char)) |
|
|
|
desugared.IsPrimitiveType(PrimitiveType.Char)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
parameter.DefaultArgument.String = "'\\0'"; |
|
|
|
result = "'\\0'"; |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void GenerateOverloads(Function function, List<int> overloadIndices) |
|
|
|
private void GenerateOverloads(Function function, List<int> overloadIndices) |
|
|
|