Browse Source

Remove `std::string` from the native Clang AST.

pull/1879/head
Joao Matos 2 years ago
parent
commit
0897119de9
  1. 98
      src/CppParser/AST.cpp
  2. 24
      src/CppParser/AST.h
  3. 1291
      src/CppParser/Bindings/CSharp/arm64-apple-darwin/CppSharp.CppParser.cs
  4. 14
      src/CppParser/Bindings/CSharp/arm64-apple-darwin/Std.cs
  5. 1291
      src/CppParser/Bindings/CSharp/i686-apple-darwin/CppSharp.CppParser.cs
  6. 14
      src/CppParser/Bindings/CSharp/i686-apple-darwin/Std.cs
  7. 1291
      src/CppParser/Bindings/CSharp/x86_64-apple-darwin/CppSharp.CppParser.cs
  8. 14
      src/CppParser/Bindings/CSharp/x86_64-apple-darwin/Std.cs
  9. 1295
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs
  10. 1293
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs
  11. 22
      src/CppParser/Comments.cpp
  12. 16
      src/CppParser/CppParser.cpp
  13. 20
      src/CppParser/CppParser.h
  14. 54
      src/CppParser/Decl.h
  15. 7
      src/CppParser/Expr.cpp
  16. 9
      src/CppParser/Expr.h
  17. 10
      src/CppParser/Helpers.h
  18. 2
      src/CppParser/Link.cpp
  19. 10
      src/CppParser/ParseExpr.cpp
  20. 2
      src/CppParser/ParseStmt.cpp
  21. 106
      src/CppParser/Parser.cpp
  22. 6
      src/CppParser/Parser.h
  23. 38
      src/CppParser/ParserGen/ParserGen.cs
  24. 4
      src/CppParser/Stmt.cpp
  25. 4
      src/CppParser/Stmt.h
  26. 3
      src/CppParser/Target.h
  27. 2
      src/CppParser/Types.h

98
src/CppParser/AST.cpp

