Browse Source

Fixed the destruction of comments another way because this one crashes the OS X build.

See https://github.com/mono/CppSharp/issues/599.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/600/head
Dimitar Dobrev 10 years ago
parent
commit
a95511600f
  1. 55
      src/CppParser/AST.cpp
  2. 1
      src/CppParser/AST.h

55
src/CppParser/AST.cpp

@ -809,8 +809,6 @@ TranslationUnit* ASTContext::FindOrCreateModule(std::string File)
// Comments // Comments
Comment::Comment(CommentKind kind) : Kind(kind) {} Comment::Comment(CommentKind kind) : Kind(kind) {}
Comment::~Comment() {}
DEF_STRING(RawComment, Text) DEF_STRING(RawComment, Text)
DEF_STRING(RawComment, BriefText) DEF_STRING(RawComment, BriefText)
@ -827,7 +825,33 @@ FullComment::FullComment() : Comment(CommentKind::FullComment) {}
FullComment::~FullComment() FullComment::~FullComment()
{ {
for (auto& block : Blocks) for (auto& block : Blocks)
delete block; {
// HACK: see https://github.com/mono/CppSharp/issues/599
switch (block->Kind)
{
case CommentKind::BlockCommandComment:
delete static_cast<BlockCommandComment*>(block);
break;
case CommentKind::ParamCommandComment:
delete static_cast<ParamCommandComment*>(block);
break;
case CommentKind::TParamCommandComment:
delete static_cast<TParamCommandComment*>(block);
break;
case CommentKind::VerbatimBlockComment:
delete static_cast<VerbatimBlockComment*>(block);
break;
case CommentKind::VerbatimLineComment:
delete static_cast<VerbatimLineComment*>(block);
break;
case CommentKind::ParagraphComment:
delete static_cast<ParagraphComment*>(block);
break;
default:
delete block;
break;
}
}
} }
DEF_VECTOR(FullComment, BlockContentComment*, Blocks) DEF_VECTOR(FullComment, BlockContentComment*, Blocks)
@ -871,7 +895,30 @@ ParagraphComment::ParagraphComment() : BlockContentComment(CommentKind::Paragrap
ParagraphComment::~ParagraphComment() ParagraphComment::~ParagraphComment()
{ {
for (auto& content : Content) for (auto& content : Content)
delete content; {
// HACK: see https://github.com/mono/CppSharp/issues/599
switch (content->Kind)
{
case CommentKind::InlineCommandComment:
delete static_cast<InlineCommandComment*>(content);
break;
case CommentKind::HTMLTagComment:
delete static_cast<HTMLTagComment*>(content);
break;
case CommentKind::HTMLStartTagComment:
delete static_cast<HTMLStartTagComment*>(content);
break;
case CommentKind::HTMLEndTagComment:
delete static_cast<HTMLEndTagComment*>(content);
break;
case CommentKind::TextComment:
delete static_cast<TextComment*>(content);
break;
default:
delete content;
break;
}
}
} }
DEF_VECTOR(ParagraphComment, InlineContentComment*, Content) DEF_VECTOR(ParagraphComment, InlineContentComment*, Content)

1
src/CppParser/AST.h

@ -932,7 +932,6 @@ class CS_API CS_ABSTRACT Comment
{ {
public: public:
Comment(CommentKind kind); Comment(CommentKind kind);
virtual ~Comment();
CommentKind Kind; CommentKind Kind;
}; };

Loading…
Cancel
Save