From 09b5863b5e05f5d1c55ed15d869d0ced177be931 Mon Sep 17 00:00:00 2001 From: triton Date: Sat, 23 Mar 2013 18:05:45 +0000 Subject: [PATCH] Added parsing support for class function templates and added parsing of template parameters. --- src/Bridge/Class.cs | 2 ++ src/Bridge/Template.cs | 1 + src/Parser/Parser.cpp | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/src/Bridge/Class.cs b/src/Bridge/Class.cs index abf0cc25..71ad40a5 100644 --- a/src/Bridge/Class.cs +++ b/src/Bridge/Class.cs @@ -84,6 +84,7 @@ namespace Cxxi public List Methods; public List Variables; public List Events; + public List FunctionTemplates; // True if the record is a POD (Plain Old Data) type. public bool IsPOD; @@ -113,6 +114,7 @@ namespace Cxxi Events = new List(); NestedClasses = new List(); NestedEnums = new List(); + FunctionTemplates = new List(); IsAbstract = false; IsUnion = false; IsOpaque = false; diff --git a/src/Bridge/Template.cs b/src/Bridge/Template.cs index 62a29ab1..5f50f2c9 100644 --- a/src/Bridge/Template.cs +++ b/src/Bridge/Template.cs @@ -12,6 +12,7 @@ namespace Cxxi protected Template(Declaration decl) { TemplatedDecl = decl; + Parameters = new List(); } public Declaration TemplatedDecl; diff --git a/src/Parser/Parser.cpp b/src/Parser/Parser.cpp index 5bcea862..4750811d 100644 --- a/src/Parser/Parser.cpp +++ b/src/Parser/Parser.cpp @@ -389,6 +389,17 @@ Cxxi::Class^ Parser::WalkRecordCXX(clang::CXXRecordDecl* Record, bool IsDependen RC->Variables->Add(Var); } + // Iterate through the record function template methods. + for(auto it = Record->decls_begin(); it != Record->decls_end(); ++it) + { + auto Decl = *it; + if (!isa(Decl)) continue; + + Cxxi::FunctionTemplate^ FT = WalkFunctionTemplate( + cast(Decl)); + RC->FunctionTemplates->Add(FT); + } + // Iterate through the record bases. for(auto it = Record->bases_begin(); it != Record->bases_end(); ++it) { @@ -435,6 +446,17 @@ Cxxi::FunctionTemplate^ Parser::WalkFunctionTemplate(clang::FunctionTemplateDecl /*AddToNamespace=*/false); Cxxi::FunctionTemplate^ FT = gcnew Cxxi::FunctionTemplate(Function); + auto TPL = TD->getTemplateParameters(); + for(auto it = TPL->begin(); it != TPL->end(); ++it) + { + auto ND = *it; + + auto TP = Cxxi::TemplateParameter(); + TP.Name = clix::marshalString(ND->getNameAsString()); + + FT->Parameters->Add(TP); + } + return FT; }