@ -214,6 +214,8 @@ DependentNameType::DependentNameType() : Type(TypeKind::DependentName) {} @@ -214,6 +214,8 @@ DependentNameType::DependentNameType() : Type(TypeKind::DependentName) {}
DependentNameType::~DependentNameType() {}
DEF_STRING(DependentNameType, Identifier)
PackExpansionType::PackExpansionType() : Type(TypeKind::PackExpansion) {}
UnaryTransformType::UnaryTransformType() : Type(TypeKind::UnaryTransform) {}
@ -242,7 +244,7 @@ LayoutField::LayoutField() : offset(0), fieldPtr(0) {} @@ -242,7 +244,7 @@ LayoutField::LayoutField() : offset(0), fieldPtr(0) {}
LayoutField::LayoutField(const LayoutField & other)
: offset(other.offset)
, name(other.name)
, Name(other.Name)
, qualifiedType(other.qualifiedType)
, fieldPtr(other.fieldPtr)
{
@ -250,6 +252,8 @@ LayoutField::LayoutField(const LayoutField & other) @@ -250,6 +252,8 @@ LayoutField::LayoutField(const LayoutField & other)
LayoutField::~LayoutField() {}
DEF_STRING(LayoutField, Name)
LayoutBase::LayoutBase() : offset(0), _class(0) {}
LayoutBase::LayoutBase(const LayoutBase& other) : offset(other.offset), _class(other._class) {}
@ -293,9 +297,9 @@ Declaration::Declaration(const Declaration& rhs) @@ -293,9 +297,9 @@ Declaration::Declaration(const Declaration& rhs)
, location(rhs.location.ID)
, lineNumberStart(rhs.lineNumberStart)
, lineNumberEnd(rhs.lineNumberEnd)
, name(rhs.name)
, Name(rhs.Name)
, comment(rhs.comment)
, debugText(rhs.debugText)
, DebugText(rhs.DebugText)
, isIncomplete(rhs.isIncomplete)
, isDependent(rhs.isDependent)
, isImplicit(rhs.isImplicit)
@ -312,6 +316,9 @@ Declaration::~Declaration() @@ -312,6 +316,9 @@ Declaration::~Declaration()
{
}
DEF_STRING(Declaration, Name)
DEF_STRING(Declaration, USR)
DEF_STRING(Declaration, DebugText)
DEF_VECTOR(Declaration, PreprocessedEntity*, PreprocessedEntities)
DEF_VECTOR(Declaration, Declaration*, Redeclarations)
@ -353,7 +360,7 @@ DeclarationContext::FindNamespace(const std::vector<std::string>& Namespaces) @@ -353,7 +360,7 @@ DeclarationContext::FindNamespace(const std::vector<std::string>& Namespaces)
auto childNamespace = std::find_if(currentNamespace->Namespaces.begin(),
currentNamespace->Namespaces.end(),
[&](CppSharp::CppParser::AST::Namespace* ns) {
return ns->name == _namespace;
return ns->Name == _namespace;
});
if (childNamespace == currentNamespace->Namespaces.end())
@ -372,7 +379,7 @@ Namespace* DeclarationContext::FindCreateNamespace(const std::string& Name) @@ -372,7 +379,7 @@ Namespace* DeclarationContext::FindCreateNamespace(const std::string& Name)
if (!_namespace)
{
_namespace = new Namespace();
_namespace->name = Name;
_namespace->Name = Name;
_namespace->_namespace = this;
Namespaces.push_back(_namespace);
@ -393,7 +400,7 @@ Class* DeclarationContext::FindClass(const void* OriginalPtr, @@ -393,7 +400,7 @@ Class* DeclarationContext::FindClass(const void* OriginalPtr,
auto _class = std::find_if(Classes.begin(), Classes.end(),
[OriginalPtr, Name, IsComplete](Class* klass) {
return (OriginalPtr && klass->originalPtr == OriginalPtr) ||
(klass->name == Name && klass->isIncomplete == !IsComplete); });
(klass->Name == Name && klass->isIncomplete == !IsComplete); });
return _class != Classes.end() ? *_class : nullptr;
}
@ -413,7 +420,7 @@ Class* DeclarationContext::FindClass(const void* OriginalPtr, @@ -413,7 +420,7 @@ Class* DeclarationContext::FindClass(const void* OriginalPtr,
Class* DeclarationContext::CreateClass(const std::string& Name, bool IsComplete)
{
auto _class = new Class();
_class->name = Name;
_class->Name = Name;
_class->_namespace = this;
_class->isIncomplete = !IsComplete;
@ -457,7 +464,7 @@ Enumeration* DeclarationContext::FindEnum(const std::string& Name, bool Create) @@ -457,7 +464,7 @@ Enumeration* DeclarationContext::FindEnum(const std::string& Name, bool Create)
if (entries.size() == 1)
{
auto foundEnum = std::find_if(Enums.begin(), Enums.end(),
[&](Enumeration* _enum) { return _enum->name == Name; });
[&](Enumeration* _enum) { return _enum->Name == Name; });
if (foundEnum != Enums.end())
return *foundEnum;
@ -466,7 +473,7 @@ Enumeration* DeclarationContext::FindEnum(const std::string& Name, bool Create) @@ -466,7 +473,7 @@ Enumeration* DeclarationContext::FindEnum(const std::string& Name, bool Create)
return nullptr;
auto _enum = new Enumeration();
_enum->name = Name;
_enum->Name = Name;
_enum->_namespace = this;
Enums.push_back(_enum);
return _enum;
@ -525,7 +532,7 @@ Function* DeclarationContext::FindFunction(const std::string& USR) @@ -525,7 +532,7 @@ Function* DeclarationContext::FindFunction(const std::string& USR)
TypedefDecl* DeclarationContext::FindTypedef(const std::string& Name, bool Create)
{
auto foundTypedef = std::find_if(Typedefs.begin(), Typedefs.end(),
[&](TypedefDecl* tdef) { return tdef->name == Name; });
[&](TypedefDecl* tdef) { return tdef->Name == Name; });
if (foundTypedef != Typedefs.end())
return *foundTypedef;
@ -534,7 +541,7 @@ TypedefDecl* DeclarationContext::FindTypedef(const std::string& Name, bool Creat @@ -534,7 +541,7 @@ TypedefDecl* DeclarationContext::FindTypedef(const std::string& Name, bool Creat
return nullptr;
auto tdef = new TypedefDecl();
tdef->name = Name;
tdef->Name = Name;
tdef->_namespace = this;
return tdef;
@ -543,7 +550,7 @@ TypedefDecl* DeclarationContext::FindTypedef(const std::string& Name, bool Creat @@ -543,7 +550,7 @@ TypedefDecl* DeclarationContext::FindTypedef(const std::string& Name, bool Creat
TypeAlias* DeclarationContext::FindTypeAlias(const std::string& Name, bool Create)
{
auto foundTypeAlias = std::find_if(TypeAliases.begin(), TypeAliases.end(),
[&](TypeAlias* talias) { return talias->name == Name; });
[&](TypeAlias* talias) { return talias->Name == Name; });
if (foundTypeAlias != TypeAliases.end())
return *foundTypeAlias;
@ -552,7 +559,7 @@ TypeAlias* DeclarationContext::FindTypeAlias(const std::string& Name, bool Creat @@ -552,7 +559,7 @@ TypeAlias* DeclarationContext::FindTypeAlias(const std::string& Name, bool Creat
return nullptr;
auto talias = new TypeAlias();
talias->name = Name;
talias->Name = Name;
talias->_namespace = this;
return talias;
@ -596,13 +603,17 @@ Friend::Friend() : CppSharp::CppParser::AST::Declaration(DeclarationKind::Friend @@ -596,13 +603,17 @@ Friend::Friend() : CppSharp::CppParser::AST::Declaration(DeclarationKind::Friend
Friend::~Friend() {}
StatementObsolete::StatementObsolete(const std::string& str, StatementClassObsolete stmtClass, Declaration* decl) : string(str), _class(stmtClass), decl(decl) {}
DEF_STRING(StatementObsolete, String)
StatementObsolete::StatementObsolete(const std::string& str, StatementClassObsolete stmtClass, Declaration* decl) : String(str), _class(stmtClass), decl(decl) {}
ExpressionObsolete::ExpressionObsolete(const std::string& str, StatementClassObsolete stmtClass, Declaration* decl)
: StatementObsolete(str, stmtClass, decl) {}
DEF_STRING(BinaryOperatorObsolete, OpcodeStr)
BinaryOperatorObsolete::BinaryOperatorObsolete(const std::string& str, ExpressionObsolete* lhs, ExpressionObsolete* rhs, const std::string& opcodeStr)
: ExpressionObsolete(str, StatementClassObsolete::BinaryOperator), LHS(lhs), RHS(rhs), opcodeStr(opcodeStr) {}
: ExpressionObsolete(str, StatementClassObsolete::BinaryOperator), LHS(lhs), RHS(rhs), OpcodeStr(opcodeStr) {}
BinaryOperatorObsolete::~BinaryOperatorObsolete()
{
@ -610,7 +621,6 @@ BinaryOperatorObsolete::~BinaryOperatorObsolete() @@ -610,7 +621,6 @@ BinaryOperatorObsolete::~BinaryOperatorObsolete()
deleteExpression(RHS);
}
CallExprObsolete::CallExprObsolete(const std::string& str, Declaration* decl)
: ExpressionObsolete(str, StatementClassObsolete::CallExprClass, decl) {}
@ -666,6 +676,10 @@ Function::Function() @@ -666,6 +676,10 @@ Function::Function()
}
Function::~Function() {}
DEF_STRING(Function, Mangled)
DEF_STRING(Function, Signature)
DEF_STRING(Function, Body)
DEF_VECTOR(Function, Parameter*, Parameters)
Method::Method()
@ -699,14 +713,16 @@ DEF_VECTOR(Enumeration, Enumeration::Item*, Items) @@ -699,14 +713,16 @@ DEF_VECTOR(Enumeration, Enumeration::Item*, Items)
Enumeration::Item::Item() : Declaration(DeclarationKind::EnumerationItem) {}
Enumeration::Item::Item(const Item& rhs) : Declaration(rhs),
expression(rhs.expression), value(rhs.value) {}
Expression(rhs.Expression), value(rhs.value) {}
Enumeration::Item::~Item() {}
DEF_STRING(Enumeration::Item, Expression)
Enumeration::Item* Enumeration::FindItemByName(const std::string& Name)
{
auto foundEnumItem = std::find_if(Items.begin(), Items.end(),
[&](Item* _item) { return _item->name == Name; });
[&](Item* _item) { return _item->Name == Name; });
if (foundEnumItem != Items.end())
return *foundEnumItem;
return nullptr;
@ -717,6 +733,8 @@ Variable::Variable() : Declaration(DeclarationKind::Variable), @@ -717,6 +733,8 @@ Variable::Variable() : Declaration(DeclarationKind::Variable),
Variable::~Variable() {}
DEF_STRING(Variable, Mangled)
BaseClassSpecifier::BaseClassSpecifier() : type(0), offset(0) {}
Field::Field() : Declaration(DeclarationKind::Field), _class(0),
@ -891,13 +909,21 @@ MacroDefinition::MacroDefinition() @@ -891,13 +909,21 @@ MacroDefinition::MacroDefinition()
MacroDefinition::~MacroDefinition() {}
DEF_STRING(MacroDefinition, Name)
DEF_STRING(MacroDefinition, Expression)
MacroExpansion::MacroExpansion() : definition(0) { kind = DeclarationKind::MacroExpansion; }
MacroExpansion::~MacroExpansion() {}
DEF_STRING(MacroExpansion, Name)
DEF_STRING(MacroExpansion, Text)
TranslationUnit::TranslationUnit() { kind = DeclarationKind::TranslationUnit; }
TranslationUnit::~TranslationUnit() {}
DEF_STRING(TranslationUnit, FileName)
DEF_VECTOR(TranslationUnit, MacroDefinition*, Macros)
NativeLibrary::NativeLibrary()
@ -906,6 +932,7 @@ NativeLibrary::NativeLibrary() @@ -906,6 +932,7 @@ NativeLibrary::NativeLibrary()
NativeLibrary::~NativeLibrary() {}
// NativeLibrary
DEF_STRING(NativeLibrary, FileName)
DEF_VECTOR_STRING(NativeLibrary, Symbols)
DEF_VECTOR_STRING(NativeLibrary, Dependencies)
@ -941,14 +968,14 @@ TranslationUnit* ASTContext::FindOrCreateModule(std::string File) @@ -941,14 +968,14 @@ TranslationUnit* ASTContext::FindOrCreateModule(std::string File)
auto existingUnit = std::find_if(TranslationUnits.begin(),
TranslationUnits.end(), [&](TranslationUnit* unit) {
return unit && unit->fileName == normalizedFile;
return unit && unit->FileName == normalizedFile;
});
if (existingUnit != TranslationUnits.end())
return *existingUnit;
auto unit = new TranslationUnit();
unit->fileName = normalizedFile;
unit->FileName = normalizedFile;
TranslationUnits.push_back(unit);
return unit;
@ -957,6 +984,9 @@ TranslationUnit* ASTContext::FindOrCreateModule(std::string File) @@ -957,6 +984,9 @@ TranslationUnit* ASTContext::FindOrCreateModule(std::string File)
// Comments
Comment::Comment(CommentKind kind) : kind(kind) {}
DEF_STRING(RawComment, Text)
DEF_STRING(RawComment, BriefText)
RawComment::RawComment() : fullCommentBlock(0) {}
RawComment::~RawComment()
@ -1007,10 +1037,12 @@ BlockContentComment::BlockContentComment(CommentKind Kind) : Comment(Kind) {} @@ -1007,10 +1037,12 @@ BlockContentComment::BlockContentComment(CommentKind Kind) : Comment(Kind) {}
BlockCommandComment::Argument::Argument() {}
BlockCommandComment::Argument::Argument(const Argument& rhs) : text(rhs.text) {}
BlockCommandComment::Argument::Argument(const Argument& rhs) : Text(rhs.Text) {}
BlockCommandComment::Argument::~Argument() {}
DEF_STRING(BlockCommandComment::Argument, Text)
BlockCommandComment::BlockCommandComment() : BlockContentComment(CommentKind::BlockCommandComment), commandId(0), paragraphComment(0) {}
BlockCommandComment::BlockCommandComment(CommentKind Kind) : BlockContentComment(Kind), commandId(0), paragraphComment(0) {}
@ -1028,6 +1060,8 @@ TParamCommandComment::TParamCommandComment() : BlockCommandComment(CommentKind:: @@ -1028,6 +1060,8 @@ TParamCommandComment::TParamCommandComment() : BlockCommandComment(CommentKind::
DEF_VECTOR(TParamCommandComment, unsigned, Position)
DEF_STRING(VerbatimBlockLineComment, Text)
VerbatimBlockComment::VerbatimBlockComment() : BlockCommandComment(CommentKind::VerbatimBlockComment) {}
VerbatimBlockComment::~VerbatimBlockComment()
@ -1036,10 +1070,14 @@ VerbatimBlockComment::~VerbatimBlockComment() @@ -1036,10 +1070,14 @@ VerbatimBlockComment::~VerbatimBlockComment()
delete line;
}
VerbatimBlockLineComment::VerbatimBlockLineComment() : Comment(CommentKind::VerbatimBlockLineComment) {}
DEF_VECTOR(VerbatimBlockComment, VerbatimBlockLineComment*, Lines)
VerbatimLineComment::VerbatimLineComment() : BlockCommandComment(CommentKind::VerbatimLineComment) {}
DEF_STRING(VerbatimLineComment, Text)
ParagraphComment::ParagraphComment() : BlockContentComment(CommentKind::ParagraphComment), isWhitespace(false) {}
ParagraphComment::~ParagraphComment()
@ -1079,7 +1117,11 @@ HTMLTagComment::HTMLTagComment(CommentKind Kind) : InlineContentComment(Kind) {} @@ -1079,7 +1117,11 @@ HTMLTagComment::HTMLTagComment(CommentKind Kind) : InlineContentComment(Kind) {}
HTMLStartTagComment::Attribute::Attribute() {}
HTMLStartTagComment::Attribute::Attribute(const Attribute& rhs) : name(rhs.name), value(rhs.value) {}
HTMLStartTagComment::Attribute::Attribute(const Attribute& rhs) : Name(rhs.Name), Value(rhs.Value) {}
DEF_STRING(HTMLStartTagComment::Attribute, Name)
DEF_STRING(HTMLStartTagComment::Attribute, Value)
HTMLStartTagComment::Attribute::~Attribute() {}
@ -1087,17 +1129,25 @@ HTMLStartTagComment::HTMLStartTagComment() : HTMLTagComment(CommentKind::HTMLSta @@ -1087,17 +1129,25 @@ HTMLStartTagComment::HTMLStartTagComment() : HTMLTagComment(CommentKind::HTMLSta
DEF_VECTOR(HTMLStartTagComment, HTMLStartTagComment::Attribute, Attributes)
DEF_STRING(HTMLStartTagComment, TagName)
HTMLEndTagComment::HTMLEndTagComment() : HTMLTagComment(CommentKind::HTMLEndTagComment) {}
DEF_STRING(HTMLEndTagComment, TagName)
InlineContentComment::InlineContentComment() : Comment(CommentKind::InlineContentComment), hasTrailingNewline(false) {}
InlineContentComment::InlineContentComment(CommentKind Kind) : Comment(Kind), hasTrailingNewline(false) {}
TextComment::TextComment() : InlineContentComment(CommentKind::TextComment) {}
DEF_STRING(TextComment, Text)
InlineCommandComment::Argument::Argument() {}
InlineCommandComment::Argument::Argument(const Argument& rhs) : text(rhs.text) {}
InlineCommandComment::Argument::Argument(const Argument& rhs) : Text(rhs.Text) {}
DEF_STRING(InlineCommandComment::Argument, Text)
InlineCommandComment::Argument::~Argument() {}
@ -1106,6 +1156,4 @@ InlineCommandComment::InlineCommandComment() @@ -1106,6 +1156,4 @@ InlineCommandComment::InlineCommandComment()
DEF_VECTOR(InlineCommandComment, InlineCommandComment::Argument, Arguments)
VerbatimBlockLineComment::VerbatimBlockLineComment() : Comment(CommentKind::VerbatimBlockLineComment) {}
} } }

24
src/CppParser/AST.h

@ -31,7 +31,7 @@ class CS_API NativeLibrary @@ -31,7 +31,7 @@ class CS_API NativeLibrary
public:
NativeLibrary();
~NativeLibrary();
std::string fileName;
STRING(FileName)
ArchType archType;
VECTOR_STRING(Symbols)
VECTOR_STRING(Dependencies)
@ -108,7 +108,7 @@ public: @@ -108,7 +108,7 @@ public:
Argument();
Argument(const Argument&);
~Argument();
std::string text;
STRING(Text)
};
BlockCommandComment();
BlockCommandComment(CommentKind Kind);
@ -143,7 +143,7 @@ class CS_API VerbatimBlockLineComment : public Comment @@ -143,7 +143,7 @@ class CS_API VerbatimBlockLineComment : public Comment
{
public:
VerbatimBlockLineComment();
std::string text;
STRING(Text)
};
class CS_API VerbatimBlockComment : public BlockCommandComment
@ -158,7 +158,7 @@ class CS_API VerbatimLineComment : public BlockCommandComment @@ -158,7 +158,7 @@ class CS_API VerbatimLineComment : public BlockCommandComment
{
public:
VerbatimLineComment();
std::string text;
STRING(Text)
};
class CS_API InlineCommandComment : public InlineContentComment
@ -178,7 +178,7 @@ public: @@ -178,7 +178,7 @@ public:
Argument();
Argument(const Argument&);
~Argument();
std::string text;
STRING(Text)
};
InlineCommandComment();
unsigned commandId;
@ -202,11 +202,11 @@ public: @@ -202,11 +202,11 @@ public:
Attribute();
Attribute(const Attribute&);
~Attribute();
std::string name;
std::string value;
STRING(Name)
STRING(Value)
};
HTMLStartTagComment();
std::string tagName;
STRING(TagName)
VECTOR(Attribute, Attributes)
};
@ -214,14 +214,14 @@ class CS_API HTMLEndTagComment : public HTMLTagComment @@ -214,14 +214,14 @@ class CS_API HTMLEndTagComment : public HTMLTagComment
{
public:
HTMLEndTagComment();
std::string tagName;
STRING(TagName)
};
class CS_API TextComment : public InlineContentComment
{
public:
TextComment();
std::string text;
STRING(Text)
};
enum class RawCommentKind
@ -242,8 +242,8 @@ public: @@ -242,8 +242,8 @@ public:
RawComment();
~RawComment();
RawCommentKind kind;
std::string text;
std::string briefText;
STRING(Text)
STRING(BriefText)
FullComment* fullCommentBlock;
};

1291
src/CppParser/Bindings/CSharp/arm64-apple-darwin/CppSharp.CppParser.cs

File diff suppressed because it is too large Load Diff

14
src/CppParser/Bindings/CSharp/arm64-apple-darwin/Std.cs

@ -310,6 +310,9 @@ namespace Std @@ -310,6 +310,9 @@ namespace Std
[SuppressUnmanagedCodeSecurity, DllImport("Std-symbols", EntryPoint = "_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev", CallingConvention = __CallingConvention.Cdecl)]
internal static extern __IntPtr dtorc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C(__IntPtr __instance);
[SuppressUnmanagedCodeSecurity, DllImport("Std-symbols", EntryPoint = "_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignEPKc", CallingConvention = __CallingConvention.Cdecl)]
internal static extern __IntPtr Assignc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C(__IntPtr __instance, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string __s);
}
namespace Rep
@ -505,21 +508,10 @@ namespace Std @@ -505,21 +508,10 @@ namespace Std
{
public partial struct __Internal
{
[SuppressUnmanagedCodeSecurity, DllImport("Std-symbols", EntryPoint = "_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignEPKc", CallingConvention = __CallingConvention.Cdecl)]
internal static extern __IntPtr Assign(__IntPtr __instance, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string __s);
[SuppressUnmanagedCodeSecurity, DllImport("Std-symbols", EntryPoint = "_ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4dataB8un170006Ev", CallingConvention = __CallingConvention.Cdecl)]
internal static extern __IntPtr Data(__IntPtr __instance);
}
public static global::Std.BasicString<sbyte, global::Std.CharTraits<sbyte>, global::Std.Allocator<sbyte>> Assign(this global::Std.BasicString<sbyte, global::Std.CharTraits<sbyte>, global::Std.Allocator<sbyte>> @this, string __s)
{
var __arg0 = @this is null ? __IntPtr.Zero : @this.__Instance;
var ___ret = __Internal.Assign(__arg0, __s);
var __result0 = global::Std.BasicString<sbyte, global::Std.CharTraits<sbyte>, global::Std.Allocator<sbyte>>.__GetOrCreateInstance(___ret, false);
return __result0;
}
public static string Data(this global::Std.BasicString<sbyte, global::Std.CharTraits<sbyte>, global::Std.Allocator<sbyte>> @this)
{
var __arg0 = @this is null ? __IntPtr.Zero : @this.__Instance;

1291
src/CppParser/Bindings/CSharp/i686-apple-darwin/CppSharp.CppParser.cs

File diff suppressed because it is too large Load Diff

14
src/CppParser/Bindings/CSharp/i686-apple-darwin/Std.cs

@ -310,6 +310,9 @@ namespace Std @@ -310,6 +310,9 @@ namespace Std
[SuppressUnmanagedCodeSecurity, DllImport("Std-symbols", EntryPoint = "_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void dtorc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C(__IntPtr __instance);
[SuppressUnmanagedCodeSecurity, DllImport("Std-symbols", EntryPoint = "_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignEPKc", CallingConvention = __CallingConvention.Cdecl)]
internal static extern __IntPtr Assignc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C(__IntPtr __instance, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string __s);
}
namespace Rep
@ -541,21 +544,10 @@ namespace Std @@ -541,21 +544,10 @@ namespace Std
{
public partial struct __Internal
{
[SuppressUnmanagedCodeSecurity, DllImport("Std-symbols", EntryPoint = "_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignEPKc", CallingConvention = __CallingConvention.Cdecl)]
internal static extern __IntPtr Assign(__IntPtr __instance, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string __s);
[SuppressUnmanagedCodeSecurity, DllImport("Std-symbols", EntryPoint = "_ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4dataB8un170006Ev", CallingConvention = __CallingConvention.Cdecl)]
internal static extern __IntPtr Data(__IntPtr __instance);
}
public static global::Std.BasicString<sbyte, global::Std.CharTraits<sbyte>, global::Std.Allocator<sbyte>> Assign(this global::Std.BasicString<sbyte, global::Std.CharTraits<sbyte>, global::Std.Allocator<sbyte>> @this, string __s)
{
var __arg0 = @this is null ? __IntPtr.Zero : @this.__Instance;
var ___ret = __Internal.Assign(__arg0, __s);
var __result0 = global::Std.BasicString<sbyte, global::Std.CharTraits<sbyte>, global::Std.Allocator<sbyte>>.__GetOrCreateInstance(___ret, false);
return __result0;
}
public static string Data(this global::Std.BasicString<sbyte, global::Std.CharTraits<sbyte>, global::Std.Allocator<sbyte>> @this)
{
var __arg0 = @this is null ? __IntPtr.Zero : @this.__Instance;

1291
src/CppParser/Bindings/CSharp/x86_64-apple-darwin/CppSharp.CppParser.cs

File diff suppressed because it is too large Load Diff

14
src/CppParser/Bindings/CSharp/x86_64-apple-darwin/Std.cs

@ -310,6 +310,9 @@ namespace Std @@ -310,6 +310,9 @@ namespace Std
[SuppressUnmanagedCodeSecurity, DllImport("Std-symbols", EntryPoint = "_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev", CallingConvention = __CallingConvention.Cdecl)]
internal static extern void dtorc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C(__IntPtr __instance);
[SuppressUnmanagedCodeSecurity, DllImport("Std-symbols", EntryPoint = "_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignEPKc", CallingConvention = __CallingConvention.Cdecl)]
internal static extern __IntPtr Assignc__N_std_N___1_S_basic_string__C___N_std_N___1_S_char_traits__C___N_std_N___1_S_allocator__C(__IntPtr __instance, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string __s);
}
namespace Rep
@ -541,21 +544,10 @@ namespace Std @@ -541,21 +544,10 @@ namespace Std
{
public partial struct __Internal
{
[SuppressUnmanagedCodeSecurity, DllImport("Std-symbols", EntryPoint = "_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6assignEPKc", CallingConvention = __CallingConvention.Cdecl)]
internal static extern __IntPtr Assign(__IntPtr __instance, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CppSharp.Runtime.UTF8Marshaller))] string __s);
[SuppressUnmanagedCodeSecurity, DllImport("Std-symbols", EntryPoint = "_ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4dataB8un170006Ev", CallingConvention = __CallingConvention.Cdecl)]
internal static extern __IntPtr Data(__IntPtr __instance);
}
public static global::Std.BasicString<sbyte, global::Std.CharTraits<sbyte>, global::Std.Allocator<sbyte>> Assign(this global::Std.BasicString<sbyte, global::Std.CharTraits<sbyte>, global::Std.Allocator<sbyte>> @this, string __s)
{
var __arg0 = @this is null ? __IntPtr.Zero : @this.__Instance;
var ___ret = __Internal.Assign(__arg0, __s);
var __result0 = global::Std.BasicString<sbyte, global::Std.CharTraits<sbyte>, global::Std.Allocator<sbyte>>.__GetOrCreateInstance(___ret, false);
return __result0;
}
public static string Data(this global::Std.BasicString<sbyte, global::Std.CharTraits<sbyte>, global::Std.Allocator<sbyte>> @this)
{
var __arg0 = @this is null ? __IntPtr.Zero : @this.__Instance;

1295
src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs

File diff suppressed because it is too large Load Diff

1293
src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs

File diff suppressed because it is too large Load Diff

22
src/CppParser/Comments.cpp

@ -41,8 +41,8 @@ RawComment* Parser::WalkRawComment(const clang::RawComment* RC) @@ -41,8 +41,8 @@ RawComment* Parser::WalkRawComment(const clang::RawComment* RC)
auto& SM = c->getSourceManager();
auto Comment = new RawComment();
Comment->kind = ConvertRawCommentKind(RC->getKind());
Comment->text = RC->getRawText(SM).str();
Comment->briefText = RC->getBriefText(c->getASTContext());
Comment->Text = RC->getRawText(SM).str();
Comment->BriefText = RC->getBriefText(c->getASTContext());
return Comment;
}
@ -96,7 +96,7 @@ static void HandleBlockCommand(const clang::comments::BlockCommandComment *CK, @@ -96,7 +96,7 @@ static void HandleBlockCommand(const clang::comments::BlockCommandComment *CK,
for (unsigned I = 0, E = CK->getNumArgs(); I != E; ++I)
{
auto Arg = BlockCommandComment::Argument();
Arg.text = CK->getArgText(I).str();
Arg.Text = CK->getArgText(I).str();
BC->Arguments.push_back(Arg);
}
}
@ -174,7 +174,7 @@ static Comment* ConvertCommentBlock(clang::comments::Comment* C) @@ -174,7 +174,7 @@ static Comment* ConvertCommentBlock(clang::comments::Comment* C)
auto CK = cast<clang::comments::VerbatimLineComment>(C);
auto VL = new VerbatimLineComment();
_Comment = VL;
VL->text = CK->getText().str();
VL->Text = CK->getText().str();
break;
}
case Comment::ParagraphCommentKind:
@ -196,13 +196,13 @@ static Comment* ConvertCommentBlock(clang::comments::Comment* C) @@ -196,13 +196,13 @@ static Comment* ConvertCommentBlock(clang::comments::Comment* C)
auto TC = new HTMLStartTagComment();
_Comment = TC;
HandleInlineContent(CK, TC);
TC->tagName = CK->getTagName().str();
TC->TagName = CK->getTagName().str();
for (unsigned I = 0, E = CK->getNumAttrs(); I != E; ++I)
{
auto A = CK->getAttr(I);
auto Attr = HTMLStartTagComment::Attribute();
Attr.name = A.Name.str();
Attr.value = A.Value.str();
Attr.Name = A.Name.str();
Attr.Value = A.Value.str();
TC->Attributes.push_back(Attr);
}
break;
@ -213,7 +213,7 @@ static Comment* ConvertCommentBlock(clang::comments::Comment* C) @@ -213,7 +213,7 @@ static Comment* ConvertCommentBlock(clang::comments::Comment* C)
auto TC = new HTMLEndTagComment();
_Comment = TC;
HandleInlineContent(CK, TC);
TC->tagName = CK->getTagName().str();
TC->TagName = CK->getTagName().str();
break;
}
case Comment::TextCommentKind:
@ -222,7 +222,7 @@ static Comment* ConvertCommentBlock(clang::comments::Comment* C) @@ -222,7 +222,7 @@ static Comment* ConvertCommentBlock(clang::comments::Comment* C)
auto TC = new TextComment();
_Comment = TC;
HandleInlineContent(CK, TC);
TC->text = CK->getText().str();
TC->Text = CK->getText().str();
break;
}
case Comment::InlineCommandCommentKind:
@ -236,7 +236,7 @@ static Comment* ConvertCommentBlock(clang::comments::Comment* C) @@ -236,7 +236,7 @@ static Comment* ConvertCommentBlock(clang::comments::Comment* C)
for (unsigned I = 0, E = CK->getNumArgs(); I != E; ++I)
{
auto Arg = InlineCommandComment::Argument();
Arg.text = CK->getArgText(I).str();
Arg.Text = CK->getArgText(I).str();
IC->Arguments.push_back(Arg);
}
break;
@ -246,7 +246,7 @@ static Comment* ConvertCommentBlock(clang::comments::Comment* C) @@ -246,7 +246,7 @@ static Comment* ConvertCommentBlock(clang::comments::Comment* C)
auto CK = cast<clang::comments::VerbatimBlockLineComment>(C);
auto VL = new VerbatimBlockLineComment();
_Comment = VL;
VL->text = CK->getText().str();
VL->Text = CK->getText().str();
break;
}
case Comment::NoCommentKind: return nullptr;

16
src/CppParser/CppParser.cpp

@ -23,16 +23,19 @@ CppParserOptions::CppParserOptions() @@ -23,16 +23,19 @@ CppParserOptions::CppParserOptions()
, skipPrivateDeclarations(true)
, skipLayoutInfo(false)
, skipFunctionBodies(true)
, clangVersion(CLANG_VERSION_STRING)
{
}
CppParserOptions::~CppParserOptions() {}
std::string CppParserOptions::getClangVersion() { return clangVersion; }
const char * CppParserOptions::getClangVersion()
{
return CLANG_VERSION_STRING;
}
DEF_VECTOR_STRING(CppParserOptions, Arguments)
DEF_VECTOR_STRING(CppParserOptions, CompilationOptions)
DEF_STRING(CppParserOptions, LibraryFile)
DEF_VECTOR_STRING(CppParserOptions, SourceFiles)
DEF_VECTOR_STRING(CppParserOptions, IncludeDirs)
DEF_VECTOR_STRING(CppParserOptions, SystemIncludeDirs)
@ -40,6 +43,8 @@ DEF_VECTOR_STRING(CppParserOptions, Defines) @@ -40,6 +43,8 @@ DEF_VECTOR_STRING(CppParserOptions, Defines)
DEF_VECTOR_STRING(CppParserOptions, Undefines)
DEF_VECTOR_STRING(CppParserOptions, SupportedStdTypes)
DEF_VECTOR_STRING(CppParserOptions, SupportedFunctionTemplates)
DEF_STRING(CppParserOptions, TargetTriple)
DEF_STRING(ParserTargetInfo, ABI)
ParserResult::ParserResult()
: targetInfo(0)
@ -77,8 +82,8 @@ DEF_VECTOR_STRING(CppLinkerOptions, Libraries) @@ -77,8 +82,8 @@ DEF_VECTOR_STRING(CppLinkerOptions, Libraries)
ParserDiagnostic::ParserDiagnostic() {}
ParserDiagnostic::ParserDiagnostic(const ParserDiagnostic& rhs)
: fileName(rhs.fileName)
, message(rhs.message)
: FileName(rhs.FileName)
, Message(rhs.Message)
, level(rhs.level)
, lineNumber(rhs.lineNumber)
, columnNumber(rhs.columnNumber)
@ -86,4 +91,7 @@ ParserDiagnostic::ParserDiagnostic(const ParserDiagnostic& rhs) @@ -86,4 +91,7 @@ ParserDiagnostic::ParserDiagnostic(const ParserDiagnostic& rhs)
ParserDiagnostic::~ParserDiagnostic() {}
DEF_STRING(ParserDiagnostic, FileName)
DEF_STRING(ParserDiagnostic, Message)
} }

20
src/CppParser/CppParser.h

@ -23,10 +23,12 @@ struct CS_API CppParserOptions @@ -23,10 +23,12 @@ struct CS_API CppParserOptions
CppParserOptions();
~CppParserOptions();
std::string getClangVersion();
static const char * getClangVersion();
VECTOR_STRING(Arguments)
VECTOR_STRING(CompilationOptions)
STRING(LibraryFile)
// C/C++ header file names.
VECTOR_STRING(SourceFiles)
@ -41,7 +43,8 @@ struct CS_API CppParserOptions @@ -41,7 +43,8 @@ struct CS_API CppParserOptions
CppSharp::CppParser::AST::ASTContext* ASTContext;
int toolSetToUse;
std::string targetTriple;
STRING(TargetTriple)
CppAbi abi;
bool noStandardIncludes;
bool noBuiltinIncludes;
@ -51,9 +54,6 @@ struct CS_API CppParserOptions @@ -51,9 +54,6 @@ struct CS_API CppParserOptions
bool skipPrivateDeclarations;
bool skipLayoutInfo;
bool skipFunctionBodies;
private:
std::string clangVersion;
};
struct CS_API CppLinkerOptions
@ -80,8 +80,8 @@ struct CS_API ParserDiagnostic @@ -80,8 +80,8 @@ struct CS_API ParserDiagnostic
ParserDiagnostic();
ParserDiagnostic(const ParserDiagnostic&);
~ParserDiagnostic();
std::string fileName;
std::string message;
STRING(FileName)
STRING(Message)
ParserDiagnosticLevel level { ParserDiagnosticLevel::Ignored };
int lineNumber {0};
int columnNumber {0};
@ -124,10 +124,10 @@ public: @@ -124,10 +124,10 @@ public:
static ParserResult* ParseHeader(CppParserOptions* Opts);
static ParserResult* ParseLibrary(CppLinkerOptions* Opts);
static ParserResult* Build(CppParserOptions* Opts,
const CppLinkerOptions* LinkerOptions, const std::string& File, bool Last);
static ParserResult* Compile(CppParserOptions* Opts, const std::string& File);
const CppLinkerOptions* LinkerOptions, const char * File, bool Last);
static ParserResult* Compile(CppParserOptions* Opts, const char * File);
static ParserResult* Link(CppParserOptions* Opts,
const CppLinkerOptions* LinkerOptions, const std::string& File, bool Last);
const CppLinkerOptions* LinkerOptions, const char * File, bool Last);
};
} }

54
src/CppParser/Decl.h

@ -84,9 +84,9 @@ namespace CppSharp @@ -84,9 +84,9 @@ namespace CppSharp
SourceLocation location;
int lineNumberStart;
int lineNumberEnd;
std::string name;
std::string USR;
std::string debugText;
STRING(Name);
STRING(USR);
STRING(DebugText);
bool isIncomplete;
bool isDependent;
bool isImplicit;
@ -207,16 +207,16 @@ namespace CppSharp @@ -207,16 +207,16 @@ namespace CppSharp
class CS_API StatementObsolete
{
public:
StatementObsolete(const std::string &str, StatementClassObsolete Class = StatementClassObsolete::Any, Declaration *decl = 0);
CS_IGNORE StatementObsolete(const std::string &str, StatementClassObsolete Class = StatementClassObsolete::Any, Declaration *decl = 0);
StatementClassObsolete _class;
Declaration *decl;
std::string string;
STRING(String);
};
class CS_API ExpressionObsolete : public StatementObsolete
{
public:
ExpressionObsolete(const std::string &str, StatementClassObsolete Class = StatementClassObsolete::Any, Declaration *decl = 0);
CS_IGNORE ExpressionObsolete(const std::string &str, StatementClassObsolete Class = StatementClassObsolete::Any, Declaration *decl = 0);
};
class Expr;
@ -224,17 +224,17 @@ namespace CppSharp @@ -224,17 +224,17 @@ namespace CppSharp
class CS_API BinaryOperatorObsolete : public ExpressionObsolete
{
public:
BinaryOperatorObsolete(const std::string &str, ExpressionObsolete *lhs, ExpressionObsolete *rhs, const std::string &opcodeStr);
CS_IGNORE BinaryOperatorObsolete(const std::string &str, ExpressionObsolete *lhs, ExpressionObsolete *rhs, const std::string &opcodeStr);
~BinaryOperatorObsolete();
ExpressionObsolete *LHS;
ExpressionObsolete *RHS;
std::string opcodeStr;
STRING(OpcodeStr);
};
class CS_API CallExprObsolete : public ExpressionObsolete
{
public:
CallExprObsolete(const std::string &str, Declaration *decl);
CS_IGNORE CallExprObsolete(const std::string &str, Declaration *decl);
~CallExprObsolete();
VECTOR(ExpressionObsolete *, Arguments)
};
@ -242,7 +242,7 @@ namespace CppSharp @@ -242,7 +242,7 @@ namespace CppSharp
class CS_API CXXConstructExprObsolete : public ExpressionObsolete
{
public:
CXXConstructExprObsolete(const std::string &str, Declaration *decl = 0);
CS_IGNORE CXXConstructExprObsolete(const std::string &str, Declaration *decl = 0);
~CXXConstructExprObsolete();
VECTOR(ExpressionObsolete *, Arguments)
};
@ -350,9 +350,9 @@ namespace CppSharp @@ -350,9 +350,9 @@ namespace CppSharp
bool isDefaulted;
FriendKind friendKind;
CXXOperatorKind operatorKind;
std::string mangled;
std::string signature;
std::string body;
STRING(Mangled);
STRING(Signature);
STRING(Body);
Stmt *bodyStmt;
CallingConvention callingConvention;
VECTOR(Parameter *, Parameters)
@ -405,7 +405,7 @@ namespace CppSharp @@ -405,7 +405,7 @@ namespace CppSharp
DECLARE_DECL_KIND(Item, EnumerationItem)
Item(const Item &);
~Item();
std::string expression;
STRING(Expression);
uint64_t value;
};
@ -421,7 +421,7 @@ namespace CppSharp @@ -421,7 +421,7 @@ namespace CppSharp
BuiltinType *builtinType;
VECTOR(Item *, Items)
Item *FindItemByName(const std::string &Name);
CS_IGNORE Item *FindItemByName(const std::string &Name);
};
class CS_API Variable : public Declaration
@ -430,7 +430,7 @@ namespace CppSharp @@ -430,7 +430,7 @@ namespace CppSharp
DECLARE_DECL_KIND(Variable, Variable)
~Variable();
bool isConstExpr;
std::string mangled;
STRING(Mangled);
QualifiedType qualifiedType;
ExpressionObsolete *initializer;
};
@ -522,7 +522,7 @@ namespace CppSharp @@ -522,7 +522,7 @@ namespace CppSharp
LayoutField(const LayoutField &other);
~LayoutField();
unsigned offset;
std::string name;
STRING(Name);
QualifiedType qualifiedType;
void *fieldPtr;
};
@ -688,8 +688,8 @@ namespace CppSharp @@ -688,8 +688,8 @@ namespace CppSharp
ClassTemplate();
~ClassTemplate();
VECTOR(ClassTemplateSpecialization *, Specializations)
ClassTemplateSpecialization *FindSpecialization(const std::string &usr);
ClassTemplatePartialSpecialization *FindPartialSpecialization(const std::string &usr);
CS_IGNORE ClassTemplateSpecialization *FindSpecialization(const std::string &usr);
CS_IGNORE ClassTemplatePartialSpecialization *FindPartialSpecialization(const std::string &usr);
};
enum class TemplateSpecializationKind
@ -725,7 +725,7 @@ namespace CppSharp @@ -725,7 +725,7 @@ namespace CppSharp
FunctionTemplate();
~FunctionTemplate();
VECTOR(FunctionTemplateSpecialization *, Specializations)
FunctionTemplateSpecialization *FindSpecialization(const std::string &usr);
CS_IGNORE FunctionTemplateSpecialization *FindSpecialization(const std::string &usr);
};
class CS_API FunctionTemplateSpecialization
@ -748,8 +748,8 @@ namespace CppSharp @@ -748,8 +748,8 @@ namespace CppSharp
VarTemplate();
~VarTemplate();
VECTOR(VarTemplateSpecialization *, Specializations)
VarTemplateSpecialization *FindSpecialization(const std::string &usr);
VarTemplatePartialSpecialization *FindPartialSpecialization(const std::string &usr);
CS_IGNORE VarTemplateSpecialization *FindSpecialization(const std::string &usr);
CS_IGNORE VarTemplatePartialSpecialization *FindPartialSpecialization(const std::string &usr);
};
class CS_API VarTemplateSpecialization : public Variable
@ -808,8 +808,8 @@ namespace CppSharp @@ -808,8 +808,8 @@ namespace CppSharp
public:
MacroDefinition();
~MacroDefinition();
std::string name;
std::string expression;
STRING(Name);
STRING(Expression);
int lineNumberStart;
int lineNumberEnd;
};
@ -819,8 +819,8 @@ namespace CppSharp @@ -819,8 +819,8 @@ namespace CppSharp
public:
MacroExpansion();
~MacroExpansion();
std::string name;
std::string text;
STRING(Name);
STRING(Text);
MacroDefinition *definition;
};
@ -829,7 +829,7 @@ namespace CppSharp @@ -829,7 +829,7 @@ namespace CppSharp
public:
TranslationUnit();
~TranslationUnit();
std::string fileName;
STRING(FileName);
bool isSystemHeader;
VECTOR(MacroDefinition *, Macros)
};

