From 8afb0acd19808132eb391767379603d7724430ea Mon Sep 17 00:00:00 2001 From: triton Date: Tue, 8 Oct 2013 01:29:00 +0100 Subject: [PATCH] Added Signature property to functions that provide the original function signature as accurately as possible from the original source. --- src/AST/Function.cs | 4 +++- src/Parser/Parser.cpp | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/AST/Function.cs b/src/AST/Function.cs index f9dba774..60ef944c 100644 --- a/src/AST/Function.cs +++ b/src/AST/Function.cs @@ -168,7 +168,9 @@ namespace CppSharp.AST public Function OriginalFunction { get; set; } public string Mangled { get; set; } - + + public string Signature { get; set; } + public override T Visit(IDeclVisitor visitor) { return visitor.VisitFunctionDecl(this); diff --git a/src/Parser/Parser.cpp b/src/Parser/Parser.cpp index 2d428e5e..e85b3ea5 100644 --- a/src/Parser/Parser.cpp +++ b/src/Parser/Parser.cpp @@ -1574,8 +1574,17 @@ void Parser::WalkFunction(clang::FunctionDecl* FD, CppSharp::AST::Function^ F, assert (!FTInfo.isNull()); ParamStartLoc = FTInfo.getRParenLoc(); + ResultLoc = FTInfo.getResultLoc().getLocStart(); } + clang::SourceRange Range(FD->getLocStart(), ParamStartLoc); + if (ResultLoc.isValid()) + Range.setBegin(ResultLoc); + + std::string Sig; + if (GetDeclText(Range, Sig)) + F->Signature = clix::marshalString(Sig); + for(auto it = FD->param_begin(); it != FD->param_end(); ++it) { ParmVarDecl* VD = (*it);