diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2005-03-31 19:18:22 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2005-03-31 19:18:22 +0000 |
commit | a4af1ecda4cb0953897fb8416e5ad3c82f143261 (patch) | |
tree | 7b47e6ed2d50dcd39338ef677febe2327cc9a640 /cpp | |
parent | Removed colloc opt (diff) | |
download | ice-a4af1ecda4cb0953897fb8416e5ad3c82f143261.tar.bz2 ice-a4af1ecda4cb0953897fb8416e5ad3c82f143261.tar.xz ice-a4af1ecda4cb0953897fb8416e5ad3c82f143261.zip |
Removed AMI/AMD
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/slice2cppe/Gen.cpp | 825 | ||||
-rw-r--r-- | cpp/src/slice2cppe/Gen.h | 38 | ||||
-rw-r--r-- | cpp/src/slice2javae/Gen.cpp | 1018 | ||||
-rw-r--r-- | cpp/src/slice2javae/Gen.h | 13 |
4 files changed, 272 insertions, 1622 deletions
diff --git a/cpp/src/slice2cppe/Gen.cpp b/cpp/src/slice2cppe/Gen.cpp index 522f5ba0c43..b862b66634b 100644 --- a/cpp/src/slice2cppe/Gen.cpp +++ b/cpp/src/slice2cppe/Gen.cpp @@ -189,15 +189,7 @@ Slice::Gen::generate(const UnitPtr& p) { H << "\n#include <Ice/Object.h>"; H << "\n#include <Ice/Outgoing.h>"; - if(p->hasContentsWithMetaData("ami")) - { - H << "\n#include <Ice/OutgoingAsync.h>"; - } H << "\n#include <Ice/Incoming.h>"; - if(p->hasContentsWithMetaData("amd")) - { - H << "\n#include <Ice/IncomingAsync.h>"; - } H << "\n#include <Ice/Direct.h>"; C << "\n#include <Ice/LocalException.h>"; } @@ -269,12 +261,6 @@ Slice::Gen::generate(const UnitPtr& p) TypesVisitor typesVisitor(H, C, _dllExport, _stream); p->visit(&typesVisitor, false); - AsyncVisitor asyncVisitor(H, C, _dllExport); - p->visit(&asyncVisitor, false); - - AsyncImplVisitor asyncImplVisitor(H, C, _dllExport); - p->visit(&asyncImplVisitor, false); - ProxyVisitor proxyVisitor(H, C, _dllExport); p->visit(&proxyVisitor, false); @@ -1387,10 +1373,6 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) vector<string> paramsDecl; vector<string> args; - vector<string> paramsAMI; - vector<string> paramsDeclAMI; - vector<string> argsAMI; - ParamDeclList paramList = p->parameters(); for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) { @@ -1416,15 +1398,6 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) params.push_back(typeString); paramsDecl.push_back(typeString + ' ' + paramName); args.push_back(paramName); - - if(!(*q)->isOutParam()) - { - string inputTypeString = inputTypeToString((*q)->type()); - - paramsAMI.push_back(inputTypeString); - paramsDeclAMI.push_back(inputTypeString + ' ' + paramName); - argsAMI.push_back(paramName); - } } string thisPointer = fixKwd(scope.substr(0, scope.size() - 2)) + "*"; @@ -1485,35 +1458,6 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) C << eb; C << eb; C << eb; - - ContainerPtr container = p->container(); - ClassDefPtr cl = ClassDefPtr::dynamicCast(container); - if(cl->hasMetaData("ami") || p->hasMetaData("ami")) - { - string classNameAMI = "AMI_" + cl->name(); - string classScope = fixKwd(cl->scope()); - string classScopedAMI = classScope + classNameAMI; - - H << nl << "void " << name << "_async" << spar << ("const" + classScopedAMI + '_' + name + "Ptr&") - << paramsAMI << epar << ';'; - H << nl << "void " << name << "_async" << spar << ("const" + classScopedAMI + '_' + name + "Ptr&") - << paramsAMI << "const ::Ice::Context&" << epar << ';'; - - C << sp << nl << "void" << nl << "IceProxy" << scope << name << "_async" << spar - << ("const " + classScopedAMI + '_' + name + "Ptr& __cb") << paramsDeclAMI << epar; - C << sb; - C << nl << name << "_async" << spar << "__cb" << argsAMI << "__defaultContext()" << epar << ';'; - C << eb; - - C << sp << nl << "void" << nl << "IceProxy" << scope << name << "_async" << spar - << ("const " + classScopedAMI + '_' + name + "Ptr& __cb") << paramsDeclAMI << "const ::Ice::Context& __ctx" - << epar; - C << sb; - // Async requests may only be sent twoway. - C << nl << "__checkTwowayOnly(\"" << name << "\");"; - C << nl << "__cb->__invoke" << spar << "this" << argsAMI << "__ctx" << epar << ';'; - C << eb; - } } Slice::Gen::DelegateVisitor::DelegateVisitor(Output& h, Output& c, const string& dllExport) : @@ -2414,19 +2358,9 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) argsAMD += "__current)"; bool nonmutating = p->mode() == Operation::Nonmutating; - bool amd = !cl->isLocal() && (cl->hasMetaData("amd") || p->hasMetaData("amd")); H << sp; - if(!amd) - { - H << nl << "virtual " << retS << ' ' << fixKwd(name) << params - << (nonmutating ? " const" : "") << " = 0;"; - } - else - { - H << nl << "virtual void " << name << "_async" << paramsAMD - << (nonmutating ? " const" : "") << " = 0;"; - } + H << nl << "virtual " << retS << ' ' << fixKwd(name) << params << (nonmutating ? " const" : "") << " = 0;"; if(!cl->isLocal()) { @@ -2437,91 +2371,61 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) C << nl << "::IceInternal::DispatchStatus" << nl << scope.substr(2) << "___" << name << "(::IceInternal::Incoming& __in, const ::Ice::Current& __current)" << (nonmutating ? " const" : ""); C << sb; - if(!amd) - { - ExceptionList throws = p->throws(); - throws.sort(); - throws.unique(); - // - // Arrange exceptions into most-derived to least-derived order. If we don't - // do this, a base exception handler can appear before a derived exception - // handler, causing compiler warnings and resulting in the base exception - // being marshaled instead of the derived exception. - // + ExceptionList throws = p->throws(); + throws.sort(); + throws.unique(); + + // + // Arrange exceptions into most-derived to least-derived order. If we don't + // do this, a base exception handler can appear before a derived exception + // handler, causing compiler warnings and resulting in the base exception + // being marshaled instead of the derived exception. + // #if defined(__SUNPRO_CC) - throws.sort(derivedToBaseCompare); + throws.sort(derivedToBaseCompare); #else - throws.sort(Slice::DerivedToBaseCompare()); + throws.sort(Slice::DerivedToBaseCompare()); #endif - if(!inParams.empty()) - { - C << nl << "::IceInternal::BasicStream* __is = __in.is();"; - } - if(ret || !outParams.empty() || !throws.empty()) - { - C << nl << "::IceInternal::BasicStream* __os = __in.os();"; - } - writeAllocateCode(C, inParams, 0); - writeUnmarshalCode(C, inParams, 0); - writeAllocateCode(C, outParams, 0); - if(!throws.empty()) - { - C << nl << "try"; - C << sb; - } - C << nl; - if(ret) - { - C << retS << " __ret = "; - } - C << fixKwd(name) << args << ';'; - writeMarshalCode(C, outParams, ret); - if(!throws.empty()) - { - C << eb; - ExceptionList::const_iterator r; - for(r = throws.begin(); r != throws.end(); ++r) - { - C << nl << "catch(const " << fixKwd((*r)->scoped()) << "& __ex)"; - C << sb; - C << nl << "__os->write(__ex);"; - C << nl << "return ::IceInternal::DispatchUserException;"; - C << eb; - } - } - C << nl << "return ::IceInternal::DispatchOK;"; + if(!inParams.empty()) + { + C << nl << "::IceInternal::BasicStream* __is = __in.is();"; } - else + if(ret || !outParams.empty() || !throws.empty()) + { + C << nl << "::IceInternal::BasicStream* __os = __in.os();"; + } + writeAllocateCode(C, inParams, 0); + writeUnmarshalCode(C, inParams, 0); + writeAllocateCode(C, outParams, 0); + if(!throws.empty()) { - if(!inParams.empty()) - { - C << nl << "::IceInternal::BasicStream* __is = __in.is();"; - } - writeAllocateCode(C, inParams, 0); - writeUnmarshalCode(C, inParams, 0); - C << nl << classScopedAMD << '_' << name << "Ptr __cb = new IceAsync" << classScopedAMD << '_' << name - << "(__in);"; C << nl << "try"; C << sb; - C << nl << name << "_async" << argsAMD << ';'; - C << eb; - C << nl << "catch(const ::Ice::Exception& __ex)"; - C << sb; - C << nl << "__cb->ice_exception(__ex);"; - C << eb; - C << nl << "catch(const ::std::exception& __ex)"; - C << sb; - C << nl << "__cb->ice_exception(__ex);"; - C << eb; - C << nl << "catch(...)"; - C << sb; - C << nl << "__cb->ice_exception();"; + } + C << nl; + if(ret) + { + C << retS << " __ret = "; + } + C << fixKwd(name) << args << ';'; + writeMarshalCode(C, outParams, ret); + if(!throws.empty()) + { C << eb; - C << nl << "return ::IceInternal::DispatchAsync;"; - } + ExceptionList::const_iterator r; + for(r = throws.begin(); r != throws.end(); ++r) + { + C << nl << "catch(const " << fixKwd((*r)->scoped()) << "& __ex)"; + C << sb; + C << nl << "__os->write(__ex);"; + C << nl << "return ::IceInternal::DispatchUserException;"; + C << eb; + } + } + C << nl << "return ::IceInternal::DispatchOK;"; C << eb; } } @@ -3240,601 +3144,104 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) TypePtr ret = op->returnType(); string retS = returnTypeToString(ret); - if(!p->isLocal() && (p->hasMetaData("amd") || op->hasMetaData("amd"))) + H << sp << nl << "virtual " << retS << ' ' << fixKwd(opName) << '('; + H.useCurrentPosAsIndent(); + ParamDeclList paramList = op->parameters(); + ParamDeclList::const_iterator q; + for(q = paramList.begin(); q != paramList.end(); ++q) { - H << sp << nl << "virtual void " << opName << "_async("; - H.useCurrentPosAsIndent(); - H << "const " << classScopedAMD << '_' << opName << "Ptr&"; - ParamDeclList paramList = op->parameters(); - ParamDeclList::const_iterator q; - for(q = paramList.begin(); q != paramList.end(); ++q) + if(q != paramList.begin()) { - if(!(*q)->isOutParam()) - { - H << ',' << nl << inputTypeToString((*q)->type()); - } + H << ',' << nl; } - H << ',' << nl << "const Ice::Current&"; - H.restoreIndent(); - - bool nonmutating = op->mode() == Operation::Nonmutating; - - H << ")" << (nonmutating ? " const" : "") << ';'; - - C << sp << nl << "void" << nl << scope << name << "I::" << opName << "_async("; - C.useCurrentPosAsIndent(); - C << "const " << classScopedAMD << '_' << opName << "Ptr& " << opName << "CB"; - for(q = paramList.begin(); q != paramList.end(); ++q) - { - if(!(*q)->isOutParam()) - { - C << ',' << nl << inputTypeToString((*q)->type()) << ' ' << fixKwd((*q)->name()); - } - } - C << ',' << nl << "const Ice::Current& current"; - C.restoreIndent(); - C << ")" << (nonmutating ? " const" : ""); - C << sb; - - string result = "r"; - for(q = paramList.begin(); q != paramList.end(); ++q) - { - if((*q)->name() == result) - { - result = "_" + result; - break; - } - } - if(ret) - { - writeDecl(C, result, ret); - } - for(q = paramList.begin(); q != paramList.end(); ++q) - { - if((*q)->isOutParam()) - { - writeDecl(C, fixKwd((*q)->name()), (*q)->type()); - } - } - - C << nl << opName << "CB->ice_response("; - if(ret) - { - C << result; - } - for(q = paramList.begin(); q != paramList.end(); ++q) - { - if((*q)->isOutParam()) - { - if(ret || q != paramList.begin()) - { - C << ", "; - } - C << fixKwd((*q)->name()); - } - } - C << ");"; - - C << eb; - } - else - { - H << sp << nl << "virtual " << retS << ' ' << fixKwd(opName) << '('; - H.useCurrentPosAsIndent(); - ParamDeclList paramList = op->parameters(); - ParamDeclList::const_iterator q; - for(q = paramList.begin(); q != paramList.end(); ++q) - { - if(q != paramList.begin()) - { - H << ',' << nl; - } #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()); - } + // + // 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()); + string typeString = (*q)->isOutParam() ? + outputTypeToString((*q)->type()) : inputTypeToString((*q)->type()); #endif - H << typeString; - } - if(!p->isLocal()) + H << typeString; + } + if(!p->isLocal()) + { + if(!paramList.empty()) { - if(!paramList.empty()) - { - H << ',' << nl; - } - H << "const Ice::Current&"; + H << ',' << nl; } - H.restoreIndent(); + H << "const Ice::Current&"; + } + H.restoreIndent(); - bool nonmutating = op->mode() == Operation::Nonmutating; + bool nonmutating = op->mode() == Operation::Nonmutating; - H << ")" << (nonmutating ? " const" : "") << ';'; + H << ")" << (nonmutating ? " const" : "") << ';'; - C << sp << nl << retS << nl; - C << scope.substr(2) << name << "I::" << fixKwd(opName) << '('; - C.useCurrentPosAsIndent(); - for(q = paramList.begin(); q != paramList.end(); ++q) + C << sp << nl << retS << nl; + C << scope.substr(2) << name << "I::" << fixKwd(opName) << '('; + C.useCurrentPosAsIndent(); + for(q = paramList.begin(); q != paramList.end(); ++q) + { + if(q != paramList.begin()) { - if(q != paramList.begin()) - { - C << ',' << nl; - } + C << ',' << nl; + } #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()); - } + // + // 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()); + string typeString = (*q)->isOutParam() ? + outputTypeToString((*q)->type()) : inputTypeToString((*q)->type()); #endif - C << typeString << ' ' << fixKwd((*q)->name()); - } - if(!p->isLocal()) - { - if(!paramList.empty()) - { - C << ',' << nl; - } - C << "const Ice::Current& current"; - } - C.restoreIndent(); - C << ')'; - C << (nonmutating ? " const" : ""); - C << sb; - - if(ret) + C << typeString << ' ' << fixKwd((*q)->name()); + } + if(!p->isLocal()) + { + if(!paramList.empty()) { - writeReturn(C, ret); + C << ',' << nl; } - - C << eb; + C << "const Ice::Current& current"; } - } - - H << eb << ';'; - - return true; -} - -Slice::Gen::AsyncVisitor::AsyncVisitor(Output& h, Output& c, const string& dllExport) : - H(h), C(c), _dllExport(dllExport) -{ -} - -bool -Slice::Gen::AsyncVisitor::visitModuleStart(const ModulePtr& p) -{ - if(!p->hasNonLocalClassDecls() || (!p->hasContentsWithMetaData("ami") && !p->hasContentsWithMetaData("amd"))) - { - return false; - } - - string name = fixKwd(p->name()); - - H << sp << nl << "namespace " << name << nl << '{'; - - return true; -} - -void -Slice::Gen::AsyncVisitor::visitModuleEnd(const ModulePtr& p) -{ - H << sp << nl << '}'; -} - -void -Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) -{ - ContainerPtr container = p->container(); - ClassDefPtr cl = ClassDefPtr::dynamicCast(container); - - if(cl->isLocal() || - (!cl->hasMetaData("ami") && !p->hasMetaData("ami") && !cl->hasMetaData("amd") && !p->hasMetaData("amd"))) - { - return; - } - - string name = p->name(); - - string className = cl->name(); - string classNameAMI = "AMI_" + className; - string classNameAMD = "AMD_" + className; - string classScope = fixKwd(cl->scope()); - string classScopedAMI = classScope + classNameAMI; - string classScopedAMD = classScope + classNameAMD; - string proxyName = classScope + className + "Prx"; - - vector<string> params; - vector<string> paramsDecl; - vector<string> args; - - vector<string> paramsInvoke; - vector<string> paramsDeclInvoke; - - paramsInvoke.push_back("const " + proxyName + "&"); - paramsDeclInvoke.push_back("const " + proxyName + "& __prx"); - - TypePtr ret = p->returnType(); - string retS = inputTypeToString(ret); - - if(ret) - { - params.push_back(retS); - paramsDecl.push_back(retS + " __ret"); - args.push_back("__ret"); - } - - TypeStringList inParams; - TypeStringList outParams; - ParamDeclList paramList = p->parameters(); - for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) - { - string paramName = fixKwd((*q)->name()); - TypePtr type = (*q)->type(); - string typeString = inputTypeToString(type); - - if((*q)->isOutParam()) - { - params.push_back(typeString); - paramsDecl.push_back(typeString + ' ' + paramName); - args.push_back(paramName); - - outParams.push_back(make_pair(type, paramName)); - } - else - { - paramsInvoke.push_back(typeString); - paramsDeclInvoke.push_back(typeString + ' ' + paramName); - - inParams.push_back(make_pair(type, paramName)); - } - } - - paramsInvoke.push_back("const ::Ice::Context&"); - paramsDeclInvoke.push_back("const ::Ice::Context& __ctx"); - - if(cl->hasMetaData("ami") || p->hasMetaData("ami")) - { - H << sp << nl << "class " << _dllExport << classNameAMI << '_' << name - << " : public ::IceInternal::OutgoingAsync"; - H << sb; - H.dec(); - H << nl << "public:"; - H.inc(); - H << sp; - H << nl << "virtual void ice_response" << spar << params << epar << " = 0;"; - H << nl << "virtual void ice_exception(const ::Ice::Exception&) = 0;"; - H << sp; - H << nl << "void __invoke" << spar << paramsInvoke << epar << ';'; - H << sp; - H.dec(); - H << nl << "protected:"; - H.inc(); - H << sp; - H << nl << "virtual void __response(bool);"; - H << eb << ';'; - H << sp << nl << "typedef ::IceUtil::Handle< " << classScopedAMI << '_' << name << "> " << classNameAMI - << '_' << name << "Ptr;"; - - C << sp << nl << "void" << nl << classScopedAMI.substr(2) << '_' << name << "::__invoke" << spar - << paramsDeclInvoke << epar; - C << sb; - C << nl << "try"; - C << sb; - C << nl << "static const ::std::string __operation(\"" << name << "\");"; - C << nl << "__prepare(__prx, __operation, static_cast< ::Ice::OperationMode>(" << p->mode() << "), __ctx);"; - writeMarshalCode(C, inParams, 0); - /* remove. - if(p->sendsClasses()) - { - C << nl << "__os->writePendingObjects();"; - } - */ - C << nl << "__os->endWriteEncaps();"; - C << eb; - C << nl << "catch(const ::Ice::LocalException& __ex)"; - C << sb; - C << nl << "__finished(__ex);"; - C << nl << "return;"; - C << eb; - C << nl << "__send();"; - C << eb; - - C << sp << nl << "void" << nl << classScopedAMI.substr(2) << '_' << name << "::__response(bool __ok)"; - C << sb; - writeAllocateCode(C, outParams, ret); - C << nl << "try"; - C << sb; - C << nl << "if(!__ok)"; - C << sb; - C << nl << "__is->throwException();"; - C << eb; - writeUnmarshalCode(C, outParams, ret); - C << eb; - C << nl << "catch(const ::Ice::LocalException& __ex)"; - C << sb; - C << nl << "__finished(__ex);"; - C << nl << "return;"; - C << eb; - - // - // Generate a catch block for each legal user exception. - // (See comment in DelegateMVisitor::visitOperation() for details.) - // - ExceptionList throws = p->throws(); - throws.sort(); - throws.unique(); -#if defined(__SUNPRO_CC) - throws.sort(derivedToBaseCompare); -#else - throws.sort(Slice::DerivedToBaseCompare()); -#endif - for(ExceptionList::const_iterator i = throws.begin(); i != throws.end(); ++i) - { - string scoped = (*i)->scoped(); - C << nl << "catch(const " << fixKwd((*i)->scoped()) << "& __ex)"; - C << sb; - C << nl << "ice_exception(__ex);"; - C << nl << "return;"; - C << eb; - } - C << nl << "catch(const ::Ice::UserException&)"; - C << sb; - C << nl << "ice_exception(::Ice::UnknownUserException(__FILE__, __LINE__));"; - C << nl << "return;"; - C << eb; - C << nl << "ice_response" << spar << args << epar << ';'; - C << eb; - } - - if(cl->hasMetaData("amd") || p->hasMetaData("amd")) - { - H << sp << nl << "class " << _dllExport << classNameAMD << '_' << name - << " : virtual public ::IceUtil::Shared"; - H << sb; - H.dec(); - H << nl << "public:"; - H.inc(); - H << sp; - H << nl << "virtual void ice_response" << spar << params << epar << " = 0;"; - H << nl << "virtual void ice_exception(const ::Ice::Exception&) = 0;"; - H << nl << "virtual void ice_exception(const ::std::exception&) = 0;"; - H << nl << "virtual void ice_exception() = 0;"; - H << eb << ';'; - H << sp << nl << "typedef ::IceUtil::Handle< " << classScopedAMD << '_' << name << "> " - << classNameAMD << '_' << name << "Ptr;"; - } -} - -Slice::Gen::AsyncImplVisitor::AsyncImplVisitor(Output& h, Output& c, const string& dllExport) : - H(h), C(c), _dllExport(dllExport) -{ -} - -bool -Slice::Gen::AsyncImplVisitor::visitUnitStart(const UnitPtr& p) -{ - if(!p->hasNonLocalClassDecls() || !p->hasContentsWithMetaData("amd")) - { - return false; - } - - H << sp << nl << "namespace IceAsync" << nl << '{'; + C.restoreIndent(); + C << ')'; + C << (nonmutating ? " const" : ""); + C << sb; - return true; -} + if(ret) + { + writeReturn(C, ret); + } -void -Slice::Gen::AsyncImplVisitor::visitUnitEnd(const UnitPtr& p) -{ - H << sp << nl << '}'; -} - -bool -Slice::Gen::AsyncImplVisitor::visitModuleStart(const ModulePtr& p) -{ - if(!p->hasNonLocalClassDecls() || !p->hasContentsWithMetaData("amd")) - { - return false; + C << eb; } - string name = fixKwd(p->name()); - - H << sp << nl << "namespace " << name << nl << '{'; + H << eb << ';'; return true; } void -Slice::Gen::AsyncImplVisitor::visitModuleEnd(const ModulePtr& p) -{ - H << sp << nl << '}'; -} - -void -Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p) -{ - ContainerPtr container = p->container(); - ClassDefPtr cl = ClassDefPtr::dynamicCast(container); - - if(cl->isLocal() || (!cl->hasMetaData("amd") && !p->hasMetaData("amd"))) - { - return; - } - - string name = p->name(); - - string classNameAMD = "AMD_" + cl->name(); - string classScope = fixKwd(cl->scope()); - string classScopedAMD = classScope + classNameAMD; - - string params; - string paramsDecl; - string args; - - ExceptionList throws = p->throws(); - throws.sort(); - throws.unique(); - - // - // Arrange exceptions into most-derived to least-derived order. If we don't - // do this, a base exception handler can appear before a derived exception - // handler, causing compiler warnings and resulting in the base exception - // being marshaled instead of the derived exception. - // -#if defined(__SUNPRO_CC) - throws.sort(derivedToBaseCompare); -#else - throws.sort(Slice::DerivedToBaseCompare()); -#endif - - TypePtr ret = p->returnType(); - string retS = inputTypeToString(ret); - - if(ret) - { - params += retS; - paramsDecl += retS; - paramsDecl += ' '; - paramsDecl += "__ret"; - args += "__ret"; - } - - TypeStringList outParams; - ParamDeclList paramList = p->parameters(); - for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) - { - if((*q)->isOutParam()) - { - string paramName = fixKwd((*q)->name()); - TypePtr type = (*q)->type(); - string typeString = inputTypeToString(type); - - if(ret || !outParams.empty()) - { - params += ", "; - paramsDecl += ", "; - args += ", "; - } - - params += typeString; - paramsDecl += typeString; - paramsDecl += ' '; - paramsDecl += paramName; - args += paramName; - - outParams.push_back(make_pair(type, paramName)); - } - } - - H << sp << nl << "class " << _dllExport << classNameAMD << '_' << name - << " : public " << classScopedAMD << '_' << name << ", public ::IceInternal::IncomingAsync"; - H << sb; - H.dec(); - H << nl << "public:"; - H.inc(); - - H << sp; - H << nl << classNameAMD << '_' << name << "(::IceInternal::Incoming&);"; - - H << sp; - H << nl << "virtual void ice_response(" << params << ");"; - H << nl << "virtual void ice_exception(const ::Ice::Exception&);"; - H << nl << "virtual void ice_exception(const ::std::exception&);"; - H << nl << "virtual void ice_exception();"; - H << eb << ';'; - - C << sp << nl << "IceAsync" << classScopedAMD << '_' << name << "::" << classNameAMD << '_' << name - << "(::IceInternal::Incoming& in) :"; - C.inc(); - C << nl << "IncomingAsync(in)"; - C.dec(); - C << sb; - C << eb; - - C << sp << nl << "void" << nl << "IceAsync" << classScopedAMD << '_' << name << "::ice_response(" - << paramsDecl << ')'; - C << sb; - if(ret || !outParams.empty()) - { - C << nl << "try"; - C << sb; - C << nl << "::IceInternal::BasicStream* __os = this->__os();"; - writeMarshalCode(C, outParams, ret); - C << eb; - C << nl << "catch(const ::Ice::Exception& __ex)"; - C << sb; - C << nl << "__exception(__ex);"; - C << nl << "return;"; - C << eb; - } - C << nl << "__response(true);"; - C << eb; - - C << sp << nl << "void" << nl << "IceAsync" << classScopedAMD << '_' << name - << "::ice_exception(const ::Ice::Exception& ex)"; - C << sb; - if(throws.empty()) - { - C << nl << "__exception(ex);"; - } - else - { - C << nl << "try"; - C << sb; - C << nl << "ex.ice_throw();"; - C << eb; - ExceptionList::const_iterator r; - for(r = throws.begin(); r != throws.end(); ++r) - { - C << nl << "catch(const " << fixKwd((*r)->scoped()) << "& __ex)"; - C << sb; - C << nl << "__os()->write(__ex);"; - C << nl << "__response(false);"; - C << eb; - } - C << nl << "catch(const ::Ice::Exception& __ex)"; - C << sb; - C << nl << "__exception(__ex);"; - C << eb; - } - C << eb; - - C << sp << nl << "void" << nl << "IceAsync" << classScopedAMD << '_' << name - << "::ice_exception(const ::std::exception& ex)"; - C << sb; - C << nl << "__exception(ex);"; - C << eb; - - C << sp << nl << "void" << nl << "IceAsync" << classScopedAMD << '_' << name - << "::ice_exception()"; - C << sb; - C << nl << "__exception();"; - C << eb; -} - -void Slice::Gen::validateMetaData(const UnitPtr& unit) { MetaDataVisitor visitor; diff --git a/cpp/src/slice2cppe/Gen.h b/cpp/src/slice2cppe/Gen.h index 6bfd9b6d1c8..4c5d86ae417 100644 --- a/cpp/src/slice2cppe/Gen.h +++ b/cpp/src/slice2cppe/Gen.h @@ -263,44 +263,6 @@ private: void writeReturn(::IceUtil::Output&, const TypePtr&); }; - class AsyncVisitor : public ::IceUtil::noncopyable, public ParserVisitor - { - public: - - AsyncVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&); - - virtual bool visitModuleStart(const ModulePtr&); - virtual void visitModuleEnd(const ModulePtr&); - virtual void visitOperation(const OperationPtr&); - - private: - - ::IceUtil::Output& H; - ::IceUtil::Output& C; - - std::string _dllExport; - }; - - class AsyncImplVisitor : public ::IceUtil::noncopyable, public ParserVisitor - { - public: - - AsyncImplVisitor(::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 void visitOperation(const OperationPtr&); - - private: - - ::IceUtil::Output& H; - ::IceUtil::Output& C; - - std::string _dllExport; - }; - private: class MetaDataVisitor : public ParserVisitor diff --git a/cpp/src/slice2javae/Gen.cpp b/cpp/src/slice2javae/Gen.cpp index 54693cfe77e..e5d33c25a03 100644 --- a/cpp/src/slice2javae/Gen.cpp +++ b/cpp/src/slice2javae/Gen.cpp @@ -88,56 +88,6 @@ Slice::JavaVisitor::getParams(const OperationPtr& op, const string& package) } vector<string> -Slice::JavaVisitor::getParamsAsync(const OperationPtr& op, const string& package, bool amd) -{ - vector<string> params; - - string name = op->name(); - ContainerPtr container = op->container(); - ClassDefPtr cl = ClassDefPtr::dynamicCast(container); - string classNameAsync = getAbsolute(cl, package, amd ? "AMD_" : "AMI_", '_' + name); - params.push_back(classNameAsync + " __cb"); - - ParamDeclList paramList = op->parameters(); - for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) - { - if(!(*q)->isOutParam()) - { - StringList metaData = (*q)->getMetaData(); - string typeString = typeToString((*q)->type(), TypeModeIn, package, metaData); - params.push_back(typeString + ' ' + fixKwd((*q)->name())); - } - } - - return params; -} - -vector<string> -Slice::JavaVisitor::getParamsAsyncCB(const OperationPtr& op, const string& package) -{ - vector<string> params; - - TypePtr ret = op->returnType(); - if(ret) - { - string retS = typeToString(ret, TypeModeIn, package, op->getMetaData()); - params.push_back(retS + " __ret"); - } - - ParamDeclList paramList = op->parameters(); - for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) - { - if((*q)->isOutParam()) - { - string typeString = typeToString((*q)->type(), TypeModeIn, package, (*q)->getMetaData()); - params.push_back(typeString + ' ' + fixKwd((*q)->name())); - } - } - - return params; -} - -vector<string> Slice::JavaVisitor::getArgs(const OperationPtr& op) { vector<string> args; @@ -151,64 +101,6 @@ Slice::JavaVisitor::getArgs(const OperationPtr& op) return args; } -vector<string> -Slice::JavaVisitor::getArgsAsync(const OperationPtr& op) -{ - vector<string> args; - - args.push_back("__cb"); - - ParamDeclList paramList = op->parameters(); - for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) - { - if(!(*q)->isOutParam()) - { - args.push_back(fixKwd((*q)->name())); - } - } - - return args; -} - -vector<string> -Slice::JavaVisitor::getArgsAsyncCB(const OperationPtr& op) -{ - vector<string> args; - - TypePtr ret = op->returnType(); - if(ret) - { - BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret)) - { - args.push_back("__ret.value"); - } - else - { - args.push_back("__ret"); - } - } - - ParamDeclList paramList = op->parameters(); - for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) - { - if((*q)->isOutParam()) - { - BuiltinPtr builtin = BuiltinPtr::dynamicCast((*q)->type()); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*q)->type())) - { - args.push_back(fixKwd((*q)->name()) + ".value"); - } - else - { - args.push_back(fixKwd((*q)->name())); - } - } - } - - return args; -} - void Slice::JavaVisitor::writeThrowsClause(const string& package, const ExceptionList& throws) { @@ -447,25 +339,14 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) ClassDefPtr cl = ClassDefPtr::dynamicCast(container); assert(cl); - bool amd = cl->hasMetaData("amd") || op->hasMetaData("amd"); - vector<string> params; vector<string> args; TypePtr ret; - if(amd) - { - opName += "_async"; - params = getParamsAsync(op, package, true); - args = getArgsAsync(op); - } - else - { - opName = fixKwd(opName); - ret = op->returnType(); - params = getParams(op, package); - args = getArgs(op); - } + opName = fixKwd(opName); + ret = op->returnType(); + params = getParams(op, package); + args = getArgs(op); ExceptionList throws = op->throws(); throws.sort(); @@ -552,239 +433,157 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) << " __obj, IceInternal.Incoming __in, Ice.Current __current)"; out << sb; - bool amd = cl->hasMetaData("amd") || op->hasMetaData("amd"); - if(!amd) - { - TypePtr ret = op->returnType(); + TypePtr ret = op->returnType(); - ParamDeclList inParams; - ParamDeclList outParams; - ParamDeclList paramList = op->parameters(); - ParamDeclList::const_iterator pli; - for(pli = paramList.begin(); pli != paramList.end(); ++pli) + ParamDeclList inParams; + ParamDeclList outParams; + ParamDeclList paramList = op->parameters(); + ParamDeclList::const_iterator pli; + for(pli = paramList.begin(); pli != paramList.end(); ++pli) + { + if((*pli)->isOutParam()) { - if((*pli)->isOutParam()) - { - outParams.push_back(*pli); - } - else - { - inParams.push_back(*pli); - } + outParams.push_back(*pli); + } + else + { + inParams.push_back(*pli); } + } - ExceptionList throws = op->throws(); - throws.sort(); - throws.unique(); + ExceptionList throws = op->throws(); + throws.sort(); + throws.unique(); - // - // Arrange exceptions into most-derived to least-derived order. If we don't - // do this, a base exception handler can appear before a derived exception - // handler, causing compiler warnings and resulting in the base exception - // being marshaled instead of the derived exception. - // + // + // Arrange exceptions into most-derived to least-derived order. If we don't + // do this, a base exception handler can appear before a derived exception + // handler, causing compiler warnings and resulting in the base exception + // being marshaled instead of the derived exception. + // #if defined(__SUNPRO_CC) - throws.sort(Slice::derivedToBaseCompare); + throws.sort(Slice::derivedToBaseCompare); #else - throws.sort(Slice::DerivedToBaseCompare()); + throws.sort(Slice::DerivedToBaseCompare()); #endif - int iter; - - if(!inParams.empty()) - { - out << nl << "IceInternal.BasicStream __is = __in.is();"; - } - if(!outParams.empty() || ret || !throws.empty()) - { - out << nl << "IceInternal.BasicStream __os = __in.os();"; - } + int iter; - // - // Unmarshal 'in' parameters. - // - iter = 0; - for(pli = inParams.begin(); pli != inParams.end(); ++pli) - { - StringList metaData = (*pli)->getMetaData(); - TypePtr paramType = (*pli)->type(); - string paramName = fixKwd((*pli)->name()); - string typeS = typeToString(paramType, TypeModeIn, package, metaData); - BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType)) - { - out << nl << typeS << "Holder " << paramName << " = new " << typeS << "Holder();"; - writeMarshalUnmarshalCode(out, package, paramType, paramName, false, iter, true, - metaData, string()); - } - else - { - out << nl << typeS << ' ' << paramName << ';'; - writeMarshalUnmarshalCode(out, package, paramType, paramName, false, iter, false, metaData); - } - } - if(op->sendsClasses()) - { - out << nl << "__is.readPendingObjects();"; - } - - // - // Create holders for 'out' parameters. - // - for(pli = outParams.begin(); pli != outParams.end(); ++pli) - { - string typeS = typeToString((*pli)->type(), TypeModeOut, package, (*pli)->getMetaData()); - out << nl << typeS << ' ' << fixKwd((*pli)->name()) << " = new " << typeS << "();"; - } - - // - // Call on the servant. - // - if(!throws.empty()) - { - out << nl << "try"; - out << sb; - } - out << nl; - if(ret) - { - string retS = typeToString(ret, TypeModeReturn, package, opMetaData); - out << retS << " __ret = "; - } - out << "__obj." << fixKwd(opName) << '('; - for(pli = inParams.begin(); pli != inParams.end(); ++pli) - { - TypePtr paramType = (*pli)->type(); - out << fixKwd((*pli)->name()); - BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType)) - { - out << ".value"; - } - out << ", "; - } - for(pli = outParams.begin(); pli != outParams.end(); ++pli) - { - out << fixKwd((*pli)->name()) << ", "; - } - out << "__current);"; + if(!inParams.empty()) + { + out << nl << "IceInternal.BasicStream __is = __in.is();"; + } + if(!outParams.empty() || ret || !throws.empty()) + { + out << nl << "IceInternal.BasicStream __os = __in.os();"; + } - // - // Marshal 'out' parameters and return value. - // - for(pli = outParams.begin(); pli != outParams.end(); ++pli) - { - writeMarshalUnmarshalCode(out, package, (*pli)->type(), fixKwd((*pli)->name()), true, iter, true, - (*pli)->getMetaData()); - } - if(ret) - { - writeMarshalUnmarshalCode(out, package, ret, "__ret", true, iter, false, opMetaData); - } - if(op->returnsClasses()) + // + // Unmarshal 'in' parameters. + // + iter = 0; + for(pli = inParams.begin(); pli != inParams.end(); ++pli) + { + StringList metaData = (*pli)->getMetaData(); + TypePtr paramType = (*pli)->type(); + string paramName = fixKwd((*pli)->name()); + string typeS = typeToString(paramType, TypeModeIn, package, metaData); + BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType); + if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType)) { - out << nl << "__os.writePendingObjects();"; + out << nl << typeS << "Holder " << paramName << " = new " << typeS << "Holder();"; + writeMarshalUnmarshalCode(out, package, paramType, paramName, false, iter, true, + metaData, string()); } - out << nl << "return IceInternal.DispatchStatus.DispatchOK;"; - - // - // Handle user exceptions. - // - if(!throws.empty()) + else { - out << eb; - ExceptionList::const_iterator t; - for(t = throws.begin(); t != throws.end(); ++t) - { - string exS = getAbsolute(*t, package); - out << nl << "catch(" << exS << " ex)"; - out << sb; - out << nl << "__os.writeUserException(ex);"; - out << nl << "return IceInternal.DispatchStatus.DispatchUserException;"; - out << eb; - } + out << nl << typeS << ' ' << paramName << ';'; + writeMarshalUnmarshalCode(out, package, paramType, paramName, false, iter, false, metaData); } - - out << eb; } - else + if(op->sendsClasses()) { - ParamDeclList inParams; - ParamDeclList paramList = op->parameters(); - ParamDeclList::const_iterator pli; - for(pli = paramList.begin(); pli != paramList.end(); ++pli) - { - if(!(*pli)->isOutParam()) - { - inParams.push_back(*pli); - } - } + out << nl << "__is.readPendingObjects();"; + } - int iter; + // + // Create holders for 'out' parameters. + // + for(pli = outParams.begin(); pli != outParams.end(); ++pli) + { + string typeS = typeToString((*pli)->type(), TypeModeOut, package, (*pli)->getMetaData()); + out << nl << typeS << ' ' << fixKwd((*pli)->name()) << " = new " << typeS << "();"; + } - if(!inParams.empty()) + // + // Call on the servant. + // + if(!throws.empty()) + { + out << nl << "try"; + out << sb; + } + out << nl; + if(ret) + { + string retS = typeToString(ret, TypeModeReturn, package, opMetaData); + out << retS << " __ret = "; + } + out << "__obj." << fixKwd(opName) << '('; + for(pli = inParams.begin(); pli != inParams.end(); ++pli) + { + TypePtr paramType = (*pli)->type(); + out << fixKwd((*pli)->name()); + BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType); + if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType)) { - out << nl << "IceInternal.BasicStream __is = __in.is();"; + out << ".value"; } + out << ", "; + } + for(pli = outParams.begin(); pli != outParams.end(); ++pli) + { + out << fixKwd((*pli)->name()) << ", "; + } + out << "__current);"; - // - // Unmarshal 'in' parameters. - // - iter = 0; - for(pli = inParams.begin(); pli != inParams.end(); ++pli) - { - StringList metaData = (*pli)->getMetaData(); - TypePtr paramType = (*pli)->type(); - string paramName = fixKwd((*pli)->name()); - string typeS = typeToString(paramType, TypeModeIn, package, metaData); - BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType)) - { - out << nl << typeS << "Holder " << paramName << " = new " << typeS << "Holder();"; - writeMarshalUnmarshalCode(out, package, paramType, paramName, false, iter, true, metaData, - string()); - } - else - { - out << nl << typeS << ' ' << paramName << ';'; - writeMarshalUnmarshalCode(out, package, paramType, paramName, false, iter, false, metaData); - } - } - if(op->sendsClasses()) - { - out << nl << "__is.readPendingObjects();"; - } + // + // Marshal 'out' parameters and return value. + // + for(pli = outParams.begin(); pli != outParams.end(); ++pli) + { + writeMarshalUnmarshalCode(out, package, (*pli)->type(), fixKwd((*pli)->name()), true, iter, true, + (*pli)->getMetaData()); + } + if(ret) + { + writeMarshalUnmarshalCode(out, package, ret, "__ret", true, iter, false, opMetaData); + } + if(op->returnsClasses()) + { + out << nl << "__os.writePendingObjects();"; + } + out << nl << "return IceInternal.DispatchStatus.DispatchOK;"; - // - // Call on the servant. - // - string classNameAMD = "AMD_" + p->name(); - out << nl << classNameAMD << '_' << opName << " __cb = new _" << classNameAMD << '_' << opName - << "(__in);"; - out << nl << "try"; - out << sb; - out << nl << "__obj." << (amd ? opName + "_async" : fixKwd(opName)) << (amd ? "(__cb, " : "("); - for(pli = inParams.begin(); pli != inParams.end(); ++pli) + // + // Handle user exceptions. + // + if(!throws.empty()) + { + out << eb; + ExceptionList::const_iterator t; + for(t = throws.begin(); t != throws.end(); ++t) { - TypePtr paramType = (*pli)->type(); - out << fixKwd((*pli)->name()); - BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType)) - { - out << ".value"; - } - out << ", "; + string exS = getAbsolute(*t, package); + out << nl << "catch(" << exS << " ex)"; + out << sb; + out << nl << "__os.writeUserException(ex);"; + out << nl << "return IceInternal.DispatchStatus.DispatchUserException;"; + out << eb; } - out << "__current);"; - out << eb; - out << nl << "catch(java.lang.Exception ex)"; - out << sb; - out << nl << "__cb.ice_exception(ex);"; - out << eb; - out << nl << "return IceInternal.DispatchStatus.DispatchAsync;"; - - out << eb; } + + out << eb; } OperationList allOps = p->allOperations(); @@ -934,9 +733,6 @@ Slice::Gen::generate(const UnitPtr& p, bool stream) DispatcherVisitor dispatcherVisitor(_dir); p->visit(&dispatcherVisitor, false); - - AsyncVisitor asyncVisitor(_dir); - p->visit(&asyncVisitor, false); } void @@ -1106,24 +902,15 @@ Slice::Gen::OpsVisitor::writeOperations(const ClassDefPtr& p, bool noCurrent) TypePtr ret; vector<string> params; - bool amd = !p->isLocal() && (cl->hasMetaData("amd") || op->hasMetaData("amd")); - - if(amd) - { - params = getParamsAsync(op, package, true); - } - else - { - params = getParams(op, package); - ret = op->returnType(); - } + params = getParams(op, package); + ret = op->returnType(); string retS = typeToString(ret, TypeModeReturn, package, op->getMetaData()); ExceptionList throws = op->throws(); throws.sort(); throws.unique(); - out << sp << nl << retS << ' ' << (amd ? name + "_async" : fixKwd(name)) << spar << params; + out << sp << nl << retS << ' ' << fixKwd(name) << spar << params; if(!noCurrent && !p->isLocal()) { out << "Ice.Current __current"; @@ -1253,41 +1040,17 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p) { ContainerPtr container = (*r)->container(); ClassDefPtr cl = ClassDefPtr::dynamicCast(container); - bool hasAMD = cl->hasMetaData("amd") || (*r)->hasMetaData("amd"); -#if defined(__SUNPRO_CC) && (__SUNPRO_CC==0x550) - // - // Work around for Sun CC 5.5 bug #4853566 - // - string opName; - if(hasAMD) - { - opName = (*r)->name() + "_async"; - } - else - { - opName = fixKwd((*r)->name()); - } -#else - string opName = hasAMD ? (*r)->name() + "_async" : fixKwd((*r)->name()); -#endif + + string opName = fixKwd((*r)->name()); + TypePtr ret = (*r)->returnType(); string retS = typeToString(ret, TypeModeReturn, package, (*r)->getMetaData()); - vector<string> params; - vector<string> args; - if(hasAMD) - { - params = getParamsAsync((*r), package, true); - args = getArgsAsync(*r); - } - else - { - params = getParams((*r), package); - args = getArgs(*r); - } + vector<string> params = getParams((*r), package); + vector<string> args = getArgs(*r); out << sp; - out << nl << "public " << (hasAMD ? "void" : retS) << nl << opName << spar << params; + out << nl << "public " << retS << nl << opName << spar << params; if(!p->isLocal()) { out << "Ice.Current __current"; @@ -1300,7 +1063,7 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p) writeThrowsClause(package, throws); out << sb; out << nl; - if(ret && !hasAMD) + if(ret) { out << "return "; } @@ -2840,31 +2603,6 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) out << eb; out << eb; out << eb; - - if(cl->hasMetaData("ami") || op->hasMetaData("ami")) - { - vector<string> paramsAMI = getParamsAsync(op, package, false); - vector<string> argsAMI = getArgsAsync(op); - - // - // Write two versions of the operation - with and without a - // context parameter - // - out << sp; - out << nl << "public void" << nl << op->name() << "_async" << spar << paramsAMI << epar; - out << sb; - out << nl << op->name() << "_async" << spar << argsAMI << "__defaultContext()" << epar << ';'; - out << eb; - - out << sp; - out << nl << "public void" << nl << op->name() << "_async" << spar << paramsAMI << "java.util.Map __ctx" - << epar; - out << sb; - // Async requests may only be sent twoway. - out << nl << "__checkTwowayOnly(\"" << p->name() << "\");"; - out << nl << "__cb.__invoke" << spar << "this" << argsAMI << "__ctx" << epar << ';'; - out << eb; - } } out << sp << nl << "public static " << name << "Prx" << nl << "checkedCast(Ice.ObjectPrx b)"; @@ -3815,20 +3553,6 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) out << nl << "public " << retS << ' ' << name << spar << params << "java.util.Map __ctx" << epar; writeThrowsClause(package, throws); out << ';'; - - if(cl->hasMetaData("ami") || p->hasMetaData("ami")) - { - vector<string> paramsAMI = getParamsAsync(p, package, false); - - // - // Write two versions of the operation - with and without a - // context parameter. - // - out << sp; - out << nl << "public void " << p->name() << "_async" << spar << paramsAMI << epar << ';'; - out << nl << "public void " << p->name() << "_async" << spar << paramsAMI << "java.util.Map __ctx" - << epar << ';'; - } } Slice::Gen::DelegateVisitor::DelegateVisitor(const string& dir) : @@ -4199,102 +3923,30 @@ Slice::Gen::BaseImplVisitor::writeOperation(Output& out, const string& package, ContainerPtr container = op->container(); ClassDefPtr cl = ClassDefPtr::dynamicCast(container); - if(!local && (cl->hasMetaData("amd") || op->hasMetaData("amd"))) + out << sp << nl << "public " << retS << nl << fixKwd(opName) << spar << params; + if(!local) { - vector<string> paramsAMD = getParamsAsync(op, package, true); - - out << sp << nl << "public void" << nl << opName << "_async" << spar << paramsAMD << "Ice.Current __current" - << epar; - - ExceptionList throws = op->throws(); - throws.sort(); - throws.unique(); - - // - // Arrange exceptions into most-derived to least-derived order. If we don't - // do this, a base exception handler can appear before a derived exception - // handler, causing compiler warnings and resulting in the base exception - // being marshaled instead of the derived exception. - // -#if defined(__SUNPRO_CC) - throws.sort(Slice::derivedToBaseCompare); -#else - throws.sort(Slice::DerivedToBaseCompare()); -#endif - writeThrowsClause(package, throws); - - out << sb; - - string result = "__r"; - ParamDeclList paramList = op->parameters(); - ParamDeclList::const_iterator q; - for(q = paramList.begin(); q != paramList.end(); ++q) - { - if((*q)->name() == result) - { - result = "_" + result; - break; - } - } - if(ret) - { - writeDecl(out, package, result, ret, opMetaData); - } - for(q = paramList.begin(); q != paramList.end(); ++q) - { - if((*q)->isOutParam()) - { - writeDecl(out, package, fixKwd((*q)->name()), (*q)->type(), (*q)->getMetaData()); - } - } - - out << nl << "__cb.ice_response("; - if(ret) - { - out << result; - } - for(q = paramList.begin(); q != paramList.end(); ++q) - { - if((*q)->isOutParam()) - { - if(ret || q != paramList.begin()) - { - out << ", "; - } - out << fixKwd((*q)->name()); - } - } - out << ");"; - - out << eb; + out << "Ice.Current __current"; } - else - { - out << sp << nl << "public " << retS << nl << fixKwd(opName) << spar << params; - if(!local) - { - out << "Ice.Current __current"; - } - out << epar; - - ExceptionList throws = op->throws(); - throws.sort(); - throws.unique(); + out << epar; - writeThrowsClause(package, throws); + ExceptionList throws = op->throws(); + throws.sort(); + throws.unique(); - out << sb; + writeThrowsClause(package, throws); - // - // Return value - // - if(ret) - { - writeReturn(out, ret); - } + out << sb; - out << eb; + // + // Return value + // + if(ret) + { + writeReturn(out, ret); } + + out << eb; } Slice::Gen::ImplVisitor::ImplVisitor(const string& dir) : @@ -4450,361 +4102,3 @@ Slice::Gen::ImplTieVisitor::visitClassDefStart(const ClassDefPtr& p) return false; } - -Slice::Gen::AsyncVisitor::AsyncVisitor(const string& dir) : - JavaVisitor(dir) -{ -} - -void -Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) -{ - ContainerPtr container = p->container(); - ClassDefPtr cl = ClassDefPtr::dynamicCast(container); - - if(cl->isLocal()) - { - return; - } - - string name = p->name(); - string classPkg = getPackage(cl); - StringList opMetaData = p->getMetaData(); - - if(cl->hasMetaData("ami") || p->hasMetaData("ami")) - { - string classNameAMI = "AMI_" + cl->name(); - string absoluteAMI = getAbsolute(cl, "", "AMI_", "_" + name); - - if(!open(absoluteAMI)) - { - return; - } - - Output& out = output(); - - TypePtr ret = p->returnType(); - - ParamDeclList inParams; - ParamDeclList outParams; - ParamDeclList paramList = p->parameters(); - ParamDeclList::const_iterator pli; - for(pli = paramList.begin(); pli != paramList.end(); ++pli) - { - if((*pli)->isOutParam()) - { - outParams.push_back(*pli); - } - else - { - inParams.push_back(*pli); - } - } - - ExceptionList throws = p->throws(); - throws.sort(); - throws.unique(); - - // - // Arrange exceptions into most-derived to least-derived order. If we don't - // do this, a base exception handler can appear before a derived exception - // handler, causing compiler warnings and resulting in the base exception - // being marshaled instead of the derived exception. - // -#if defined(__SUNPRO_CC) - throws.sort(Slice::derivedToBaseCompare); -#else - throws.sort(Slice::DerivedToBaseCompare()); -#endif - - int iter; - - vector<string> params = getParamsAsyncCB(p, classPkg); - vector<string> args = getArgsAsyncCB(p); - - vector<string> paramsInvoke = getParamsAsync(p, classPkg, false); - - out << sp << nl << "public abstract class " << classNameAMI << '_' << name - << " extends IceInternal.OutgoingAsync"; - out << sb; - out << sp; - out << nl << "public abstract void ice_response" << spar << params << epar << ';'; - out << nl << "public abstract void ice_exception(Ice.LocalException ex);"; - if(!throws.empty()) - { - out << nl << "public abstract void ice_exception(Ice.UserException ex);"; - } - - out << sp << nl << "public final void" << nl << "__invoke" << spar << "Ice.ObjectPrx __prx" - << paramsInvoke << "java.util.Map __ctx" << epar; - out << sb; - out << nl << "try"; - out << sb; - out << nl << "__prepare(__prx, \"" << p->name() << "\", " << sliceModeToIceMode(p) << ", __ctx);"; - iter = 0; - for(pli = inParams.begin(); pli != inParams.end(); ++pli) - { - StringList metaData = (*pli)->getMetaData(); - string typeS = typeToString((*pli)->type(), TypeModeIn, classPkg, metaData); - writeMarshalUnmarshalCode(out, classPkg, (*pli)->type(), fixKwd((*pli)->name()), true, iter, false, - metaData); - } - if(p->sendsClasses()) - { - out << nl << "__os.writePendingObjects();"; - } - out << nl << "__os.endWriteEncaps();"; - out << eb; - out << nl << "catch(Ice.LocalException __ex)"; - out << sb; - out << nl << "__finished(__ex);"; - out << nl << "return;"; - out << eb; - out << nl << "__send();"; - out << eb; - - out << sp << nl << "protected final void" << nl << "__response(boolean __ok)"; - out << sb; - for(pli = outParams.begin(); pli != outParams.end(); ++pli) - { - TypePtr paramType = (*pli)->type(); - string paramName = fixKwd((*pli)->name()); - string typeS = typeToString(paramType, TypeModeIn, classPkg, (*pli)->getMetaData()); - BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType)) - { - out << nl << typeS << "Holder " << paramName << " = new " << typeS << "Holder();"; - } - else - { - out << nl << typeS << ' ' << paramName << ';'; - } - } - if(ret) - { - string retS = typeToString(ret, TypeModeIn, classPkg, opMetaData); - BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret)) - { - out << nl << retS << "Holder __ret = new " << retS << "Holder();"; - } - else - { - out << nl << retS << " __ret;"; - } - } - out << nl << "try"; - out << sb; - out << nl << "if(!__ok)"; - out << sb; - out << nl << "try"; - out << sb; - out << nl << "__is.throwException();"; - out << eb; - for(ExceptionList::const_iterator r = throws.begin(); r != throws.end(); ++r) - { - out << nl << "catch(" << getAbsolute(*r, classPkg) << " __ex)"; - out << sb; - out << nl << "throw __ex;"; - out << eb; - } - out << nl << "catch(Ice.UserException __ex)"; - out << sb; - out << nl << "throw new Ice.UnknownUserException();"; - out << eb; - out << eb; - for(pli = outParams.begin(); pli != outParams.end(); ++pli) - { - TypePtr paramType = (*pli)->type(); - string paramName = fixKwd((*pli)->name()); - BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType)) - { - out << nl << "__is.readObject(" << paramName << ".getPatcher());"; - } - else - { - writeMarshalUnmarshalCode(out, classPkg, paramType, paramName, false, iter, false, - (*pli)->getMetaData()); - } - } - if(ret) - { - BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret)) - { - out << nl << "__is.readObject(__ret.getPatcher());"; - } - else - { - writeMarshalUnmarshalCode(out, classPkg, ret, "__ret", false, iter, false, opMetaData); - } - } - if(p->returnsClasses()) - { - out << nl << "__is.readPendingObjects();"; - } - out << eb; - out << nl << "catch(Ice.LocalException __ex)"; - out << sb; - out << nl << "__finished(__ex);"; - out << nl << "return;"; - out << eb; - if(!throws.empty()) - { - out << nl << "catch(Ice.UserException __ex)"; - out << sb; - out << nl << "ice_exception(__ex);"; - out << nl << "return;"; - out << eb; - } - out << nl << "ice_response" << spar << args << epar << ';'; - out << eb; - out << eb; - - close(); - } - - if(cl->hasMetaData("amd") || p->hasMetaData("amd")) - { - string classNameAMD = "AMD_" + cl->name(); - string absoluteAMD = getAbsolute(cl, "", "AMD_", "_" + name); - - string classNameAMDI = "_AMD_" + cl->name(); - string absoluteAMDI = getAbsolute(cl, "", "_AMD_", "_" + name); - - vector<string> paramsAMD = getParamsAsyncCB(p, classPkg); - - { - if(!open(absoluteAMD)) - { - return; - } - - Output& out = output(); - - out << sp << nl << "public interface " << classNameAMD << '_' << name; - out << sb; - out << sp << nl << "void ice_response" << spar << paramsAMD << epar << ';'; - out << sp << nl << "void ice_exception(java.lang.Exception ex);"; - out << eb; - - close(); - } - - { - if(!open(absoluteAMDI)) - { - return; - } - - Output& out = output(); - - TypePtr ret = p->returnType(); - - ParamDeclList outParams; - ParamDeclList paramList = p->parameters(); - ParamDeclList::const_iterator pli; - for(pli = paramList.begin(); pli != paramList.end(); ++pli) - { - if((*pli)->isOutParam()) - { - outParams.push_back(*pli); - } - } - - ExceptionList throws = p->throws(); - throws.sort(); - throws.unique(); - - // - // Arrange exceptions into most-derived to least-derived order. If we don't - // do this, a base exception handler can appear before a derived exception - // handler, causing compiler warnings and resulting in the base exception - // being marshaled instead of the derived exception. - // -#if defined(__SUNPRO_CC) - throws.sort(Slice::derivedToBaseCompare); -#else - throws.sort(Slice::DerivedToBaseCompare()); -#endif - - int iter; - - out << sp << nl << "final class " << classNameAMDI << '_' << name - << " extends IceInternal.IncomingAsync implements " << classNameAMD << '_' << name; - out << sb; - - out << sp << nl << "public" << nl << classNameAMDI << '_' << name << "(IceInternal.Incoming in)"; - out << sb; - out << nl << "super(in);"; - out << eb; - - out << sp << nl << "public void" << nl << "ice_response" << spar << paramsAMD << epar; - out << sb; - iter = 0; - if(ret || !outParams.empty()) - { - out << nl << "try"; - out << sb; - out << nl << "IceInternal.BasicStream __os = this.__os();"; - for(pli = outParams.begin(); pli != outParams.end(); ++pli) - { - StringList metaData = (*pli)->getMetaData(); - string typeS = typeToString((*pli)->type(), TypeModeIn, classPkg, metaData); - writeMarshalUnmarshalCode(out, classPkg, (*pli)->type(), fixKwd((*pli)->name()), true, iter, - false, metaData); - } - if(ret) - { - string retS = typeToString(ret, TypeModeIn, classPkg, opMetaData); - writeMarshalUnmarshalCode(out, classPkg, ret, "__ret", true, iter, false, opMetaData); - } - if(p->returnsClasses()) - { - out << nl << "__os.writePendingObjects();"; - } - out << eb; - out << nl << "catch(Ice.LocalException __ex)"; - out << sb; - out << nl << "ice_exception(__ex);"; - out << eb; - } - out << nl << "__response(true);"; - out << eb; - - out << sp << nl << "public void" << nl << "ice_exception(java.lang.Exception ex)"; - out << sb; - if(throws.empty()) - { - out << nl << "__exception(ex);"; - } - else - { - out << nl << "try"; - out << sb; - out << nl << "throw ex;"; - out << eb; - ExceptionList::const_iterator r; - for(r = throws.begin(); r != throws.end(); ++r) - { - string exS = getAbsolute(*r, classPkg); - out << nl << "catch(" << exS << " __ex)"; - out << sb; - out << nl << "__os().writeUserException(__ex);"; - out << nl << "__response(false);"; - out << eb; - } - out << nl << "catch(java.lang.Exception __ex)"; - out << sb; - out << nl << "__exception(__ex);"; - out << eb; - } - out << eb; - - out << eb; - - close(); - } - } -} diff --git a/cpp/src/slice2javae/Gen.h b/cpp/src/slice2javae/Gen.h index c172f30119f..907851578f2 100644 --- a/cpp/src/slice2javae/Gen.h +++ b/cpp/src/slice2javae/Gen.h @@ -31,15 +31,11 @@ protected: // Compose the parameter lists for an operation. // std::vector<std::string> getParams(const OperationPtr&, const std::string&); - std::vector<std::string> getParamsAsync(const OperationPtr&, const std::string&, bool); - std::vector<std::string> getParamsAsyncCB(const OperationPtr&, const std::string&); // // Compose the argument lists for an operation. // std::vector<std::string> getArgs(const OperationPtr&); - std::vector<std::string> getArgsAsync(const OperationPtr&); - std::vector<std::string> getArgsAsyncCB(const OperationPtr&); // // Generate a throws clause containing only non-local exceptions. @@ -247,15 +243,6 @@ private: virtual bool visitClassDefStart(const ClassDefPtr&); }; - - class AsyncVisitor : public JavaVisitor - { - public: - - AsyncVisitor(const std::string&); - - virtual void visitOperation(const OperationPtr&); - }; }; } |