7
src/CppParser/Expr.cpp

@ -131,6 +131,9 @@ ImaginaryLiteral::ImaginaryLiteral() @@ -131,6 +131,9 @@ ImaginaryLiteral::ImaginaryLiteral()
{
}
DEF_STRING(StringLiteral, String)
DEF_STRING(StringLiteral, Bytes)
StringLiteral::StringLiteral()
: Expr(StmtClass::StringLiteral)
, byteLength(0)
@ -314,6 +317,8 @@ CStyleCastExpr::CStyleCastExpr() @@ -314,6 +317,8 @@ CStyleCastExpr::CStyleCastExpr()
{
}
DEF_STRING(BinaryOperator, OpcodeStr)
BinaryOperator::BinaryOperator()
: Expr(StmtClass::BinaryOperator)
, operatorLoc(SourceLocation())
@ -722,6 +727,8 @@ MSPropertySubscriptExpr::MSPropertySubscriptExpr() @@ -722,6 +727,8 @@ MSPropertySubscriptExpr::MSPropertySubscriptExpr()
{
}
DEF_STRING(CXXUuidofExpr, UuidStr)
CXXUuidofExpr::CXXUuidofExpr()
: Expr(StmtClass::CXXUuidofExpr)
, exprOperand(nullptr)

9
src/CppParser/Expr.h

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
#pragma once
#include "Helpers.h"
#include "Sources.h"
#include "Types.h"
#include "Stmt.h"
@ -438,8 +439,8 @@ public: @@ -438,8 +439,8 @@ public:
};
StringLiteral();
std::string string;
std::string bytes;
STRING(String);
STRING(Bytes);
unsigned int byteLength;
unsigned int length;
unsigned int charByteWidth;
@ -630,7 +631,7 @@ public: @@ -630,7 +631,7 @@ public:
BinaryOperatorKind opcode;
Expr* lHS;
Expr* rHS;
std::string opcodeStr;
STRING(OpcodeStr);
bool isPtrMemOp;
bool isMultiplicativeOp;
bool isAdditiveOp;
@ -1116,7 +1117,7 @@ class CS_API CXXUuidofExpr : public Expr @@ -1116,7 +1117,7 @@ class CS_API CXXUuidofExpr : public Expr
public:
CXXUuidofExpr();
Expr* exprOperand;
std::string uuidStr;
STRING(UuidStr);
bool isTypeOperand;
};

