diff options
author | Jose <jose@zeroc.com> | 2017-01-26 21:52:52 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2017-01-26 21:52:52 +0100 |
commit | f3eeced45abdcbb8af31569bf8cee55f0d2a3b4b (patch) | |
tree | f98f59d56e7185ee90d504cf077e57465655f7fd /python/modules | |
parent | Fixed ICE-6920 - Communicator::destroy is now noexcept (diff) | |
download | ice-f3eeced45abdcbb8af31569bf8cee55f0d2a3b4b.tar.bz2 ice-f3eeced45abdcbb8af31569bf8cee55f0d2a3b4b.tar.xz ice-f3eeced45abdcbb8af31569bf8cee55f0d2a3b4b.zip |
Python: Ice.Value implementation
Diffstat (limited to 'python/modules')
-rw-r--r-- | python/modules/IcePy/Init.cpp | 4 | ||||
-rw-r--r-- | python/modules/IcePy/Types.cpp | 358 | ||||
-rw-r--r-- | python/modules/IcePy/Types.h | 67 | ||||
-rw-r--r-- | python/modules/IcePy/ValueFactoryManager.cpp | 33 |
4 files changed, 368 insertions, 94 deletions
diff --git a/python/modules/IcePy/Init.cpp b/python/modules/IcePy/Init.cpp index a7855719137..f618e0c10eb 100644 --- a/python/modules/IcePy/Init.cpp +++ b/python/modules/IcePy/Init.cpp @@ -85,6 +85,10 @@ static PyMethodDef methods[] = PyDoc_STR(STRCAST("internal function")) }, { STRCAST("defineClass"), reinterpret_cast<PyCFunction>(IcePy_defineClass), METH_VARARGS, PyDoc_STR(STRCAST("internal function")) }, + { STRCAST("declareValue"), reinterpret_cast<PyCFunction>(IcePy_declareValue), METH_VARARGS, + PyDoc_STR(STRCAST("internal function")) }, + { STRCAST("defineValue"), reinterpret_cast<PyCFunction>(IcePy_defineValue), METH_VARARGS, + PyDoc_STR(STRCAST("internal function")) }, { STRCAST("defineException"), reinterpret_cast<PyCFunction>(IcePy_defineException), METH_VARARGS, PyDoc_STR(STRCAST("internal function")) }, { STRCAST("stringify"), reinterpret_cast<PyCFunction>(IcePy_stringify), METH_VARARGS, diff --git a/python/modules/IcePy/Types.cpp b/python/modules/IcePy/Types.cpp index 2f81d25443c..7e34b0a5857 100644 --- a/python/modules/IcePy/Types.cpp +++ b/python/modules/IcePy/Types.cpp @@ -33,7 +33,10 @@ using namespace IceUtilInternal; typedef map<string, ClassInfoPtr> ClassInfoMap; static ClassInfoMap _classInfoMap; -typedef map<Ice::Int, ClassInfoPtr> CompactIdMap; +typedef map<string, ValueInfoPtr> ValueInfoMap; +static ValueInfoMap _valueInfoMap; + +typedef map<Ice::Int, ValueInfoPtr> CompactIdMap; static CompactIdMap _compactIdMap; typedef map<string, ProxyInfoPtr> ProxyInfoMap; @@ -209,6 +212,26 @@ addClassInfo(const string& id, const ClassInfoPtr& info) } // +// addValueInfo() +// +static void +addValueInfo(const string& id, const ValueInfoPtr& info) +{ + // + // Do not assert. An application may load statically- + // translated definitions and then dynamically load + // duplicate definitions. + // +// assert(_valueInfoMap.find(id) == _valueInfoMap.end()); + ValueInfoMap::iterator p = _valueInfoMap.find(id); + if(p != _valueInfoMap.end()) + { + _valueInfoMap.erase(p); + } + _valueInfoMap.insert(ValueInfoMap::value_type(id, info)); +} + +// // addProxyInfo() // static void @@ -541,7 +564,7 @@ IcePy::StreamUtil::getSlicedDataMember(PyObject* obj, ObjectMap* objectMap) ObjectMap::iterator i = objectMap->find(o); if(i == objectMap->end()) { - writer = new ObjectWriter(o, objectMap); + writer = new ObjectWriter(o, objectMap, 0); objectMap->insert(ObjectMap::value_type(o, writer)); } else @@ -2790,21 +2813,16 @@ IcePy::DictionaryInfo::destroy() // ClassInfo implementation. // IcePy::ClassInfo::ClassInfo(const string& ident) : - id(ident), compactId(-1), isAbstract(false), preserve(false), defined(false) + id(ident), defined(false) { const_cast<PyObjectHandle&>(typeObj) = createType(this); } void -IcePy::ClassInfo::define(PyObject* t, int compact, bool abstr, bool pres, PyObject* b, PyObject* i, PyObject* m) +IcePy::ClassInfo::define(PyObject* t, PyObject* b, PyObject* i) { assert(PyType_Check(t)); assert(PyTuple_Check(i)); - assert(PyTuple_Check(m)); - - const_cast<int&>(compactId) = compact; - const_cast<bool&>(isAbstract) = abstr; - const_cast<bool&>(preserve) = pres; if(b != Py_None) { @@ -2822,8 +2840,6 @@ IcePy::ClassInfo::define(PyObject* t, int compact, bool abstr, bool pres, PyObje const_cast<ClassInfoList&>(interfaces).push_back(iface); } - convertDataMembers(m, const_cast<DataMemberList&>(members), const_cast<DataMemberList&>(optionalMembers), true); - const_cast<PyObjectHandle&>(pythonType) = t; Py_INCREF(t); @@ -2839,12 +2855,14 @@ IcePy::ClassInfo::getId() const bool IcePy::ClassInfo::validate(PyObject* val) { - return val == Py_None || PyObject_IsInstance(val, pythonType.get()) == 1; + assert(false); + return true; } bool IcePy::ClassInfo::variableLength() const { + assert(false); return true; } @@ -2870,6 +2888,144 @@ void IcePy::ClassInfo::marshal(PyObject* p, Ice::OutputStream* os, ObjectMap* objectMap, bool, const Ice::StringSeq*) { + assert(false); + throw AbortMarshaling(); +} + +void +IcePy::ClassInfo::unmarshal(Ice::InputStream* is, const UnmarshalCallbackPtr& cb, PyObject* target, + void* closure, bool, const Ice::StringSeq*) +{ + assert(false); + throw AbortMarshaling(); +} + +void +IcePy::ClassInfo::print(PyObject* value, IceUtilInternal::Output& out, PrintObjectHistory* history) +{ + if(!validate(value)) + { + out << "<invalid value - expected " << id << ">"; + return; + } + + if(value == Py_None) + { + out << "<nil>"; + } + else + { + map<PyObject*, int>::iterator q = history->objects.find(value); + if(q != history->objects.end()) + { + out << "<object #" << q->second << ">"; + } + else + { + PyObjectHandle iceType = PyObject_GetAttrString(value, STRCAST("_ice_type")); + ClassInfoPtr info; + if(!iceType.get()) + { + // + // The _ice_type attribute will be missing in an instance of LocalObject + // that does not derive from a user-defined type. + // + assert(id == "::Ice::LocalObject"); + info = this; + } + else + { + info = ClassInfoPtr::dynamicCast(getType(iceType.get())); + assert(info); + } + out << "object #" << history->index << " (" << info->id << ')'; + history->objects.insert(map<PyObject*, int>::value_type(value, history->index)); + ++history->index; + } + } +} + +void +IcePy::ClassInfo::destroy() +{ + const_cast<ClassInfoPtr&>(base) = 0; + const_cast<ClassInfoList&>(interfaces).clear(); + const_cast<PyObjectHandle&>(typeObj) = 0; // Break circular reference. +} + +// +// ValueInfo implementation. +// +IcePy::ValueInfo::ValueInfo(const string& ident) : + id(ident), compactId(-1), preserve(false), interface(false), defined(false) +{ + const_cast<PyObjectHandle&>(typeObj) = createType(this); +} + +void +IcePy::ValueInfo::define(PyObject* t, int compact, bool pres, bool intf, PyObject* b, PyObject* m) +{ + assert(PyType_Check(t)); + assert(PyTuple_Check(m)); + + const_cast<int&>(compactId) = compact; + const_cast<bool&>(preserve) = pres; + const_cast<bool&>(interface) = intf; + + if(b != Py_None) + { + const_cast<ValueInfoPtr&>(base) = ValueInfoPtr::dynamicCast(getType(b)); + assert(base); + } + + convertDataMembers(m, const_cast<DataMemberList&>(members), const_cast<DataMemberList&>(optionalMembers), true); + + const_cast<PyObjectHandle&>(pythonType) = t; + Py_INCREF(t); + + const_cast<bool&>(defined) = true; +} + +string +IcePy::ValueInfo::getId() const +{ + return id; +} + +bool +IcePy::ValueInfo::validate(PyObject* val) +{ + return val == Py_None || PyObject_IsInstance(val, pythonType.get()) == 1; +} + +bool +IcePy::ValueInfo::variableLength() const +{ + return true; +} + +int +IcePy::ValueInfo::wireSize() const +{ + return 1; +} + +Ice::OptionalFormat +IcePy::ValueInfo::optionalFormat() const +{ + return Ice::OptionalFormatClass; +} + +bool +IcePy::ValueInfo::usesClasses() const +{ + return true; +} + +void +IcePy::ValueInfo::marshal(PyObject* p, Ice::OutputStream* os, ObjectMap* objectMap, bool, + const Ice::StringSeq*) +{ if(!pythonType.get()) { PyErr_Format(PyExc_RuntimeError, STRCAST("class %s is declared but not defined"), id.c_str()); @@ -2900,7 +3056,7 @@ IcePy::ClassInfo::marshal(PyObject* p, Ice::OutputStream* os, ObjectMap* objectM ObjectMap::iterator q = objectMap->find(p); if(q == objectMap->end()) { - writer = new ObjectWriter(p, objectMap); + writer = new ObjectWriter(p, objectMap, this); objectMap->insert(ObjectMap::value_type(p, writer)); } else @@ -2928,7 +3084,7 @@ patchObject(void* addr, const Ice::ObjectPtr& v) } void -IcePy::ClassInfo::unmarshal(Ice::InputStream* is, const UnmarshalCallbackPtr& cb, PyObject* target, +IcePy::ValueInfo::unmarshal(Ice::InputStream* is, const UnmarshalCallbackPtr& cb, PyObject* target, void* closure, bool, const Ice::StringSeq*) { if(!pythonType.get()) @@ -2950,7 +3106,7 @@ IcePy::ClassInfo::unmarshal(Ice::InputStream* is, const UnmarshalCallbackPtr& cb } void -IcePy::ClassInfo::print(PyObject* value, IceUtilInternal::Output& out, PrintObjectHistory* history) +IcePy::ValueInfo::print(PyObject* value, IceUtilInternal::Output& out, PrintObjectHistory* history) { if(!validate(value)) { @@ -2972,7 +3128,7 @@ IcePy::ClassInfo::print(PyObject* value, IceUtilInternal::Output& out, PrintObje else { PyObjectHandle iceType = PyObject_GetAttrString(value, STRCAST("_ice_type")); - ClassInfoPtr info; + ValueInfoPtr info; if(!iceType.get()) { // @@ -2984,7 +3140,7 @@ IcePy::ClassInfo::print(PyObject* value, IceUtilInternal::Output& out, PrintObje } else { - info = ClassInfoPtr::dynamicCast(getType(iceType.get())); + info = ValueInfoPtr::dynamicCast(getType(iceType.get())); assert(info); } out << "object #" << history->index << " (" << info->id << ')'; @@ -2998,10 +3154,9 @@ IcePy::ClassInfo::print(PyObject* value, IceUtilInternal::Output& out, PrintObje } void -IcePy::ClassInfo::destroy() +IcePy::ValueInfo::destroy() { - const_cast<ClassInfoPtr&>(base) = 0; - const_cast<ClassInfoList&>(interfaces).clear(); + const_cast<ValueInfoPtr&>(base) = 0; if(!members.empty()) { DataMemberList ml = members; @@ -3015,7 +3170,7 @@ IcePy::ClassInfo::destroy() } void -IcePy::ClassInfo::printMembers(PyObject* value, IceUtilInternal::Output& out, PrintObjectHistory* history) +IcePy::ValueInfo::printMembers(PyObject* value, IceUtilInternal::Output& out, PrintObjectHistory* history) { if(base) { @@ -3197,19 +3352,21 @@ IcePy::ProxyInfo::destroy() // // ObjectWriter implementation. // -IcePy::ObjectWriter::ObjectWriter(PyObject* object, ObjectMap* objectMap) : - _object(object), _map(objectMap) +IcePy::ObjectWriter::ObjectWriter(PyObject* object, ObjectMap* objectMap, const ValueInfoPtr& formal) : + _object(object), _map(objectMap), _formal(formal) { Py_INCREF(_object); - - PyObjectHandle iceType = PyObject_GetAttrString(object, STRCAST("_ice_type")); - if(!iceType.get()) + if(!_formal || !_formal->interface) { - assert(PyErr_Occurred()); - throw AbortMarshaling(); + PyObjectHandle iceType = PyObject_GetAttrString(object, STRCAST("_ice_type")); + if(!iceType.get()) + { + assert(PyErr_Occurred()); + throw AbortMarshaling(); + } + _info = ValueInfoPtr::dynamicCast(getType(iceType.get())); + assert(_info); } - _info = ClassInfoPtr::dynamicCast(getType(iceType.get())); - assert(_info); } IcePy::ObjectWriter::~ObjectWriter() @@ -3236,7 +3393,7 @@ IcePy::ObjectWriter::_iceWrite(Ice::OutputStream* os) const { Ice::SlicedDataPtr slicedData; - if(_info->preserve) + if(_info && _info->preserve) { // // Retrieve the SlicedData object that we stored as a hidden member of the Python object. @@ -3246,19 +3403,34 @@ IcePy::ObjectWriter::_iceWrite(Ice::OutputStream* os) const os->startValue(slicedData); - if(_info->id != "::Ice::UnknownSlicedObject") + if(_formal && _formal->interface) { - ClassInfoPtr info = _info; - while(info) + PyObjectHandle ret = PyObject_CallMethod(_object, STRCAST("ice_id"), 0); + if(!ret.get()) + { + assert(PyErr_Occurred()); + throw AbortMarshaling(); + } + string id = getString(ret.get()); + os->startSlice(id, -1, true); + os->endSlice(); + } + else + { + if(_info->id != "::Ice::UnknownSlicedValue") { - os->startSlice(info->id, info->compactId, !info->base); + ValueInfoPtr info = _info; + while(info) + { + os->startSlice(info->id, info->compactId, !info->base); - writeMembers(os, info->members); - writeMembers(os, info->optionalMembers); // The optional members have already been sorted by tag. + writeMembers(os, info->members); + writeMembers(os, info->optionalMembers); // The optional members have already been sorted by tag. - os->endSlice(); + os->endSlice(); - info = info->base; + info = info->base; + } } } @@ -3315,7 +3487,7 @@ IcePy::ObjectWriter::writeMembers(Ice::OutputStream* os, const DataMemberList& m // // ObjectReader implementation. // -IcePy::ObjectReader::ObjectReader(PyObject* object, const ClassInfoPtr& info) : +IcePy::ObjectReader::ObjectReader(PyObject* object, const ValueInfoPtr& info) : _object(object), _info(info) { Py_INCREF(_object); @@ -3351,14 +3523,14 @@ IcePy::ObjectReader::_iceRead(Ice::InputStream* is) { is->startValue(); - const bool unknown = _info->id == "::Ice::UnknownSlicedObject"; + const bool unknown = _info->id == "::Ice::UnknownSlicedValue"; // // Unmarshal the slices of a user-defined class. // if(!unknown && _info->id != Ice::Object::ice_staticId()) { - ClassInfoPtr info = _info; + ValueInfoPtr info = _info; while(info) { is->startSlice(); @@ -3419,7 +3591,7 @@ IcePy::ObjectReader::_iceRead(Ice::InputStream* is) } } -ClassInfoPtr +ValueInfoPtr IcePy::ObjectReader::getInfo() const { return _info; @@ -3454,6 +3626,12 @@ IcePy::InfoMapDestroyer::~InfoMapDestroyer() p->second->destroy(); } } + { + for(ValueInfoMap::iterator p = _valueInfoMap.begin(); p != _valueInfoMap.end(); ++p) + { + p->second->destroy(); + } + } _compactIdMap.clear(); _exceptionInfoMap.clear(); } @@ -3461,7 +3639,7 @@ IcePy::InfoMapDestroyer::~InfoMapDestroyer() // // ReadObjectCallback implementation. // -IcePy::ReadObjectCallback::ReadObjectCallback(const ClassInfoPtr& info, const UnmarshalCallbackPtr& cb, +IcePy::ReadObjectCallback::ReadObjectCallback(const ValueInfoPtr& info, const UnmarshalCallbackPtr& cb, PyObject* target, void* closure) : _info(info), _cb(cb), _target(target), _closure(closure) { @@ -3854,6 +4032,20 @@ IcePy::lookupClassInfo(const string& id) } // +// lookupClassInfo() +// +IcePy::ValueInfoPtr +IcePy::lookupValueInfo(const string& id) +{ + ValueInfoMap::iterator p = _valueInfoMap.find(id); + if(p != _valueInfoMap.end()) + { + return p->second; + } + return 0; +} + +// // lookupExceptionInfo() // IcePy::ExceptionInfoPtr @@ -4350,15 +4542,10 @@ IcePy_defineClass(PyObject*, PyObject* args) { char* id; PyObject* type; - int compactId; PyObject* meta; // Not currently used. - int isAbstract; - int preserve; PyObject* base; PyObject* interfaces; - PyObject* members; - if(!PyArg_ParseTuple(args, STRCAST("sOiOiiOOO"), &id, &type, &compactId, &meta, &isAbstract, &preserve, &base, - &interfaces, &members)) + if(!PyArg_ParseTuple(args, STRCAST("sOOOO"), &id, &type, &meta, &base, &interfaces)) { return 0; } @@ -4377,15 +4564,76 @@ IcePy_defineClass(PyObject*, PyObject* args) addClassInfo(id, info); } - info->define(type, compactId, isAbstract ? true : false, preserve ? true : false, base, interfaces, members); + info->define(type, base, interfaces); + + Py_INCREF(info->typeObj.get()); + return info->typeObj.get(); +} + +extern "C" +PyObject* +IcePy_declareValue(PyObject*, PyObject* args) +{ + char* id; + if(!PyArg_ParseTuple(args, STRCAST("s"), &id)) + { + return 0; + } + + ValueInfoPtr info = lookupValueInfo(id); + if(!info) + { + info = new ValueInfo(id); + addValueInfo(id, info); + } + + Py_INCREF(info->typeObj.get()); + return info->typeObj.get(); +} + +extern "C" +PyObject* +IcePy_defineValue(PyObject*, PyObject* args) +{ + char* id; + PyObject* type; + int compactId; + PyObject* meta; // Not currently used. + int preserve; + int interface; + PyObject* base; + PyObject* members; + if(!PyArg_ParseTuple(args, STRCAST("sOiOiiOO"), &id, &type, &compactId, &meta, &preserve, &interface, &base, + &members)) + { + return 0; + } + + assert(PyTuple_Check(meta)); - CompactIdMap::iterator q = _compactIdMap.find(info->compactId); - if(q != _compactIdMap.end()) + // + // A ClassInfo object will already exist for this id if a forward declaration + // was encountered, or if the Slice definition is being reloaded. In the latter + // case, we act as if it hasn't been defined yet. + // + ValueInfoPtr info = lookupValueInfo(id); + if(!info || info->defined) { - _compactIdMap.erase(q); + info = new ValueInfo(id); + addValueInfo(id, info); } - _compactIdMap.insert(CompactIdMap::value_type(info->compactId, info)); + info->define(type, compactId, preserve ? true : false, interface ? true : false, base, members); + + if(info->compactId != -1) + { + CompactIdMap::iterator q = _compactIdMap.find(info->compactId); + if(q != _compactIdMap.end()) + { + _compactIdMap.erase(q); + } + _compactIdMap.insert(CompactIdMap::value_type(info->compactId, info)); + } Py_INCREF(info->typeObj.get()); return info->typeObj.get(); } diff --git a/python/modules/IcePy/Types.h b/python/modules/IcePy/Types.h index 5933c6dd234..fd3df2bc243 100644 --- a/python/modules/IcePy/Types.h +++ b/python/modules/IcePy/Types.h @@ -30,6 +30,10 @@ class ClassInfo; typedef IceUtil::Handle<ClassInfo> ClassInfoPtr; typedef std::vector<ClassInfoPtr> ClassInfoList; + +class ValueInfo; +typedef IceUtil::Handle<ValueInfo> ValueInfoPtr; + // // This class is raised as an exception when object marshaling needs to be aborted. // @@ -73,14 +77,14 @@ class ReadObjectCallback : public IceUtil::Shared { public: - ReadObjectCallback(const ClassInfoPtr&, const UnmarshalCallbackPtr&, PyObject*, void*); + ReadObjectCallback(const ValueInfoPtr&, const UnmarshalCallbackPtr&, PyObject*, void*); ~ReadObjectCallback(); void invoke(const ::Ice::ObjectPtr&); private: - ClassInfoPtr _info; + ValueInfoPtr _info; UnmarshalCallbackPtr _cb; PyObject* _target; void* _closure; @@ -448,7 +452,45 @@ public: ClassInfo(const std::string&); - void define(PyObject*, int, bool, bool, PyObject*, PyObject*, PyObject*); + void define(PyObject*, PyObject*, PyObject*); + + virtual std::string getId() const; + + virtual bool validate(PyObject*); + + virtual bool variableLength() const; + virtual int wireSize() const; + virtual Ice::OptionalFormat optionalFormat() const; + + virtual bool usesClasses() const; + + virtual void marshal(PyObject*, Ice::OutputStream*, ObjectMap*, bool, const Ice::StringSeq* = 0); + virtual void unmarshal(Ice::InputStream*, const UnmarshalCallbackPtr&, PyObject*, void*, bool, + const Ice::StringSeq* = 0); + + virtual void print(PyObject*, IceUtilInternal::Output&, PrintObjectHistory*); + + virtual void destroy(); + + const std::string id; + const ClassInfoPtr base; + const ClassInfoList interfaces; + const PyObjectHandle pythonType; + const PyObjectHandle typeObj; + const bool defined; +}; + +// +// Value type information +// + +class ValueInfo : public TypeInfo +{ +public: + + ValueInfo(const std::string&); + + void define(PyObject*, int, bool, bool, PyObject*, PyObject*); virtual std::string getId() const; @@ -472,10 +514,9 @@ public: const std::string id; const Ice::Int compactId; - const bool isAbstract; const bool preserve; - const ClassInfoPtr base; - const ClassInfoList interfaces; + const bool interface; + const ValueInfoPtr base; const DataMemberList members; const DataMemberList optionalMembers; const PyObjectHandle pythonType; @@ -549,7 +590,7 @@ class ObjectWriter : public Ice::Object { public: - ObjectWriter(PyObject*, ObjectMap*); + ObjectWriter(PyObject*, ObjectMap*, const ValueInfoPtr&); ~ObjectWriter(); virtual void ice_preMarshal(); @@ -563,7 +604,8 @@ private: PyObject* _object; ObjectMap* _map; - ClassInfoPtr _info; + ValueInfoPtr _info; + ValueInfoPtr _formal; }; // @@ -573,7 +615,7 @@ class ObjectReader : public Ice::Object { public: - ObjectReader(PyObject*, const ClassInfoPtr&); + ObjectReader(PyObject*, const ValueInfoPtr&); ~ObjectReader(); virtual void ice_postUnmarshal(); @@ -581,7 +623,7 @@ public: virtual void _iceWrite(Ice::OutputStream*) const; virtual void _iceRead(Ice::InputStream*); - virtual ClassInfoPtr getInfo() const; + virtual ValueInfoPtr getInfo() const; PyObject* getObject() const; // Borrowed reference. @@ -590,7 +632,7 @@ public: private: PyObject* _object; - ClassInfoPtr _info; + ValueInfoPtr _info; Ice::SlicedDataPtr _slicedData; }; @@ -672,6 +714,7 @@ public: }; ClassInfoPtr lookupClassInfo(const std::string&); +ValueInfoPtr lookupValueInfo(const std::string&); ExceptionInfoPtr lookupExceptionInfo(const std::string&); extern PyObject* Unset; @@ -695,6 +738,8 @@ extern "C" PyObject* IcePy_declareProxy(PyObject*, PyObject*); extern "C" PyObject* IcePy_defineProxy(PyObject*, PyObject*); extern "C" PyObject* IcePy_declareClass(PyObject*, PyObject*); extern "C" PyObject* IcePy_defineClass(PyObject*, PyObject*); +extern "C" PyObject* IcePy_declareValue(PyObject*, PyObject*); +extern "C" PyObject* IcePy_defineValue(PyObject*, PyObject*); extern "C" PyObject* IcePy_defineException(PyObject*, PyObject*); extern "C" PyObject* IcePy_stringify(PyObject*, PyObject*); extern "C" PyObject* IcePy_stringifyException(PyObject*, PyObject*); diff --git a/python/modules/IcePy/ValueFactoryManager.cpp b/python/modules/IcePy/ValueFactoryManager.cpp index d1f78ddbaad..5ef221b0d0e 100644 --- a/python/modules/IcePy/ValueFactoryManager.cpp +++ b/python/modules/IcePy/ValueFactoryManager.cpp @@ -32,25 +32,10 @@ struct ValueFactoryManagerObject namespace { -ClassInfoPtr -getClassInfo(const string& id) +ValueInfoPtr +getValueInfo(const string& id) { - ClassInfoPtr info; - - if(id == Ice::Object::ice_staticId()) - { - // - // When the ID is that of Ice::Object, it indicates that the stream has not - // found a factory and is providing us an opportunity to preserve the object. - // - info = lookupClassInfo("::Ice::UnknownSlicedObject"); - } - else - { - info = lookupClassInfo(id); - } - - return info; + return id == Ice::Object::ice_staticId() ? lookupValueInfo("::Ice::UnknownSlicedValue") : lookupValueInfo(id); } } @@ -229,7 +214,7 @@ IcePy::FactoryWrapper::create(const string& id) // // Get the type information. // - ClassInfoPtr info = getClassInfo(id); + ValueInfoPtr info = getValueInfo(id); if(!info) { @@ -298,7 +283,7 @@ IcePy::DefaultValueFactory::create(const string& id) // // Get the type information. // - ClassInfoPtr info = getClassInfo(id); + ValueInfoPtr info = getValueInfo(id); if(!info) { @@ -306,14 +291,6 @@ IcePy::DefaultValueFactory::create(const string& id) } // - // If the requested type is an abstract class, then we give up. - // - if(info->isAbstract) - { - return 0; - } - - // // Instantiate the object. // PyTypeObject* type = reinterpret_cast<PyTypeObject*>(info->pythonType.get()); |