Browse Source

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

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

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

21
src/CppParser/AST.cpp

@ -498,8 +498,6 @@ DEF_STRING(Statement, String) @@ -498,8 +498,6 @@ DEF_STRING(Statement, String)
Statement::Statement(const std::string& str, StatementClass stmtClass, Declaration* decl) : String(str), Class(stmtClass), Decl(decl) {}
Statement::~Statement() {}
Expression::Expression(const std::string& str, StatementClass stmtClass, Declaration* decl)
: Statement(str, stmtClass, decl) {}
@ -542,7 +540,24 @@ Parameter::Parameter() : Declaration(DeclarationKind::Parameter), @@ -542,7 +540,24 @@ Parameter::Parameter() : Declaration(DeclarationKind::Parameter),
Parameter::~Parameter()
{
if (DefaultArgument)
delete DefaultArgument;
{
// HACK: see https://github.com/mono/CppSharp/issues/598
switch (DefaultArgument->Class)
{
case StatementClass::BinaryOperator:
delete static_cast<BinaryOperator*>(DefaultArgument);
break;
case StatementClass::CallExprClass:
delete static_cast<CallExpr*>(DefaultArgument);
break;
case StatementClass::CXXConstructExprClass:
delete static_cast<CXXConstructExpr*>(DefaultArgument);
break;
default:
delete DefaultArgument;
break;
}
}
}
Function::Function()

1
src/CppParser/AST.h

@ -498,7 +498,6 @@ class CS_API Statement @@ -498,7 +498,6 @@ class CS_API Statement
{
public:
Statement(const std::string& str, StatementClass Class = StatementClass::Any, Declaration* decl = 0);
virtual ~Statement();
StatementClass Class;
Declaration* Decl;
STRING(String)

Loading…
Cancel
Save