10
src/CppParser/Helpers.h

@ -53,3 +53,13 @@ @@ -53,3 +53,13 @@
void klass::add##name (const char* s) { return name.push_back(std::string(s)); } \
unsigned klass::get##name##Count () { return name.size(); } \
void klass::clear##name() { name.clear(); }
#define STRING(name) \
std::string name; \
const char* get##name(); \
void set##name(const char* s);
#define DEF_STRING(klass, name) \
const char* klass::get##name() { return name.c_str(); } \
void klass::set##name(const char* s) { name = s; }

2
src/CppParser/Link.cpp

@ -18,7 +18,7 @@ LLD_HAS_DRIVER(macho) @@ -18,7 +18,7 @@ LLD_HAS_DRIVER(macho)
using namespace CppSharp::CppParser;
bool Parser::Link(const std::string& File, const CppLinkerOptions* LinkerOptions)
bool Parser::Link(const char * File, const CppLinkerOptions* LinkerOptions)
{
std::vector<const char*> args;
llvm::StringRef Dir(llvm::sys::path::parent_path(File));

10
src/CppParser/ParseExpr.cpp

@ -217,8 +217,8 @@ AST::Expr* Parser::WalkExpression(const clang::Expr* Expr) @@ -217,8 +217,8 @@ AST::Expr* Parser::WalkExpression(const clang::Expr* Expr)
_S->sourceBitField = static_cast<AST::Field*>(WalkDeclaration(S->getSourceBitField()));
_S->referencedDeclOfCallee = static_cast<AST::Declaration*>(WalkDeclaration(S->getReferencedDeclOfCallee()));
_S->hasPlaceholderType = S->hasPlaceholderType();
_S->string = S->getString().str();
_S->bytes = S->getBytes().str();
_S->String = S->getString();
_S->Bytes = S->getBytes();
_S->byteLength = S->getByteLength();
_S->length = S->getLength();
_S->charByteWidth = S->getCharByteWidth();
@ -537,7 +537,7 @@ AST::Expr* Parser::WalkExpression(const clang::Expr* Expr) @@ -537,7 +537,7 @@ AST::Expr* Parser::WalkExpression(const clang::Expr* Expr)
_S->opcode = (BinaryOperatorKind) S->getOpcode();
_S->lHS = static_cast<AST::Expr*>(WalkExpression(S->getLHS()));
_S->rHS = static_cast<AST::Expr*>(WalkExpression(S->getRHS()));
_S->opcodeStr = S->getOpcodeStr().str();
_S->OpcodeStr = S->getOpcodeStr();
_S->isPtrMemOp = S->isPtrMemOp();
_S->isMultiplicativeOp = S->isMultiplicativeOp();
_S->isAdditiveOp = S->isAdditiveOp();
@ -575,7 +575,7 @@ AST::Expr* Parser::WalkExpression(const clang::Expr* Expr) @@ -575,7 +575,7 @@ AST::Expr* Parser::WalkExpression(const clang::Expr* Expr)
_S->opcode = (BinaryOperatorKind) S->getOpcode();
_S->lHS = static_cast<AST::Expr*>(WalkExpression(S->getLHS()));
_S->rHS = static_cast<AST::Expr*>(WalkExpression(S->getRHS()));
_S->opcodeStr = S->getOpcodeStr().str();
_S->OpcodeStr = S->getOpcodeStr();
_S->isPtrMemOp = S->isPtrMemOp();
_S->isMultiplicativeOp = S->isMultiplicativeOp();
_S->isAdditiveOp = S->isAdditiveOp();
@ -1552,7 +1552,7 @@ AST::Expr* Parser::WalkExpression(const clang::Expr* Expr) @@ -1552,7 +1552,7 @@ AST::Expr* Parser::WalkExpression(const clang::Expr* Expr)
_S->referencedDeclOfCallee = static_cast<AST::Declaration*>(WalkDeclaration(S->getReferencedDeclOfCallee()));
_S->hasPlaceholderType = S->hasPlaceholderType();
_S->exprOperand = static_cast<AST::Expr*>(WalkExpression(S->getExprOperand()));
_S->uuidStr = S->getGuidDecl()->getNameAsString();
_S->UuidStr = S->getGuidDecl()->getNameAsString();
_S->isTypeOperand = S->isTypeOperand();
_Expr = _S;
break;

2
src/CppParser/ParseStmt.cpp

@ -244,7 +244,7 @@ AST::Stmt* Parser::WalkStatement(const clang::Stmt* Stmt) @@ -244,7 +244,7 @@ AST::Stmt* Parser::WalkStatement(const clang::Stmt* Stmt)
}
_S->hasBraces = S->hasBraces();
_S->numAsmToks = S->getNumAsmToks();
_S->asmString = S->getAsmString().str();
_S->AsmString = S->getAsmString();
_Stmt = _S;
break;
}

