diff options
Diffstat (limited to 'cpp/src/slice2java')
-rw-r--r-- | cpp/src/slice2java/Gen.cpp | 3508 | ||||
-rw-r--r-- | cpp/src/slice2java/Gen.h | 12 | ||||
-rw-r--r-- | cpp/src/slice2java/Main.cpp | 204 |
3 files changed, 1862 insertions, 1862 deletions
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index 03d04934dca..aa163075dfb 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -38,26 +38,26 @@ sliceModeToIceMode(Operation::Mode opMode) string mode; switch(opMode) { - case Operation::Normal: - { - mode = "Ice.OperationMode.Normal"; - break; - } - case Operation::Nonmutating: - { - mode = "Ice.OperationMode.Nonmutating"; - break; - } - case Operation::Idempotent: - { - mode = "Ice.OperationMode.Idempotent"; - break; - } - default: - { - assert(false); - break; - } + case Operation::Normal: + { + mode = "Ice.OperationMode.Normal"; + break; + } + case Operation::Nonmutating: + { + mode = "Ice.OperationMode.Nonmutating"; + break; + } + case Operation::Idempotent: + { + mode = "Ice.OperationMode.Idempotent"; + break; + } + default: + { + assert(false); + break; + } } return mode; } @@ -72,7 +72,7 @@ getDeprecateReason(const ContainedPtr& p1, const ContainedPtr& p2, const string& deprecateReason = "This " + type + " has been deprecated."; if(deprecateMetadata.find("deprecate:") == 0 && deprecateMetadata.size() > 10) { - deprecateReason = deprecateMetadata.substr(10); + deprecateReason = deprecateMetadata.substr(10); } } return deprecateReason; @@ -96,7 +96,7 @@ Slice::JavaVisitor::getParams(const OperationPtr& op, const string& package) for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) { StringList metaData = (*q)->getMetaData(); - string typeString = typeToString((*q)->type(), (*q)->isOutParam() ? TypeModeOut : TypeModeIn, package, + string typeString = typeToString((*q)->type(), (*q)->isOutParam() ? TypeModeOut : TypeModeIn, package, metaData); params.push_back(typeString + ' ' + fixKwd((*q)->name())); } @@ -118,12 +118,12 @@ Slice::JavaVisitor::getParamsAsync(const OperationPtr& op, const string& package ParamDeclList paramList = op->parameters(); for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) { - if(!(*q)->isOutParam()) - { + if(!(*q)->isOutParam()) + { StringList metaData = (*q)->getMetaData(); - string typeString = typeToString((*q)->type(), TypeModeIn, package, metaData); - params.push_back(typeString + ' ' + fixKwd((*q)->name())); - } + string typeString = typeToString((*q)->type(), TypeModeIn, package, metaData); + params.push_back(typeString + ' ' + fixKwd((*q)->name())); + } } return params; @@ -137,18 +137,18 @@ Slice::JavaVisitor::getParamsAsyncCB(const OperationPtr& op, const string& packa TypePtr ret = op->returnType(); if(ret) { - string retS = typeToString(ret, TypeModeIn, package, op->getMetaData()); - params.push_back(retS + " __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())); - } + if((*q)->isOutParam()) + { + string typeString = typeToString((*q)->type(), TypeModeIn, package, (*q)->getMetaData()); + params.push_back(typeString + ' ' + fixKwd((*q)->name())); + } } return params; @@ -178,10 +178,10 @@ Slice::JavaVisitor::getArgsAsync(const OperationPtr& op) ParamDeclList paramList = op->parameters(); for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) { - if(!(*q)->isOutParam()) - { - args.push_back(fixKwd((*q)->name())); - } + if(!(*q)->isOutParam()) + { + args.push_back(fixKwd((*q)->name())); + } } return args; @@ -195,32 +195,32 @@ Slice::JavaVisitor::getArgsAsyncCB(const OperationPtr& op) 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"); - } + 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())); - } - } + 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; @@ -239,12 +239,12 @@ Slice::JavaVisitor::writeThrowsClause(const string& package, const ExceptionList int count = 0; for(r = throws.begin(); r != throws.end(); ++r) { - if(count > 0) - { - out << "," << nl; - } - out << getAbsolute(*r, package); - count++; + if(count > 0) + { + out << "," << nl; + } + out << getAbsolute(*r, package); + count++; } out.restoreIndent(); out.dec(); @@ -263,8 +263,8 @@ Slice::JavaVisitor::writeDelegateThrowsClause(const string& package, const Excep ExceptionList::const_iterator r; for(r = throws.begin(); r != throws.end(); ++r) { - out << "," << nl; - out << getAbsolute(*r, package); + out << "," << nl; + out << getAbsolute(*r, package); } out.restoreIndent(); out.dec(); @@ -343,7 +343,7 @@ Slice::JavaVisitor::writeHashCode(Output& out, const TypePtr& type, const string SequencePtr seq = SequencePtr::dynamicCast(type); if(seq) { - bool customType = hasTypeMetaData(seq, metaData); + bool customType = hasTypeMetaData(seq, metaData); out << nl << "if(" << name << " != null)"; out << sb; @@ -354,7 +354,7 @@ Slice::JavaVisitor::writeHashCode(Output& out, const TypePtr& type, const string else { out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < " << name << ".length; __i" << iter - << "++)"; + << "++)"; out << sb; ostringstream elem; elem << name << "[__i" << iter << ']'; @@ -397,15 +397,15 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) out << sb; { - StringList::const_iterator q = ids.begin(); - while(q != ids.end()) - { - out << nl << '"' << *q << '"'; - if(++q != ids.end()) - { - out << ','; - } - } + StringList::const_iterator q = ids.begin(); + while(q != ids.end()) + { + out << nl << '"' << *q << '"'; + if(++q != ids.end()) + { + out << ','; + } + } } out << eb << ';'; @@ -452,96 +452,96 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) // for(r = ops.begin(); r != ops.end(); ++r) { - OperationPtr op = *r; + OperationPtr op = *r; string opName = op->name(); ContainerPtr container = op->container(); 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); - } - - ExceptionList throws = op->throws(); - throws.sort(); - throws.unique(); - - // - // Only generate a "no current" version of the operation if it hasn't been done in a base - // class already, because the "no current" version is final. - // - bool generateOperation = cl == p; // Generate if the operation is defined in this class. - if(!generateOperation) - { - // - // The operation is not defined in this class. - // - if(!bases.empty()) - { - // - // Check if the operation is already implemented by a base class. - // - bool implementedByBase = false; - if(!bases.front()->isInterface()) - { - OperationList baseOps = bases.front()->allOperations(); - OperationList::const_iterator i; - for(i = baseOps.begin(); i != baseOps.end(); ++i) - { - if((*i)->name() == op->name()) - { - implementedByBase = true; - break; - } - } - if(i == baseOps.end()) - { - generateOperation = true; - } - } - if(!generateOperation && !implementedByBase) - { - // - // No base class defines the operation. Check if one of the - // interfaces defines it, in which case this class must provide it. - // - if(bases.front()->isInterface() || bases.size() > 1) - { - generateOperation = true; - } - } - } - } - if(generateOperation) - { - out << sp << nl << "public final " << typeToString(ret, TypeModeReturn, package, op->getMetaData()) - << nl << opName << spar << params << epar; - writeThrowsClause(package, throws); - out << sb << nl; - if(ret) - { - out << "return "; - } - out << opName << spar << args << "null" << epar << ';'; - out << eb; - } + 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); + } + + ExceptionList throws = op->throws(); + throws.sort(); + throws.unique(); + + // + // Only generate a "no current" version of the operation if it hasn't been done in a base + // class already, because the "no current" version is final. + // + bool generateOperation = cl == p; // Generate if the operation is defined in this class. + if(!generateOperation) + { + // + // The operation is not defined in this class. + // + if(!bases.empty()) + { + // + // Check if the operation is already implemented by a base class. + // + bool implementedByBase = false; + if(!bases.front()->isInterface()) + { + OperationList baseOps = bases.front()->allOperations(); + OperationList::const_iterator i; + for(i = baseOps.begin(); i != baseOps.end(); ++i) + { + if((*i)->name() == op->name()) + { + implementedByBase = true; + break; + } + } + if(i == baseOps.end()) + { + generateOperation = true; + } + } + if(!generateOperation && !implementedByBase) + { + // + // No base class defines the operation. Check if one of the + // interfaces defines it, in which case this class must provide it. + // + if(bases.front()->isInterface() || bases.size() > 1) + { + generateOperation = true; + } + } + } + } + if(generateOperation) + { + out << sp << nl << "public final " << typeToString(ret, TypeModeReturn, package, op->getMetaData()) + << nl << opName << spar << params << epar; + writeThrowsClause(package, throws); + out << sb << nl; + if(ret) + { + out << "return "; + } + out << opName << spar << args << "null" << epar << ';'; + out << eb; + } } // @@ -556,250 +556,250 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) StringList opMetaData = op->getMetaData(); ContainerPtr container = op->container(); ClassDefPtr cl = ClassDefPtr::dynamicCast(container); - assert(cl); + assert(cl); string opName = op->name(); out << sp << nl << "public static IceInternal.DispatchStatus" << nl << "___" << opName << '(' << name - << " __obj, IceInternal.Incoming __inS, Ice.Current __current)"; + << " __obj, IceInternal.Incoming __inS, Ice.Current __current)"; out << sb; - bool amd = cl->hasMetaData("amd") || op->hasMetaData("amd"); - if(!amd) - { - TypePtr ret = op->returnType(); - - ParamDeclList inParams; - ParamDeclList outParams; - ParamDeclList paramList = op->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 = 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. - // + bool amd = cl->hasMetaData("amd") || op->hasMetaData("amd"); + if(!amd) + { + TypePtr ret = op->returnType(); + + ParamDeclList inParams; + ParamDeclList outParams; + ParamDeclList paramList = op->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 = 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); + throws.sort(Slice::derivedToBaseCompare); #else - throws.sort(Slice::DerivedToBaseCompare()); + throws.sort(Slice::DerivedToBaseCompare()); #endif - int iter; - - out << nl << "__checkMode(" << sliceModeToIceMode(op->mode()) << ", __current.mode);"; - - if(!inParams.empty()) - { - out << nl << "IceInternal.BasicStream __is = __inS.is();"; - } - if(!outParams.empty() || ret || !throws.empty()) - { - out << nl << "IceInternal.BasicStream __os = __inS.os();"; - } - - // - // Unmarshal 'in' parameters. - // - iter = 0; - for(pli = inParams.begin(); pli != inParams.end(); ++pli) - { + int iter; + + out << nl << "__checkMode(" << sliceModeToIceMode(op->mode()) << ", __current.mode);"; + + if(!inParams.empty()) + { + out << nl << "IceInternal.BasicStream __is = __inS.is();"; + } + if(!outParams.empty() || ret || !throws.empty()) + { + out << nl << "IceInternal.BasicStream __os = __inS.os();"; + } + + // + // 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) - { + 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);"; - - // - // 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, + 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);"; + + // + // 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;"; - - // - // Handle user exceptions. - // - if(!throws.empty()) - { - 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 << eb; - } - else - { - 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); - } - } - - int iter; - - out << nl << "__checkMode(" << sliceModeToIceMode(op->mode()) << ", __current.mode);"; - - if(!inParams.empty()) - { - out << nl << "IceInternal.BasicStream __is = __inS.is();"; - } - - // - // Unmarshal 'in' parameters. - // - iter = 0; - for(pli = inParams.begin(); pli != inParams.end(); ++pli) - { + } + if(ret) + { + writeMarshalUnmarshalCode(out, package, ret, "__ret", true, iter, false, opMetaData); + } + if(op->returnsClasses()) + { + out << nl << "__os.writePendingObjects();"; + } + out << nl << "return IceInternal.DispatchStatus.DispatchOK;"; + + // + // Handle user exceptions. + // + if(!throws.empty()) + { + 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 << eb; + } + else + { + 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); + } + } + + int iter; + + out << nl << "__checkMode(" << sliceModeToIceMode(op->mode()) << ", __current.mode);"; + + if(!inParams.empty()) + { + out << nl << "IceInternal.BasicStream __is = __inS.is();"; + } + + // + // 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 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();"; - } - - // - // Call on the servant. - // - string classNameAMD = "AMD_" + p->name(); - out << nl << classNameAMD << '_' << opName << " __cb = new _" << classNameAMD << '_' << opName - << "(__inS);"; + } + else + { + out << nl << typeS << ' ' << paramName << ';'; + writeMarshalUnmarshalCode(out, package, paramType, paramName, false, iter, false, metaData); + } + } + if(op->sendsClasses()) + { + out << nl << "__is.readPendingObjects();"; + } + + // + // Call on the servant. + // + string classNameAMD = "AMD_" + p->name(); + out << nl << classNameAMD << '_' << opName << " __cb = new _" << classNameAMD << '_' << opName + << "(__inS);"; out << nl << "try"; out << sb; - out << nl << "__obj." << (amd ? opName + "_async" : fixKwd(opName)) << (amd ? "(__cb, " : "("); - for(pli = inParams.begin(); pli != inParams.end(); ++pli) - { + out << nl << "__obj." << (amd ? opName + "_async" : fixKwd(opName)) << (amd ? "(__cb, " : "("); + 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 << ", "; - } - 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 << fixKwd((*pli)->name()); + BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType); + if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType)) + { + out << ".value"; + } + out << ", "; + } + 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; + } } OperationList allOps = p->allOperations(); @@ -830,7 +830,7 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) out << eb << ';'; out << sp << nl << "public IceInternal.DispatchStatus" << nl - << "__dispatch(IceInternal.Incoming in, Ice.Current __current)"; + << "__dispatch(IceInternal.Incoming in, Ice.Current __current)"; out << sb; out << nl << "int pos = java.util.Arrays.binarySearch(__all, __current.operation);"; out << nl << "if(pos < 0)"; @@ -903,47 +903,47 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p) out << eb; - // - // Check if we need to generate ice_operationAttributes() - // - - StringList freezeWriteOpNames; - for(OperationList::iterator r = allOps.begin(); r != allOps.end(); ++r) - { - ClassDefPtr classDef = ClassDefPtr::dynamicCast((*r)->container()); - assert(classDef != 0); - - if((*r)->hasMetaData("freeze:write") || - (classDef->hasMetaData("freeze:write") && !(*r)->hasMetaData("freeze:read"))) - { - freezeWriteOpNames.push_back((*r)->name()); - } - } - - if(!freezeWriteOpNames.empty()) - { - freezeWriteOpNames.sort(); - - StringList::iterator q; - - out << sp << nl << "private final static String[] __freezeWriteOperations ="; - out << sb; - q = freezeWriteOpNames.begin(); - while(q != freezeWriteOpNames.end()) - { - out << nl << '"' << *q << '"'; - if(++q != freezeWriteOpNames.end()) - { - out << ','; - } - } - out << eb << ';'; - - out << sp << nl << "public int ice_operationAttributes(String operation)"; - out << sb; - out << nl << "return (java.util.Arrays.binarySearch(__freezeWriteOperations, operation) >= 0) ? 1 : 0;"; - out << eb; - } + // + // Check if we need to generate ice_operationAttributes() + // + + StringList freezeWriteOpNames; + for(OperationList::iterator r = allOps.begin(); r != allOps.end(); ++r) + { + ClassDefPtr classDef = ClassDefPtr::dynamicCast((*r)->container()); + assert(classDef != 0); + + if((*r)->hasMetaData("freeze:write") || + (classDef->hasMetaData("freeze:write") && !(*r)->hasMetaData("freeze:read"))) + { + freezeWriteOpNames.push_back((*r)->name()); + } + } + + if(!freezeWriteOpNames.empty()) + { + freezeWriteOpNames.sort(); + + StringList::iterator q; + + out << sp << nl << "private final static String[] __freezeWriteOperations ="; + out << sb; + q = freezeWriteOpNames.begin(); + while(q != freezeWriteOpNames.end()) + { + out << nl << '"' << *q << '"'; + if(++q != freezeWriteOpNames.end()) + { + out << ','; + } + } + out << eb << ';'; + + out << sp << nl << "public int ice_operationAttributes(String operation)"; + out << sb; + out << nl << "return (java.util.Arrays.binarySearch(__freezeWriteOperations, operation) >= 0) ? 1 : 0;"; + out << eb; + } } } @@ -1062,21 +1062,21 @@ Slice::Gen::writeChecksumClass(const string& checksumClass, const string& dir, c // if(java2) { - out << sp << nl << "public static java.util.Map checksums;"; + out << sp << nl << "public static java.util.Map checksums;"; } else { - out << sp << nl << "public static java.util.Map<String, String> checksums;"; + out << sp << nl << "public static java.util.Map<String, String> checksums;"; } out << sp << nl << "static"; out << sb; if(java2) { - out << nl << "java.util.Map map = new java.util.HashMap();"; + out << nl << "java.util.Map map = new java.util.HashMap();"; } else { - out << nl << "java.util.Map<String, String> map = new java.util.HashMap<String, String>();"; + out << nl << "java.util.Map<String, String> map = new java.util.HashMap<String, String>();"; } for(ChecksumMap::const_iterator p = m.begin(); p != m.end(); ++p) { @@ -1115,7 +1115,7 @@ Slice::Gen::OpsVisitor::visitClassDefStart(const ClassDefPtr& p) if(!p->isLocal()) { - writeOperations(p, false); + writeOperations(p, false); } writeOperations(p, true); @@ -1131,7 +1131,7 @@ Slice::Gen::OpsVisitor::writeOperations(const ClassDefPtr& p, bool noCurrent) string opIntfName = "Operations"; if(noCurrent || p->isLocal()) { - opIntfName += "NC"; + opIntfName += "NC"; } string absolute = getAbsolute(p, "", "_", opIntfName); @@ -1176,47 +1176,47 @@ Slice::Gen::OpsVisitor::writeOperations(const ClassDefPtr& p, bool noCurrent) OperationList::const_iterator r; for(r = ops.begin(); r != ops.end(); ++r) { - OperationPtr op = *r; + OperationPtr op = *r; ContainerPtr container = op->container(); - ClassDefPtr cl = ClassDefPtr::dynamicCast(container); - string opname = op->name(); - - 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(); - } - - string deprecateReason = getDeprecateReason(*r, p, "operation"); - - string retS = typeToString(ret, TypeModeReturn, package, op->getMetaData()); - ExceptionList throws = op->throws(); - throws.sort(); - throws.unique(); - out << sp; - if(!deprecateReason.empty()) - { - out << nl << "/**"; - out << nl << " * @deprecated " << deprecateReason; - out << nl << " **/"; - } - out << nl << retS << ' ' << (amd ? opname + "_async" : fixKwd(opname)) << spar << params; - if(!noCurrent && !p->isLocal()) - { - out << "Ice.Current __current"; - } - out << epar; - writeThrowsClause(package, throws); - out << ';'; + ClassDefPtr cl = ClassDefPtr::dynamicCast(container); + string opname = op->name(); + + 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(); + } + + string deprecateReason = getDeprecateReason(*r, p, "operation"); + + string retS = typeToString(ret, TypeModeReturn, package, op->getMetaData()); + ExceptionList throws = op->throws(); + throws.sort(); + throws.unique(); + out << sp; + if(!deprecateReason.empty()) + { + out << nl << "/**"; + out << nl << " * @deprecated " << deprecateReason; + out << nl << " **/"; + } + out << nl << retS << ' ' << (amd ? opname + "_async" : fixKwd(opname)) << spar << params; + if(!noCurrent && !p->isLocal()) + { + out << "Ice.Current __current"; + } + out << epar; + writeThrowsClause(package, throws); + out << ';'; } out << eb; @@ -1320,47 +1320,47 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p) if(p->isLocal()) { out << sp << nl << "public int" << nl << "ice_hash()"; - out << sb; - out << nl << "return hashCode();"; - out << eb; + out << sb; + out << nl << "return hashCode();"; + out << eb; - out << sp << nl << "public java.lang.Object" << nl << "clone()"; - out.inc(); - out << nl << "throws java.lang.CloneNotSupportedException"; - out.dec(); - out << sb; - out << nl << "return super.clone();"; - out << eb; + out << sp << nl << "public java.lang.Object" << nl << "clone()"; + out.inc(); + out << nl << "throws java.lang.CloneNotSupportedException"; + out.dec(); + out << sb; + out << nl << "return super.clone();"; + out << eb; } OperationList ops = p->allOperations(); OperationList::const_iterator r; for(r = ops.begin(); r != ops.end(); ++r) { - ContainerPtr container = (*r)->container(); - ClassDefPtr cl = ClassDefPtr::dynamicCast(container); - bool hasAMD = cl->hasMetaData("amd") || (*r)->hasMetaData("amd"); + 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; + if(hasAMD) + { + opName = (*r)->name() + "_async"; + } + else + { + opName = fixKwd((*r)->name()); + } +#else string opName = hasAMD ? (*r)->name() + "_async" : fixKwd((*r)->name()); #endif TypePtr ret = (*r)->returnType(); string retS = typeToString(ret, TypeModeReturn, package, (*r)->getMetaData()); vector<string> params; - vector<string> args; + vector<string> args; if(hasAMD) { params = getParamsAsync((*r), package, true); @@ -1458,7 +1458,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) ClassDefPtr baseClass; if(!bases.empty() && !bases.front()->isInterface()) { - baseClass = bases.front(); + baseClass = bases.front(); } string package = getPackage(p); @@ -1489,15 +1489,15 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) { out << "Ice.Object"; } - out << "," << nl << '_' << name; - if(!p->isLocal()) - { - out << "Operations, _" << name << "OperationsNC"; - } - else - { - out << "OperationsNC"; - } + out << "," << nl << '_' << name; + if(!p->isLocal()) + { + out << "Operations, _" << name << "OperationsNC"; + } + else + { + out << "OperationsNC"; + } if(!bases.empty()) { ClassList::const_iterator q = bases.begin(); @@ -1542,10 +1542,10 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) StringList implements; if(p->isAbstract()) { - if(!p->isLocal()) - { - implements.push_back("_" + name + "Operations"); - } + if(!p->isLocal()) + { + implements.push_back("_" + name + "Operations"); + } implements.push_back("_" + name + "OperationsNC"); } if(!bases.empty()) @@ -1584,49 +1584,49 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) if(!p->isInterface() && !allDataMembers.empty()) { - // - // Constructors. - // - out << sp; - out << nl << "public " << name << "()"; - out << sb; - if(baseClass) - { - out << nl << "super();"; - } - out << eb; - - out << sp << nl << "public " << name << spar; - vector<string> paramDecl; - for(d = allDataMembers.begin(); d != allDataMembers.end(); ++d) - { - string memberName = fixKwd((*d)->name()); - string memberType = typeToString((*d)->type(), TypeModeMember, package, (*d)->getMetaData()); - paramDecl.push_back(memberType + " " + memberName); - } - out << paramDecl << epar; - out << sb; - if(baseClass && allDataMembers.size() != members.size()) - { - out << nl << "super" << spar; - vector<string> baseParamNames; - DataMemberList baseDataMembers = baseClass->allDataMembers(); - for(d = baseDataMembers.begin(); d != baseDataMembers.end(); ++d) - { - baseParamNames.push_back(fixKwd((*d)->name())); - } - out << baseParamNames << epar << ';'; - } - vector<string> paramNames; - for(d = members.begin(); d != members.end(); ++d) - { - paramNames.push_back(fixKwd((*d)->name())); - } - for(vector<string>::const_iterator i = paramNames.begin(); i != paramNames.end(); ++i) - { - out << nl << "this." << *i << " = " << *i << ';'; - } - out << eb; + // + // Constructors. + // + out << sp; + out << nl << "public " << name << "()"; + out << sb; + if(baseClass) + { + out << nl << "super();"; + } + out << eb; + + out << sp << nl << "public " << name << spar; + vector<string> paramDecl; + for(d = allDataMembers.begin(); d != allDataMembers.end(); ++d) + { + string memberName = fixKwd((*d)->name()); + string memberType = typeToString((*d)->type(), TypeModeMember, package, (*d)->getMetaData()); + paramDecl.push_back(memberType + " " + memberName); + } + out << paramDecl << epar; + out << sb; + if(baseClass && allDataMembers.size() != members.size()) + { + out << nl << "super" << spar; + vector<string> baseParamNames; + DataMemberList baseDataMembers = baseClass->allDataMembers(); + for(d = baseDataMembers.begin(); d != baseDataMembers.end(); ++d) + { + baseParamNames.push_back(fixKwd((*d)->name())); + } + out << baseParamNames << epar << ';'; + } + vector<string> paramNames; + for(d = members.begin(); d != members.end(); ++d) + { + paramNames.push_back(fixKwd((*d)->name())); + } + for(vector<string>::const_iterator i = paramNames.begin(); i != paramNames.end(); ++i) + { + out << nl << "this." << *i << " = " << *i << ';'; + } + out << eb; } // @@ -1665,91 +1665,91 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) out << sp << nl << "public void" << nl << "__write(IceInternal.BasicStream __os)"; out << sb; - out << nl << "__os.writeTypeId(ice_staticId());"; - out << nl << "__os.startWriteSlice();"; + out << nl << "__os.writeTypeId(ice_staticId());"; + out << nl << "__os.startWriteSlice();"; iter = 0; for(d = members.begin(); d != members.end(); ++d) { StringList metaData = (*d)->getMetaData(); writeMarshalUnmarshalCode(out, package, (*d)->type(), fixKwd((*d)->name()), true, iter, false, metaData); } - out << nl << "__os.endWriteSlice();"; + out << nl << "__os.endWriteSlice();"; out << nl << "super.__write(__os);"; out << eb; - DataMemberList allClassMembers = p->allClassDataMembers(); - if(allClassMembers.size() != 0) - { - out << sp << nl << "private class Patcher implements IceInternal.Patcher"; + DataMemberList allClassMembers = p->allClassDataMembers(); + if(allClassMembers.size() != 0) + { + out << sp << nl << "private class Patcher implements IceInternal.Patcher"; if(_stream) { out << ", Ice.ReadObjectCallback"; } - out << sb; - if(allClassMembers.size() > 1) - { - out << sp << nl << "Patcher(int member)"; - out << sb; - out << nl << "__member = member;"; - out << eb; - } - - out << sp << nl << "public void" << nl << "patch(Ice.Object v)"; - out << sb; - out << nl << "try"; - out << sb; - if(allClassMembers.size() > 1) - { - out << nl << "switch(__member)"; - out << sb; - } - int memberCount = 0; - for(d = allClassMembers.begin(); d != allClassMembers.end(); ++d) - { - if(allClassMembers.size() > 1) - { - out.dec(); - out << nl << "case " << memberCount << ":"; - out.inc(); - } - if(allClassMembers.size() > 1) - { - out << nl << "__typeId = \"" << (*d)->type()->typeId() << "\";"; - } - string memberName = fixKwd((*d)->name()); - string memberType = typeToString((*d)->type(), TypeModeMember, package); - out << nl << memberName << " = (" << memberType << ")v;"; - if(allClassMembers.size() > 1) - { - out << nl << "break;"; - } - memberCount++; - } - if(allClassMembers.size() > 1) - { - out << eb; - } - out << eb; - out << nl << "catch(ClassCastException ex)"; - out << sb; - out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();"; - out << nl << "_e.type = v.ice_id();"; - out << nl << "_e.expectedType = type();"; - out << nl << "throw _e;"; - out << eb; - out << eb; - - out << sp << nl << "public String" << nl << "type()"; - out << sb; - if(allClassMembers.size() > 1) - { - out << nl << "return __typeId;"; - } - else - { - out << nl << "return \"" << (*allClassMembers.begin())->type()->typeId() << "\";"; - } - out << eb; + out << sb; + if(allClassMembers.size() > 1) + { + out << sp << nl << "Patcher(int member)"; + out << sb; + out << nl << "__member = member;"; + out << eb; + } + + out << sp << nl << "public void" << nl << "patch(Ice.Object v)"; + out << sb; + out << nl << "try"; + out << sb; + if(allClassMembers.size() > 1) + { + out << nl << "switch(__member)"; + out << sb; + } + int memberCount = 0; + for(d = allClassMembers.begin(); d != allClassMembers.end(); ++d) + { + if(allClassMembers.size() > 1) + { + out.dec(); + out << nl << "case " << memberCount << ":"; + out.inc(); + } + if(allClassMembers.size() > 1) + { + out << nl << "__typeId = \"" << (*d)->type()->typeId() << "\";"; + } + string memberName = fixKwd((*d)->name()); + string memberType = typeToString((*d)->type(), TypeModeMember, package); + out << nl << memberName << " = (" << memberType << ")v;"; + if(allClassMembers.size() > 1) + { + out << nl << "break;"; + } + memberCount++; + } + if(allClassMembers.size() > 1) + { + out << eb; + } + out << eb; + out << nl << "catch(ClassCastException ex)"; + out << sb; + out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();"; + out << nl << "_e.type = v.ice_id();"; + out << nl << "_e.expectedType = type();"; + out << nl << "throw _e;"; + out << eb; + out << eb; + + out << sp << nl << "public String" << nl << "type()"; + out << sb; + if(allClassMembers.size() > 1) + { + out << nl << "return __typeId;"; + } + else + { + out << nl << "return \"" << (*allClassMembers.begin())->type()->typeId() << "\";"; + } + out << eb; if(_stream) { @@ -1759,40 +1759,40 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) out << eb; } - if(allClassMembers.size() > 1) - { - out << sp << nl << "private int __member;"; - out << nl << "private String __typeId;"; - } - out << eb; - } + if(allClassMembers.size() > 1) + { + out << sp << nl << "private int __member;"; + out << nl << "private String __typeId;"; + } + out << eb; + } out << sp << nl << "public void" << nl << "__read(IceInternal.BasicStream __is, boolean __rid)"; out << sb; - out << nl << "if(__rid)"; - out << sb; - out << nl << "__is.readTypeId();"; - out << eb; - out << nl << "__is.startReadSlice();"; + out << nl << "if(__rid)"; + out << sb; + out << nl << "__is.readTypeId();"; + out << eb; + out << nl << "__is.startReadSlice();"; iter = 0; - DataMemberList classMembers = p->classDataMembers(); - size_t classMemberCount = allClassMembers.size() - classMembers.size(); + DataMemberList classMembers = p->classDataMembers(); + size_t classMemberCount = allClassMembers.size() - classMembers.size(); for(d = members.begin(); d != members.end(); ++d) { StringList metaData = (*d)->getMetaData(); - ostringstream patchParams; - BuiltinPtr builtin = BuiltinPtr::dynamicCast((*d)->type()); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*d)->type())) - { - if(classMembers.size() > 1 || allClassMembers.size() > 1) - { - patchParams << "new Patcher(" << classMemberCount++ << ')'; - } - } + ostringstream patchParams; + BuiltinPtr builtin = BuiltinPtr::dynamicCast((*d)->type()); + if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*d)->type())) + { + if(classMembers.size() > 1 || allClassMembers.size() > 1) + { + patchParams << "new Patcher(" << classMemberCount++ << ')'; + } + } writeMarshalUnmarshalCode(out, package, (*d)->type(), fixKwd((*d)->name()), false, iter, false, metaData, - patchParams.str()); + patchParams.str()); } - out << nl << "__is.endReadSlice();"; + out << nl << "__is.endReadSlice();"; out << nl << "super.__read(__is, true);"; out << eb; @@ -1897,9 +1897,9 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) string deprecateReason = getDeprecateReason(p, 0, "type"); if(!deprecateReason.empty()) { - out << nl << "/**"; - out << nl << " * @deprecated " << deprecateReason; - out << nl << " **/"; + out << nl << "/**"; + out << nl << " * @deprecated " << deprecateReason; + out << nl << " **/"; } out << nl << "public class " << name << " extends "; @@ -1923,49 +1923,49 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) if(!allDataMembers.empty()) { - // - // Constructors. - // - out << sp; - out << nl << "public " << name << "()"; - out << sb; - if(base) - { - out << nl << "super();"; - } - out << eb; - - out << sp << nl << "public " << name << spar; - vector<string> paramDecl; - for(d = allDataMembers.begin(); d != allDataMembers.end(); ++d) - { - string memberName = fixKwd((*d)->name()); - string memberType = typeToString((*d)->type(), TypeModeMember, package, (*d)->getMetaData()); - paramDecl.push_back(memberType + " " + memberName); - } - out << paramDecl << epar; - out << sb; - if(base && allDataMembers.size() != members.size()) - { - out << nl << "super" << spar; - vector<string> baseParamNames; - DataMemberList baseDataMembers = base->allDataMembers(); - for(d = baseDataMembers.begin(); d != baseDataMembers.end(); ++d) - { - baseParamNames.push_back(fixKwd((*d)->name())); - } - out << baseParamNames << epar << ';'; - } - vector<string> paramNames; - for(d = members.begin(); d != members.end(); ++d) - { - paramNames.push_back(fixKwd((*d)->name())); - } - for(vector<string>::const_iterator i = paramNames.begin(); i != paramNames.end(); ++i) - { - out << nl << "this." << *i << " = " << *i << ';'; - } - out << eb; + // + // Constructors. + // + out << sp; + out << nl << "public " << name << "()"; + out << sb; + if(base) + { + out << nl << "super();"; + } + out << eb; + + out << sp << nl << "public " << name << spar; + vector<string> paramDecl; + for(d = allDataMembers.begin(); d != allDataMembers.end(); ++d) + { + string memberName = fixKwd((*d)->name()); + string memberType = typeToString((*d)->type(), TypeModeMember, package, (*d)->getMetaData()); + paramDecl.push_back(memberType + " " + memberName); + } + out << paramDecl << epar; + out << sb; + if(base && allDataMembers.size() != members.size()) + { + out << nl << "super" << spar; + vector<string> baseParamNames; + DataMemberList baseDataMembers = base->allDataMembers(); + for(d = baseDataMembers.begin(); d != baseDataMembers.end(); ++d) + { + baseParamNames.push_back(fixKwd((*d)->name())); + } + out << baseParamNames << epar << ';'; + } + vector<string> paramNames; + for(d = members.begin(); d != members.end(); ++d) + { + paramNames.push_back(fixKwd((*d)->name())); + } + for(vector<string>::const_iterator i = paramNames.begin(); i != paramNames.end(); ++i) + { + out << nl << "this." << *i << " = " << *i << ';'; + } + out << eb; } out << sp << nl << "public String" << nl << "ice_name()"; @@ -1994,94 +1994,94 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) out << sp << nl << "public void" << nl << "__write(IceInternal.BasicStream __os)"; out << sb; - out << nl << "__os.writeString(\"" << scoped << "\");"; - out << nl << "__os.startWriteSlice();"; + out << nl << "__os.writeString(\"" << scoped << "\");"; + out << nl << "__os.startWriteSlice();"; iter = 0; for(d = members.begin(); d != members.end(); ++d) { StringList metaData = (*d)->getMetaData(); writeMarshalUnmarshalCode(out, package, (*d)->type(), fixKwd((*d)->name()), true, iter, false, metaData); } - out << nl << "__os.endWriteSlice();"; + out << nl << "__os.endWriteSlice();"; if(base) { out << nl << "super.__write(__os);"; } out << eb; - DataMemberList allClassMembers = p->allClassDataMembers(); - if(allClassMembers.size() != 0) - { - out << sp << nl << "private class Patcher implements IceInternal.Patcher"; + DataMemberList allClassMembers = p->allClassDataMembers(); + if(allClassMembers.size() != 0) + { + out << sp << nl << "private class Patcher implements IceInternal.Patcher"; if(_stream) { out << ", Ice.ReadObjectCallback"; } - out << sb; - if(allClassMembers.size() > 1) - { - out << sp << nl << "Patcher(int member)"; - out << sb; - out << nl << "__member = member;"; - out << eb; - } - - out << sp << nl << "public void" << nl << "patch(Ice.Object v)"; - out << sb; - out << nl << "try"; - out << sb; - if(allClassMembers.size() > 1) - { - out << nl << "switch(__member)"; - out << sb; - } - int memberCount = 0; - for(d = allClassMembers.begin(); d != allClassMembers.end(); ++d) - { - if(allClassMembers.size() > 1) - { - out.dec(); - out << nl << "case " << memberCount << ":"; - out.inc(); - } - if(allClassMembers.size() > 1) - { - out << nl << "__typeId = \"" << (*d)->type()->typeId() << "\";"; - } - string memberName = fixKwd((*d)->name()); - string memberType = typeToString((*d)->type(), TypeModeMember, package); - out << nl << memberName << " = (" << memberType << ")v;"; - if(allClassMembers.size() > 1) - { - out << nl << "break;"; - } - memberCount++; - } - if(allClassMembers.size() > 1) - { - out << eb; - } - out << eb; - out << nl << "catch(ClassCastException ex)"; - out << sb; - out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();"; - out << nl << "_e.type = v.ice_id();"; - out << nl << "_e.expectedType = type();"; - out << nl << "throw _e;"; - out << eb; - out << eb; - - out << sp << nl << "public String" << nl << "type()"; - out << sb; - if(allClassMembers.size() > 1) - { - out << nl << "return __typeId;"; - } - else - { - out << nl << "return \"" << (*allClassMembers.begin())->type()->typeId() << "\";"; - } - out << eb; + out << sb; + if(allClassMembers.size() > 1) + { + out << sp << nl << "Patcher(int member)"; + out << sb; + out << nl << "__member = member;"; + out << eb; + } + + out << sp << nl << "public void" << nl << "patch(Ice.Object v)"; + out << sb; + out << nl << "try"; + out << sb; + if(allClassMembers.size() > 1) + { + out << nl << "switch(__member)"; + out << sb; + } + int memberCount = 0; + for(d = allClassMembers.begin(); d != allClassMembers.end(); ++d) + { + if(allClassMembers.size() > 1) + { + out.dec(); + out << nl << "case " << memberCount << ":"; + out.inc(); + } + if(allClassMembers.size() > 1) + { + out << nl << "__typeId = \"" << (*d)->type()->typeId() << "\";"; + } + string memberName = fixKwd((*d)->name()); + string memberType = typeToString((*d)->type(), TypeModeMember, package); + out << nl << memberName << " = (" << memberType << ")v;"; + if(allClassMembers.size() > 1) + { + out << nl << "break;"; + } + memberCount++; + } + if(allClassMembers.size() > 1) + { + out << eb; + } + out << eb; + out << nl << "catch(ClassCastException ex)"; + out << sb; + out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();"; + out << nl << "_e.type = v.ice_id();"; + out << nl << "_e.expectedType = type();"; + out << nl << "throw _e;"; + out << eb; + out << eb; + + out << sp << nl << "public String" << nl << "type()"; + out << sb; + if(allClassMembers.size() > 1) + { + out << nl << "return __typeId;"; + } + else + { + out << nl << "return \"" << (*allClassMembers.begin())->type()->typeId() << "\";"; + } + out << eb; if(_stream) { @@ -2091,39 +2091,39 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) out << eb; } - if(allClassMembers.size() > 1) - { - out << sp << nl << "private int __member;"; - out << nl << "private String __typeId;"; - } - out << eb; - } + if(allClassMembers.size() > 1) + { + out << sp << nl << "private int __member;"; + out << nl << "private String __typeId;"; + } + out << eb; + } out << sp << nl << "public void" << nl << "__read(IceInternal.BasicStream __is, boolean __rid)"; out << sb; - out << nl << "if(__rid)"; - out << sb; - out << nl << "__is.readString();"; - out << eb; - out << nl << "__is.startReadSlice();"; + out << nl << "if(__rid)"; + out << sb; + out << nl << "__is.readString();"; + out << eb; + out << nl << "__is.startReadSlice();"; iter = 0; - DataMemberList classMembers = p->classDataMembers(); - size_t classMemberCount = allClassMembers.size() - classMembers.size(); + DataMemberList classMembers = p->classDataMembers(); + size_t classMemberCount = allClassMembers.size() - classMembers.size(); for(d = members.begin(); d != members.end(); ++d) { - ostringstream patchParams; - BuiltinPtr builtin = BuiltinPtr::dynamicCast((*d)->type()); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*d)->type())) - { - if(classMembers.size() > 1 || allClassMembers.size() > 1) - { - patchParams << "new Patcher(" << classMemberCount++ << ')'; - } - } + ostringstream patchParams; + BuiltinPtr builtin = BuiltinPtr::dynamicCast((*d)->type()); + if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*d)->type())) + { + if(classMembers.size() > 1 || allClassMembers.size() > 1) + { + patchParams << "new Patcher(" << classMemberCount++ << ')'; + } + } StringList metaData = (*d)->getMetaData(); writeMarshalUnmarshalCode(out, package, (*d)->type(), fixKwd((*d)->name()), false, iter, false, metaData, - patchParams.str()); + patchParams.str()); } - out << nl << "__is.endReadSlice();"; + out << nl << "__is.endReadSlice();"; if(base) { out << nl << "super.__read(__is, true);"; @@ -2200,16 +2200,16 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) out << eb; } - if(p->usesClasses()) - { - if(!base || base && !base->usesClasses()) - { - out << sp << nl << "public boolean" << nl << "__usesClasses()"; - out << sb; - out << nl << "return true;"; - out << eb; - } - } + if(p->usesClasses()) + { + if(!base || base && !base->usesClasses()) + { + out << sp << nl << "public boolean" << nl << "__usesClasses()"; + out << sb; + out << nl << "return true;"; + out << eb; + } + } } out << eb; @@ -2234,9 +2234,9 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p) string deprecateReason = getDeprecateReason(p, 0, "type"); if(!deprecateReason.empty()) { - out << nl << "/**"; - out << nl << " * @deprecated " << deprecateReason; - out << nl << " **/"; + out << nl << "/**"; + out << nl << " * @deprecated " << deprecateReason; + out << nl << " **/"; } out << nl << "public final class " << name << " implements java.lang.Cloneable"; @@ -2267,17 +2267,17 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) vector<string> paramNames; for(d = members.begin(); d != members.end(); ++d) { - string memberName = fixKwd((*d)->name()); - string memberType = typeToString((*d)->type(), TypeModeMember, package, (*d)->getMetaData()); - paramDecl.push_back(memberType + " " + memberName); - paramNames.push_back(memberName); + string memberName = fixKwd((*d)->name()); + string memberType = typeToString((*d)->type(), TypeModeMember, package, (*d)->getMetaData()); + paramDecl.push_back(memberType + " " + memberName); + paramNames.push_back(memberName); } out << sp << nl << "public " << name << spar << paramDecl << epar; out << sb; for(vector<string>::const_iterator i = paramNames.begin(); i != paramNames.end(); ++i) { - out << nl << "this." << *i << " = " << *i << ';'; + out << nl << "this." << *i << " = " << *i << ';'; } out << eb; @@ -2347,7 +2347,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) SequencePtr seq = SequencePtr::dynamicCast((*d)->type()); if(seq) { - if(hasTypeMetaData(seq, (*d)->getMetaData())) + if(hasTypeMetaData(seq, (*d)->getMetaData())) { out << nl << "if(" << memberName << " != _r." << memberName << " && " << memberName << " != null && !" << memberName << ".equals(_r." << memberName << "))"; @@ -2417,80 +2417,80 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) } out << eb; - DataMemberList classMembers = p->classDataMembers(); + DataMemberList classMembers = p->classDataMembers(); - if(classMembers.size() != 0) - { - out << sp << nl << "private class Patcher implements IceInternal.Patcher"; + if(classMembers.size() != 0) + { + out << sp << nl << "private class Patcher implements IceInternal.Patcher"; if(_stream) { out << ", Ice.ReadObjectCallback"; } - out << sb; - if(classMembers.size() > 1) - { - out << sp << nl << "Patcher(int member)"; - out << sb; - out << nl << "__member = member;"; - out << eb; - } - - out << sp << nl << "public void" << nl << "patch(Ice.Object v)"; - out << sb; - out << nl << "try"; - out << sb; - if(classMembers.size() > 1) - { - out << nl << "switch(__member)"; - out << sb; - } - int memberCount = 0; - for(d = classMembers.begin(); d != classMembers.end(); ++d) - { - if(classMembers.size() > 1) - { - out.dec(); - out << nl << "case " << memberCount << ":"; - out.inc(); - } - if(classMembers.size() > 1) - { - out << nl << "__typeId = \"" << (*d)->type()->typeId() << "\";"; - } - string memberName = fixKwd((*d)->name()); - string memberType = typeToString((*d)->type(), TypeModeMember, package); - out << nl << memberName << " = (" << memberType << ")v;"; - if(classMembers.size() > 1) - { - out << nl << "break;"; - } - memberCount++; - } - if(classMembers.size() > 1) - { - out << eb; - } - out << eb; - out << nl << "catch(ClassCastException ex)"; - out << sb; - out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();"; - out << nl << "_e.type = v.ice_id();"; - out << nl << "_e.expectedType = type();"; - out << nl << "throw _e;"; - out << eb; - out << eb; - - out << sp << nl << "public String" << nl << "type()"; - out << sb; - if(classMembers.size() > 1) - { - out << nl << "return __typeId;"; - } - else - { - out << nl << "return \"" << (*classMembers.begin())->type()->typeId() << "\";"; - } - out << eb; + out << sb; + if(classMembers.size() > 1) + { + out << sp << nl << "Patcher(int member)"; + out << sb; + out << nl << "__member = member;"; + out << eb; + } + + out << sp << nl << "public void" << nl << "patch(Ice.Object v)"; + out << sb; + out << nl << "try"; + out << sb; + if(classMembers.size() > 1) + { + out << nl << "switch(__member)"; + out << sb; + } + int memberCount = 0; + for(d = classMembers.begin(); d != classMembers.end(); ++d) + { + if(classMembers.size() > 1) + { + out.dec(); + out << nl << "case " << memberCount << ":"; + out.inc(); + } + if(classMembers.size() > 1) + { + out << nl << "__typeId = \"" << (*d)->type()->typeId() << "\";"; + } + string memberName = fixKwd((*d)->name()); + string memberType = typeToString((*d)->type(), TypeModeMember, package); + out << nl << memberName << " = (" << memberType << ")v;"; + if(classMembers.size() > 1) + { + out << nl << "break;"; + } + memberCount++; + } + if(classMembers.size() > 1) + { + out << eb; + } + out << eb; + out << nl << "catch(ClassCastException ex)"; + out << sb; + out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();"; + out << nl << "_e.type = v.ice_id();"; + out << nl << "_e.expectedType = type();"; + out << nl << "throw _e;"; + out << eb; + out << eb; + + out << sp << nl << "public String" << nl << "type()"; + out << sb; + if(classMembers.size() > 1) + { + out << nl << "return __typeId;"; + } + else + { + out << nl << "return \"" << (*classMembers.begin())->type()->typeId() << "\";"; + } + out << eb; if(_stream) { @@ -2500,32 +2500,32 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) out << eb; } - if(classMembers.size() > 1) - { - out << sp << nl << "private int __member;"; - out << nl << "private String __typeId;"; - } - out << eb; - } + if(classMembers.size() > 1) + { + out << sp << nl << "private int __member;"; + out << nl << "private String __typeId;"; + } + out << eb; + } out << sp << nl << "public void" << nl << "__read(IceInternal.BasicStream __is)"; out << sb; iter = 0; - int classMemberCount = 0; + int classMemberCount = 0; for(d = members.begin(); d != members.end(); ++d) { - ostringstream patchParams; - BuiltinPtr builtin = BuiltinPtr::dynamicCast((*d)->type()); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*d)->type())) - { - if(classMembers.size() > 1) - { - patchParams << "new Patcher(" << classMemberCount++ << ')'; - } - } + ostringstream patchParams; + BuiltinPtr builtin = BuiltinPtr::dynamicCast((*d)->type()); + if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*d)->type())) + { + if(classMembers.size() > 1) + { + patchParams << "new Patcher(" << classMemberCount++ << ')'; + } + } StringList metaData = (*d)->getMetaData(); writeMarshalUnmarshalCode(out, package, (*d)->type(), fixKwd((*d)->name()), false, iter, false, metaData, - patchParams.str()); + patchParams.str()); } out << eb; @@ -2585,9 +2585,9 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p) string deprecateReason = getDeprecateReason(p, contained, "member"); if(!deprecateReason.empty()) { - out << nl << "/**"; - out << nl << " * @deprecated " << deprecateReason; - out << nl << " **/"; + out << nl << "/**"; + out << nl << " * @deprecated " << deprecateReason; + out << nl << " **/"; } out << nl << "public " << s << ' ' << name << ';'; @@ -2596,134 +2596,134 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p) // if(p->hasMetaData(_getSetMetaData) || contained->hasMetaData(_getSetMetaData)) { - string capName = p->name(); - capName[0] = toupper(capName[0]); - - // - // If container is a class, get all of its operations so that we can check for conflicts. - // - OperationList ops; - string file, line; - ClassDefPtr cls = ClassDefPtr::dynamicCast(container); - if(cls) - { - ops = cls->allOperations(); - DefinitionContextPtr dc = p->definitionContext(); - file = dc->filename(); - line = p->line(); - if(!validateGetterSetter(ops, "get" + capName, 0, file, line) || - !validateGetterSetter(ops, "set" + capName, 1, file, line)) - { - return; - } - } - - // - // Getter. - // - out << sp; - if(!deprecateReason.empty()) - { - out << nl << "/**"; - out << nl << " * @deprecated " << deprecateReason; - out << nl << " **/"; - } - out << nl << "public " << s; - out << nl << "get" << capName << "()"; - out << sb; - out << nl << "return " << name << ';'; - out << eb; - - // - // Setter. - // - out << sp; - if(!deprecateReason.empty()) - { - out << nl << "/**"; - out << nl << " * @deprecated " << deprecateReason; - out << nl << " **/"; - } - out << nl << "public void"; - out << nl << "set" << capName << '(' << s << " _" << name << ')'; - out << sb; - out << nl << name << " = _" << name << ';'; - out << eb; - - // - // Check for bool type. - // - BuiltinPtr b = BuiltinPtr::dynamicCast(type); - if(b && b->kind() == Builtin::KindBool) - { - if(cls && !validateGetterSetter(ops, "is" + capName, 0, file, line)) - { - return; - } - out << sp; - if(!deprecateReason.empty()) - { - out << nl << "/**"; - out << nl << " * @deprecated " << deprecateReason; - out << nl << " **/"; - } - out << nl << "public boolean"; - out << nl << "is" << capName << "()"; - out << sb; - out << nl << "return " << name << ';'; - out << eb; - } - - // - // Check for unmodified sequence type and emit indexing methods. - // - SequencePtr seq = SequencePtr::dynamicCast(type); - if(seq) - { - if(!hasTypeMetaData(seq, metaData)) - { - if(cls && - (!validateGetterSetter(ops, "get" + capName, 1, file, line) || - !validateGetterSetter(ops, "set" + capName, 2, file, line))) - { - return; - } - - string elem = typeToString(seq->type(), TypeModeMember, getPackage(contained)); - - // - // Indexed getter. - // - out << sp; - if(!deprecateReason.empty()) - { - out << nl << "/**"; - out << nl << " * @deprecated " << deprecateReason; - out << nl << " **/"; - } - out << nl << "public " << elem; - out << nl << "get" << capName << "(int _index)"; - out << sb; - out << nl << "return " << name << "[_index];"; - out << eb; - - // - // Indexed setter. - // - out << sp; - if(!deprecateReason.empty()) - { - out << nl << "/**"; - out << nl << " * @deprecated " << deprecateReason; - out << nl << " **/"; - } - out << nl << "public void"; - out << nl << "set" << capName << "(int _index, " << elem << " _val)"; - out << sb; - out << nl << name << "[_index] = _val;"; - out << eb; - } - } + string capName = p->name(); + capName[0] = toupper(capName[0]); + + // + // If container is a class, get all of its operations so that we can check for conflicts. + // + OperationList ops; + string file, line; + ClassDefPtr cls = ClassDefPtr::dynamicCast(container); + if(cls) + { + ops = cls->allOperations(); + DefinitionContextPtr dc = p->definitionContext(); + file = dc->filename(); + line = p->line(); + if(!validateGetterSetter(ops, "get" + capName, 0, file, line) || + !validateGetterSetter(ops, "set" + capName, 1, file, line)) + { + return; + } + } + + // + // Getter. + // + out << sp; + if(!deprecateReason.empty()) + { + out << nl << "/**"; + out << nl << " * @deprecated " << deprecateReason; + out << nl << " **/"; + } + out << nl << "public " << s; + out << nl << "get" << capName << "()"; + out << sb; + out << nl << "return " << name << ';'; + out << eb; + + // + // Setter. + // + out << sp; + if(!deprecateReason.empty()) + { + out << nl << "/**"; + out << nl << " * @deprecated " << deprecateReason; + out << nl << " **/"; + } + out << nl << "public void"; + out << nl << "set" << capName << '(' << s << " _" << name << ')'; + out << sb; + out << nl << name << " = _" << name << ';'; + out << eb; + + // + // Check for bool type. + // + BuiltinPtr b = BuiltinPtr::dynamicCast(type); + if(b && b->kind() == Builtin::KindBool) + { + if(cls && !validateGetterSetter(ops, "is" + capName, 0, file, line)) + { + return; + } + out << sp; + if(!deprecateReason.empty()) + { + out << nl << "/**"; + out << nl << " * @deprecated " << deprecateReason; + out << nl << " **/"; + } + out << nl << "public boolean"; + out << nl << "is" << capName << "()"; + out << sb; + out << nl << "return " << name << ';'; + out << eb; + } + + // + // Check for unmodified sequence type and emit indexing methods. + // + SequencePtr seq = SequencePtr::dynamicCast(type); + if(seq) + { + if(!hasTypeMetaData(seq, metaData)) + { + if(cls && + (!validateGetterSetter(ops, "get" + capName, 1, file, line) || + !validateGetterSetter(ops, "set" + capName, 2, file, line))) + { + return; + } + + string elem = typeToString(seq->type(), TypeModeMember, getPackage(contained)); + + // + // Indexed getter. + // + out << sp; + if(!deprecateReason.empty()) + { + out << nl << "/**"; + out << nl << " * @deprecated " << deprecateReason; + out << nl << " **/"; + } + out << nl << "public " << elem; + out << nl << "get" << capName << "(int _index)"; + out << sb; + out << nl << "return " << name << "[_index];"; + out << eb; + + // + // Indexed setter. + // + out << sp; + if(!deprecateReason.empty()) + { + out << nl << "/**"; + out << nl << " * @deprecated " << deprecateReason; + out << nl << " **/"; + } + out << nl << "public void"; + out << nl << "set" << capName << "(int _index, " << elem << " _val)"; + out << sb; + out << nl << name << "[_index] = _val;"; + out << eb; + } + } } } @@ -2748,49 +2748,49 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) string deprecateReason = getDeprecateReason(p, 0, "type"); if(!deprecateReason.empty()) { - out << nl << "/**"; - out << nl << " * @deprecated " << deprecateReason; - out << nl << " **/"; + out << nl << "/**"; + out << nl << " * @deprecated " << deprecateReason; + out << nl << " **/"; } bool java2 = p->definitionContext()->findMetaData("java:java2") == "java:java2"; if(java2) { - out << nl << "public final class " << name; + out << nl << "public final class " << name; } else { - out << nl << "public enum " << name; + out << nl << "public enum " << name; } out << sb; if(!java2) { - int n; - for(en = enumerators.begin(), n = 0; en != enumerators.end(); ++en, ++n) - { - if(en != enumerators.begin()) - { - out << ','; - } - out << nl << fixKwd((*en)->name()) << '(' << n << ')'; - } - out << ';'; - out << sp; + int n; + for(en = enumerators.begin(), n = 0; en != enumerators.end(); ++en, ++n) + { + if(en != enumerators.begin()) + { + out << ','; + } + out << nl << fixKwd((*en)->name()) << '(' << n << ')'; + } + out << ';'; + out << sp; } out << nl << "private static " << name << "[] __values = new " << name << "[" << sz << "];"; if(!java2) { - out << nl << "static"; - out << sb; - int n; - for(en = enumerators.begin(), n = 0; en != enumerators.end(); ++en, ++n) - { - out << nl << "__values[" << n << "] = " << fixKwd((*en)->name()) << ';'; - } - out << eb; + out << nl << "static"; + out << sb; + int n; + for(en = enumerators.begin(), n = 0; en != enumerators.end(); ++en, ++n) + { + out << nl << "__values[" << n << "] = " << fixKwd((*en)->name()) << ';'; + } + out << eb; } out << nl << "private int __value;"; @@ -2798,18 +2798,18 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) // For backward compatibility, we keep the integer member in the Java5 mapping. // { - out << sp; - int n; - for(en = enumerators.begin(), n = 0; en != enumerators.end(); ++en, ++n) - { - string member = fixKwd((*en)->name()); - out << nl << "public static final int _" << member << " = " << n << ';'; - if(java2) - { - out << nl << "public static final " << name << ' ' << fixKwd(member) - << " = new " << name << "(_" << member << ");"; - } - } + out << sp; + int n; + for(en = enumerators.begin(), n = 0; en != enumerators.end(); ++en, ++n) + { + string member = fixKwd((*en)->name()); + out << nl << "public static final int _" << member << " = " << n << ';'; + if(java2) + { + out << nl << "public static final " << name << ' ' << fixKwd(member) + << " = new " << name << "(_" << member << ");"; + } + } } out << sp << nl << "public static " << name << nl << "convert(int val)"; @@ -2838,10 +2838,10 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) if(java2) { - out << sp << nl << "public String" << nl << "toString()"; - out << sb; - out << nl << "return __T[__value];"; - out << eb; + out << sp << nl << "public String" << nl << "toString()"; + out << sb; + out << nl << "return __T[__value];"; + out << eb; } out << sp << nl << "private" << nl << name << "(int val)"; @@ -2849,7 +2849,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) out << nl << "__value = val;"; if(java2) { - out << nl << "__values[val] = this;"; + out << nl << "__values[val] = this;"; } out << eb; @@ -2935,18 +2935,18 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) if(java2) { - out << sp << nl << "final static private String[] __T ="; - out << sb; - en = enumerators.begin(); - while(en != enumerators.end()) - { - out << nl << "\"" << (*en)->name() << "\""; - if(++en != enumerators.end()) - { - out << ','; - } - } - out << eb << ';'; + out << sp << nl << "final static private String[] __T ="; + out << sb; + en = enumerators.begin(); + while(en != enumerators.end()) + { + out << nl << "\"" << (*en)->name() << "\""; + if(++en != enumerators.end()) + { + out << ','; + } + } + out << eb << ';'; } out << eb; @@ -2974,76 +2974,76 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p) EnumPtr ep; if(bp = BuiltinPtr::dynamicCast(type)) { - switch(bp->kind()) - { - case Builtin::KindString: - { - out << "\""; - - const string val = p->value(); - for(string::const_iterator c = val.begin(); c != val.end(); ++c) - { - if(isascii(*c) && isprint(*c)) - { - switch(*c) - { - case '\\': - case '"': - { - out << "\\"; - break; - } - } - out << *c; - } - else - { - switch(*c) - { - case '\r': - { - out << "\\r"; - break; - } - case '\n': - { - out << "\\n"; - break; - } - default: - { - unsigned char uc = *c; - ostringstream s; - s << "\\u"; - s.flags(ios_base::hex); - s.width(4); - s.fill('0'); - s << static_cast<unsigned>(uc); - out << s.str(); - break; - } - } - } - } - - out << "\""; - break; - } - case Builtin::KindByte: - { - int i = atoi(p->value().c_str()); - if(i > 127) - { - i -= 256; - } - out << i; // Slice byte runs from 0-255, Java byte runs from -128 - 127. - break; - } - case Builtin::KindLong: - { - out << p->value() << "L"; // Need to append "L" modifier for long constants. - break; - } + switch(bp->kind()) + { + case Builtin::KindString: + { + out << "\""; + + const string val = p->value(); + for(string::const_iterator c = val.begin(); c != val.end(); ++c) + { + if(isascii(*c) && isprint(*c)) + { + switch(*c) + { + case '\\': + case '"': + { + out << "\\"; + break; + } + } + out << *c; + } + else + { + switch(*c) + { + case '\r': + { + out << "\\r"; + break; + } + case '\n': + { + out << "\\n"; + break; + } + default: + { + unsigned char uc = *c; + ostringstream s; + s << "\\u"; + s.flags(ios_base::hex); + s.width(4); + s.fill('0'); + s << static_cast<unsigned>(uc); + out << s.str(); + break; + } + } + } + } + + out << "\""; + break; + } + case Builtin::KindByte: + { + int i = atoi(p->value().c_str()); + if(i > 127) + { + i -= 256; + } + out << i; // Slice byte runs from 0-255, Java byte runs from -128 - 127. + break; + } + case Builtin::KindLong: + { + out << p->value() << "L"; // Need to append "L" modifier for long constants. + break; + } case Builtin::KindBool: case Builtin::KindShort: case Builtin::KindInt: @@ -3052,11 +3052,11 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p) case Builtin::KindObject: case Builtin::KindObjectProxy: case Builtin::KindLocalObject: - { - out << p->value(); + { + out << p->value(); break; - } - } + } + } } else if(ep = EnumPtr::dynamicCast(type)) @@ -3067,11 +3067,11 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p) { val.erase(0, pos + 1); } - out << getAbsolute(ep, package) << '.' << fixKwd(val); + out << getAbsolute(ep, package) << '.' << fixKwd(val); } else { - out << p->value(); + out << p->value(); } out << ';' << eb; close(); @@ -3079,21 +3079,21 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p) bool Slice::Gen::TypesVisitor::validateGetterSetter(const OperationList& ops, const std::string& name, int numArgs, - const string& file, const string& line) + const string& file, const string& line) { for(OperationList::const_iterator i = ops.begin(); i != ops.end(); ++i) { - if((*i)->name() == name) - { - int numParams = static_cast<int>((*i)->parameters().size()); - if(numArgs >= numParams && numArgs - numParams <= 1) - { - cerr << file << ":" << line - << ": error: operation `" << name << "' conflicts with getter/setter method" << endl; - return false; - } - break; - } + if((*i)->name() == name) + { + int numParams = static_cast<int>((*i)->parameters().size()); + if(numArgs >= numParams && numArgs - numParams <= 1) + { + cerr << file << ":" << line + << ": error: operation `" << name << "' conflicts with getter/setter method" << endl; + return false; + } + break; + } } return true; } @@ -3181,37 +3181,37 @@ Slice::Gen::HolderVisitor::writeHolder(const TypePtr& p) out << sb; out << nl << "this.value = value;"; out << eb; - if(!p->isLocal()) - { - BuiltinPtr builtin = BuiltinPtr::dynamicCast(p); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(p)) - { - out << sp << nl << "public class Patcher implements IceInternal.Patcher"; + if(!p->isLocal()) + { + BuiltinPtr builtin = BuiltinPtr::dynamicCast(p); + if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(p)) + { + out << sp << nl << "public class Patcher implements IceInternal.Patcher"; if(_stream) { out << ", Ice.ReadObjectCallback"; } - out << sb; - out << nl << "public void"; - out << nl << "patch(Ice.Object v)"; - out << sb; - out << nl << "try"; - out << sb; - out << nl << "value = (" << typeS << ")v;"; - out << eb; - out << nl << "catch(ClassCastException ex)"; - out << sb; - out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();"; - out << nl << "_e.type = v.ice_id();"; - out << nl << "_e.expectedType = type();"; - out << nl << "throw _e;"; - out << eb; - out << eb; - - out << sp << nl << "public String" << nl << "type()"; - out << sb; - out << nl << "return \"" << p->typeId() << "\";"; - out << eb; + out << sb; + out << nl << "public void"; + out << nl << "patch(Ice.Object v)"; + out << sb; + out << nl << "try"; + out << sb; + out << nl << "value = (" << typeS << ")v;"; + out << eb; + out << nl << "catch(ClassCastException ex)"; + out << sb; + out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();"; + out << nl << "_e.type = v.ice_id();"; + out << nl << "_e.expectedType = type();"; + out << nl << "throw _e;"; + out << eb; + out << eb; + + out << sp << nl << "public String" << nl << "type()"; + out << sb; + out << nl << "return \"" << p->typeId() << "\";"; + out << eb; if(_stream) { @@ -3220,15 +3220,15 @@ Slice::Gen::HolderVisitor::writeHolder(const TypePtr& p) out << nl << "patch(v);"; out << eb; } - out << eb; - - out << sp << nl << "public Patcher"; - out << nl << "getPatcher()"; - out << sb; - out << nl << "return new Patcher();"; - out << eb; - } - } + out << eb; + + out << sp << nl << "public Patcher"; + out << nl << "getPatcher()"; + out << sb; + out << nl << "return new Patcher();"; + out << eb; + } + } out << sp << nl << "public " << typeS << " value;"; out << eb; close(); @@ -3285,8 +3285,8 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) for(r = ops.begin(); r != ops.end(); ++r) { OperationPtr op = *r; - ContainerPtr container = op->container(); - ClassDefPtr cl = ClassDefPtr::dynamicCast(container); + 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()); @@ -3311,51 +3311,51 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) { out << "return "; } - out << opName << spar << args << "null" << "false" << epar << ';'; + out << opName << spar << args << "null" << "false" << epar << ';'; out << eb; - out << sp; + out << sp; out << nl << "public " << retS << nl << opName << spar << params << contextParam << epar; writeThrowsClause(package, throws); out << sb; - out << nl; + out << nl; if(ret) { out << "return "; } - out << opName << spar << args << "__ctx" << "true" << epar << ';'; + out << opName << spar << args << "__ctx" << "true" << epar << ';'; out << eb; out << sp; - // - // TODO: If we eventually drop support for Java2, we can remove this - // SupressWarnings annotation. Meanwhile, it is necessary to prevent - // a compiler warning about an unchecked conversion. This is caused - // by the fact that _emptyContext returns the unchecked type - // java.util.Map but Ice.Context is mapped to Map<String, String>. - // - if(!java2) - { - out << nl << "@SuppressWarnings(\"unchecked\")"; - } + // + // TODO: If we eventually drop support for Java2, we can remove this + // SupressWarnings annotation. Meanwhile, it is necessary to prevent + // a compiler warning about an unchecked conversion. This is caused + // by the fact that _emptyContext returns the unchecked type + // java.util.Map but Ice.Context is mapped to Map<String, String>. + // + if(!java2) + { + out << nl << "@SuppressWarnings(\"unchecked\")"; + } out << nl << "private " << retS << nl << opName << spar << params << contextParam - << explicitContextParam << epar; + << explicitContextParam << epar; writeThrowsClause(package, throws); out << sb; - out << nl << "if(__explicitCtx && __ctx == null)"; - out << sb; - out << nl << "__ctx = _emptyContext;"; - out << eb; + out << nl << "if(__explicitCtx && __ctx == null)"; + out << sb; + out << nl << "__ctx = _emptyContext;"; + out << eb; out << nl << "int __cnt = 0;"; out << nl << "while(true)"; out << sb; out << nl << "Ice._ObjectDel __delBase = null;"; out << nl << "try"; out << sb; - if(op->returnsData()) - { - out << nl << "__checkTwowayOnly(\"" << opName << "\");"; - } + if(op->returnsData()) + { + out << nl << "__checkTwowayOnly(\"" << opName << "\");"; + } out << nl << "__delBase = __getDelegate();"; out << nl << '_' << name << "Del __del = (_" << name << "Del)__delBase;"; out << nl; @@ -3387,43 +3387,43 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) 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 << "__cb.__invoke" << spar << "this" << argsAMI << "null" << epar << ';'; - out << eb; - - out << sp; - // - // TODO: If we eventually drop support for Java2, we can remove this - // SupressWarnings annotation. Meanwhile, it is necessary to prevent - // a compiler warning about an unchecked conversion. This is caused - // by the fact that _emptyContext returns the unchecked type - // java.util.Map but Ice.Context is mapped to Map<String, String>. - // - if(!java2) - { - out << nl << "@SuppressWarnings(\"unchecked\")"; - } - out << nl << "public void" << nl << op->name() << "_async" << spar << paramsAMI - << contextParam << epar; - out << sb; - out << nl << "if( __ctx == null)"; - out << sb; - out << nl << "__ctx = _emptyContext;"; - out << eb; - out << nl << "__cb.__invoke" << spar << "this" << argsAMI << "__ctx" << epar << ';'; - 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 << "__cb.__invoke" << spar << "this" << argsAMI << "null" << epar << ';'; + out << eb; + + out << sp; + // + // TODO: If we eventually drop support for Java2, we can remove this + // SupressWarnings annotation. Meanwhile, it is necessary to prevent + // a compiler warning about an unchecked conversion. This is caused + // by the fact that _emptyContext returns the unchecked type + // java.util.Map but Ice.Context is mapped to Map<String, String>. + // + if(!java2) + { + out << nl << "@SuppressWarnings(\"unchecked\")"; + } + out << nl << "public void" << nl << op->name() << "_async" << spar << paramsAMI + << contextParam << epar; + out << sb; + out << nl << "if( __ctx == null)"; + out << sb; + out << nl << "__ctx = _emptyContext;"; + out << eb; + out << nl << "__cb.__invoke" << spar << "this" << argsAMI << "__ctx" << epar << ';'; + out << eb; + } } out << sp << nl << "public static " << name << "Prx" << nl << "checkedCast(Ice.ObjectPrx __obj)"; @@ -3449,7 +3449,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) out << eb; out << sp << nl << "public static " << name << "Prx" << nl << "checkedCast(Ice.ObjectPrx __obj, " << contextParam - << ')'; + << ')'; out << sb; out << nl << name << "Prx __d = null;"; out << nl << "if(__obj != null)"; @@ -3695,7 +3695,7 @@ Slice::Gen::HelperVisitor::visitSequence(const SequencePtr& p) out << sb; out << nl << typeS << " __v;"; iter = 0; - writeSequenceMarshalUnmarshalCode(out, package, p, "__v", false, iter, false); + writeSequenceMarshalUnmarshalCode(out, package, p, "__v", false, iter, false); out << nl << "return __v;"; out << eb; @@ -3746,42 +3746,42 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) if(open(helper)) { Output& out = output(); - int iter; + int iter; out << sp << nl << "public final class " << name << "Helper"; out << sb; out << nl << "public static void" << nl << "write(IceInternal.BasicStream __os, " << abstractType << " __v)"; out << sb; - iter = 0; + iter = 0; writeDictionaryMarshalUnmarshalCode(out, package, p, "__v", true, iter, false); - out << eb; + out << eb; - out << sp << nl << "public static " << abstractType - << nl << "read(IceInternal.BasicStream __is)"; - out << sb; - out << nl << abstractType << " __v = new " << concreteType << "();"; - iter = 0; - writeDictionaryMarshalUnmarshalCode(out, package, p, "__v", false, iter, false); - out << nl << "return __v;"; - out << eb; + out << sp << nl << "public static " << abstractType + << nl << "read(IceInternal.BasicStream __is)"; + out << sb; + out << nl << abstractType << " __v = new " << concreteType << "();"; + iter = 0; + writeDictionaryMarshalUnmarshalCode(out, package, p, "__v", false, iter, false); + out << nl << "return __v;"; + out << eb; if(_stream) { out << sp << nl << "public static void" << nl << "write(Ice.OutputStream __outS, " << abstractType - << " __v)"; + << " __v)"; out << sb; - iter = 0; - writeStreamDictionaryMarshalUnmarshalCode(out, package, p, "__v", true, iter, false); + iter = 0; + writeStreamDictionaryMarshalUnmarshalCode(out, package, p, "__v", true, iter, false); out << eb; - out << sp << nl << "public static " << abstractType + out << sp << nl << "public static " << abstractType << nl << "read(Ice.InputStream __inS)"; out << sb; - out << nl << abstractType << " __v = new " << concreteType << "();"; - iter = 0; - writeStreamDictionaryMarshalUnmarshalCode(out, package, p, "__v", false, iter, false); - out << nl << "return __v;"; + out << nl << abstractType << " __v = new " << concreteType << "();"; + iter = 0; + writeStreamDictionaryMarshalUnmarshalCode(out, package, p, "__v", false, iter, false); + out << nl << "return __v;"; out << eb; } @@ -3910,18 +3910,18 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) out << sp; if(!deprecateReason.empty()) { - out << nl << "/**"; - out << nl << " * @deprecated " << deprecateReason; - out << nl << " **/"; + out << nl << "/**"; + out << nl << " * @deprecated " << deprecateReason; + out << nl << " **/"; } out << nl << "public " << retS << ' ' << name << spar << params << epar; writeThrowsClause(package, throws); out << ';'; if(!deprecateReason.empty()) { - out << nl << "/**"; - out << nl << " * @deprecated " << deprecateReason; - out << nl << " **/"; + out << nl << "/**"; + out << nl << " * @deprecated " << deprecateReason; + out << nl << " **/"; } bool java2 = p->definitionContext()->findMetaData("java:java2") == "java:java2"; @@ -3933,27 +3933,27 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) 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; - if(!deprecateReason.empty()) - { - out << nl << "/**"; - out << nl << " * @deprecated " << deprecateReason; - out << nl << " **/"; - } - out << nl << "public void " << p->name() << "_async" << spar << paramsAMI << epar << ';'; - if(!deprecateReason.empty()) - { - out << nl << "/**"; - out << nl << " * @deprecated " << deprecateReason; - out << nl << " **/"; - } - out << nl << "public void " << p->name() << "_async" << spar << paramsAMI << contextParam << epar << ';'; + vector<string> paramsAMI = getParamsAsync(p, package, false); + + // + // Write two versions of the operation - with and without a + // context parameter. + // + out << sp; + if(!deprecateReason.empty()) + { + out << nl << "/**"; + out << nl << " * @deprecated " << deprecateReason; + out << nl << " **/"; + } + out << nl << "public void " << p->name() << "_async" << spar << paramsAMI << epar << ';'; + if(!deprecateReason.empty()) + { + out << nl << "/**"; + out << nl << " * @deprecated " << deprecateReason; + out << nl << " **/"; + } + out << nl << "public void " << p->name() << "_async" << spar << paramsAMI << contextParam << epar << ';'; } } @@ -4080,34 +4080,34 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) ParamDeclList inParams; ParamDeclList outParams; - ParamDeclList paramList = op->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); - } - } + ParamDeclList paramList = op->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 = 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 vector<string> params = getParams(op, package); @@ -4118,50 +4118,50 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) out << sb; out << nl << "IceInternal.Outgoing __og = __connection.getOutgoing(__reference, \"" << op->name() << "\", " - << sliceModeToIceMode(op->sendMode()) << ", __ctx, __compress);"; + << sliceModeToIceMode(op->sendMode()) << ", __ctx, __compress);"; out << nl << "try"; out << sb; if(!inParams.empty()) { - out << nl << "try"; - out << sb; + out << nl << "try"; + out << sb; out << nl << "IceInternal.BasicStream __os = __og.os();"; - for(pli = inParams.begin(); pli != inParams.end(); ++pli) - { - writeMarshalUnmarshalCode(out, package, (*pli)->type(), fixKwd((*pli)->name()), true, iter, false, - (*pli)->getMetaData()); - } - if(op->sendsClasses()) - { - out << nl << "__os.writePendingObjects();"; - } - out << eb; - out << nl << "catch(Ice.LocalException __ex)"; - out << sb; - out << nl << "__og.abort(__ex);"; - out << eb; - } - out << nl << "boolean __ok = __og.invoke();"; - out << nl << "try"; - out << sb; - out << nl << "IceInternal.BasicStream __is = __og.is();"; + for(pli = inParams.begin(); pli != inParams.end(); ++pli) + { + writeMarshalUnmarshalCode(out, package, (*pli)->type(), fixKwd((*pli)->name()), true, iter, false, + (*pli)->getMetaData()); + } + if(op->sendsClasses()) + { + out << nl << "__os.writePendingObjects();"; + } + out << eb; + out << nl << "catch(Ice.LocalException __ex)"; + out << sb; + out << nl << "__og.abort(__ex);"; + out << eb; + } + out << nl << "boolean __ok = __og.invoke();"; + out << nl << "try"; + out << sb; + out << nl << "IceInternal.BasicStream __is = __og.is();"; out << nl << "if(!__ok)"; out << sb; out << nl << "try"; out << sb; - out << nl << "__is.throwException();"; + out << nl << "__is.throwException();"; out << eb; - for(ExceptionList::const_iterator t = throws.begin(); t != throws.end(); ++t) - { - out << nl << "catch(" << getAbsolute(*t, package) << " __ex)"; - out << sb; - out << nl << "throw __ex;"; - out << eb; - } - out << nl << "catch(Ice.UserException __ex)"; - out << sb; + for(ExceptionList::const_iterator t = throws.begin(); t != throws.end(); ++t) + { + out << nl << "catch(" << getAbsolute(*t, package) << " __ex)"; + out << sb; + out << nl << "throw __ex;"; + out << eb; + } + out << nl << "catch(Ice.UserException __ex)"; + out << sb; out << nl << "throw new Ice.UnknownUserException(__ex.ice_name());"; - out << eb; + out << eb; out << eb; for(pli = outParams.begin(); pli != outParams.end(); ++pli) { @@ -4170,39 +4170,39 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) } if(ret) { - BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret)) - { - out << nl << retS << "Holder __ret = new " << retS << "Holder();"; - out << nl << "__is.readObject(__ret.getPatcher());"; - } - else - { - out << nl << retS << " __ret;"; - writeMarshalUnmarshalCode(out, package, ret, "__ret", false, iter, false, opMetaData); - } - } - if(op->returnsClasses()) - { - out << nl << "__is.readPendingObjects();"; - } - if(ret) - { - BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret)) - { - out << nl << "return __ret.value;"; - } - else - { - out << nl << "return __ret;"; - } - } - out << eb; - out << nl << "catch(Ice.LocalException __ex)"; - out << sb; - out << nl << "throw new IceInternal.LocalExceptionWrapper(__ex, false);"; - out << eb; + BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret); + if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret)) + { + out << nl << retS << "Holder __ret = new " << retS << "Holder();"; + out << nl << "__is.readObject(__ret.getPatcher());"; + } + else + { + out << nl << retS << " __ret;"; + writeMarshalUnmarshalCode(out, package, ret, "__ret", false, iter, false, opMetaData); + } + } + if(op->returnsClasses()) + { + out << nl << "__is.readPendingObjects();"; + } + if(ret) + { + BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret); + if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret)) + { + out << nl << "return __ret.value;"; + } + else + { + out << nl << "return __ret;"; + } + } + out << eb; + out << nl << "catch(Ice.LocalException __ex)"; + out << sb; + out << nl << "throw new IceInternal.LocalExceptionWrapper(__ex, false);"; + out << eb; out << eb; out << nl << "finally"; out << sb; @@ -4254,8 +4254,8 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) for(r = ops.begin(); r != ops.end(); ++r) { OperationPtr op = *r; - ContainerPtr container = op->container(); - ClassDefPtr cl = ClassDefPtr::dynamicCast(container); + 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()); @@ -4267,63 +4267,63 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) vector<string> params = getParams(op, package); vector<string> args = getArgs(op); - out << sp; + out << sp; out << nl << "public " << retS << nl << opName << spar << params << contextParam << 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->sendMode()) - << ", __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; + 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->sendMode()) + << ", __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; - if(ret) - { - out << "return "; - } - out << "__servant." << opName << spar << args << "__current" << epar << ';'; - if(!ret) - { - out << nl << "return;"; - } + 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.LocalExceptionWrapper(__ex, false);"; - out << eb; - out << eb; - out << nl << "finally"; - out << sb; - out << nl << "__direct.destroy();"; - out << eb; - out << eb; - } + out << eb; + out << eb; + out << nl << "finally"; + out << sb; + out << nl << "__direct.destroy();"; + out << eb; + out << eb; + } out << eb; } @@ -4523,25 +4523,25 @@ Slice::Gen::BaseImplVisitor::writeOperation(Output& out, const string& package, if(!local && (cl->hasMetaData("amd") || op->hasMetaData("amd"))) { - vector<string> paramsAMD = getParamsAsync(op, package, true); + vector<string> paramsAMD = getParamsAsync(op, package, true); out << sp << nl << "public void" << nl << opName << "_async" << spar << paramsAMD << "Ice.Current __current" - << epar; + << 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. - // + // + // 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 writeThrowsClause(package, throws); @@ -4717,15 +4717,15 @@ Slice::Gen::ImplTieVisitor::visitClassDefStart(const ClassDefPtr& p) out << sp << nl << "public class " << name << 'I'; if(inheritImpl) { - out << " extends "; + out << " extends "; if(bases.front()->isAbstract()) - { - out << bases.front()->name() << 'I'; - } - else - { - out << fixKwd(bases.front()->name()); - } + { + out << bases.front()->name() << 'I'; + } + else + { + out << fixKwd(bases.front()->name()); + } } out << " implements " << '_' << name << "Operations"; if(p->isLocal()) @@ -4786,7 +4786,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) if(cl->isLocal()) { - return; + return; } string name = p->name(); @@ -4795,148 +4795,148 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) if(cl->hasMetaData("ami") || p->hasMetaData("ami")) { - string classNameAMI = "AMI_" + cl->name(); - string absoluteAMI = getAbsolute(cl, "", "AMI_", "_" + name); + string classNameAMI = "AMI_" + cl->name(); + string absoluteAMI = getAbsolute(cl, "", "AMI_", "_" + name); - if(!open(absoluteAMI)) - { - return; - } - - Output& out = output(); + if(!open(absoluteAMI)) + { + return; + } + + Output& out = output(); TypePtr ret = p->returnType(); - ParamDeclList inParams; + 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); - } - } + 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. - // + // + // 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; - 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);"; - } - - bool java2 = p->definitionContext()->findMetaData("java:java2") == "java:java2"; - string contextParam = java2 ? "java.util.Map __ctx" : "java.util.Map<String, String> __ctx"; - - out << sp << nl << "public final void" << nl << "__invoke" << spar << "Ice.ObjectPrx __prx" - << paramsInvoke << contextParam << epar; - out << sb; - out << nl << "try"; - out << sb; - out << nl << "__prepare(__prx, \"" << p->name() << "\", " - << sliceModeToIceMode(p->sendMode()) << ", __ctx);"; + 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);"; + } + + bool java2 = p->definitionContext()->findMetaData("java:java2") == "java:java2"; + string contextParam = java2 ? "java.util.Map __ctx" : "java.util.Map<String, String> __ctx"; + + out << sp << nl << "public final void" << nl << "__invoke" << spar << "Ice.ObjectPrx __prx" + << paramsInvoke << contextParam << epar; + out << sb; + out << nl << "try"; + out << sb; + out << nl << "__prepare(__prx, \"" << p->name() << "\", " + << sliceModeToIceMode(p->sendMode()) << ", __ctx);"; iter = 0; - for(pli = inParams.begin(); pli != inParams.end(); ++pli) - { + 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, + 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; + } + 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 << ';'; - } + 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)"; + 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 << "ice_exception(__ex);"; + out << nl << "return;"; + out << eb; + } + out << nl << "catch(Ice.UserException __ex)"; 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 << "ice_exception(__ex);"; - out << nl << "return;"; - out << eb; - } - out << nl << "catch(Ice.UserException __ex)"; - out << sb; out << nl << "throw new Ice.UnknownUserException(__ex.ice_name());"; out << eb; out << eb; @@ -4944,186 +4944,186 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) { 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, + 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; - out << nl << "ice_response" << spar << args << epar << ';'; - out << eb; - out << eb; - - close(); + 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; + 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. - // + 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); + throws.sort(Slice::derivedToBaseCompare); #else - throws.sort(Slice::DerivedToBaseCompare()); + throws.sort(Slice::DerivedToBaseCompare()); #endif - int iter; + int iter; - out << sp << nl << "final class " << classNameAMDI << '_' << name - << " extends IceInternal.IncomingAsync implements " << classNameAMD << '_' << name; - out << sb; + 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" << 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; + 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) - { + 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, + 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(); - } + } + 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/slice2java/Gen.h b/cpp/src/slice2java/Gen.h index 07cfd847a4c..8326dd115e3 100644 --- a/cpp/src/slice2java/Gen.h +++ b/cpp/src/slice2java/Gen.h @@ -98,7 +98,7 @@ private: virtual bool visitClassDefStart(const ClassDefPtr&); private: - void writeOperations(const ClassDefPtr&, bool); + void writeOperations(const ClassDefPtr&, bool); }; class TieVisitor : public JavaVisitor @@ -137,11 +137,11 @@ private: private: - // - // Verifies that a getter/setter method does not conflict with an operation. - // - bool validateGetterSetter(const OperationList&, const std::string&, int, const std::string&, - const std::string&); + // + // Verifies that a getter/setter method does not conflict with an operation. + // + bool validateGetterSetter(const OperationList&, const std::string&, int, const std::string&, + const std::string&); bool _stream; }; diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp index b2014f0e247..6daeac74c03 100644 --- a/cpp/src/slice2java/Main.cpp +++ b/cpp/src/slice2java/Main.cpp @@ -30,12 +30,12 @@ usage(const char* n) "-DNAME=DEF Define NAME as DEF.\n" "-UNAME Remove any definition for NAME.\n" "-IDIR Put DIR in the include file search path.\n" - "-E Print preprocessor output on stdout.\n" + "-E Print preprocessor output on stdout.\n" "--output-dir DIR Create files in the directory DIR.\n" "--tie Generate TIE classes.\n" "--impl Generate sample implementations.\n" "--impl-tie Generate sample TIE implementations.\n" - "--depend Generate Makefile dependencies.\n" + "--depend Generate Makefile dependencies.\n" "-d, --debug Print debug messages.\n" "--ice Permit `Ice' prefix (for building Ice source code only)\n" "--checksum CLASS Generate checksums for Slice definitions into CLASS.\n" @@ -75,20 +75,20 @@ main(int argc, char* argv[]) catch(const IceUtil::BadOptException& e) { cerr << argv[0] << ": " << e.reason << endl; - usage(argv[0]); - return EXIT_FAILURE; + usage(argv[0]); + return EXIT_FAILURE; } if(opts.isSet("help")) { - usage(argv[0]); - return EXIT_SUCCESS; + usage(argv[0]); + return EXIT_SUCCESS; } if(opts.isSet("version")) { - cout << ICE_STRING_VERSION << endl; - return EXIT_SUCCESS; + cout << ICE_STRING_VERSION << endl; + return EXIT_SUCCESS; } string cppArgs; @@ -96,19 +96,19 @@ main(int argc, char* argv[]) vector<string>::const_iterator i; for(i = optargs.begin(); i != optargs.end(); ++i) { - cppArgs += " -D" + Preprocessor::addQuotes(*i); + cppArgs += " -D" + Preprocessor::addQuotes(*i); } optargs = opts.argVec("U"); for(i = optargs.begin(); i != optargs.end(); ++i) { - cppArgs += " -U" + Preprocessor::addQuotes(*i); + cppArgs += " -U" + Preprocessor::addQuotes(*i); } vector<string> includePaths = opts.argVec("I"); for(i = includePaths.begin(); i != includePaths.end(); ++i) { - cppArgs += " -I" + Preprocessor::addQuotes(*i); + cppArgs += " -I" + Preprocessor::addQuotes(*i); } bool preprocess = opts.isSet("E"); @@ -157,101 +157,101 @@ main(int argc, char* argv[]) for(i = args.begin(); i != args.end(); ++i) { - if(depend) - { - Preprocessor icecpp(argv[0], *i, cppArgs); - icecpp.printMakefileDependencies(Preprocessor::Java); - } - else - { - Preprocessor icecpp(argv[0], *i, cppArgs); - FILE* cppHandle = icecpp.preprocess(false); - - if(cppHandle == 0) - { - return EXIT_FAILURE; - } - - if(preprocess) - { - char buf[4096]; - while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL) - { - if(fputs(buf, stdout) == EOF) - { - return EXIT_FAILURE; - } - } - if(!icecpp.close()) - { - return EXIT_FAILURE; - } - } - else - { - UnitPtr p = Unit::createUnit(false, false, ice, caseSensitive, globalMetadata); - int parseStatus = p->parse(cppHandle, debug, Ice); - - if(!icecpp.close()) - { - p->destroy(); - return EXIT_FAILURE; - } - - if(parseStatus == EXIT_FAILURE) - { - status = EXIT_FAILURE; - } - else - { - Gen gen(argv[0], icecpp.getBaseName(), includePaths, output); - if(!gen) - { - p->destroy(); - return EXIT_FAILURE; - } - gen.generate(p, stream); - if(tie) - { - gen.generateTie(p); - } - if(impl) - { - gen.generateImpl(p); - } - if(implTie) - { - gen.generateImplTie(p); - } - if(!checksumClass.empty()) - { - // - // Calculate checksums for the Slice definitions in the unit. - // - ChecksumMap m = createChecksums(p); - copy(m.begin(), m.end(), inserter(checksums, checksums.begin())); - } - } - p->destroy(); - } - } + if(depend) + { + Preprocessor icecpp(argv[0], *i, cppArgs); + icecpp.printMakefileDependencies(Preprocessor::Java); + } + else + { + Preprocessor icecpp(argv[0], *i, cppArgs); + FILE* cppHandle = icecpp.preprocess(false); + + if(cppHandle == 0) + { + return EXIT_FAILURE; + } + + if(preprocess) + { + char buf[4096]; + while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL) + { + if(fputs(buf, stdout) == EOF) + { + return EXIT_FAILURE; + } + } + if(!icecpp.close()) + { + return EXIT_FAILURE; + } + } + else + { + UnitPtr p = Unit::createUnit(false, false, ice, caseSensitive, globalMetadata); + int parseStatus = p->parse(cppHandle, debug, Ice); + + if(!icecpp.close()) + { + p->destroy(); + return EXIT_FAILURE; + } + + if(parseStatus == EXIT_FAILURE) + { + status = EXIT_FAILURE; + } + else + { + Gen gen(argv[0], icecpp.getBaseName(), includePaths, output); + if(!gen) + { + p->destroy(); + return EXIT_FAILURE; + } + gen.generate(p, stream); + if(tie) + { + gen.generateTie(p); + } + if(impl) + { + gen.generateImpl(p); + } + if(implTie) + { + gen.generateImplTie(p); + } + if(!checksumClass.empty()) + { + // + // Calculate checksums for the Slice definitions in the unit. + // + ChecksumMap m = createChecksums(p); + copy(m.begin(), m.end(), inserter(checksums, checksums.begin())); + } + } + p->destroy(); + } + } } if(!checksumClass.empty()) { - // - // Look for the Java2 metadata. - // - bool java2 = false; - for(StringList::iterator p = globalMetadata.begin(); p != globalMetadata.end(); ++p) - { - if((*p) == "java:java2") - { - java2 = true; - break; - } - } - Gen::writeChecksumClass(checksumClass, output, checksums, java2); + // + // Look for the Java2 metadata. + // + bool java2 = false; + for(StringList::iterator p = globalMetadata.begin(); p != globalMetadata.end(); ++p) + { + if((*p) == "java:java2") + { + java2 = true; + break; + } + } + Gen::writeChecksumClass(checksumClass, output, checksums, java2); } return status; |