mirror of https://github.com/mono/CppSharp.git
Browse Source
This allows custom passes to add other specialisations to support. Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>pull/696/head
24 changed files with 928 additions and 220 deletions
@ -1,4 +1,61 @@
@@ -1,4 +1,61 @@
|
||||
#include <string> |
||||
|
||||
template class __declspec(dllexport) std::basic_string<char, std::char_traits<char>, std::allocator<char>>; |
||||
template class __declspec(dllexport) __gnu_cxx::__add_unsigned<bool>; |
||||
template class __declspec(dllexport) __gnu_cxx::__add_unsigned<wchar_t>; |
||||
template class __declspec(dllexport) __gnu_cxx::__remove_unsigned<bool>; |
||||
template class __declspec(dllexport) __gnu_cxx::__remove_unsigned<wchar_t>; |
||||
template class __declspec(dllexport) std::make_unsigned<bool>; |
||||
template class __declspec(dllexport) std::make_signed<bool>; |
||||
template class __declspec(dllexport) std::allocator<void>; |
||||
template class __declspec(dllexport) std::allocator<char>; |
||||
template class __declspec(dllexport) std::initializer_list<bool>; |
||||
template class __declspec(dllexport) std::initializer_list<char>; |
||||
template class __declspec(dllexport) std::initializer_list<wchar_t>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::PreprocessedEntity*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::BlockContentComment*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Parameter*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Declaration*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::FunctionTemplateSpecialization*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::TemplateArgument>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Function*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Template*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::TypedefDecl*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::TypeAlias*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Variable*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Friend*>; |
||||
template class __declspec(dllexport) std::initializer_list<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, CppSharp::CppParser::AST::Declaration*>>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::BaseClassSpecifier*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Field*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Method*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::AccessSpecifierDecl*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::VTableComponent>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::VFTableInfo>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::LayoutField>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::LayoutBase>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Class*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Enumeration::Item*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Enumeration*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Namespace*>; |
||||
template class __declspec(dllexport) std::initializer_list<std::basic_string<char, std::char_traits<char>, std::allocator<char>>>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::ClassTemplateSpecialization*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Expression*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::VarTemplateSpecialization*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::MacroDefinition*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::TranslationUnit*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::InlineContentComment*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::BlockCommandComment::Argument>; |
||||
template class __declspec(dllexport) std::initializer_list<unsigned int>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::VerbatimBlockLineComment*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::InlineCommandComment::Argument>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::HTMLStartTagComment::Attribute>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::ParserDiagnostic>; |
||||
template class __declspec(dllexport) std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, CppSharp::CppParser::AST::Declaration*>>; |
||||
template class __declspec(dllexport) std::char_traits<char>; |
||||
template class __declspec(dllexport) std::char_traits<wchar_t>; |
||||
template class __declspec(dllexport) std::char_traits<char16_t>; |
||||
template class __declspec(dllexport) std::char_traits<char32_t>; |
||||
template class __declspec(dllexport) std::ctype<char>; |
||||
template class __declspec(dllexport) std::ctype<wchar_t>; |
||||
template class __declspec(dllexport) std::codecvt<char, char, __mbstate_t>; |
||||
template class __declspec(dllexport) std::codecvt<wchar_t, char, __mbstate_t>; |
||||
@ -1,4 +1,61 @@
@@ -1,4 +1,61 @@
|
||||
#include <string> |
||||
|
||||
template class __declspec(dllexport) std::basic_string<char, std::char_traits<char>, std::allocator<char>>; |
||||
template class __declspec(dllexport) __gnu_cxx::__add_unsigned<bool>; |
||||
template class __declspec(dllexport) __gnu_cxx::__add_unsigned<wchar_t>; |
||||
template class __declspec(dllexport) __gnu_cxx::__remove_unsigned<bool>; |
||||
template class __declspec(dllexport) __gnu_cxx::__remove_unsigned<wchar_t>; |
||||
template class __declspec(dllexport) std::make_unsigned<bool>; |
||||
template class __declspec(dllexport) std::make_signed<bool>; |
||||
template class __declspec(dllexport) std::allocator<void>; |
||||
template class __declspec(dllexport) std::allocator<char>; |
||||
template class __declspec(dllexport) std::initializer_list<bool>; |
||||
template class __declspec(dllexport) std::initializer_list<char>; |
||||
template class __declspec(dllexport) std::initializer_list<wchar_t>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::PreprocessedEntity*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::BlockContentComment*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Parameter*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Declaration*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::FunctionTemplateSpecialization*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::TemplateArgument>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Function*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Template*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::TypedefDecl*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::TypeAlias*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Variable*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Friend*>; |
||||
template class __declspec(dllexport) std::initializer_list<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, CppSharp::CppParser::AST::Declaration*>>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::BaseClassSpecifier*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Field*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Method*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::AccessSpecifierDecl*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::VTableComponent>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::VFTableInfo>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::LayoutField>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::LayoutBase>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Class*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Enumeration::Item*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Enumeration*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Namespace*>; |
||||
template class __declspec(dllexport) std::initializer_list<std::basic_string<char, std::char_traits<char>, std::allocator<char>>>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::ClassTemplateSpecialization*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::Expression*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::VarTemplateSpecialization*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::MacroDefinition*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::TranslationUnit*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::InlineContentComment*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::BlockCommandComment::Argument>; |
||||
template class __declspec(dllexport) std::initializer_list<unsigned int>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::VerbatimBlockLineComment*>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::InlineCommandComment::Argument>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::AST::HTMLStartTagComment::Attribute>; |
||||
template class __declspec(dllexport) std::initializer_list<CppSharp::CppParser::ParserDiagnostic>; |
||||
template class __declspec(dllexport) std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, CppSharp::CppParser::AST::Declaration*>>; |
||||
template class __declspec(dllexport) std::char_traits<char>; |
||||
template class __declspec(dllexport) std::char_traits<wchar_t>; |
||||
template class __declspec(dllexport) std::char_traits<char16_t>; |
||||
template class __declspec(dllexport) std::char_traits<char32_t>; |
||||
template class __declspec(dllexport) std::ctype<char>; |
||||
template class __declspec(dllexport) std::ctype<wchar_t>; |
||||
template class __declspec(dllexport) std::codecvt<char, char, __mbstate_t>; |
||||
template class __declspec(dllexport) std::codecvt<wchar_t, char, __mbstate_t>; |
||||
@ -0,0 +1,63 @@
@@ -0,0 +1,63 @@
|
||||
using System.Linq; |
||||
using CppSharp.AST; |
||||
using CppSharp.AST.Extensions; |
||||
|
||||
namespace CppSharp.Passes |
||||
{ |
||||
public class MarkSupportedSpecializationsPass : TranslationUnitPass |
||||
{ |
||||
public override bool VisitClassDecl(Class @class) |
||||
{ |
||||
if (!base.VisitClassDecl(@class) || !@class.IsDependent) |
||||
return false; |
||||
|
||||
foreach (var specialization in @class.Specializations) |
||||
{ |
||||
if (IsSupportedStdSpecialization(specialization)) |
||||
{ |
||||
MarkForGeneration(specialization); |
||||
@class.GenerationKind = GenerationKind.Generate; |
||||
} |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
private static bool IsSupportedStdSpecialization(ClassTemplateSpecialization specialization) |
||||
{ |
||||
return IsSupportedStdType(specialization) && |
||||
specialization.Arguments[0].Type.Type.IsPrimitiveType(PrimitiveType.Char); |
||||
} |
||||
|
||||
private static bool IsSupportedStdType(Declaration declaration) |
||||
{ |
||||
return declaration.Namespace != null && |
||||
declaration.TranslationUnit.IsSystemHeader && |
||||
IsNameSpaceStd(declaration.Namespace) && |
||||
supportedStdTypes.Contains(declaration.OriginalName); |
||||
} |
||||
|
||||
private static bool IsNameSpaceStd(DeclarationContext declarationContext) |
||||
{ |
||||
if (declarationContext == null) |
||||
return false; |
||||
var @namespace = declarationContext as Namespace; |
||||
if (@namespace != null && @namespace.IsInline) |
||||
return IsNameSpaceStd(declarationContext.Namespace); |
||||
return declarationContext.OriginalName == "std"; |
||||
} |
||||
|
||||
private static void MarkForGeneration(ClassTemplateSpecialization specialization) |
||||
{ |
||||
specialization.GenerationKind = GenerationKind.Generate; |
||||
Declaration declaration = specialization.TemplatedDecl.TemplatedDecl; |
||||
while (declaration != null) |
||||
{ |
||||
declaration.GenerationKind = GenerationKind.Generate; |
||||
declaration = declaration.Namespace; |
||||
} |
||||
} |
||||
|
||||
private static string[] supportedStdTypes = { "basic_string", "allocator" }; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue