diff options
author | Marc Laukien <marc@zeroc.com> | 2002-01-23 15:02:52 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2002-01-23 15:02:52 +0000 |
commit | d0c10bd20d41334973de40b315ac17a41265d627 (patch) | |
tree | 09044e57cdb3b2727683d9fdbd86d8808cfcac0c /cpp/src/slice2cpp | |
parent | adding --impl option (diff) | |
download | ice-d0c10bd20d41334973de40b315ac17a41265d627.tar.bz2 ice-d0c10bd20d41334973de40b315ac17a41265d627.tar.xz ice-d0c10bd20d41334973de40b315ac17a41265d627.zip |
fixes
Diffstat (limited to 'cpp/src/slice2cpp')
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 467 |
1 files changed, 232 insertions, 235 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 686c689e5b6..7d6f343009b 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -2092,6 +2092,229 @@ Slice::Gen::ObjectVisitor::visitDataMember(const DataMemberPtr& p) H << nl << s << ' ' << name << ';'; } +Slice::Gen::IceInternalVisitor::IceInternalVisitor(Output& h, Output& c, const string& dllExport) : + H(h), C(c), _dllExport(dllExport) +{ +} + +bool +Slice::Gen::IceInternalVisitor::visitUnitStart(const UnitPtr& p) +{ + if (!p->hasClassDecls()) + { + return false; + } + + H << sp; + H << nl << "namespace IceInternal" << nl << '{'; + + return true; +} + +void +Slice::Gen::IceInternalVisitor::visitUnitEnd(const UnitPtr& p) +{ + H << sp; + H << nl << '}'; +} + +void +Slice::Gen::IceInternalVisitor::visitClassDecl(const ClassDeclPtr& p) +{ + string scoped = p->scoped(); + + H << sp; + H << nl << _dllExport << "void incRef(" << scoped << "*);"; + H << nl << _dllExport << "void decRef(" << scoped << "*);"; + if (!p->isLocal()) + { + H << sp; + H << nl << _dllExport << "void incRef(::IceProxy" << scoped << "*);"; + H << nl << _dllExport << "void decRef(::IceProxy" << scoped << "*);"; + + H << sp; + H << nl << _dllExport << "void checkedCast(const ::Ice::ObjectPrx&, const ::std::string&, " + << "ProxyHandle< ::IceProxy" << scoped << ">&);"; + H << nl << _dllExport << "void uncheckedCast(const ::Ice::ObjectPrx&, const ::std::string&, " + << "ProxyHandle< ::IceProxy" << scoped << ">&);"; + } +} + +bool +Slice::Gen::IceInternalVisitor::visitClassDefStart(const ClassDefPtr& p) +{ + string scoped = p->scoped(); + string scope = p->scope(); + + C << sp; + C << nl << "void" << nl << "IceInternal::incRef(" << scoped << "* p)"; + C << sb; + C << nl << "p->__incRef();"; + C << eb; + + C << sp; + C << nl << "void" << nl << "IceInternal::decRef(" << scoped << "* p)"; + C << sb; + C << nl << "p->__decRef();"; + C << eb; + + if (!p->isLocal()) + { + C << sp; + C << nl << "void" << nl << "IceInternal::incRef(::IceProxy" << scoped << "* p)"; + C << sb; + C << nl << "p->__incRef();"; + C << eb; + + C << sp; + C << nl << "void" << nl << "IceInternal::decRef(::IceProxy" << scoped << "* p)"; + C << sb; + C << nl << "p->__decRef();"; + C << eb; + + C << sp; + C << nl << "void" << nl << "IceInternal::checkedCast(const ::Ice::ObjectPrx& b, const ::std::string& f, " + << scoped << "Prx& d)"; + C << sb; + C << nl << "d = 0;"; + C << nl << "if (b)"; + C << sb; + C << nl << "if (f == b->ice_getFacet())"; + C << sb; + C << nl << "d = dynamic_cast< ::IceProxy" << scoped << "*>(b.get());"; + C << nl << "if (!d && b->ice_isA(\"" << scoped << "\"))"; + C << sb; + C << nl << "d = new ::IceProxy" << scoped << ";"; + C << nl << "d->__copyFrom(b);"; + C << eb; + C << eb; + C << nl << "else"; + C << sb; + C << nl << "::Ice::ObjectPrx bb = b->ice_newFacet(f);"; + C << nl << "try"; + C << sb; + C << nl << "if (bb->ice_isA(\"" << scoped << "\"))"; + C << sb; + C << nl << "d = new ::IceProxy" << scoped << ";"; + C << nl << "d->__copyFrom(bb);"; + C << eb; + C << eb; + C << nl << "catch (const ::Ice::FacetNotExistException&)"; + C << sb; + C << eb; + C << eb; + C << eb; + C << eb; + + C << sp; + C << nl << "void" << nl << "IceInternal::uncheckedCast(const ::Ice::ObjectPrx& b, const ::std::string& f, " + << scoped << "Prx& d)"; + C << sb; + C << nl << "d = 0;"; + C << nl << "if (b)"; + C << sb; + C << nl << "if (f == b->ice_getFacet())"; + C << sb; + C << nl << "d = dynamic_cast< ::IceProxy" << scoped << "*>(b.get());"; + C << nl << "if (!d)"; + C << sb; + C << nl << "d = new ::IceProxy" << scoped << ";"; + C << nl << "d->__copyFrom(b);"; + C << eb; + C << eb; + C << nl << "else"; + C << sb; + C << nl << "::Ice::ObjectPrx bb = b->ice_newFacet(f);"; + C << nl << "d = new ::IceProxy" << scoped << ";"; + C << nl << "d->__copyFrom(bb);"; + C << eb; + C << eb; + C << eb; + } + + return true; +} + +Slice::Gen::HandleVisitor::HandleVisitor(Output& h, Output& c, const string& dllExport) : + H(h), C(c), _dllExport(dllExport) +{ +} + +bool +Slice::Gen::HandleVisitor::visitModuleStart(const ModulePtr& p) +{ + if (!p->hasClassDecls()) + { + return false; + } + + string name = p->name(); + + H << sp; + H << nl << "namespace " << name << nl << '{'; + + return true; +} + +void +Slice::Gen::HandleVisitor::visitModuleEnd(const ModulePtr& p) +{ + H << sp; + H << nl << '}'; +} + +void +Slice::Gen::HandleVisitor::visitClassDecl(const ClassDeclPtr& p) +{ + string name = p->name(); + string scoped = p->scoped(); + + H << sp; + H << nl << "typedef ::IceInternal::Handle< " << scoped << "> " << name << "Ptr;"; + if (!p->isLocal()) + { + H << nl << "typedef ::IceInternal::ProxyHandle< ::IceProxy" << scoped << "> " << name << "Prx;"; + H << sp; + H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name << "Prx&);"; + H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "Prx&);"; + } +} + +bool +Slice::Gen::HandleVisitor::visitClassDefStart(const ClassDefPtr& p) +{ + if (!p->isLocal()) + { + string scoped = p->scoped(); + string scope = p->scope(); + + C << sp; + C << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const " << scoped + << "Prx& v)"; + C << sb; + C << nl << "__os->write(::Ice::ObjectPrx(v));"; + C << eb; + C << sp; + C << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped + << "Prx& v)"; + C << sb; + C << nl << "::Ice::ObjectPrx proxy;"; + C << nl << "__is->read(proxy);"; + C << nl << "if (!proxy)"; + C << sb; + C << nl << "v = 0;"; + C << eb; + C << nl << "else"; + C << sb; + C << nl << "v = new ::IceProxy" << scoped << ';'; + C << nl << "v->__copyFrom(proxy);"; + C << eb; + C << eb; + } + + return true; +} + Slice::Gen::ImplVisitor::ImplVisitor(Output& h, Output& c, const string& dllExport) : H(h), C(c), _dllExport(dllExport) @@ -2099,8 +2322,7 @@ Slice::Gen::ImplVisitor::ImplVisitor(Output& h, Output& c, } void -Slice::Gen::ImplVisitor::writeAssign(Output& out, const TypePtr& type, - const string& name, int& iter) +Slice::Gen::ImplVisitor::writeAssign(Output& out, const TypePtr& type, const string& name, int& iter) { BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); if (builtin) @@ -2109,7 +2331,7 @@ Slice::Gen::ImplVisitor::writeAssign(Output& out, const TypePtr& type, { case Builtin::KindByte: { - out << nl << name << " = (Ice::Byte)0;"; + out << nl << name << " = ::Ice::Byte(0);"; break; } case Builtin::KindBool: @@ -2119,27 +2341,27 @@ Slice::Gen::ImplVisitor::writeAssign(Output& out, const TypePtr& type, } case Builtin::KindShort: { - out << nl << name << " = (Ice::Short)0;"; + out << nl << name << " = ::Ice::Short(0);"; break; } case Builtin::KindInt: { - out << nl << name << " = (Ice::Int)0;"; + out << nl << name << " = ::Ice::Int(0);"; break; } case Builtin::KindLong: { - out << nl << name << " = (Ice::Long)0;"; + out << nl << name << " = ::Ice::Long(0);"; break; } case Builtin::KindFloat: { - out << nl << name << " = (Ice::Float)0;"; + out << nl << name << " = ::Ice::Float(0);"; break; } case Builtin::KindDouble: { - out << nl << name << " = (Ice::Double)0;"; + out << nl << name << " = ::Ice::Double(0);"; break; } case Builtin::KindString: @@ -2191,8 +2413,7 @@ Slice::Gen::ImplVisitor::writeAssign(Output& out, const TypePtr& type, if (en) { EnumeratorList enumerators = en->getEnumerators(); - out << nl << name << " = " << en->scope() - << enumerators.front()->name() << ';'; + out << nl << name << " = " << en->scope() << enumerators.front()->name() << ';'; return; } @@ -2200,8 +2421,7 @@ Slice::Gen::ImplVisitor::writeAssign(Output& out, const TypePtr& type, if (seq) { out << nl << name << ".resize(5);"; - out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < " - << name << ".size(); __i" << iter << "++)"; + out << nl << "for (int __i" << iter << " = 0; __i" << iter << " < " << name << ".size(); __i" << iter << "++)"; out << sb; ostringstream elem; elem << name << "[__i" << iter << ']'; @@ -2396,226 +2616,3 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) return true; } - -Slice::Gen::IceInternalVisitor::IceInternalVisitor(Output& h, Output& c, const string& dllExport) : - H(h), C(c), _dllExport(dllExport) -{ -} - -bool -Slice::Gen::IceInternalVisitor::visitUnitStart(const UnitPtr& p) -{ - if (!p->hasClassDecls()) - { - return false; - } - - H << sp; - H << nl << "namespace IceInternal" << nl << '{'; - - return true; -} - -void -Slice::Gen::IceInternalVisitor::visitUnitEnd(const UnitPtr& p) -{ - H << sp; - H << nl << '}'; -} - -void -Slice::Gen::IceInternalVisitor::visitClassDecl(const ClassDeclPtr& p) -{ - string scoped = p->scoped(); - - H << sp; - H << nl << _dllExport << "void incRef(" << scoped << "*);"; - H << nl << _dllExport << "void decRef(" << scoped << "*);"; - if (!p->isLocal()) - { - H << sp; - H << nl << _dllExport << "void incRef(::IceProxy" << scoped << "*);"; - H << nl << _dllExport << "void decRef(::IceProxy" << scoped << "*);"; - - H << sp; - H << nl << _dllExport << "void checkedCast(const ::Ice::ObjectPrx&, const ::std::string&, " - << "ProxyHandle< ::IceProxy" << scoped << ">&);"; - H << nl << _dllExport << "void uncheckedCast(const ::Ice::ObjectPrx&, const ::std::string&, " - << "ProxyHandle< ::IceProxy" << scoped << ">&);"; - } -} - -bool -Slice::Gen::IceInternalVisitor::visitClassDefStart(const ClassDefPtr& p) -{ - string scoped = p->scoped(); - string scope = p->scope(); - - C << sp; - C << nl << "void" << nl << "IceInternal::incRef(" << scoped << "* p)"; - C << sb; - C << nl << "p->__incRef();"; - C << eb; - - C << sp; - C << nl << "void" << nl << "IceInternal::decRef(" << scoped << "* p)"; - C << sb; - C << nl << "p->__decRef();"; - C << eb; - - if (!p->isLocal()) - { - C << sp; - C << nl << "void" << nl << "IceInternal::incRef(::IceProxy" << scoped << "* p)"; - C << sb; - C << nl << "p->__incRef();"; - C << eb; - - C << sp; - C << nl << "void" << nl << "IceInternal::decRef(::IceProxy" << scoped << "* p)"; - C << sb; - C << nl << "p->__decRef();"; - C << eb; - - C << sp; - C << nl << "void" << nl << "IceInternal::checkedCast(const ::Ice::ObjectPrx& b, const ::std::string& f, " - << scoped << "Prx& d)"; - C << sb; - C << nl << "d = 0;"; - C << nl << "if (b)"; - C << sb; - C << nl << "if (f == b->ice_getFacet())"; - C << sb; - C << nl << "d = dynamic_cast< ::IceProxy" << scoped << "*>(b.get());"; - C << nl << "if (!d && b->ice_isA(\"" << scoped << "\"))"; - C << sb; - C << nl << "d = new ::IceProxy" << scoped << ";"; - C << nl << "d->__copyFrom(b);"; - C << eb; - C << eb; - C << nl << "else"; - C << sb; - C << nl << "::Ice::ObjectPrx bb = b->ice_newFacet(f);"; - C << nl << "try"; - C << sb; - C << nl << "if (bb->ice_isA(\"" << scoped << "\"))"; - C << sb; - C << nl << "d = new ::IceProxy" << scoped << ";"; - C << nl << "d->__copyFrom(bb);"; - C << eb; - C << eb; - C << nl << "catch (const ::Ice::FacetNotExistException&)"; - C << sb; - C << eb; - C << eb; - C << eb; - C << eb; - - C << sp; - C << nl << "void" << nl << "IceInternal::uncheckedCast(const ::Ice::ObjectPrx& b, const ::std::string& f, " - << scoped << "Prx& d)"; - C << sb; - C << nl << "d = 0;"; - C << nl << "if (b)"; - C << sb; - C << nl << "if (f == b->ice_getFacet())"; - C << sb; - C << nl << "d = dynamic_cast< ::IceProxy" << scoped << "*>(b.get());"; - C << nl << "if (!d)"; - C << sb; - C << nl << "d = new ::IceProxy" << scoped << ";"; - C << nl << "d->__copyFrom(b);"; - C << eb; - C << eb; - C << nl << "else"; - C << sb; - C << nl << "::Ice::ObjectPrx bb = b->ice_newFacet(f);"; - C << nl << "d = new ::IceProxy" << scoped << ";"; - C << nl << "d->__copyFrom(bb);"; - C << eb; - C << eb; - C << eb; - } - - return true; -} - -Slice::Gen::HandleVisitor::HandleVisitor(Output& h, Output& c, const string& dllExport) : - H(h), C(c), _dllExport(dllExport) -{ -} - -bool -Slice::Gen::HandleVisitor::visitModuleStart(const ModulePtr& p) -{ - if (!p->hasClassDecls()) - { - return false; - } - - string name = p->name(); - - H << sp; - H << nl << "namespace " << name << nl << '{'; - - return true; -} - -void -Slice::Gen::HandleVisitor::visitModuleEnd(const ModulePtr& p) -{ - H << sp; - H << nl << '}'; -} - -void -Slice::Gen::HandleVisitor::visitClassDecl(const ClassDeclPtr& p) -{ - string name = p->name(); - string scoped = p->scoped(); - - H << sp; - H << nl << "typedef ::IceInternal::Handle< " << scoped << "> " << name << "Ptr;"; - if (!p->isLocal()) - { - H << nl << "typedef ::IceInternal::ProxyHandle< ::IceProxy" << scoped << "> " << name << "Prx;"; - H << sp; - H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name << "Prx&);"; - H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "Prx&);"; - } -} - -bool -Slice::Gen::HandleVisitor::visitClassDefStart(const ClassDefPtr& p) -{ - if (!p->isLocal()) - { - string scoped = p->scoped(); - string scope = p->scope(); - - C << sp; - C << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const " << scoped - << "Prx& v)"; - C << sb; - C << nl << "__os->write(::Ice::ObjectPrx(v));"; - C << eb; - C << sp; - C << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped - << "Prx& v)"; - C << sb; - C << nl << "::Ice::ObjectPrx proxy;"; - C << nl << "__is->read(proxy);"; - C << nl << "if (!proxy)"; - C << sb; - C << nl << "v = 0;"; - C << eb; - C << nl << "else"; - C << sb; - C << nl << "v = new ::IceProxy" << scoped << ';'; - C << nl << "v->__copyFrom(proxy);"; - C << eb; - C << eb; - } - - return true; -} |