|
|
@ -57,22 +57,48 @@ namespace CppSharp.Passes |
|
|
|
if (@operator.SynthKind == FunctionSynthKind.NonMemberOperator) |
|
|
|
if (@operator.SynthKind == FunctionSynthKind.NonMemberOperator) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
// Handle missing operator parameters
|
|
|
|
if (@operator.OperatorKind == CXXOperatorKind.Subscript) |
|
|
|
if (@operator.IsStatic) |
|
|
|
|
|
|
|
@operator.Parameters = @operator.Parameters.Skip(1).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var type = new PointerType() |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
QualifiedPointee = new QualifiedType(new TagType(@class)), |
|
|
|
CreateIndexer(@class, @operator); |
|
|
|
Modifier = PointerType.TypeModifier.LVReference |
|
|
|
} |
|
|
|
}; |
|
|
|
else |
|
|
|
|
|
|
|
|
|
|
|
@operator.Parameters.Insert(0, new Parameter |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
Name = Generator.GeneratedIdentifier("op"), |
|
|
|
// Handle missing operator parameters
|
|
|
|
QualifiedType = new QualifiedType(type), |
|
|
|
if (@operator.IsStatic) |
|
|
|
Kind = ParameterKind.OperatorParameter |
|
|
|
@operator.Parameters = @operator.Parameters.Skip(1).ToList(); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
var type = new PointerType() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QualifiedPointee = new QualifiedType(new TagType(@class)), |
|
|
|
|
|
|
|
Modifier = PointerType.TypeModifier.LVReference |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@operator.Parameters.Insert(0, new Parameter |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Name = Generator.GeneratedIdentifier("op"), |
|
|
|
|
|
|
|
QualifiedType = new QualifiedType(type), |
|
|
|
|
|
|
|
Kind = ParameterKind.OperatorParameter |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void CreateIndexer(Class @class, Method @operator) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (@class.Properties.All(p => p.Parameters.Count == 0 || |
|
|
|
|
|
|
|
p.Parameters[0].QualifiedType != @operator.Parameters[0].QualifiedType)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Property property = new Property |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Name = "Item", |
|
|
|
|
|
|
|
QualifiedType = @operator.ReturnType, |
|
|
|
|
|
|
|
Access = @operator.Access, |
|
|
|
|
|
|
|
Namespace = @class |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
property.GetMethod = @operator; |
|
|
|
|
|
|
|
property.Parameters.AddRange(@operator.Parameters); |
|
|
|
|
|
|
|
@class.Properties.Add(property); |
|
|
|
|
|
|
|
@operator.IsGenerated = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -153,6 +179,9 @@ namespace CppSharp.Passes |
|
|
|
case CXXOperatorKind.Pipe: |
|
|
|
case CXXOperatorKind.Pipe: |
|
|
|
case CXXOperatorKind.Caret: |
|
|
|
case CXXOperatorKind.Caret: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// The array indexing operator can be overloaded
|
|
|
|
|
|
|
|
case CXXOperatorKind.Subscript: |
|
|
|
|
|
|
|
|
|
|
|
// The comparison operators can be overloaded
|
|
|
|
// The comparison operators can be overloaded
|
|
|
|
case CXXOperatorKind.EqualEqual: |
|
|
|
case CXXOperatorKind.EqualEqual: |
|
|
|
case CXXOperatorKind.ExclaimEqual: |
|
|
|
case CXXOperatorKind.ExclaimEqual: |
|
|
@ -180,9 +209,6 @@ namespace CppSharp.Passes |
|
|
|
case CXXOperatorKind.LessLessEqual: |
|
|
|
case CXXOperatorKind.LessLessEqual: |
|
|
|
case CXXOperatorKind.GreaterGreaterEqual: |
|
|
|
case CXXOperatorKind.GreaterGreaterEqual: |
|
|
|
|
|
|
|
|
|
|
|
// The array indexing operator cannot be overloaded
|
|
|
|
|
|
|
|
case CXXOperatorKind.Subscript: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// The conditional logical operators cannot be overloaded
|
|
|
|
// The conditional logical operators cannot be overloaded
|
|
|
|
case CXXOperatorKind.AmpAmp: |
|
|
|
case CXXOperatorKind.AmpAmp: |
|
|
|
case CXXOperatorKind.PipePipe: |
|
|
|
case CXXOperatorKind.PipePipe: |
|
|
|