From 978edf9b6b427042380c51697adaffd46c247390 Mon Sep 17 00:00:00 2001 From: Mark Spruiell Date: Fri, 20 Jul 2012 12:43:35 -0700 Subject: adding more Java optional tests --- cpp/src/slice2java/Gen.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'cpp/src/slice2java/Gen.cpp') diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index ce6aaff3cbb..ee4f01688d3 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -353,19 +353,20 @@ Slice::JavaVisitor::writeMarshalUnmarshalParams(Output& out, const string& packa { if(checkReturnType && op->returnTag() < (*pli)->tag()) { - writeMarshalUnmarshalCode(out, package, ret, OptionalParam, op->returnTag(), "__ret", marshal, iter, false, - op->getMetaData()); + writeMarshalUnmarshalCode(out, package, ret, OptionalReturnParam, op->returnTag(), "__ret", marshal, iter, + false, op->getMetaData()); checkReturnType = false; } - writeMarshalUnmarshalCode(out, package, (*pli)->type(), OptionalParam, (*pli)->tag(), + writeMarshalUnmarshalCode(out, package, (*pli)->type(), + (*pli)->isOutParam() ? OptionalOutParam : OptionalInParam, (*pli)->tag(), fixKwd((*pli)->name()), marshal, iter, false, (*pli)->getMetaData()); } if(checkReturnType) { - writeMarshalUnmarshalCode(out, package, ret, OptionalParam, op->returnTag(), "__ret", marshal, iter, false, - op->getMetaData()); + writeMarshalUnmarshalCode(out, package, ret, OptionalReturnParam, op->returnTag(), "__ret", marshal, iter, + false, op->getMetaData()); } } -- cgit v1.2.3 From 038a4b832342ccf710d7d57bad1d10c7b36af022 Mon Sep 17 00:00:00 2001 From: Mark Spruiell Date: Fri, 27 Jul 2012 16:04:43 -0700 Subject: updating Java API --- cpp/include/Slice/JavaUtil.h | 11 +- cpp/src/Slice/JavaUtil.cpp | 167 ++++++++++-- cpp/src/slice2java/Gen.cpp | 89 +++++-- cpp/src/slice2java/Gen.h | 5 +- java/src/Ice/BooleanOptional.java | 106 ++++++++ java/src/Ice/ByteOptional.java | 106 ++++++++ java/src/Ice/DoubleOptional.java | 106 ++++++++ java/src/Ice/FloatOptional.java | 106 ++++++++ java/src/Ice/IntOptional.java | 106 ++++++++ java/src/Ice/LongOptional.java | 106 ++++++++ java/src/Ice/ShortOptional.java | 106 ++++++++ java/src/IceInternal/BasicStream.java | 277 +++++++++++++++----- java/test/Ice/optional/AllTests.java | 481 ++++++++++++++++++++++++++-------- java/test/Ice/optional/InitialI.java | 244 +++++++++++++++-- java/test/Ice/optional/Test.ice | 83 ++++-- 15 files changed, 1839 insertions(+), 260 deletions(-) create mode 100644 java/src/Ice/BooleanOptional.java create mode 100644 java/src/Ice/ByteOptional.java create mode 100644 java/src/Ice/DoubleOptional.java create mode 100644 java/src/Ice/FloatOptional.java create mode 100644 java/src/Ice/IntOptional.java create mode 100644 java/src/Ice/LongOptional.java create mode 100644 java/src/Ice/ShortOptional.java (limited to 'cpp/src/slice2java/Gen.cpp') diff --git a/cpp/include/Slice/JavaUtil.h b/cpp/include/Slice/JavaUtil.h index a3cba96e6c6..7fc742b2ac3 100644 --- a/cpp/include/Slice/JavaUtil.h +++ b/cpp/include/Slice/JavaUtil.h @@ -117,6 +117,11 @@ protected: // std::string getStaticId(const TypePtr&, const std::string&) const; + // + // Determines whether an in parameter should use the optional mapping. + // + bool useOptionalMapping(const ParamDeclPtr&); + // // Returns the optional type corresponding to the given Slice type. // @@ -150,7 +155,8 @@ protected: enum OptionalMode { OptionalNone, - OptionalInParam, + OptionalInParamReq, // Use the required mapping. + OptionalInParamOpt, // Use the optional mapping. OptionalOutParam, OptionalReturnParam, OptionalMember @@ -158,7 +164,8 @@ protected: bool isOptionalParam(OptionalMode mode) const { - return mode == OptionalInParam || mode == OptionalOutParam || mode == OptionalReturnParam; + return mode == OptionalInParamReq || mode == OptionalInParamOpt || mode == OptionalOutParam || + mode == OptionalReturnParam; } void writeMarshalUnmarshalCode(::IceUtilInternal::Output&, const std::string&, const TypePtr&, OptionalMode, int, diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index 9af4e993894..a1dabf6d6dc 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -550,6 +550,36 @@ Slice::JavaGenerator::getStaticId(const TypePtr& type, const string& package) co } } +bool +Slice::JavaGenerator::useOptionalMapping(const ParamDeclPtr& p) +{ + if(p->optional()) + { + // + // Optional in parameters can be marked with the "java:optional" metadata to force + // the mapping to use the Ice.Optional types. The tag can also be applied to an + // operation or its interface. + // + // Without the tag, in parameters use the normal (non-optional) mapping. + // + if(!p->isOutParam()) + { + static const string tag = "java:optional"; + + OperationPtr op = OperationPtr::dynamicCast(p->container()); + assert(op); + ClassDefPtr cl = ClassDefPtr::dynamicCast(op->container()); + assert(cl); + + return p->hasMetaData(tag) || op->hasMetaData(tag) || cl->hasMetaData(tag); + } + + return true; + } + + return false; +} + string Slice::JavaGenerator::getOptionalType(const TypePtr& type) { @@ -667,6 +697,20 @@ Slice::JavaGenerator::typeToString(const TypePtr& type, "Ice.ObjectPrxHolder", "Ice.LocalObjectHolder" }; + static const char* builtinOptionalTable[] = + { + "Ice.ByteOptional", + "Ice.BooleanOptional", + "Ice.ShortOptional", + "Ice.IntOptional", + "Ice.LongOptional", + "Ice.FloatOptional", + "Ice.DoubleOptional", + "???", + "???", + "???", + "???" + }; if(!type) { @@ -679,7 +723,26 @@ Slice::JavaGenerator::typeToString(const TypePtr& type, { if(optional) { - return "Ice.Optional<" + typeToObjectString(builtin, TypeModeIn, package, metaData, formal) + ">"; + switch(builtin->kind()) + { + case Builtin::KindByte: + case Builtin::KindBool: + case Builtin::KindShort: + case Builtin::KindInt: + case Builtin::KindLong: + case Builtin::KindFloat: + case Builtin::KindDouble: + { + return builtinOptionalTable[builtin->kind()]; + } + case Builtin::KindString: + case Builtin::KindObject: + case Builtin::KindObjectProxy: + case Builtin::KindLocalObject: + { + break; + } + } } else { @@ -1184,13 +1247,25 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(isOptionalParam(optional)) { - out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" << tag - << ", " << getOptionalType(type) << "))"; - out << sb; - out << nl << stream << ".startSize();"; - out << nl << typeS << "Helper.__write(" << stream << ", " << v << ".get());"; - out << nl << stream << ".endSize();"; - out << eb; + if(optional == OptionalInParamReq) + { + out << nl << "if(" << stream << ".writeOpt(" << tag << ", " << getOptionalType(type) << "))"; + out << sb; + out << nl << stream << ".startSize();"; + out << nl << typeS << "Helper.__write(" << stream << ", " << v << ");"; + out << nl << stream << ".endSize();"; + out << eb; + } + else + { + out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" << tag + << ", " << getOptionalType(type) << "))"; + out << sb; + out << nl << stream << ".startSize();"; + out << nl << typeS << "Helper.__write(" << stream << ", " << v << ".get());"; + out << nl << stream << ".endSize();"; + out << eb; + } } else if(optional == OptionalMember) { @@ -1298,10 +1373,19 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, if(isOptionalParam(optional)) { - out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" << tag - << ", " << getOptionalType(type) << "))"; + if(optional == OptionalInParamReq) + { + out << nl << "if(" << stream << ".writeOpt(" << tag << ", " << getOptionalType(type) << "))"; + val = v; + } + else + { + out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" + << tag << ", " << getOptionalType(type) << "))"; + val = v + ".get()"; + } + out << sb; - val = v + ".get()"; } else { @@ -1391,11 +1475,21 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(isOptionalParam(optional)) { - out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" << tag - << ", " << getOptionalType(type) << "))"; - out << sb; - out << nl << v << ".get().__write(" << stream << ");"; - out << eb; + if(optional == OptionalInParamReq) + { + out << nl << "if(" << stream << ".writeOpt(" << tag << ", " << getOptionalType(type) << "))"; + out << sb; + out << nl << v << ".__write(" << stream << ");"; + out << eb; + } + else + { + out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" << tag + << ", " << getOptionalType(type) << "))"; + out << sb; + out << nl << v << ".get().__write(" << stream << ");"; + out << eb; + } } else { @@ -1441,14 +1535,22 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(isOptionalParam(optional)) { - out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" << tag - << ", " << getOptionalType(type) << "))"; - out << sb; + if(optional == OptionalInParamReq) + { + out << nl << "if(" << stream << ".writeOpt(" << tag << ", " << getOptionalType(type) << "))"; + out << sb; + } + else + { + out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" + << tag << ", " << getOptionalType(type) << "))"; + out << sb; + } } if(keyType->isVariableLength() || valueType->isVariableLength()) { - string d = isOptionalParam(optional) ? v + ".get()" : v; + string d = isOptionalParam(optional) && optional != OptionalInParamReq ? v + ".get()" : v; out << nl << stream << ".startSize();"; writeDictionaryMarshalUnmarshalCode(out, package, dict, d, marshal, iter, true, metaData); out << nl << stream << ".endSize();"; @@ -1457,7 +1559,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { const int wireSize = keyType->minWireSize() + valueType->minWireSize(); string tmpName; - if(isOptionalParam(optional)) + if(isOptionalParam(optional) && optional != OptionalInParamReq) { tmpName = "__optDict"; out << nl << "final " << typeS << ' ' << tmpName << " = " << v << ".get();"; @@ -1548,6 +1650,9 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, "Float", "Double", "String", + "???", + "???", + "???" }; switch(elemBuiltin->kind()) @@ -1589,14 +1694,22 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(isOptionalParam(optional)) { - out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" << tag - << ", " << getOptionalType(type) << "))"; + if(optional == OptionalInParamReq) + { + out << nl << "if(" << stream << ".writeOpt(" << tag << ", " << getOptionalType(type) << "))"; + } + else + { + out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" + << tag << ", " << getOptionalType(type) << "))"; + } + out << sb; } if(elemType->isVariableLength()) { - string s = isOptionalParam(optional) ? v + ".get()" : v; + string s = isOptionalParam(optional) && optional != OptionalInParamReq ? v + ".get()" : v; out << nl << stream << ".startSize();"; writeSequenceMarshalUnmarshalCode(out, package, seq, s, marshal, iter, true, metaData); out << nl << stream << ".endSize();"; @@ -1610,7 +1723,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, // string tmpName; - if(isOptionalParam(optional)) + if(isOptionalParam(optional) && optional != OptionalInParamReq) { tmpName = "__optSeq"; out << nl << "final " << typeS << ' ' << tmpName << " = " << v << ".get();"; @@ -1647,7 +1760,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, // // This just writes a byte sequence. // - string s = isOptionalParam(optional) ? v + ".get()" : v; + string s = isOptionalParam(optional) && optional != OptionalInParamReq ? v + ".get()" : v; writeSequenceMarshalUnmarshalCode(out, package, seq, s, marshal, iter, true, metaData); } else @@ -1657,7 +1770,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, // string tmpName; - if(isOptionalParam(optional)) + if(isOptionalParam(optional) && optional != OptionalInParamReq) { tmpName = "__optSeq"; out << nl << "final " << typeS << ' ' << tmpName << " = " << v << ".get();"; diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index ee4f01688d3..37879c13ca7 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -109,7 +109,7 @@ Slice::JavaVisitor::~JavaVisitor() } vector -Slice::JavaVisitor::getParams(const OperationPtr& op, const string& package, bool final) +Slice::JavaVisitor::getParams(const OperationPtr& op, const string& package) { vector params; @@ -119,6 +119,23 @@ Slice::JavaVisitor::getParams(const OperationPtr& op, const string& package, boo StringList metaData = (*q)->getMetaData(); string typeString = typeToString((*q)->type(), (*q)->isOutParam() ? TypeModeOut : TypeModeIn, package, metaData, true, (*q)->optional()); + params.push_back(typeString + ' ' + fixKwd((*q)->name())); + } + + return params; +} + +vector +Slice::JavaVisitor::getParamsProxy(const OperationPtr& op, const string& package, bool final) +{ + vector params; + + ParamDeclList paramList = op->parameters(); + 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, + metaData, true, useOptionalMapping(*q)); if(final) { typeString = "final " + typeString; @@ -130,7 +147,7 @@ Slice::JavaVisitor::getParams(const OperationPtr& op, const string& package, boo } vector -Slice::JavaVisitor::getInOutParams(const OperationPtr& op, const string& package, ParamDir paramType) +Slice::JavaVisitor::getInOutParams(const OperationPtr& op, const string& package, ParamDir paramType, bool proxy) { vector params; @@ -139,9 +156,14 @@ Slice::JavaVisitor::getInOutParams(const OperationPtr& op, const string& package { if((*q)->isOutParam() == (paramType == OutParam)) { + bool optional = (*q)->optional(); + if(optional && proxy) + { + optional = useOptionalMapping(*q); + } StringList metaData = (*q)->getMetaData(); string typeString = typeToString((*q)->type(), paramType == InParam ? TypeModeIn : TypeModeOut, package, - metaData, true, (*q)->optional()); + metaData, true, optional); params.push_back(typeString + ' ' + fixKwd((*q)->name())); } } @@ -152,7 +174,7 @@ Slice::JavaVisitor::getInOutParams(const OperationPtr& op, const string& package vector Slice::JavaVisitor::getParamsAsync(const OperationPtr& op, const string& package, bool amd) { - vector params = getInOutParams(op, package, InParam); + vector params = getInOutParams(op, package, InParam, !amd); string name = op->name(); ContainerPtr container = op->container(); @@ -358,9 +380,18 @@ Slice::JavaVisitor::writeMarshalUnmarshalParams(Output& out, const string& packa checkReturnType = false; } - writeMarshalUnmarshalCode(out, package, (*pli)->type(), - (*pli)->isOutParam() ? OptionalOutParam : OptionalInParam, (*pli)->tag(), - fixKwd((*pli)->name()), marshal, iter, false, (*pli)->getMetaData()); + OptionalMode mode; + if((*pli)->isOutParam()) + { + mode = OptionalOutParam; + } + else + { + mode = useOptionalMapping(*pli) ? OptionalInParamOpt : OptionalInParamReq; + } + + writeMarshalUnmarshalCode(out, package, (*pli)->type(), mode, (*pli)->tag(), fixKwd((*pli)->name()), marshal, + iter, false, (*pli)->getMetaData()); } if(checkReturnType) @@ -2793,11 +2824,11 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) out << ';'; // - // Generate asynchronous API for local operations marked with XXX metadata. + // Generate asynchronous API for local operations marked with "async" metadata. // if(p->hasMetaData("async") || op->hasMetaData("async")) { - vector inParams = getInOutParams(op, package, InParam); + vector inParams = getInOutParams(op, package, InParam, true); out << sp; writeDocCommentAMI(out, op, InParam); @@ -2827,7 +2858,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) string cb = "Callback_" + name + "_" + opname + " __cb"; out << "Ice.AsyncResult begin_" << opname << spar << inParams << cb << epar << ';'; - vector outParams = getInOutParams(op, package, OutParam); + vector outParams = getInOutParams(op, package, OutParam, true); out << sp; writeDocCommentAMI(out, op, OutParam); out << nl; @@ -4384,7 +4415,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) TypePtr ret = op->returnType(); string retS = typeToString(ret, TypeModeReturn, package, op->getMetaData(), true, op->returnIsOptional()); - vector params = getParams(op, package); + vector params = getParamsProxy(op, package); vector args = getArgs(op); ExceptionList throws = op->throws(); @@ -4478,7 +4509,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) // // Write the asynchronous begin/end methods. // - vector inParams = getInOutParams(op, package, InParam); + vector inParams = getInOutParams(op, package, InParam, true); vector inArgs = getInOutArgs(op, InParam); string callbackParam = "Ice.Callback __cb"; int iter; @@ -4600,7 +4631,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) out << nl << "return __result;"; out << eb; - vector outParams = getInOutParams(op, package, OutParam); + vector outParams = getInOutParams(op, package, OutParam, true); // // End method @@ -5316,7 +5347,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) TypePtr ret = p->returnType(); string retS = typeToString(ret, TypeModeReturn, package, p->getMetaData(), true, p->returnIsOptional()); - vector params = getParams(p, package); + vector params = getParamsProxy(p, package); ExceptionList throws = p->throws(); throws.sort(); throws.unique(); @@ -5349,7 +5380,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) // // Start with the type-unsafe begin methods. // - vector inParams = getInOutParams(p, package, InParam); + vector inParams = getInOutParams(p, package, InParam, true); string callbackParam = "Ice.Callback __cb"; string callbackDoc = "@param __cb The asynchronous callback object."; @@ -5394,7 +5425,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) out << nl << "public Ice.AsyncResult begin_" << p->name() << spar << inParams << contextParam << typeSafeCallbackParam << epar << ';'; - vector outParams = getInOutParams(p, package, OutParam); + vector outParams = getInOutParams(p, package, OutParam, true); out << sp; writeDocCommentAMI(out, p, OutParam); @@ -5477,7 +5508,7 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p) TypePtr ret = op->returnType(); string retS = typeToString(ret, TypeModeReturn, package, op->getMetaData(), true, op->returnIsOptional()); - vector params = getParams(op, package); + vector params = getParamsProxy(op, package); ExceptionList throws = op->throws(); throws.sort(); @@ -5565,7 +5596,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) throws.sort(Slice::DerivedToBaseCompare()); #endif - vector params = getParams(op, package); + vector params = getParamsProxy(op, package); out << sp; out << nl << "public " << retS << nl << opName << spar << params << contextParam << epar; @@ -5730,8 +5761,26 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) throws.sort(Slice::DerivedToBaseCompare()); #endif - vector params = getParams(op, package, true); - vector args = getArgs(op); + vector params = getParamsProxy(op, package, true); + + // + // Collect the arguments that will be passed to the servant. + // + // Note that for optional in parameters, we may have to wrap a value + // in an Optional object to be compatible with the servant's signature. + // + vector args; + ParamDeclList paramList = op->parameters(); + for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) + { + string param = fixKwd((*q)->name()); + if(!(*q)->isOutParam() && (*q)->optional() && !useOptionalMapping(*q)) + { + string typeString = typeToString((*q)->type(), TypeModeIn, package, (*q)->getMetaData(), true, true); + param = "new " + typeString + "(" + param + ")"; + } + args.push_back(param); + } out << sp; if(!deprecateReason.empty()) diff --git a/cpp/src/slice2java/Gen.h b/cpp/src/slice2java/Gen.h index 001bca3c89e..5cfeae3714a 100644 --- a/cpp/src/slice2java/Gen.h +++ b/cpp/src/slice2java/Gen.h @@ -32,8 +32,9 @@ protected: // // Compose the parameter lists for an operation. // - std::vector getParams(const OperationPtr&, const std::string&, bool = false); - std::vector getInOutParams(const OperationPtr&, const std::string&, ParamDir); + std::vector getParams(const OperationPtr&, const std::string&); + std::vector getParamsProxy(const OperationPtr&, const std::string&, bool = false); + std::vector getInOutParams(const OperationPtr&, const std::string&, ParamDir, bool); std::vector getParamsAsync(const OperationPtr&, const std::string&, bool); std::vector getParamsAsyncCB(const OperationPtr&, const std::string&); diff --git a/java/src/Ice/BooleanOptional.java b/java/src/Ice/BooleanOptional.java new file mode 100644 index 00000000000..724f89e7460 --- /dev/null +++ b/java/src/Ice/BooleanOptional.java @@ -0,0 +1,106 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package Ice; + +/** + * Manages an optional boolean parameter. + **/ +public class BooleanOptional +{ + /** + * The value defaults to unset. + **/ + public BooleanOptional() + { + _isSet = false; + } + + /** + * Sets the value to the given argument. + * + * @param v The initial value. + **/ + public BooleanOptional(boolean v) + { + _value = v; + _isSet = true; + } + + /** + * Sets the value to a shallow copy of the given optional. + * + * @param opt The source value. + **/ + public BooleanOptional(BooleanOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Obtains the current value. + * + * @return The current value. + * @throws IllegalStateException If the value is not set. + **/ + public boolean get() + { + if(!_isSet) + { + throw new IllegalStateException("no value is set"); + } + return _value; + } + + /** + * Sets the value to the given argument. + * + * @param v The new value. + **/ + public void set(boolean v) + { + _value = v; + _isSet = true; + } + + /** + * If the given argument is set, this optional is set to a shallow copy of the argument, + * otherwise this optional is unset. + * + * @param opt The source value. + **/ + public void set(BooleanOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Determines whether the value is set. + * + * @return True if the value is set, false otherwise. + **/ + public boolean isSet() + { + return _isSet; + } + + /** + * Unsets this value. + **/ + public void clear() + { + _isSet = false; + _value = false; + } + + private boolean _value; + private boolean _isSet; +} diff --git a/java/src/Ice/ByteOptional.java b/java/src/Ice/ByteOptional.java new file mode 100644 index 00000000000..4430f634ffc --- /dev/null +++ b/java/src/Ice/ByteOptional.java @@ -0,0 +1,106 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package Ice; + +/** + * Manages an optional byte parameter. + **/ +public class ByteOptional +{ + /** + * The value defaults to unset. + **/ + public ByteOptional() + { + _isSet = false; + } + + /** + * Sets the value to the given argument. + * + * @param v The initial value. + **/ + public ByteOptional(byte v) + { + _value = v; + _isSet = true; + } + + /** + * Sets the value to a shallow copy of the given optional. + * + * @param opt The source value. + **/ + public ByteOptional(ByteOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Obtains the current value. + * + * @return The current value. + * @throws IllegalStateException If the value is not set. + **/ + public byte get() + { + if(!_isSet) + { + throw new IllegalStateException("no value is set"); + } + return _value; + } + + /** + * Sets the value to the given argument. + * + * @param v The new value. + **/ + public void set(byte v) + { + _value = v; + _isSet = true; + } + + /** + * If the given argument is set, this optional is set to a shallow copy of the argument, + * otherwise this optional is unset. + * + * @param opt The source value. + **/ + public void set(ByteOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Determines whether the value is set. + * + * @return True if the value is set, false otherwise. + **/ + public boolean isSet() + { + return _isSet; + } + + /** + * Unsets this value. + **/ + public void clear() + { + _isSet = false; + _value = 0; + } + + private byte _value; + private boolean _isSet; +} diff --git a/java/src/Ice/DoubleOptional.java b/java/src/Ice/DoubleOptional.java new file mode 100644 index 00000000000..d9b78066616 --- /dev/null +++ b/java/src/Ice/DoubleOptional.java @@ -0,0 +1,106 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package Ice; + +/** + * Manages an optional double parameter. + **/ +public class DoubleOptional +{ + /** + * The value defaults to unset. + **/ + public DoubleOptional() + { + _isSet = false; + } + + /** + * Sets the value to the given argument. + * + * @param v The initial value. + **/ + public DoubleOptional(double v) + { + _value = v; + _isSet = true; + } + + /** + * Sets the value to a shallow copy of the given optional. + * + * @param opt The source value. + **/ + public DoubleOptional(DoubleOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Obtains the current value. + * + * @return The current value. + * @throws IllegalStateException If the value is not set. + **/ + public double get() + { + if(!_isSet) + { + throw new IllegalStateException("no value is set"); + } + return _value; + } + + /** + * Sets the value to the given argument. + * + * @param v The new value. + **/ + public void set(double v) + { + _value = v; + _isSet = true; + } + + /** + * If the given argument is set, this optional is set to a shallow copy of the argument, + * otherwise this optional is unset. + * + * @param opt The source value. + **/ + public void set(DoubleOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Determines whether the value is set. + * + * @return True if the value is set, false otherwise. + **/ + public boolean isSet() + { + return _isSet; + } + + /** + * Unsets this value. + **/ + public void clear() + { + _isSet = false; + _value = 0; + } + + private double _value; + private boolean _isSet; +} diff --git a/java/src/Ice/FloatOptional.java b/java/src/Ice/FloatOptional.java new file mode 100644 index 00000000000..d8f11cb6e5e --- /dev/null +++ b/java/src/Ice/FloatOptional.java @@ -0,0 +1,106 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package Ice; + +/** + * Manages an optional float parameter. + **/ +public class FloatOptional +{ + /** + * The value defaults to unset. + **/ + public FloatOptional() + { + _isSet = false; + } + + /** + * Sets the value to the given argument. + * + * @param v The initial value. + **/ + public FloatOptional(float v) + { + _value = v; + _isSet = true; + } + + /** + * Sets the value to a shallow copy of the given optional. + * + * @param opt The source value. + **/ + public FloatOptional(FloatOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Obtains the current value. + * + * @return The current value. + * @throws IllegalStateException If the value is not set. + **/ + public float get() + { + if(!_isSet) + { + throw new IllegalStateException("no value is set"); + } + return _value; + } + + /** + * Sets the value to the given argument. + * + * @param v The new value. + **/ + public void set(float v) + { + _value = v; + _isSet = true; + } + + /** + * If the given argument is set, this optional is set to a shallow copy of the argument, + * otherwise this optional is unset. + * + * @param opt The source value. + **/ + public void set(FloatOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Determines whether the value is set. + * + * @return True if the value is set, false otherwise. + **/ + public boolean isSet() + { + return _isSet; + } + + /** + * Unsets this value. + **/ + public void clear() + { + _isSet = false; + _value = (float)0; + } + + private float _value; + private boolean _isSet; +} diff --git a/java/src/Ice/IntOptional.java b/java/src/Ice/IntOptional.java new file mode 100644 index 00000000000..d80f963b11a --- /dev/null +++ b/java/src/Ice/IntOptional.java @@ -0,0 +1,106 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package Ice; + +/** + * Manages an optional int parameter. + **/ +public class IntOptional +{ + /** + * The value defaults to unset. + **/ + public IntOptional() + { + _isSet = false; + } + + /** + * Sets the value to the given argument. + * + * @param v The initial value. + **/ + public IntOptional(int v) + { + _value = v; + _isSet = true; + } + + /** + * Sets the value to a shallow copy of the given optional. + * + * @param opt The source value. + **/ + public IntOptional(IntOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Obtains the current value. + * + * @return The current value. + * @throws IllegalStateException If the value is not set. + **/ + public int get() + { + if(!_isSet) + { + throw new IllegalStateException("no value is set"); + } + return _value; + } + + /** + * Sets the value to the given argument. + * + * @param v The new value. + **/ + public void set(int v) + { + _value = v; + _isSet = true; + } + + /** + * If the given argument is set, this optional is set to a shallow copy of the argument, + * otherwise this optional is unset. + * + * @param opt The source value. + **/ + public void set(IntOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Determines whether the value is set. + * + * @return True if the value is set, false otherwise. + **/ + public boolean isSet() + { + return _isSet; + } + + /** + * Unsets this value. + **/ + public void clear() + { + _isSet = false; + _value = 0; + } + + private int _value; + private boolean _isSet; +} diff --git a/java/src/Ice/LongOptional.java b/java/src/Ice/LongOptional.java new file mode 100644 index 00000000000..a40c362736f --- /dev/null +++ b/java/src/Ice/LongOptional.java @@ -0,0 +1,106 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package Ice; + +/** + * Manages an optional long parameter. + **/ +public class LongOptional +{ + /** + * The value defaults to unset. + **/ + public LongOptional() + { + _isSet = false; + } + + /** + * Sets the value to the given argument. + * + * @param v The initial value. + **/ + public LongOptional(long v) + { + _value = v; + _isSet = true; + } + + /** + * Sets the value to a shallow copy of the given optional. + * + * @param opt The source value. + **/ + public LongOptional(LongOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Obtains the current value. + * + * @return The current value. + * @throws IllegalStateException If the value is not set. + **/ + public long get() + { + if(!_isSet) + { + throw new IllegalStateException("no value is set"); + } + return _value; + } + + /** + * Sets the value to the given argument. + * + * @param v The new value. + **/ + public void set(long v) + { + _value = v; + _isSet = true; + } + + /** + * If the given argument is set, this optional is set to a shallow copy of the argument, + * otherwise this optional is unset. + * + * @param opt The source value. + **/ + public void set(LongOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Determines whether the value is set. + * + * @return True if the value is set, false otherwise. + **/ + public boolean isSet() + { + return _isSet; + } + + /** + * Unsets this value. + **/ + public void clear() + { + _isSet = false; + _value = 0; + } + + private long _value; + private boolean _isSet; +} diff --git a/java/src/Ice/ShortOptional.java b/java/src/Ice/ShortOptional.java new file mode 100644 index 00000000000..b3d3742f8ad --- /dev/null +++ b/java/src/Ice/ShortOptional.java @@ -0,0 +1,106 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package Ice; + +/** + * Manages an optional short parameter. + **/ +public class ShortOptional +{ + /** + * The value defaults to unset. + **/ + public ShortOptional() + { + _isSet = false; + } + + /** + * Sets the value to the given argument. + * + * @param v The initial value. + **/ + public ShortOptional(short v) + { + _value = v; + _isSet = true; + } + + /** + * Sets the value to a shallow copy of the given optional. + * + * @param opt The source value. + **/ + public ShortOptional(ShortOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Obtains the current value. + * + * @return The current value. + * @throws IllegalStateException If the value is not set. + **/ + public short get() + { + if(!_isSet) + { + throw new IllegalStateException("no value is set"); + } + return _value; + } + + /** + * Sets the value to the given argument. + * + * @param v The new value. + **/ + public void set(short v) + { + _value = v; + _isSet = true; + } + + /** + * If the given argument is set, this optional is set to a shallow copy of the argument, + * otherwise this optional is unset. + * + * @param opt The source value. + **/ + public void set(ShortOptional opt) + { + _value = opt._value; + _isSet = opt._isSet; + } + + /** + * Determines whether the value is set. + * + * @return True if the value is set, false otherwise. + **/ + public boolean isSet() + { + return _isSet; + } + + /** + * Unsets this value. + **/ + public void clear() + { + _isSet = false; + _value = 0; + } + + private short _value; + private boolean _isSet; +} diff --git a/java/src/IceInternal/BasicStream.java b/java/src/IceInternal/BasicStream.java index 3ed20b61b90..7732c8e4c1a 100644 --- a/java/src/IceInternal/BasicStream.java +++ b/java/src/IceInternal/BasicStream.java @@ -822,11 +822,20 @@ public class BasicStream } public void - writeByte(int tag, Ice.Optional v) + writeByte(int tag, Ice.ByteOptional v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.F1)) + if(v != null && v.isSet()) { - writeByte(v.get()); + writeByte(tag, v.get()); + } + } + + public void + writeByte(int tag, byte v) + { + if(writeOpt(tag, Ice.OptionalType.F1)) + { + writeByte(v); } } @@ -854,9 +863,18 @@ public class BasicStream public void writeByteSeq(int tag, Ice.Optional v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.VSize)) + if(v != null && v.isSet()) + { + writeByteSeq(tag, v.get()); + } + } + + public void + writeByteSeq(int tag, byte[] v) + { + if(writeOpt(tag, Ice.OptionalType.VSize)) { - writeByteSeq(v.get()); + writeByteSeq(v); } } @@ -896,7 +914,7 @@ public class BasicStream } public void - readByte(int tag, Ice.Optional v) + readByte(int tag, Ice.ByteOptional v) { if(readOpt(tag, Ice.OptionalType.F1)) { @@ -965,11 +983,20 @@ public class BasicStream } public void - writeBool(int tag, Ice.Optional v) + writeBool(int tag, Ice.BooleanOptional v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.F1)) + if(v != null && v.isSet()) { - writeBool(v.get()); + writeBool(tag, v.get()); + } + } + + public void + writeBool(int tag, boolean v) + { + if(writeOpt(tag, Ice.OptionalType.F1)) + { + writeBool(v); } } @@ -1000,9 +1027,18 @@ public class BasicStream public void writeBoolSeq(int tag, Ice.Optional v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.VSize)) + if(v != null && v.isSet()) { - writeBoolSeq(v.get()); + writeBoolSeq(tag, v.get()); + } + } + + public void + writeBoolSeq(int tag, boolean[] v) + { + if(writeOpt(tag, Ice.OptionalType.VSize)) + { + writeBoolSeq(v); } } @@ -1020,7 +1056,7 @@ public class BasicStream } public void - readBool(int tag, Ice.Optional v) + readBool(int tag, Ice.BooleanOptional v) { if(readOpt(tag, Ice.OptionalType.F1)) { @@ -1072,11 +1108,20 @@ public class BasicStream } public void - writeShort(int tag, Ice.Optional v) + writeShort(int tag, Ice.ShortOptional v) + { + if(v != null && v.isSet()) + { + writeShort(tag, v.get()); + } + } + + public void + writeShort(int tag, short v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.F2)) + if(writeOpt(tag, Ice.OptionalType.F2)) { - writeShort(v.get()); + writeShort(v); } } @@ -1100,11 +1145,19 @@ public class BasicStream public void writeShortSeq(int tag, Ice.Optional v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.VSize)) + if(v != null && v.isSet()) + { + writeShortSeq(tag, v.get()); + } + } + + public void + writeShortSeq(int tag, short[] v) + { + if(writeOpt(tag, Ice.OptionalType.VSize)) { - final short[] arr = v.get(); - writeSize(arr == null || arr.length == 0 ? 1 : arr.length * 2 + (arr.length > 254 ? 5 : 1)); - writeShortSeq(arr); + writeSize(v == null || v.length == 0 ? 1 : v.length * 2 + (v.length > 254 ? 5 : 1)); + writeShortSeq(v); } } @@ -1122,7 +1175,7 @@ public class BasicStream } public void - readShort(int tag, Ice.Optional v) + readShort(int tag, Ice.ShortOptional v) { if(readOpt(tag, Ice.OptionalType.F2)) { @@ -1174,11 +1227,20 @@ public class BasicStream } public void - writeInt(int tag, Ice.Optional v) + writeInt(int tag, Ice.IntOptional v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.F4)) + if(v != null && v.isSet()) { - writeInt(v.get()); + writeInt(tag, v.get()); + } + } + + public void + writeInt(int tag, int v) + { + if(writeOpt(tag, Ice.OptionalType.F4)) + { + writeInt(v); } } @@ -1208,11 +1270,19 @@ public class BasicStream public void writeIntSeq(int tag, Ice.Optional v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.VSize)) + if(v != null && v.isSet()) + { + writeIntSeq(tag, v.get()); + } + } + + public void + writeIntSeq(int tag, int[] v) + { + if(writeOpt(tag, Ice.OptionalType.VSize)) { - final int[] arr = v.get(); - writeSize(arr == null || arr.length == 0 ? 1 : arr.length * 4 + (arr.length > 254 ? 5 : 1)); - writeIntSeq(arr); + writeSize(v == null || v.length == 0 ? 1 : v.length * 4 + (v.length > 254 ? 5 : 1)); + writeIntSeq(v); } } @@ -1230,7 +1300,7 @@ public class BasicStream } public void - readInt(int tag, Ice.Optional v) + readInt(int tag, Ice.IntOptional v) { if(readOpt(tag, Ice.OptionalType.F4)) { @@ -1282,11 +1352,20 @@ public class BasicStream } public void - writeLong(int tag, Ice.Optional v) + writeLong(int tag, Ice.LongOptional v) + { + if(v != null && v.isSet()) + { + writeLong(tag, v.get()); + } + } + + public void + writeLong(int tag, long v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.F8)) + if(writeOpt(tag, Ice.OptionalType.F8)) { - writeLong(v.get()); + writeLong(v); } } @@ -1310,11 +1389,19 @@ public class BasicStream public void writeLongSeq(int tag, Ice.Optional v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.VSize)) + if(v != null && v.isSet()) { - final long[] arr = v.get(); - writeSize(arr == null || arr.length == 0 ? 1 : arr.length * 8 + (arr.length > 254 ? 5 : 1)); - writeLongSeq(arr); + writeLongSeq(tag, v.get()); + } + } + + public void + writeLongSeq(int tag, long[] v) + { + if(writeOpt(tag, Ice.OptionalType.VSize)) + { + writeSize(v == null || v.length == 0 ? 1 : v.length * 8 + (v.length > 254 ? 5 : 1)); + writeLongSeq(v); } } @@ -1332,7 +1419,7 @@ public class BasicStream } public void - readLong(int tag, Ice.Optional v) + readLong(int tag, Ice.LongOptional v) { if(readOpt(tag, Ice.OptionalType.F8)) { @@ -1384,11 +1471,20 @@ public class BasicStream } public void - writeFloat(int tag, Ice.Optional v) + writeFloat(int tag, Ice.FloatOptional v) + { + if(v != null && v.isSet()) + { + writeFloat(tag, v.get()); + } + } + + public void + writeFloat(int tag, float v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.F4)) + if(writeOpt(tag, Ice.OptionalType.F4)) { - writeFloat(v.get()); + writeFloat(v); } } @@ -1412,11 +1508,19 @@ public class BasicStream public void writeFloatSeq(int tag, Ice.Optional v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.VSize)) + if(v != null && v.isSet()) { - final float[] arr = v.get(); - writeSize(arr == null || arr.length == 0 ? 1 : arr.length * 4 + (arr.length > 254 ? 5 : 1)); - writeFloatSeq(arr); + writeFloatSeq(tag, v.get()); + } + } + + public void + writeFloatSeq(int tag, float[] v) + { + if(writeOpt(tag, Ice.OptionalType.VSize)) + { + writeSize(v == null || v.length == 0 ? 1 : v.length * 4 + (v.length > 254 ? 5 : 1)); + writeFloatSeq(v); } } @@ -1434,7 +1538,7 @@ public class BasicStream } public void - readFloat(int tag, Ice.Optional v) + readFloat(int tag, Ice.FloatOptional v) { if(readOpt(tag, Ice.OptionalType.F4)) { @@ -1486,11 +1590,20 @@ public class BasicStream } public void - writeDouble(int tag, Ice.Optional v) + writeDouble(int tag, Ice.DoubleOptional v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.F8)) + if(v != null && v.isSet()) { - writeDouble(v.get()); + writeDouble(tag, v.get()); + } + } + + public void + writeDouble(int tag, double v) + { + if(writeOpt(tag, Ice.OptionalType.F8)) + { + writeDouble(v); } } @@ -1514,11 +1627,19 @@ public class BasicStream public void writeDoubleSeq(int tag, Ice.Optional v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.VSize)) + if(v != null && v.isSet()) + { + writeDoubleSeq(tag, v.get()); + } + } + + public void + writeDoubleSeq(int tag, double[] v) + { + if(writeOpt(tag, Ice.OptionalType.VSize)) { - final double[] arr = v.get(); - writeSize(arr == null || arr.length == 0 ? 1 : arr.length * 8 + (arr.length > 254 ? 5 : 1)); - writeDoubleSeq(arr); + writeSize(v == null || v.length == 0 ? 1 : v.length * 8 + (v.length > 254 ? 5 : 1)); + writeDoubleSeq(v); } } @@ -1536,7 +1657,7 @@ public class BasicStream } public void - readDouble(int tag, Ice.Optional v) + readDouble(int tag, Ice.DoubleOptional v) { if(readOpt(tag, Ice.OptionalType.F8)) { @@ -1649,9 +1770,18 @@ public class BasicStream public void writeString(int tag, Ice.Optional v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.VSize)) + if(v != null && v.isSet()) + { + writeString(tag, v.get()); + } + } + + public void + writeString(int tag, String v) + { + if(writeOpt(tag, Ice.OptionalType.VSize)) { - writeString(v.get()); + writeString(v); } } @@ -1675,10 +1805,19 @@ public class BasicStream public void writeStringSeq(int tag, Ice.Optional v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.FSize)) + if(v != null && v.isSet()) + { + writeStringSeq(tag, v.get()); + } + } + + public void + writeStringSeq(int tag, String[] v) + { + if(writeOpt(tag, Ice.OptionalType.FSize)) { startSize(); - writeStringSeq(v.get()); + writeStringSeq(v); endSize(); } } @@ -1809,10 +1948,19 @@ public class BasicStream public void writeProxy(int tag, Ice.Optional v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.FSize)) + if(v != null && v.isSet()) + { + writeProxy(tag, v.get()); + } + } + + public void + writeProxy(int tag, Ice.ObjectPrx v) + { + if(writeOpt(tag, Ice.OptionalType.FSize)) { startSize(); - writeProxy(v.get()); + writeProxy(v); endSize(); } } @@ -1895,9 +2043,18 @@ public class BasicStream public void writeObject(int tag, Ice.Optional v) { - if(v != null && v.isSet() && writeOpt(tag, Ice.OptionalType.Size)) + if(v != null && v.isSet()) + { + writeObject(tag, v.get()); + } + } + + public void + writeObject(int tag, Ice.Object v) + { + if(writeOpt(tag, Ice.OptionalType.Size)) { - writeObject(v.get()); + writeObject(v); } } diff --git a/java/test/Ice/optional/AllTests.java b/java/test/Ice/optional/AllTests.java index 98eeec34aab..98538ba7311 100644 --- a/java/test/Ice/optional/AllTests.java +++ b/java/test/Ice/optional/AllTests.java @@ -524,16 +524,24 @@ public class AllTests out.print("testing optional parameters... "); out.flush(); { - Ice.Optional p1 = new Ice.Optional(); - Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opByte(p1, p3); + Ice.ByteOptional p1 = new Ice.ByteOptional(); + Ice.ByteOptional p3 = new Ice.ByteOptional(); + Ice.ByteOptional p2 = initial.opByteOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set((byte)56); - p2 = initial.opByte(p1, p3); + p2 = initial.opByteOpt(p1, p3); + test(p2.get() == (byte)56 && p3.get() == (byte)56); + Ice.AsyncResult r = initial.begin_opByteOpt(p1); + p2 = initial.end_opByteOpt(p3, r); + test(p2.get() == (byte)56 && p3.get() == (byte)56); + p2 = initial.opByte(p1.get(), p3); + test(p2.get() == (byte)56 && p3.get() == (byte)56); + r = initial.begin_opByte(p1.get()); + p2 = initial.end_opByte(p3, r); test(p2.get() == (byte)56 && p3.get() == (byte)56); - p2 = initial.opByte(new Ice.Optional(), p3); + p2 = initial.opByteOpt(new Ice.ByteOptional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -557,16 +565,24 @@ public class AllTests } { - Ice.Optional p1 = new Ice.Optional(); - Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opBool(p1, p3); + Ice.BooleanOptional p1 = new Ice.BooleanOptional(); + Ice.BooleanOptional p3 = new Ice.BooleanOptional(); + Ice.BooleanOptional p2 = initial.opBoolOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(true); - p2 = initial.opBool(p1, p3); + p2 = initial.opBoolOpt(p1, p3); + test(p2.get() == true && p3.get() == true); + Ice.AsyncResult r = initial.begin_opBoolOpt(p1); + p2 = initial.end_opBoolOpt(p3, r); + test(p2.get() == true && p3.get() == true); + p2 = initial.opBool(true, p3); + test(p2.get() == true && p3.get() == true); + r = initial.begin_opBool(true); + p2 = initial.end_opBool(p3, r); test(p2.get() == true && p3.get() == true); - p2 = initial.opBool(new Ice.Optional(), p3); + p2 = initial.opBoolOpt(new Ice.BooleanOptional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -590,16 +606,24 @@ public class AllTests } { - Ice.Optional p1 = new Ice.Optional(); - Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opShort(p1, p3); + Ice.ShortOptional p1 = new Ice.ShortOptional(); + Ice.ShortOptional p3 = new Ice.ShortOptional(); + Ice.ShortOptional p2 = initial.opShortOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set((short)56); - p2 = initial.opShort(p1, p3); + p2 = initial.opShortOpt(p1, p3); + test(p2.get() == 56 && p3.get() == 56); + Ice.AsyncResult r = initial.begin_opShortOpt(p1); + p2 = initial.end_opShortOpt(p3, r); + test(p2.get() == 56 && p3.get() == 56); + p2 = initial.opShort(p1.get(), p3); + test(p2.get() == 56 && p3.get() == 56); + r = initial.begin_opShort(p1.get()); + p2 = initial.end_opShort(p3, r); test(p2.get() == 56 && p3.get() == 56); - p2 = initial.opShort(new Ice.Optional(), p3); + p2 = initial.opShortOpt(new Ice.ShortOptional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -623,16 +647,24 @@ public class AllTests } { - Ice.Optional p1 = new Ice.Optional(); - Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opInt(p1, p3); + Ice.IntOptional p1 = new Ice.IntOptional(); + Ice.IntOptional p3 = new Ice.IntOptional(); + Ice.IntOptional p2 = initial.opIntOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(56); - p2 = initial.opInt(p1, p3); + p2 = initial.opIntOpt(p1, p3); + test(p2.get() == 56 && p3.get() == 56); + Ice.AsyncResult r = initial.begin_opIntOpt(p1); + p2 = initial.end_opIntOpt(p3, r); + test(p2.get() == 56 && p3.get() == 56); + p2 = initial.opInt(p1.get(), p3); + test(p2.get() == 56 && p3.get() == 56); + r = initial.begin_opInt(p1.get()); + p2 = initial.end_opInt(p3, r); test(p2.get() == 56 && p3.get() == 56); - p2 = initial.opInt(new Ice.Optional(), p3); + p2 = initial.opIntOpt(new Ice.IntOptional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -656,16 +688,24 @@ public class AllTests } { - Ice.Optional p1 = new Ice.Optional(); - Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opLong(p1, p3); + Ice.LongOptional p1 = new Ice.LongOptional(); + Ice.LongOptional p3 = new Ice.LongOptional(); + Ice.LongOptional p2 = initial.opLongOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); - p1.set((long)56); - p2 = initial.opLong(p1, p3); + p1.set(56); + p2 = initial.opLongOpt(p1, p3); + test(p2.get() == 56 && p3.get() == 56); + Ice.AsyncResult r = initial.begin_opLongOpt(p1); + p2 = initial.end_opLongOpt(p3, r); + test(p2.get() == 56 && p3.get() == 56); + p2 = initial.opLong(p1.get(), p3); + test(p2.get() == 56 && p3.get() == 56); + r = initial.begin_opLong(p1.get()); + p2 = initial.end_opLong(p3, r); test(p2.get() == 56 && p3.get() == 56); - p2 = initial.opLong(new Ice.Optional(), p3); + p2 = initial.opLongOpt(new Ice.LongOptional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -689,16 +729,24 @@ public class AllTests } { - Ice.Optional p1 = new Ice.Optional(); - Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opFloat(p1, p3); + Ice.FloatOptional p1 = new Ice.FloatOptional(); + Ice.FloatOptional p3 = new Ice.FloatOptional(); + Ice.FloatOptional p2 = initial.opFloatOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set((float)1.0); - p2 = initial.opFloat(p1, p3); + p2 = initial.opFloatOpt(p1, p3); + test(p2.get() == 1.0 && p3.get() == 1.0); + Ice.AsyncResult r = initial.begin_opFloatOpt(p1); + p2 = initial.end_opFloatOpt(p3, r); + test(p2.get() == 1.0 && p3.get() == 1.0); + p2 = initial.opFloat(p1.get(), p3); + test(p2.get() == 1.0 && p3.get() == 1.0); + r = initial.begin_opFloat(p1.get()); + p2 = initial.end_opFloat(p3, r); test(p2.get() == 1.0 && p3.get() == 1.0); - p2 = initial.opFloat(new Ice.Optional(), p3); + p2 = initial.opFloatOpt(new Ice.FloatOptional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -722,16 +770,24 @@ public class AllTests } { - Ice.Optional p1 = new Ice.Optional(); - Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opDouble(p1, p3); + Ice.DoubleOptional p1 = new Ice.DoubleOptional(); + Ice.DoubleOptional p3 = new Ice.DoubleOptional(); + Ice.DoubleOptional p2 = initial.opDoubleOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(1.0); - p2 = initial.opDouble(p1, p3); + p2 = initial.opDoubleOpt(p1, p3); + test(p2.get() == 1.0 && p3.get() == 1.0); + Ice.AsyncResult r = initial.begin_opDoubleOpt(p1); + p2 = initial.end_opDoubleOpt(p3, r); + test(p2.get() == 1.0 && p3.get() == 1.0); + p2 = initial.opDouble(p1.get(), p3); + test(p2.get() == 1.0 && p3.get() == 1.0); + r = initial.begin_opDouble(p1.get()); + p2 = initial.end_opDouble(p3, r); test(p2.get() == 1.0 && p3.get() == 1.0); - p2 = initial.opDouble(new Ice.Optional(), p3); + p2 = initial.opDoubleOpt(new Ice.DoubleOptional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -757,14 +813,22 @@ public class AllTests { Ice.Optional p1 = new Ice.Optional(); Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opString(p1, p3); + Ice.Optional p2 = initial.opStringOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set("test"); - p2 = initial.opString(p1, p3); + p2 = initial.opStringOpt(p1, p3); + test(p2.get().equals("test") && p3.get().equals("test")); + Ice.AsyncResult r = initial.begin_opStringOpt(p1); + p2 = initial.end_opStringOpt(p3, r); + test(p2.get().equals("test") && p3.get().equals("test")); + p2 = initial.opString(p1.get(), p3); + test(p2.get().equals("test") && p3.get().equals("test")); + r = initial.begin_opString(p1.get()); + p2 = initial.end_opString(p3, r); test(p2.get().equals("test") && p3.get().equals("test")); - p2 = initial.opString(new Ice.Optional(), p3); + p2 = initial.opStringOpt(new Ice.Optional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -790,14 +854,22 @@ public class AllTests { Ice.Optional p1 = new Ice.Optional(); Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opMyEnum(p1, p3); + Ice.Optional p2 = initial.opMyEnumOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(MyEnum.MyEnumMember); - p2 = initial.opMyEnum(p1, p3); + p2 = initial.opMyEnumOpt(p1, p3); + test(p2.get() == MyEnum.MyEnumMember && p3.get() == MyEnum.MyEnumMember); + Ice.AsyncResult r = initial.begin_opMyEnumOpt(p1); + p2 = initial.end_opMyEnumOpt(p3, r); + test(p2.get() == MyEnum.MyEnumMember && p3.get() == MyEnum.MyEnumMember); + p2 = initial.opMyEnum(p1.get(), p3); + test(p2.get() == MyEnum.MyEnumMember && p3.get() == MyEnum.MyEnumMember); + r = initial.begin_opMyEnum(p1.get()); + p2 = initial.end_opMyEnum(p3, r); test(p2.get() == MyEnum.MyEnumMember && p3.get() == MyEnum.MyEnumMember); - p2 = initial.opMyEnum(new Ice.Optional(), p3); + p2 = initial.opMyEnumOpt(new Ice.Optional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -823,14 +895,22 @@ public class AllTests { Ice.Optional p1 = new Ice.Optional(); Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opSmallStruct(p1, p3); + Ice.Optional p2 = initial.opSmallStructOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new SmallStruct((byte)56)); - p2 = initial.opSmallStruct(p1, p3); + p2 = initial.opSmallStructOpt(p1, p3); + test(p2.get().m == (byte)56 && p3.get().m == (byte)56); + Ice.AsyncResult r = initial.begin_opSmallStructOpt(p1); + p2 = initial.end_opSmallStructOpt(p3, r); + test(p2.get().m == (byte)56 && p3.get().m == (byte)56); + p2 = initial.opSmallStruct(p1.get(), p3); + test(p2.get().m == (byte)56 && p3.get().m == (byte)56); + r = initial.begin_opSmallStruct(p1.get()); + p2 = initial.end_opSmallStruct(p3, r); test(p2.get().m == (byte)56 && p3.get().m == (byte)56); - p2 = initial.opSmallStruct(new Ice.Optional(), p3); + p2 = initial.opSmallStructOpt(new Ice.Optional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -862,14 +942,22 @@ public class AllTests { Ice.Optional p1 = new Ice.Optional(); Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opFixedStruct(p1, p3); + Ice.Optional p2 = initial.opFixedStructOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new FixedStruct(56)); - p2 = initial.opFixedStruct(p1, p3); + p2 = initial.opFixedStructOpt(p1, p3); + test(p2.get().m == 56 && p3.get().m == 56); + Ice.AsyncResult r = initial.begin_opFixedStructOpt(p1); + p2 = initial.end_opFixedStructOpt(p3, r); + test(p2.get().m == 56 && p3.get().m == 56); + p2 = initial.opFixedStruct(p1.get(), p3); + test(p2.get().m == 56 && p3.get().m == 56); + r = initial.begin_opFixedStruct(p1.get()); + p2 = initial.end_opFixedStruct(p3, r); test(p2.get().m == 56 && p3.get().m == 56); - p2 = initial.opFixedStruct(new Ice.Optional(), p3); + p2 = initial.opFixedStructOpt(new Ice.Optional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -901,14 +989,22 @@ public class AllTests { Ice.Optional p1 = new Ice.Optional(); Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opVarStruct(p1, p3); + Ice.Optional p2 = initial.opVarStructOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new VarStruct("test")); - p2 = initial.opVarStruct(p1, p3); + p2 = initial.opVarStructOpt(p1, p3); + test(p2.get().m.equals("test") && p3.get().m.equals("test")); + Ice.AsyncResult r = initial.begin_opVarStructOpt(p1); + p2 = initial.end_opVarStructOpt(p3, r); + test(p2.get().m.equals("test") && p3.get().m.equals("test")); + p2 = initial.opVarStruct(p1.get(), p3); + test(p2.get().m.equals("test") && p3.get().m.equals("test")); + r = initial.begin_opVarStruct(p1.get()); + p2 = initial.end_opVarStruct(p3, r); test(p2.get().m.equals("test") && p3.get().m.equals("test")); - p2 = initial.opVarStruct(new Ice.Optional(), p3); + p2 = initial.opVarStructOpt(new Ice.Optional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -941,14 +1037,22 @@ public class AllTests { Ice.Optional p1 = new Ice.Optional(); Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opOneOptional(p1, p3); + Ice.Optional p2 = initial.opOneOptionalOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new OneOptional(58)); - p2 = initial.opOneOptional(p1, p3); + p2 = initial.opOneOptionalOpt(p1, p3); + test(p2.get().getA() == 58 && p3.get().getA() == 58); + Ice.AsyncResult r = initial.begin_opOneOptionalOpt(p1); + p2 = initial.end_opOneOptionalOpt(p3, r); + test(p2.get().getA() == 58 && p3.get().getA() == 58); + p2 = initial.opOneOptional(p1.get(), p3); + test(p2.get().getA() == 58 && p3.get().getA() == 58); + r = initial.begin_opOneOptional(p1.get()); + p2 = initial.end_opOneOptional(p3, r); test(p2.get().getA() == 58 && p3.get().getA() == 58); - p2 = initial.opOneOptional(new Ice.Optional(), p3); + p2 = initial.opOneOptionalOpt(new Ice.Optional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -977,14 +1081,22 @@ public class AllTests { Ice.Optional p1 = new Ice.Optional(); Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opOneOptionalProxy(p1, p3); + Ice.Optional p2 = initial.opOneOptionalProxyOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(OneOptionalPrxHelper.uncheckedCast(communicator.stringToProxy("test"))); - p2 = initial.opOneOptionalProxy(p1, p3); + p2 = initial.opOneOptionalProxyOpt(p1, p3); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + Ice.AsyncResult r = initial.begin_opOneOptionalProxyOpt(p1); + p2 = initial.end_opOneOptionalProxyOpt(p3, r); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + p2 = initial.opOneOptionalProxy(p1.get(), p3); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + r = initial.begin_opOneOptionalProxy(p1.get()); + p2 = initial.end_opOneOptionalProxy(p3, r); test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); - p2 = initial.opOneOptionalProxy(new Ice.Optional(), p3); + p2 = initial.opOneOptionalProxyOpt(new Ice.Optional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -1014,15 +1126,23 @@ public class AllTests { Ice.Optional p1 = new Ice.Optional(); Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opByteSeq(p1, p3); + Ice.Optional p2 = initial.opByteSeqOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new byte[100]); java.util.Arrays.fill(p1.get(), (byte)56); - p2 = initial.opByteSeq(p1, p3); + p2 = initial.opByteSeqOpt(p1, p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + Ice.AsyncResult r = initial.begin_opByteSeqOpt(p1); + p2 = initial.end_opByteSeqOpt(p3, r); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + p2 = initial.opByteSeq(p1.get(), p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + r = initial.begin_opByteSeq(p1.get()); + p2 = initial.end_opByteSeq(p3, r); test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); - p2 = initial.opByteSeq(new Ice.Optional(), p3); + p2 = initial.opByteSeqOpt(new Ice.Optional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -1048,14 +1168,22 @@ public class AllTests { Ice.Optional p1 = new Ice.Optional(); Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opBoolSeq(p1, p3); + Ice.Optional p2 = initial.opBoolSeqOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new boolean[100]); - p2 = initial.opBoolSeq(p1, p3); + p2 = initial.opBoolSeqOpt(p1, p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + Ice.AsyncResult r = initial.begin_opBoolSeqOpt(p1); + p2 = initial.end_opBoolSeqOpt(p3, r); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + p2 = initial.opBoolSeq(p1.get(), p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + r = initial.begin_opBoolSeq(p1.get()); + p2 = initial.end_opBoolSeq(p3, r); test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); - p2 = initial.opBoolSeq(new Ice.Optional(), p3); + p2 = initial.opBoolSeqOpt(new Ice.Optional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -1081,15 +1209,23 @@ public class AllTests { Ice.Optional p1 = new Ice.Optional(); Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opShortSeq(p1, p3); + Ice.Optional p2 = initial.opShortSeqOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new short[100]); java.util.Arrays.fill(p1.get(), (short)56); - p2 = initial.opShortSeq(p1, p3); + p2 = initial.opShortSeqOpt(p1, p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + Ice.AsyncResult r = initial.begin_opShortSeqOpt(p1); + p2 = initial.end_opShortSeqOpt(p3, r); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + p2 = initial.opShortSeq(p1.get(), p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + r = initial.begin_opShortSeq(p1.get()); + p2 = initial.end_opShortSeq(p3, r); test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); - p2 = initial.opShortSeq(new Ice.Optional(), p3); + p2 = initial.opShortSeqOpt(new Ice.Optional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -1118,15 +1254,23 @@ public class AllTests { Ice.Optional p1 = new Ice.Optional(); Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opIntSeq(p1, p3); + Ice.Optional p2 = initial.opIntSeqOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new int[100]); java.util.Arrays.fill(p1.get(), 56); - p2 = initial.opIntSeq(p1, p3); + p2 = initial.opIntSeqOpt(p1, p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + Ice.AsyncResult r = initial.begin_opIntSeqOpt(p1); + p2 = initial.end_opIntSeqOpt(p3, r); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + p2 = initial.opIntSeq(p1.get(), p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + r = initial.begin_opIntSeq(p1.get()); + p2 = initial.end_opIntSeq(p3, r); test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); - p2 = initial.opIntSeq(new Ice.Optional(), p3); + p2 = initial.opIntSeqOpt(new Ice.Optional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -1155,15 +1299,23 @@ public class AllTests { Ice.Optional p1 = new Ice.Optional(); Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opLongSeq(p1, p3); + Ice.Optional p2 = initial.opLongSeqOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new long[100]); java.util.Arrays.fill(p1.get(), 56); - p2 = initial.opLongSeq(p1, p3); + p2 = initial.opLongSeqOpt(p1, p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + Ice.AsyncResult r = initial.begin_opLongSeqOpt(p1); + p2 = initial.end_opLongSeqOpt(p3, r); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + p2 = initial.opLongSeq(p1.get(), p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + r = initial.begin_opLongSeq(p1.get()); + p2 = initial.end_opLongSeq(p3, r); test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); - p2 = initial.opLongSeq(new Ice.Optional(), p3); + p2 = initial.opLongSeqOpt(new Ice.Optional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -1192,15 +1344,23 @@ public class AllTests { Ice.Optional p1 = new Ice.Optional(); Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opFloatSeq(p1, p3); + Ice.Optional p2 = initial.opFloatSeqOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new float[100]); java.util.Arrays.fill(p1.get(), (float)1.0); - p2 = initial.opFloatSeq(p1, p3); + p2 = initial.opFloatSeqOpt(p1, p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + Ice.AsyncResult r = initial.begin_opFloatSeqOpt(p1); + p2 = initial.end_opFloatSeqOpt(p3, r); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + p2 = initial.opFloatSeq(p1.get(), p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + r = initial.begin_opFloatSeq(p1.get()); + p2 = initial.end_opFloatSeq(p3, r); test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); - p2 = initial.opFloatSeq(new Ice.Optional(), p3); + p2 = initial.opFloatSeqOpt(new Ice.Optional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -1229,15 +1389,23 @@ public class AllTests { Ice.Optional p1 = new Ice.Optional(); Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opDoubleSeq(p1, p3); + Ice.Optional p2 = initial.opDoubleSeqOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new double[100]); java.util.Arrays.fill(p1.get(), 1.0); - p2 = initial.opDoubleSeq(p1, p3); + p2 = initial.opDoubleSeqOpt(p1, p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + Ice.AsyncResult r = initial.begin_opDoubleSeqOpt(p1); + p2 = initial.end_opDoubleSeqOpt(p3, r); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + p2 = initial.opDoubleSeq(p1.get(), p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + r = initial.begin_opDoubleSeq(p1.get()); + p2 = initial.end_opDoubleSeq(p3, r); test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); - p2 = initial.opDoubleSeq(new Ice.Optional(), p3); + p2 = initial.opDoubleSeqOpt(new Ice.Optional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -1266,15 +1434,23 @@ public class AllTests { Ice.Optional p1 = new Ice.Optional(); Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opStringSeq(p1, p3); + Ice.Optional p2 = initial.opStringSeqOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new String[10]); java.util.Arrays.fill(p1.get(), "test1"); - p2 = initial.opStringSeq(p1, p3); + p2 = initial.opStringSeqOpt(p1, p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + Ice.AsyncResult r = initial.begin_opStringSeqOpt(p1); + p2 = initial.end_opStringSeqOpt(p3, r); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + p2 = initial.opStringSeq(p1.get(), p3); + test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); + r = initial.begin_opStringSeq(p1.get()); + p2 = initial.end_opStringSeq(p3, r); test(java.util.Arrays.equals(p2.get(), p1.get()) && java.util.Arrays.equals(p3.get(), p1.get())); - p2 = initial.opStringSeq(new Ice.Optional(), p3); + p2 = initial.opStringSeqOpt(new Ice.Optional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -1304,7 +1480,7 @@ public class AllTests { Ice.Optional p1 = new Ice.Optional(); Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opSmallStructSeq(p1, p3); + Ice.Optional p2 = initial.opSmallStructSeqOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new SmallStruct[10]); @@ -1312,13 +1488,30 @@ public class AllTests { p1.get()[i] = new SmallStruct(); } - p2 = initial.opSmallStructSeq(p1, p3); + p2 = initial.opSmallStructSeqOpt(p1, p3); + for(int i = 0; i < p1.get().length; ++i) + { + test(p2.get()[i].equals(p1.get()[i])); + } + Ice.AsyncResult r = initial.begin_opSmallStructSeqOpt(p1); + p2 = initial.end_opSmallStructSeqOpt(p3, r); + for(int i = 0; i < p1.get().length; ++i) + { + test(p2.get()[i].equals(p1.get()[i])); + } + p2 = initial.opSmallStructSeq(p1.get(), p3); + for(int i = 0; i < p1.get().length; ++i) + { + test(p2.get()[i].equals(p1.get()[i])); + } + r = initial.begin_opSmallStructSeq(p1.get()); + p2 = initial.end_opSmallStructSeq(p3, r); for(int i = 0; i < p1.get().length; ++i) { test(p2.get()[i].equals(p1.get()[i])); } - p2 = initial.opSmallStructSeq(new Ice.Optional(), p3); + p2 = initial.opSmallStructSeqOpt(new Ice.Optional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -1355,7 +1548,7 @@ public class AllTests { Ice.Optional> p1 = new Ice.Optional>(); Ice.Optional> p3 = new Ice.Optional>(); - Ice.Optional> p2 = initial.opSmallStructList(p1, p3); + Ice.Optional> p2 = initial.opSmallStructListOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new java.util.ArrayList()); @@ -1363,10 +1556,18 @@ public class AllTests { p1.get().add(new SmallStruct()); } - p2 = initial.opSmallStructList(p1, p3); + p2 = initial.opSmallStructListOpt(p1, p3); + test(p2.get().equals(p1.get())); + Ice.AsyncResult r = initial.begin_opSmallStructListOpt(p1); + p2 = initial.end_opSmallStructListOpt(p3, r); + test(p2.get().equals(p1.get())); + p2 = initial.opSmallStructList(p1.get(), p3); + test(p2.get().equals(p1.get())); + r = initial.begin_opSmallStructList(p1.get()); + p2 = initial.end_opSmallStructList(p3, r); test(p2.get().equals(p1.get())); - p2 = initial.opSmallStructList(new Ice.Optional>(), p3); + p2 = initial.opSmallStructListOpt(new Ice.Optional>(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -1397,7 +1598,7 @@ public class AllTests { Ice.Optional p1 = new Ice.Optional(); Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opFixedStructSeq(p1, p3); + Ice.Optional p2 = initial.opFixedStructSeqOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new FixedStruct[10]); @@ -1405,13 +1606,30 @@ public class AllTests { p1.get()[i] = new FixedStruct(); } - p2 = initial.opFixedStructSeq(p1, p3); + p2 = initial.opFixedStructSeqOpt(p1, p3); + for(int i = 0; i < p1.get().length; ++i) + { + test(p2.get()[i].equals(p1.get()[i])); + } + Ice.AsyncResult r = initial.begin_opFixedStructSeqOpt(p1); + p2 = initial.end_opFixedStructSeqOpt(p3, r); + for(int i = 0; i < p1.get().length; ++i) + { + test(p2.get()[i].equals(p1.get()[i])); + } + p2 = initial.opFixedStructSeq(p1.get(), p3); + for(int i = 0; i < p1.get().length; ++i) + { + test(p2.get()[i].equals(p1.get()[i])); + } + r = initial.begin_opFixedStructSeq(p1.get()); + p2 = initial.end_opFixedStructSeq(p3, r); for(int i = 0; i < p1.get().length; ++i) { test(p2.get()[i].equals(p1.get()[i])); } - p2 = initial.opFixedStructSeq(new Ice.Optional(), p3); + p2 = initial.opFixedStructSeqOpt(new Ice.Optional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -1448,7 +1666,7 @@ public class AllTests { Ice.Optional> p1 = new Ice.Optional>(); Ice.Optional> p3 = new Ice.Optional>(); - Ice.Optional> p2 = initial.opFixedStructList(p1, p3); + Ice.Optional> p2 = initial.opFixedStructListOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new java.util.ArrayList()); @@ -1456,10 +1674,18 @@ public class AllTests { p1.get().add(new FixedStruct()); } - p2 = initial.opFixedStructList(p1, p3); + p2 = initial.opFixedStructListOpt(p1, p3); + test(p2.get().equals(p1.get())); + Ice.AsyncResult r = initial.begin_opFixedStructListOpt(p1); + p2 = initial.end_opFixedStructListOpt(p3, r); + test(p2.get().equals(p1.get())); + p2 = initial.opFixedStructList(p1.get(), p3); + test(p2.get().equals(p1.get())); + r = initial.begin_opFixedStructList(p1.get()); + p2 = initial.end_opFixedStructList(p3, r); test(p2.get().equals(p1.get())); - p2 = initial.opFixedStructList(new Ice.Optional>(), p3); + p2 = initial.opFixedStructListOpt(new Ice.Optional>(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -1490,7 +1716,7 @@ public class AllTests { Ice.Optional p1 = new Ice.Optional(); Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opVarStructSeq(p1, p3); + Ice.Optional p2 = initial.opVarStructSeqOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new VarStruct[10]); @@ -1498,13 +1724,30 @@ public class AllTests { p1.get()[i] = new VarStruct(""); } - p2 = initial.opVarStructSeq(p1, p3); + p2 = initial.opVarStructSeqOpt(p1, p3); + for(int i = 0; i < p1.get().length; ++i) + { + test(p2.get()[i].equals(p1.get()[i])); + } + Ice.AsyncResult r = initial.begin_opVarStructSeqOpt(p1); + p2 = initial.end_opVarStructSeqOpt(p3, r); + for(int i = 0; i < p1.get().length; ++i) + { + test(p2.get()[i].equals(p1.get()[i])); + } + p2 = initial.opVarStructSeq(p1.get(), p3); + for(int i = 0; i < p1.get().length; ++i) + { + test(p2.get()[i].equals(p1.get()[i])); + } + r = initial.begin_opVarStructSeq(p1.get()); + p2 = initial.end_opVarStructSeq(p3, r); for(int i = 0; i < p1.get().length; ++i) { test(p2.get()[i].equals(p1.get()[i])); } - p2 = initial.opVarStructSeq(new Ice.Optional(), p3); + p2 = initial.opVarStructSeqOpt(new Ice.Optional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -1542,14 +1785,22 @@ public class AllTests { Ice.Optional p1 = new Ice.Optional(); Ice.Optional p3 = new Ice.Optional(); - Ice.Optional p2 = initial.opSerializable(p1, p3); + Ice.Optional p2 = initial.opSerializableOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new SerializableClass(58)); - p2 = initial.opSerializable(p1, p3); + p2 = initial.opSerializableOpt(p1, p3); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + Ice.AsyncResult r = initial.begin_opSerializableOpt(p1); + p2 = initial.end_opSerializableOpt(p3, r); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + p2 = initial.opSerializable(p1.get(), p3); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + r = initial.begin_opSerializable(p1.get()); + p2 = initial.end_opSerializable(p3, r); test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); - p2 = initial.opSerializable(new Ice.Optional(), p3); + p2 = initial.opSerializableOpt(new Ice.Optional(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -1577,16 +1828,24 @@ public class AllTests { Ice.Optional> p1 = new Ice.Optional>(); Ice.Optional> p3 = new Ice.Optional>(); - Ice.Optional> p2 = initial.opIntIntDict(p1, p3); + Ice.Optional> p2 = initial.opIntIntDictOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new java.util.HashMap()); p1.get().put(1, 2); p1.get().put(2, 3); - p2 = initial.opIntIntDict(p1, p3); + p2 = initial.opIntIntDictOpt(p1, p3); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + Ice.AsyncResult r = initial.begin_opIntIntDictOpt(p1); + p2 = initial.end_opIntIntDictOpt(p3, r); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + p2 = initial.opIntIntDict(p1.get(), p3); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + r = initial.begin_opIntIntDict(p1.get()); + p2 = initial.end_opIntIntDict(p3, r); test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); - p2 = initial.opIntIntDict(new Ice.Optional>(), p3); + p2 = initial.opIntIntDictOpt(new Ice.Optional>(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -1617,16 +1876,24 @@ public class AllTests { Ice.Optional> p1 = new Ice.Optional>(); Ice.Optional> p3 = new Ice.Optional>(); - Ice.Optional> p2 = initial.opStringIntDict(p1, p3); + Ice.Optional> p2 = initial.opStringIntDictOpt(p1, p3); test(!p2.isSet() && !p3.isSet()); p1.set(new java.util.HashMap()); p1.get().put("1", 1); p1.get().put("2", 2); - p2 = initial.opStringIntDict(p1, p3); + p2 = initial.opStringIntDictOpt(p1, p3); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + Ice.AsyncResult r = initial.begin_opStringIntDictOpt(p1); + p2 = initial.end_opStringIntDictOpt(p3, r); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + p2 = initial.opStringIntDict(p1.get(), p3); + test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); + r = initial.begin_opStringIntDict(p1.get()); + p2 = initial.end_opStringIntDict(p3, r); test(p2.get().equals(p1.get()) && p3.get().equals(p1.get())); - p2 = initial.opStringIntDict(new Ice.Optional>(), p3); + p2 = initial.opStringIntDictOpt(new Ice.Optional>(), p3); test(!p2.isSet() && !p3.isSet()); // Ensure out parameter is cleared. os = Ice.Util.createOutputStream(communicator); @@ -1661,7 +1928,7 @@ public class AllTests { try { - Ice.Optional a = new Ice.Optional(); + Ice.IntOptional a = new Ice.IntOptional(); Ice.Optional b = new Ice.Optional(); Ice.Optional o = new Ice.Optional(); initial.opOptionalException(a, b, o); @@ -1675,7 +1942,7 @@ public class AllTests try { - Ice.Optional a = new Ice.Optional(30); + Ice.IntOptional a = new Ice.IntOptional(30); Ice.Optional b = new Ice.Optional("test"); Ice.Optional o = new Ice.Optional(new OneOptional(53)); initial.opOptionalException(a, b, o); diff --git a/java/test/Ice/optional/InitialI.java b/java/test/Ice/optional/InitialI.java index 89b5ac237d5..31df8707394 100644 --- a/java/test/Ice/optional/InitialI.java +++ b/java/test/Ice/optional/InitialI.java @@ -26,7 +26,7 @@ public final class InitialI extends Initial } public void - opOptionalException(Ice.Optional a, Ice.Optional b, Ice.Optional o, + opOptionalException(Ice.IntOptional a, Ice.Optional b, Ice.Optional o, Ice.Current current) throws OptionalException { @@ -50,50 +50,99 @@ public final class InitialI extends Initial throw ex; } - public Ice.Optional - opByte(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public Ice.ByteOptional + opByte(Ice.ByteOptional p1, Ice.ByteOptional p3, Ice.Current current) { p3.set(p1); return p1; } - public Ice.Optional - opBool(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public Ice.ByteOptional + opByteOpt(Ice.ByteOptional p1, Ice.ByteOptional p3, Ice.Current current) { p3.set(p1); return p1; } - public Ice.Optional - opShort(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public Ice.BooleanOptional + opBool(Ice.BooleanOptional p1, Ice.BooleanOptional p3, Ice.Current current) { p3.set(p1); return p1; } - public Ice.Optional - opInt(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public Ice.BooleanOptional + opBoolOpt(Ice.BooleanOptional p1, Ice.BooleanOptional p3, Ice.Current current) { p3.set(p1); return p1; } - public Ice.Optional - opLong(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public Ice.ShortOptional + opShort(Ice.ShortOptional p1, Ice.ShortOptional p3, Ice.Current current) { p3.set(p1); return p1; } - public Ice.Optional - opFloat(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public Ice.ShortOptional + opShortOpt(Ice.ShortOptional p1, Ice.ShortOptional p3, Ice.Current current) { p3.set(p1); return p1; } - public Ice.Optional - opDouble(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public Ice.IntOptional + opInt(Ice.IntOptional p1, Ice.IntOptional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public Ice.IntOptional + opIntOpt(Ice.IntOptional p1, Ice.IntOptional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public Ice.LongOptional + opLong(Ice.LongOptional p1, Ice.LongOptional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public Ice.LongOptional + opLongOpt(Ice.LongOptional p1, Ice.LongOptional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public Ice.FloatOptional + opFloat(Ice.FloatOptional p1, Ice.FloatOptional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public Ice.FloatOptional + opFloatOpt(Ice.FloatOptional p1, Ice.FloatOptional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public Ice.DoubleOptional + opDouble(Ice.DoubleOptional p1, Ice.DoubleOptional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + + public Ice.DoubleOptional + opDoubleOpt(Ice.DoubleOptional p1, Ice.DoubleOptional p3, Ice.Current current) { p3.set(p1); return p1; @@ -106,6 +155,13 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional + opStringOpt(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public Ice.Optional opMyEnum(Ice.Optional p1, Ice.Optional p3, Ice.Current current) { @@ -113,6 +169,13 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional + opMyEnumOpt(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public Ice.Optional opSmallStruct(Ice.Optional p1, Ice.Optional p3, Ice.Current current) { @@ -120,6 +183,13 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional + opSmallStructOpt(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public Ice.Optional opFixedStruct(Ice.Optional p1, Ice.Optional p3, Ice.Current current) { @@ -127,6 +197,13 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional + opFixedStructOpt(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public Ice.Optional opVarStruct(Ice.Optional p1, Ice.Optional p3, Ice.Current current) { @@ -134,6 +211,13 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional + opVarStructOpt(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public Ice.Optional opOneOptional(Ice.Optional p1, Ice.Optional p3, Ice.Current current) { @@ -141,6 +225,13 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional + opOneOptionalOpt(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public Ice.Optional opOneOptionalProxy(Ice.Optional p1, Ice.Optional p3, Ice.Current current) { @@ -148,6 +239,13 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional + opOneOptionalProxyOpt(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public Ice.Optional opByteSeq(Ice.Optional p1, Ice.Optional p3, Ice.Current current) { @@ -155,6 +253,13 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional + opByteSeqOpt(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public Ice.Optional opBoolSeq(Ice.Optional p1, Ice.Optional p3, Ice.Current current) { @@ -162,6 +267,13 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional + opBoolSeqOpt(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public Ice.Optional opShortSeq(Ice.Optional p1, Ice.Optional p3, Ice.Current current) { @@ -169,6 +281,13 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional + opShortSeqOpt(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public Ice.Optional opIntSeq(Ice.Optional p1, Ice.Optional p3, Ice.Current current) { @@ -176,6 +295,13 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional + opIntSeqOpt(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public Ice.Optional opLongSeq(Ice.Optional p1, Ice.Optional p3, Ice.Current current) { @@ -183,6 +309,13 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional + opLongSeqOpt(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public Ice.Optional opFloatSeq(Ice.Optional p1, Ice.Optional p3, Ice.Current current) { @@ -190,6 +323,13 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional + opFloatSeqOpt(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public Ice.Optional opDoubleSeq(Ice.Optional p1, Ice.Optional p3, Ice.Current current) { @@ -197,6 +337,13 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional + opDoubleSeqOpt(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public Ice.Optional opStringSeq(Ice.Optional p1, Ice.Optional p3, Ice.Current current) { @@ -204,6 +351,13 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional + opStringSeqOpt(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public Ice.Optional opSmallStructSeq(Ice.Optional p1, Ice.Optional p3, Ice.Current current) { @@ -211,6 +365,13 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional + opSmallStructSeqOpt(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public Ice.Optional> opSmallStructList(Ice.Optional> p1, Ice.Optional> p3, Ice.Current current) @@ -219,6 +380,14 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional> + opSmallStructListOpt(Ice.Optional> p1, + Ice.Optional> p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public Ice.Optional opFixedStructSeq(Ice.Optional p1, Ice.Optional p3, Ice.Current current) { @@ -226,6 +395,13 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional + opFixedStructSeqOpt(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public Ice.Optional> opFixedStructList(Ice.Optional> p1, Ice.Optional> p3, Ice.Current current) @@ -234,6 +410,14 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional> + opFixedStructListOpt(Ice.Optional> p1, + Ice.Optional> p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public Ice.Optional opVarStructSeq(Ice.Optional p1, Ice.Optional p3, Ice.Current current) { @@ -241,6 +425,13 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional + opVarStructSeqOpt(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public Ice.Optional opSerializable(Ice.Optional p1, Ice.Optional p3, Ice.Current current) { @@ -248,6 +439,13 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional + opSerializableOpt(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public Ice.Optional> opIntIntDict(Ice.Optional> p1, Ice.Optional> p3, Ice.Current current) @@ -256,6 +454,14 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional> + opIntIntDictOpt(Ice.Optional> p1, + Ice.Optional> p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public Ice.Optional> opStringIntDict(Ice.Optional> p1, Ice.Optional> p3, Ice.Current current) @@ -264,6 +470,14 @@ public final class InitialI extends Initial return p1; } + public Ice.Optional> + opStringIntDictOpt(Ice.Optional> p1, + Ice.Optional> p3, Ice.Current current) + { + p3.set(p1); + return p1; + } + public void opClassAndUnknownOptional(A p, Ice.Current current) { diff --git a/java/test/Ice/optional/Test.ice b/java/test/Ice/optional/Test.ice index c86a74294f7..ce4c442d93b 100644 --- a/java/test/Ice/optional/Test.ice +++ b/java/test/Ice/optional/Test.ice @@ -9,8 +9,6 @@ #pragma once -[["cpp:include:list"]] - [["java:package:test.Ice.optional"]] module Test { @@ -40,7 +38,7 @@ struct VarStruct string m; }; -["cpp:class"] struct ClassVarStruct +struct ClassVarStruct { int a; }; @@ -156,90 +154,121 @@ exception RequiredException extends OptionalException class OptionalWithCustom { - ["cpp:type:std::list< ::Ice::Byte>", "java:type:java.util.ArrayList"] optional(1) ByteSeq bs; + ["java:type:java.util.ArrayList"] optional(1) ByteSeq bs; optional(2) ClassVarStruct s; }; +["ami"] class Initial { void shutdown(); Object pingPong(Object o); + ["java:optional"] void opOptionalException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) throws OptionalException; optional(1) byte opByte(optional(2) byte p1, out optional(3) byte p3); + ["java:optional"] optional(1) byte opByteOpt(optional(2) byte p1, out optional(3) byte p3); optional(1) bool opBool(optional(2) bool p1, out optional(3) bool p3); + ["java:optional"] optional(1) bool opBoolOpt(optional(2) bool p1, out optional(3) bool p3); optional(1) short opShort(optional(2) short p1, out optional(3) short p3); + ["java:optional"] optional(1) short opShortOpt(optional(2) short p1, out optional(3) short p3); optional(1) int opInt(optional(2) int p1, out optional(3) int p3); + ["java:optional"] optional(1) int opIntOpt(optional(2) int p1, out optional(3) int p3); optional(1) long opLong(optional(2) long p1, out optional(3) long p3); + ["java:optional"] optional(1) long opLongOpt(optional(2) long p1, out optional(3) long p3); optional(1) float opFloat(optional(2) float p1, out optional(3) float p3); + ["java:optional"] optional(1) float opFloatOpt(optional(2) float p1, out optional(3) float p3); optional(1) double opDouble(optional(2) double p1, out optional(3) double p3); + ["java:optional"] optional(1) double opDoubleOpt(optional(2) double p1, out optional(3) double p3); optional(1) string opString(optional(2) string p1, out optional(3) string p3); + ["java:optional"] optional(1) string opStringOpt(optional(2) string p1, out optional(3) string p3); optional(1) MyEnum opMyEnum(optional(2) MyEnum p1, out optional(3) MyEnum p3); + ["java:optional"] optional(1) MyEnum opMyEnumOpt(optional(2) MyEnum p1, out optional(3) MyEnum p3); optional(1) SmallStruct opSmallStruct(optional(2) SmallStruct p1, out optional(3) SmallStruct p3); + ["java:optional"] optional(1) SmallStruct opSmallStructOpt(optional(2) SmallStruct p1, + out optional(3) SmallStruct p3); optional(1) FixedStruct opFixedStruct(optional(2) FixedStruct p1, out optional(3) FixedStruct p3); + ["java:optional"] optional(1) FixedStruct opFixedStructOpt(optional(2) FixedStruct p1, + out optional(3) FixedStruct p3); optional(1) VarStruct opVarStruct(optional(2) VarStruct p1, out optional(3) VarStruct p3); + ["java:optional"] optional(1) VarStruct opVarStructOpt(optional(2) VarStruct p1, out optional(3) VarStruct p3); optional(1) OneOptional opOneOptional(optional(2) OneOptional p1, out optional(3) OneOptional p3); + ["java:optional"] optional(1) OneOptional opOneOptionalOpt(optional(2) OneOptional p1, + out optional(3) OneOptional p3); optional(1) OneOptional* opOneOptionalProxy(optional(2) OneOptional* p1, out optional(3) OneOptional* p3); + ["java:optional"] optional(1) OneOptional* opOneOptionalProxyOpt(optional(2) OneOptional* p1, + out optional(3) OneOptional* p3); - // Custom mapping operations - ["cpp:array"] optional(1) ByteSeq opByteSeq(["cpp:array"] optional(2) ByteSeq p1, - out ["cpp:array"] optional(3) ByteSeq p3); + optional(1) ByteSeq opByteSeq(optional(2) ByteSeq p1, out optional(3) ByteSeq p3); + ["java:optional"] optional(1) ByteSeq opByteSeqOpt(optional(2) ByteSeq p1, out optional(3) ByteSeq p3); - ["cpp:range:array"] optional(1) BoolSeq opBoolSeq(["cpp:range:array"] optional(2) BoolSeq p1, - out ["cpp:range:array"] optional(3) BoolSeq p3); + optional(1) BoolSeq opBoolSeq(optional(2) BoolSeq p1, out optional(3) BoolSeq p3); + ["java:optional"] optional(1) BoolSeq opBoolSeqOpt(optional(2) BoolSeq p1, out optional(3) BoolSeq p3); - ["cpp:array"] optional(1) ShortSeq opShortSeq(["cpp:array"] optional(2) ShortSeq p1, - out ["cpp:array"] optional(3) ShortSeq p3); + optional(1) ShortSeq opShortSeq(optional(2) ShortSeq p1, out optional(3) ShortSeq p3); + ["java:optional"] optional(1) ShortSeq opShortSeqOpt(optional(2) ShortSeq p1, out optional(3) ShortSeq p3); - ["cpp:array"] optional(1) IntSeq opIntSeq(["cpp:array"] optional(2) IntSeq p1, - out ["cpp:array"] optional(3) IntSeq p3); + optional(1) IntSeq opIntSeq(optional(2) IntSeq p1, out optional(3) IntSeq p3); + ["java:optional"] optional(1) IntSeq opIntSeqOpt(optional(2) IntSeq p1, out optional(3) IntSeq p3); - ["cpp:array"] optional(1) LongSeq opLongSeq(["cpp:array"] optional(2) LongSeq p1, - out ["cpp:array"] optional(3) LongSeq p3); + optional(1) LongSeq opLongSeq(optional(2) LongSeq p1, out optional(3) LongSeq p3); + ["java:optional"] optional(1) LongSeq opLongSeqOpt(optional(2) LongSeq p1, out optional(3) LongSeq p3); - ["cpp:array"] optional(1) FloatSeq opFloatSeq(["cpp:array"] optional(2) FloatSeq p1, - out ["cpp:array"] optional(3) FloatSeq p3); + optional(1) FloatSeq opFloatSeq(optional(2) FloatSeq p1, out optional(3) FloatSeq p3); + ["java:optional"] optional(1) FloatSeq opFloatSeqOpt(optional(2) FloatSeq p1, out optional(3) FloatSeq p3); - ["cpp:array"] optional(1) DoubleSeq opDoubleSeq(["cpp:array"] optional(2) DoubleSeq p1, - out ["cpp:array"] optional(3) DoubleSeq p3); + optional(1) DoubleSeq opDoubleSeq(optional(2) DoubleSeq p1, out optional(3) DoubleSeq p3); + ["java:optional"] optional(1) DoubleSeq opDoubleSeqOpt(optional(2) DoubleSeq p1, out optional(3) DoubleSeq p3); - ["cpp:range"] optional(1) StringSeq opStringSeq(["cpp:range"] optional(2) StringSeq p1, - out ["cpp:range"] optional(3) StringSeq p3); + optional(1) StringSeq opStringSeq(optional(2) StringSeq p1, out optional(3) StringSeq p3); + ["java:optional"] optional(1) StringSeq opStringSeqOpt(optional(2) StringSeq p1, out optional(3) StringSeq p3); - ["cpp:array"] optional(1) SmallStructSeq opSmallStructSeq(["cpp:array"] optional(2) SmallStructSeq p1, - out ["cpp:array"] optional(3) SmallStructSeq p3); + optional(1) SmallStructSeq opSmallStructSeq(optional(2) SmallStructSeq p1, out optional(3) SmallStructSeq p3); + ["java:optional"] optional(1) SmallStructSeq opSmallStructSeqOpt(optional(2) SmallStructSeq p1, + out optional(3) SmallStructSeq p3); optional(1) SmallStructList opSmallStructList(optional(2) SmallStructList p1, out optional(3) SmallStructList p3); + ["java:optional"] optional(1) SmallStructList opSmallStructListOpt(optional(2) SmallStructList p1, + out optional(3) SmallStructList p3); - ["cpp:array"] optional(1) FixedStructSeq opFixedStructSeq(["cpp:array"] optional(2) FixedStructSeq p1, - out ["cpp:array"] optional(3) FixedStructSeq p3); + optional(1) FixedStructSeq opFixedStructSeq(optional(2) FixedStructSeq p1, out optional(3) FixedStructSeq p3); + ["java:optional"] optional(1) FixedStructSeq opFixedStructSeqOpt(optional(2) FixedStructSeq p1, + out optional(3) FixedStructSeq p3); optional(1) FixedStructList opFixedStructList(optional(2) FixedStructList p1, out optional(3) FixedStructList p3); + ["java:optional"] optional(1) FixedStructList opFixedStructListOpt(optional(2) FixedStructList p1, + out optional(3) FixedStructList p3); - ["cpp:range"] optional(1) VarStructSeq opVarStructSeq(["cpp:range"] optional(2) VarStructSeq p1, - out ["cpp:range"] optional(3) VarStructSeq p3); + optional(1) VarStructSeq opVarStructSeq(optional(2) VarStructSeq p1, out optional(3) VarStructSeq p3); + ["java:optional"] optional(1) VarStructSeq opVarStructSeqOpt(optional(2) VarStructSeq p1, + out optional(3) VarStructSeq p3); optional(1) Serializable opSerializable(optional(2) Serializable p1, out optional(3) Serializable p3); + ["java:optional"] optional(1) Serializable opSerializableOpt(optional(2) Serializable p1, + out optional(3) Serializable p3); optional(1) IntIntDict opIntIntDict(optional(2) IntIntDict p1, out optional(3) IntIntDict p3); + ["java:optional"] optional(1) IntIntDict opIntIntDictOpt(optional(2) IntIntDict p1, out optional(3) IntIntDict p3); optional(1) StringIntDict opStringIntDict(optional(2) StringIntDict p1, out optional(3) StringIntDict p3); + ["java:optional"] optional(1) StringIntDict opStringIntDictOpt(optional(2) StringIntDict p1, + out optional(3) StringIntDict p3); void opClassAndUnknownOptional(A p); }; -- cgit v1.2.3 From 0bb93b9fac3f6a198798cfcd86b79121f76598fc Mon Sep 17 00:00:00 2001 From: Mark Spruiell Date: Wed, 1 Aug 2012 15:40:11 -0700 Subject: more Java changes & tests --- cpp/include/Slice/JavaUtil.h | 23 +- cpp/src/Slice/JavaUtil.cpp | 284 ++++++++--------- cpp/src/slice2freezej/Main.cpp | 17 +- cpp/src/slice2java/Gen.cpp | 532 +++++++++++++++++++------------- cpp/src/slice2java/Gen.h | 11 +- java/build.xml | 1 + java/test/Ice/optional/AMDInitialI.java | 428 +++++++++++++++++++++++++ java/test/Ice/optional/AMDServer.java | 39 +++ java/test/Ice/optional/InitialI.java | 244 +++++++-------- java/test/Ice/optional/TestAMD.ice | 276 +++++++++++++++++ java/test/Ice/optional/run.py | 2 + 11 files changed, 1342 insertions(+), 515 deletions(-) create mode 100644 java/test/Ice/optional/AMDInitialI.java create mode 100644 java/test/Ice/optional/AMDServer.java create mode 100644 java/test/Ice/optional/TestAMD.ice (limited to 'cpp/src/slice2java/Gen.cpp') diff --git a/cpp/include/Slice/JavaUtil.h b/cpp/include/Slice/JavaUtil.h index 7fc742b2ac3..c8bb6a71f85 100644 --- a/cpp/include/Slice/JavaUtil.h +++ b/cpp/include/Slice/JavaUtil.h @@ -118,9 +118,9 @@ protected: std::string getStaticId(const TypePtr&, const std::string&) const; // - // Determines whether an in parameter should use the optional mapping. + // Determines whether an operation should use the optional mapping. // - bool useOptionalMapping(const ParamDeclPtr&); + bool useOptionalMapping(const OperationPtr&); // // Returns the optional type corresponding to the given Slice type. @@ -155,22 +155,15 @@ protected: enum OptionalMode { OptionalNone, - OptionalInParamReq, // Use the required mapping. - OptionalInParamOpt, // Use the optional mapping. + OptionalInParam, OptionalOutParam, OptionalReturnParam, OptionalMember }; - bool isOptionalParam(OptionalMode mode) const - { - return mode == OptionalInParamReq || mode == OptionalInParamOpt || mode == OptionalOutParam || - mode == OptionalReturnParam; - } - - void writeMarshalUnmarshalCode(::IceUtilInternal::Output&, const std::string&, const TypePtr&, OptionalMode, int, - const std::string&, bool, int&, bool = false, const StringList& = StringList(), - const std::string& patchParams = ""); + void writeMarshalUnmarshalCode(::IceUtilInternal::Output&, const std::string&, const TypePtr&, OptionalMode, + bool, int, const std::string&, bool, int&, bool = false, + const StringList& = StringList(), const std::string& patchParams = ""); // // Generate code to marshal or unmarshal a dictionary type. @@ -188,8 +181,8 @@ protected: // // Generate code to marshal or unmarshal a type using the public stream API. // - void writeStreamMarshalUnmarshalCode(::IceUtilInternal::Output&, const std::string&, const TypePtr&, OptionalMode, - int, const std::string&, bool, int&, bool = false, + void writeStreamMarshalUnmarshalCode(::IceUtilInternal::Output&, const std::string&, const TypePtr&, bool, int, + const std::string&, bool, int&, bool = false, const StringList& = StringList(), const std::string& patchParams = ""); // diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index a1dabf6d6dc..781b020c0c8 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -551,33 +551,20 @@ Slice::JavaGenerator::getStaticId(const TypePtr& type, const string& package) co } bool -Slice::JavaGenerator::useOptionalMapping(const ParamDeclPtr& p) +Slice::JavaGenerator::useOptionalMapping(const OperationPtr& p) { - if(p->optional()) - { - // - // Optional in parameters can be marked with the "java:optional" metadata to force - // the mapping to use the Ice.Optional types. The tag can also be applied to an - // operation or its interface. - // - // Without the tag, in parameters use the normal (non-optional) mapping. - // - if(!p->isOutParam()) - { - static const string tag = "java:optional"; - - OperationPtr op = OperationPtr::dynamicCast(p->container()); - assert(op); - ClassDefPtr cl = ClassDefPtr::dynamicCast(op->container()); - assert(cl); - - return p->hasMetaData(tag) || op->hasMetaData(tag) || cl->hasMetaData(tag); - } + // + // The "java:optional" metadata can be applied to an operation or its + // interface to force the mapping to use the Ice.Optional types. + // + // Without the tag, parameters use the normal (non-optional) mapping. + // + static const string tag = "java:optional"; - return true; - } + ClassDefPtr cl = ClassDefPtr::dynamicCast(p->container()); + assert(cl); - return false; + return p->hasMetaData(tag) || cl->hasMetaData(tag); } string @@ -923,7 +910,8 @@ void Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, const string& package, const TypePtr& type, - OptionalMode optional, + OptionalMode mode, + bool optionalMapping, int tag, const string& param, bool marshal, @@ -934,7 +922,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { string stream = marshal ? "__os" : "__is"; string v; - if(holder && optional == OptionalNone) + if(holder) { v = param + ".value"; } @@ -943,6 +931,8 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, v = param; } + const bool optionalParam = mode == OptionalInParam || mode == OptionalOutParam || mode == OptionalReturnParam; + BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); if(builtin) { @@ -952,7 +942,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(marshal) { - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << stream << ".writeByte(" << tag << ", " << v << ");"; } @@ -963,7 +953,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } else { - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << stream << ".readByte(" << tag << ", " << v << ");"; } @@ -978,7 +968,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(marshal) { - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << stream << ".writeBool(" << tag << ", " << v << ");"; } @@ -989,7 +979,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } else { - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << stream << ".readBool(" << tag << ", " << v << ");"; } @@ -1004,7 +994,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(marshal) { - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << stream << ".writeShort(" << tag << ", " << v << ");"; } @@ -1015,7 +1005,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } else { - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << stream << ".readShort(" << tag << ", " << v << ");"; } @@ -1030,7 +1020,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(marshal) { - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << stream << ".writeInt(" << tag << ", " << v << ");"; } @@ -1041,7 +1031,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } else { - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << stream << ".readInt(" << tag << ", " << v << ");"; } @@ -1056,7 +1046,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(marshal) { - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << stream << ".writeLong(" << tag << ", " << v << ");"; } @@ -1067,7 +1057,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } else { - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << stream << ".readLong(" << tag << ", " << v << ");"; } @@ -1082,7 +1072,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(marshal) { - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << stream << ".writeFloat(" << tag << ", " << v << ");"; } @@ -1093,7 +1083,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } else { - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << stream << ".readFloat(" << tag << ", " << v << ");"; } @@ -1108,7 +1098,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(marshal) { - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << stream << ".writeDouble(" << tag << ", " << v << ");"; } @@ -1119,7 +1109,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } else { - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << stream << ".readDouble(" << tag << ", " << v << ");"; } @@ -1134,7 +1124,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(marshal) { - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << stream << ".writeString(" << tag << ", " << v << ");"; } @@ -1145,7 +1135,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } else { - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << stream << ".readString(" << tag << ", " << v << ");"; } @@ -1160,7 +1150,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(marshal) { - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << stream << ".writeObject(" << tag << ", " << v << ");"; } @@ -1171,11 +1161,11 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } else { - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << stream << ".readObject(" << tag << ", " << param << ");"; } - else if(holder && optional == OptionalNone) + else if(holder && mode == OptionalNone) { out << nl << stream << ".readObject(" << param << ");"; } @@ -1197,11 +1187,11 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(marshal) { - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << stream << ".writeProxy(" << tag << ", " << v << ");"; } - else if(optional == OptionalMember) + else if(mode == OptionalMember) { out << nl << stream << ".startSize();"; out << nl << stream << ".writeProxy(" << v << ");"; @@ -1214,11 +1204,11 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } else { - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << stream << ".readProxy(" << tag << ", " << v << ");"; } - else if(optional == OptionalMember) + else if(mode == OptionalMember) { out << nl << stream << ".skip(4);"; out << nl << v << " = " << stream << ".readProxy();"; @@ -1245,29 +1235,29 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, string typeS = typeToString(type, TypeModeIn, package); if(marshal) { - if(isOptionalParam(optional)) + if(optionalParam) { - if(optional == OptionalInParamReq) + if(optionalMapping) { - out << nl << "if(" << stream << ".writeOpt(" << tag << ", " << getOptionalType(type) << "))"; + out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" << tag + << ", " << getOptionalType(type) << "))"; out << sb; out << nl << stream << ".startSize();"; - out << nl << typeS << "Helper.__write(" << stream << ", " << v << ");"; + out << nl << typeS << "Helper.__write(" << stream << ", " << v << ".get());"; out << nl << stream << ".endSize();"; out << eb; } else { - out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" << tag - << ", " << getOptionalType(type) << "))"; + out << nl << "if(" << stream << ".writeOpt(" << tag << ", " << getOptionalType(type) << "))"; out << sb; out << nl << stream << ".startSize();"; - out << nl << typeS << "Helper.__write(" << stream << ", " << v << ".get());"; + out << nl << typeS << "Helper.__write(" << stream << ", " << v << ");"; out << nl << stream << ".endSize();"; out << eb; } } - else if(optional == OptionalMember) + else if(mode == OptionalMember) { out << nl << stream << ".startSize();"; out << nl << typeS << "Helper.__write(" << stream << ", " << v << ");"; @@ -1280,14 +1270,14 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } else { - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << "if(" << stream << ".readOpt(" << tag << ", " << getOptionalType(type) << "))"; out << sb; out << nl << stream << ".skip(4);"; out << nl << v << ".set(" << typeS << "Helper.__read(" << stream << "));"; out << eb; - if(optional == OptionalOutParam) + if(mode == OptionalOutParam) { out << nl << "else"; out << sb; @@ -1295,7 +1285,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, out << eb; } } - else if(optional == OptionalMember) + else if(mode == OptionalMember) { out << nl << stream << ".skip(4);"; out << nl << v << " = " << typeS << "Helper.__read(" << stream << ");"; @@ -1313,7 +1303,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(marshal) { - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << stream << ".writeObject(" << tag << ", " << v << ");"; } @@ -1324,7 +1314,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } else { - if(isOptionalParam(optional)) + if(optionalParam) { string typeS = typeToString(type, TypeModeIn, package); out << nl << "if(" << stream << ".readOpt(" << tag << ", " << getOptionalType(type) << "))"; @@ -1332,7 +1322,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, out << nl << stream << ".readObject(new Ice.OptionalObject(" << v << ", " << typeS << ".class, " << getStaticId(type, package) << "));"; out << eb; - if(optional == OptionalOutParam) + if(mode == OptionalOutParam) { out << nl << "else"; out << sb; @@ -1342,7 +1332,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } else { - if(holder && optional == OptionalNone) + if(holder && mode == OptionalNone) { out << nl << stream << ".readObject(" << param << ");"; } @@ -1367,23 +1357,23 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(marshal) { - if(optional != OptionalNone) + if(optionalParam || mode == OptionalMember) { string val; - if(isOptionalParam(optional)) + if(optionalParam) { - if(optional == OptionalInParamReq) - { - out << nl << "if(" << stream << ".writeOpt(" << tag << ", " << getOptionalType(type) << "))"; - val = v; - } - else + if(optionalMapping) { out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" << tag << ", " << getOptionalType(type) << "))"; val = v + ".get()"; } + else + { + out << nl << "if(" << stream << ".writeOpt(" << tag << ", " << getOptionalType(type) << "))"; + val = v; + } out << sb; } @@ -1404,7 +1394,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, out << nl << val << ".__write(" << stream << ");"; } - if(isOptionalParam(optional)) + if(optionalParam) { out << eb; } @@ -1418,7 +1408,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { string typeS = typeToString(type, TypeModeIn, package, metaData); - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << "if(" << stream << ".readOpt(" << tag << ", " << getOptionalType(type) << "))"; out << sb; @@ -1438,7 +1428,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, out << eb; - if(optional == OptionalOutParam) + if(mode == OptionalOutParam) { out << nl << "else"; out << sb; @@ -1446,7 +1436,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, out << eb; } } - else if(optional == OptionalMember) + else if(mode == OptionalMember) { if(st->isVariableLength()) { @@ -1473,21 +1463,21 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(marshal) { - if(isOptionalParam(optional)) + if(optionalParam) { - if(optional == OptionalInParamReq) + if(optionalMapping) { - out << nl << "if(" << stream << ".writeOpt(" << tag << ", " << getOptionalType(type) << "))"; + out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" << tag + << ", " << getOptionalType(type) << "))"; out << sb; - out << nl << v << ".__write(" << stream << ");"; + out << nl << v << ".get().__write(" << stream << ");"; out << eb; } else { - out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" << tag - << ", " << getOptionalType(type) << "))"; + out << nl << "if(" << stream << ".writeOpt(" << tag << ", " << getOptionalType(type) << "))"; out << sb; - out << nl << v << ".get().__write(" << stream << ");"; + out << nl << v << ".__write(" << stream << ");"; out << eb; } } @@ -1500,13 +1490,13 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { string typeS = typeToString(type, TypeModeIn, package, metaData); - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << "if(" << stream << ".readOpt(" << tag << ", " << getOptionalType(type) << "))"; out << sb; out << nl << v << ".set(" << typeS << ".__read(" << stream << "));"; out << eb; - if(optional == OptionalOutParam) + if(mode == OptionalOutParam) { out << nl << "else"; out << sb; @@ -1525,7 +1515,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, DictionaryPtr dict = DictionaryPtr::dynamicCast(type); if(dict) { - if(optional != OptionalNone) + if(optionalParam || mode == OptionalMember) { string typeS = typeToString(type, TypeModeIn, package, metaData); TypePtr keyType = dict->keyType(); @@ -1533,24 +1523,24 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, if(marshal) { - if(isOptionalParam(optional)) + if(optionalParam) { - if(optional == OptionalInParamReq) + if(optionalMapping) { - out << nl << "if(" << stream << ".writeOpt(" << tag << ", " << getOptionalType(type) << "))"; + out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" + << tag << ", " << getOptionalType(type) << "))"; out << sb; } else { - out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" - << tag << ", " << getOptionalType(type) << "))"; + out << nl << "if(" << stream << ".writeOpt(" << tag << ", " << getOptionalType(type) << "))"; out << sb; } } if(keyType->isVariableLength() || valueType->isVariableLength()) { - string d = isOptionalParam(optional) && optional != OptionalInParamReq ? v + ".get()" : v; + string d = optionalParam && optionalMapping ? v + ".get()" : v; out << nl << stream << ".startSize();"; writeDictionaryMarshalUnmarshalCode(out, package, dict, d, marshal, iter, true, metaData); out << nl << stream << ".endSize();"; @@ -1559,7 +1549,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { const int wireSize = keyType->minWireSize() + valueType->minWireSize(); string tmpName; - if(isOptionalParam(optional) && optional != OptionalInParamReq) + if(optionalParam && optionalMapping) { tmpName = "__optDict"; out << nl << "final " << typeS << ' ' << tmpName << " = " << v << ".get();"; @@ -1568,14 +1558,13 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { tmpName = v; } - out << nl << "final int __optSize = " << tmpName << " == null ? 0 : " << tmpName - << ".size();"; + out << nl << "final int __optSize = " << tmpName << " == null ? 0 : " << tmpName << ".size();"; out << nl << stream << ".writeSize(__optSize > 254 ? __optSize * " << wireSize << " + 5 : __optSize * " << wireSize << " + 1);"; writeDictionaryMarshalUnmarshalCode(out, package, dict, tmpName, marshal, iter, true, metaData); } - if(isOptionalParam(optional)) + if(optionalParam) { out << eb; } @@ -1584,7 +1573,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { string tmpName; - if(isOptionalParam(optional)) + if(optionalParam) { tmpName = "__optDict"; out << nl << "if(" << stream << ".readOpt(" << tag << ", " << getOptionalType(type) << "))"; @@ -1607,11 +1596,11 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, writeDictionaryMarshalUnmarshalCode(out, package, dict, tmpName, marshal, iter, true, metaData); - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << v << ".set(" << tmpName << ");"; out << eb; - if(optional == OptionalOutParam) + if(mode == OptionalOutParam) { out << nl << "else"; out << sb; @@ -1631,13 +1620,13 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, SequencePtr seq = SequencePtr::dynamicCast(type); if(seq) { - if(optional != OptionalNone) + if(optionalParam || mode == OptionalMember) { string typeS = typeToString(type, TypeModeIn, package, metaData); TypePtr elemType = seq->type(); BuiltinPtr elemBuiltin = BuiltinPtr::dynamicCast(elemType); - if(isOptionalParam(optional) && elemBuiltin && elemBuiltin->kind() != Builtin::KindObject && + if(optionalParam && elemBuiltin && elemBuiltin->kind() != Builtin::KindObject && elemBuiltin->kind() != Builtin::KindObjectProxy && !hasTypeMetaData(seq, metaData)) { static const char* builtinTable[] = @@ -1692,16 +1681,16 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, if(marshal) { - if(isOptionalParam(optional)) + if(optionalParam) { - if(optional == OptionalInParamReq) + if(optionalMapping) { - out << nl << "if(" << stream << ".writeOpt(" << tag << ", " << getOptionalType(type) << "))"; + out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" + << tag << ", " << getOptionalType(type) << "))"; } else { - out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" - << tag << ", " << getOptionalType(type) << "))"; + out << nl << "if(" << stream << ".writeOpt(" << tag << ", " << getOptionalType(type) << "))"; } out << sb; @@ -1709,7 +1698,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, if(elemType->isVariableLength()) { - string s = isOptionalParam(optional) && optional != OptionalInParamReq ? v + ".get()" : v; + string s = optionalParam && optionalMapping ? v + ".get()" : v; out << nl << stream << ".startSize();"; writeSequenceMarshalUnmarshalCode(out, package, seq, s, marshal, iter, true, metaData); out << nl << stream << ".endSize();"; @@ -1723,7 +1712,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, // string tmpName; - if(isOptionalParam(optional) && optional != OptionalInParamReq) + if(optionalParam && optionalMapping) { tmpName = "__optSeq"; out << nl << "final " << typeS << ' ' << tmpName << " = " << v << ".get();"; @@ -1760,7 +1749,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, // // This just writes a byte sequence. // - string s = isOptionalParam(optional) && optional != OptionalInParamReq ? v + ".get()" : v; + string s = optionalParam && optionalMapping ? v + ".get()" : v; writeSequenceMarshalUnmarshalCode(out, package, seq, s, marshal, iter, true, metaData); } else @@ -1770,7 +1759,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, // string tmpName; - if(isOptionalParam(optional) && optional != OptionalInParamReq) + if(optionalParam && optionalMapping) { tmpName = "__optSeq"; out << nl << "final " << typeS << ' ' << tmpName << " = " << v << ".get();"; @@ -1803,7 +1792,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, writeSequenceMarshalUnmarshalCode(out, package, seq, tmpName, marshal, iter, true, metaData); } - if(isOptionalParam(optional)) + if(optionalParam) { out << eb; } @@ -1811,7 +1800,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, else { string tmpName; - if(isOptionalParam(optional)) + if(optionalParam) { tmpName = "__optSeq"; out << nl << "if(" << stream << ".readOpt(" << tag << ", " << getOptionalType(type) << "))"; @@ -1853,11 +1842,11 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, writeSequenceMarshalUnmarshalCode(out, package, seq, tmpName, marshal, iter, true, metaData); - if(isOptionalParam(optional)) + if(optionalParam) { out << nl << v << ".set(" << tmpName << ");"; out << eb; - if(optional == OptionalOutParam) + if(mode == OptionalOutParam) { out << nl << "else"; out << sb; @@ -1982,7 +1971,7 @@ Slice::JavaGenerator::writeDictionaryMarshalUnmarshalCode(Output& out, arg = "__e.getValue()"; type = value; } - writeMarshalUnmarshalCode(out, package, type, OptionalNone, 0, arg, true, iter, false); + writeMarshalUnmarshalCode(out, package, type, OptionalNone, false, 0, arg, true, iter, false); } out << eb; out << eb; @@ -2016,14 +2005,15 @@ Slice::JavaGenerator::writeDictionaryMarshalUnmarshalCode(Output& out, { string keyTypeStr = typeToObjectString(key, TypeModeIn, package); string valueTypeStr = typeToObjectString(value, TypeModeIn, package); - writeMarshalUnmarshalCode(out, package, type, OptionalNone, 0, arg, false, iter, false, StringList(), + writeMarshalUnmarshalCode(out, package, type, OptionalNone, false, 0, arg, false, iter, false, + StringList(), "new IceInternal.DictionaryPatcher<" + keyTypeStr + ", " + valueTypeStr + ">(" + v + ", " + typeS + ".class, \"" + type->typeId() + "\", __key)"); } else { out << nl << typeS << ' ' << arg << ';'; - writeMarshalUnmarshalCode(out, package, type, OptionalNone, 0, arg, false, iter, false); + writeMarshalUnmarshalCode(out, package, type, OptionalNone, false, 0, arg, false, iter, false); } } BuiltinPtr builtin = BuiltinPtr::dynamicCast(value); @@ -2190,7 +2180,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, string typeS = typeToString(type, TypeModeIn, package); out << nl << "for(" << typeS << " __elem : " << v << ')'; out << sb; - writeMarshalUnmarshalCode(out, package, type, OptionalNone, 0, "__elem", true, iter, false); + writeMarshalUnmarshalCode(out, package, type, OptionalNone, false, 0, "__elem", true, iter, false); out << eb; out << eb; // else } @@ -2237,13 +2227,13 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, ostringstream patchParams; patchParams << "new IceInternal.ListPatcher<" << origContentS << ">(" << v << ", " << origContentS << ".class, __type" << iter << ", __i" << iter << ')'; - writeMarshalUnmarshalCode(out, package, type, OptionalNone, 0, "__elem", false, iter, false, - StringList(), patchParams.str()); + writeMarshalUnmarshalCode(out, package, type, OptionalNone, false, 0, "__elem", false, iter, + false, StringList(), patchParams.str()); } else { out << nl << cont << " __elem;"; - writeMarshalUnmarshalCode(out, package, type, OptionalNone, 0, "__elem", false, iter, false); + writeMarshalUnmarshalCode(out, package, type, OptionalNone, false, 0, "__elem", false, iter, false); } if(!isObject) { @@ -2382,7 +2372,7 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, ostringstream o; o << v << "[__i" << iter << "]"; iter++; - writeMarshalUnmarshalCode(out, package, type, OptionalNone, 0, o.str(), true, iter, false); + writeMarshalUnmarshalCode(out, package, type, OptionalNone, false, 0, o.str(), true, iter, false); out << eb; out << eb; } @@ -2467,12 +2457,12 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, { patchParams << "new IceInternal.SequencePatcher(" << v << ", " << origContentS << ".class, __type" << iter << ", __i" << iter << ')'; - writeMarshalUnmarshalCode(out, package, type, OptionalNone, 0, o.str(), false, iter, false, - StringList(), patchParams.str()); + writeMarshalUnmarshalCode(out, package, type, OptionalNone, false, 0, o.str(), false, iter, + false, StringList(), patchParams.str()); } else { - writeMarshalUnmarshalCode(out, package, type, OptionalNone, 0, o.str(), false, iter, false); + writeMarshalUnmarshalCode(out, package, type, OptionalNone, false, 0, o.str(), false, iter, false); } out << eb; iter++; @@ -2485,7 +2475,7 @@ void Slice::JavaGenerator::writeStreamMarshalUnmarshalCode(Output& out, const string& package, const TypePtr& type, - OptionalMode optional, + bool optional, int tag, const string& param, bool marshal, @@ -2494,11 +2484,9 @@ Slice::JavaGenerator::writeStreamMarshalUnmarshalCode(Output& out, const StringList& metaData, const string& patchParams) { - assert(optional == OptionalNone || optional == OptionalMember); // Stream API doesn't support Ice.Optional<>. - string stream = marshal ? "__outS" : "__inS"; string v; - if(holder && optional == OptionalNone) + if(holder && !optional) { v = param + ".value"; } @@ -2616,7 +2604,7 @@ Slice::JavaGenerator::writeStreamMarshalUnmarshalCode(Output& out, } else { - if(holder && optional == OptionalNone) + if(holder && !optional) { out << nl << stream << ".readObject(" << param << ");"; } @@ -2638,7 +2626,7 @@ Slice::JavaGenerator::writeStreamMarshalUnmarshalCode(Output& out, { if(marshal) { - if(optional == OptionalMember) + if(optional) { out << nl << stream << ".startSize();"; out << nl << stream << ".writeProxy(" << v << ");"; @@ -2651,7 +2639,7 @@ Slice::JavaGenerator::writeStreamMarshalUnmarshalCode(Output& out, } else { - if(optional == OptionalMember) + if(optional) { out << nl << stream << ".skip(4);"; } @@ -2674,7 +2662,7 @@ Slice::JavaGenerator::writeStreamMarshalUnmarshalCode(Output& out, string typeS = typeToString(type, TypeModeIn, package); if(marshal) { - if(optional == OptionalMember) + if(optional) { out << nl << stream << ".startSize();"; out << nl << typeS << "Helper.write(" << stream << ", " << v << ");"; @@ -2687,7 +2675,7 @@ Slice::JavaGenerator::writeStreamMarshalUnmarshalCode(Output& out, } else { - if(optional == OptionalMember) + if(optional) { out << nl << stream << ".skip(4);"; } @@ -2705,7 +2693,7 @@ Slice::JavaGenerator::writeStreamMarshalUnmarshalCode(Output& out, } else { - if(holder && optional == OptionalNone) + if(holder && !optional) { out << nl << stream << ".readObject(" << param << ");"; } @@ -2729,7 +2717,7 @@ Slice::JavaGenerator::writeStreamMarshalUnmarshalCode(Output& out, { if(marshal) { - if(optional != OptionalNone) + if(optional) { if(st->isVariableLength()) { @@ -2751,7 +2739,7 @@ Slice::JavaGenerator::writeStreamMarshalUnmarshalCode(Output& out, else { string typeS = typeToString(type, TypeModeIn, package); - if(optional == OptionalMember) + if(optional) { if(st->isVariableLength()) { @@ -2791,7 +2779,7 @@ Slice::JavaGenerator::writeStreamMarshalUnmarshalCode(Output& out, DictionaryPtr dict = DictionaryPtr::dynamicCast(type); if(dict) { - if(optional != OptionalNone) + if(optional) { string typeS = typeToString(type, TypeModeIn, package, metaData); TypePtr keyType = dict->keyType(); @@ -2838,7 +2826,7 @@ Slice::JavaGenerator::writeStreamMarshalUnmarshalCode(Output& out, SequencePtr seq = SequencePtr::dynamicCast(type); if(seq) { - if(optional != OptionalNone) + if(optional) { string typeS = typeToString(type, TypeModeIn, package, metaData); TypePtr elemType = seq->type(); @@ -3066,7 +3054,7 @@ Slice::JavaGenerator::writeStreamDictionaryMarshalUnmarshalCode(Output& out, arg = "__e.getValue()"; type = value; } - writeStreamMarshalUnmarshalCode(out, package, type, OptionalNone, 0, arg, true, iter, false); + writeStreamMarshalUnmarshalCode(out, package, type, false, 0, arg, true, iter, false); } out << eb; out << eb; @@ -3101,7 +3089,7 @@ Slice::JavaGenerator::writeStreamDictionaryMarshalUnmarshalCode(Output& out, { string keyTypeStr = typeToObjectString(key, TypeModeIn, package); string valueTypeStr = typeToObjectString(value, TypeModeIn, package); - writeStreamMarshalUnmarshalCode(out, package, type, OptionalNone, 0, arg, false, iter, false, + writeStreamMarshalUnmarshalCode(out, package, type, false, 0, arg, false, iter, false, StringList(), "new IceInternal.DictionaryPatcher<" + keyTypeStr + ", " + valueTypeStr + ">(" + v + ", " + s + ".class, \"" + type->typeId() + "\", __key)"); @@ -3109,7 +3097,7 @@ Slice::JavaGenerator::writeStreamDictionaryMarshalUnmarshalCode(Output& out, else { out << nl << s << ' ' << arg << ';'; - writeStreamMarshalUnmarshalCode(out, package, type, OptionalNone, 0, arg, false, iter, false); + writeStreamMarshalUnmarshalCode(out, package, type, false, 0, arg, false, iter, false); } } BuiltinPtr builtin = BuiltinPtr::dynamicCast(value); @@ -3275,7 +3263,7 @@ Slice::JavaGenerator::writeStreamSequenceMarshalUnmarshalCode(Output& out, string typeS = typeToString(type, TypeModeIn, package); out << nl << "for(" << typeS << " __elem : " << v << ')'; out << sb; - writeStreamMarshalUnmarshalCode(out, package, type, OptionalNone, 0, "__elem", true, iter, false); + writeStreamMarshalUnmarshalCode(out, package, type, false, 0, "__elem", true, iter, false); out << eb; out << eb; // else } @@ -3322,13 +3310,13 @@ Slice::JavaGenerator::writeStreamSequenceMarshalUnmarshalCode(Output& out, ostringstream patchParams; patchParams << "new IceInternal.ListPatcher<" << origContentS << ">(" << v << ", " << origContentS << ".class, __type" << iter << ", __i" << iter << ')'; - writeStreamMarshalUnmarshalCode(out, package, type, OptionalNone, 0, "__elem", false, iter, false, + writeStreamMarshalUnmarshalCode(out, package, type, false, 0, "__elem", false, iter, false, StringList(), patchParams.str()); } else { out << nl << cont << " __elem;"; - writeStreamMarshalUnmarshalCode(out, package, type, OptionalNone, 0, "__elem", false, iter, false); + writeStreamMarshalUnmarshalCode(out, package, type, false, 0, "__elem", false, iter, false); } if(!isObject) { @@ -3467,7 +3455,7 @@ Slice::JavaGenerator::writeStreamSequenceMarshalUnmarshalCode(Output& out, ostringstream o; o << v << "[__i" << iter << "]"; iter++; - writeStreamMarshalUnmarshalCode(out, package, type, OptionalNone, 0, o.str(), true, iter, false); + writeStreamMarshalUnmarshalCode(out, package, type, false, 0, o.str(), true, iter, false); out << eb; out << eb; } @@ -3552,12 +3540,12 @@ Slice::JavaGenerator::writeStreamSequenceMarshalUnmarshalCode(Output& out, { patchParams << "new IceInternal.SequencePatcher(" << v << ", " << origContentS << ".class, __type" << iter << ", __i" << iter << ')'; - writeStreamMarshalUnmarshalCode(out, package, type, OptionalNone, 0, o.str(), false, iter, false, + writeStreamMarshalUnmarshalCode(out, package, type, false, 0, o.str(), false, iter, false, StringList(), patchParams.str()); } else { - writeStreamMarshalUnmarshalCode(out, package, type, OptionalNone, 0, o.str(), false, iter, false); + writeStreamMarshalUnmarshalCode(out, package, type, false, 0, o.str(), false, iter, false); } out << eb; iter++; diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp index 4a90ca266d0..9f85a9f5536 100755 --- a/cpp/src/slice2freezej/Main.cpp +++ b/cpp/src/slice2freezej/Main.cpp @@ -903,7 +903,7 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) out << nl << "__os.startWriteEncaps();"; } iter = 0; - writeMarshalUnmarshalCode(out, "", type, OptionalNone, 0, valS, true, iter, false); + writeMarshalUnmarshalCode(out, "", type, OptionalNone, false, 0, valS, true, iter, false); if(type->usesClasses()) { out << nl << "__os.writePendingObjects();"; @@ -996,7 +996,7 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) case Builtin::KindObjectProxy: case Builtin::KindLocalObject: { - writeMarshalUnmarshalCode(out, "", type, OptionalNone, 0, "__r", false, iter, false, metaData, + writeMarshalUnmarshalCode(out, "", type, OptionalNone, false, 0, "__r", false, iter, false, metaData, patchParams); break; } @@ -1004,7 +1004,8 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) } else { - writeMarshalUnmarshalCode(out, "", type, OptionalNone, 0, "__r", false, iter, false, metaData, patchParams); + writeMarshalUnmarshalCode(out, "", type, OptionalNone, false, 0, "__r", false, iter, false, metaData, + patchParams); } if(type->usesClasses()) { @@ -1069,7 +1070,7 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) out << nl << "IceInternal.BasicStream __os = " << "new IceInternal.BasicStream(IceInternal.Util.getInstance(communicator), encoding, true, false);"; int iter = 0; - writeMarshalUnmarshalCode(out, "", indexTypes[i], OptionalNone, 0, keyS, true, iter, false); + writeMarshalUnmarshalCode(out, "", indexTypes[i], OptionalNone, false, 0, keyS, true, iter, false); assert(!indexTypes[i]->usesClasses()); out << nl << "IceInternal.Buffer buf = __os.prepareWrite();"; @@ -1153,7 +1154,7 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) case Builtin::KindObjectProxy: case Builtin::KindLocalObject: { - writeMarshalUnmarshalCode(out, "", indexTypes[i], OptionalNone, 0, "r", false, iter, false, + writeMarshalUnmarshalCode(out, "", indexTypes[i], OptionalNone, false, 0, "r", false, iter, false, metaData, patchParams); break; } @@ -1161,8 +1162,8 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) } else { - writeMarshalUnmarshalCode(out, "", indexTypes[i], OptionalNone, 0, "r", false, iter, false, metaData, - patchParams); + writeMarshalUnmarshalCode(out, "", indexTypes[i], OptionalNone, false, 0, "r", false, iter, false, + metaData, patchParams); } out << nl << "return r;"; } @@ -1409,7 +1410,7 @@ FreezeGenerator::generate(UnitPtr& u, const Index& index) out << nl << "IceInternal.BasicStream __os = " << "new IceInternal.BasicStream(IceInternal.Util.getInstance(communicator()), encoding(), true, false);"; int iter = 0; - writeMarshalUnmarshalCode(out, "", dataMember->type(), OptionalNone, 0, valueS, true, iter, false); + writeMarshalUnmarshalCode(out, "", dataMember->type(), OptionalNone, false, 0, valueS, true, iter, false); if(type->usesClasses()) { out << nl << "__os.writePendingObjects();"; diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index 37879c13ca7..1327e24fb14 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -109,16 +109,23 @@ Slice::JavaVisitor::~JavaVisitor() } vector -Slice::JavaVisitor::getParams(const OperationPtr& op, const string& package) +Slice::JavaVisitor::getParams(const OperationPtr& op, const string& package, bool local) { vector params; + const bool optionalMapping = useOptionalMapping(op); + ParamDeclList paramList = op->parameters(); for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) { StringList metaData = (*q)->getMetaData(); + bool optional = (*q)->optional(); + if(optional && (local || (*q)->isOutParam())) + { + optional = optionalMapping; + } string typeString = typeToString((*q)->type(), (*q)->isOutParam() ? TypeModeOut : TypeModeIn, package, - metaData, true, (*q)->optional()); + metaData, true, optional); params.push_back(typeString + ' ' + fixKwd((*q)->name())); } @@ -130,12 +137,24 @@ Slice::JavaVisitor::getParamsProxy(const OperationPtr& op, const string& package { vector params; + const bool optionalMapping = useOptionalMapping(op); + ParamDeclList paramList = op->parameters(); for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) { + bool optional; + if((*q)->optional()) + { + optional = (*q)->isOutParam() ? true : optionalMapping; + } + else + { + optional = false; + } + StringList metaData = (*q)->getMetaData(); string typeString = typeToString((*q)->type(), (*q)->isOutParam() ? TypeModeOut : TypeModeIn, package, - metaData, true, useOptionalMapping(*q)); + metaData, true, optional); if(final) { typeString = "final " + typeString; @@ -151,15 +170,28 @@ Slice::JavaVisitor::getInOutParams(const OperationPtr& op, const string& package { vector params; + const bool optionalMapping = useOptionalMapping(op); + ParamDeclList paramList = op->parameters(); for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) { if((*q)->isOutParam() == (paramType == OutParam)) { - bool optional = (*q)->optional(); - if(optional && proxy) + bool optional; + if((*q)->optional()) { - optional = useOptionalMapping(*q); + if(proxy) + { + optional = paramType == InParam ? optionalMapping : true; + } + else + { + optional = true; + } + } + else + { + optional = false; } StringList metaData = (*q)->getMetaData(); string typeString = typeToString((*q)->type(), paramType == InParam ? TypeModeIn : TypeModeOut, package, @@ -186,14 +218,17 @@ Slice::JavaVisitor::getParamsAsync(const OperationPtr& op, const string& package } vector -Slice::JavaVisitor::getParamsAsyncCB(const OperationPtr& op, const string& package) +Slice::JavaVisitor::getParamsAsyncCB(const OperationPtr& op, const string& package, bool amd) { vector params; + const bool optionalMapping = amd ? useOptionalMapping(op) : true; + TypePtr ret = op->returnType(); if(ret) { - string retS = typeToString(ret, TypeModeIn, package, op->getMetaData(), true, op->returnIsOptional()); + string retS = typeToString(ret, TypeModeIn, package, op->getMetaData(), true, + optionalMapping && op->returnIsOptional()); params.push_back(retS + " __ret"); } @@ -203,7 +238,7 @@ Slice::JavaVisitor::getParamsAsyncCB(const OperationPtr& op, const string& packa if((*q)->isOutParam()) { string typeString = typeToString((*q)->type(), TypeModeIn, package, (*q)->getMetaData(), true, - (*q)->optional()); + optionalMapping && (*q)->optional()); params.push_back(typeString + ' ' + fixKwd((*q)->name())); } } @@ -291,7 +326,8 @@ Slice::JavaVisitor::getArgsAsyncCB(const OperationPtr& op) void Slice::JavaVisitor::writeMarshalUnmarshalParams(Output& out, const string& package, const ParamDeclList& params, - const OperationPtr& op, int& iter, bool marshal, bool dispatch) + const OperationPtr& op, int& iter, bool marshal, bool optionalMapping, + bool dispatch) { ParamDeclList optionals; ParamDeclList::const_iterator pli; @@ -311,8 +347,8 @@ Slice::JavaVisitor::writeMarshalUnmarshalParams(Output& out, const string& packa { patchParams = paramName; } - writeMarshalUnmarshalCode(out, package, (*pli)->type(), OptionalNone, 0, paramName, marshal, iter, holder, - (*pli)->getMetaData(), patchParams); + writeMarshalUnmarshalCode(out, package, (*pli)->type(), OptionalNone, false, 0, paramName, marshal, + iter, holder, (*pli)->getMetaData(), patchParams); } } @@ -325,13 +361,14 @@ Slice::JavaVisitor::writeMarshalUnmarshalParams(Output& out, const string& packa BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret); ClassDeclPtr cl = ClassDeclPtr::dynamicCast(ret); returnsObject = (builtin && builtin->kind() == Builtin::KindObject) || cl; + const bool optional = optionalMapping && op->returnIsOptional(); - string retS = typeToString(ret, TypeModeReturn, package, op->getMetaData(), true, op->returnIsOptional()); + string retS = typeToString(ret, TypeModeReturn, package, op->getMetaData(), true, optional); bool holder = false; if(!marshal) { - if(op->returnIsOptional()) + if(optional) { out << nl << retS << " __ret = new " << retS << "();"; } @@ -348,7 +385,7 @@ Slice::JavaVisitor::writeMarshalUnmarshalParams(Output& out, const string& packa if(!op->returnIsOptional()) { - writeMarshalUnmarshalCode(out, package, ret, OptionalNone, 0, "__ret", marshal, iter, holder, + writeMarshalUnmarshalCode(out, package, ret, OptionalNone, false, 0, "__ret", marshal, iter, holder, op->getMetaData()); } } @@ -375,29 +412,22 @@ Slice::JavaVisitor::writeMarshalUnmarshalParams(Output& out, const string& packa { if(checkReturnType && op->returnTag() < (*pli)->tag()) { - writeMarshalUnmarshalCode(out, package, ret, OptionalReturnParam, op->returnTag(), "__ret", marshal, iter, - false, op->getMetaData()); + writeMarshalUnmarshalCode(out, package, ret, OptionalReturnParam, optionalMapping, op->returnTag(), + "__ret", marshal, iter, false, op->getMetaData()); checkReturnType = false; } - OptionalMode mode; - if((*pli)->isOutParam()) - { - mode = OptionalOutParam; - } - else - { - mode = useOptionalMapping(*pli) ? OptionalInParamOpt : OptionalInParamReq; - } + const bool holder = dispatch && (*pli)->isOutParam() && !optionalMapping; - writeMarshalUnmarshalCode(out, package, (*pli)->type(), mode, (*pli)->tag(), fixKwd((*pli)->name()), marshal, - iter, false, (*pli)->getMetaData()); + writeMarshalUnmarshalCode(out, package, (*pli)->type(), + (*pli)->isOutParam() ? OptionalOutParam : OptionalInParam, optionalMapping, + (*pli)->tag(), fixKwd((*pli)->name()), marshal, iter, holder, (*pli)->getMetaData()); } if(checkReturnType) { - writeMarshalUnmarshalCode(out, package, ret, OptionalReturnParam, op->returnTag(), "__ret", marshal, iter, - false, op->getMetaData()); + writeMarshalUnmarshalCode(out, package, ret, OptionalReturnParam, optionalMapping, op->returnTag(), "__ret", + marshal, iter, false, op->getMetaData()); } } @@ -554,16 +584,16 @@ Slice::JavaVisitor::writeMarshalDataMember(Output& out, const string& package, c { if(!member->optional()) { - writeMarshalUnmarshalCode(out, package, member->type(), OptionalNone, 0, fixKwd(member->name()), true, iter, - false, member->getMetaData()); + writeMarshalUnmarshalCode(out, package, member->type(), OptionalNone, false, 0, fixKwd(member->name()), + true, iter, false, member->getMetaData()); } else { out << nl << "if(__has_" << member->name() << " && __os.writeOpt(" << member->tag() << ", " << getOptionalType(member->type()) << "))"; out << sb; - writeMarshalUnmarshalCode(out, package, member->type(), OptionalMember, 0, fixKwd(member->name()), true, iter, - false, member->getMetaData()); + writeMarshalUnmarshalCode(out, package, member->type(), OptionalMember, false, 0, fixKwd(member->name()), true, + iter, false, member->getMetaData()); out << eb; } } @@ -586,15 +616,15 @@ Slice::JavaVisitor::writeUnmarshalDataMember(Output& out, const string& package, if(!member->optional()) { - writeMarshalUnmarshalCode(out, package, member->type(), OptionalNone, 0, fixKwd(member->name()), false, iter, - false, member->getMetaData(), patchParams); + writeMarshalUnmarshalCode(out, package, member->type(), OptionalNone, false, 0, fixKwd(member->name()), false, + iter, false, member->getMetaData(), patchParams); } else { out << nl << "if(__has_" << member->name() << " = __is.readOpt(" << member->tag() << ", " << getOptionalType(member->type()) << "))"; out << sb; - writeMarshalUnmarshalCode(out, package, member->type(), OptionalMember, 0, fixKwd(member->name()), false, + writeMarshalUnmarshalCode(out, package, member->type(), OptionalMember, false, 0, fixKwd(member->name()), false, iter, false, member->getMetaData(), patchParams); out << eb; } @@ -880,7 +910,8 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr& string deprecateReason = getDeprecateReason(op, cl, "operation"); - bool amd = cl->hasMetaData("amd") || op->hasMetaData("amd"); + const bool amd = cl->hasMetaData("amd") || op->hasMetaData("amd"); + const bool optionalMapping = useOptionalMapping(op); vector params; vector args; @@ -962,7 +993,8 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr& writeDocComment(out, op, deprecateReason); } out << nl << "public final " - << typeToString(ret, TypeModeReturn, package, op->getMetaData(), true, op->returnIsOptional()) + << typeToString(ret, TypeModeReturn, package, op->getMetaData(), true, + optionalMapping && op->returnIsOptional()) << nl << opName << spar << params << epar; if(op->hasMetaData("UserException")) { @@ -1009,7 +1041,9 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr& << " __obj, IceInternal.Incoming __inS, Ice.Current __current)"; out << sb; - bool amd = cl->hasMetaData("amd") || op->hasMetaData("amd"); + const bool amd = cl->hasMetaData("amd") || op->hasMetaData("amd"); + const bool optionalMapping = useOptionalMapping(op); + if(!amd) { TypePtr ret = op->returnType(); @@ -1080,7 +1114,7 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr& } } iter = 0; - writeMarshalUnmarshalParams(out, package, inParams, 0, iter, false, true); + writeMarshalUnmarshalParams(out, package, inParams, 0, iter, false, true, true); out << nl << "__inS.endReadParams();"; } else @@ -1094,7 +1128,7 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr& for(pli = outParams.begin(); pli != outParams.end(); ++pli) { string typeS = typeToString((*pli)->type(), TypeModeOut, package, (*pli)->getMetaData(), true, - (*pli)->optional()); + optionalMapping && (*pli)->optional()); out << nl << typeS << ' ' << fixKwd((*pli)->name()) << " = new " << typeS << "();"; } @@ -1109,7 +1143,8 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr& out << nl; if(ret) { - string retS = typeToString(ret, TypeModeReturn, package, opMetaData, true, op->returnIsOptional()); + string retS = typeToString(ret, TypeModeReturn, package, opMetaData, true, + optionalMapping && op->returnIsOptional()); out << retS << " __ret = "; } out << "__obj." << fixKwd(opName) << '('; @@ -1144,7 +1179,7 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr& { out << nl << "__os.format(" << formatTypeToString(format) << ");"; } - writeMarshalUnmarshalParams(out, package, outParams, op, iter, true, true); + writeMarshalUnmarshalParams(out, package, outParams, op, iter, true, optionalMapping, true); out << nl << "__inS.__endWriteParams(true);"; } else @@ -1205,24 +1240,28 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr& 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)) + string typeS = typeToString(paramType, TypeModeIn, package, (*pli)->getMetaData(), + true, (*pli)->optional()); + if((*pli)->optional()) { - out << nl << typeS << "Holder " << paramName << " = new " << typeS << "Holder();"; - writeMarshalUnmarshalCode(out, package, paramType, OptionalNone, 0, paramName, false, iter, - true, metaData, string()); + out << nl << typeS << ' ' << paramName << " = new " << typeS << "();"; } else { - out << nl << typeS << ' ' << paramName << ';'; - writeMarshalUnmarshalCode(out, package, paramType, OptionalNone, 0, paramName, false, iter, - false, metaData); + 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 << ';'; + } } } + writeMarshalUnmarshalParams(out, package, inParams, 0, iter, false, true, true); out << nl << "__inS.endReadParams();"; } else @@ -1243,10 +1282,13 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr& { TypePtr paramType = (*pli)->type(); out << fixKwd((*pli)->name()); - BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType)) + if(!(*pli)->optional()) { - out << ".value"; + BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType); + if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType)) + { + out << ".value"; + } } out << ", "; } @@ -2357,7 +2399,8 @@ Slice::Gen::OpsVisitor::writeOperations(const ClassDefPtr& p, bool noCurrent) TypePtr ret; vector params; - bool amd = !p->isLocal() && (cl->hasMetaData("amd") || op->hasMetaData("amd")); + const bool amd = !p->isLocal() && (cl->hasMetaData("amd") || op->hasMetaData("amd")); + const bool optionalMapping = useOptionalMapping(op); if(amd) { @@ -2369,7 +2412,8 @@ Slice::Gen::OpsVisitor::writeOperations(const ClassDefPtr& p, bool noCurrent) ret = op->returnType(); } - string retS = typeToString(ret, TypeModeReturn, package, op->getMetaData(), true, op->returnIsOptional()); + string retS = typeToString(ret, TypeModeReturn, package, op->getMetaData(), true, + optionalMapping && op->returnIsOptional()); ExceptionList throws = op->throws(); throws.sort(); throws.unique(); @@ -2528,7 +2572,9 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p) { ContainerPtr container = (*r)->container(); ClassDefPtr cl = ClassDefPtr::dynamicCast(container); - bool hasAMD = cl->hasMetaData("amd") || (*r)->hasMetaData("amd"); + const bool hasAMD = cl->hasMetaData("amd") || (*r)->hasMetaData("amd"); + const bool optionalMapping = useOptionalMapping(*r); + #if defined(__SUNPRO_CC) && (__SUNPRO_CC==0x550) // // Work around for Sun CC 5.5 bug #4853566 @@ -2545,8 +2591,10 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p) #else string opName = hasAMD ? (*r)->name() + "_async" : fixKwd((*r)->name()); #endif + TypePtr ret = (*r)->returnType(); - string retS = typeToString(ret, TypeModeReturn, package, (*r)->getMetaData()); + string retS = typeToString(ret, TypeModeReturn, package, (*r)->getMetaData(), true, + optionalMapping && (*r)->returnIsOptional()); vector params; vector args; @@ -2780,7 +2828,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) // // For local classes and interfaces, we don't use the OperationsNC interface. - // Instead, we generated the operation signatures directly into the class + // Instead, we generate the operation signatures directly into the class // or interface. // if(p->isLocal()) @@ -2793,12 +2841,13 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) ContainerPtr container = op->container(); ClassDefPtr cl = ClassDefPtr::dynamicCast(container); string opname = op->name(); + const bool optionalMapping = useOptionalMapping(op); - TypePtr ret; - vector params = getParams(op, package); - ret = op->returnType(); + TypePtr ret = op->returnType(); + vector params = getParams(op, package, true); - string retS = typeToString(ret, TypeModeReturn, package, op->getMetaData()); + string retS = typeToString(ret, TypeModeReturn, package, op->getMetaData(), true, + optionalMapping && op->returnIsOptional()); ExceptionList throws = op->throws(); throws.sort(); throws.unique(); @@ -4418,6 +4467,8 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) vector params = getParamsProxy(op, package); vector args = getArgs(op); + const bool optionalMapping = useOptionalMapping(op); + ExceptionList throws = op->throws(); throws.sort(); throws.unique(); @@ -4615,7 +4666,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) pl.push_back(*pli); } } - writeMarshalUnmarshalParams(out, package, pl, 0, iter, true); + writeMarshalUnmarshalParams(out, package, pl, 0, iter, true, optionalMapping); out << nl << "__result.__endWriteParams();"; } else @@ -4688,7 +4739,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) pl.push_back(*pli); } } - writeMarshalUnmarshalParams(out, package, pl, op, iter, false); + writeMarshalUnmarshalParams(out, package, pl, op, iter, false, true); out << nl << "__result.__endReadParams();"; } else @@ -5562,6 +5613,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) string opName = fixKwd(op->name()); TypePtr ret = op->returnType(); string retS = typeToString(ret, TypeModeReturn, package, opMetaData, true, op->returnIsOptional()); + const bool optionalMapping = useOptionalMapping(op); int iter = 0; ParamDeclList inParams; @@ -5617,7 +5669,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) { out << nl << "__os.format(" << formatTypeToString(format) << ");"; } - writeMarshalUnmarshalParams(out, package, inParams, 0, iter, true); + writeMarshalUnmarshalParams(out, package, inParams, 0, iter, true, optionalMapping); out << nl << "__og.endWriteParams();"; out << eb; out << nl << "catch(Ice.LocalException __ex)"; @@ -5660,7 +5712,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) if(ret || !outParams.empty()) { out << nl << "IceInternal.BasicStream __is = __og.startReadParams();"; - writeMarshalUnmarshalParams(out, package, outParams, op, iter, false); + writeMarshalUnmarshalParams(out, package, outParams, op, iter, false, true); out << nl << "__og.endReadParams();"; } else @@ -5742,6 +5794,7 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) ClassDefPtr cl = ClassDefPtr::dynamicCast(container); string opName = fixKwd(op->name()); TypePtr ret = op->returnType(); + const bool optionalMapping = useOptionalMapping(op); string retS = typeToString(ret, TypeModeReturn, package, op->getMetaData(), true, op->returnIsOptional()); ExceptionList throws = op->throws(); @@ -5763,25 +5816,6 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) vector params = getParamsProxy(op, package, true); - // - // Collect the arguments that will be passed to the servant. - // - // Note that for optional in parameters, we may have to wrap a value - // in an Optional object to be compatible with the servant's signature. - // - vector args; - ParamDeclList paramList = op->parameters(); - for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) - { - string param = fixKwd((*q)->name()); - if(!(*q)->isOutParam() && (*q)->optional() && !useOptionalMapping(*q)) - { - string typeString = typeToString((*q)->type(), TypeModeIn, package, (*q)->getMetaData(), true, true); - param = "new " + typeString + "(" + param + ")"; - } - args.push_back(param); - } - out << sp; if(!deprecateReason.empty()) { @@ -5837,27 +5871,87 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) out << sb; } + // + // Collect the arguments that will be passed to the servant. + // + vector args; + ParamDeclList paramList = op->parameters(); + ParamDeclList::const_iterator q; + for(q = paramList.begin(); q != paramList.end(); ++q) + { + string param = fixKwd((*q)->name()); + // + // For optional parameters, the proxy mapping can differ from the servant + // mapping, depending on whether the optional mapping is being used. + // + if((*q)->optional() && !optionalMapping) + { + if((*q)->isOutParam()) + { + param = "__" + (*q)->name(); + string typeS = typeToString((*q)->type(), TypeModeOut, package, (*q)->getMetaData()); + out << nl << typeS << ' ' << param << " = new " << typeS << "();"; + } + else + { + string typeS = typeToString((*q)->type(), TypeModeIn, package, (*q)->getMetaData(), true, true); + param = "new " + typeS + "(" + param + ")"; + } + } + args.push_back(param); + } + out << nl; if(ret) { if(op->returnIsOptional()) { - out << resultType << " __r = "; + if(optionalMapping) + { + out << resultType << " __r = "; + } + else + { + out << typeToString(ret, TypeModeIn, package, op->getMetaData()) << " __r = "; + } } else { out << "__result.value = "; } } + out << "__servant." << opName << spar << args << "__current" << epar << ';'; - if(op->returnIsOptional()) + + for(q = paramList.begin(); q != paramList.end(); ++q) { - out << nl << "if(__r != null && __r.isSet())"; - out << sb; - out << nl << "__result.set(__r.get());"; - out << eb; + // + // For optional parameters, the proxy mapping can differ from the servant + // mapping, depending on whether the optional mapping is being used. + // + if((*q)->optional() && !optionalMapping && (*q)->isOutParam()) + { + out << nl << fixKwd((*q)->name()) << ".set(__" << (*q)->name() << ".value);"; + } + } + + if(ret && op->returnIsOptional()) + { + if(optionalMapping) + { + out << nl << "if(__r != null && __r.isSet())"; + out << sb; + out << nl << "__result.set(__r.get());"; + out << eb; + } + else + { + out << nl << "__result.set(__r);"; + } } + out << nl << "return Ice.DispatchStatus.DispatchOK;"; + if(!throws.empty()) { out << eb; @@ -5991,129 +6085,144 @@ Slice::Gen::BaseImplVisitor::BaseImplVisitor(const string& dir) : void Slice::Gen::BaseImplVisitor::writeDecl(Output& out, const string& package, const string& name, const TypePtr& type, - const StringList& metaData) + const StringList& metaData, bool optional) { - out << nl << typeToString(type, TypeModeIn, package, metaData) << ' ' << name; + string typeS = typeToString(type, TypeModeIn, package, metaData, true, optional); + out << nl << typeS << ' ' << name; - BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); - if(builtin) + if(optional) { - switch(builtin->kind()) + out << " = new " << typeS << "();"; + } + else + { + BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); + if(builtin) { - case Builtin::KindBool: - { - out << " = false"; - break; - } - case Builtin::KindByte: - { - out << " = (byte)0"; - break; - } - case Builtin::KindShort: + switch(builtin->kind()) { - out << " = (short)0"; - break; - } - case Builtin::KindInt: - case Builtin::KindLong: - { - out << " = 0"; - break; - } - case Builtin::KindFloat: - { - out << " = (float)0.0"; - break; - } - case Builtin::KindDouble: - { - out << " = 0.0"; - break; + case Builtin::KindBool: + { + out << " = false"; + break; + } + case Builtin::KindByte: + { + out << " = (byte)0"; + break; + } + case Builtin::KindShort: + { + out << " = (short)0"; + break; + } + case Builtin::KindInt: + case Builtin::KindLong: + { + out << " = 0"; + break; + } + case Builtin::KindFloat: + { + out << " = (float)0.0"; + break; + } + case Builtin::KindDouble: + { + out << " = 0.0"; + break; + } + case Builtin::KindString: + { + out << " = \"\""; + break; + } + case Builtin::KindObject: + case Builtin::KindObjectProxy: + case Builtin::KindLocalObject: + { + out << " = null"; + break; + } } - case Builtin::KindString: + } + else + { + EnumPtr en = EnumPtr::dynamicCast(type); + if(en) { - out << " = \"\""; - break; + EnumeratorList enumerators = en->getEnumerators(); + out << " = " << getAbsolute(en, package) << '.' << fixKwd(enumerators.front()->name()); } - case Builtin::KindObject: - case Builtin::KindObjectProxy: - case Builtin::KindLocalObject: + else { out << " = null"; - break; } } - } - else - { - EnumPtr en = EnumPtr::dynamicCast(type); - if(en) - { - EnumeratorList enumerators = en->getEnumerators(); - out << " = " << getAbsolute(en, package) << '.' << fixKwd(enumerators.front()->name()); - } - else - { - out << " = null"; - } - } - out << ';'; + out << ';'; + } } void -Slice::Gen::BaseImplVisitor::writeReturn(Output& out, const TypePtr& type) +Slice::Gen::BaseImplVisitor::writeReturn(Output& out, const TypePtr& type, bool optional) { - BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); - if(builtin) + if(optional) { - switch(builtin->kind()) + out << nl << "return null;"; + } + else + { + BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); + if(builtin) { - case Builtin::KindBool: - { - out << nl << "return false;"; - break; - } - case Builtin::KindByte: + switch(builtin->kind()) { - out << nl << "return (byte)0;"; - break; - } - case Builtin::KindShort: - { - out << nl << "return (short)0;"; - break; - } - case Builtin::KindInt: - case Builtin::KindLong: - { - out << nl << "return 0;"; - break; - } - case Builtin::KindFloat: - { - out << nl << "return (float)0.0;"; - break; - } - case Builtin::KindDouble: - { - out << nl << "return 0.0;"; - break; - } - case Builtin::KindString: - case Builtin::KindObject: - case Builtin::KindObjectProxy: - case Builtin::KindLocalObject: - { - out << nl << "return null;"; - break; + case Builtin::KindBool: + { + out << nl << "return false;"; + break; + } + case Builtin::KindByte: + { + out << nl << "return (byte)0;"; + break; + } + case Builtin::KindShort: + { + out << nl << "return (short)0;"; + break; + } + case Builtin::KindInt: + case Builtin::KindLong: + { + out << nl << "return 0;"; + break; + } + case Builtin::KindFloat: + { + out << nl << "return (float)0.0;"; + break; + } + case Builtin::KindDouble: + { + out << nl << "return 0.0;"; + break; + } + case Builtin::KindString: + case Builtin::KindObject: + case Builtin::KindObjectProxy: + case Builtin::KindLocalObject: + { + out << nl << "return null;"; + break; + } } + return; } - return; - } - out << nl << "return null;"; + out << nl << "return null;"; + } } void @@ -6122,8 +6231,10 @@ Slice::Gen::BaseImplVisitor::writeOperation(Output& out, const string& package, string opName = op->name(); TypePtr ret = op->returnType(); + const bool optionalMapping = useOptionalMapping(op); StringList opMetaData = op->getMetaData(); - string retS = typeToString(ret, TypeModeReturn, package, opMetaData); + string retS = typeToString(ret, TypeModeReturn, package, opMetaData, true, + optionalMapping && op->returnIsOptional()); vector params = getParams(op, package); ContainerPtr container = op->container(); @@ -6168,13 +6279,14 @@ Slice::Gen::BaseImplVisitor::writeOperation(Output& out, const string& package, } if(ret) { - writeDecl(out, package, result, ret, opMetaData); + writeDecl(out, package, result, ret, opMetaData, optionalMapping && op->returnIsOptional()); } for(q = paramList.begin(); q != paramList.end(); ++q) { if((*q)->isOutParam()) { - writeDecl(out, package, fixKwd((*q)->name()), (*q)->type(), (*q)->getMetaData()); + writeDecl(out, package, fixKwd((*q)->name()), (*q)->type(), (*q)->getMetaData(), + optionalMapping && (*q)->optional()); } } @@ -6231,7 +6343,7 @@ Slice::Gen::BaseImplVisitor::writeOperation(Output& out, const string& package, // if(ret) { - writeReturn(out, ret); + writeReturn(out, ret, optionalMapping && op->returnIsOptional()); } out << eb; @@ -6432,7 +6544,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) ExceptionList throws = p->throws(); - vector params = getParamsAsyncCB(p, classPkg); + vector params = getParamsAsyncCB(p, classPkg, false); vector args = getInOutArgs(p, OutParam); writeDocCommentOp(out, p); @@ -6529,7 +6641,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) ExceptionList throws = p->throws(); - vector params = getParamsAsyncCB(p, classPkg); + vector params = getParamsAsyncCB(p, classPkg, false); vector args = getInOutArgs(p, OutParam); writeDocCommentOp(out, p); @@ -6596,7 +6708,9 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) string classNameAMDI = "_AMD_" + cl->name(); string absoluteAMDI = getAbsolute(cl, "", "_AMD_", "_" + name); - vector paramsAMD = getParamsAsyncCB(p, classPkg); + vector paramsAMD = getParamsAsyncCB(p, classPkg, true); + + const bool optionalMapping = useOptionalMapping(p); { open(absoluteAMD, p->file()); @@ -6676,19 +6790,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) { out << nl << "__os.format(" << formatTypeToString(format) << ");"; } - 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(), OptionalNone, 0, fixKwd((*pli)->name()), - true, iter, false, metaData); - } - if(ret) - { - string retS = typeToString(ret, TypeModeIn, classPkg, opMetaData); - writeMarshalUnmarshalCode(out, classPkg, ret, OptionalNone, 0, "__ret", true, iter, false, - opMetaData); - } + writeMarshalUnmarshalParams(out, classPkg, outParams, p, iter, true, optionalMapping, false); out << nl << "this.__endWriteParams(true);"; out << eb; out << nl << "catch(Ice.LocalException __ex)"; diff --git a/cpp/src/slice2java/Gen.h b/cpp/src/slice2java/Gen.h index 5cfeae3714a..94f0dc95a2d 100644 --- a/cpp/src/slice2java/Gen.h +++ b/cpp/src/slice2java/Gen.h @@ -32,11 +32,11 @@ protected: // // Compose the parameter lists for an operation. // - std::vector getParams(const OperationPtr&, const std::string&); + std::vector getParams(const OperationPtr&, const std::string&, bool = false); std::vector getParamsProxy(const OperationPtr&, const std::string&, bool = false); std::vector getInOutParams(const OperationPtr&, const std::string&, ParamDir, bool); std::vector getParamsAsync(const OperationPtr&, const std::string&, bool); - std::vector getParamsAsyncCB(const OperationPtr&, const std::string&); + std::vector getParamsAsyncCB(const OperationPtr&, const std::string&, bool); // // Compose the argument lists for an operation. @@ -47,7 +47,7 @@ protected: std::vector getArgsAsyncCB(const OperationPtr&); void writeMarshalUnmarshalParams(::IceUtilInternal::Output&, const std::string&, const ParamDeclList&, - const OperationPtr&, int&, bool, bool = false); + const OperationPtr&, int&, bool, bool, bool = false); // // Generate a throws clause containing only non-local exceptions. @@ -290,12 +290,13 @@ private: // Generate code to emit a local variable declaration and initialize it // if necessary. // - void writeDecl(::IceUtilInternal::Output&, const std::string&, const std::string&, const TypePtr&, const StringList&); + void writeDecl(::IceUtilInternal::Output&, const std::string&, const std::string&, const TypePtr&, + const StringList&, bool); // // Generate code to return a value. // - void writeReturn(::IceUtilInternal::Output&, const TypePtr&); + void writeReturn(::IceUtilInternal::Output&, const TypePtr&, bool); // // Generate an operation. diff --git a/java/build.xml b/java/build.xml index abb6569e399..4164c47b28d 100644 --- a/java/build.xml +++ b/java/build.xml @@ -577,6 +577,7 @@ + diff --git a/java/test/Ice/optional/AMDInitialI.java b/java/test/Ice/optional/AMDInitialI.java new file mode 100644 index 00000000000..732b0152b46 --- /dev/null +++ b/java/test/Ice/optional/AMDInitialI.java @@ -0,0 +1,428 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package test.Ice.optional; + +import test.Ice.optional.AMD.Test.*; + +public final class AMDInitialI extends Initial +{ + public void + shutdown_async(AMD_Initial_shutdown cb, Ice.Current current) + { + current.adapter.getCommunicator().shutdown(); + cb.ice_response(); + } + + public void + pingPong_async(AMD_Initial_pingPong cb, Ice.Object obj, Ice.Current current) + { + cb.ice_response(obj); + } + + public void + opOptionalException_async(AMD_Initial_opOptionalException cb, Ice.IntOptional a, Ice.Optional b, + Ice.Optional o, Ice.Current current) + throws OptionalException + { + OptionalException ex = new OptionalException(); + if(a.isSet()) + { + ex.setA(a.get()); + } + else + { + ex.clearA(); // The member "a" has a default value. + } + if(b.isSet()) + { + ex.setB(b.get()); + } + if(o.isSet()) + { + ex.setO(o.get()); + } + cb.ice_exception(ex); + } + + public void + opByte_async(AMD_Initial_opByte cb, Ice.ByteOptional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opByteOpt_async(AMD_Initial_opByteOpt cb, Ice.ByteOptional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opBool_async(AMD_Initial_opBool cb, Ice.BooleanOptional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opBoolOpt_async(AMD_Initial_opBoolOpt cb, Ice.BooleanOptional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opShort_async(AMD_Initial_opShort cb, Ice.ShortOptional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opShortOpt_async(AMD_Initial_opShortOpt cb, Ice.ShortOptional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opInt_async(AMD_Initial_opInt cb, Ice.IntOptional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opIntOpt_async(AMD_Initial_opIntOpt cb, Ice.IntOptional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opLong_async(AMD_Initial_opLong cb, Ice.LongOptional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opLongOpt_async(AMD_Initial_opLongOpt cb, Ice.LongOptional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opFloat_async(AMD_Initial_opFloat cb, Ice.FloatOptional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opFloatOpt_async(AMD_Initial_opFloatOpt cb, Ice.FloatOptional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opDouble_async(AMD_Initial_opDouble cb, Ice.DoubleOptional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opDoubleOpt_async(AMD_Initial_opDoubleOpt cb, Ice.DoubleOptional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opString_async(AMD_Initial_opString cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opStringOpt_async(AMD_Initial_opStringOpt cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opMyEnum_async(AMD_Initial_opMyEnum cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opMyEnumOpt_async(AMD_Initial_opMyEnumOpt cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opSmallStruct_async(AMD_Initial_opSmallStruct cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opSmallStructOpt_async(AMD_Initial_opSmallStructOpt cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opFixedStruct_async(AMD_Initial_opFixedStruct cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opFixedStructOpt_async(AMD_Initial_opFixedStructOpt cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opVarStruct_async(AMD_Initial_opVarStruct cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opVarStructOpt_async(AMD_Initial_opVarStructOpt cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opOneOptional_async(AMD_Initial_opOneOptional cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opOneOptionalOpt_async(AMD_Initial_opOneOptionalOpt cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opOneOptionalProxy_async(AMD_Initial_opOneOptionalProxy cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opOneOptionalProxyOpt_async(AMD_Initial_opOneOptionalProxyOpt cb, Ice.Optional p1, + Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opByteSeq_async(AMD_Initial_opByteSeq cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opByteSeqOpt_async(AMD_Initial_opByteSeqOpt cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opBoolSeq_async(AMD_Initial_opBoolSeq cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opBoolSeqOpt_async(AMD_Initial_opBoolSeqOpt cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opShortSeq_async(AMD_Initial_opShortSeq cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opShortSeqOpt_async(AMD_Initial_opShortSeqOpt cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opIntSeq_async(AMD_Initial_opIntSeq cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opIntSeqOpt_async(AMD_Initial_opIntSeqOpt cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opLongSeq_async(AMD_Initial_opLongSeq cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opLongSeqOpt_async(AMD_Initial_opLongSeqOpt cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opFloatSeq_async(AMD_Initial_opFloatSeq cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opFloatSeqOpt_async(AMD_Initial_opFloatSeqOpt cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opDoubleSeq_async(AMD_Initial_opDoubleSeq cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opDoubleSeqOpt_async(AMD_Initial_opDoubleSeqOpt cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opStringSeq_async(AMD_Initial_opStringSeq cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opStringSeqOpt_async(AMD_Initial_opStringSeqOpt cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opSmallStructSeq_async(AMD_Initial_opSmallStructSeq cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opSmallStructSeqOpt_async(AMD_Initial_opSmallStructSeqOpt cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opSmallStructList_async(AMD_Initial_opSmallStructList cb, Ice.Optional> p1, + Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opSmallStructListOpt_async(AMD_Initial_opSmallStructListOpt cb, Ice.Optional> p1, + Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opFixedStructSeq_async(AMD_Initial_opFixedStructSeq cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opFixedStructSeqOpt_async(AMD_Initial_opFixedStructSeqOpt cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opFixedStructList_async(AMD_Initial_opFixedStructList cb, Ice.Optional> p1, + Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opFixedStructListOpt_async(AMD_Initial_opFixedStructListOpt cb, Ice.Optional> p1, + Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opVarStructSeq_async(AMD_Initial_opVarStructSeq cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opVarStructSeqOpt_async(AMD_Initial_opVarStructSeqOpt cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opSerializable_async(AMD_Initial_opSerializable cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opSerializableOpt_async(AMD_Initial_opSerializableOpt cb, Ice.Optional p1, Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opIntIntDict_async(AMD_Initial_opIntIntDict cb, Ice.Optional> p1, + Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opIntIntDictOpt_async(AMD_Initial_opIntIntDictOpt cb, Ice.Optional> p1, + Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opStringIntDict_async(AMD_Initial_opStringIntDict cb, Ice.Optional> p1, + Ice.Current current) + { + cb.ice_response(p1.get(), p1.get()); + } + + public void + opStringIntDictOpt_async(AMD_Initial_opStringIntDictOpt cb, Ice.Optional> p1, + Ice.Current current) + { + cb.ice_response(p1, p1); + } + + public void + opClassAndUnknownOptional_async(AMD_Initial_opClassAndUnknownOptional cb, A p, Ice.Current current) + { + cb.ice_response(); + } +} diff --git a/java/test/Ice/optional/AMDServer.java b/java/test/Ice/optional/AMDServer.java new file mode 100644 index 00000000000..df5550d0544 --- /dev/null +++ b/java/test/Ice/optional/AMDServer.java @@ -0,0 +1,39 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package test.Ice.optional; + +public class AMDServer extends test.Util.Application +{ + public int run(String[] args) + { + communicator().getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp"); + Ice.ObjectAdapter adapter = communicator().createObjectAdapter("TestAdapter"); + adapter.add(new AMDInitialI(), communicator().stringToIdentity("initial")); + adapter.activate(); + return WAIT; + } + + protected Ice.InitializationData getInitData(Ice.StringSeqHolder argsH) + { + Ice.InitializationData initData = new Ice.InitializationData(); + initData.properties = Ice.Util.createProperties(argsH); + initData.properties.setProperty("Ice.Package.Test", "test.Ice.optional.AMD"); + return initData; + } + + public static void main(String[] args) + { + AMDServer c = new AMDServer(); + int status = c.main("Server", args); + + System.gc(); + System.exit(status); + } +} diff --git a/java/test/Ice/optional/InitialI.java b/java/test/Ice/optional/InitialI.java index 31df8707394..2acba8b6158 100644 --- a/java/test/Ice/optional/InitialI.java +++ b/java/test/Ice/optional/InitialI.java @@ -50,11 +50,11 @@ public final class InitialI extends Initial throw ex; } - public Ice.ByteOptional - opByte(Ice.ByteOptional p1, Ice.ByteOptional p3, Ice.Current current) + public byte + opByte(Ice.ByteOptional p1, Ice.ByteHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.ByteOptional @@ -64,11 +64,11 @@ public final class InitialI extends Initial return p1; } - public Ice.BooleanOptional - opBool(Ice.BooleanOptional p1, Ice.BooleanOptional p3, Ice.Current current) + public boolean + opBool(Ice.BooleanOptional p1, Ice.BooleanHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.BooleanOptional @@ -78,11 +78,11 @@ public final class InitialI extends Initial return p1; } - public Ice.ShortOptional - opShort(Ice.ShortOptional p1, Ice.ShortOptional p3, Ice.Current current) + public short + opShort(Ice.ShortOptional p1, Ice.ShortHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.ShortOptional @@ -92,11 +92,11 @@ public final class InitialI extends Initial return p1; } - public Ice.IntOptional - opInt(Ice.IntOptional p1, Ice.IntOptional p3, Ice.Current current) + public int + opInt(Ice.IntOptional p1, Ice.IntHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.IntOptional @@ -106,11 +106,11 @@ public final class InitialI extends Initial return p1; } - public Ice.LongOptional - opLong(Ice.LongOptional p1, Ice.LongOptional p3, Ice.Current current) + public long + opLong(Ice.LongOptional p1, Ice.LongHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.LongOptional @@ -120,11 +120,11 @@ public final class InitialI extends Initial return p1; } - public Ice.FloatOptional - opFloat(Ice.FloatOptional p1, Ice.FloatOptional p3, Ice.Current current) + public float + opFloat(Ice.FloatOptional p1, Ice.FloatHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.FloatOptional @@ -134,11 +134,11 @@ public final class InitialI extends Initial return p1; } - public Ice.DoubleOptional - opDouble(Ice.DoubleOptional p1, Ice.DoubleOptional p3, Ice.Current current) + public double + opDouble(Ice.DoubleOptional p1, Ice.DoubleHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.DoubleOptional @@ -148,11 +148,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional - opString(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public String + opString(Ice.Optional p1, Ice.StringHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional @@ -162,11 +162,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional - opMyEnum(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public MyEnum + opMyEnum(Ice.Optional p1, MyEnumHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional @@ -176,11 +176,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional - opSmallStruct(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public SmallStruct + opSmallStruct(Ice.Optional p1, SmallStructHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional @@ -190,11 +190,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional - opFixedStruct(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public FixedStruct + opFixedStruct(Ice.Optional p1, FixedStructHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional @@ -204,11 +204,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional - opVarStruct(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public VarStruct + opVarStruct(Ice.Optional p1, VarStructHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional @@ -218,11 +218,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional - opOneOptional(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public OneOptional + opOneOptional(Ice.Optional p1, OneOptionalHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional @@ -232,11 +232,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional - opOneOptionalProxy(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public OneOptionalPrx + opOneOptionalProxy(Ice.Optional p1, OneOptionalPrxHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional @@ -246,11 +246,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional - opByteSeq(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public byte[] + opByteSeq(Ice.Optional p1, ByteSeqHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional @@ -260,11 +260,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional - opBoolSeq(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public boolean[] + opBoolSeq(Ice.Optional p1, BoolSeqHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional @@ -274,11 +274,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional - opShortSeq(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public short[] + opShortSeq(Ice.Optional p1, ShortSeqHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional @@ -288,11 +288,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional - opIntSeq(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public int[] + opIntSeq(Ice.Optional p1, IntSeqHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional @@ -302,11 +302,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional - opLongSeq(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public long[] + opLongSeq(Ice.Optional p1, LongSeqHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional @@ -316,11 +316,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional - opFloatSeq(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public float[] + opFloatSeq(Ice.Optional p1, FloatSeqHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional @@ -330,11 +330,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional - opDoubleSeq(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public double[] + opDoubleSeq(Ice.Optional p1, DoubleSeqHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional @@ -344,11 +344,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional - opStringSeq(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public String[] + opStringSeq(Ice.Optional p1, StringSeqHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional @@ -358,11 +358,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional - opSmallStructSeq(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public SmallStruct[] + opSmallStructSeq(Ice.Optional p1, SmallStructSeqHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional @@ -372,12 +372,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional> - opSmallStructList(Ice.Optional> p1, - Ice.Optional> p3, Ice.Current current) + public java.util.List + opSmallStructList(Ice.Optional> p1, SmallStructListHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional> @@ -388,11 +387,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional - opFixedStructSeq(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public FixedStruct[] + opFixedStructSeq(Ice.Optional p1, FixedStructSeqHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional @@ -402,12 +401,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional> - opFixedStructList(Ice.Optional> p1, - Ice.Optional> p3, Ice.Current current) + public java.util.List + opFixedStructList(Ice.Optional> p1, FixedStructListHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional> @@ -418,11 +416,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional - opVarStructSeq(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public VarStruct[] + opVarStructSeq(Ice.Optional p1, VarStructSeqHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional @@ -432,11 +430,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional - opSerializable(Ice.Optional p1, Ice.Optional p3, Ice.Current current) + public SerializableClass + opSerializable(Ice.Optional p1, Ice.Holder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional @@ -446,12 +444,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional> - opIntIntDict(Ice.Optional> p1, - Ice.Optional> p3, Ice.Current current) + public java.util.Map + opIntIntDict(Ice.Optional> p1, IntIntDictHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional> @@ -462,12 +459,11 @@ public final class InitialI extends Initial return p1; } - public Ice.Optional> - opStringIntDict(Ice.Optional> p1, - Ice.Optional> p3, Ice.Current current) + public java.util.Map + opStringIntDict(Ice.Optional> p1, StringIntDictHolder p3, Ice.Current current) { - p3.set(p1); - return p1; + p3.value = p1.get(); + return p1.get(); } public Ice.Optional> diff --git a/java/test/Ice/optional/TestAMD.ice b/java/test/Ice/optional/TestAMD.ice new file mode 100644 index 00000000000..42209e9ee1e --- /dev/null +++ b/java/test/Ice/optional/TestAMD.ice @@ -0,0 +1,276 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#pragma once + +[["java:package:test.Ice.optional.AMD"]] +module Test +{ + +class OneOptional +{ + optional(1) int a; +}; + +enum MyEnum +{ + MyEnumMember +}; + +struct SmallStruct +{ + byte m; +}; + +struct FixedStruct +{ + int m; +}; + +struct VarStruct +{ + string m; +}; + +struct ClassVarStruct +{ + int a; +}; + +sequence ByteSeq; +sequence BoolSeq; +sequence ShortSeq; +sequence IntSeq; +sequence LongSeq; +sequence FloatSeq; +sequence DoubleSeq; +sequence StringSeq; +sequence MyEnumSeq; +sequence SmallStructSeq; +["java:type:java.util.ArrayList"] sequence SmallStructList; +sequence FixedStructSeq; +["java:type:java.util.ArrayList"] sequence FixedStructList; +sequence VarStructSeq; +sequence OneOptionalSeq; +sequence OneOptionalPrxSeq; + +["java:serializable:test.Ice.optional.SerializableClass"] sequence Serializable; + +dictionary IntIntDict; +dictionary StringIntDict; +dictionary IntEnumDict; +dictionary IntFixedStructDict; +dictionary IntVarStructDict; +dictionary IntOneOptionalDict; +dictionary IntOneOptionalPrxDict; + +class MultiOptional +{ + optional(1) byte a; + optional(2) bool b; + optional(3) short c; + optional(4) int d; + optional(5) long e; + optional(6) float f; + optional(7) double g; + optional(8) string h; + optional(9) MyEnum i; + optional(10) MultiOptional* j; + optional(11) MultiOptional k; + optional(12) ByteSeq bs; + optional(13) StringSeq ss; + optional(14) IntIntDict iid; + optional(15) StringIntDict sid; + optional(16) FixedStruct fs; + optional(17) VarStruct vs; + + optional(18) ShortSeq shs; + optional(19) MyEnumSeq es; + optional(20) FixedStructSeq fss; + optional(21) VarStructSeq vss; + optional(22) OneOptionalSeq oos; + optional(23) OneOptionalPrxSeq oops; + + optional(24) IntEnumDict ied; + optional(25) IntFixedStructDict ifsd; + optional(26) IntVarStructDict ivsd; + optional(27) IntOneOptionalDict iood; + optional(28) IntOneOptionalPrxDict ioopd; + + optional(29) BoolSeq bos; +}; + +class A +{ + int requiredA; + optional(1) int ma; + optional(50) int mb; + optional(500) int mc; +}; + +["preserve-slice"] +class B extends A +{ + int requiredB; + optional(10) int md; +}; + +class C extends B +{ + string ss; + optional(890) string ms; +}; + +class WD +{ + optional(1) int a = 5; + optional(2) string s = "test"; +}; + +exception OptionalException +{ + optional(1) int a = 5; + optional(2) string b; + optional(50) OneOptional o; +}; + +exception DerivedException extends OptionalException +{ + optional(600) string ss = "test"; + optional(601) OneOptional o2; +}; + +exception RequiredException extends OptionalException +{ + string ss = "test"; + OneOptional o2; +}; + +class OptionalWithCustom +{ + ["java:type:java.util.ArrayList"] optional(1) ByteSeq bs; + optional(2) ClassVarStruct s; +}; + +["ami", "amd"] +class Initial +{ + void shutdown(); + + Object pingPong(Object o); + + ["java:optional"] + void opOptionalException(optional(1) int a, optional(2) string b, optional(3) OneOptional o) + throws OptionalException; + + optional(1) byte opByte(optional(2) byte p1, out optional(3) byte p3); + ["java:optional"] optional(1) byte opByteOpt(optional(2) byte p1, out optional(3) byte p3); + + optional(1) bool opBool(optional(2) bool p1, out optional(3) bool p3); + ["java:optional"] optional(1) bool opBoolOpt(optional(2) bool p1, out optional(3) bool p3); + + optional(1) short opShort(optional(2) short p1, out optional(3) short p3); + ["java:optional"] optional(1) short opShortOpt(optional(2) short p1, out optional(3) short p3); + + optional(1) int opInt(optional(2) int p1, out optional(3) int p3); + ["java:optional"] optional(1) int opIntOpt(optional(2) int p1, out optional(3) int p3); + + optional(1) long opLong(optional(2) long p1, out optional(3) long p3); + ["java:optional"] optional(1) long opLongOpt(optional(2) long p1, out optional(3) long p3); + + optional(1) float opFloat(optional(2) float p1, out optional(3) float p3); + ["java:optional"] optional(1) float opFloatOpt(optional(2) float p1, out optional(3) float p3); + + optional(1) double opDouble(optional(2) double p1, out optional(3) double p3); + ["java:optional"] optional(1) double opDoubleOpt(optional(2) double p1, out optional(3) double p3); + + optional(1) string opString(optional(2) string p1, out optional(3) string p3); + ["java:optional"] optional(1) string opStringOpt(optional(2) string p1, out optional(3) string p3); + + optional(1) MyEnum opMyEnum(optional(2) MyEnum p1, out optional(3) MyEnum p3); + ["java:optional"] optional(1) MyEnum opMyEnumOpt(optional(2) MyEnum p1, out optional(3) MyEnum p3); + + optional(1) SmallStruct opSmallStruct(optional(2) SmallStruct p1, out optional(3) SmallStruct p3); + ["java:optional"] optional(1) SmallStruct opSmallStructOpt(optional(2) SmallStruct p1, + out optional(3) SmallStruct p3); + + optional(1) FixedStruct opFixedStruct(optional(2) FixedStruct p1, out optional(3) FixedStruct p3); + ["java:optional"] optional(1) FixedStruct opFixedStructOpt(optional(2) FixedStruct p1, + out optional(3) FixedStruct p3); + + optional(1) VarStruct opVarStruct(optional(2) VarStruct p1, out optional(3) VarStruct p3); + ["java:optional"] optional(1) VarStruct opVarStructOpt(optional(2) VarStruct p1, out optional(3) VarStruct p3); + + optional(1) OneOptional opOneOptional(optional(2) OneOptional p1, out optional(3) OneOptional p3); + ["java:optional"] optional(1) OneOptional opOneOptionalOpt(optional(2) OneOptional p1, + out optional(3) OneOptional p3); + + optional(1) OneOptional* opOneOptionalProxy(optional(2) OneOptional* p1, out optional(3) OneOptional* p3); + ["java:optional"] optional(1) OneOptional* opOneOptionalProxyOpt(optional(2) OneOptional* p1, + out optional(3) OneOptional* p3); + + optional(1) ByteSeq opByteSeq(optional(2) ByteSeq p1, out optional(3) ByteSeq p3); + ["java:optional"] optional(1) ByteSeq opByteSeqOpt(optional(2) ByteSeq p1, out optional(3) ByteSeq p3); + + optional(1) BoolSeq opBoolSeq(optional(2) BoolSeq p1, out optional(3) BoolSeq p3); + ["java:optional"] optional(1) BoolSeq opBoolSeqOpt(optional(2) BoolSeq p1, out optional(3) BoolSeq p3); + + optional(1) ShortSeq opShortSeq(optional(2) ShortSeq p1, out optional(3) ShortSeq p3); + ["java:optional"] optional(1) ShortSeq opShortSeqOpt(optional(2) ShortSeq p1, out optional(3) ShortSeq p3); + + optional(1) IntSeq opIntSeq(optional(2) IntSeq p1, out optional(3) IntSeq p3); + ["java:optional"] optional(1) IntSeq opIntSeqOpt(optional(2) IntSeq p1, out optional(3) IntSeq p3); + + optional(1) LongSeq opLongSeq(optional(2) LongSeq p1, out optional(3) LongSeq p3); + ["java:optional"] optional(1) LongSeq opLongSeqOpt(optional(2) LongSeq p1, out optional(3) LongSeq p3); + + optional(1) FloatSeq opFloatSeq(optional(2) FloatSeq p1, out optional(3) FloatSeq p3); + ["java:optional"] optional(1) FloatSeq opFloatSeqOpt(optional(2) FloatSeq p1, out optional(3) FloatSeq p3); + + optional(1) DoubleSeq opDoubleSeq(optional(2) DoubleSeq p1, out optional(3) DoubleSeq p3); + ["java:optional"] optional(1) DoubleSeq opDoubleSeqOpt(optional(2) DoubleSeq p1, out optional(3) DoubleSeq p3); + + optional(1) StringSeq opStringSeq(optional(2) StringSeq p1, out optional(3) StringSeq p3); + ["java:optional"] optional(1) StringSeq opStringSeqOpt(optional(2) StringSeq p1, out optional(3) StringSeq p3); + + optional(1) SmallStructSeq opSmallStructSeq(optional(2) SmallStructSeq p1, out optional(3) SmallStructSeq p3); + ["java:optional"] optional(1) SmallStructSeq opSmallStructSeqOpt(optional(2) SmallStructSeq p1, + out optional(3) SmallStructSeq p3); + + optional(1) SmallStructList opSmallStructList(optional(2) SmallStructList p1, out optional(3) SmallStructList p3); + ["java:optional"] optional(1) SmallStructList opSmallStructListOpt(optional(2) SmallStructList p1, + out optional(3) SmallStructList p3); + + optional(1) FixedStructSeq opFixedStructSeq(optional(2) FixedStructSeq p1, out optional(3) FixedStructSeq p3); + ["java:optional"] optional(1) FixedStructSeq opFixedStructSeqOpt(optional(2) FixedStructSeq p1, + out optional(3) FixedStructSeq p3); + + optional(1) FixedStructList opFixedStructList(optional(2) FixedStructList p1, out optional(3) FixedStructList p3); + ["java:optional"] optional(1) FixedStructList opFixedStructListOpt(optional(2) FixedStructList p1, + out optional(3) FixedStructList p3); + + optional(1) VarStructSeq opVarStructSeq(optional(2) VarStructSeq p1, out optional(3) VarStructSeq p3); + ["java:optional"] optional(1) VarStructSeq opVarStructSeqOpt(optional(2) VarStructSeq p1, + out optional(3) VarStructSeq p3); + + optional(1) Serializable opSerializable(optional(2) Serializable p1, out optional(3) Serializable p3); + ["java:optional"] optional(1) Serializable opSerializableOpt(optional(2) Serializable p1, + out optional(3) Serializable p3); + + optional(1) IntIntDict opIntIntDict(optional(2) IntIntDict p1, out optional(3) IntIntDict p3); + ["java:optional"] optional(1) IntIntDict opIntIntDictOpt(optional(2) IntIntDict p1, out optional(3) IntIntDict p3); + + optional(1) StringIntDict opStringIntDict(optional(2) StringIntDict p1, out optional(3) StringIntDict p3); + ["java:optional"] optional(1) StringIntDict opStringIntDictOpt(optional(2) StringIntDict p1, + out optional(3) StringIntDict p3); + + void opClassAndUnknownOptional(A p); +}; + +}; diff --git a/java/test/Ice/optional/run.py b/java/test/Ice/optional/run.py index 6ab39a07d80..1faa524d762 100755 --- a/java/test/Ice/optional/run.py +++ b/java/test/Ice/optional/run.py @@ -24,3 +24,5 @@ print("Running test with compact (default) format.") TestUtil.clientServerTest() print("Running test with sliced format.") TestUtil.clientServerTest(additionalClientOptions="--Ice.Default.SlicedFormat", additionalServerOptions="--Ice.Default.SlicedFormat") +print("Running test with AMD server.") +TestUtil.clientServerTest(server="test.Ice.optional.AMDServer") -- cgit v1.2.3 From 4f9a13928253344c0191b3116c4408c1d83604d9 Mon Sep 17 00:00:00 2001 From: Benoit Foucher Date: Mon, 6 Aug 2012 15:02:15 +0200 Subject: Removed Stream::format method, replace with startWriteEncaps parameter --- cpp/include/Ice/BasicStream.h | 15 +++---- cpp/include/Ice/Incoming.h | 3 +- cpp/include/Ice/Outgoing.h | 4 +- cpp/include/Ice/OutgoingAsync.h | 4 +- cpp/include/Ice/Stream.h | 4 +- cpp/include/Slice/CPlusPlusUtil.h | 2 +- cpp/src/Ice/BasicStream.cpp | 35 +++++++--------- cpp/src/Ice/Incoming.cpp | 16 ++++++-- cpp/src/Ice/Object.cpp | 6 +-- cpp/src/Ice/OpaqueEndpointI.cpp | 2 +- cpp/src/Ice/Proxy.cpp | 4 +- cpp/src/Ice/StreamI.cpp | 10 +---- cpp/src/Ice/StreamI.h | 4 +- cpp/src/Slice/CPlusPlusUtil.cpp | 4 +- cpp/src/slice2cpp/Gen.cpp | 48 ++++------------------ cpp/src/slice2java/Gen.cpp | 51 +++++------------------- java/src/Ice/ObjectImpl.java | 6 +-- java/src/Ice/ObjectPrxHelperBase.java | 2 +- java/src/Ice/OutputStream.java | 12 ++---- java/src/Ice/OutputStreamI.java | 10 +---- java/src/Ice/_ObjectDelM.java | 2 +- java/src/IceInternal/BasicStream.java | 45 ++++++++------------- java/src/IceInternal/EndpointFactoryManager.java | 2 +- java/src/IceInternal/Incoming.java | 2 +- java/src/IceInternal/IncomingBase.java | 12 +++++- java/src/IceInternal/OpaqueEndpointI.java | 2 +- java/src/IceInternal/Outgoing.java | 4 +- java/src/IceInternal/OutgoingAsync.java | 4 +- 28 files changed, 114 insertions(+), 201 deletions(-) (limited to 'cpp/src/slice2java/Gen.cpp') diff --git a/cpp/include/Ice/BasicStream.h b/cpp/include/Ice/BasicStream.h index 0ac688ab381..5871e510672 100644 --- a/cpp/include/Ice/BasicStream.h +++ b/cpp/include/Ice/BasicStream.h @@ -89,8 +89,6 @@ public: b.resize(sz); } - void format(Ice::FormatType); - void startWriteObject(const Ice::SlicedDataPtr& data) { assert(_currentWriteEncaps && _currentWriteEncaps->encoder); @@ -137,7 +135,7 @@ public: void startWriteEncaps(); - void startWriteEncaps(const Ice::EncodingVersion& encoding) + void startWriteEncaps(const Ice::EncodingVersion& encoding, Ice::FormatType format) { checkSupportedEncoding(encoding); @@ -151,6 +149,7 @@ public: _currentWriteEncaps = new WriteEncaps(); _currentWriteEncaps->previous = oldEncaps; } + _currentWriteEncaps->format = format; _currentWriteEncaps->encoding = encoding; _currentWriteEncaps->start = b.size(); @@ -965,9 +964,9 @@ private: class EncapsEncoder : private ::IceUtil::noncopyable { public: - EncapsEncoder(BasicStream* stream, WriteEncaps* encaps, Ice::FormatType format) : - _stream(stream), _encaps(encaps), _format(format), _sliceType(NoSlice), _usesClasses(false), - _objectIdIndex(0), _typeIdIndex(0) + EncapsEncoder(BasicStream* stream, WriteEncaps* encaps) : + _stream(stream), _encaps(encaps), _sliceType(NoSlice), _usesClasses(false), _objectIdIndex(0), + _typeIdIndex(0) { } @@ -1013,7 +1012,6 @@ private: BasicStream* _stream; WriteEncaps* _encaps; - const Ice::FormatType _format; // Object/exception attributes SliceType _sliceType; @@ -1092,6 +1090,7 @@ private: Container::size_type start; Ice::EncodingVersion encoding; + Ice::FormatType format; EncapsEncoder* encoder; @@ -1126,8 +1125,6 @@ private: int _startSeq; int _minSeqSize; - Ice::FormatType _format; - static const Ice::Byte FLAG_HAS_TYPE_ID_STRING; static const Ice::Byte FLAG_HAS_TYPE_ID_INDEX; static const Ice::Byte FLAG_HAS_OPTIONAL_MEMBERS; diff --git a/cpp/include/Ice/Incoming.h b/cpp/include/Ice/Incoming.h index 635ed3709b4..83a47c17b48 100644 --- a/cpp/include/Ice/Incoming.h +++ b/cpp/include/Ice/Incoming.h @@ -28,10 +28,11 @@ public: void __adopt(IncomingBase&); - BasicStream* __startWriteParams(); + BasicStream* __startWriteParams(Ice::FormatType); void __endWriteParams(bool); void __writeEmptyParams(); void __writeParamEncaps(const Ice::Byte*, Ice::Int, bool); + void __writeUserException(const Ice::UserException&, Ice::FormatType); protected: diff --git a/cpp/include/Ice/Outgoing.h b/cpp/include/Ice/Outgoing.h index 58e0dc28d66..37fdd9f248c 100644 --- a/cpp/include/Ice/Outgoing.h +++ b/cpp/include/Ice/Outgoing.h @@ -103,9 +103,9 @@ public: _is.readEncaps(encaps, sz); } - BasicStream* startWriteParams() + BasicStream* startWriteParams(Ice::FormatType format) { - _os.startWriteEncaps(_encoding); + _os.startWriteEncaps(_encoding, format); return &_os; } void endWriteParams() diff --git a/cpp/include/Ice/OutgoingAsync.h b/cpp/include/Ice/OutgoingAsync.h index ab8e59d8ea1..ff9c4e1a4fc 100644 --- a/cpp/include/Ice/OutgoingAsync.h +++ b/cpp/include/Ice/OutgoingAsync.h @@ -220,9 +220,9 @@ public: bool __send(bool); - BasicStream* __startWriteParams() + BasicStream* __startWriteParams(Ice::FormatType format) { - _os.startWriteEncaps(_encoding); + _os.startWriteEncaps(_encoding, format); return &_os; } void __endWriteParams() diff --git a/cpp/include/Ice/Stream.h b/cpp/include/Ice/Stream.h index b4b75516213..6ec33c5e2e1 100644 --- a/cpp/include/Ice/Stream.h +++ b/cpp/include/Ice/Stream.h @@ -287,8 +287,6 @@ public: virtual void writeException(const UserException&) = 0; - virtual void format(FormatType) = 0; - virtual void startObject(const SlicedDataPtr&) = 0; virtual void endObject() = 0; @@ -298,7 +296,7 @@ public: virtual void startSlice(const ::std::string&, bool) = 0; virtual void endSlice() = 0; - virtual void startEncapsulation(const Ice::EncodingVersion&) = 0; + virtual void startEncapsulation(const Ice::EncodingVersion&, FormatType) = 0; virtual void startEncapsulation() = 0; virtual void endEncapsulation() = 0; diff --git a/cpp/include/Slice/CPlusPlusUtil.h b/cpp/include/Slice/CPlusPlusUtil.h index 9febb97eb1b..dae79c161ec 100644 --- a/cpp/include/Slice/CPlusPlusUtil.h +++ b/cpp/include/Slice/CPlusPlusUtil.h @@ -39,7 +39,7 @@ SLICE_API std::string returnTypeToString(const TypePtr&, bool, const StringList& SLICE_API std::string inputTypeToString(const TypePtr&, bool, const StringList& = StringList(), int = 0); SLICE_API std::string outputTypeToString(const TypePtr&, bool, const StringList& = StringList(), int = 0); SLICE_API std::string operationModeToString(Operation::Mode); -SLICE_API std::string formatTypeToString(FormatType); +SLICE_API std::string opFormatTypeToString(const OperationPtr&); SLICE_API std::string fixKwd(const std::string&); diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp index 4636813d40a..ce7c37fa025 100755 --- a/cpp/src/Ice/BasicStream.cpp +++ b/cpp/src/Ice/BasicStream.cpp @@ -97,8 +97,7 @@ IceInternal::BasicStream::BasicStream(Instance* instance, const EncodingVersion& _unlimited(unlimited), _stringConverter(instance->initializationData().stringConverter), _wstringConverter(instance->initializationData().wstringConverter), - _startSeq(-1), - _format(_instance->defaultsAndOverrides()->defaultFormat) + _startSeq(-1) { // // Initialize the encoding members of our pre-allocated encapsulations, in case @@ -164,7 +163,6 @@ IceInternal::BasicStream::swap(BasicStream& other) std::swap(_unlimited, other._unlimited); std::swap(_startSeq, other._startSeq); std::swap(_minSeqSize, other._minSeqSize); - std::swap(_format, other._format); } void @@ -188,16 +186,6 @@ IceInternal::BasicStream::resetEncaps() _preAllocatedWriteEncaps.reset(); } - -void -IceInternal::BasicStream::format(Ice::FormatType format) -{ - if(format != DefaultFormat) - { - _format = format; - } -} - void IceInternal::BasicStream::startWriteEncaps() { @@ -209,11 +197,11 @@ IceInternal::BasicStream::startWriteEncaps() if(_currentWriteEncaps) { - startWriteEncaps(_currentWriteEncaps->encoding); + startWriteEncaps(_currentWriteEncaps->encoding, _currentWriteEncaps->format); } else { - startWriteEncaps(_encoding); + startWriteEncaps(_encoding, Ice::DefaultFormat); } } @@ -1768,9 +1756,14 @@ IceInternal::BasicStream::initWriteEncaps() _currentWriteEncaps->start = b.size(); } + if(_currentWriteEncaps->format == Ice::DefaultFormat) + { + _currentWriteEncaps->format = _instance->defaultsAndOverrides()->defaultFormat; + } + if(!_currentWriteEncaps->encoder) // Lazy initialization. { - _currentWriteEncaps->encoder = new EncapsEncoder(this, _currentWriteEncaps, _format); + _currentWriteEncaps->encoder = new EncapsEncoder(this, _currentWriteEncaps); } } @@ -1792,7 +1785,7 @@ IceInternal::BasicStream::EncapsEncoder::write(const ObjectPtr& v) _stream->write(-index); _usesClasses = true; } - else if(_sliceType != NoSlice && _format == SlicedFormat) + else if(_sliceType != NoSlice && _encaps->format == SlicedFormat) { // // An object reference that appears inside a slice of an @@ -1911,7 +1904,7 @@ IceInternal::BasicStream::EncapsEncoder::startSlice(const string& typeId, bool l // Encode the slice size for the old encoding and if using the // sliced format. // - if(_encaps->encoding == Encoding_1_0 || _format == SlicedFormat) + if(_encaps->encoding == Encoding_1_0 || _encaps->format == SlicedFormat) { _sliceFlags |= FLAG_HAS_SLICE_SIZE; } @@ -1937,7 +1930,7 @@ IceInternal::BasicStream::EncapsEncoder::startSlice(const string& typeId, bool l // Encode the type ID (only in the first slice for the compact // encoding). // - if(_format == SlicedFormat || _encaps->encoding == Encoding_1_0 || _firstSlice) + if(_encaps->format == SlicedFormat || _encaps->encoding == Encoding_1_0 || _firstSlice) { // // If the type ID has already been seen, write the index @@ -2006,7 +1999,7 @@ IceInternal::BasicStream::EncapsEncoder::endSlice() if(!_indirectionTable.empty()) { assert(_encaps->encoding != Encoding_1_0); - assert(_format == SlicedFormat); + assert(_encaps->format == SlicedFormat); _sliceFlags |= FLAG_HAS_INDIRECTION_TABLE; // @@ -2126,7 +2119,7 @@ IceInternal::BasicStream::EncapsEncoder::writeSlicedData(const SlicedDataPtr& sl // using the sliced format. Otherwise, we ignore the preserved slices, which // essentially "slices" the object into the most-derived type known by the sender. // - if(_encaps->encoding == Encoding_1_0 || _format != SlicedFormat) + if(_encaps->encoding == Encoding_1_0 || _encaps->format != SlicedFormat) { return; } diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp index 15e49a61608..34f583bb1df 100644 --- a/cpp/src/Ice/Incoming.cpp +++ b/cpp/src/Ice/Incoming.cpp @@ -80,14 +80,14 @@ IceInternal::IncomingBase::__adopt(IncomingBase& other) } BasicStream* -IncomingBase::__startWriteParams() +IncomingBase::__startWriteParams(FormatType format) { if(_response) { assert(_os.b.size() == headerSize + 4); // Reply status position. assert(_current.encoding >= Ice::Encoding_1_0); // Encoding for reply is known. _os.write(static_cast(0)); - _os.startWriteEncaps(_current.encoding); + _os.startWriteEncaps(_current.encoding, format); } // @@ -141,6 +141,14 @@ IncomingBase::__writeParamEncaps(const Byte* v, Ice::Int sz, bool ok) } } +void +IncomingBase::__writeUserException(const Ice::UserException& ex, Ice::FormatType format) +{ + ::IceInternal::BasicStream* __os = __startWriteParams(format); + __os->write(ex); + __endWriteParams(false); +} + void IceInternal::IncomingBase::__warning(const Exception& ex) const { @@ -203,7 +211,7 @@ IceInternal::IncomingBase::__servantLocatorFinished() { _os.b.resize(headerSize + 4); // Reply status position. _os.write(replyUserException); - _os.startWriteEncaps(_current.encoding); + _os.startWriteEncaps(_current.encoding, DefaultFormat); _os.write(ex); _os.endWriteEncaps(); _connection->sendResponse(&_os, _compress); @@ -567,7 +575,7 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager, BasicStre if(_response) { _os.write(replyUserException); - _os.startWriteEncaps(encoding); + _os.startWriteEncaps(encoding, DefaultFormat); _os.write(ex); _os.endWriteEncaps(); _connection->sendResponse(&_os, _compress); diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp index 875c58ed78d..39ad9df18c2 100644 --- a/cpp/src/Ice/Object.cpp +++ b/cpp/src/Ice/Object.cpp @@ -111,7 +111,7 @@ Ice::Object::___ice_isA(Incoming& __inS, const Current& __current) __is->read(__id, false); __inS.endReadParams(); bool __ret = ice_isA(__id, __current); - BasicStream* __os = __inS.__startWriteParams(); + BasicStream* __os = __inS.__startWriteParams(DefaultFormat); __os->write(__ret); __inS.__endWriteParams(true); return DispatchOK; @@ -131,7 +131,7 @@ Ice::Object::___ice_ids(Incoming& __inS, const Current& __current) { __inS.readEmptyParams(); vector __ret = ice_ids(__current); - BasicStream* __os = __inS.__startWriteParams(); + BasicStream* __os = __inS.__startWriteParams(DefaultFormat); __os->write(&__ret[0], &__ret[0] + __ret.size(), false); __inS.__endWriteParams(true); return DispatchOK; @@ -142,7 +142,7 @@ Ice::Object::___ice_id(Incoming& __inS, const Current& __current) { __inS.readEmptyParams(); string __ret = ice_id(__current); - BasicStream* __os = __inS.__startWriteParams(); + BasicStream* __os = __inS.__startWriteParams(DefaultFormat); __os->write(__ret, false); __inS.__endWriteParams(true); return DispatchOK; diff --git a/cpp/src/Ice/OpaqueEndpointI.cpp b/cpp/src/Ice/OpaqueEndpointI.cpp index 9b0eea19b0e..a3ed87efd85 100644 --- a/cpp/src/Ice/OpaqueEndpointI.cpp +++ b/cpp/src/Ice/OpaqueEndpointI.cpp @@ -196,7 +196,7 @@ void IceInternal::OpaqueEndpointI::streamWrite(BasicStream* s) const { s->write(_type); - s->startWriteEncaps(_rawEncoding); + s->startWriteEncaps(_rawEncoding, DefaultFormat); s->writeBlob(_rawBytes); s->endWriteEncaps(); } diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index eead1433242..33081299113 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -155,7 +155,7 @@ IceProxy::Ice::Object::begin_ice_isA(const string& typeId, try { __result->__prepare(ice_isA_name, Nonmutating, ctx); - IceInternal::BasicStream* __os = __result->__startWriteParams(); + IceInternal::BasicStream* __os = __result->__startWriteParams(DefaultFormat); __os->write(typeId); __result->__endWriteParams(); __result->__send(true); @@ -1461,7 +1461,7 @@ IceDelegateM::Ice::Object::ice_isA(const string& __id, const Context* context) Outgoing __og(__handler.get(), ice_isA_name, ::Ice::Nonmutating, context); try { - BasicStream* __os = __og.startWriteParams(); + BasicStream* __os = __og.startWriteParams(DefaultFormat); __os->write(__id, false); __og.endWriteParams(); } diff --git a/cpp/src/Ice/StreamI.cpp b/cpp/src/Ice/StreamI.cpp index 91c658abcf2..e1e73f94617 100644 --- a/cpp/src/Ice/StreamI.cpp +++ b/cpp/src/Ice/StreamI.cpp @@ -576,12 +576,6 @@ OutputStreamI::writeOptional(Int tag, OptionalType type) _os->writeOpt(tag, type); } -void -OutputStreamI::format(FormatType format) -{ - _os->format(format); -} - void OutputStreamI::startObject(const SlicedDataPtr& slicedData) { @@ -619,9 +613,9 @@ OutputStreamI::endSlice() } void -OutputStreamI::startEncapsulation(const EncodingVersion& version) +OutputStreamI::startEncapsulation(const EncodingVersion& version, FormatType format) { - _os->startWriteEncaps(version); + _os->startWriteEncaps(version, format); } void diff --git a/cpp/src/Ice/StreamI.h b/cpp/src/Ice/StreamI.h index 299e8a2bf02..0ccf35a8e6a 100644 --- a/cpp/src/Ice/StreamI.h +++ b/cpp/src/Ice/StreamI.h @@ -140,8 +140,6 @@ public: virtual void writeOptional(Int, OptionalType); - virtual void format(FormatType); - virtual void startObject(const SlicedDataPtr&); virtual void endObject(); @@ -151,7 +149,7 @@ public: virtual void startSlice(const std::string&, bool); virtual void endSlice(); - virtual void startEncapsulation(const Ice::EncodingVersion&); + virtual void startEncapsulation(const Ice::EncodingVersion&, FormatType); virtual void startEncapsulation(); virtual void endEncapsulation(); diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp index aa35affc81b..a4ae0905b3f 100644 --- a/cpp/src/Slice/CPlusPlusUtil.cpp +++ b/cpp/src/Slice/CPlusPlusUtil.cpp @@ -712,9 +712,9 @@ Slice::operationModeToString(Operation::Mode mode) } string -Slice::formatTypeToString(FormatType type) +Slice::opFormatTypeToString(const OperationPtr& op) { - switch(type) + switch(op->format()) { case DefaultFormat: return "::Ice::DefaultFormat"; diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 44e4b501637..db0cbd559bd 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -2236,12 +2236,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) } else { - C << nl << "::IceInternal::BasicStream* __os = __result->__startWriteParams();"; - FormatType format = p->format(); - if(p->sendsClasses() && format != DefaultFormat) - { - C << nl << "__os->format(" << formatTypeToString(format) << ");"; - } + C << nl << "::IceInternal::BasicStream* __os = __result->__startWriteParams(" << opFormatTypeToString(p) <<");"; writeMarshalCode(C, inParams, 0, TypeContextInParam); C << nl << "__result->__endWriteParams();"; } @@ -2777,15 +2772,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) { C << nl << "try"; C << sb; - C << nl<< "::IceInternal::BasicStream* __os = __og.startWriteParams();"; - if(p->sendsClasses()) - { - FormatType format = p->format(); - if(format != DefaultFormat) - { - C << nl << "__os->format(" << formatTypeToString(format) << ");"; - } - } + C << nl<< "::IceInternal::BasicStream* __os = __og.startWriteParams(" << opFormatTypeToString(p) << ");"; writeMarshalCode(C, inParams, 0, TypeContextInParam); C << nl << "__og.endWriteParams();"; C << eb; @@ -4344,14 +4331,10 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) C << retS << " __ret = "; } C << fixKwd(name) << args << ';'; - FormatType format = p->format(); if(ret || !outParams.empty()) { - C << nl << "::IceInternal::BasicStream* __os = __inS.__startWriteParams();"; - if(p->returnsClasses() && format != DefaultFormat) - { - C << nl << "__os->format(" << formatTypeToString(format) << ");"; - } + C << nl << "::IceInternal::BasicStream* __os = __inS.__startWriteParams(" + << opFormatTypeToString(p) << ");"; writeMarshalCode(C, outParams, p); C << nl << "__inS.__endWriteParams(true);"; } @@ -4368,13 +4351,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) { C << nl << "catch(const " << fixKwd((*r)->scoped()) << "& __ex)"; C << sb; - C << nl << "::IceInternal::BasicStream* __os = __inS.__startWriteParams();"; - if(format != DefaultFormat) - { - C << nl << "__os->format(" << formatTypeToString(format) << ");"; - } - C << nl << "__os->write(__ex);"; - C << nl << "__inS.__endWriteParams(false);"; + C << nl << "__inS.__writeUserException(__ex, " << opFormatTypeToString(p) << ");"; C << eb; } C << nl << "return ::Ice::DispatchUserException;"; @@ -6044,16 +6021,11 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p) C << sb; C << nl << "if(__validateResponse(true))"; C << sb; - FormatType format = p->format(); if(ret || !outParams.empty()) { C << nl << "try"; C << sb; - C << nl << "::IceInternal::BasicStream* __os = __startWriteParams();"; - if(p->returnsClasses() && format != DefaultFormat) - { - C << nl << "__os->format(" << formatTypeToString(format) << ");"; - } + C << nl << "::IceInternal::BasicStream* __os = __startWriteParams(" << opFormatTypeToString(p) << ");"; writeMarshalCode(C, outParams, p, TypeContextInParam); C << nl << "__endWriteParams(true);"; C << eb; @@ -6089,13 +6061,7 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p) C << sb; C << nl <<"if(__validateResponse(false))"; C << sb; - C << nl << "::IceInternal::BasicStream* __os = __startWriteParams();"; - if(format != DefaultFormat) - { - C << nl << "__os->format(" << formatTypeToString(format) << ");"; - } - C << nl << "__os->write(*__ex);"; - C << nl << "__endWriteParams(false);"; + C << nl << "__writeUserException(*__ex, " << opFormatTypeToString(p) << ");"; C << nl << "__response();"; C << eb; C << eb; diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index 1327e24fb14..b15dc0d5f5a 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -66,9 +66,9 @@ sliceModeToIceMode(Operation::Mode opMode) } static string -formatTypeToString(FormatType type) +opFormatTypeToString(const OperationPtr& op) { - switch(type) + switch(op->format()) { case DefaultFormat: return "Ice.FormatType.DefaultFormat"; @@ -1171,14 +1171,10 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr& // // Marshal 'out' parameters and return value. // - FormatType format = op->format(); if(!outParams.empty() || ret) { - out << nl << "IceInternal.BasicStream __os = __inS.__startWriteParams();"; - if(op->returnsClasses() && format != DefaultFormat) - { - out << nl << "__os.format(" << formatTypeToString(format) << ");"; - } + out << nl << "IceInternal.BasicStream __os = __inS.__startWriteParams(" + << opFormatTypeToString(op) << ");"; writeMarshalUnmarshalParams(out, package, outParams, op, iter, true, optionalMapping, true); out << nl << "__inS.__endWriteParams(true);"; } @@ -1200,13 +1196,7 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr& string exS = getAbsolute(*t, package); out << nl << "catch(" << exS << " ex)"; out << sb; - out << nl << "IceInternal.BasicStream __os = __inS.__startWriteParams();"; - if(format != DefaultFormat) - { - out << nl << "__os.format(" << formatTypeToString(format) << ");"; - } - out << nl << "__os.writeUserException(ex);"; - out << nl << "__inS.__endWriteParams(false);"; + out << nl << "__inS.__writeUserException(ex, " << opFormatTypeToString(op) << ");"; out << nl << "return Ice.DispatchStatus.DispatchUserException;"; out << eb; } @@ -4652,12 +4642,8 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) iter = 0; if(!inArgs.empty()) { - out << nl << "IceInternal.BasicStream __os = __result.__startWriteParams();"; - FormatType format = op->format(); - if(op->sendsClasses() && format != DefaultFormat) - { - out << nl << "__os.format(" << formatTypeToString(format) << ");"; - } + out << nl << "IceInternal.BasicStream __os = __result.__startWriteParams(" + << opFormatTypeToString(op) << ");"; ParamDeclList pl; for(pli = paramList.begin(); pli != paramList.end(); ++pli) { @@ -5663,12 +5649,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) { out << nl << "try"; out << sb; - out << nl << "IceInternal.BasicStream __os = __og.startWriteParams();"; - FormatType format = op->format(); - if(op->sendsClasses() && format != DefaultFormat) - { - out << nl << "__os.format(" << formatTypeToString(format) << ");"; - } + out << nl << "IceInternal.BasicStream __os = __og.startWriteParams(" << opFormatTypeToString(op) << ");"; writeMarshalUnmarshalParams(out, package, inParams, 0, iter, true, optionalMapping); out << nl << "__og.endWriteParams();"; out << eb; @@ -6780,16 +6761,12 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) iter = 0; out << nl << "if(__validateResponse(true))"; out << sb; - FormatType format = p->format(); if(ret || !outParams.empty()) { out << nl << "try"; out << sb; - out << nl << "IceInternal.BasicStream __os = this.__startWriteParams();"; - if(p->returnsClasses() && format != DefaultFormat) - { - out << nl << "__os.format(" << formatTypeToString(format) << ");"; - } + out << nl << "IceInternal.BasicStream __os = this.__startWriteParams(" + << opFormatTypeToString(p) << ");"; writeMarshalUnmarshalParams(out, classPkg, outParams, p, iter, true, optionalMapping, false); out << nl << "this.__endWriteParams(true);"; out << eb; @@ -6822,13 +6799,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) out << sb; out << nl << "if(__validateResponse(false))"; out << sb; - out << nl << "IceInternal.BasicStream __os = __startWriteParams();"; - if(format != DefaultFormat) - { - out << nl << "__os.format(" << formatTypeToString(format) << ");"; - } - out << nl << "__os.writeUserException(__ex);"; - out << nl << "__endWriteParams(false);"; + out << nl << "__writeUserException(__ex, " << opFormatTypeToString(p) << ");"; out << nl << "__response();"; out << eb; out << eb; diff --git a/java/src/Ice/ObjectImpl.java b/java/src/Ice/ObjectImpl.java index 6d2352d6075..7ff5636cc0f 100644 --- a/java/src/Ice/ObjectImpl.java +++ b/java/src/Ice/ObjectImpl.java @@ -91,7 +91,7 @@ public abstract class ObjectImpl implements Object, java.lang.Cloneable, java.io String __id = __is.readString(); __inS.endReadParams(); boolean __ret = __obj.ice_isA(__id, __current); - IceInternal.BasicStream __os = __inS.__startWriteParams(); + IceInternal.BasicStream __os = __inS.__startWriteParams(Ice.FormatType.DefaultFormat); __os.writeBool(__ret); __inS.__endWriteParams(true); return DispatchStatus.DispatchOK; @@ -154,7 +154,7 @@ public abstract class ObjectImpl implements Object, java.lang.Cloneable, java.io { __inS.readEmptyParams(); String[] __ret = __obj.ice_ids(__current); - IceInternal.BasicStream __os = __inS.__startWriteParams(); + IceInternal.BasicStream __os = __inS.__startWriteParams(Ice.FormatType.DefaultFormat); __os.writeStringSeq(__ret); __inS.__endWriteParams(true); return DispatchStatus.DispatchOK; @@ -188,7 +188,7 @@ public abstract class ObjectImpl implements Object, java.lang.Cloneable, java.io { __inS.readEmptyParams(); String __ret = __obj.ice_id(__current); - IceInternal.BasicStream __os = __inS.__startWriteParams(); + IceInternal.BasicStream __os = __inS.__startWriteParams(Ice.FormatType.DefaultFormat); __os.writeString(__ret); __inS.__endWriteParams(true); return DispatchStatus.DispatchOK; diff --git a/java/src/Ice/ObjectPrxHelperBase.java b/java/src/Ice/ObjectPrxHelperBase.java index 916ada0220d..9a1de69d685 100644 --- a/java/src/Ice/ObjectPrxHelperBase.java +++ b/java/src/Ice/ObjectPrxHelperBase.java @@ -209,7 +209,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable try { __result.__prepare(__ice_isA_name, OperationMode.Nonmutating, __context, __explicitCtx); - IceInternal.BasicStream __os = __result.__startWriteParams(); + IceInternal.BasicStream __os = __result.__startWriteParams(Ice.FormatType.DefaultFormat); __os.writeString(__id); __result.__endWriteParams(); __result.__send(true); diff --git a/java/src/Ice/OutputStream.java b/java/src/Ice/OutputStream.java index d921241b2f4..7c92d240ff3 100644 --- a/java/src/Ice/OutputStream.java +++ b/java/src/Ice/OutputStream.java @@ -189,13 +189,6 @@ public interface OutputStream **/ void writeException(UserException ex); - /** - * Select the format to be used for classes and exceptions. - * - * @param format Specify the compact or sliced format. - **/ - void format(FormatType format); - /** * Marks the start of an Ice object. * @@ -237,8 +230,11 @@ public interface OutputStream * Writes the start of an encapsulation to the stream. * * @param encoding The encoding version of the encapsulation. + * + * @param format Specify the compact or sliced format. + * **/ - void startEncapsulation(Ice.EncodingVersion encoding); + void startEncapsulation(Ice.EncodingVersion encoding, Ice.FormatType format); /** * Writes the start of an encapsulation to the stream. diff --git a/java/src/Ice/OutputStreamI.java b/java/src/Ice/OutputStreamI.java index 0a28528037f..67a51d4cbe5 100644 --- a/java/src/Ice/OutputStreamI.java +++ b/java/src/Ice/OutputStreamI.java @@ -171,12 +171,6 @@ public class OutputStreamI implements OutputStream _os.writeUserException(v); } - public void - format(FormatType format) - { - _os.format(format); - } - public void startObject(SlicedData slicedData) { @@ -214,9 +208,9 @@ public class OutputStreamI implements OutputStream } public void - startEncapsulation(Ice.EncodingVersion encoding) + startEncapsulation(Ice.EncodingVersion encoding, Ice.FormatType format) { - _os.startWriteEncaps(encoding); + _os.startWriteEncaps(encoding, format); } public void diff --git a/java/src/Ice/_ObjectDelM.java b/java/src/Ice/_ObjectDelM.java index 05e217f45a6..398eed35a11 100644 --- a/java/src/Ice/_ObjectDelM.java +++ b/java/src/Ice/_ObjectDelM.java @@ -20,7 +20,7 @@ public class _ObjectDelM implements _ObjectDel { try { - IceInternal.BasicStream __os = __og.startWriteParams(); + IceInternal.BasicStream __os = __og.startWriteParams(Ice.FormatType.DefaultFormat); __os.writeString(__id); __og.endWriteParams(); } diff --git a/java/src/IceInternal/BasicStream.java b/java/src/IceInternal/BasicStream.java index 7732c8e4c1a..e8d0483e8fa 100644 --- a/java/src/IceInternal/BasicStream.java +++ b/java/src/IceInternal/BasicStream.java @@ -48,7 +48,6 @@ public class BasicStream _unlimited = unlimited; _startSeq = -1; - _format = _instance.defaultsAndOverrides().defaultFormat; _sizePos = -1; } @@ -142,10 +141,6 @@ public class BasicStream other._minSeqSize = _minSeqSize; _minSeqSize = tmpMinSeqSize; - Ice.FormatType tmpFormat = other._format; - other._format = _format; - _format = tmpFormat; - int tmpSizePos = other._sizePos; other._sizePos = _sizePos; _sizePos = tmpSizePos; @@ -187,15 +182,6 @@ public class BasicStream return _buf; } - public void - format(Ice.FormatType format) - { - if(format != Ice.FormatType.DefaultFormat) - { - _format = format; - } - } - public void startWriteObject(Ice.SlicedData data) { @@ -263,16 +249,16 @@ public class BasicStream if(_writeEncapsStack != null) { - startWriteEncaps(_writeEncapsStack.encoding); + startWriteEncaps(_writeEncapsStack.encoding, _writeEncapsStack.format); } else { - startWriteEncaps(_encoding); + startWriteEncaps(_encoding, Ice.FormatType.DefaultFormat); } } public void - startWriteEncaps(Ice.EncodingVersion encoding) + startWriteEncaps(Ice.EncodingVersion encoding, Ice.FormatType format) { Protocol.checkSupportedEncoding(encoding); @@ -289,6 +275,7 @@ public class BasicStream curr.next = _writeEncapsStack; _writeEncapsStack = curr; + _writeEncapsStack.format = format; _writeEncapsStack.setEncoding(encoding); _writeEncapsStack.start = _buf.size(); @@ -3686,11 +3673,10 @@ public class BasicStream private static final class EncapsEncoder { - EncapsEncoder(BasicStream stream, WriteEncaps encaps, Ice.FormatType format) + EncapsEncoder(BasicStream stream, WriteEncaps encaps) { _stream = stream; _encaps = encaps; - _format = format; _sliceType = SliceType.NoSlice; _usesClasses = false; _objectIdIndex = 0; @@ -3719,7 +3705,7 @@ public class BasicStream _stream.writeInt(-index); _usesClasses = true; } - else if(_sliceType != SliceType.NoSlice && _format == Ice.FormatType.SlicedFormat) + else if(_sliceType != SliceType.NoSlice && _encaps.format == Ice.FormatType.SlicedFormat) { // // An object reference that appears inside a slice of an @@ -3831,7 +3817,7 @@ public class BasicStream // Encode the slice size for the old encoding and if using the // sliced format. // - if(_encaps.encoding_1_0 || _format == Ice.FormatType.SlicedFormat) + if(_encaps.encoding_1_0 || _encaps.format == Ice.FormatType.SlicedFormat) { _sliceFlags |= FLAG_HAS_SLICE_SIZE; } @@ -3857,7 +3843,7 @@ public class BasicStream // Encode the type ID (only in the first slice for the compact // encoding). // - if(_format == Ice.FormatType.SlicedFormat || _encaps.encoding_1_0 || _firstSlice) + if(_encaps.format == Ice.FormatType.SlicedFormat || _encaps.encoding_1_0 || _firstSlice) { // // If the type ID has already been seen, write the index @@ -3924,7 +3910,7 @@ public class BasicStream if(!_indirectionTable.isEmpty()) { assert(!_encaps.encoding_1_0); - assert(_format == Ice.FormatType.SlicedFormat); + assert(_encaps.format == Ice.FormatType.SlicedFormat); _sliceFlags |= FLAG_HAS_INDIRECTION_TABLE; // @@ -4056,7 +4042,7 @@ public class BasicStream // using the sliced format. Otherwise, we ignore the preserved slices, which // essentially "slices" the object into the most-derived type known by the sender. // - if(_encaps.encoding_1_0 || _format != Ice.FormatType.SlicedFormat) + if(_encaps.encoding_1_0 || _encaps.format != Ice.FormatType.SlicedFormat) { return; } @@ -4119,7 +4105,6 @@ public class BasicStream private final BasicStream _stream; private final WriteEncaps _encaps; - private final Ice.FormatType _format; // Object/exception attributes private SliceType _sliceType; @@ -4179,6 +4164,7 @@ public class BasicStream } int start; + Ice.FormatType format; Ice.EncodingVersion encoding; boolean encoding_1_0; @@ -4249,9 +4235,14 @@ public class BasicStream _writeEncapsStack.setEncoding(_encoding); } + if(_writeEncapsStack.format == Ice.FormatType.DefaultFormat) + { + _writeEncapsStack.format = _instance.defaultsAndOverrides().defaultFormat; + } + if(_writeEncapsStack.encoder == null) // Lazy initialization. { - _writeEncapsStack.encoder = new EncapsEncoder(this, _writeEncapsStack, _format); + _writeEncapsStack.encoder = new EncapsEncoder(this, _writeEncapsStack); } } @@ -4263,8 +4254,6 @@ public class BasicStream private int _startSeq; private int _minSeqSize; - private Ice.FormatType _format; - private int _sizePos; private static final byte FLAG_HAS_TYPE_ID_STRING = (byte)(1<<0); diff --git a/java/src/IceInternal/EndpointFactoryManager.java b/java/src/IceInternal/EndpointFactoryManager.java index 9c7c075851e..b3c666c4c6a 100644 --- a/java/src/IceInternal/EndpointFactoryManager.java +++ b/java/src/IceInternal/EndpointFactoryManager.java @@ -108,7 +108,7 @@ public final class EndpointFactoryManager // and ask the factory to read the endpoint data from that stream to create // the actual endpoint. // - BasicStream bs = new BasicStream(_instance, Protocol.currentEncoding, true, false); + BasicStream bs = new BasicStream(_instance, Protocol.currentProtocolEncoding, true, false); ue.streamWrite(bs); Buffer buf = bs.getBuffer(); buf.b.position(0); diff --git a/java/src/IceInternal/Incoming.java b/java/src/IceInternal/Incoming.java index 25eeab25bf5..819a6dda886 100644 --- a/java/src/IceInternal/Incoming.java +++ b/java/src/IceInternal/Incoming.java @@ -149,7 +149,7 @@ final public class Incoming extends IncomingBase implements Ice.Request if(_response) { _os.writeByte(ReplyStatus.replyUserException); - _os.startWriteEncaps(encoding); + _os.startWriteEncaps(encoding, Ice.FormatType.DefaultFormat); _os.writeUserException(ex); _os.endWriteEncaps(); _connection.sendResponse(_os, _compress); diff --git a/java/src/IceInternal/IncomingBase.java b/java/src/IceInternal/IncomingBase.java index 0f4000efbad..f3d89f3b71d 100644 --- a/java/src/IceInternal/IncomingBase.java +++ b/java/src/IceInternal/IncomingBase.java @@ -88,14 +88,14 @@ public class IncomingBase } public BasicStream - __startWriteParams() + __startWriteParams(Ice.FormatType format) { if(_response) { assert(_os.size() == Protocol.headerSize + 4); // Reply status position. assert(_current.encoding != null); // Encoding for reply is known. _os.writeByte((byte)0); - _os.startWriteEncaps(_current.encoding); + _os.startWriteEncaps(_current.encoding, format); } // @@ -152,6 +152,14 @@ public class IncomingBase } } + public void + __writeUserException(Ice.UserException ex, Ice.FormatType format) + { + BasicStream __os = __startWriteParams(format); + __os.writeUserException(ex); + __endWriteParams(false); + } + // // These functions allow this object to be reused, rather than reallocated. // diff --git a/java/src/IceInternal/OpaqueEndpointI.java b/java/src/IceInternal/OpaqueEndpointI.java index 91c34ad00bf..3982b095415 100644 --- a/java/src/IceInternal/OpaqueEndpointI.java +++ b/java/src/IceInternal/OpaqueEndpointI.java @@ -164,7 +164,7 @@ final class OpaqueEndpointI extends EndpointI streamWrite(BasicStream s) { s.writeShort(_type); - s.startWriteEncaps(_rawEncoding); + s.startWriteEncaps(_rawEncoding, Ice.FormatType.DefaultFormat); s.writeBlob(_rawBytes); s.endWriteEncaps(); } diff --git a/java/src/IceInternal/Outgoing.java b/java/src/IceInternal/Outgoing.java index c7ace46eb31..aa07f8aa052 100644 --- a/java/src/IceInternal/Outgoing.java +++ b/java/src/IceInternal/Outgoing.java @@ -457,9 +457,9 @@ public final class Outgoing implements OutgoingMessageCallback } public BasicStream - startWriteParams() + startWriteParams(Ice.FormatType format) { - _os.startWriteEncaps(_encoding); + _os.startWriteEncaps(_encoding, format); return _os; } diff --git a/java/src/IceInternal/OutgoingAsync.java b/java/src/IceInternal/OutgoingAsync.java index ca55efc67b1..2333c148c47 100644 --- a/java/src/IceInternal/OutgoingAsync.java +++ b/java/src/IceInternal/OutgoingAsync.java @@ -397,9 +397,9 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa } public BasicStream - __startWriteParams() + __startWriteParams(Ice.FormatType format) { - _os.startWriteEncaps(_encoding); + _os.startWriteEncaps(_encoding, format); return _os; } -- cgit v1.2.3