Skip to content

Commit b684fe0

Browse files
committed
Revert "Removed the macros in C++ AST for std::string because we can marshal it (#866)"
1 parent 38621c3 commit b684fe0

34 files changed

+5255
-44990
lines changed

src/CppParser/AST.cpp

+75-27
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ DependentNameType::DependentNameType() : Type(TypeKind::DependentName) {}
214214

215215
DependentNameType::~DependentNameType() {}
216216

217+
DEF_STRING(DependentNameType, Identifier)
218+
217219
PackExpansionType::PackExpansionType() : Type(TypeKind::PackExpansion) {}
218220

219221
UnaryTransformType::UnaryTransformType() : Type(TypeKind::UnaryTransform) {}
@@ -242,14 +244,16 @@ LayoutField::LayoutField() : offset(0), fieldPtr(0) {}
242244

243245
LayoutField::LayoutField(const LayoutField & other)
244246
: offset(other.offset)
245-
, name(other.name)
247+
, Name(other.Name)
246248
, qualifiedType(other.qualifiedType)
247249
, fieldPtr(other.fieldPtr)
248250
{
249251
}
250252

251253
LayoutField::~LayoutField() {}
252254

255+
DEF_STRING(LayoutField, Name)
256+
253257
LayoutBase::LayoutBase() : offset(0), _class(0) {}
254258

255259
LayoutBase::LayoutBase(const LayoutBase& other) : offset(other.offset), _class(other._class) {}
@@ -293,9 +297,9 @@ Declaration::Declaration(const Declaration& rhs)
293297
, location(rhs.location.ID)
294298
, lineNumberStart(rhs.lineNumberStart)
295299
, lineNumberEnd(rhs.lineNumberEnd)
296-
, name(rhs.name)
300+
, Name(rhs.Name)
297301
, comment(rhs.comment)
298-
, debugText(rhs.debugText)
302+
, DebugText(rhs.DebugText)
299303
, isIncomplete(rhs.isIncomplete)
300304
, isDependent(rhs.isDependent)
301305
, isImplicit(rhs.isImplicit)
@@ -312,6 +316,9 @@ Declaration::~Declaration()
312316
{
313317
}
314318

319+
DEF_STRING(Declaration, Name)
320+
DEF_STRING(Declaration, USR)
321+
DEF_STRING(Declaration, DebugText)
315322
DEF_VECTOR(Declaration, PreprocessedEntity*, PreprocessedEntities)
316323
DEF_VECTOR(Declaration, Declaration*, Redeclarations)
317324

@@ -353,7 +360,7 @@ DeclarationContext::FindNamespace(const std::vector<std::string>& Namespaces)
353360
auto childNamespace = std::find_if(currentNamespace->Namespaces.begin(),
354361
currentNamespace->Namespaces.end(),
355362
[&](CppSharp::CppParser::AST::Namespace* ns) {
356-
return ns->name == _namespace;
363+
return ns->Name == _namespace;
357364
});
358365

359366
if (childNamespace == currentNamespace->Namespaces.end())
@@ -372,7 +379,7 @@ Namespace* DeclarationContext::FindCreateNamespace(const std::string& Name)
372379
if (!_namespace)
373380
{
374381
_namespace = new Namespace();
375-
_namespace->name = Name;
382+
_namespace->Name = Name;
376383
_namespace->_namespace = this;
377384

378385
Namespaces.push_back(_namespace);
@@ -393,7 +400,7 @@ Class* DeclarationContext::FindClass(const void* OriginalPtr,
393400
auto _class = std::find_if(Classes.begin(), Classes.end(),
394401
[OriginalPtr, Name, IsComplete](Class* klass) {
395402
return (OriginalPtr && klass->originalPtr == OriginalPtr) ||
396-
(klass->name == Name && klass->isIncomplete == !IsComplete); });
403+
(klass->Name == Name && klass->isIncomplete == !IsComplete); });
397404

