diff options
Diffstat (limited to 'cpp/src')
-rwxr-xr-x | cpp/src/Ice/BasicStream.cpp | 39 | ||||
-rw-r--r-- | cpp/src/Ice/SlicedData.cpp | 6 | ||||
-rw-r--r-- | cpp/src/Ice/StreamI.cpp | 16 | ||||
-rw-r--r-- | cpp/src/Ice/StreamI.h | 5 | ||||
-rw-r--r-- | cpp/src/Slice/CPlusPlusUtil.cpp | 5 | ||||
-rwxr-xr-x | cpp/src/Slice/PythonUtil.cpp | 47 | ||||
-rw-r--r-- | cpp/src/Slice/Scanner.cpp | 59 | ||||
-rw-r--r-- | cpp/src/Slice/Scanner.l | 7 |
8 files changed, 137 insertions, 47 deletions
diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp index d8cf31ff20e..07fa34c50b0 100755 --- a/cpp/src/Ice/BasicStream.cpp +++ b/cpp/src/Ice/BasicStream.cpp @@ -97,7 +97,8 @@ IceInternal::BasicStream::BasicStream(Instance* instance, const EncodingVersion& _unlimited(unlimited), _stringConverter(instance->initializationData().stringConverter), _wstringConverter(instance->initializationData().wstringConverter), - _startSeq(-1) + _startSeq(-1), + _sizePos(-1) { // // Initialize the encoding members of our pre-allocated encapsulations, in case @@ -126,6 +127,8 @@ IceInternal::BasicStream::clear() _startSeq = -1; + _sizePos = -1; + _sliceObjects = true; } @@ -163,6 +166,7 @@ IceInternal::BasicStream::swap(BasicStream& other) std::swap(_unlimited, other._unlimited); std::swap(_startSeq, other._startSeq); std::swap(_minSeqSize, other._minSeqSize); + std::swap(_sizePos, other._sizePos); } void @@ -2754,12 +2758,39 @@ IceInternal::BasicStream::EncapsDecoder::readInstance() skipSlice(); // - // If this is the last slice, keep the object as an opaque - // UnknownSlicedData object. + // If this is the last slice, keep the object as an opaque UnknownSlicedObject. // if(_sliceFlags & FLAG_IS_LAST_SLICE) { - v = new UnknownSlicedObject(mostDerivedId); + // + // Provide a factory with an opportunity to supply the object. + // We pass the "::Ice::Object" ID to indicate that this is the + // last chance to preserve the object. + // + userFactory = servantFactoryManager->find(Object::ice_staticId()); + if(userFactory) + { + v = userFactory->create(Object::ice_staticId()); + } + + // + // If that fails, invoke the default factory if one has been + // registered. + // + if(!v) + { + userFactory = servantFactoryManager->find(""); + if(userFactory) + { + v = userFactory->create(Object::ice_staticId()); + } + } + + if(!v) + { + v = new UnknownSlicedObject(mostDerivedId); + } + break; } diff --git a/cpp/src/Ice/SlicedData.cpp b/cpp/src/Ice/SlicedData.cpp index 9b2e88b609c..5332719eec9 100644 --- a/cpp/src/Ice/SlicedData.cpp +++ b/cpp/src/Ice/SlicedData.cpp @@ -82,6 +82,12 @@ Ice::UnknownSlicedObject::getUnknownTypeId() const return _unknownTypeId; } +SlicedDataPtr +Ice::UnknownSlicedObject::getSlicedData() const +{ + return _slicedData; +} + void Ice::UnknownSlicedObject::__addObject(IceInternal::GCCountMap& _c) { diff --git a/cpp/src/Ice/StreamI.cpp b/cpp/src/Ice/StreamI.cpp index e1e73f94617..431926d64b0 100644 --- a/cpp/src/Ice/StreamI.cpp +++ b/cpp/src/Ice/StreamI.cpp @@ -570,10 +570,10 @@ OutputStreamI::write(const Double* begin, const Double* end) _os->write(begin, end); } -void +bool OutputStreamI::writeOptional(Int tag, OptionalType type) { - _os->writeOpt(tag, type); + return _os->writeOpt(tag, type); } void @@ -677,6 +677,18 @@ OutputStreamI::rewrite(Int sz, size_type p) _os->rewrite(sz, p); } +void +OutputStreamI::startSize() +{ + _os->startSize(); +} + +void +OutputStreamI::endSize() +{ + _os->endSize(); +} + // // ObjectReader // diff --git a/cpp/src/Ice/StreamI.h b/cpp/src/Ice/StreamI.h index 8d9bba4e977..ba0d103a640 100644 --- a/cpp/src/Ice/StreamI.h +++ b/cpp/src/Ice/StreamI.h @@ -147,7 +147,7 @@ public: using OutputStream::write; #endif - virtual void writeOptional(Int, OptionalType); + virtual bool writeOptional(Int, OptionalType); virtual void startObject(const SlicedDataPtr&); virtual void endObject(); @@ -173,6 +173,9 @@ public: virtual size_type pos(); virtual void rewrite(Int, size_type); + virtual void startSize(); + virtual void endSize(); + private: const CommunicatorPtr _communicator; diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp index c14476148c2..9eaed2ebcc5 100644 --- a/cpp/src/Slice/CPlusPlusUtil.cpp +++ b/cpp/src/Slice/CPlusPlusUtil.cpp @@ -310,6 +310,11 @@ writeMarshalUnmarshalParams(Output& out, const ParamDeclList& params, const Oper writeMarshalUnmarshalCode(out, (*p)->type(), true, (*p)->tag(), fixKwd((*p)->name()), marshal, (*p)->getMetaData(), typeCtx); } + if(checkReturnType) + { + writeMarshalUnmarshalCode(out, op->returnType(), true, op->returnTag(), "__ret", marshal, op->getMetaData(), + typeCtx); + } } } diff --git a/cpp/src/Slice/PythonUtil.cpp b/cpp/src/Slice/PythonUtil.cpp index 4e363c17d18..45ded5d48bc 100755 --- a/cpp/src/Slice/PythonUtil.cpp +++ b/cpp/src/Slice/PythonUtil.cpp @@ -565,7 +565,7 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) string fixedOpName = fixIdent((*oli)->name()); if(!p->isLocal() && (p->hasMetaData("amd") || (*oli)->hasMetaData("amd"))) { - _out << sp << nl << "def " << fixedOpName << "_async(self, _cb"; + _out << sp << nl << "def " << (*oli)->name() << "_async(self, _cb"; ParamDeclList params = (*oli)->parameters(); @@ -749,7 +749,7 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) { _out << nl << comment; } - _out << nl << "def " << fixedOpName << "_async(self, _cb"; + _out << nl << "def " << (*oli)->name() << "_async(self, _cb"; if(!inParams.empty()) { _out << ", " << inParams; @@ -832,7 +832,7 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) // // Data members are represented as a tuple: // - // ('MemberName', MemberMetaData, MemberType) + // ('MemberName', MemberMetaData, MemberType, Optional, Tag) // // where MemberType is either a primitive type constant (T_INT, etc.) or the id of a constructed type. // @@ -858,7 +858,8 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) writeMetaData((*r)->getMetaData()); _out << ", "; writeType((*r)->type()); - _out << ')'; + _out << ", " << ((*r)->optional() ? "True" : "False") << ", " + << ((*r)->optional() ? (*r)->tag() : 0) << ')'; } if(members.size() == 1) { @@ -875,7 +876,7 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) // // Define each operation. The arguments to the IcePy.Operation constructor are: // - // 'opName', Mode, SendMode, AMD, (MetaData), (InParams), (OutParams), ReturnType, (Exceptions) + // 'opName', Mode, SendMode, AMD, Format, MetaData, (InParams), (OutParams), ReturnParam, (Exceptions) // // where InParams and OutParams are tuples of type descriptions, and Exceptions // is a tuple of exception type ids. @@ -923,7 +924,8 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) writeMetaData((*t)->getMetaData()); _out << ", "; writeType((*t)->type()); - _out << ')'; + _out << ", " << ((*t)->optional() ? "True" : "False") << ", " + << ((*t)->optional() ? (*t)->tag() : 0) << ')'; ++count; } } @@ -944,7 +946,8 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) writeMetaData((*t)->getMetaData()); _out << ", "; writeType((*t)->type()); - _out << ')'; + _out << ", " << ((*t)->optional() ? "True" : "False") << ", " + << ((*t)->optional() ? (*t)->tag() : 0) << ')'; ++count; } } @@ -956,7 +959,15 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) TypePtr returnType = (*s)->returnType(); if(returnType) { + // + // The return type has the same format as an in/out parameter: + // + // MetaData, Type, Optional?, OptionalTag + // + _out << "((), "; writeType(returnType); + _out << ", " << ((*s)->returnIsOptional() ? "True" : "False") << ", " + << ((*s)->returnIsOptional() ? (*s)->returnTag() : 0) << ')'; } else { @@ -1125,7 +1136,7 @@ Slice::Python::CodeVisitor::visitExceptionStart(const ExceptionPtr& p) // // Data members are represented as a tuple: // - // ('MemberName', MemberMetaData, MemberType) + // ('MemberName', MemberMetaData, MemberType, Optional, Tag) // // where MemberType is either a primitive type constant (T_INT, etc.) or the id of a constructed type. // @@ -1139,7 +1150,8 @@ Slice::Python::CodeVisitor::visitExceptionStart(const ExceptionPtr& p) writeMetaData((*dmli)->getMetaData()); _out << ", "; writeType((*dmli)->type()); - _out << ')'; + _out << ", " << ((*dmli)->optional() ? "True" : "False") << ", " + << ((*dmli)->optional() ? (*dmli)->tag() : 0) << ')'; } if(members.size() == 1) { @@ -1762,24 +1774,27 @@ Slice::Python::CodeVisitor::writeMetaData(const StringList& meta) void Slice::Python::CodeVisitor::writeAssign(const MemberInfo& info) { + string paramName = info.fixedName; + string memberName = info.fixedName; + // // Structures are treated differently (see bug 3676). // StructPtr st = StructPtr::dynamicCast(info.dataMember->type()); - if(st) + if(st && !info.dataMember->optional()) { - _out << nl << "if " << info.fixedName << " is Ice._struct_marker:"; + _out << nl << "if " << paramName << " is Ice._struct_marker:"; _out.inc(); - _out << nl << "self." << info.fixedName << " = " << getSymbol(st) << "()"; + _out << nl << "self." << memberName << " = " << getSymbol(st) << "()"; _out.dec(); _out << nl << "else:"; _out.inc(); - _out << nl << "self." << info.fixedName << " = " << info.fixedName; + _out << nl << "self." << memberName << " = " << paramName; _out.dec(); } else { - _out << nl << "self." << info.fixedName << " = " << info.fixedName; + _out << nl << "self." << memberName << " = " << paramName; } } @@ -1933,6 +1948,10 @@ Slice::Python::CodeVisitor::writeConstructorParams(const MemberInfoList& members { writeConstantValue(member->type(), member->defaultValueType(), member->defaultValue()); } + else if(member->optional()) + { + _out << "Ice.Unset"; + } else { writeInitializer(member->type()); diff --git a/cpp/src/Slice/Scanner.cpp b/cpp/src/Slice/Scanner.cpp index 87667e38132..9399b80a741 100644 --- a/cpp/src/Slice/Scanner.cpp +++ b/cpp/src/Slice/Scanner.cpp @@ -1,4 +1,4 @@ -#include <IceUtil/ScannerConfig.h> +#include "IceUtil/ScannerConfig.h"
#line 2 "lex.yy.c" #line 4 "lex.yy.c" @@ -574,6 +574,13 @@ char *slice_text; # pragma warning( 4 : 4244 ) #endif +#if defined(_MSC_VER) && defined(ICE_32) +// +// '<' : signed/unsigned mismatch +// +# pragma warning( 4 : 4018 ) +#endif + #ifdef _MSC_VER # ifdef slice_wrap # undef slice_wrap @@ -613,7 +620,7 @@ int checkKeyword(string&); -#line 616 "lex.yy.c" +#line 623 "lex.yy.c" #define INITIAL 0 #define BOMSCAN 1 @@ -800,10 +807,10 @@ YY_DECL register char *yy_cp, *yy_bp; register int yy_act; -#line 85 "Scanner.l" +#line 92 "Scanner.l" -#line 806 "lex.yy.c" +#line 813 "lex.yy.c" if ( !(yy_init) ) { @@ -888,7 +895,7 @@ case 1: (yy_c_buf_p) = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up slice_text again */ YY_RULE_SETUP -#line 87 "Scanner.l" +#line 94 "Scanner.l" { if(unit->scanPosition(slice_text)) { @@ -902,7 +909,7 @@ case 2: (yy_c_buf_p) = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up slice_text again */ YY_RULE_SETUP -#line 94 "Scanner.l" +#line 101 "Scanner.l" { if(unit->scanPosition(slice_text)) { @@ -915,7 +922,7 @@ case 3: (yy_c_buf_p) = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up slice_text again */ YY_RULE_SETUP -#line 101 "Scanner.l" +#line 108 "Scanner.l" { if(unit->scanPosition(slice_text)) { @@ -929,7 +936,7 @@ case 4: (yy_c_buf_p) = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up slice_text again */ YY_RULE_SETUP -#line 108 "Scanner.l" +#line 115 "Scanner.l" { if(unit->scanPosition(slice_text)) { @@ -939,7 +946,7 @@ YY_RULE_SETUP YY_BREAK case 5: YY_RULE_SETUP -#line 115 "Scanner.l" +#line 122 "Scanner.l" { // C++-style comment BEGIN(MAINSCAN); @@ -957,7 +964,7 @@ YY_RULE_SETUP YY_BREAK case 6: YY_RULE_SETUP -#line 130 "Scanner.l" +#line 137 "Scanner.l" { // C-style comment BEGIN(MAINSCAN); @@ -1001,7 +1008,7 @@ YY_RULE_SETUP YY_BREAK case 7: YY_RULE_SETUP -#line 171 "Scanner.l" +#line 178 "Scanner.l" { BEGIN(MAINSCAN); return ICE_SCOPE_DELIMITER; @@ -1009,7 +1016,7 @@ YY_RULE_SETUP YY_BREAK case 8: YY_RULE_SETUP -#line 176 "Scanner.l" +#line 183 "Scanner.l" { BEGIN(MAINSCAN); return ICE_METADATA_OPEN; @@ -1017,7 +1024,7 @@ YY_RULE_SETUP YY_BREAK case 9: YY_RULE_SETUP -#line 181 "Scanner.l" +#line 188 "Scanner.l" { BEGIN(MAINSCAN); return ICE_METADATA_CLOSE; @@ -1025,7 +1032,7 @@ YY_RULE_SETUP YY_BREAK case 10: YY_RULE_SETUP -#line 186 "Scanner.l" +#line 193 "Scanner.l" { BEGIN(MAINSCAN); return ICE_GLOBAL_METADATA_OPEN; @@ -1033,7 +1040,7 @@ YY_RULE_SETUP YY_BREAK case 11: YY_RULE_SETUP -#line 191 "Scanner.l" +#line 198 "Scanner.l" { BEGIN(MAINSCAN); return ICE_GLOBAL_METADATA_CLOSE; @@ -1042,7 +1049,7 @@ YY_RULE_SETUP case 12: /* rule 12 can match eol */ YY_RULE_SETUP -#line 196 "Scanner.l" +#line 203 "Scanner.l" { BEGIN(MAINSCAN); StringTokPtr ident = new StringTok; @@ -1070,7 +1077,7 @@ YY_RULE_SETUP YY_BREAK case 13: YY_RULE_SETUP -#line 221 "Scanner.l" +#line 228 "Scanner.l" { BEGIN(MAINSCAN); StringTokPtr ident = new StringTok; @@ -1081,7 +1088,7 @@ YY_RULE_SETUP YY_BREAK case 14: YY_RULE_SETUP -#line 229 "Scanner.l" +#line 236 "Scanner.l" { BEGIN(MAINSCAN); StringTokPtr str = new StringTok; @@ -1245,7 +1252,7 @@ YY_RULE_SETUP YY_BREAK case 15: YY_RULE_SETUP -#line 390 "Scanner.l" +#line 397 "Scanner.l" { BEGIN(MAINSCAN); IntegerTokPtr itp = new IntegerTok; @@ -1264,7 +1271,7 @@ YY_RULE_SETUP YY_BREAK case 16: YY_RULE_SETUP -#line 406 "Scanner.l" +#line 413 "Scanner.l" { BEGIN(MAINSCAN); errno = 0; @@ -1298,7 +1305,7 @@ YY_RULE_SETUP case 17: /* rule 17 can match eol */ YY_RULE_SETUP -#line 436 "Scanner.l" +#line 443 "Scanner.l" { // Ignore white-space @@ -1314,7 +1321,7 @@ YY_RULE_SETUP YY_BREAK case 18: YY_RULE_SETUP -#line 449 "Scanner.l" +#line 456 "Scanner.l" { // Ignore UTF-8 BOM, rule only active when parsing start of file. @@ -1323,7 +1330,7 @@ YY_RULE_SETUP YY_BREAK case 19: YY_RULE_SETUP -#line 455 "Scanner.l" +#line 462 "Scanner.l" { BEGIN(MAINSCAN); if(slice_text[0] < 32 || slice_text[0] > 126) @@ -1342,10 +1349,10 @@ YY_RULE_SETUP YY_BREAK case 20: YY_RULE_SETUP -#line 471 "Scanner.l" +#line 478 "Scanner.l" ECHO; YY_BREAK -#line 1348 "lex.yy.c" +#line 1355 "lex.yy.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(BOMSCAN): case YY_STATE_EOF(MAINSCAN): @@ -2345,7 +2352,7 @@ void slice_free (void * ptr ) #define YYTABLES_NAME "yytables" -#line 471 "Scanner.l" +#line 478 "Scanner.l" diff --git a/cpp/src/Slice/Scanner.l b/cpp/src/Slice/Scanner.l index 1d981e3e567..5e2b93df079 100644 --- a/cpp/src/Slice/Scanner.l +++ b/cpp/src/Slice/Scanner.l @@ -29,6 +29,13 @@ # pragma warning( 4 : 4244 ) #endif +#if defined(_MSC_VER) && defined(ICE_32) +// +// '<' : signed/unsigned mismatch +// +# pragma warning( 4 : 4018 ) +#endif + #ifdef _MSC_VER # ifdef slice_wrap # undef slice_wrap |