106
src/CppParser/Parser.cpp

@ -85,7 +85,7 @@ LayoutField Parser::WalkVTablePointer(Class* Class, @@ -85,7 +85,7 @@ LayoutField Parser::WalkVTablePointer(Class* Class,
{
LayoutField LayoutField;
LayoutField.offset = Offset.getQuantity();
LayoutField.name = prefix + "_" + Class->name;
LayoutField.Name = prefix + "_" + Class->Name;
LayoutField.qualifiedType = GetQualifiedType(c->getASTContext().VoidPtrTy);
return LayoutField;
}
@ -189,7 +189,7 @@ void Parser::ReadClassLayout(Class* Class, const clang::RecordDecl* RD, @@ -189,7 +189,7 @@ void Parser::ReadClassLayout(Class* Class, const clang::RecordDecl* RD,
auto F = WalkFieldCXX(Field, Parent);
LayoutField LayoutField;
LayoutField.offset = FieldOffset.getQuantity();
LayoutField.name = F->name;
LayoutField.Name = F->Name;
LayoutField.qualifiedType = GetQualifiedType(Field->getType());
LayoutField.fieldPtr = (void*)Field;
Class->layout->Fields.push_back(LayoutField);
@ -285,9 +285,9 @@ void Parser::Setup(bool Compile) @@ -285,9 +285,9 @@ void Parser::Setup(bool Compile)
auto& TO = Inv->TargetOpts;
if (opts->targetTriple.empty())
opts->targetTriple = llvm::sys::getDefaultTargetTriple();
TO->Triple = llvm::Triple::normalize(opts->targetTriple);
if (opts->TargetTriple.empty())
opts->TargetTriple = llvm::sys::getDefaultTargetTriple();
TO->Triple = llvm::Triple::normalize(opts->TargetTriple);
if (opts->verbose)
printf("Target triple: %s\n", TO->Triple.c_str());
@ -297,8 +297,8 @@ void Parser::Setup(bool Compile) @@ -297,8 +297,8 @@ void Parser::Setup(bool Compile)
{
// We might have no target info due to an invalid user-provided triple.
// Try again with the default triple.
opts->targetTriple = llvm::sys::getDefaultTargetTriple();
TO->Triple = llvm::Triple::normalize(opts->targetTriple);
opts->TargetTriple = llvm::sys::getDefaultTargetTriple();
TO->Triple = llvm::Triple::normalize(opts->TargetTriple);
TI = TargetInfo::CreateTargetInfo(c->getDiagnostics(), TO);
}
@ -1258,7 +1258,7 @@ Parser::WalkClassTemplateSpecialization(const clang::ClassTemplateSpecialization @@ -1258,7 +1258,7 @@ Parser::WalkClassTemplateSpecialization(const clang::ClassTemplateSpecialization
auto NS = GetNamespace(CTS);
assert(NS && "Expected a valid namespace");
TS->_namespace = NS;
TS->name = CTS->getName().str();
TS->Name = CTS->getName().str();
TS->templatedDecl = CT;
TS->specializationKind = WalkTemplateSpecializationKind(CTS->getSpecializationKind());
CT->Specializations.push_back(TS);
@ -1313,7 +1313,7 @@ Parser::WalkClassTemplatePartialSpecialization(const clang::ClassTemplatePartial @@ -1313,7 +1313,7 @@ Parser::WalkClassTemplatePartialSpecialization(const clang::ClassTemplatePartial
auto NS = GetNamespace(CTS);
assert(NS && "Expected a valid namespace");
TS->_namespace = NS;
TS->name = CTS->getName().str();
TS->Name = CTS->getName();
TS->templatedDecl = CT;
TS->specializationKind = WalkTemplateSpecializationKind(CTS->getSpecializationKind());
CT->Specializations.push_back(TS);
@ -1377,7 +1377,7 @@ ClassTemplate* Parser::WalkClassTemplate(const clang::ClassTemplateDecl* TD) @@ -1377,7 +1377,7 @@ ClassTemplate* Parser::WalkClassTemplate(const clang::ClassTemplateDecl* TD)
CT = new ClassTemplate();
HandleDeclaration(TD, CT);
CT->name = GetDeclName(TD);
CT->Name = GetDeclName(TD);
CT->_namespace = NS;
NS->Templates.push_back(CT);
@ -1425,7 +1425,7 @@ TypeTemplateParameter* Parser::WalkTypeTemplateParameter(const clang::TemplateTy @@ -1425,7 +1425,7 @@ TypeTemplateParameter* Parser::WalkTypeTemplateParameter(const clang::TemplateTy
return TP;
TP = new CppSharp::CppParser::TypeTemplateParameter();
TP->name = GetDeclName(TTPD);
TP->Name = GetDeclName(TTPD);
HandleDeclaration(TTPD, TP);
if (TTPD->hasDefaultArgument())
TP->defaultArgument = GetQualifiedType(TTPD->getDefaultArgument());
@ -1445,7 +1445,7 @@ NonTypeTemplateParameter* Parser::WalkNonTypeTemplateParameter(const clang::NonT @@ -1445,7 +1445,7 @@ NonTypeTemplateParameter* Parser::WalkNonTypeTemplateParameter(const clang::NonT
return NTP;
NTP = new CppSharp::CppParser::NonTypeTemplateParameter();
NTP->name = GetDeclName(NTTPD);
NTP->Name = GetDeclName(NTTPD);
HandleDeclaration(NTTPD, NTP);
if (NTTPD->hasDefaultArgument())
NTP->defaultArgument = WalkExpressionObsolete(NTTPD->getDefaultArgument());
@ -1606,7 +1606,7 @@ TypeAliasTemplate* Parser::WalkTypeAliasTemplate( @@ -1606,7 +1606,7 @@ TypeAliasTemplate* Parser::WalkTypeAliasTemplate(
TA = new TypeAliasTemplate();
HandleDeclaration(TD, TA);
TA->name = GetDeclName(TD);
TA->Name = GetDeclName(TD);
NS->Templates.push_back(TA);
TA->TemplatedDecl = WalkDeclaration(TD->getTemplatedDecl());
@ -1644,7 +1644,7 @@ FunctionTemplate* Parser::WalkFunctionTemplate(const clang::FunctionTemplateDecl @@ -1644,7 +1644,7 @@ FunctionTemplate* Parser::WalkFunctionTemplate(const clang::FunctionTemplateDecl
FT = new FunctionTemplate();
HandleDeclaration(TD, FT);
FT->name = GetDeclName(TD);
FT->Name = GetDeclName(TD);
FT->_namespace = NS;
FT->TemplatedDecl = F;
FT->Parameters = WalkTemplateParameterList(TD->getTemplateParameters());
@ -1718,7 +1718,7 @@ VarTemplate* Parser::WalkVarTemplate(const clang::VarTemplateDecl* TD) @@ -1718,7 +1718,7 @@ VarTemplate* Parser::WalkVarTemplate(const clang::VarTemplateDecl* TD)
VT = new VarTemplate();
HandleDeclaration(TD, VT);
VT->name = GetDeclName(TD);
VT->Name = GetDeclName(TD);
VT->_namespace = NS;
NS->Templates.push_back(VT);
@ -1746,7 +1746,7 @@ Parser::WalkVarTemplateSpecialization(const clang::VarTemplateSpecializationDecl @@ -1746,7 +1746,7 @@ Parser::WalkVarTemplateSpecialization(const clang::VarTemplateSpecializationDecl
auto NS = GetNamespace(VTS);
assert(NS && "Expected a valid namespace");
TS->_namespace = NS;
TS->name = VTS->getName().str();
TS->Name = VTS->getName();
TS->templatedDecl = VT;
TS->specializationKind = WalkTemplateSpecializationKind(VTS->getSpecializationKind());
VT->Specializations.push_back(TS);
@ -1786,7 +1786,7 @@ Parser::WalkVarTemplatePartialSpecialization(const clang::VarTemplatePartialSpec @@ -1786,7 +1786,7 @@ Parser::WalkVarTemplatePartialSpecialization(const clang::VarTemplatePartialSpec
auto NS = GetNamespace(VTS);
assert(NS && "Expected a valid namespace");
TS->_namespace = NS;
TS->name = VTS->getName().str();
TS->Name = VTS->getName();
TS->templatedDecl = VT;
TS->specializationKind = WalkTemplateSpecializationKind(VTS->getSpecializationKind());
VT->Specializations.push_back(TS);
@ -1963,7 +1963,7 @@ Field* Parser::WalkFieldCXX(const clang::FieldDecl* FD, Class* Class) @@ -1963,7 +1963,7 @@ Field* Parser::WalkFieldCXX(const clang::FieldDecl* FD, Class* Class)
HandleDeclaration(FD, F);
F->_namespace = Class;
F->name = FD->getName().str();
F->Name = FD->getName();
auto TL = FD->getTypeSourceInfo()->getTypeLoc();
F->qualifiedType = GetQualifiedType(FD->getType(), &TL);
F->access = ConvertToAccess(FD->getAccess());
@ -2589,7 +2589,7 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL, @@ -2589,7 +2589,7 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL,
{
auto FA = new Parameter();
auto Arg = FP->getParamType(i);
FA->name = "";
FA->Name = "";
FA->qualifiedType = GetQualifiedType(Arg);
// In this case we have no valid value to use as a pointer so
@ -2724,7 +2724,7 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL, @@ -2724,7 +2724,7 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL,
auto TPT = new CppSharp::CppParser::TemplateParameterType();
if (auto Ident = TP->getIdentifier())
TPT->parameter->name = Ident->getName().str();
TPT->parameter->Name = Ident->getName();
TypeLoc UTL, ETL, ITL, Next;
@ -2825,7 +2825,7 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL, @@ -2825,7 +2825,7 @@ Type* Parser::WalkType(clang::QualType QualType, const clang::TypeLoc* TL,
}
default: break;
}
DNT->identifier = DN->getIdentifier()->getName().str();
DNT->Identifier = DN->getIdentifier()->getName();
Ty = DNT;
break;
@ -2976,7 +2976,7 @@ Enumeration* Parser::WalkEnum(const clang::EnumDecl* ED) @@ -2976,7 +2976,7 @@ Enumeration* Parser::WalkEnum(const clang::EnumDecl* ED)
else
{
E = new Enumeration();
E->name = Name;
E->Name = Name;
E->_namespace = NS;
NS->Enums.push_back(E);
}
@ -3013,7 +3013,7 @@ Enumeration::Item* Parser::WalkEnumItem(clang::EnumConstantDecl* ECD) @@ -3013,7 +3013,7 @@ Enumeration::Item* Parser::WalkEnumItem(clang::EnumConstantDecl* ECD)
auto EnumItem = new Enumeration::Item();
HandleDeclaration(ECD, EnumItem);
EnumItem->name = ECD->getNameAsString();
EnumItem->Name = ECD->getNameAsString();
auto Value = ECD->getInitVal();
EnumItem->value = Value.isSigned() ? Value.getSExtValue()
: Value.getZExtValue();
@ -3021,7 +3021,7 @@ Enumeration::Item* Parser::WalkEnumItem(clang::EnumConstantDecl* ECD) @@ -3021,7 +3021,7 @@ Enumeration::Item* Parser::WalkEnumItem(clang::EnumConstantDecl* ECD)
std::string Text;
if (GetDeclText(ECD->getSourceRange(), Text))
EnumItem->expression = Text;
EnumItem->Expression = Text;
return EnumItem;
}
@ -3153,7 +3153,7 @@ Parameter* Parser::WalkParameter(const clang::ParmVarDecl* PVD, @@ -3153,7 +3153,7 @@ Parameter* Parser::WalkParameter(const clang::ParmVarDecl* PVD,
return P;
P = new Parameter();
P->name = PVD->getNameAsString();
P->Name = PVD->getNameAsString();
TypeLoc PTL;
if (auto TSI = PVD->getTypeSourceInfo())
@ -3188,16 +3188,16 @@ Parameter* Parser::WalkParameter(const clang::ParmVarDecl* PVD, @@ -3188,16 +3188,16 @@ Parameter* Parser::WalkParameter(const clang::ParmVarDecl* PVD,
void Parser::SetBody(const clang::FunctionDecl* FD, Function* F)
{
F->body = GetFunctionBody(FD);
F->Body = GetFunctionBody(FD);
F->isInline = FD->isInlined();
if (!F->body.empty() && F->isInline)
if (!F->Body.empty() && F->isInline)
return;
for (const auto& R : FD->redecls())
{
if (F->body.empty())
F->body = GetFunctionBody(R);
if (F->Body.empty())
F->Body = GetFunctionBody(R);
F->isInline |= R->isInlined();
if (!F->body.empty() && F->isInline)
if (!F->Body.empty() && F->isInline)
break;
}
}
@ -3293,7 +3293,7 @@ void Parser::WalkFunction(const clang::FunctionDecl* FD, Function* F) @@ -3293,7 +3293,7 @@ void Parser::WalkFunction(const clang::FunctionDecl* FD, Function* F)
auto NS = GetNamespace(FD);
assert(NS && "Expected a valid namespace");
F->name = FD->getNameAsString();
F->Name = FD->getNameAsString();
F->_namespace = NS;
F->isConstExpr = FD->isConstexpr();
F->isVariadic = FD->isVariadic();
@ -3338,10 +3338,10 @@ void Parser::WalkFunction(const clang::FunctionDecl* FD, Function* F) @@ -3338,10 +3338,10 @@ void Parser::WalkFunction(const clang::FunctionDecl* FD, Function* F)
F->returnType = GetQualifiedType(ReturnType, &RTL);
const auto& Mangled = GetDeclMangledName(FD);
F->mangled = Mangled;
F->Mangled = Mangled;
const auto& Body = GetFunctionBody(FD);
F->body = Body;
F->Body = Body;
clang::SourceLocation ParamStartLoc = FD->getBeginLoc();
clang::SourceLocation ResultLoc;
@ -3371,7 +3371,7 @@ void Parser::WalkFunction(const clang::FunctionDecl* FD, Function* F) @@ -3371,7 +3371,7 @@ void Parser::WalkFunction(const clang::FunctionDecl* FD, Function* F)
std::string Sig;
if (GetDeclText(Range, Sig))
F->signature = Sig;
F->Signature = Sig;
for (auto VD : FD->parameters())
{
@ -3501,7 +3501,7 @@ void Parser::WalkVariable(const clang::VarDecl* VD, Variable* Var) @@ -3501,7 +3501,7 @@ void Parser::WalkVariable(const clang::VarDecl* VD, Variable* Var)
HandleDeclaration(VD, Var);
Var->isConstExpr = VD->isConstexpr();
Var->name = VD->getName().str();
Var->Name = VD->getName();
Var->access = ConvertToAccess(VD->getAccess());
auto Init = VD->getAnyInitializer();
@ -3512,7 +3512,7 @@ void Parser::WalkVariable(const clang::VarDecl* VD, Variable* Var) @@ -3512,7 +3512,7 @@ void Parser::WalkVariable(const clang::VarDecl* VD, Variable* Var)
Var->qualifiedType = GetQualifiedType(VD->getType(), &TL);
auto Mangled = GetDeclMangledName(VD);
Var->mangled = Mangled;
Var->Mangled = Mangled;
}
Variable* Parser::WalkVariable(const clang::VarDecl *VD)
@ -3615,7 +3615,7 @@ PreprocessedEntity* Parser::WalkPreprocessedEntity( @@ -3615,7 +3615,7 @@ PreprocessedEntity* Parser::WalkPreprocessedEntity(
std::string Text;
GetDeclText(PPEntity->getSourceRange(), Text);
static_cast<MacroExpansion*>(Entity)->text = Text;
static_cast<MacroExpansion*>(Entity)->Text = Text;
break;
}
case clang::PreprocessedEntity::MacroDefinitionKind:
@ -3659,8 +3659,8 @@ PreprocessedEntity* Parser::WalkPreprocessedEntity( @@ -3659,8 +3659,8 @@ PreprocessedEntity* Parser::WalkPreprocessedEntity(
Definition->lineNumberEnd = SM.getExpansionLineNumber(MD->getLocation());
Entity = Definition;
Definition->name = II->getName().trim().str();
Definition->expression = Expression.trim().str();
Definition->Name = II->getName().trim();
Definition->Expression = Expression.trim();
}
case clang::PreprocessedEntity::InclusionDirectiveKind:
// nothing to be done for InclusionDirectiveKind
@ -3710,7 +3710,7 @@ AST::ExpressionObsolete* Parser::WalkExpressionObsolete(const clang::Expr* Expr) @@ -3710,7 +3710,7 @@ AST::ExpressionObsolete* Parser::WalkExpressionObsolete(const clang::Expr* Expr)
auto BinaryOperator = cast<clang::BinaryOperator>(Expr);
return new AST::BinaryOperatorObsolete(GetStringFromStatement(Expr),
WalkExpressionObsolete(BinaryOperator->getLHS()), WalkExpressionObsolete(BinaryOperator->getRHS()),
BinaryOperator->getOpcodeStr().str());
BinaryOperator->getOpcodeStr().str().c_str());
}
case clang::Stmt::CallExprClass:
{
@ -3930,7 +3930,7 @@ void Parser::HandleOriginalText(const clang::Decl* D, Declaration* Decl) @@ -3930,7 +3930,7 @@ void Parser::HandleOriginalText(const clang::Decl* D, Declaration* Decl)
auto DeclText = clang::Lexer::getSourceText(Range, SM, LangOpts, &Invalid);
if (!Invalid)
Decl->debugText = DeclText.str();
Decl->DebugText = DeclText;
}
void Parser::HandleDeclaration(const clang::Decl* D, Declaration* Decl)
@ -4339,8 +4339,8 @@ void Parser::HandleDiagnostics(ParserResult* res) @@ -4339,8 +4339,8 @@ void Parser::HandleDiagnostics(ParserResult* res)
auto FileName = Source.getFilename(Source.getFileLoc(Diag.Location));
auto PDiag = ParserDiagnostic();
PDiag.fileName = FileName.str();
PDiag.message = Diag.Message.str().str();
PDiag.FileName = FileName.str();
PDiag.Message = Diag.Message.str();
PDiag.lineNumber = 0;
PDiag.columnNumber = 0;
@ -4510,7 +4510,7 @@ ParserResultKind Parser::ParseArchive(const std::string& File, @@ -4510,7 +4510,7 @@ ParserResultKind Parser::ParseArchive(const std::string& File,
std::vector<CppSharp::CppParser::NativeLibrary*>& NativeLibs)
{
auto NativeLib = new NativeLibrary();
NativeLib->fileName = File;
NativeLib->FileName = File;
for (const auto& Symbol : Archive->symbols())
{
@ -4547,7 +4547,7 @@ ParserResultKind Parser::ParseSharedLib(const std::string& File, @@ -4547,7 +4547,7 @@ ParserResultKind Parser::ParseSharedLib(const std::string& File,
std::vector<CppSharp::CppParser::NativeLibrary*>& NativeLibs)
{
auto NativeLib = new NativeLibrary();
NativeLib->fileName = File;
NativeLib->FileName = File;
NativeLib->archType = ConvertArchType(ObjectFile->getArch());
NativeLibs.push_back(NativeLib);
@ -4645,7 +4645,7 @@ ParserResultKind Parser::ReadSymbols(llvm::StringRef File, @@ -4645,7 +4645,7 @@ ParserResultKind Parser::ReadSymbols(llvm::StringRef File,
{
auto LibName = File;
NativeLib = new NativeLibrary();
NativeLib->fileName = LibName.str();
NativeLib->FileName = LibName;
for (auto it = Begin; it != End; ++it)
{
@ -4714,8 +4714,8 @@ ParserResult* Parser::ParseLibrary(const CppLinkerOptions* Opts) @@ -4714,8 +4714,8 @@ ParserResult* Parser::ParseLibrary(const CppLinkerOptions* Opts)
{
auto ErrMsg = llvm::toString(BinaryOrErr.takeError());
auto Diag = ParserDiagnostic();
Diag.fileName = FileEntry;
Diag.message = ErrMsg;
Diag.FileName = FileEntry;
Diag.Message = ErrMsg;
Diag.level = ParserDiagnosticLevel::Error;
res->Diagnostics.push_back(Diag);
@ -4743,7 +4743,7 @@ ParserResult* Parser::ParseLibrary(const CppLinkerOptions* Opts) @@ -4743,7 +4743,7 @@ ParserResult* Parser::ParseLibrary(const CppLinkerOptions* Opts)
return res;
}
ParserResult* Parser::Build(const CppLinkerOptions* LinkerOptions, const std::string& File, bool Last)
ParserResult* Parser::Build(const CppLinkerOptions* LinkerOptions, const char * File, bool Last)
{
ParserResult* error = Compile(File);
if (error)
@ -4806,7 +4806,7 @@ ParserResult* ClangParser::ParseLibrary(CppLinkerOptions* Opts) @@ -4806,7 +4806,7 @@ ParserResult* ClangParser::ParseLibrary(CppLinkerOptions* Opts)
}
ParserResult* ClangParser::Build(CppParserOptions* Opts,
const CppLinkerOptions* LinkerOptions, const std::string& File, bool Last)
const CppLinkerOptions* LinkerOptions, const char * File, bool Last)
{
if (!Opts)
return 0;
@ -4816,7 +4816,7 @@ ParserResult* ClangParser::Build(CppParserOptions* Opts, @@ -4816,7 +4816,7 @@ ParserResult* ClangParser::Build(CppParserOptions* Opts,
}
ParserResult* ClangParser::Compile(CppParserOptions* Opts,
const std::string& File)
const char * File)
{
if (!Opts)
return 0;
@ -4826,7 +4826,7 @@ ParserResult* ClangParser::Compile(CppParserOptions* Opts, @@ -4826,7 +4826,7 @@ ParserResult* ClangParser::Compile(CppParserOptions* Opts,
}
ParserResult* ClangParser::Link(CppParserOptions* Opts,
const CppLinkerOptions* LinkerOptions, const std::string& File, bool Last)
const CppLinkerOptions* LinkerOptions, const char * File, bool Last)
{
if (!Opts)
return 0;
@ -4848,7 +4848,7 @@ ParserResult* ClangParser::Link(CppParserOptions* Opts, @@ -4848,7 +4848,7 @@ ParserResult* ClangParser::Link(CppParserOptions* Opts,
return res;
}
ParserResult* Parser::Compile(const std::string& File)
ParserResult* Parser::Compile(const char * File)
{
llvm::InitializeAllAsmPrinters();
llvm::StringRef Stem = llvm::sys::path::stem(File);

6
src/CppParser/Parser.h

@ -56,9 +56,9 @@ public: @@ -56,9 +56,9 @@ public:
void Setup(bool Compile = false);
ParserResult* Parse(const std::vector<std::string>& SourceFiles);
static ParserResult* ParseLibrary(const CppLinkerOptions* Opts);
ParserResult* Build(const CppLinkerOptions* LinkerOptions, const std::string& File, bool Last);
ParserResult* Compile(const std::string& File);
bool Link(const std::string& File, const CppLinkerOptions* LinkerOptions);
ParserResult* Build(const CppLinkerOptions* LinkerOptions, const char * File, bool Last);
ParserResult* Compile(const char * File);
bool Link(const char * File, const CppLinkerOptions* LinkerOptions);
void WalkAST(clang::TranslationUnitDecl* TU);
void HandleDeclaration(const clang::Decl* D, Declaration* Decl);
CppParserOptions* opts;

38
src/CppParser/ParserGen/ParserGen.cs

@ -4,6 +4,7 @@ using System.IO; @@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using CppSharp.AST;
using CppSharp.Generators;
using CppSharp.Generators.C;
using CppSharp.Parser;
using CppSharp.Passes;
using CppAbi = CppSharp.Parser.AST.CppAbi;
@ -120,6 +121,7 @@ namespace CppSharp @@ -120,6 +121,7 @@ namespace CppSharp
public void SetupPasses(Driver driver)
{
driver.AddTranslationUnitPass(new IgnoreStdFieldsPass());
}
public void Preprocess(Driver driver, ASTContext ctx)
@ -218,4 +220,40 @@ namespace CppSharp @@ -218,4 +220,40 @@ namespace CppSharp
}
}
}
public class IgnoreStdFieldsPass : TranslationUnitPass
{
public override bool VisitFieldDecl(Field field)
{
if (!field.IsGenerated)
return false;
if (!IsStdType(field.QualifiedType)) return false;
field.ExplicitlyIgnore();
return true;
}
public override bool VisitFunctionDecl(Function function)
{
if (function.GenerationKind == GenerationKind.None)
return false;
if (function.Parameters.Any(param => IsStdType(param.QualifiedType)))
{
function.ExplicitlyIgnore();
return false;
}
return true;
}
private bool IsStdType(QualifiedType type)
{
var typePrinter = new CppTypePrinter(Context);
var typeName = type.Visit(typePrinter);
return typeName.Type.Contains("std::");
}
}
}

4
src/CppParser/Stmt.cpp

@ -228,6 +228,8 @@ DEF_VECTOR(AsmStmt, Expr*, inputs) @@ -228,6 +228,8 @@ DEF_VECTOR(AsmStmt, Expr*, inputs)
DEF_VECTOR(AsmStmt, Expr*, outputs)
DEF_STRING(GCCAsmStmt::AsmStringPiece, String)
GCCAsmStmt::AsmStringPiece::AsmStringPiece()
{
}
@ -238,6 +240,8 @@ GCCAsmStmt::GCCAsmStmt() @@ -238,6 +240,8 @@ GCCAsmStmt::GCCAsmStmt()
{
}
DEF_STRING(MSAsmStmt, AsmString)
MSAsmStmt::MSAsmStmt()
: AsmStmt(StmtClass::MSAsmStmt)
, lBraceLoc(SourceLocation())

4
src/CppParser/Stmt.h

@ -372,7 +372,7 @@ public: @@ -372,7 +372,7 @@ public:
AsmStringPiece();
bool isString;
bool isOperand;
std::string string;
STRING(String);
unsigned int operandNo;
char modifier;
};
@ -388,7 +388,7 @@ public: @@ -388,7 +388,7 @@ public:
SourceLocation lBraceLoc;
bool hasBraces;
unsigned int numAsmToks;
std::string asmString;
STRING(AsmString);
};
class CS_API SEHExceptStmt : public Stmt

3
src/CppParser/Target.h

@ -30,7 +30,8 @@ struct CS_API ParserTargetInfo @@ -30,7 +30,8 @@ struct CS_API ParserTargetInfo
{
ParserTargetInfo();
~ParserTargetInfo();
std::string ABI;
STRING(ABI);
ParserIntType char16Type;
ParserIntType char32Type;

2
src/CppParser/Types.h

@ -259,7 +259,7 @@ public: @@ -259,7 +259,7 @@ public:
DECLARE_TYPE_KIND(DependentName)
~DependentNameType();
QualifiedType qualifier;
std::string identifier;
STRING(Identifier);
};
class CS_API PackExpansionType : public Type

Loading…
Cancel
Save