398405
return _class != Classes.end() ? *_class : nullptr;
399406
}
@@ -413,7 +420,7 @@ Class* DeclarationContext::FindClass(const void* OriginalPtr,
413420
Class* DeclarationContext::CreateClass(const std::string& Name, bool IsComplete)
414421
{
415422
auto _class = new Class();
416-
_class->name = Name;
423+
_class->Name = Name;
417424
_class->_namespace = this;
418425
_class->isIncomplete = !IsComplete;
419426

@@ -457,7 +464,7 @@ Enumeration* DeclarationContext::FindEnum(const std::string& Name, bool Create)
457464
if (entries.size() == 1)
458465
{
459466
auto foundEnum = std::find_if(Enums.begin(), Enums.end(),
460-
[&](Enumeration* _enum) { return _enum->name == Name; });
467+
[&](Enumeration* _enum) { return _enum->Name == Name; });
461468

462469
if (foundEnum != Enums.end())
463470
return *foundEnum;
@@ -466,7 +473,7 @@ Enumeration* DeclarationContext::FindEnum(const std::string& Name, bool Create)
466473
return nullptr;
467474

468475
auto _enum = new Enumeration();
469-
_enum->name = Name;
476+
_enum->Name = Name;
470477
_enum->_namespace = this;
471478
Enums.push_back(_enum);
472479
return _enum;
@@ -525,7 +532,7 @@ Function* DeclarationContext::FindFunction(const std::string& USR)
525532
TypedefDecl* DeclarationContext::FindTypedef(const std::string& Name, bool Create)
526533
{
527534
auto foundTypedef = std::find_if(Typedefs.begin(), Typedefs.end(),
528-
[&](TypedefDecl* tdef) { return tdef->name == Name; });
535+
[&](TypedefDecl* tdef) { return tdef->Name == Name; });
529536

530537
if (foundTypedef != Typedefs.end())
531538
return *foundTypedef;
@@ -534,7 +541,7 @@ TypedefDecl* DeclarationContext::FindTypedef(const std::string& Name, bool Creat
534541
return nullptr;
535542

536543
auto tdef = new TypedefDecl();
537-
tdef->name = Name;
544+
tdef->Name = Name;
538545
tdef->_namespace = this;
539546

540547
return tdef;
@@ -543,7 +550,7 @@ TypedefDecl* DeclarationContext::FindTypedef(const std::string& Name, bool Creat
543550
TypeAlias* DeclarationContext::FindTypeAlias(const std::string& Name, bool Create)
544551
{
545552
auto foundTypeAlias = std::find_if(TypeAliases.begin(), TypeAliases.end(),
546-
[&](TypeAlias* talias) { return talias->name == Name; });
553+
[&](TypeAlias* talias) { return talias->Name == Name; });
547554

548555
if (foundTypeAlias != TypeAliases.end())
549556
return *foundTypeAlias;
@@ -552,7 +559,7 @@ TypeAlias* DeclarationContext::FindTypeAlias(const std::string& Name, bool Creat
552559
return nullptr;
553560

554561
auto talias = new TypeAlias();
555-
talias->name = Name;
562+
talias->Name = Name;
556563
talias->_namespace = this;
557564

558565
return talias;
@@ -596,22 +603,25 @@ Friend::Friend() : CppSharp::CppParser::AST::Declaration(DeclarationKind::Friend
596603

597604
Friend::~Friend() {}
598605

599-
StatementObsolete::StatementObsolete(const std::string& str, StatementClassObsolete stmtClass, Declaration* decl) : string(str), _class(stmtClass), decl(decl) {}
606+
DEF_STRING(StatementObsolete, String)
607+
608+
StatementObsolete::StatementObsolete(const std::string& str, StatementClassObsolete stmtClass, Declaration* decl) : String(str), _class(stmtClass), decl(decl) {}
600609

601610
ExpressionObsolete::ExpressionObsolete(const std::string& str, StatementClassObsolete stmtClass, Declaration* decl)
602611
: StatementObsolete(str, stmtClass, decl) {}
603612

613+
DEF_STRING(BinaryOperatorObsolete, OpcodeStr)
614+
604615
BinaryOperatorObsolete::BinaryOperatorObsolete(const std::string& str, ExpressionObsolete* lhs, ExpressionObsolete* rhs, const std::string& opcodeStr)
605-
: ExpressionObsolete(str, StatementClassObsolete::BinaryOperator), LHS(lhs), RHS(rhs), opcodeStr(opcodeStr) {}
616+
: ExpressionObsolete(str, StatementClassObsolete::BinaryOperator), LHS(lhs), RHS(rhs), OpcodeStr(opcodeStr) {}
606617

607618
BinaryOperatorObsolete::~BinaryOperatorObsolete()
608619
{
609620
deleteExpression(LHS);
610621
deleteExpression(RHS);
611622
}
612623

613-
614-
CallExprObsolete::CallExprObsolete(const std::string& str, Declaration* decl)
624+
CallExprObsolete::CallExprObsolete(const char* str, Declaration* decl)
615625
: ExpressionObsolete(str, StatementClassObsolete::CallExprClass, decl) {}
616626

617627
CallExprObsolete::~CallExprObsolete()
@@ -622,7 +632,7 @@ CallExprObsolete::~CallExprObsolete()
622632

623633
DEF_VECTOR(CallExprObsolete, ExpressionObsolete*, Arguments)
624634

625-
CXXConstructExprObsolete::CXXConstructExprObsolete(const std::string& str, Declaration* decl)
635+
CXXConstructExprObsolete::CXXConstructExprObsolete(const char* str, Declaration* decl)
626636
: ExpressionObsolete(str, StatementClassObsolete::CXXConstructExprClass, decl) {}
627637

628638
CXXConstructExprObsolete::~CXXConstructExprObsolete()
@@ -666,6 +676,10 @@ Function::Function()
666676
}
667677

668678
Function::~Function() {}
679+
680+
DEF_STRING(Function, Mangled)
681+
DEF_STRING(Function, Signature)
682+
DEF_STRING(Function, Body)
669683
DEF_VECTOR(Function, Parameter*, Parameters)
670684

671685
Method::Method()
@@ -699,14 +713,16 @@ DEF_VECTOR(Enumeration, Enumeration::Item*, Items)
699713
Enumeration::Item::Item() : Declaration(DeclarationKind::EnumerationItem) {}
700714

701715
Enumeration::Item::Item(const Item& rhs) : Declaration(rhs),
702-
expression(rhs.expression), value(rhs.value) {}
716+
Expression(rhs.Expression), value(rhs.value) {}
703717

704718
Enumeration::Item::~Item() {}
705719

720+
DEF_STRING(Enumeration::Item, Expression)
721+
706722
Enumeration::Item* Enumeration::FindItemByName(const std::string& Name)
707723
{
708724
auto foundEnumItem = std::find_if(Items.begin(), Items.end(),
709-
[&](Item* _item) { return _item->name == Name; });
725+
[&](Item* _item) { return _item->Name == Name; });
710726
if (foundEnumItem != Items.end())
711727
return *foundEnumItem;
712728
return nullptr;
@@ -717,6 +733,8 @@ Variable::Variable() : Declaration(DeclarationKind::Variable),
717733

718734
Variable::~Variable() {}
719735

736+
DEF_STRING(Variable, Mangled)
737+
720738
BaseClassSpecifier::BaseClassSpecifier() : type(0), offset(0) {}
721739

722740
Field::Field() : Declaration(DeclarationKind::Field), _class(0),
@@ -891,13 +909,21 @@ MacroDefinition::MacroDefinition()
891909

892910
MacroDefinition::~MacroDefinition() {}
893911

912+
DEF_STRING(MacroDefinition, Name)
913+
DEF_STRING(MacroDefinition, Expression)
914+
894915
MacroExpansion::MacroExpansion() : definition(0) { kind = DeclarationKind::MacroExpansion; }
895916

896917
MacroExpansion::~MacroExpansion() {}
897918

919+
DEF_STRING(MacroExpansion, Name)
920+
DEF_STRING(MacroExpansion, Text)
921+
898922
TranslationUnit::TranslationUnit() { kind = DeclarationKind::TranslationUnit; }
899923

900924
TranslationUnit::~TranslationUnit() {}
925+
926+
DEF_STRING(TranslationUnit, FileName)
901927
DEF_VECTOR(TranslationUnit, MacroDefinition*, Macros)
902928

903929
NativeLibrary::NativeLibrary()
@@ -906,6 +932,7 @@ NativeLibrary::NativeLibrary()
906932
NativeLibrary::~NativeLibrary() {}
907933

908934
// NativeLibrary
935+
DEF_STRING(NativeLibrary, FileName)
909936
DEF_VECTOR_STRING(NativeLibrary, Symbols)
910937
DEF_VECTOR_STRING(NativeLibrary, Dependencies)
911938

@@ -941,14 +968,14 @@ TranslationUnit* ASTContext::FindOrCreateModule(std::string File)
941968

942969
auto existingUnit = std::find_if(TranslationUnits.begin(),
943970
TranslationUnits.end(), [&](TranslationUnit* unit) {
944-
return unit && unit->fileName == normalizedFile;
971+
return unit && unit->FileName == normalizedFile;
945972
});
946973

947974
if (existingUnit != TranslationUnits.end())
948975
return *existingUnit;
949976

950977
auto unit = new TranslationUnit();
951-
unit->fileName = normalizedFile;
978+
unit->FileName = normalizedFile;
952979
TranslationUnits.push_back(unit);
953980

954981
return unit;
@@ -957,6 +984,9 @@ TranslationUnit* ASTContext::FindOrCreateModule(std::string File)
957984
// Comments
958985
Comment::Comment(CommentKind kind) : kind(kind) {}
959986

987+
DEF_STRING(RawComment, Text)
988+
DEF_STRING(RawComment, BriefText)
989+
960990
RawComment::RawComment() : fullCommentBlock(0) {}
961991

962992
RawComment::~RawComment()
@@ -1007,10 +1037,12 @@ BlockContentComment::BlockContentComment(CommentKind Kind) : Comment(Kind) {}
10071037

10081038
BlockCommandComment::Argument::Argument() {}
10091039

1010-
BlockCommandComment::Argument::Argument(const Argument& rhs) : text(rhs.text) {}
1040+
BlockCommandComment::Argument::Argument(const Argument& rhs) : Text(rhs.Text) {}
10111041

10121042
BlockCommandComment::Argument::~Argument() {}
10131043

1044+
DEF_STRING(BlockCommandComment::Argument, Text)
1045+
10141046
BlockCommandComment::BlockCommandComment() : BlockContentComment(CommentKind::BlockCommandComment), commandId(0), paragraphComment(0) {}
10151047

10161048
BlockCommandComment::BlockCommandComment(CommentKind Kind) : BlockContentComment(Kind), commandId(0), paragraphComment(0) {}
@@ -1028,6 +1060,8 @@ TParamCommandComment::TParamCommandComment() : BlockCommandComment(CommentKind::
10281060

10291061
DEF_VECTOR(TParamCommandComment, unsigned, Position)
10301062

1063+
DEF_STRING(VerbatimBlockLineComment, Text)
1064+
10311065
VerbatimBlockComment::VerbatimBlockComment() : BlockCommandComment(CommentKind::VerbatimBlockComment) {}
10321066

10331067
VerbatimBlockComment::~VerbatimBlockComment()
@@ -1036,10 +1070,14 @@ VerbatimBlockComment::~VerbatimBlockComment()
10361070
delete line;
10371071
}
10381072

1073+
VerbatimBlockLineComment::VerbatimBlockLineComment() : Comment(CommentKind::VerbatimBlockLineComment) {}
1074+
10391075
DEF_VECTOR(VerbatimBlockComment, VerbatimBlockLineComment*, Lines)
10401076

10411077
VerbatimLineComment::VerbatimLineComment() : BlockCommandComment(CommentKind::VerbatimLineComment) {}
10421078

1079+
DEF_STRING(VerbatimLineComment, Text)
1080+
10431081
ParagraphComment::ParagraphComment() : BlockContentComment(CommentKind::ParagraphComment), isWhitespace(false) {}
10441082

10451083
ParagraphComment::~ParagraphComment()
@@ -1079,25 +1117,37 @@ HTMLTagComment::HTMLTagComment(CommentKind Kind) : InlineContentComment(Kind) {}
10791117

10801118
HTMLStartTagComment::Attribute::Attribute() {}
10811119

1082-
HTMLStartTagComment::Attribute::Attribute(const Attribute& rhs) : name(rhs.name), value(rhs.value) {}
1120+
HTMLStartTagComment::Attribute::Attribute(const Attribute& rhs) : Name(rhs.Name), Value(rhs.Value) {}
1121+
1122+
DEF_STRING(HTMLStartTagComment::Attribute, Name)
1123+
1124+
DEF_STRING(HTMLStartTagComment::Attribute, Value)
10831125

10841126
HTMLStartTagComment::Attribute::~Attribute() {}
10851127

10861128
HTMLStartTagComment::HTMLStartTagComment() : HTMLTagComment(CommentKind::HTMLStartTagComment) {}
10871129

10881130
DEF_VECTOR(HTMLStartTagComment, HTMLStartTagComment::Attribute, Attributes)
10891131

1132+
DEF_STRING(HTMLStartTagComment, TagName)
1133+
10901134
HTMLEndTagComment::HTMLEndTagComment() : HTMLTagComment(CommentKind::HTMLEndTagComment) {}
10911135

1136+
DEF_STRING(HTMLEndTagComment, TagName)
1137+
10921138
InlineContentComment::InlineContentComment() : Comment(CommentKind::InlineContentComment), hasTrailingNewline(false) {}
10931139

10941140
InlineContentComment::InlineContentComment(CommentKind Kind) : Comment(Kind), hasTrailingNewline(false) {}
10951141

10961142
TextComment::TextComment() : InlineContentComment(CommentKind::TextComment) {}
10971143

1144+
DEF_STRING(TextComment, Text)
1145+
10981146
InlineCommandComment::Argument::Argument() {}
10991147

1100-
InlineCommandComment::Argument::Argument(const Argument& rhs) : text(rhs.text) {}
1148+
InlineCommandComment::Argument::Argument(const Argument& rhs) : Text(rhs.Text) {}
1149+
1150+
DEF_STRING(InlineCommandComment::Argument, Text)
11011151

11021152
InlineCommandComment::Argument::~Argument() {}
11031153

@@ -1106,6 +1156,4 @@ InlineCommandComment::InlineCommandComment()
11061156

11071157
DEF_VECTOR(InlineCommandComment, InlineCommandComment::Argument, Arguments)
11081158

1109-
VerbatimBlockLineComment::VerbatimBlockLineComment() : Comment(CommentKind::VerbatimBlockLineComment) {}
1110-
11111159
} } }

0 commit comments

Comments
 (0)