From 6bb0a7b82684d1ce59a996848773054ede1f442e Mon Sep 17 00:00:00 2001 From: Mark Spruiell Date: Mon, 24 Sep 2012 16:00:56 -0700 Subject: Ruby port; Python & C++ fixes --- cpp/src/slice2cpp/Gen.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'cpp/src/slice2cpp/Gen.cpp') diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index e46b5aeae43..1edb081c9ad 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -4581,7 +4581,17 @@ Slice::Gen::ObjectVisitor::emitGCFunctions(const ClassDefPtr& p) { if((*i)->type()->usesClasses()) { - emitGCInsertCode((*i)->type(), getDataMemberRef(*i), "", 0); + if((*i)->optional()) + { + C << nl << "if(" << fixKwd((*i)->name()) << ')'; + C << sb; + emitGCInsertCode((*i)->type(), getDataMemberRef(*i), "", 0); + C << eb; + } + else + { + emitGCInsertCode((*i)->type(), getDataMemberRef(*i), "", 0); + } } } C << eb; @@ -4617,7 +4627,17 @@ Slice::Gen::ObjectVisitor::emitGCFunctions(const ClassDefPtr& p) { if((*j)->type()->usesClasses()) { - emitGCClearCode((*j)->type(), getDataMemberRef(*j), "", 0); + if((*j)->optional()) + { + C << nl << "if(" << fixKwd((*j)->name()) << ')'; + C << sb; + emitGCClearCode((*j)->type(), getDataMemberRef(*j), "", 0); + C << eb; + } + else + { + emitGCClearCode((*j)->type(), getDataMemberRef(*j), "", 0); + } } } C << eb; -- cgit v1.2.3