Skip to content

Commit d5ee92b

Browse files
ddobrevtritao
authored andcommitted
Ignore methods with parameters when generating expressions
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent 93cc7ed commit d5ee92b

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

src/CppParser/Bootstrap/Bootstrap.cs

+4-13
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ public void SetupPasses(Driver driver)
7777

7878
public void Preprocess(Driver driver, ASTContext ctx)
7979
{
80-
GenerateProperties(driver.Context, ctx);
80+
new IgnoreMethodsWithParametersPass { Context = driver.Context }
81+
.VisitASTContext(ctx);
82+
new GetterSetterToPropertyPass { Context = driver.Context }
83+
.VisitASTContext(ctx);
8184

8285
var preprocessDecls = new PreprocessDeclarations();
8386
foreach (var unit in ctx.TranslationUnits)
@@ -102,18 +105,6 @@ public void Postprocess(Driver driver, ASTContext ctx)
102105
{
103106
}
104107

105-
private static void GenerateProperties(BindingContext ctx,
106-
ASTContext ast)
107-
{
108-
var propertyPass = new GetterSetterToPropertyPass()
109-
{
110-
Context = ctx
111-
};
112-
113-
foreach (var unit in ast.TranslationUnits)
114-
unit.Visit(propertyPass);
115-
}
116-
117108
public IEnumerable<Class> ExprClasses;
118109

119110
private void GenerateExpr(BindingContext ctx)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using CppSharp.AST;
2+
using CppSharp.AST.Extensions;
3+
using CppSharp.Passes;
4+
using System.Linq;
5+
6+
namespace CppSharp
7+
{
8+
public class IgnoreMethodsWithParametersPass : TranslationUnitPass
9+
{
10+
public override bool VisitMethodDecl(Method method)
11+
{
12+
if (!base.VisitMethodDecl(method))
13+
return false;
14+
15+
if (!method.OriginalReturnType.Type.IsPrimitiveType(PrimitiveType.Void) &&
16+
method.Parameters.Count(
17+
p => p.Kind == ParameterKind.Regular && p.DefaultValue == null) > 0)
18+
method.ExplicitlyIgnore();
19+
20+
return true;
21+
}
22+
}
23+
}

src/CppParser/Bootstrap/premake5.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ project "CppSharp.Parser.Bootstrap"
66
language "C#"
77
debugdir "."
88

9-
files { "Bootstrap.cs", "*.lua" }
9+
files { "*.cs", "*.lua" }
1010
links { "CppSharp", "CppSharp.AST", "CppSharp.Generator", "CppSharp.Parser" }
1111

1212
filter { "action:not netcore" }

0 commit comments

Comments
 (0)