diff options
author | Mark Spruiell <mes@zeroc.com> | 2012-09-24 16:00:56 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2012-09-24 16:00:56 -0700 |
commit | 6bb0a7b82684d1ce59a996848773054ede1f442e (patch) | |
tree | 9a9cfbaa225afd5caca819eea9558908c9a64a40 /py | |
parent | Replaced optionalType in StreamTrait<> by a bool fixedLength member (diff) | |
download | ice-6bb0a7b82684d1ce59a996848773054ede1f442e.tar.bz2 ice-6bb0a7b82684d1ce59a996848773054ede1f442e.tar.xz ice-6bb0a7b82684d1ce59a996848773054ede1f442e.zip |
Ruby port; Python & C++ fixes
Diffstat (limited to 'py')
-rw-r--r-- | py/modules/IcePy/Operation.cpp | 19 | ||||
-rw-r--r-- | py/modules/IcePy/Types.cpp | 94 | ||||
-rw-r--r-- | py/modules/IcePy/Types.h | 17 |
3 files changed, 4 insertions, 126 deletions
diff --git a/py/modules/IcePy/Operation.cpp b/py/modules/IcePy/Operation.cpp index 036b2da4aad..4e3e16115f4 100644 --- a/py/modules/IcePy/Operation.cpp +++ b/py/modules/IcePy/Operation.cpp @@ -77,15 +77,13 @@ public: ParamInfoPtr returnType; ExceptionInfoList exceptions; string dispatchName; - bool sendsClasses; - bool returnsClasses; bool pseudoOp; private: string _deprecateMessage; - static void convertParams(PyObject*, ParamInfoList&, int, bool&); + static void convertParams(PyObject*, ParamInfoList&, int); static ParamInfoPtr convertParam(PyObject*, int); }; typedef IceUtil::Handle<Operation> OperationPtr; @@ -1079,21 +1077,17 @@ IcePy::Operation::Operation(const char* n, PyObject* m, PyObject* sm, int amdFla if(ret != Py_None) { returnType = convertParam(ret, 0); - if(!returnsClasses) - { - returnsClasses = returnType->type->usesClasses(); - } } // // inParams // - convertParams(in, inParams, 0, sendsClasses); + convertParams(in, inParams, 0); // // outParams // - convertParams(out, outParams, returnType ? 1 : 0, returnsClasses); + convertParams(out, outParams, returnType ? 1 : 0); class SortFn { @@ -1159,19 +1153,14 @@ IcePy::Operation::deprecate(const string& msg) } void -IcePy::Operation::convertParams(PyObject* p, ParamInfoList& params, int posOffset, bool& usesClasses) +IcePy::Operation::convertParams(PyObject* p, ParamInfoList& params, int posOffset) { - usesClasses = false; int sz = static_cast<int>(PyTuple_GET_SIZE(p)); for(int i = 0; i < sz; ++i) { PyObject* item = PyTuple_GET_ITEM(p, i); ParamInfoPtr param = convertParam(item, i + posOffset); params.push_back(param); - if(!usesClasses) - { - usesClasses = param->type->usesClasses(); - } } } diff --git a/py/modules/IcePy/Types.cpp b/py/modules/IcePy/Types.cpp index d8d381aab1d..c7546679fbf 100644 --- a/py/modules/IcePy/Types.cpp +++ b/py/modules/IcePy/Types.cpp @@ -165,31 +165,6 @@ exceptionInfoDealloc(ExceptionInfoObject* self) Py_TYPE(self)->tp_free(reinterpret_cast<PyObject*>(self)); } -static bool -getUsesClasses(PyObject* ex, bool dflt) -{ - if(PyObject_HasAttrString(ex, STRCAST("_ice_usesClasses"))) - { - PyObjectHandle m = PyObject_GetAttrString(ex, STRCAST("_ice_usesClasses")); - assert(m.get()); - int isTrue = PyObject_IsTrue(m.get()); - assert(isTrue >= 0); - return isTrue ? true : false; - } - - return dflt; -} - -static void -setUsesClasses(PyObject* ex, bool v) -{ - if(PyObject_SetAttrString(ex, STRCAST("_ice_usesClasses"), v ? getTrue() : getFalse()) < 0) - { - assert(PyErr_Occurred()); - throw AbortMarshaling(); - } -} - // // addClassInfo() // @@ -528,12 +503,6 @@ IcePy::TypeInfo::TypeInfo() { } -bool -IcePy::TypeInfo::usesClasses() -{ - return false; -} - void IcePy::TypeInfo::unmarshaled(PyObject*, PyObject*, void*) { @@ -1187,20 +1156,6 @@ IcePy::StructInfo::validate(PyObject* val) } bool -IcePy::StructInfo::usesClasses() -{ - for(DataMemberList::const_iterator q = members.begin(); q != members.end(); ++q) - { - if((*q)->type->usesClasses()) - { - return true; - } - } - - return false; -} - -bool IcePy::StructInfo::variableLength() const { return _variableLength; @@ -1365,12 +1320,6 @@ IcePy::SequenceInfo::validate(PyObject* val) } bool -IcePy::SequenceInfo::usesClasses() -{ - return elementType->usesClasses(); -} - -bool IcePy::SequenceInfo::variableLength() const { return true; @@ -2264,12 +2213,6 @@ IcePy::CustomInfo::validate(PyObject* val) } bool -IcePy::CustomInfo::usesClasses() -{ - return false; -} - -bool IcePy::CustomInfo::variableLength() const { return true; @@ -2436,12 +2379,6 @@ IcePy::DictionaryInfo::validate(PyObject* val) } bool -IcePy::DictionaryInfo::usesClasses() -{ - return valueType->usesClasses(); -} - -bool IcePy::DictionaryInfo::variableLength() const { return true; @@ -2704,12 +2641,6 @@ IcePy::ClassInfo::validate(PyObject* val) } bool -IcePy::ClassInfo::usesClasses() -{ - return true; -} - -bool IcePy::ClassInfo::variableLength() const { return true; @@ -3504,8 +3435,6 @@ IcePy::ExceptionWriter::ExceptionWriter(const Ice::CommunicatorPtr& communicator _info = ExceptionInfoPtr::dynamicCast(getException(iceType.get())); assert(_info); } - - _usesClasses = getUsesClasses(_ex.get(), _info->usesClasses); } IcePy::ExceptionWriter::~ExceptionWriter() throw() @@ -3523,12 +3452,6 @@ IcePy::ExceptionWriter::write(const Ice::OutputStreamPtr& os) const _info->marshal(_ex.get(), os, const_cast<ObjectMap*>(&_objects)); } -bool -IcePy::ExceptionWriter::usesClasses() const -{ - return _usesClasses; -} - string IcePy::ExceptionWriter::ice_name() const { @@ -3574,21 +3497,6 @@ IcePy::ExceptionReader::read(const Ice::InputStreamPtr& is) const const_cast<Ice::SlicedDataPtr&>(_slicedData) = is->endException(_info->preserve); } -bool -IcePy::ExceptionReader::usesClasses() const -{ - return _info->usesClasses; -} - -void -IcePy::ExceptionReader::usesClasses(bool b) -{ - if(_info->preserve) - { - setUsesClasses(_ex.get(), b); - } -} - string IcePy::ExceptionReader::ice_name() const { @@ -4123,8 +4031,6 @@ IcePy_defineException(PyObject*, PyObject* args) assert(info->base); } - info->usesClasses = false; - convertDataMembers(members, info->members, info->optionalMembers, true); info->pythonType = type; diff --git a/py/modules/IcePy/Types.h b/py/modules/IcePy/Types.h index 46e07ce3840..32d481b35e4 100644 --- a/py/modules/IcePy/Types.h +++ b/py/modules/IcePy/Types.h @@ -103,8 +103,6 @@ public: virtual bool validate(PyObject*) = 0; - virtual bool usesClasses(); // Default implementation returns false. - virtual bool variableLength() const = 0; virtual int wireSize() const = 0; virtual Ice::OptionalType optionalType() const = 0; @@ -233,8 +231,6 @@ public: virtual int wireSize() const; virtual Ice::OptionalType optionalType() const; - virtual bool usesClasses(); - virtual void marshal(PyObject*, const Ice::OutputStreamPtr&, ObjectMap*, bool, const Ice::StringSeq* = 0); virtual void unmarshal(const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, PyObject*, void*, bool, const Ice::StringSeq* = 0); @@ -271,8 +267,6 @@ public: virtual int wireSize() const; virtual Ice::OptionalType optionalType() const; - virtual bool usesClasses(); - virtual void marshal(PyObject*, const Ice::OutputStreamPtr&, ObjectMap*, bool, const Ice::StringSeq* = 0); virtual void unmarshal(const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, PyObject*, void*, bool, const Ice::StringSeq* = 0); @@ -331,8 +325,6 @@ public: virtual int wireSize() const; virtual Ice::OptionalType optionalType() const; - virtual bool usesClasses(); - virtual void marshal(PyObject*, const Ice::OutputStreamPtr&, ObjectMap*, bool, const Ice::StringSeq* = 0); virtual void unmarshal(const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, PyObject*, void*, bool, const Ice::StringSeq* = 0); @@ -363,8 +355,6 @@ public: virtual int wireSize() const; virtual Ice::OptionalType optionalType() const; - virtual bool usesClasses(); - virtual void marshal(PyObject*, const Ice::OutputStreamPtr&, ObjectMap*, bool, const Ice::StringSeq* = 0); virtual void unmarshal(const Ice::InputStreamPtr&, const UnmarshalCallbackPtr&, PyObject*, void*, bool, const Ice::StringSeq* = 0); @@ -409,8 +399,6 @@ public: virtual bool validate(PyObject*); - virtual bool usesClasses(); - virtual bool variableLength() const; virtual int wireSize() const; virtual Ice::OptionalType optionalType() const; @@ -488,7 +476,6 @@ public: ExceptionInfoPtr base; DataMemberList members; DataMemberList optionalMembers; - bool usesClasses; PyObjectHandle pythonType; private: @@ -557,7 +544,6 @@ public: ~ExceptionWriter() throw(); virtual void write(const Ice::OutputStreamPtr&) const; - virtual bool usesClasses() const; virtual std::string ice_name() const; virtual Ice::UserException* ice_clone() const; @@ -568,7 +554,6 @@ private: PyObjectHandle _ex; ExceptionInfoPtr _info; ObjectMap _objects; - bool _usesClasses; }; // @@ -582,8 +567,6 @@ public: ~ExceptionReader() throw(); virtual void read(const Ice::InputStreamPtr&) const; - virtual bool usesClasses() const; - virtual void usesClasses(bool); virtual std::string ice_name() const; virtual Ice::UserException* ice_clone() const; |