diff options
author | Michi Henning <michi@zeroc.com> | 2006-07-16 00:44:14 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2006-07-16 00:44:14 +0000 |
commit | ba29ace8169d09698fc7ff750c52e5d4641d2e2c (patch) | |
tree | 7cfc31b26a894aacb5696271d293a66a166be5f9 /cpp | |
parent | remove ability to create a dual java distro (diff) | |
download | ice-ba29ace8169d09698fc7ff750c52e5d4641d2e2c.tar.bz2 ice-ba29ace8169d09698fc7ff750c52e5d4641d2e2c.tar.xz ice-ba29ace8169d09698fc7ff750c52e5d4641d2e2c.zip |
Fixed http://www.zeroc.com/vbulletin/showthread.php?p=10871#post10871
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/CHANGES | 21 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 15 | ||||
-rw-r--r-- | cpp/test/Ice/gc/Test.ice | 29 |
3 files changed, 56 insertions, 9 deletions
diff --git a/cpp/CHANGES b/cpp/CHANGES index 4a819157f84..4528276e798 100644 --- a/cpp/CHANGES +++ b/cpp/CHANGES @@ -1,6 +1,27 @@ Changes since version 3.1.0 --------------------------- +- Fixed a bug in slice2cpp that caused incorrect code to be generated + if a class had member that was an interface (not class) by value: + + interface I + { + void op(); + }; + + class C + { + void op(); + }; + + class MyClass + { + I myI; // Note: I, not I*. Bad code generated for this in 3.1.0. + I* myIstar; // OK, no problem with 3.1.0. + C myC; // OK, no problem with 3.1.0. + C myCstar; // OK, no problem with 3.1.0. + }; + - For non-abstract Slice classes, the C++ code generated now adds a protected destructor. This prevents accidental allocation of class instances on the stack or as static variables. For the diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 03fcc4555c3..43af82aeb33 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -441,7 +441,7 @@ Slice::Gen::TypesVisitor::visitModuleEnd(const ModulePtr& p) bool Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) { - if(!p->isInterface() && !p->isLocal()) + if(!p->isLocal()) { string name = fixKwd(p->name()); string scope = fixKwd(p->scope()); @@ -459,7 +459,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) C << eb; C << sp << nl << "void"; - C << nl << scope.substr(2) << "__decRefUnsafe(" << name << "Ptr& p)"; + C << nl << scope.substr(2) << "__decRefUnsafe(const " << name << "Ptr& p)"; C << sb; C << nl << "p->__decRefUnsafe();"; C << eb; @@ -4008,13 +4008,10 @@ Slice::Gen::HandleVisitor::visitClassDecl(const ClassDeclPtr& p) H << nl << _dllExport << "void ice_read" << name << "(const ::Ice::InputStreamPtr&, " << name << "Ptr&);"; } - if(!p->isInterface()) - { - H << sp << nl << "void __addObject(const " << name << "Ptr&, ::IceInternal::GCCountMap&);"; - H << nl << "bool __usesClasses(const " << name << "Ptr&);"; - H << nl << "void __decRefUnsafe(" << name << "Ptr&);"; - H << nl << "void __clearHandleUnsafe(" << name << "Ptr&);"; - } + H << sp << nl << "void __addObject(const " << name << "Ptr&, ::IceInternal::GCCountMap&);"; + H << nl << "bool __usesClasses(const " << name << "Ptr&);"; + H << nl << "void __decRefUnsafe(const " << name << "Ptr&);"; + H << nl << "void __clearHandleUnsafe(" << name << "Ptr&);"; } } diff --git a/cpp/test/Ice/gc/Test.ice b/cpp/test/Ice/gc/Test.ice index 4f9ed11da06..ac0724bdf12 100644 --- a/cpp/test/Ice/gc/Test.ice +++ b/cpp/test/Ice/gc/Test.ice @@ -163,6 +163,35 @@ module CCC }; }; +module DDD +{ + interface I + { + void op(); + }; + + class C + { + void op(); + }; + + class C2; + + class U + { + I myI; + I* myIstar; + C myC; + C* myCstar; + C2 myC2; + C2* myC2star; + }; + + class C2 + { + }; +}; + }; #endif |