Browse Source

Merge pull request #303 from tomspilman/macrofix

Fixed Macro Parsing
pull/300/merge
João Matos 11 years ago
parent
commit
06c81a26a8
  1. 6
      src/CppParser/Parser.cpp
  2. 9
      tests/Basic/Basic.cs

6
src/CppParser/Parser.cpp

@ -2142,6 +2142,7 @@ void Parser::WalkFunction(clang::FunctionDecl* FD, Function* F, @@ -2142,6 +2142,7 @@ void Parser::WalkFunction(clang::FunctionDecl* FD, Function* F,
F->Mangled = Mangled;
clang::SourceLocation ParamStartLoc = FD->getLocStart();
clang::SourceLocation ParamEndLoc = FD->getLocEnd();
clang::SourceLocation ResultLoc;
auto FTSI = FD->getTypeSourceInfo();
@ -2156,12 +2157,13 @@ void Parser::WalkFunction(clang::FunctionDecl* FD, Function* F, @@ -2156,12 +2157,13 @@ void Parser::WalkFunction(clang::FunctionDecl* FD, Function* F,
auto FTInfo = FTL.castAs<FunctionTypeLoc>();
assert (!FTInfo.isNull());
ParamStartLoc = FTInfo.getRParenLoc();
ParamStartLoc = FTInfo.getLParenLoc();
ParamEndLoc = FTInfo.getRParenLoc();
ResultLoc = FTInfo.getReturnLoc().getLocStart();
}
}
clang::SourceRange Range(FD->getLocStart(), ParamStartLoc);
clang::SourceRange Range(FD->getLocStart(), ParamEndLoc);
if (ResultLoc.isValid())
Range.setBegin(ResultLoc);

9
tests/Basic/Basic.cs

@ -27,16 +27,9 @@ namespace CppSharp.Tests @@ -27,16 +27,9 @@ namespace CppSharp.Tests
public override void Preprocess(Driver driver, ASTContext ctx)
{
driver.AddTranslationUnitPass(new GetterSetterToPropertyPass());
driver.AddTranslationUnitPass(new CheckMacroPass());
ctx.SetClassAsValueType("Bar");
ctx.SetClassAsValueType("Bar2");
ctx.SetMethodParameterUsage("Hello", "TestPrimitiveOut", 1, ParameterUsage.Out);
ctx.SetMethodParameterUsage("Hello", "TestPrimitiveOutRef", 1, ParameterUsage.Out);
ctx.SetMethodParameterUsage("Hello", "TestPrimitiveInOut", 1, ParameterUsage.InOut);
ctx.SetMethodParameterUsage("Hello", "TestPrimitiveInOutRef", 1, ParameterUsage.InOut);
ctx.SetMethodParameterUsage("Hello", "EnumOut", 2, ParameterUsage.Out);
ctx.SetMethodParameterUsage("Hello", "EnumOutRef", 2, ParameterUsage.Out);
ctx.SetMethodParameterUsage("Hello", "EnumInOut", 1, ParameterUsage.InOut);
ctx.SetMethodParameterUsage("Hello", "EnumInOutRef", 1, ParameterUsage.InOut);
}
public static void Main(string[] args)

Loading…
Cancel
Save