Browse Source

Improved the generation of indexers by removing const overloads of []. NOTE: did that by removing the method type check in the pass for ambiguous overloads.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/61/head
Dimitar Dobrev 12 years ago
parent
commit
083dc3a9f8
  1. 2
      src/Generator/Driver.cs
  2. 8
      src/Generator/Passes/CheckAmbiguousFunctions.cs
  3. 26
      src/Generator/Passes/CheckOperatorsOverloads.cs

2
src/Generator/Driver.cs

@ -140,9 +140,9 @@ namespace CppSharp @@ -140,9 +140,9 @@ namespace CppSharp
TranslationUnitPasses.AddPass(new FindSymbolsPass());
TranslationUnitPasses.AddPass(new MoveOperatorToClassPass());
TranslationUnitPasses.AddPass(new CheckAmbiguousFunctions());
TranslationUnitPasses.AddPass(new CheckOperatorsOverloadsPass());
TranslationUnitPasses.AddPass(new CheckVirtualOverrideReturnCovariance());
TranslationUnitPasses.AddPass(new CheckAmbiguousFunctions());
Generator.SetupPasses();
TranslationUnitPasses.AddPass(new FieldToPropertyPass());

8
src/Generator/Passes/CheckAmbiguousFunctions.cs

@ -23,14 +23,6 @@ namespace CppSharp.Passes @@ -23,14 +23,6 @@ namespace CppSharp.Passes
/// </summary>
public class CheckAmbiguousFunctions : TranslationUnitPass
{
public override bool VisitMethodDecl(Method method)
{
if (method.Kind != CXXMethodKind.Normal)
return false;
return base.VisitMethodDecl(method);
}
public override bool VisitFunctionDecl(AST.Function function)
{
if (AlreadyVisited(function))

26
src/Generator/Passes/CheckOperatorsOverloads.cs

@ -44,7 +44,7 @@ namespace CppSharp.Passes @@ -44,7 +44,7 @@ namespace CppSharp.Passes
private void CheckInvalidOperators(Class @class)
{
foreach (var @operator in @class.Operators)
foreach (var @operator in @class.Operators.Where(o => !o.Ignore))
{
if (!IsValidOperatorOverload(@operator))
{
@ -85,21 +85,17 @@ namespace CppSharp.Passes @@ -85,21 +85,17 @@ namespace CppSharp.Passes
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
{
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;
}
Name = "Item",
QualifiedType = @operator.ReturnType,
Access = @operator.Access,
Namespace = @class,
GetMethod = @operator
};
property.Parameters.AddRange(@operator.Parameters);
@class.Properties.Add(property);
@operator.IsGenerated = false;
}
static void HandleMissingOperatorOverloadPair(Class @class, CXXOperatorKind op1,

Loading…
Cancel
Save