From 8a3f50337ce75b4398ae33db58215c05dcf8437e Mon Sep 17 00:00:00 2001 From: triton Date: Sat, 16 Aug 2014 00:37:56 +0100 Subject: [PATCH] Added an hack for parsing declaration without unique native pointers. We only need this because we're re-using the parameter declaration for function type parameters. --- src/Core/Parser/ASTConverter.cs | 3 +++ src/CppParser/Parser.cpp | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/src/Core/Parser/ASTConverter.cs b/src/Core/Parser/ASTConverter.cs index 4197a82d..85a81819 100644 --- a/src/Core/Parser/ASTConverter.cs +++ b/src/Core/Parser/ASTConverter.cs @@ -698,6 +698,9 @@ namespace CppSharp bool CheckForDuplicates(Declaration decl) { + if (decl.OriginalPtr == (void*) (0x1)) + return false; + return !(decl is PreprocessedEntity); } diff --git a/src/CppParser/Parser.cpp b/src/CppParser/Parser.cpp index bfee41b9..98ac6020 100644 --- a/src/CppParser/Parser.cpp +++ b/src/CppParser/Parser.cpp @@ -44,6 +44,9 @@ using namespace CppSharp::CppParser; +// We use this as a placeholder for pointer values that should be ignored. +void* IgnorePtr = (void*) 0x1; + //-----------------------------------// Parser::Parser(ParserOptions* Opts) : Lib(Opts->ASTContext), Opts(Opts), Index(0) @@ -1746,6 +1749,11 @@ Type* Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, auto Arg = FP->getParamType(i); FA->Name = ""; FA->QualifiedType = GetQualifiedType(Arg, WalkType(Arg)); + + // In this case we have no valid value to use as a pointer so + // use a special value known to the managed side to make sure + // it gets ignored. + FA->OriginalPtr = IgnorePtr; } F->Parameters.push_back(FA); }