Skip to content

Instantly share code, notes, and snippets.

@tritao
Created December 5, 2013 07:07
Show Gist options
  • Save tritao/7801326 to your computer and use it in GitHub Desktop.
Save tritao/7801326 to your computer and use it in GitHub Desktop.
CppSharp dependent types fix
58bc07661c287b097c4bd99d24ab2387c8057a4c
src/Generator/Generators/CLI/CLIMarshal.cs | 4 ++--
src/Generator/Generators/CSharp/CSharpMarshal.cs | 10 ++++++++++
src/Parser/Parser.cpp | 10 +++-------
3 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/Generator/Generators/CLI/CLIMarshal.cs b/src/Generator/Generators/CLI/CLIMarshal.cs
index 03977ec..ab36a7b 100644
--- a/src/Generator/Generators/CLI/CLIMarshal.cs
+++ b/src/Generator/Generators/CLI/CLIMarshal.cs
@@ -282,7 +282,7 @@ namespace CppSharp.Generators.CLI
public override bool VisitFunctionTemplateDecl(FunctionTemplate template)
{
- throw new NotImplementedException();
+ return template.TemplatedFunction.Visit(this);
}
public override bool VisitMacroDefinition(MacroDefinition macro)
@@ -666,7 +666,7 @@ namespace CppSharp.Generators.CLI
public override bool VisitFunctionTemplateDecl(FunctionTemplate template)
{
- throw new NotImplementedException();
+ return template.TemplatedFunction.Visit(this);
}
public override bool VisitMacroDefinition(MacroDefinition macro)
diff --git a/src/Generator/Generators/CSharp/CSharpMarshal.cs b/src/Generator/Generators/CSharp/CSharpMarshal.cs
index db41846..a7e2e87 100644
--- a/src/Generator/Generators/CSharp/CSharpMarshal.cs
+++ b/src/Generator/Generators/CSharp/CSharpMarshal.cs
@@ -616,6 +616,16 @@ namespace CppSharp.Generators.CSharp
Context.Return.Write(Context.Parameter.Name);
return true;
}
+
+ public override bool VisitClassTemplateDecl(ClassTemplate template)
+ {
+ return VisitClassDecl(template.TemplatedClass);
+ }
+
+ public override bool VisitFunctionTemplateDecl(FunctionTemplate template)
+ {
+ return template.TemplatedFunction.Visit(this);
+ }
}
public static class CSharpMarshalExtensions
diff --git a/src/Parser/Parser.cpp b/src/Parser/Parser.cpp
index 6238022..a5f4f11 100644
--- a/src/Parser/Parser.cpp
+++ b/src/Parser/Parser.cpp
@@ -769,9 +769,6 @@ CppSharp::AST::ClassTemplate^ Parser::WalkClassTemplate(clang::ClassTemplateDecl
using namespace clang;
using namespace clix;
- if (TD->getCanonicalDecl() != TD)
- return WalkClassTemplate(TD->getCanonicalDecl());
-
auto NS = GetNamespace(TD);
assert(NS && "Expected a valid namespace");
@@ -808,9 +805,6 @@ CppSharp::AST::FunctionTemplate^ Parser::WalkFunctionTemplate(clang::FunctionTem
using namespace clang;
using namespace clix;
- if (TD->getCanonicalDecl() != TD)
- return WalkFunctionTemplate(TD->getCanonicalDecl());
-
auto NS = GetNamespace(TD);
assert(NS && "Expected a valid namespace");
@@ -897,7 +891,9 @@ CppSharp::AST::Method^ Parser::WalkMethodCXX(clang::CXXMethodDecl* MD)
return WalkMethodCXX(cast<CXXMethodDecl>(MD->getPrimaryContext()));
auto RD = MD->getParent();
- auto Class = WalkRecordCXX(RD);
+ auto Decl = WalkDeclaration(RD, /*IgnoreSystemDecls=*/false);
+
+ auto Class = safe_cast<CppSharp::AST::Class^>(Decl);
// Check for an already existing method that came from the same declaration.
for each (CppSharp::AST::Method^ Method in Class->Methods)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment