Browse Source

Merge pull request #339 from ddobrev/master

Improved the advanced property pass to avoid a crash and generate more properties
pull/341/head
João Matos 11 years ago
parent
commit
7b9f10b4ae
  1. 3
      src/AST/Function.cs
  2. 5
      src/AST/Property.cs
  3. 2
      src/Generator/Passes/CleanInvalidDeclNamesPass.cs
  4. 7
      src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs
  5. 6
      src/Generator/Passes/MultipleInheritancePass.cs
  6. 10
      tests/Basic/Basic.h

3
src/AST/Function.cs

@ -93,7 +93,8 @@ namespace CppSharp.AST @@ -93,7 +93,8 @@ namespace CppSharp.AST
None,
ComplementOperator,
AbstractImplCall,
DefaultValueOverload
DefaultValueOverload,
InterfaceInstance
}
public class Function : Declaration, ITypedDecl, IMangledDecl

5
src/AST/Property.cs

@ -115,6 +115,11 @@ namespace CppSharp.AST @@ -115,6 +115,11 @@ namespace CppSharp.AST
}
}
public bool IsSynthetized
{
get { return GetMethod != null && GetMethod.IsSynthetized; }
}
public override T Visit<T>(IDeclVisitor<T> visitor)
{
return visitor.VisitProperty(this);

2
src/Generator/Passes/CleanInvalidDeclNamesPass.cs

@ -35,7 +35,7 @@ namespace CppSharp.Passes @@ -35,7 +35,7 @@ namespace CppSharp.Passes
// types with empty names are assumed to be private
if (decl is Class && string.IsNullOrWhiteSpace(decl.Name))
{
decl.Name = "_";
decl.Name = decl.Namespace.Name == "_" ? "__" : "_";
decl.ExplicitlyIgnore();
return false;
}

7
src/Generator/Passes/GetterSetterToPropertyAdvancedPass.cs

@ -271,17 +271,14 @@ namespace CppSharp.Passes @@ -271,17 +271,14 @@ namespace CppSharp.Passes
public GetterSetterToPropertyAdvancedPass()
{
Options.VisitClassProperties = false;
Options.VisitFunctionParameters = false;
}
public override bool VisitClassDecl(Class @class)
{
if (!AlreadyVisited(@class))
if (base.VisitClassDecl(@class))
{
bool result = base.VisitClassDecl(@class);
new PropertyGenerator(@class, Log).GenerateProperties();
return result;
}
return false;
}

6
src/Generator/Passes/MultipleInheritancePass.cs

@ -84,7 +84,11 @@ namespace CppSharp.Passes @@ -84,7 +84,11 @@ namespace CppSharp.Passes
instance.Namespace = @interface;
instance.Name = Helpers.InstanceIdentifier;
instance.QualifiedType = new QualifiedType(new BuiltinType(PrimitiveType.IntPtr));
instance.GetMethod = new Method { Namespace = @interface };
instance.GetMethod = new Method
{
SynthKind = FunctionSynthKind.InterfaceInstance,
Namespace = @interface
};
@interface.Properties.Add(instance);
}

10
tests/Basic/Basic.h

@ -561,3 +561,13 @@ public: @@ -561,3 +561,13 @@ public:
};
DLL_API void va_listFunction(va_list v);
struct DLL_API TestEmptyName
{
struct
{
struct
{
};
};
};

Loading…
Cancel
Save