diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2005-03-31 16:00:13 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2005-03-31 16:00:13 +0000 |
commit | 5e599fce5d155d010e27588cceeaef35bd2d0af7 (patch) | |
tree | 2b21129d52f74ce10bf1ebf568169b2d2b36b3cf /cpp/src | |
parent | ObjectNotExistException are now always retried. (diff) | |
download | ice-5e599fce5d155d010e27588cceeaef35bd2d0af7.tar.bz2 ice-5e599fce5d155d010e27588cceeaef35bd2d0af7.tar.xz ice-5e599fce5d155d010e27588cceeaef35bd2d0af7.zip |
More Ice-E changes
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/slice2cppe/Gen.cpp | 342 | ||||
-rw-r--r-- | cpp/src/slice2cppe/Gen.h | 44 | ||||
-rw-r--r-- | cpp/src/slice2javae/Gen.cpp | 204 | ||||
-rw-r--r-- | cpp/src/slice2javae/Gen.h | 18 |
4 files changed, 8 insertions, 600 deletions
diff --git a/cpp/src/slice2cppe/Gen.cpp b/cpp/src/slice2cppe/Gen.cpp index 6306a576439..522f5ba0c43 100644 --- a/cpp/src/slice2cppe/Gen.cpp +++ b/cpp/src/slice2cppe/Gen.cpp @@ -281,12 +281,6 @@ Slice::Gen::generate(const UnitPtr& p) DelegateVisitor delegateVisitor(H, C, _dllExport); p->visit(&delegateVisitor, false); - DelegateMVisitor delegateMVisitor(H, C, _dllExport); - p->visit(&delegateMVisitor, false); - - DelegateDVisitor delegateDVisitor(H, C, _dllExport); - p->visit(&delegateDVisitor, false); - ObjectVisitor objectVisitor(H, C, _dllExport, _stream); p->visit(&objectVisitor, false); @@ -1341,8 +1335,7 @@ Slice::Gen::ProxyVisitor::visitClassDefEnd(const ClassDefPtr& p) H.dec(); H << sp << nl << "private: "; H.inc(); - H << sp << nl << "virtual ::IceInternal::Handle< ::IceDelegateM::Ice::Object> __createDelegateM();"; - H << nl << "virtual ::IceInternal::Handle< ::IceDelegateD::Ice::Object> __createDelegateD();"; + H << sp << nl << "virtual ::IceInternal::Handle< ::IceDelegate::Ice::Object> __createDelegate();"; H << eb << ';'; C << sp; @@ -1351,15 +1344,10 @@ Slice::Gen::ProxyVisitor::visitClassDefEnd(const ClassDefPtr& p) C << nl << "return "<< scoped << "::ice_staticId();"; C << eb; - C << sp << nl << "::IceInternal::Handle< ::IceDelegateM::Ice::Object>"; - C << nl << "IceProxy" << scoped << "::__createDelegateM()"; + C << sp << nl << "::IceInternal::Handle< ::IceDelegate::Ice::Object>"; + C << nl << "IceProxy" << scoped << "::__createDelegate()"; C << sb; - C << nl << "return ::IceInternal::Handle< ::IceDelegateM::Ice::Object>(new ::IceDelegateM" << scoped << ");"; - C << eb; - C << sp << nl << "::IceInternal::Handle< ::IceDelegateD::Ice::Object>"; - C << nl << "IceProxy" << scoped << "::__createDelegateD()"; - C << sb; - C << nl << "return ::IceInternal::Handle< ::IceDelegateD::Ice::Object>(new ::IceDelegateD" << scoped << ");"; + C << nl << "return ::IceInternal::Handle< ::IceDelegate::Ice::Object>(new ::IceDelegate" << scoped << ");"; C << eb; C << sp; @@ -1621,135 +1609,6 @@ void Slice::Gen::DelegateVisitor::visitOperation(const OperationPtr& p) { string name = fixKwd(p->name()); - - TypePtr ret = p->returnType(); - string retS = returnTypeToString(ret); - - vector<string> params; - - ParamDeclList paramList = p->parameters(); - for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) - { -#if defined(__SUNPRO_CC) && (__SUNPRO_CC==0x550) - // - // Work around for Sun CC 5.5 bug #4853566 - // - string typeString; - if((*q)->isOutParam()) - { - typeString = outputTypeToString((*q)->type()); - } - else - { - typeString = inputTypeToString((*q)->type()); - } -#else - string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type()) : inputTypeToString((*q)->type()); -#endif - - params.push_back(typeString); - } - - params.push_back("const ::Ice::Context&"); - - H << sp << nl << "virtual " << retS << ' ' << name << spar << params << epar << " = 0;"; -} - -Slice::Gen::DelegateMVisitor::DelegateMVisitor(Output& h, Output& c, const string& dllExport) : - H(h), C(c), _dllExport(dllExport) -{ -} - -bool -Slice::Gen::DelegateMVisitor::visitUnitStart(const UnitPtr& p) -{ - if(!p->hasNonLocalClassDecls()) - { - return false; - } - - H << sp << nl << "namespace IceDelegateM" << nl << '{'; - - return true; -} - -void -Slice::Gen::DelegateMVisitor::visitUnitEnd(const UnitPtr& p) -{ - H << sp << nl << '}'; -} - -bool -Slice::Gen::DelegateMVisitor::visitModuleStart(const ModulePtr& p) -{ - if(!p->hasNonLocalClassDecls()) - { - return false; - } - - string name = fixKwd(p->name()); - - H << sp << nl << "namespace " << name << nl << '{'; - - return true; -} - -void -Slice::Gen::DelegateMVisitor::visitModuleEnd(const ModulePtr& p) -{ - H << sp << nl << '}'; -} - -bool -Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) -{ - if(p->isLocal()) - { - return false; - } - - string name = fixKwd(p->name()); - string scoped = fixKwd(p->scoped()); - ClassList bases = p->bases(); - - H << sp << nl << "class " << _dllExport << name << " : "; - H.useCurrentPosAsIndent(); - H << "virtual public ::IceDelegate" << scoped << ','; - if(bases.empty()) - { - H << nl << "virtual public ::IceDelegateM::Ice::Object"; - } - else - { - ClassList::const_iterator q = bases.begin(); - while(q != bases.end()) - { - H << nl << "virtual public ::IceDelegateM" << fixKwd((*q)->scoped()); - if(++q != bases.end()) - { - H << ','; - } - } - } - H.restoreIndent(); - H << sb; - H.dec(); - H << nl << "public:"; - H.inc(); - - return true; -} - -void -Slice::Gen::DelegateMVisitor::visitClassDefEnd(const ClassDefPtr& p) -{ - H << eb << ';'; -} - -void -Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) -{ - string name = fixKwd(p->name()); string scoped = fixKwd(p->scoped()); TypePtr ret = p->returnType(); @@ -1786,7 +1645,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) paramsDecl.push_back("const ::Ice::Context& __context"); H << sp << nl << "virtual " << retS << ' ' << name << spar << params << epar << ';'; - C << sp << nl << retS << nl << "IceDelegateM" << scoped << spar << paramsDecl << epar; + C << sp << nl << retS << nl << "IceDelegate" << scoped << spar << paramsDecl << epar; C << sb; C << nl << "static const ::std::string __operation(\"" << p->name() << "\");"; C << nl << "::IceInternal::Outgoing __out(__connection.get(), __reference.get(), __operation, " @@ -1869,197 +1728,6 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) C << eb; } -Slice::Gen::DelegateDVisitor::DelegateDVisitor(Output& h, Output& c, const string& dllExport) : - H(h), C(c), _dllExport(dllExport) -{ -} - -bool -Slice::Gen::DelegateDVisitor::visitUnitStart(const UnitPtr& p) -{ - if(!p->hasNonLocalClassDecls()) - { - return false; - } - - H << sp << nl << "namespace IceDelegateD" << nl << '{'; - - return true; -} - -void -Slice::Gen::DelegateDVisitor::visitUnitEnd(const UnitPtr& p) -{ - H << sp << nl << '}'; -} - -bool -Slice::Gen::DelegateDVisitor::visitModuleStart(const ModulePtr& p) -{ - if(!p->hasNonLocalClassDecls()) - { - return false; - } - - string name = fixKwd(p->name()); - - H << sp << nl << "namespace " << name << nl << '{'; - - return true; -} - -void -Slice::Gen::DelegateDVisitor::visitModuleEnd(const ModulePtr& p) -{ - H << sp << nl << '}'; -} - -bool -Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) -{ - if(p->isLocal()) - { - return false; - } - - string name = fixKwd(p->name()); - string scoped = fixKwd(p->scoped()); - ClassList bases = p->bases(); - - H << sp << nl << "class " << _dllExport << name << " : "; - H.useCurrentPosAsIndent(); - H << "virtual public ::IceDelegate" << scoped << ','; - if(bases.empty()) - { - H << nl << "virtual public ::IceDelegateD::Ice::Object"; - } - else - { - ClassList::const_iterator q = bases.begin(); - while(q != bases.end()) - { - H << nl << "virtual public ::IceDelegateD" << fixKwd((*q)->scoped()); - if(++q != bases.end()) - { - H << ','; - } - } - } - H.restoreIndent(); - H << sb; - H.dec(); - H << nl << "public:"; - H.inc(); - - return true; -} - -void -Slice::Gen::DelegateDVisitor::visitClassDefEnd(const ClassDefPtr& p) -{ - H << eb << ';'; -} - -void -Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) -{ - string name = fixKwd(p->name()); - string scoped = fixKwd(p->scoped()); - - TypePtr ret = p->returnType(); - string retS = returnTypeToString(ret); - - vector<string> params; - vector<string> paramsDecl; - vector<string> args; - - ParamDeclList paramList = p->parameters(); - for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) - { - string paramName = fixKwd((*q)->name()); - -#if defined(__SUNPRO_CC) && (__SUNPRO_CC==0x550) - // - // Work around for Sun CC 5.5 bug #4853566 - // - string typeString; - if((*q)->isOutParam()) - { - typeString = outputTypeToString((*q)->type()); - } - else - { - typeString = inputTypeToString((*q)->type()); - } -#else - string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type()) : inputTypeToString((*q)->type()); -#endif - - params.push_back(typeString); - paramsDecl.push_back(typeString + ' ' + paramName); - args.push_back(paramName); - } - - params.push_back("const ::Ice::Context&"); - paramsDecl.push_back("const ::Ice::Context& __context"); - args.push_back("__current"); - - ContainerPtr container = p->container(); - ClassDefPtr cl = ClassDefPtr::dynamicCast(container); - string thisPointer = fixKwd(cl->scoped()) + "*"; - - H << sp; - - H << nl << "virtual " << retS << ' ' << name << spar << params << epar << ';'; - bool amd = !cl->isLocal() && (cl->hasMetaData("amd") || p->hasMetaData("amd")); - if(amd) - { - C << sp << nl << retS << nl << "IceDelegateD" << scoped << spar << params << epar; - C << sb; - C << nl << "throw ::Ice::CollocationOptimizationException(__FILE__, __LINE__);"; - C << eb; - } - else - { - C << sp << nl << retS << nl << "IceDelegateD" << scoped << spar << paramsDecl << epar; - C << sb; - C << nl << "::Ice::Current __current;"; - C << nl << "__initCurrent(__current, \"" << p->name() - << "\", static_cast< ::Ice::OperationMode>(" << p->mode() << "), __context);"; - C << nl << "while(true)"; - C << sb; - C << nl << "::IceInternal::Direct __direct(__current);"; - C << nl << thisPointer << " __servant = dynamic_cast< " << thisPointer << ">(__direct.servant().get());"; - C << nl << "if(!__servant)"; - C << sb; - C << nl << "::Ice::OperationNotExistException __opEx(__FILE__, __LINE__);"; - C << nl << "__opEx.id = __current.id;"; - C << nl << "__opEx.facet = __current.facet;"; - C << nl << "__opEx.operation = __current.operation;"; - C << nl << "throw __opEx;"; - C << eb; - C << nl << "try"; - C << sb; - C << nl; - if(ret) - { - C << "return "; - } - C << "__servant->" << name << spar << args << epar << ';'; - if(!ret) - { - C << nl << "return;"; - } - C << eb; - C << nl << "catch(const ::Ice::LocalException& __ex)"; - C << sb; - C << nl << "throw ::IceInternal::NonRepeatable(__ex);"; - C << eb; - C << eb; - C << eb; - } -} - Slice::Gen::ObjectDeclVisitor::ObjectDeclVisitor(Output& h, Output& c, const string& dllExport) : H(h), C(c), _dllExport(dllExport) { diff --git a/cpp/src/slice2cppe/Gen.h b/cpp/src/slice2cppe/Gen.h index f32715b3fb1..6bfd9b6d1c8 100644 --- a/cpp/src/slice2cppe/Gen.h +++ b/cpp/src/slice2cppe/Gen.h @@ -149,50 +149,6 @@ private: std::string _dllExport; }; - class DelegateMVisitor : public ::IceUtil::noncopyable, public ParserVisitor - { - public: - - DelegateMVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&); - - virtual bool visitUnitStart(const UnitPtr&); - virtual void visitUnitEnd(const UnitPtr&); - virtual bool visitModuleStart(const ModulePtr&); - virtual void visitModuleEnd(const ModulePtr&); - virtual bool visitClassDefStart(const ClassDefPtr&); - virtual void visitClassDefEnd(const ClassDefPtr&); - virtual void visitOperation(const OperationPtr&); - - private: - - ::IceUtil::Output& H; - ::IceUtil::Output& C; - - std::string _dllExport; - }; - - class DelegateDVisitor : public ::IceUtil::noncopyable, public ParserVisitor - { - public: - - DelegateDVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&); - - virtual bool visitUnitStart(const UnitPtr&); - virtual void visitUnitEnd(const UnitPtr&); - virtual bool visitModuleStart(const ModulePtr&); - virtual void visitModuleEnd(const ModulePtr&); - virtual bool visitClassDefStart(const ClassDefPtr&); - virtual void visitClassDefEnd(const ClassDefPtr&); - virtual void visitOperation(const OperationPtr&); - - private: - - ::IceUtil::Output& H; - ::IceUtil::Output& C; - - std::string _dllExport; - }; - class ObjectDeclVisitor : public ::IceUtil::noncopyable, public ParserVisitor { public: diff --git a/cpp/src/slice2javae/Gen.cpp b/cpp/src/slice2javae/Gen.cpp index e92cadc18cc..54693cfe77e 100644 --- a/cpp/src/slice2javae/Gen.cpp +++ b/cpp/src/slice2javae/Gen.cpp @@ -932,12 +932,6 @@ Slice::Gen::generate(const UnitPtr& p, bool stream) DelegateVisitor delegateVisitor(_dir); p->visit(&delegateVisitor, false); - DelegateMVisitor delegateMVisitor(_dir); - p->visit(&delegateMVisitor, false); - - DelegateDVisitor delegateDVisitor(_dir); - p->visit(&delegateDVisitor, false); - DispatcherVisitor dispatcherVisitor(_dir); p->visit(&dispatcherVisitor, false); @@ -2987,14 +2981,9 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) out << nl << "return d;"; out << eb; - out << sp << nl << "protected Ice._ObjectDelM" << nl << "__createDelegateM()"; - out << sb; - out << nl << "return new _" << name << "DelM();"; - out << eb; - - out << sp << nl << "protected Ice._ObjectDelD" << nl << "__createDelegateD()"; + out << sp << nl << "protected Ice._ObjectDel" << nl << "__createDelegate()"; out << sb; - out << nl << "return new _" << name << "DelD();"; + out << nl << "return new _" << name << "Del();"; out << eb; out << sp << nl << "public static void" << nl << "__write(IceInternal.BasicStream __os, " << name << "Prx v)"; @@ -3867,82 +3856,7 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p) Output& out = output(); - out << sp << nl << "public interface _" << name << "Del extends "; - if(bases.empty()) - { - out << "Ice._ObjectDel"; - } - else - { - out.useCurrentPosAsIndent(); - ClassList::const_iterator q = bases.begin(); - while(q != bases.end()) - { - out << getAbsolute(*q, package, "_", "Del"); - if(++q != bases.end()) - { - out << ',' << nl; - } - } - out.restoreIndent(); - } - - out << sb; - - OperationList ops = p->operations(); - - OperationList::const_iterator r; - for(r = ops.begin(); r != ops.end(); ++r) - { - OperationPtr op = *r; - string opName = fixKwd(op->name()); - TypePtr ret = op->returnType(); - string retS = typeToString(ret, TypeModeReturn, package, op->getMetaData()); - - vector<string> params = getParams(op, package); - - ExceptionList throws = op->throws(); - throws.sort(); - throws.unique(); - - out << sp; - out << nl << retS << ' ' << opName << spar << params << "java.util.Map __ctx" << epar; - writeDelegateThrowsClause(package, throws); - out << ';'; - } - - out << eb; - close(); - - return false; -} - -Slice::Gen::DelegateMVisitor::DelegateMVisitor(const string& dir) : - JavaVisitor(dir) -{ -} - -bool -Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) -{ - if(p->isLocal()) - { - return false; - } - - string name = p->name(); - ClassList bases = p->bases(); - string package = getPackage(p); - string absolute = getAbsolute(p, "", "_", "DelM"); - - if(!open(absolute)) - { - return false; - } - - Output& out = output(); - - out << sp << nl << "public final class _" << name << "DelM extends Ice._ObjectDelM implements _" << name << "Del"; + out << sp << nl << "public final class _" << name << "Del extends Ice._ObjectDel"; out << sb; OperationList ops = p->allOperations(); @@ -4097,118 +4011,6 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) return false; } -Slice::Gen::DelegateDVisitor::DelegateDVisitor(const string& dir) : - JavaVisitor(dir) -{ -} - -bool -Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) -{ - if(p->isLocal()) - { - return false; - } - - string name = p->name(); - ClassList bases = p->bases(); - string package = getPackage(p); - string absolute = getAbsolute(p, "", "_", "DelD"); - - if(!open(absolute)) - { - return false; - } - - Output& out = output(); - - out << sp << nl << "public final class _" << name << "DelD extends Ice._ObjectDelD implements _" << name << "Del"; - out << sb; - - OperationList ops = p->allOperations(); - - OperationList::const_iterator r; - for(r = ops.begin(); r != ops.end(); ++r) - { - OperationPtr op = *r; - ContainerPtr container = op->container(); - ClassDefPtr cl = ClassDefPtr::dynamicCast(container); - string opName = fixKwd(op->name()); - TypePtr ret = op->returnType(); - string retS = typeToString(ret, TypeModeReturn, package, op->getMetaData()); - - ExceptionList throws = op->throws(); - throws.sort(); - throws.unique(); - - vector<string> params = getParams(op, package); - vector<string> args = getArgs(op); - - out << sp; - out << nl << "public " << retS << nl << opName << spar << params << "java.util.Map __ctx" << epar; - writeDelegateThrowsClause(package, throws); - out << sb; - if(cl->hasMetaData("amd") || op->hasMetaData("amd")) - { - out << nl << "throw new Ice.CollocationOptimizationException();"; - } - else - { - StringList metaData = op->getMetaData(); - out << nl << "Ice.Current __current = new Ice.Current();"; - out << nl << "__initCurrent(__current, \"" << op->name() << "\", " << sliceModeToIceMode(op) - << ", __ctx);"; - out << nl << "while(true)"; - out << sb; - out << nl << "IceInternal.Direct __direct = new IceInternal.Direct(__current);"; - out << nl << "try"; - out << sb; - out << nl << fixKwd(name) << " __servant = null;"; - out << nl << "try"; - out << sb; - out << nl << "__servant = (" << fixKwd(name) << ")__direct.servant();"; - out << eb; - out << nl << "catch(ClassCastException __ex)"; - out << sb; - out << nl << "Ice.OperationNotExistException __opEx = new Ice.OperationNotExistException();"; - out << nl << "__opEx.id = __current.id;"; - out << nl << "__opEx.facet = __current.facet;"; - out << nl << "__opEx.operation = __current.operation;"; - out << nl << "throw __opEx;"; - out << eb; - out << nl << "try"; - out << sb; - out << nl; - if(ret) - { - out << "return "; - } - out << "__servant." << opName << spar << args << "__current" << epar << ';'; - if(!ret) - { - out << nl << "return;"; - } - out << eb; - out << nl << "catch(Ice.LocalException __ex)"; - out << sb; - out << nl << "throw new IceInternal.NonRepeatable(__ex);"; - out << eb; - out << eb; - out << nl << "finally"; - out << sb; - out << nl << "__direct.destroy();"; - out << eb; - out << eb; - } - out << eb; - } - - out << eb; - close(); - - return false; -} - Slice::Gen::DispatcherVisitor::DispatcherVisitor(const string& dir) : JavaVisitor(dir) { diff --git a/cpp/src/slice2javae/Gen.h b/cpp/src/slice2javae/Gen.h index ff555c28102..c172f30119f 100644 --- a/cpp/src/slice2javae/Gen.h +++ b/cpp/src/slice2javae/Gen.h @@ -196,24 +196,6 @@ private: virtual bool visitClassDefStart(const ClassDefPtr&); }; - class DelegateMVisitor : public JavaVisitor - { - public: - - DelegateMVisitor(const std::string&); - - virtual bool visitClassDefStart(const ClassDefPtr&); - }; - - class DelegateDVisitor : public JavaVisitor - { - public: - - DelegateDVisitor(const std::string&); - - virtual bool visitClassDefStart(const ClassDefPtr&); - }; - class DispatcherVisitor : public JavaVisitor { public: |