diff --git a/src/CppParser/Parser.cpp b/src/CppParser/Parser.cpp index b7d1d895..dd69b553 100644 --- a/src/CppParser/Parser.cpp +++ b/src/CppParser/Parser.cpp @@ -157,6 +157,8 @@ Parser::Parser(CppParserOptions* Opts) { supportedStdTypes.insert("allocator"); supportedStdTypes.insert("basic_string"); + supportedStdTypes.insert("optional"); + supportedStdTypes.insert("vector"); } LayoutField Parser::WalkVTablePointer(Class* Class, @@ -1011,15 +1013,44 @@ bool Parser::IsSupported(const clang::CXXMethodDecl* MD) { using namespace clang; - return !c->getSourceManager().isInSystemHeader(MD->getBeginLoc()) || - (isa(MD) && MD->getNumParams() == 0) || - isa(MD) || - (MD->getDeclName().isIdentifier() && - ((MD->getName() == "data" && MD->getNumParams() == 0 && MD->isConst()) || - (MD->getName() == "assign" && MD->getNumParams() == 1 && - MD->parameters()[0]->getType()->isPointerType())) && - supportedStdTypes.find(MD->getParent()->getName().str()) != - supportedStdTypes.end()); + if (!c->getSourceManager().isInSystemHeader(MD->getBeginLoc())) + return true; + + if (isa(MD)) + return MD->getNumParams() == 0; + + if (isa(MD)) + return true; + + if (!MD->getDeclName().isIdentifier()) + return false; + + if (supportedStdTypes.find(MD->getParent()->getName().str()) == supportedStdTypes.end()) + return false; + + switch (MD->getNumParams()) + { + case 0: + { + if (!MD->isConst()) + return false; + + return MD->getName() == "data" || + MD->getName() == "has_value" || + MD->getName() == "value"; + } + case 1: + { + if (!MD->parameters()[0]->getType()->isPointerType()) + return false; + + return MD->getName() == "assign"; + } + default: + { + return false; + } + } } static RecordArgABI GetRecordArgABI( diff --git a/src/Generator/Passes/IgnoreSystemDeclarationsPass.cs b/src/Generator/Passes/IgnoreSystemDeclarationsPass.cs index 1f0a7bf9..4d46f654 100644 --- a/src/Generator/Passes/IgnoreSystemDeclarationsPass.cs +++ b/src/Generator/Passes/IgnoreSystemDeclarationsPass.cs @@ -44,12 +44,25 @@ namespace CppSharp.Passes case "basic_string": case "allocator": case "char_traits": + @class.GenerationKind = GenerationKind.Generate; + foreach (var specialization in from s in @class.Specializations + where !s.Arguments.Any(a => + s.UnsupportedTemplateArgument(a, Context.TypeMaps)) + let arg = s.Arguments[0].Type.Type.Desugar() + where arg.IsPrimitiveType(PrimitiveType.Char) + select s) + { + specialization.GenerationKind = GenerationKind.Generate; + InternalizeSpecializationsInFields(specialization); + } + break; + + case "optional": + case "vector": @class.GenerationKind = GenerationKind.Generate; foreach (var specialization in from s in @class.Specializations where !s.Arguments.Any(a => s.UnsupportedTemplateArgument(a, Context.TypeMaps)) - let arg = s.Arguments[0].Type.Type.Desugar() - where arg.IsPrimitiveType(PrimitiveType.Char) select s) { specialization.GenerationKind = GenerationKind.Generate; diff --git a/src/Generator/Passes/SymbolsCodeGenerator.cs b/src/Generator/Passes/SymbolsCodeGenerator.cs index 1b5bf760..397c17f8 100644 --- a/src/Generator/Passes/SymbolsCodeGenerator.cs +++ b/src/Generator/Passes/SymbolsCodeGenerator.cs @@ -34,6 +34,7 @@ namespace CppSharp.Passes WriteLine("#define _LIBCPP_HIDE_FROM_ABI"); NewLine(); WriteLine("#include "); + WriteLine("#include "); } else foreach (var header in TranslationUnit.Module.Headers)