diff options
author | Mark Spruiell <mes@zeroc.com> | 2016-02-02 17:54:44 -0800 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2016-02-02 17:54:44 -0800 |
commit | 7002b1f35bcd0a08a4ecf768a65db8fca787a0a6 (patch) | |
tree | 32e3e870f424dfdc198e2577db66b34957b44ae5 /cpp/src | |
parent | interim Java fix for ValueFactoryManager (diff) | |
download | ice-7002b1f35bcd0a08a4ecf768a65db8fca787a0a6.tar.bz2 ice-7002b1f35bcd0a08a4ecf768a65db8fca787a0a6.tar.xz ice-7002b1f35bcd0a08a4ecf768a65db8fca787a0a6.zip |
ICE-6861 - Java stream API changes
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/CollocatedRequestHandler.cpp | 28 | ||||
-rw-r--r-- | cpp/src/Slice/JavaUtil.cpp | 1254 | ||||
-rw-r--r-- | cpp/src/slice2java/Gen.cpp | 590 | ||||
-rw-r--r-- | cpp/src/slice2java/Gen.h | 22 | ||||
-rw-r--r-- | cpp/src/slice2java/Main.cpp | 6 |
5 files changed, 123 insertions, 1777 deletions
diff --git a/cpp/src/Ice/CollocatedRequestHandler.cpp b/cpp/src/Ice/CollocatedRequestHandler.cpp index d57d9d72934..5e9dee2b5a3 100644 --- a/cpp/src/Ice/CollocatedRequestHandler.cpp +++ b/cpp/src/Ice/CollocatedRequestHandler.cpp @@ -323,13 +323,17 @@ CollocatedRequestHandler::sendResponse(Int requestId, OutputStream* os, Byte, bo Lock sync(*this); assert(_response); + if(_traceLevels->protocol >= 1) + { + fillInValue(os, 10, static_cast<Int>(os->b.size())); + } + InputStream is(os->instance(), os->getEncoding(), *os, true); // Adopting the OutputStream's buffer. is.i = is.b.begin() + sizeof(replyHdr) + 4; if(_traceLevels->protocol >= 1) { - fillInValue(os, 10, static_cast<Int>(os->b.size())); traceRecv(is, _logger, _traceLevels); } @@ -446,17 +450,6 @@ CollocatedRequestHandler::sentAsync(OutgoingAsyncBase* outAsync) void CollocatedRequestHandler::invokeAll(OutputStream* os, Int requestId, Int batchRequestNum) { - InputStream is(os->instance(), os->getEncoding(), *os); - - if(batchRequestNum > 0) - { - is.i = is.b.begin() + sizeof(requestBatchHdr); - } - else - { - is.i = is.b.begin() + sizeof(requestHdr); - } - if(_traceLevels->protocol >= 1) { fillInValue(os, 10, static_cast<Int>(os->b.size())); @@ -471,6 +464,17 @@ CollocatedRequestHandler::invokeAll(OutputStream* os, Int requestId, Int batchRe traceSend(*os, _logger, _traceLevels); } + InputStream is(os->instance(), os->getEncoding(), *os); + + if(batchRequestNum > 0) + { + is.i = is.b.begin() + sizeof(requestBatchHdr); + } + else + { + is.i = is.b.begin() + sizeof(requestHdr); + } + int invokeNum = batchRequestNum > 0 ? batchRequestNum : 1; ServantManagerPtr servantManager = _adapter->getServantManager(); try diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index f84b30eb8d5..7375215f3f4 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -1259,8 +1259,8 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(optionalMapping) { - out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" << tag - << ", " << getOptionalFormat(type) << "))"; + out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOptional(" + << tag << ", " << getOptionalFormat(type) << "))"; out << sb; out << nl << "int __pos = " << stream << ".startSize();"; out << nl << typeS << "Helper.__write(" << stream << ", " << v << ".get());"; @@ -1269,7 +1269,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } else { - out << nl << "if(" << stream << ".writeOpt(" << tag << ", " << getOptionalFormat(type) << "))"; + out << nl << "if(" << stream << ".writeOptional(" << tag << ", " << getOptionalFormat(type) << "))"; out << sb; out << nl << "int __pos = " << stream << ".startSize();"; out << nl << typeS << "Helper.__write(" << stream << ", " << v << ");"; @@ -1292,7 +1292,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(optionalParam) { - out << nl << "if(" << stream << ".readOpt(" << tag << ", " << getOptionalFormat(type) << "))"; + out << nl << "if(" << stream << ".readOptional(" << tag << ", " << getOptionalFormat(type) << "))"; out << sb; out << nl << stream << ".skip(4);"; out << nl << v << ".set(" << typeS << "Helper.__read(" << stream << "));"; @@ -1337,7 +1337,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, if(optionalParam) { string typeS = typeToString(type, TypeModeIn, package); - out << nl << "if(" << stream << ".readOpt(" << tag << ", " << getOptionalFormat(type) << "))"; + out << nl << "if(" << stream << ".readOptional(" << tag << ", " << getOptionalFormat(type) << "))"; out << sb; out << nl << stream << ".readObject(new Ice.OptionalObject(" << v << ", " << typeS << ".class, " << getStaticId(type, package) << "));"; @@ -1385,13 +1385,14 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(optionalMapping) { - out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" + out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOptional(" << tag << ", " << getOptionalFormat(type) << "))"; val = v + ".get()"; } else { - out << nl << "if(" << stream << ".writeOpt(" << tag << ", " << getOptionalFormat(type) << "))"; + out << nl << "if(" << stream << ".writeOptional(" << tag << ", " << getOptionalFormat(type) + << "))"; val = v; } out << sb; @@ -1404,13 +1405,13 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, if(st->isVariableLength()) { out << nl << "int __pos = " << stream << ".startSize();"; - out << nl << typeS << ".__write(" << stream << ", " << val << ");"; + out << nl << typeS << ".ice_write(" << stream << ", " << val << ");"; out << nl << stream << ".endSize(__pos);"; } else { out << nl << stream << ".writeSize(" << st->minWireSize() << ");"; - out << nl << typeS << ".__write(" << stream << ", " << val << ");"; + out << nl << typeS << ".ice_write(" << stream << ", " << val << ");"; } if(optionalParam) { @@ -1419,14 +1420,14 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } else { - out << nl << typeS << ".__write(" << stream << ", " << v << ");"; + out << nl << typeS << ".ice_write(" << stream << ", " << v << ");"; } } else { if(optionalParam) { - out << nl << "if(" << stream << ".readOpt(" << tag << ", " << getOptionalFormat(type) << "))"; + out << nl << "if(" << stream << ".readOptional(" << tag << ", " << getOptionalFormat(type) << "))"; out << sb; if(st->isVariableLength()) @@ -1439,7 +1440,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } out << nl << typeS << " __tmpOpt = new " << typeS << "();"; - out << nl << "__tmpOpt.__read(" << stream << ");"; + out << nl << "__tmpOpt.ice_read(" << stream << ");"; out << nl << v << ".set(__tmpOpt);"; out << eb; @@ -1462,11 +1463,11 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { out << nl << stream << ".skipSize();"; } - out << nl << v << " = " << typeS << ".__read(" << stream << ", " << v << ");"; + out << nl << v << " = " << typeS << ".ice_read(" << stream << ", " << v << ");"; } else { - out << nl << v << " = " << typeS << ".__read(" << stream << ", " << v << ");"; + out << nl << v << " = " << typeS << ".ice_read(" << stream << ", " << v << ");"; } } return; @@ -1482,32 +1483,32 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(optionalMapping) { - out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" << tag - << ", " << getOptionalFormat(type) << "))"; + out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOptional(" + << tag << ", " << getOptionalFormat(type) << "))"; out << sb; - out << nl << typeS << ".__write(" << stream << ", " << v << ".get());"; + out << nl << typeS << ".ice_write(" << stream << ", " << v << ".get());"; out << eb; } else { - out << nl << "if(" << stream << ".writeOpt(" << tag << ", " << getOptionalFormat(type) << "))"; + out << nl << "if(" << stream << ".writeOptional(" << tag << ", " << getOptionalFormat(type) << "))"; out << sb; - out << nl << typeS << ".__write(" << stream << ", " << v << ");"; + out << nl << typeS << ".ice_write(" << stream << ", " << v << ");"; out << eb; } } else { - out << nl << typeS << ".__write(" << stream << ", " << v << ");"; + out << nl << typeS << ".ice_write(" << stream << ", " << v << ");"; } } else { if(optionalParam) { - out << nl << "if(" << stream << ".readOpt(" << tag << ", " << getOptionalFormat(type) << "))"; + out << nl << "if(" << stream << ".readOptional(" << tag << ", " << getOptionalFormat(type) << "))"; out << sb; - out << nl << v << ".set(" << typeS << ".__read(" << stream << "));"; + out << nl << v << ".set(" << typeS << ".ice_read(" << stream << "));"; out << eb; if(mode == OptionalOutParam) { @@ -1519,7 +1520,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, } else { - out << nl << v << " = " << typeS << ".__read(" << stream << ");"; + out << nl << v << " = " << typeS << ".ice_read(" << stream << ");"; } } return; @@ -1540,13 +1541,14 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(optionalMapping) { - out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" + out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOptional(" << tag << ", " << getOptionalFormat(type) << "))"; out << sb; } else { - out << nl << "if(" << stream << ".writeOpt(" << tag << ", " << getOptionalFormat(type) << "))"; + out << nl << "if(" << stream << ".writeOptional(" << tag << ", " << getOptionalFormat(type) + << "))"; out << sb; } } @@ -1589,7 +1591,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, if(optionalParam) { tmpName = "__optDict"; - out << nl << "if(" << stream << ".readOpt(" << tag << ", " << getOptionalFormat(type) << "))"; + out << nl << "if(" << stream << ".readOptional(" << tag << ", " << getOptionalFormat(type) << "))"; out << sb; out << nl << typeS << ' ' << tmpName << ';'; } @@ -1701,12 +1703,13 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, { if(optionalMapping) { - out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOpt(" + out << nl << "if(" << v << " != null && " << v << ".isSet() && " << stream << ".writeOptional(" << tag << ", " << getOptionalFormat(type) << "))"; } else { - out << nl << "if(" << stream << ".writeOpt(" << tag << ", " << getOptionalFormat(type) << "))"; + out << nl << "if(" << stream << ".writeOptional(" << tag << ", " << getOptionalFormat(type) + << "))"; } out << sb; @@ -1793,7 +1796,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out, if(optionalParam) { tmpName = "__optSeq"; - out << nl << "if(" << stream << ".readOpt(" << tag << ", " << getOptionalFormat(type) << "))"; + out << nl << "if(" << stream << ".readOptional(" << tag << ", " << getOptionalFormat(type) << "))"; out << sb; out << nl << typeS << ' ' << tmpName << ';'; } @@ -2570,1199 +2573,6 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out, } } -void -Slice::JavaGenerator::writeStreamMarshalUnmarshalCode(Output& out, - const string& package, - const TypePtr& type, - bool optional, - int /*tag*/, - const string& param, - bool marshal, - int& iter, - bool holder, - const StringList& metaData, - const string& patchParams) -{ - string stream = marshal ? "__outS" : "__inS"; - string v; - if(holder && !optional) - { - v = param + ".value"; - } - else - { - v = param; - } - - BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); - if(builtin) - { - switch(builtin->kind()) - { - case Builtin::KindByte: - { - if(marshal) - { - out << nl << stream << ".writeByte(" << v << ");"; - } - else - { - out << nl << v << " = " << stream << ".readByte();"; - } - break; - } - case Builtin::KindBool: - { - if(marshal) - { - out << nl << stream << ".writeBool(" << v << ");"; - } - else - { - out << nl << v << " = " << stream << ".readBool();"; - } - break; - } - case Builtin::KindShort: - { - if(marshal) - { - out << nl << stream << ".writeShort(" << v << ");"; - } - else - { - out << nl << v << " = " << stream << ".readShort();"; - } - break; - } - case Builtin::KindInt: - { - if(marshal) - { - out << nl << stream << ".writeInt(" << v << ");"; - } - else - { - out << nl << v << " = " << stream << ".readInt();"; - } - break; - } - case Builtin::KindLong: - { - if(marshal) - { - out << nl << stream << ".writeLong(" << v << ");"; - } - else - { - out << nl << v << " = " << stream << ".readLong();"; - } - break; - } - case Builtin::KindFloat: - { - if(marshal) - { - out << nl << stream << ".writeFloat(" << v << ");"; - } - else - { - out << nl << v << " = " << stream << ".readFloat();"; - } - break; - } - case Builtin::KindDouble: - { - if(marshal) - { - out << nl << stream << ".writeDouble(" << v << ");"; - } - else - { - out << nl << v << " = " << stream << ".readDouble();"; - } - break; - } - case Builtin::KindString: - { - if(marshal) - { - out << nl << stream << ".writeString(" << v << ");"; - } - else - { - out << nl << v << " = " << stream << ".readString();"; - } - break; - } - case Builtin::KindValue: - case Builtin::KindObject: - { - if(marshal) - { - out << nl << stream << ".writeObject(" << v << ");"; - } - else - { - if(holder && !optional) - { - out << nl << stream << ".readObject(" << param << ");"; - } - else - { - if(patchParams.empty()) - { - out << nl << stream << ".readObject(new Patcher());"; - } - else - { - out << nl << stream << ".readObject(" << patchParams << ");"; - } - } - } - break; - } - case Builtin::KindObjectProxy: - { - if(marshal) - { - if(optional) - { - out << nl << "int __pos = " << stream << ".startSize();"; - out << nl << stream << ".writeProxy(" << v << ");"; - out << nl << stream << ".endSize(__pos);"; - } - else - { - out << nl << stream << ".writeProxy(" << v << ");"; - } - } - else - { - if(optional) - { - out << nl << stream << ".skip(4);"; - } - out << nl << v << " = " << stream << ".readProxy();"; - } - break; - } - case Builtin::KindLocalObject: - { - assert(false); - break; - } - } - return; - } - - ProxyPtr prx = ProxyPtr::dynamicCast(type); - if(prx) - { - string typeS = typeToString(type, TypeModeIn, package); - if(marshal) - { - if(optional) - { - out << nl << "int __pos = " << stream << ".startSize();"; - out << nl << typeS << "Helper.write(" << stream << ", " << v << ");"; - out << nl << stream << ".endSize(__pos);"; - } - else - { - out << nl << typeS << "Helper.write(" << stream << ", " << v << ");"; - } - } - else - { - if(optional) - { - out << nl << stream << ".skip(4);"; - } - out << nl << v << " = " << typeS << "Helper.read(" << stream << ");"; - } - return; - } - - ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type); - if(cl) - { - if(marshal) - { - out << nl << stream << ".writeObject(" << v << ");"; - } - else - { - if(holder && !optional) - { - out << nl << stream << ".readObject(" << param << ");"; - } - else - { - if(patchParams.empty()) - { - out << nl << stream << ".readObject(new Patcher());"; - } - else - { - out << nl << stream << ".readObject(" << patchParams << ");"; - } - } - } - return; - } - - StructPtr st = StructPtr::dynamicCast(type); - if(st) - { - string typeS = typeToString(type, TypeModeIn, package); - if(marshal) - { - if(optional) - { - if(st->isVariableLength()) - { - out << nl << "int __pos = " << stream << ".startSize();"; - out << nl << typeS << ".ice_write(" << stream << ", " << v << ");"; - out << nl << stream << ".endSize(__pos);"; - } - else - { - out << nl << stream << ".writeSize(" << st->minWireSize() << ");"; - out << nl << typeS << ".ice_write(" << stream << ", " << v << ");"; - } - } - else - { - out << nl << typeS << ".ice_write(" << stream << ", " << v << ");"; - } - } - else - { - if(optional) - { - if(st->isVariableLength()) - { - out << nl << stream << ".skip(4);"; - } - else - { - out << nl << stream << ".skipSize();"; - } - } - out << nl << v << " = " << typeS << ".ice_read(" << stream << ", " << v << ");"; - } - return; - } - - EnumPtr en = EnumPtr::dynamicCast(type); - if(en) - { - string typeS = typeToString(type, TypeModeIn, package); - if(marshal) - { - out << nl << typeS << ".ice_write(" << stream << ", " << v << ");"; - } - else - { - out << nl << v << " = " << typeS << ".ice_read(" << stream << ");"; - } - return; - } - - DictionaryPtr dict = DictionaryPtr::dynamicCast(type); - if(dict) - { - if(optional) - { - string typeS = typeToString(type, TypeModeIn, package, metaData); - TypePtr keyType = dict->keyType(); - TypePtr valueType = dict->valueType(); - - if(marshal) - { - if(keyType->isVariableLength() || valueType->isVariableLength()) - { - out << nl << "int __pos = " << stream << ".startSize();"; - writeStreamDictionaryMarshalUnmarshalCode(out, package, dict, v, marshal, iter, true, metaData); - out << nl << stream << ".endSize(__pos);"; - } - else - { - const size_t wireSize = keyType->minWireSize() + valueType->minWireSize(); - out << nl << "final int __optSize = " << v << " == null ? 0 : " << v << ".size();"; - out << nl << stream << ".writeSize(__optSize > 254 ? __optSize * " << wireSize - << " + 5 : __optSize * " << wireSize << " + 1);"; - writeStreamDictionaryMarshalUnmarshalCode(out, package, dict, v, marshal, iter, true, metaData); - } - } - else - { - if(keyType->isVariableLength() || valueType->isVariableLength()) - { - out << nl << stream << ".skip(4);"; - } - else - { - out << nl << stream << ".skipSize();"; - } - - writeStreamDictionaryMarshalUnmarshalCode(out, package, dict, v, marshal, iter, true, metaData); - } - } - else - { - writeStreamDictionaryMarshalUnmarshalCode(out, package, dict, v, marshal, iter, true, metaData); - } - return; - } - - SequencePtr seq = SequencePtr::dynamicCast(type); - if(seq) - { - if(optional) - { - string typeS = typeToString(type, TypeModeIn, package, metaData); - TypePtr elemType = seq->type(); - BuiltinPtr elemBuiltin = BuiltinPtr::dynamicCast(elemType); - - string ignore; - - if(marshal) - { - if(elemType->isVariableLength()) - { - out << nl << "int __pos = " << stream << ".startSize();"; - writeStreamSequenceMarshalUnmarshalCode(out, package, seq, v, marshal, iter, true, metaData); - out << nl << stream << ".endSize(__pos);"; - } - else if(findMetaData("java:type:", metaData, ignore) || - findMetaData("java:type:", seq->getMetaData(), ignore)) - { - // - // The sequence is an instance of java.util.List<E>, where E is a fixed-size type. - // If the element type is bool or byte, we do NOT write an extra size. - // - - if(!elemBuiltin || - (elemBuiltin->kind() != Builtin::KindByte && elemBuiltin->kind() != Builtin::KindBool)) - { - out << nl << "final int __optSize = " << v << " == null ? 0 : " << v << ".size();"; - const size_t wireSize = elemType->minWireSize(); - - if(wireSize > 1) - { - out << nl << stream << ".writeSize(__optSize > 254 ? __optSize * " << wireSize - << " + 5 : __optSize * " << wireSize << " + 1);"; - } - else - { - // - // The element type could be a struct with a wire size of 1. - // - out << nl << stream << ".writeSize(__optSize > 254 ? __optSize + 5 : __optSize + 1);"; - } - } - writeStreamSequenceMarshalUnmarshalCode(out, package, seq, v, marshal, iter, true, metaData); - } - else if(findMetaData("java:protobuf:", seq->getMetaData(), ignore) || - findMetaData("java:serializable:", seq->getMetaData(), ignore)) - { - // - // This just writes a byte sequence. - // - writeStreamSequenceMarshalUnmarshalCode(out, package, seq, v, marshal, iter, true, metaData); - } - else - { - // - // At this point we have a regular Java array of a fixed-size type. - // - - if(!elemBuiltin || (elemBuiltin->kind() != Builtin::KindByte && - elemBuiltin->kind() != Builtin::KindBool)) - { - out << nl << "final int __optSize = " << v << " == null ? 0 : " << v << ".length;"; - const size_t wireSize = elemType->minWireSize(); - - if(wireSize > 1) - { - out << nl << stream << ".writeSize(__optSize > 254 ? __optSize * " << wireSize - << " + 5 : __optSize * " << wireSize << " + 1);"; - } - else - { - // - // The element type could be a struct with a wire size of 1. - // - out << nl << stream << ".writeSize(__optSize > 254 ? __optSize + 5 : __optSize + 1);"; - } - } - - writeStreamSequenceMarshalUnmarshalCode(out, package, seq, v, marshal, iter, true, metaData); - } - } - else - { - if(elemType->isVariableLength()) - { - out << nl << stream << ".skip(4);"; - } - else if(findMetaData("java:type:", metaData, ignore) || - findMetaData("java:type:", seq->getMetaData(), ignore)) - { - // - // The sequence is an instance of java.util.List<E>, where E is a fixed-size type. - // If the element type is bool or byte, we do NOT write an extra size. - // - - if(!elemBuiltin || - (elemBuiltin->kind() != Builtin::KindByte && elemBuiltin->kind() != Builtin::KindBool)) - { - out << nl << stream << ".skipSize();"; - } - } - else if(!findMetaData("java:protobuf:", seq->getMetaData(), ignore) && - !findMetaData("java:serializable:", seq->getMetaData(), ignore)) - { - if(!elemBuiltin || - (elemBuiltin->kind() != Builtin::KindByte && elemBuiltin->kind() != Builtin::KindBool)) - { - out << nl << stream << ".skipSize();"; - } - } - - writeStreamSequenceMarshalUnmarshalCode(out, package, seq, v, marshal, iter, true, metaData); - } - } - else - { - writeStreamSequenceMarshalUnmarshalCode(out, package, seq, v, marshal, iter, true, metaData); - } - return; - } - - ConstructedPtr constructed = ConstructedPtr::dynamicCast(type); - assert(constructed); - string typeS = getAbsolute(constructed, package); - if(marshal) - { - out << nl << typeS << "Helper.write(" << stream << ", " << v << ");"; - } - else - { - out << nl << v << " = " << typeS << "Helper.read(" << stream << ");"; - } -} - -void -Slice::JavaGenerator::writeStreamDictionaryMarshalUnmarshalCode(Output& out, - const string& package, - const DictionaryPtr& dict, - const string& param, - bool marshal, - int& iter, - bool useHelper, - const StringList& metaData) -{ - string stream = marshal ? "__outS" : "__inS"; - string v = param; - - // - // We have to determine whether it's possible to use the - // type's generated helper class for this marshal/unmarshal - // task. Since the user may have specified a custom type in - // metadata, it's possible that the helper class is not - // compatible and therefore we'll need to generate the code - // in-line instead. - // - // Specifically, there may be "local" metadata (i.e., from - // a data member or parameter definition) that overrides the - // original type. We'll compare the mapped types with and - // without local metadata to determine whether we can use - // the helper. - // - string instanceType, formalType; - getDictionaryTypes(dict, "", metaData, instanceType, formalType); - string origInstanceType, origFormalType; - getDictionaryTypes(dict, "", StringList(), origInstanceType, origFormalType); - if((formalType != origFormalType) || (!marshal && instanceType != origInstanceType)) - { - useHelper = false; - } - - // - // If we can use the helper, it's easy. - // - if(useHelper) - { - string typeS = getAbsolute(dict, package); - if(marshal) - { - out << nl << typeS << "Helper.write(" << stream << ", " << v << ");"; - } - else - { - out << nl << v << " = " << typeS << "Helper.read(" << stream << ");"; - } - return; - } - - TypePtr key = dict->keyType(); - TypePtr value = dict->valueType(); - - string keyS = typeToString(key, TypeModeIn, package); - string valueS = typeToString(value, TypeModeIn, package); - - ostringstream o; - o << iter; - string iterS = o.str(); - iter++; - - if(marshal) - { - out << nl << "if(" << v << " == null)"; - out << sb; - out << nl << "__outS.writeSize(0);"; - out << eb; - out << nl << "else"; - out << sb; - out << nl << "__outS.writeSize(" << v << ".size());"; - string keyObjectS = typeToObjectString(key, TypeModeIn, package); - string valueObjectS = typeToObjectString(value, TypeModeIn, package); - out << nl << "for(java.util.Map.Entry<" << keyObjectS << ", " << valueObjectS << "> __e : " << v - << ".entrySet())"; - out << sb; - for(int i = 0; i < 2; i++) - { - string arg; - TypePtr type; - if(i == 0) - { - arg = "__e.getKey()"; - type = key; - } - else - { - arg = "__e.getValue()"; - type = value; - } - writeStreamMarshalUnmarshalCode(out, package, type, false, 0, arg, true, iter, false); - } - out << eb; - out << eb; - } - else - { - out << nl << v << " = new " << instanceType << "();"; - out << nl << "int __sz" << iterS << " = __inS.readSize();"; - out << nl << "for(int __i" << iterS << " = 0; __i" << iterS << " < __sz" << iterS << "; __i" << iterS << "++)"; - out << sb; - for(int i = 0; i < 2; i++) - { - string arg; - TypePtr type; - string typeS; - if(i == 0) - { - arg = "__key"; - type = key; - typeS = keyS; - } - else - { - arg = "__value"; - type = value; - typeS = valueS; - } - - BuiltinPtr b = BuiltinPtr::dynamicCast(type); - string s = typeToString(type, TypeModeIn, package); - if(ClassDeclPtr::dynamicCast(type) || (b && b->kind() == Builtin::KindObject)) - { - string keyTypeStr = typeToObjectString(key, TypeModeIn, package); - string valueTypeStr = typeToObjectString(value, TypeModeIn, package); - writeStreamMarshalUnmarshalCode(out, package, type, false, 0, arg, false, iter, false, - StringList(), "new IceInternal.DictionaryPatcher<" + keyTypeStr + - ", " + valueTypeStr + ">(" + v + ", " + s + ".class, \"" + - type->typeId() + "\", __key)"); - } - else - { - if(StructPtr::dynamicCast(type)) - { - out << nl << s << ' ' << arg << " = null;"; - } - else - { - out << nl << s << ' ' << arg << ';'; - } - writeStreamMarshalUnmarshalCode(out, package, type, false, 0, arg, false, iter, false); - } - } - BuiltinPtr builtin = BuiltinPtr::dynamicCast(value); - if(!(builtin && (builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindValue)) && - !ClassDeclPtr::dynamicCast(value)) - { - out << nl << "" << v << ".put(__key, __value);"; - } - out << eb; - } -} - -void -Slice::JavaGenerator::writeStreamSequenceMarshalUnmarshalCode(Output& out, - const string& package, - const SequencePtr& seq, - const string& param, - bool marshal, - int& iter, - bool useHelper, - const StringList& metaData) -{ - string stream = marshal ? "__outS" : "__inS"; - string v = param; - - // - // If the sequence is a byte sequence, check if there's the serializable or protobuf metadata to - // get rid of these two easy cases first. - // - BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type()); - if(builtin && builtin->kind() == Builtin::KindByte) - { - string meta; - static const string protobuf = "java:protobuf:"; - static const string serializable = "java:serializable:"; - if(seq->findMetaData(serializable, meta)) - { - if(marshal) - { - out << nl << stream << ".writeSerializable(" << v << ");"; - } - else - { - string type = typeToString(seq, TypeModeIn, package); - out << nl << v << " = (" << type << ")" << stream << ".readSerializable();"; - } - return; - } - else if(seq->findMetaData(protobuf, meta)) - { - if(marshal) - { - out << nl << "if(!" << v << ".isInitialized())"; - out << sb; - out << nl << "throw new Ice.MarshalException(\"type not fully initialized\");"; - out << eb; - out << nl << stream << ".writeByteSeq(" << v << ".toByteArray());"; - } - else - { - string type = meta.substr(protobuf.size()); - out << nl << "try"; - out << sb; - out << nl << v << " = " << type << ".parseFrom(" << stream << ".readByteSeq());"; - out << eb; - out << nl << "catch(com.google.protobuf.InvalidProtocolBufferException __ex)"; - out << sb; - out << nl << "Ice.MarshalException __mex = new Ice.MarshalException();"; - out << nl << "__mex.initCause(__ex);"; - out << nl << "throw __mex;"; - out << eb; - } - return; - } - } - - if(builtin && - (builtin->kind() == Builtin::KindByte || builtin->kind() == Builtin::KindShort || - builtin->kind() == Builtin::KindInt || builtin->kind() == Builtin::KindLong || - builtin->kind() == Builtin::KindFloat || builtin->kind() == Builtin::KindDouble)) - { - string meta; - static const string bytebuffer = "java:buffer"; - if(seq->findMetaData(bytebuffer, meta) || findMetaData(bytebuffer, metaData, meta)) - { - switch(builtin->kind()) - { - case Builtin::KindByte: - { - if(marshal) - { - out << nl << stream << ".writeByteBuffer(" << v << ");"; - } - else - { - out << nl << v << " = " << stream << ".readByteBuffer();"; - } - break; - } - case Builtin::KindShort: - { - if(marshal) - { - out << nl << stream << ".writeShortBuffer(" << v << ");"; - } - else - { - out << nl << v << " = " << stream << ".readShortBuffer();"; - } - break; - } - case Builtin::KindInt: - { - if(marshal) - { - out << nl << stream << ".writeIntBuffer(" << v << ");"; - } - else - { - out << nl << v << " = " << stream << ".readIntBuffer();"; - } - break; - } - case Builtin::KindLong: - { - if(marshal) - { - out << nl << stream << ".writeLongBuffer(" << v << ");"; - } - else - { - out << nl << v << " = " << stream << ".readLongBuffer();"; - } - break; - } - case Builtin::KindFloat: - { - if(marshal) - { - out << nl << stream << ".writeFloatBuffer(" << v << ");"; - } - else - { - out << nl << v << " = " << stream << ".readFloatBuffer();"; - } - break; - } - case Builtin::KindDouble: - { - if(marshal) - { - out << nl << stream << ".writeDoubleBuffer(" << v << ");"; - } - else - { - out << nl << v << " = " << stream << ".readDoubleBuffer();"; - } - break; - } - case Builtin::KindBool: - case Builtin::KindString: - case Builtin::KindObject: - case Builtin::KindObjectProxy: - case Builtin::KindLocalObject: - case Builtin::KindValue: - { - assert(false); - break; - } - } - return; - } - } - - // - // We have to determine whether it's possible to use the - // type's generated helper class for this marshal/unmarshal - // task. Since the user may have specified a custom type in - // metadata, it's possible that the helper class is not - // compatible and therefore we'll need to generate the code - // in-line instead. - // - // Specifically, there may be "local" metadata (i.e., from - // a data member or parameter definition) that overrides the - // original type. We'll compare the mapped types with and - // without local metadata to determine whether we can use - // the helper. - // - string instanceType, formalType; - bool customType = getSequenceTypes(seq, "", metaData, instanceType, formalType); - string origInstanceType, origFormalType; - getSequenceTypes(seq, "", StringList(), origInstanceType, origFormalType); - if((formalType != origFormalType) || (!marshal && instanceType != origInstanceType)) - { - useHelper = false; - } - - // - // If we can use the helper, it's easy. - // - if(useHelper) - { - string typeS = getAbsolute(seq, package); - if(marshal) - { - out << nl << typeS << "Helper.write(" << stream << ", " << v << ");"; - } - else - { - out << nl << v << " = " << typeS << "Helper.read(" << stream << ");"; - } - return; - } - - // - // Determine sequence depth - // - int depth = 0; - TypePtr origContent = seq->type(); - SequencePtr s = SequencePtr::dynamicCast(origContent); - while(s) - { - // - // Stop if the inner sequence type has a custom, serializable or protobuf type. - // - if(hasTypeMetaData(s)) - { - break; - } - depth++; - origContent = s->type(); - s = SequencePtr::dynamicCast(origContent); - } - string origContentS = typeToString(origContent, TypeModeIn, package); - - TypePtr type = seq->type(); - - if(customType) - { - // - // Marshal/unmarshal a custom sequence type. - // - BuiltinPtr b = BuiltinPtr::dynamicCast(type); - string typeS = getAbsolute(seq, package); - ostringstream o; - o << origContentS; - int d = depth; - while(d--) - { - o << "[]"; - } - string cont = o.str(); - if(marshal) - { - out << nl << "if(" << v << " == null)"; - out << sb; - out << nl << stream << ".writeSize(0);"; - out << eb; - out << nl << "else"; - out << sb; - out << nl << stream << ".writeSize(" << v << ".size());"; - string typeS = typeToString(type, TypeModeIn, package); - out << nl << "for(" << typeS << " __elem : " << v << ')'; - out << sb; - writeStreamMarshalUnmarshalCode(out, package, type, false, 0, "__elem", true, iter, false); - out << eb; - out << eb; // else - } - else - { - bool isObject = false; - ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type); - if((b && (b->kind() == Builtin::KindObject || b->kind() == Builtin::KindValue)) || cl) - { - isObject = true; - } - out << nl << v << " = new " << instanceType << "();"; - out << nl << "final int __len" << iter << " = " << stream << ".readAndCheckSeqSize(" << type->minWireSize() - << ");"; - if(isObject) - { - if(b) - { - out << nl << "final String __type" << iter << " = Ice.ObjectImpl.ice_staticId();"; - } - else - { - assert(cl); - if(cl->isInterface()) - { - out << nl << "final String __type" << iter << " = " - << getAbsolute(cl, package, "_", "Disp") << ".ice_staticId();"; - } - else - { - out << nl << "final String __type" << iter << " = " << origContentS << ".ice_staticId();"; - } - } - } - out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < __len" << iter << "; __i" << iter - << "++)"; - out << sb; - if(isObject) - { - // - // Add a null value to the list as a placeholder for the element. - // - out << nl << v << ".add(null);"; - ostringstream patchParams; - patchParams << "new IceInternal.ListPatcher<" << origContentS << ">(" << v << ", " << origContentS - << ".class, __type" << iter << ", __i" << iter << ')'; - writeStreamMarshalUnmarshalCode(out, package, type, false, 0, "__elem", false, iter, false, - StringList(), patchParams.str()); - } - else - { - if(StructPtr::dynamicCast(type)) - { - out << nl << cont << " __elem = null;"; - } - else - { - out << nl << cont << " __elem;"; - } - writeStreamMarshalUnmarshalCode(out, package, type, false, 0, "__elem", false, iter, false); - } - if(!isObject) - { - out << nl << v << ".add(__elem);"; - } - out << eb; - iter++; - } - } - else - { - BuiltinPtr b = BuiltinPtr::dynamicCast(type); - if(b && b->kind() != Builtin::KindObject && - b->kind() != Builtin::KindValue && - b->kind() != Builtin::KindObjectProxy) - { - switch(b->kind()) - { - case Builtin::KindByte: - { - if(marshal) - { - out << nl << stream << ".writeByteSeq(" << v << ");"; - } - else - { - out << nl << v << " = " << stream << ".readByteSeq();"; - } - break; - } - case Builtin::KindBool: - { - if(marshal) - { - out << nl << stream << ".writeBoolSeq(" << v << ");"; - } - else - { - out << nl << v << " = " << stream << ".readBoolSeq();"; - } - break; - } - case Builtin::KindShort: - { - if(marshal) - { - out << nl << stream << ".writeShortSeq(" << v << ");"; - } - else - { - out << nl << v << " = " << stream << ".readShortSeq();"; - } - break; - } - case Builtin::KindInt: - { - if(marshal) - { - out << nl << stream << ".writeIntSeq(" << v << ");"; - } - else - { - out << nl << v << " = " << stream << ".readIntSeq();"; - } - break; - } - case Builtin::KindLong: - { - if(marshal) - { - out << nl << stream << ".writeLongSeq(" << v << ");"; - } - else - { - out << nl << v << " = " << stream << ".readLongSeq();"; - } - break; - } - case Builtin::KindFloat: - { - if(marshal) - { - out << nl << stream << ".writeFloatSeq(" << v << ");"; - } - else - { - out << nl << v << " = " << stream << ".readFloatSeq();"; - } - break; - } - case Builtin::KindDouble: - { - if(marshal) - { - out << nl << stream << ".writeDoubleSeq(" << v << ");"; - } - else - { - out << nl << v << " = " << stream << ".readDoubleSeq();"; - } - break; - } - case Builtin::KindString: - { - if(marshal) - { - out << nl << stream << ".writeStringSeq(" << v << ");"; - } - else - { - out << nl << v << " = " << stream << ".readStringSeq();"; - } - break; - } - case Builtin::KindObject: - case Builtin::KindObjectProxy: - case Builtin::KindLocalObject: - case Builtin::KindValue: - { - assert(false); - break; - } - } - } - else - { - if(marshal) - { - out << nl << "if(" << v << " == null)"; - out << sb; - out << nl << stream << ".writeSize(0);"; - out << eb; - out << nl << "else"; - out << sb; - out << nl << stream << ".writeSize(" << v << ".length);"; - out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < " << v << ".length; __i" << iter - << "++)"; - out << sb; - ostringstream o; - o << v << "[__i" << iter << "]"; - iter++; - writeStreamMarshalUnmarshalCode(out, package, type, false, 0, o.str(), true, iter, false); - out << eb; - out << eb; - } - else - { - bool isObject = false; - ClassDeclPtr cl = ClassDeclPtr::dynamicCast(origContent); - if((b && (b->kind() == Builtin::KindObject || b->kind() == Builtin::KindValue)) || cl) - { - isObject = true; - } - out << nl << "final int __len" << iter << " = " << stream << ".readAndCheckSeqSize(" - << type->minWireSize() << ");"; - if(isObject) - { - if(b) - { - out << nl << "final String __type" << iter << " = Ice.ObjectImpl.ice_staticId();"; - } - else - { - assert(cl); - if(cl->isInterface()) - { - out << nl << "final String __type" << iter << " = " - << getAbsolute(cl, package, "_", "Disp") << ".ice_staticId();"; - } - else - { - out << nl << "final String __type" << iter << " = " << origContentS << ".ice_staticId();"; - } - } - } - // - // We cannot allocate an array of a generic type, such as - // - // arr = new Map<String, String>[sz]; - // - // Attempting to compile this code results in a "generic array creation" error - // message. This problem can occur when the sequence's element type is a - // dictionary, or when the element type is a nested sequence that uses a custom - // mapping. - // - // The solution is to rewrite the code as follows: - // - // arr = (Map<String, String>[])new Map[sz]; - // - // Unfortunately, this produces an unchecked warning during compilation. - // - // A simple test is to look for a "<" character in the content type, which - // indicates the use of a generic type. - // - string::size_type pos = origContentS.find('<'); - if(pos != string::npos) - { - string nonGenericType = origContentS.substr(0, pos); - out << nl << v << " = (" << origContentS << "[]"; - int d = depth; - while(d--) - { - out << "[]"; - } - out << ")new " << nonGenericType << "[__len" << iter << "]"; - } - else - { - out << nl << v << " = new " << origContentS << "[__len" << iter << "]"; - } - int d = depth; - while(d--) - { - out << "[]"; - } - out << ';'; - out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < __len" << iter << "; __i" << iter - << "++)"; - out << sb; - ostringstream o; - o << v << "[__i" << iter << "]"; - ostringstream patchParams; - if(isObject) - { - patchParams << "new IceInternal.SequencePatcher(" << v << ", " << origContentS - << ".class, __type" << iter << ", __i" << iter << ')'; - writeStreamMarshalUnmarshalCode(out, package, type, false, 0, o.str(), false, iter, false, - StringList(), patchParams.str()); - } - else - { - writeStreamMarshalUnmarshalCode(out, package, type, false, 0, o.str(), false, iter, false); - } - out << eb; - iter++; - } - } - } -} - bool Slice::JavaGenerator::findMetaData(const string& prefix, const StringList& metaData, string& value) { diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index 8df6121d117..447b960ac48 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -761,7 +761,7 @@ Slice::JavaVisitor::writeMarshalDataMember(Output& out, const string& package, c } else { - out << nl << "if(__has_" << member->name() << " && __os.writeOpt(" << member->tag() << ", " + out << nl << "if(__has_" << member->name() << " && __os.writeOptional(" << member->tag() << ", " << getOptionalFormat(member->type()) << "))"; out << sb; writeMarshalUnmarshalCode(out, package, member->type(), OptionalMember, false, 0, fixKwd(member->name()), true, @@ -793,7 +793,7 @@ Slice::JavaVisitor::writeUnmarshalDataMember(Output& out, const string& package, } else { - out << nl << "if(__has_" << member->name() << " = __is.readOpt(" << member->tag() << ", " + out << nl << "if(__has_" << member->name() << " = __is.readOptional(" << member->tag() << ", " << getOptionalFormat(member->type()) << "))"; out << sb; writeMarshalUnmarshalCode(out, package, member->type(), OptionalMember, false, 0, fixKwd(member->name()), false, @@ -803,66 +803,10 @@ Slice::JavaVisitor::writeUnmarshalDataMember(Output& out, const string& package, } void -Slice::JavaVisitor::writeStreamMarshalDataMember(Output& out, const string& package, const DataMemberPtr& member, - int& iter) -{ - if(!member->optional()) - { - writeStreamMarshalUnmarshalCode(out, package, member->type(), false, 0, fixKwd(member->name()), true, - iter, false, member->getMetaData()); - } - else - { - out << nl << "if(__has_" << member->name() << " && __outS.writeOptional(" << member->tag() << ", " - << getOptionalFormat(member->type()) << "))"; - out << sb; - writeStreamMarshalUnmarshalCode(out, package, member->type(), true, member->tag(), fixKwd(member->name()), - true, iter, false, member->getMetaData()); - out << eb; - } -} - -void -Slice::JavaVisitor::writeStreamUnmarshalDataMember(Output& out, const string& package, const DataMemberPtr& member, - int& iter, bool needPatcher, int& patchIter) -{ - string patchParams; - if(needPatcher) - { - BuiltinPtr builtin = BuiltinPtr::dynamicCast(member->type()); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(member->type())) - { - ostringstream ostr; - ostr << "new Patcher(" << patchIter++ << ')'; - patchParams = ostr.str(); - } - } - - if(!member->optional()) - { - writeStreamMarshalUnmarshalCode(out, package, member->type(), false, 0, fixKwd(member->name()), false, - iter, false, member->getMetaData(), patchParams); - } - else - { - out << nl << "if(__has_" << member->name() << " = __inS.readOptional(" << member->tag() << ", " - << getOptionalFormat(member->type()) << "))"; - out << sb; - writeStreamMarshalUnmarshalCode(out, package, member->type(), true, member->tag(), fixKwd(member->name()), - false, iter, false, member->getMetaData(), patchParams); - out << eb; - } -} - -void Slice::JavaVisitor::writePatcher(Output& out, const string& package, const DataMemberList& classMembers, - const DataMemberList& optionalMembers, bool stream) + const DataMemberList& optionalMembers) { - out << sp << nl << "private class Patcher implements IceInternal.Patcher"; - if(stream) - { - out << ", Ice.ReadObjectCallback"; - } + out << sp << nl << "private class Patcher implements Ice.ReadObjectCallback"; out << sb; if(classMembers.size() > 1) { @@ -872,7 +816,7 @@ Slice::JavaVisitor::writePatcher(Output& out, const string& package, const DataM out << eb; } - out << sp << nl << "public void" << nl << "patch(Ice.Object v)"; + out << sp << nl << "public void" << nl << "objectReady(Ice.Object v)"; out << sb; if(classMembers.size() > 1) { @@ -1009,14 +953,6 @@ Slice::JavaVisitor::writePatcher(Output& out, const string& package, const DataM } out << eb; - if(stream) - { - out << sp << nl << "public void" << nl << "invoke(Ice.Object v)"; - out << sb; - out << nl << "patch(v);"; - out << eb; - } - if(classMembers.size() > 1) { out << sp << nl << "private int __member;"; @@ -1027,7 +963,7 @@ Slice::JavaVisitor::writePatcher(Output& out, const string& package, const DataM } void -Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr& p, bool stream) +Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr& p) { string name = fixKwd(p->name()); string package = getPackage(p); @@ -1295,7 +1231,7 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr& // // Unmarshal 'in' parameters. // - out << nl << "IceInternal.BasicStream __is = __inS.startReadParams();"; + out << nl << "Ice.InputStream __is = __inS.startReadParams();"; for(ParamDeclList::const_iterator pli = inParams.begin(); pli != inParams.end(); ++pli) { TypePtr paramType = (*pli)->type(); @@ -1387,7 +1323,7 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr& // if(!outParams.empty() || ret) { - out << nl << "IceInternal.BasicStream __os = __inS.__startWriteParams(" + out << nl << "Ice.OutputStream __os = __inS.__startWriteParams(" << opFormatTypeToString(op) << ");"; writeMarshalUnmarshalParams(out, package, outParams, op, iter, true, optionalMapping, true); if(op->returnsClasses(false)) @@ -1442,7 +1378,7 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr& // // Unmarshal 'in' parameters. // - out << nl << "IceInternal.BasicStream __is = __inS.startReadParams();"; + out << nl << "Ice.InputStream __is = __inS.startReadParams();"; iter = 0; for(ParamDeclList::const_iterator pli = inParams.begin(); pli != inParams.end(); ++pli) { @@ -1687,48 +1623,24 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr& if(preserved && !basePreserved) { - out << sp << nl << "public void __write(IceInternal.BasicStream __os)"; + out << sp << nl << "public void __write(Ice.OutputStream __os)"; out << sb; - out << nl << "__os.startWriteObject(__slicedData);"; + out << nl << "__os.startObject(__slicedData);"; out << nl << "__writeImpl(__os);"; - out << nl << "__os.endWriteObject();"; + out << nl << "__os.endObject();"; out << eb; - out << sp << nl << "public void __read(IceInternal.BasicStream __is)"; + out << sp << nl << "public void __read(Ice.InputStream __is)"; out << sb; - out << nl << "__is.startReadObject();"; + out << nl << "__is.startObject();"; out << nl << "__readImpl(__is);"; - out << nl << "__slicedData = __is.endReadObject(true);"; + out << nl << "__slicedData = __is.endObject(true);"; out << eb; - - if(stream) - { - out << sp << nl << "public void __write(Ice.OutputStream __outS)"; - out << sb; - if(preserved) - { - out << nl << "__outS.startObject(__slicedData);"; - } - else - { - out << nl << "__outS.startObject(null);"; - } - out << nl << "__writeImpl(__outS);"; - out << nl << "__outS.endObject();"; - out << eb; - - out << sp << nl << "public void __read(Ice.InputStream __inS)"; - out << sb; - out << nl << "__inS.startObject();"; - out << nl << "__readImpl(__inS);"; - out << nl << "__slicedData = __inS.endObject(true);"; - out << eb; - } } - out << sp << nl << "protected void __writeImpl(IceInternal.BasicStream __os)"; + out << sp << nl << "protected void __writeImpl(Ice.OutputStream __os)"; out << sb; - out << nl << "__os.startWriteSlice(ice_staticId(), " << p->compactId() << (!base ? ", true" : ", false") << ");"; + out << nl << "__os.startSlice(ice_staticId(), " << p->compactId() << (!base ? ", true" : ", false") << ");"; iter = 0; for(DataMemberList::const_iterator d = members.begin(); d != members.end(); ++d) { @@ -1741,7 +1653,7 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr& { writeMarshalDataMember(out, package, *d, iter); } - out << nl << "__os.endWriteSlice();"; + out << nl << "__os.endSlice();"; if(base) { out << nl << "super.__writeImpl(__os);"; @@ -1753,12 +1665,12 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr& if(classMembers.size() != 0) { - writePatcher(out, package, classMembers, optionalMembers, stream); + writePatcher(out, package, classMembers, optionalMembers); } - out << sp << nl << "protected void __readImpl(IceInternal.BasicStream __is)"; + out << sp << nl << "protected void __readImpl(Ice.InputStream __is)"; out << sb; - out << nl << "__is.startReadSlice();"; + out << nl << "__is.startSlice();"; int patchIter = 0; const bool needCustomPatcher = classMembers.size() > 1; @@ -1774,61 +1686,13 @@ Slice::JavaVisitor::writeDispatchAndMarshalling(Output& out, const ClassDefPtr& { writeUnmarshalDataMember(out, package, *d, iter, needCustomPatcher, patchIter); } - out << nl << "__is.endReadSlice();"; + out << nl << "__is.endSlice();"; if(base) { out << nl << "super.__readImpl(__is);"; } out << eb; - if(stream) - { - out << sp << nl << "protected void __writeImpl(Ice.OutputStream __outS)"; - out << sb; - out << nl << "__outS.startSlice(ice_staticId(), " << p->compactId() << (!base ? ", true" : ", false") << ");"; - iter = 0; - for(DataMemberList::const_iterator d = members.begin(); d != members.end(); ++d) - { - if(!(*d)->optional()) - { - writeStreamMarshalDataMember(out, package, *d, iter); - } - } - for(DataMemberList::const_iterator d = optionalMembers.begin(); d != optionalMembers.end(); ++d) - { - writeStreamMarshalDataMember(out, package, *d, iter); - } - out << nl << "__outS.endSlice();"; - if(base) - { - out << nl << "super.__writeImpl(__outS);"; - } - out << eb; - - out << sp << nl << "protected void __readImpl(Ice.InputStream __inS)"; - out << sb; - out << nl << "__inS.startSlice();"; - iter = 0; - patchIter = 0; - for(DataMemberList::const_iterator d = members.begin(); d != members.end(); ++d) - { - if(!(*d)->optional()) - { - writeStreamUnmarshalDataMember(out, package, *d, iter, needCustomPatcher, patchIter); - } - } - for(DataMemberList::const_iterator d = optionalMembers.begin(); d != optionalMembers.end(); ++d) - { - writeStreamUnmarshalDataMember(out, package, *d, iter, needCustomPatcher, patchIter); - } - out << nl << "__inS.endSlice();"; - if(base) - { - out << nl << "super.__readImpl(__inS);"; - } - out << eb; - } - if(preserved && !basePreserved) { out << sp << nl << "protected Ice.SlicedData __slicedData;"; @@ -2397,7 +2261,7 @@ Slice::Gen::~Gen() } void -Slice::Gen::generate(const UnitPtr& p, bool stream) +Slice::Gen::generate(const UnitPtr& p) { JavaGenerator::validateMetaData(p); @@ -2407,7 +2271,7 @@ Slice::Gen::generate(const UnitPtr& p, bool stream) PackageVisitor packageVisitor(_dir); p->visit(&packageVisitor, false); - TypesVisitor typesVisitor(_dir, stream); + TypesVisitor typesVisitor(_dir); p->visit(&typesVisitor, false); CompactIdVisitor compactIdVisitor(_dir); @@ -2416,13 +2280,13 @@ Slice::Gen::generate(const UnitPtr& p, bool stream) HolderVisitor holderVisitor(_dir); p->visit(&holderVisitor, false); - HelperVisitor helperVisitor(_dir, stream); + HelperVisitor helperVisitor(_dir); p->visit(&helperVisitor, false); ProxyVisitor proxyVisitor(_dir); p->visit(&proxyVisitor, false); - DispatcherVisitor dispatcherVisitor(_dir, stream); + DispatcherVisitor dispatcherVisitor(_dir); p->visit(&dispatcherVisitor, false); AsyncVisitor asyncVisitor(_dir); @@ -2884,8 +2748,8 @@ Slice::Gen::PackageVisitor::visitModuleStart(const ModulePtr& p) return false; } -Slice::Gen::TypesVisitor::TypesVisitor(const string& dir, bool stream) : - JavaVisitor(dir), _stream(stream) +Slice::Gen::TypesVisitor::TypesVisitor(const string& dir) : + JavaVisitor(dir) { } @@ -3298,7 +3162,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) // if(!p->isInterface() && !p->isLocal()) { - writeDispatchAndMarshalling(out, p, _stream); + writeDispatchAndMarshalling(out, p); } return true; @@ -3682,41 +3546,24 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) if(preserved && !basePreserved) { - out << sp << nl << "public void" << nl << "__write(IceInternal.BasicStream __os)"; + out << sp << nl << "public void" << nl << "__write(Ice.OutputStream __os)"; out << sb; - out << nl << "__os.startWriteException(__slicedData);"; + out << nl << "__os.startException(__slicedData);"; out << nl << "__writeImpl(__os);"; - out << nl << "__os.endWriteException();"; + out << nl << "__os.endException();"; out << eb; - out << sp << nl << "public void" << nl << "__read(IceInternal.BasicStream __is)"; + out << sp << nl << "public void" << nl << "__read(Ice.InputStream __is)"; out << sb; - out << nl << "__is.startReadException();"; + out << nl << "__is.startException();"; out << nl << "__readImpl(__is);"; - out << nl << "__slicedData = __is.endReadException(true);"; + out << nl << "__slicedData = __is.endException(true);"; out << eb; - - if(_stream) - { - out << sp << nl << "public void" << nl << "__write(Ice.OutputStream __outS)"; - out << sb; - out << nl << "__outS.startException(__slicedData);"; - out << nl << "__writeImpl(__outS);"; - out << nl << "__outS.endException();"; - out << eb; - - out << sp << nl << "public void" << nl << "__read(Ice.InputStream __inS)"; - out << sb; - out << nl << "__inS.startException();"; - out << nl << "__readImpl(__inS);"; - out << nl << "__slicedData = __inS.endException(true);"; - out << eb; - } } - out << sp << nl << "protected void" << nl << "__writeImpl(IceInternal.BasicStream __os)"; + out << sp << nl << "protected void" << nl << "__writeImpl(Ice.OutputStream __os)"; out << sb; - out << nl << "__os.startWriteSlice(\"" << scoped << "\", -1, " << (!base ? "true" : "false") << ");"; + out << nl << "__os.startSlice(\"" << scoped << "\", -1, " << (!base ? "true" : "false") << ");"; iter = 0; for(DataMemberList::const_iterator d = members.begin(); d != members.end(); ++d) { @@ -3729,7 +3576,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) { writeMarshalDataMember(out, package, *d, iter); } - out << nl << "__os.endWriteSlice();"; + out << nl << "__os.endSlice();"; if(base) { out << nl << "super.__writeImpl(__os);"; @@ -3741,11 +3588,11 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) if(classMembers.size() != 0) { - writePatcher(out, package, classMembers, optionalMembers, _stream); + writePatcher(out, package, classMembers, optionalMembers); } - out << sp << nl << "protected void" << nl << "__readImpl(IceInternal.BasicStream __is)"; + out << sp << nl << "protected void" << nl << "__readImpl(Ice.InputStream __is)"; out << sb; - out << nl << "__is.startReadSlice();"; + out << nl << "__is.startSlice();"; iter = 0; int patchIter = 0; const bool needCustomPatcher = classMembers.size() > 1; @@ -3760,61 +3607,13 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) { writeUnmarshalDataMember(out, package, *d, iter, needCustomPatcher, patchIter); } - out << nl << "__is.endReadSlice();"; + out << nl << "__is.endSlice();"; if(base) { out << nl << "super.__readImpl(__is);"; } out << eb; - if(_stream) - { - out << sp << nl << "protected void" << nl << "__writeImpl(Ice.OutputStream __outS)"; - out << sb; - out << nl << "__outS.startSlice(\"" << scoped << "\", -1, " << (!base ? "true" : "false") << ");"; - iter = 0; - for(DataMemberList::const_iterator d = members.begin(); d != members.end(); ++d) - { - if(!(*d)->optional()) - { - writeStreamMarshalDataMember(out, package, *d, iter); - } - } - for(DataMemberList::const_iterator d = optionalMembers.begin(); d != optionalMembers.end(); ++d) - { - writeStreamMarshalDataMember(out, package, *d, iter); - } - out << nl << "__outS.endSlice();"; - if(base) - { - out << nl << "super.__writeImpl(__outS);"; - } - out << eb; - - out << sp << nl << "protected void" << nl << "__readImpl(Ice.InputStream __inS)"; - out << sb; - out << nl << "__inS.startSlice();"; - iter = 0; - patchIter = 0; - for(DataMemberList::const_iterator d = members.begin(); d != members.end(); ++d) - { - if(!(*d)->optional()) - { - writeStreamUnmarshalDataMember(out, package, *d, iter, needCustomPatcher, patchIter); - } - } - for(DataMemberList::const_iterator d = optionalMembers.begin(); d != optionalMembers.end(); ++d) - { - writeStreamUnmarshalDataMember(out, package, *d, iter, needCustomPatcher, patchIter); - } - out << nl << "__inS.endSlice();"; - if(base) - { - out << nl << "super.__readImpl(__inS);"; - } - out << eb; - } - if(p->usesClasses(false)) { if(!base || (base && !base->usesClasses(false))) @@ -4074,7 +3873,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) if(!p->isLocal()) { - out << sp << nl << "public void" << nl << "__write(IceInternal.BasicStream __os)"; + out << sp << nl << "public void" << nl << "ice_write(Ice.OutputStream __os)"; out << sb; iter = 0; for(DataMemberList::const_iterator d = members.begin(); d != members.end(); ++d) @@ -4087,10 +3886,10 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) if(classMembers.size() != 0) { - writePatcher(out, package, classMembers, DataMemberList(), _stream); + writePatcher(out, package, classMembers, DataMemberList()); } - out << sp << nl << "public void" << nl << "__read(IceInternal.BasicStream __is)"; + out << sp << nl << "public void" << nl << "ice_read(Ice.InputStream __is)"; out << sb; iter = 0; int patchIter = 0; @@ -4101,75 +3900,28 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) } out << eb; - if(_stream) - { - out << sp << nl << "public void" << nl << "ice_write(Ice.OutputStream __outS)"; - out << sb; - iter = 0; - for(DataMemberList::const_iterator d = members.begin(); d != members.end(); ++d) - { - writeStreamMarshalDataMember(out, package, *d, iter); - } - out << eb; - - out << sp << nl << "public void" << nl << "ice_read(Ice.InputStream __inS)"; - out << sb; - iter = 0; - patchIter = 0; - for(DataMemberList::const_iterator d = members.begin(); d != members.end(); ++d) - { - writeStreamUnmarshalDataMember(out, package, *d, iter, needCustomPatcher, patchIter); - } - out << eb; - } - - out << sp << nl << "static public void" << nl << "__write(IceInternal.BasicStream __os, " << name << " __v)"; + out << sp << nl << "static public void" << nl << "ice_write(Ice.OutputStream __os, " << name << " __v)"; out << sb; out << nl << "if(__v == null)"; out << sb; - out << nl << "__nullMarshalValue.__write(__os);"; + out << nl << "__nullMarshalValue.ice_write(__os);"; out << eb; out << nl << "else"; out << sb; - out << nl << "__v.__write(__os);"; + out << nl << "__v.ice_write(__os);"; out << eb; out << eb; - out << sp << nl << "static public " << name << nl << "__read(IceInternal.BasicStream __is, " << name << " __v)"; + out << sp << nl << "static public " << name << nl << "ice_read(Ice.InputStream __is, " << name << " __v)"; out << sb; out << nl << "if(__v == null)"; out << sb; out << nl << " __v = new " << name << "();"; out << eb; - out << nl << "__v.__read(__is);"; + out << nl << "__v.ice_read(__is);"; out << nl << "return __v;"; out << eb; - if(_stream) - { - out << sp << nl << "static public void" << nl << "ice_write(Ice.OutputStream __outS, " << name << " __v)"; - out << sb; - out << nl << "if(__v == null)"; - out << sb; - out << nl << "__nullMarshalValue.ice_write(__outS);"; - out << eb; - out << nl << "else"; - out << sb; - out << nl << "__v.ice_write(__outS);"; - out << eb; - out << eb; - - out << sp << nl << "static public " << name << nl << "ice_read(Ice.InputStream __inS, " << name << " __v)"; - out << sb; - out << nl << "if(__v == null)"; - out << sb; - out << nl << " __v = new " << name << "();"; - out << eb; - out << nl << "__v.ice_read(__inS);"; - out << nl << "return __v;"; - out << eb; - } - out << nl << nl << "private static final " << name << " __nullMarshalValue = new " << name << "();"; } @@ -4539,12 +4291,12 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) if(!p->isLocal()) { - out << sp << nl << "public void" << nl << "__write(IceInternal.BasicStream __os)"; + out << sp << nl << "public void" << nl << "ice_write(Ice.OutputStream __os)"; out << sb; out << nl << "__os.writeEnum(value(), " << p->maxValue() << ");"; out << eb; - out << sp << nl << "public static void" << nl << "__write(IceInternal.BasicStream __os, " << name << " __v)"; + out << sp << nl << "public static void" << nl << "ice_write(Ice.OutputStream __os, " << name << " __v)"; out << sb; out << nl << "if(__v == null)"; out << sb; @@ -4557,38 +4309,12 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) out << eb; out << eb; - out << sp << nl << "public static " << name << nl << "__read(IceInternal.BasicStream __is)"; + out << sp << nl << "public static " << name << nl << "ice_read(Ice.InputStream __is)"; out << sb; out << nl << "int __v = __is.readEnum(" << p->maxValue() << ");"; out << nl << "return __validate(__v);"; out << eb; - if(_stream) - { - out << sp << nl << "public void" << nl << "ice_write(Ice.OutputStream __outS)"; - out << sb; - out << nl << "__outS.writeEnum(value(), " << p->maxValue() << ");"; - out << eb; - - out << sp << nl << "public static void" << nl << "ice_write(Ice.OutputStream __outS, " << name << " __v)"; - out << sb; - out << nl << "if(__v == null)"; - out << sb; - out << nl << "__outS.writeEnum(" << absolute << '.' << firstEnum << ".value(), " << p->maxValue() << ");"; - out << eb; - out << nl << "else"; - out << sb; - out << nl << "__outS.writeEnum(__v.value(), " << p->maxValue() << ");"; - out << eb; - out << eb; - - out << sp << nl << "public static " << name << nl << "ice_read(Ice.InputStream __inS)"; - out << sb; - out << nl << "int __v = __inS.readEnum(" << p->maxValue() << ");"; - out << nl << "return __validate(__v);"; - out << eb; - } - out << sp << nl << "private static " << name << nl << "__validate(int __v)"; out << sb; @@ -4786,7 +4512,7 @@ Slice::Gen::HolderVisitor::writeHolder(const TypePtr& p) out << eb; out << sp << nl << "public void"; - out << nl << "patch(Ice.Object v)"; + out << nl << "objectReady(Ice.Object v)"; out << sb; out << nl << "if(v == null || v instanceof " << typeS << ")"; out << sb; @@ -4830,8 +4556,8 @@ Slice::Gen::HolderVisitor::writeHolder(const TypePtr& p) close(); } -Slice::Gen::HelperVisitor::HelperVisitor(const string& dir, bool stream) : - JavaVisitor(dir), _stream(stream) +Slice::Gen::HelperVisitor::HelperVisitor(const string& dir) : + JavaVisitor(dir) { } @@ -4949,7 +4675,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) if(ret || !outParams.empty()) { - out << nl << "IceInternal.BasicStream __is = __result.startReadParams();"; + out << nl << "Ice.InputStream __is = __result.startReadParams();"; const ParamDeclList paramList = op->parameters(); ParamDeclList pl; for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli) @@ -5157,12 +4883,12 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) out << nl << "return __ids[" << scopedPos << "];"; out << eb; - out << sp << nl << "public static void __write(IceInternal.BasicStream __os, " << name << "Prx v)"; + out << sp << nl << "public static void __write(Ice.OutputStream __os, " << name << "Prx v)"; out << sb; out << nl << "__os.writeProxy(v);"; out << eb; - out << sp << nl << "public static " << name << "Prx __read(IceInternal.BasicStream __is)"; + out << sp << nl << "public static " << name << "Prx __read(Ice.InputStream __is)"; out << sb; out << nl << "Ice.ObjectPrx proxy = __is.readProxy();"; out << nl << "if(proxy != null)"; @@ -5174,31 +4900,6 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) out << nl << "return null;"; out << eb; - if(_stream) - { - out << sp << nl << "public static void write(Ice.OutputStream __outS, " << name << "Prx v)"; - out << sb; - out << nl << "__outS.writeProxy(v);"; - out << eb; - - out << sp << nl << "public static " << name << "Prx read(Ice.InputStream __inS)"; - out << sb; - out << nl << "Ice.ObjectPrx proxy = __inS.readProxy();"; - out << nl << "if(proxy != null)"; - out << sb; - out << nl << name << "PrxHelper result = new " << name << "PrxHelper();"; - out << nl << "result.__copyFrom(proxy);"; - out << nl << "return result;"; - out << eb; - out << nl << "return null;"; - out << eb; - - out << sp << nl << "public static Ice.OptionalFormat optionalFormat()"; - out << sb; - out << nl << "return Ice.OptionalFormat.FSize;"; - out << eb; - } - // // Avoid serialVersionUID warnings for Proxy Helper classes. // @@ -5207,76 +4908,6 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) close(); - if(_stream) - { - // - // Class helper. - // - open(getAbsolute(p, "", "", "Helper"), p->file()); - - Output& out2 = output(); - - out2 << sp << nl << "public final class " << name << "Helper"; - out2 << sb; - - out2 << sp << nl << "public static void write(Ice.OutputStream __outS, " << fixKwd(name) << " __v)"; - out2 << sb; - out2 << nl << "__outS.writeObject(__v);"; - out2 << eb; - - out2 << sp << nl << "public static void read(Ice.InputStream __inS, " << name << "Holder __h)"; - out2 << sb; - out2 << nl << "__inS.readObject(__h);"; - out2 << eb; - - out2 << sp << nl << "public static Ice.OptionalFormat optionalFormat()"; - out2 << sb; - out2 << nl << "return " << getOptionalFormat(p->declaration()) << ';'; - out2 << eb; - - out2 << eb; - close(); - } - - return false; -} - -bool -Slice::Gen::HelperVisitor::visitStructStart(const StructPtr& p) -{ - if(!p->isLocal() && _stream) - { - string name = p->name(); - string fixedName = fixKwd(name); - - open(getAbsolute(p, "", "", "Helper"), p->file()); - - Output& out = output(); - - out << sp << nl << "public final class " << name << "Helper"; - out << sb; - - out << sp << nl << "public static void write(Ice.OutputStream __outS, " << fixedName << " __v)"; - out << sb; - out << nl << "__v.ice_write(__outS);"; - out << eb; - - out << sp << nl << "public static " << fixedName << " read(Ice.InputStream __inS)"; - out << sb; - out << nl << fixedName << " __v = new " << fixedName << "();"; - out << nl << "__v.ice_read(__inS);"; - out << nl << "return __v;"; - out << eb; - - out << sp << nl << "public static Ice.OptionalFormat optionalFormat()"; - out << sb; - out << nl << "return " << getOptionalFormat(p) << ';'; - out << eb; - - out << eb; - close(); - } - return false; } @@ -5370,7 +5001,7 @@ Slice::Gen::HelperVisitor::visitSequence(const SequencePtr& p) out << sp << nl << "public final class " << name << "Helper"; out << sb; - out << nl << "public static void" << nl << "write(IceInternal.BasicStream __os, " << typeS << " __v)"; + out << nl << "public static void" << nl << "write(Ice.OutputStream __os, " << typeS << " __v)"; out << sb; iter = 0; writeSequenceMarshalUnmarshalCode(out, package, p, "__v", true, iter, false); @@ -5381,7 +5012,7 @@ Slice::Gen::HelperVisitor::visitSequence(const SequencePtr& p) { out << nl << "@SuppressWarnings(\"unchecked\")"; } - out << nl << "public static " << typeS << nl << "read(IceInternal.BasicStream __is)"; + out << nl << "public static " << typeS << nl << "read(Ice.InputStream __is)"; out << sb; out << nl << typeS << " __v;"; iter = 0; @@ -5389,33 +5020,6 @@ Slice::Gen::HelperVisitor::visitSequence(const SequencePtr& p) out << nl << "return __v;"; out << eb; - if(_stream) - { - out << sp << nl << "public static void write(Ice.OutputStream __outS, " << typeS << " __v)"; - out << sb; - iter = 0; - writeStreamSequenceMarshalUnmarshalCode(out, package, p, "__v", true, iter, false); - out << eb; - - out << sp; - if(suppressUnchecked) - { - out << nl << "@SuppressWarnings(\"unchecked\")"; - } - out << nl << "public static " << typeS << " read(Ice.InputStream __inS)"; - out << sb; - out << nl << typeS << " __v;"; - iter = 0; - writeStreamSequenceMarshalUnmarshalCode(out, package, p, "__v", false, iter, false); - out << nl << "return __v;"; - out << eb; - - out << sp << nl << "public static Ice.OptionalFormat optionalFormat()"; - out << sb; - out << nl << "return " << getOptionalFormat(p) << ';'; - out << eb; - } - out << eb; close(); } @@ -5449,14 +5053,14 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) out << sp << nl << "public final class " << name << "Helper"; out << sb; - out << nl << "public static void" << nl << "write(IceInternal.BasicStream __os, " << formalType << " __v)"; + out << nl << "public static void" << nl << "write(Ice.OutputStream __os, " << formalType << " __v)"; out << sb; iter = 0; writeDictionaryMarshalUnmarshalCode(out, package, p, "__v", true, iter, false); out << eb; out << sp << nl << "public static " << formalType - << nl << "read(IceInternal.BasicStream __is)"; + << nl << "read(Ice.InputStream __is)"; out << sb; out << nl << formalType << " __v;"; iter = 0; @@ -5464,69 +5068,11 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) out << nl << "return __v;"; out << eb; - if(_stream) - { - out << sp << nl << "public static void write(Ice.OutputStream __outS, " << formalType - << " __v)"; - out << sb; - iter = 0; - writeStreamDictionaryMarshalUnmarshalCode(out, package, p, "__v", true, iter, false); - out << eb; - - out << sp << nl << "public static " << formalType << " read(Ice.InputStream __inS)"; - out << sb; - out << nl << formalType << " __v;"; - iter = 0; - writeStreamDictionaryMarshalUnmarshalCode(out, package, p, "__v", false, iter, false); - out << nl << "return __v;"; - out << eb; - - out << sp << nl << "public static Ice.OptionalFormat optionalFormat()"; - out << sb; - out << nl << "return " << getOptionalFormat(p) << ';'; - out << eb; - } - out << eb; close(); } void -Slice::Gen::HelperVisitor::visitEnum(const EnumPtr& p) -{ - if(!p->isLocal() && _stream) - { - string name = p->name(); - string fixedName = fixKwd(name); - - open(getAbsolute(p, "", "", "Helper"), p->file()); - - Output& out = output(); - - out << sp << nl << "public final class " << name << "Helper"; - out << sb; - - out << sp << nl << "public static void write(Ice.OutputStream __outS, " << fixedName << " __v)"; - out << sb; - out << nl << "__v.ice_write(__outS);"; - out << eb; - - out << sp << nl << "public static " << fixedName << " read(Ice.InputStream __inS)"; - out << sb; - out << nl << "return " << fixedName << ".ice_read(__inS);"; - out << eb; - - out << sp << nl << "public static Ice.OptionalFormat optionalFormat()"; - out << sb; - out << nl << "return " << getOptionalFormat(p) << ';'; - out << eb; - - out << eb; - close(); - } -} - -void Slice::Gen::HelperVisitor::writeOperation(const ClassDefPtr& p, const string& package, const OperationPtr& op, bool optionalMapping) { @@ -5875,7 +5421,7 @@ Slice::Gen::HelperVisitor::writeOperation(const ClassDefPtr& p, const string& pa iter = 0; if(!inArgs.empty()) { - out << nl << "IceInternal.BasicStream __os = __result.startWriteParams(" + out << nl << "Ice.OutputStream __os = __result.startWriteParams(" << opFormatTypeToString(op) << ");"; ParamDeclList pl; for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli) @@ -6211,8 +5757,8 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) } } -Slice::Gen::DispatcherVisitor::DispatcherVisitor(const string& dir, bool stream) : - JavaVisitor(dir), _stream(stream) +Slice::Gen::DispatcherVisitor::DispatcherVisitor(const string& dir) : + JavaVisitor(dir) { } @@ -6245,7 +5791,7 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p) out << nl << "throw new java.lang.CloneNotSupportedException();"; out << eb; - writeDispatchAndMarshalling(out, p, _stream); + writeDispatchAndMarshalling(out, p); // // Avoid serialVersionUID warnings for dispatch classes. @@ -6850,7 +6396,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) { out << nl << "try"; out << sb; - out << nl << "IceInternal.BasicStream __os = this.__startWriteParams(" + out << nl << "Ice.OutputStream __os = this.__startWriteParams(" << opFormatTypeToString(p) << ");"; writeMarshalUnmarshalParams(out, classPkg, outParams, p, iter, true, optionalMapping, false); if(p->returnsClasses(false)) diff --git a/cpp/src/slice2java/Gen.h b/cpp/src/slice2java/Gen.h index e4def10d75e..eb3b5f914fb 100644 --- a/cpp/src/slice2java/Gen.h +++ b/cpp/src/slice2java/Gen.h @@ -86,12 +86,12 @@ protected: // // Generate a patcher class. // - void writePatcher(::IceUtilInternal::Output&, const std::string&, const DataMemberList&, const DataMemberList&, bool); + void writePatcher(::IceUtilInternal::Output&, const std::string&, const DataMemberList&, const DataMemberList&); // // Generate dispatch and marshalling methods for a class or interface. // - void writeDispatchAndMarshalling(::IceUtilInternal::Output&, const ClassDefPtr&, bool); + void writeDispatchAndMarshalling(::IceUtilInternal::Output&, const ClassDefPtr&); // // Write a constant or default value initializer. @@ -129,7 +129,7 @@ public: const std::string&); ~Gen(); - void generate(const UnitPtr&, bool); + void generate(const UnitPtr&); void generateTie(const UnitPtr&); void generateImpl(const UnitPtr&); void generateImplTie(const UnitPtr&); @@ -176,7 +176,7 @@ private: { public: - TypesVisitor(const std::string&, bool); + TypesVisitor(const std::string&); virtual bool visitClassDefStart(const ClassDefPtr&); virtual void visitClassDefEnd(const ClassDefPtr&); @@ -194,8 +194,6 @@ private: // Verifies that a data member method does not conflict with an operation. // bool validateMethod(const OperationList&, const std::string&, int, const std::string&, const std::string&); - - bool _stream; }; class CompactIdVisitor : public JavaVisitor @@ -228,19 +226,15 @@ private: { public: - HelperVisitor(const std::string&, bool); + HelperVisitor(const std::string&); virtual bool visitClassDefStart(const ClassDefPtr&); - virtual bool visitStructStart(const StructPtr&); virtual void visitSequence(const SequencePtr&); virtual void visitDictionary(const DictionaryPtr&); - virtual void visitEnum(const EnumPtr&); private: void writeOperation(const ClassDefPtr&, const std::string&, const OperationPtr&, bool); - - bool _stream; }; class ProxyVisitor : public JavaVisitor @@ -258,13 +252,9 @@ private: { public: - DispatcherVisitor(const std::string&, bool); + DispatcherVisitor(const std::string&); virtual bool visitClassDefStart(const ClassDefPtr&); - - private: - - bool _stream; }; class BaseImplVisitor : public JavaVisitor diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp index de53ef640da..8396b17f99a 100644 --- a/cpp/src/slice2java/Main.cpp +++ b/cpp/src/slice2java/Main.cpp @@ -80,7 +80,6 @@ usage(const char* n) "--ice Allow reserved Ice prefix in Slice identifiers.\n" "--underscore Allow underscores in Slice identifiers.\n" "--checksum CLASS Generate checksums for Slice definitions into CLASS.\n" - "--stream Generate marshaling support for public stream API.\n" "--meta META Define global metadata directive META.\n" ; } @@ -108,7 +107,6 @@ compile(int argc, char* argv[]) opts.addOpt("", "ice"); opts.addOpt("", "underscore"); opts.addOpt("", "checksum", IceUtilInternal::Options::NeedArg); - opts.addOpt("", "stream"); opts.addOpt("", "meta", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); @@ -189,8 +187,6 @@ compile(int argc, char* argv[]) string checksumClass = opts.optArg("checksum"); - bool stream = opts.isSet("stream"); - bool listGenerated = opts.isSet("list-generated"); StringList globalMetadata; @@ -353,7 +349,7 @@ compile(int argc, char* argv[]) try { Gen gen(argv[0], icecpp->getBaseName(), includePaths, output); - gen.generate(p, stream); + gen.generate(p); if(tie) { gen.generateTie(p); |