diff options
49 files changed, 946 insertions, 507 deletions
diff --git a/cpp/src/Slice/PythonUtil.cpp b/cpp/src/Slice/PythonUtil.cpp index e1001869e8a..9dc1830cb1b 100644 --- a/cpp/src/Slice/PythonUtil.cpp +++ b/cpp/src/Slice/PythonUtil.cpp @@ -124,9 +124,14 @@ public: private: // + // Emit Python code for the class operations + // + void writeOperations(const ClassDefPtr&); + + // // Return a Python symbol for the given parser element. // - string getSymbol(const ContainedPtr&, const string& = string()); + string getSymbol(const ContainedPtr&, const string& = "", const string& = ""); // // Emit Python code to assign the given symbol in the current module. @@ -269,7 +274,7 @@ splitScopedName(const string& scoped) } static string -getDictLookup(const ContainedPtr& cont, const string& suffix = string()) +getDictLookup(const ContainedPtr& cont, const string& suffix = "", const string& prefix = "") { string scope = Slice::Python::scopedToName(cont->scope()); assert(!scope.empty()); @@ -280,7 +285,7 @@ getDictLookup(const ContainedPtr& cont, const string& suffix = string()) scope = package + "." + scope; } - return "'" + suffix + Slice::Python::fixIdent(cont->name()) + "' not in _M_" + scope + "__dict__"; + return "'" + suffix + Slice::Python::fixIdent(cont->name() + prefix) + "' not in _M_" + scope + "__dict__"; } // @@ -421,10 +426,15 @@ Slice::Python::CodeVisitor::visitClassDecl(const ClassDeclPtr& p) { _out << sp << nl << "if " << getDictLookup(p) << ':'; _out.inc(); - string type = getAbsolute(p, "_t_"); - _out << nl << "_M_" << type << " = IcePy.declareClass('" << scoped << "')"; - if(!p->isLocal()) + + if(!p->isInterface() || p->isLocal()) { + _out << nl << "_M_" << getAbsolute(p, "_t_") << " = IcePy.declareValue('" << scoped << "')"; + } + + if(!p->isLocal() && (p->isInterface() || p->definition()->allOperations().size())) + { + _out << nl << "_M_" << getAbsolute(p, "_t_", "Disp") << " = IcePy.declareClass('" << scoped << "')"; _out << nl << "_M_" << getAbsolute(p, "_t_", "Prx") << " = IcePy.declareProxy('" << scoped << "')"; } _out.dec(); @@ -432,150 +442,10 @@ Slice::Python::CodeVisitor::visitClassDecl(const ClassDeclPtr& p) } } -bool -Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) +void +Slice::Python::CodeVisitor::writeOperations(const ClassDefPtr& p) { - string scoped = p->scoped(); - string type = getAbsolute(p, "_t_"); - string abs = getAbsolute(p); - string name = fixIdent(p->name()); - string prxAbs = getAbsolute(p, "", "Prx"); - string prxName = fixIdent(p->name() + "Prx"); - string prxType = getAbsolute(p, "_t_", "Prx"); - ClassList bases = p->bases(); - ClassDefPtr base; OperationList ops = p->operations(); - bool isAbstract = p->isInterface() || p->allOperations().size() > 0; // Don't use isAbstract() - see bug 3739 - - // - // Define the class. - // - _out << sp << nl << "if " << getDictLookup(p) << ':'; - _out.inc(); - _out << nl << "_M_" << abs << " = Ice.createTempClass()"; - _out << nl << "class " << name << '('; - if(bases.empty()) - { - if(p->isLocal()) - { - _out << "object"; - } - else - { - _out << "Ice.Object"; - } - } - else - { - for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q) - { - if(q != bases.begin()) - { - _out << ", "; - } - _out << getSymbol(*q); - } - if(!bases.front()->isInterface()) - { - base = bases.front(); - } - } - _out << "):"; - - _out.inc(); - - writeDocstring(p->comment(), p->dataMembers()); - - // - // __init__ - // - _out << nl << "def __init__(self"; - MemberInfoList allMembers; - collectClassMembers(p, allMembers, false); - writeConstructorParams(allMembers); - _out << "):"; - _out.inc(); - if(!base && !p->hasDataMembers() && !isAbstract) - { - _out << nl << "pass"; - } - else - { - if(isAbstract) - { - _out << nl << "if Ice.getType(self) == _M_" << abs << ':'; - _out.inc(); - _out << nl << "raise RuntimeError('" << abs << " is an abstract class')"; - _out.dec(); - } - if(base) - { - _out << nl << getSymbol(base) << ".__init__(self"; - for(MemberInfoList::iterator q = allMembers.begin(); q != allMembers.end(); ++q) - { - if(q->inherited) - { - _out << ", " << q->fixedName; - } - } - _out << ')'; - } - for(MemberInfoList::iterator q = allMembers.begin(); q != allMembers.end(); ++q) - { - if(!q->inherited) - { - writeAssign(*q); - } - } - } - _out.dec(); - - if(!p->isLocal()) - { - // - // ice_ids - // - ClassList allBases = p->allBases(); - StringList ids; - transform(allBases.begin(), allBases.end(), back_inserter(ids), IceUtil::constMemFun(&Contained::scoped)); - StringList other; - other.push_back(scoped); - other.push_back("::Ice::Object"); - other.sort(); - ids.merge(other); - ids.unique(); - _out << sp << nl << "def ice_ids(self, current=None):"; - _out.inc(); - _out << nl << "return ("; - for(StringList::iterator q = ids.begin(); q != ids.end(); ++q) - { - if(q != ids.begin()) - { - _out << ", "; - } - _out << "'" << *q << "'"; - } - _out << ')'; - _out.dec(); - - // - // ice_id - // - _out << sp << nl << "def ice_id(self, current=None):"; - _out.inc(); - _out << nl << "return '" << scoped << "'"; - _out.dec(); - - // - // ice_staticId - // - _out << sp << nl << "@staticmethod"; - _out << nl << "def ice_staticId():"; - _out.inc(); - _out << nl << "return '" << scoped << "'"; - _out.dec(); - } - if(!ops.empty()) { // @@ -637,44 +507,276 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) } } } +} - // - // __str__ - // - _out << sp << nl << "def __str__(self):"; - _out.inc(); - _out << nl << "return IcePy.stringify(self, _M_" << getAbsolute(p, "_t_") << ")"; - _out.dec(); - _out << sp << nl << "__repr__ = __str__"; +bool +Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) +{ + bool isLocal = p->isLocal(); + bool isInterface = p->isInterface(); + bool isAbstract = isInterface || p->allOperations().size() > 0; // Don't use isAbstract() - see bug 3739 - _out.dec(); + string scoped = p->scoped(); + string type = getAbsolute(p, "_t_"); + string classType = getAbsolute(p, "_t_", "Disp"); + string abs = getAbsolute(p); + string className = isLocal ? fixIdent(p->name()) : isAbstract ? fixIdent("_" + p->name() + "Disp") : "None"; + string classAbs = getAbsolute(p, "_", "Disp"); + string valueName = (isInterface && !isLocal) ? "Ice.Value" : fixIdent(p->name()); + string prxAbs = getAbsolute(p, "", "Prx"); + string prxName = fixIdent(p->name() + "Prx"); + string prxType = getAbsolute(p, "_t_", "Prx"); + ClassList bases = p->bases(); + ClassDefPtr base; + + if(!bases.empty() && !bases.front()->isInterface()) + { + base = bases.front(); + } // - // Define the proxy class. + // Define a class type for Value types or local classes. // - if(!p->isLocal()) + if(isLocal || !isInterface) { - _out << sp << nl << "_M_" << prxAbs << " = Ice.createTempClass()"; - _out << nl << "class " << prxName << "("; - if(bases.empty()) + _out << sp << nl << "if " << getDictLookup(p) << ':'; + _out.inc(); + _out << nl << "_M_" << abs << " = Ice.createTempClass()"; + _out << nl << "class " << valueName << '('; + if(isLocal) + { + if(bases.empty()) + { + _out << "object"; + } + else + { + for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q) + { + if(q != bases.begin()) + { + _out << ", "; + } + _out << getSymbol(*q); + } + } + } + else { - _out << "Ice.ObjectPrx"; + if(bases.empty() || bases.front()->isInterface()) + { + _out << "Ice.Value"; + } + else + { + _out << getSymbol(bases.front()); + } + } + _out << "):"; + + _out.inc(); + + writeDocstring(p->comment(), p->dataMembers()); + + // + // __init__ + // + _out << nl << "def __init__(self"; + MemberInfoList allMembers; + collectClassMembers(p, allMembers, false); + writeConstructorParams(allMembers); + _out << "):"; + _out.inc(); + if(!base && !p->hasDataMembers() && (!isAbstract || !isLocal)) + { + _out << nl << "pass"; } else { - ClassList::const_iterator q = bases.begin(); - while(q != bases.end()) + if(isAbstract && isLocal) { - _out << getSymbol(*q, "Prx"); - if(++q != bases.end()) + _out << nl << "if Ice.getType(self) == _M_" << abs << ':'; + _out.inc(); + _out << nl << "raise RuntimeError('" << abs << " is an abstract class')"; + _out.dec(); + } + if(base) + { + _out << nl << getSymbol(base) << ".__init__(self"; + for(MemberInfoList::iterator q = allMembers.begin(); q != allMembers.end(); ++q) { - _out << ", "; + if(q->inherited) + { + _out << ", " << q->fixedName; + } + } + _out << ')'; + } + for(MemberInfoList::iterator q = allMembers.begin(); q != allMembers.end(); ++q) + { + if(!q->inherited) + { + writeAssign(*q); } } } - _out << "):"; + _out.dec(); + + if(!isLocal) + { + // + // ice_id + // + _out << sp << nl << "def ice_id(self, current=None):"; + _out.inc(); + _out << nl << "return '" << scoped << "'"; + _out.dec(); + + // + // ice_staticId + // + _out << sp << nl << "@staticmethod"; + _out << nl << "def ice_staticId():"; + _out.inc(); + _out << nl << "return '" << scoped << "'"; + _out.dec(); + } + else + { + writeOperations(p); + } + + // + // __str__ + // + _out << sp << nl << "def __str__(self):"; + _out.inc(); + _out << nl << "return IcePy.stringify(self, _M_" << type << ")"; + _out.dec(); + _out << sp << nl << "__repr__ = __str__"; + + _out.dec(); + + if(_classHistory.count(scoped) == 0 && p->canBeCyclic()) + { + // + // Emit a forward declaration for the class in case a data member refers to this type. + // + _out << sp << nl << "_M_" << type << " = IcePy.declareValue('" << scoped << "')"; + } + DataMemberList members = p->dataMembers(); + _out << sp << nl << "_M_" << type << " = IcePy.defineValue('" << scoped << "', " << valueName + << ", " << p->compactId() << ", "; + writeMetaData(p->getMetaData()); + const bool preserved = p->hasMetaData("preserve-slice") || p->inheritsMetaData("preserve-slice"); + _out << ", " << (preserved ? "True" : "False") << ", " << (isInterface ? "True" : "False") << ", "; + if(!base) + { + _out << "None"; + } + else + { + _out << "_M_" << getAbsolute(base, "_t_"); + } + _out << ", ("; + // + // Members + // + // Data members are represented as a tuple: + // + // ('MemberName', MemberMetaData, MemberType, Optional, Tag) + // + // where MemberType is either a primitive type constant (T_INT, etc.) or the id of a constructed type. + // + if(members.size() > 1) + { + _out.inc(); + _out << nl; + } + bool isProtected = p->hasMetaData("protected"); + for(DataMemberList::iterator r = members.begin(); r != members.end(); ++r) + { + if(r != members.begin()) + { + _out << ',' << nl; + } + _out << "('"; + if(isProtected || (*r)->hasMetaData("protected")) + { + _out << '_'; + } + _out << fixIdent((*r)->name()) << "', "; + writeMetaData((*r)->getMetaData()); + _out << ", "; + writeType((*r)->type()); + _out << ", " << ((*r)->optional() ? "True" : "False") << ", " + << ((*r)->optional() ? (*r)->tag() : 0) << ')'; + } + if(members.size() == 1) + { + _out << ','; + } + else if(members.size() > 1) + { + _out.dec(); + _out << nl; + } + _out << "))"; + _out << nl << valueName << "._ice_type = _M_" << type; + + registerName(valueName); + + _out.dec(); + } + else if(!isLocal && isInterface) + { + _out << sp << nl << "_M_" << type << " = IcePy.defineValue('" << scoped << "', Ice.Value, -1, "; + writeMetaData(p->getMetaData()); + _out << ", False, True, None, ())"; + } + + if(!isLocal && isAbstract) + { + _out << sp << nl << "if " << getDictLookup(p, "", "Prx") << ':'; _out.inc(); + // Define the proxy class + _out << nl << "_M_" << prxAbs << " = Ice.createTempClass()"; + _out << nl << "class " << prxName << '('; + + { + vector<string> baseClasses; + for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q) + { + ClassDefPtr d = *q; + if(d->isInterface() || d->allOperations().size() > 0) + { + baseClasses.push_back(getSymbol(*q, "", "Prx")); + } + } + + if(baseClasses.empty()) + { + _out << "Ice.ObjectPrx"; + } + else + { + vector<string>::const_iterator q = baseClasses.begin(); + while(q != baseClasses.end()) + { + _out << *q; + + if(++q != baseClasses.end()) + { + _out << ", "; + } + } + } + } + _out << "):"; + _out.inc(); + + OperationList ops = p->operations(); for(OperationList::iterator oli = ops.begin(); oli != ops.end(); ++oli) { string fixedOpName = fixIdent((*oli)->name()); @@ -708,7 +810,7 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) const string contextParamName = getEscapedParamName(*oli, "context"); _out << ", " << contextParamName << "=None):"; _out.inc(); - _out << nl << "return _M_" << abs << "._op_" << (*oli)->name() << ".invoke(self, ((" << inParams; + _out << nl << "return _M_" << classAbs << "._op_" << (*oli)->name() << ".invoke(self, ((" << inParams; if(!inParams.empty() && inParams.find(',') == string::npos) { _out << ", "; @@ -728,7 +830,7 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) } _out << ", " << contextParamName << "=None):"; _out.inc(); - _out << nl << "return _M_" << abs << "._op_" << (*oli)->name() << ".invokeAsync(self, ((" << inParams; + _out << nl << "return _M_" << classAbs << "._op_" << (*oli)->name() << ".invokeAsync(self, ((" << inParams; if(!inParams.empty() && inParams.find(',') == string::npos) { _out << ", "; @@ -745,7 +847,7 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) } _out << ", _response=None, _ex=None, _sent=None, " << contextParamName << "=None):"; _out.inc(); - _out << nl << "return _M_" << abs << "._op_" << (*oli)->name() << ".begin(self, ((" << inParams; + _out << nl << "return _M_" << classAbs << "._op_" << (*oli)->name() << ".begin(self, ((" << inParams; if(!inParams.empty() && inParams.find(',') == string::npos) { _out << ", "; @@ -757,7 +859,7 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) writeDocstring(*oli, DocAsyncEnd, false); _out << nl << "def end_" << (*oli)->name() << "(self, _r):"; _out.inc(); - _out << nl << "return _M_" << abs << "._op_" << (*oli)->name() << ".end(self, _r)"; + _out << nl << "return _M_" << classAbs << "._op_" << (*oli)->name() << ".end(self, _r)"; _out.dec(); } @@ -783,110 +885,149 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << "return '" << scoped << "'"; _out.dec(); - _out.dec(); + _out.dec(); // end prx class + + _out << nl << "_M_" << prxType << " = IcePy.defineProxy('" << scoped << "', " << prxName << ")"; - _out << sp << nl << "_M_" << prxType << " = IcePy.defineProxy('" << scoped << "', " << prxName << ")"; - } + registerName(prxName); - if(_classHistory.count(scoped) == 0 && p->canBeCyclic()) - { + // Define the servant class + _out << sp << nl << "_M_" << classAbs << " = Ice.createTempClass()"; + _out << nl << "class " << className << '('; + { + vector<string> baseClasses; + for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q) + { + ClassDefPtr d = *q; + if(d->isInterface() || d->allOperations().size() > 0) + { + baseClasses.push_back(getSymbol(*q, "_", "Disp")); + } + } + + if(baseClasses.empty()) + { + _out << "Ice.Object"; + } + else + { + vector<string>::const_iterator q = baseClasses.begin(); + while(q != baseClasses.end()) + { + _out << *q; + + if(++q != baseClasses.end()) + { + _out << ", "; + } + } + } + } + _out << "):"; + + _out.inc(); + // - // Emit a forward declaration for the class in case a data member refers to this type. + // ice_ids // - _out << sp << nl << "_M_" << type << " = IcePy.declareClass('" << scoped << "')"; - } - - DataMemberList members = p->dataMembers(); - _out << sp << nl << "_M_" << type << " = IcePy.defineClass('" << scoped << "', " << name << ", " << p->compactId() - << ", "; - writeMetaData(p->getMetaData()); - const bool preserved = p->hasMetaData("preserve-slice") || p->inheritsMetaData("preserve-slice"); - _out << ", " << (isAbstract ? "True" : "False") << ", " << (preserved ? "True" : "False") << ", "; - if(!base) - { - _out << "None"; - } - else - { - _out << "_M_" << getAbsolute(base, "_t_"); - } - _out << ", ("; - // - // Interfaces - // - int interfaceCount = 0; - for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q) - { - if((*q)->isInterface()) + ClassList allBases = p->allBases(); + StringList ids; + transform(allBases.begin(), allBases.end(), back_inserter(ids), IceUtil::constMemFun(&Contained::scoped)); + StringList other; + other.push_back(scoped); + other.push_back("::Ice::Object"); + other.sort(); + ids.merge(other); + ids.unique(); + _out << sp << nl << "def ice_ids(self, current=None):"; + _out.inc(); + _out << nl << "return ("; + for(StringList::iterator q = ids.begin(); q != ids.end(); ++q) { - if(interfaceCount > 0) + if(q != ids.begin()) { _out << ", "; } - _out << "_M_" << getAbsolute(*q, "_t_"); - ++interfaceCount; + _out << "'" << *q << "'"; } - } - if(interfaceCount == 1) - { - _out << ','; - } - // - // Members - // - // Data members are represented as a tuple: - // - // ('MemberName', MemberMetaData, MemberType, Optional, Tag) - // - // where MemberType is either a primitive type constant (T_INT, etc.) or the id of a constructed type. - // - _out << "), ("; - if(members.size() > 1) - { + _out << ')'; + _out.dec(); + + // + // ice_id + // + _out << sp << nl << "def ice_id(self, current=None):"; _out.inc(); - _out << nl; - } - bool isProtected = p->hasMetaData("protected"); - for(DataMemberList::iterator r = members.begin(); r != members.end(); ++r) - { - if(r != members.begin()) + _out << nl << "return '" << scoped << "'"; + _out.dec(); + + // + // ice_staticId + // + _out << sp << nl << "@staticmethod"; + _out << nl << "def ice_staticId():"; + _out.inc(); + _out << nl << "return '" << scoped << "'"; + _out.dec(); + + writeOperations(p); + + // + // __str__ + // + _out << sp << nl << "def __str__(self):"; + _out.inc(); + _out << nl << "return IcePy.stringify(self, _M_" << getAbsolute(p, "_t_", "Disp") << ")"; + _out.dec(); + _out << sp << nl << "__repr__ = __str__"; + + _out.dec(); + + _out << sp << nl << "_M_" << classType << " = IcePy.defineClass('" << scoped << "', " << className + << ", "; + writeMetaData(p->getMetaData()); + _out << ", "; + if(!base || (!base->isInterface() && base->allOperations().size() == 0)) { - _out << ',' << nl; + _out << "None"; + } + else + { + _out << "_M_" << getAbsolute(base, "_t_", "Disp"); } - _out << "('"; - if(isProtected || (*r)->hasMetaData("protected")) + _out << ", ("; + // + // Interfaces + // + int interfaceCount = 0; + for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q) { - _out << '_'; + if((*q)->isInterface()) + { + if(interfaceCount > 0) + { + _out << ", "; + } + _out << "_M_" << getAbsolute(*q, "_t_", "Disp"); + ++interfaceCount; + } } - _out << fixIdent((*r)->name()) << "', "; - writeMetaData((*r)->getMetaData()); - _out << ", "; - writeType((*r)->type()); - _out << ", " << ((*r)->optional() ? "True" : "False") << ", " - << ((*r)->optional() ? (*r)->tag() : 0) << ')'; - } - if(members.size() == 1) - { - _out << ','; - } - else if(members.size() > 1) - { - _out.dec(); - _out << nl; - } - _out << "))"; - _out << nl << name << "._ice_type = _M_" << type; - - // - // Define each operation. The arguments to the IcePy.Operation constructor are: - // - // '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. - // - if(!p->isLocal()) - { + if(interfaceCount == 1) + { + _out << ','; + } + _out << "))"; + _out << nl << className << "._ice_type = _M_" << classType; + + + // + // Define each operation. The arguments to the IcePy.Operation constructor are: + // + // '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. + // if(!ops.empty()) { _out << sp; @@ -910,10 +1051,10 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) break; } - _out << nl << name << "._op_" << (*s)->name() << " = IcePy.Operation('" << (*s)->name() << "', " - << getOperationMode((*s)->mode()) << ", " << getOperationMode((*s)->sendMode()) << ", " - << ((p->hasMetaData("amd") || (*s)->hasMetaData("amd")) ? "True" : "False") << ", " - << format << ", "; + _out << nl << className << "._op_" << (*s)->name() << " = IcePy.Operation('" << (*s)->name() << "', " + << getOperationMode((*s)->mode()) << ", " << getOperationMode((*s)->sendMode()) << ", " + << ((p->hasMetaData("amd") || (*s)->hasMetaData("amd")) ? "True" : "False") << ", " + << format << ", "; writeMetaData((*s)->getMetaData()); _out << ", ("; for(t = params.begin(), count = 0; t != params.end(); ++t) @@ -951,7 +1092,7 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) _out << ", "; writeType((*t)->type()); _out << ", " << ((*t)->optional() ? "True" : "False") << ", " - << ((*t)->optional() ? (*t)->tag() : 0) << ')'; + << ((*t)->optional() ? (*t)->tag() : 0) << ')'; ++count; } } @@ -1002,20 +1143,14 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) { msg = deprecateMetadata.substr(pos + 1); } - _out << nl << name << "._op_" << (*s)->name() << ".deprecate(\"" << msg << "\")"; + _out << nl << className << "._op_" << (*s)->name() << ".deprecate(\"" << msg << "\")"; } } - } - - registerName(name); - if(!p->isLocal()) - { - registerName(prxName); + registerName(className); + _out.dec(); } - _out.dec(); - if(_classHistory.count(scoped) == 0) { _classHistory.insert(scoped); // Avoid redundant declarations. @@ -1588,12 +1723,12 @@ Slice::Python::CodeVisitor::visitConst(const ConstPtr& p) } string -Slice::Python::CodeVisitor::getSymbol(const ContainedPtr& p, const string& nameSuffix) +Slice::Python::CodeVisitor::getSymbol(const ContainedPtr& p, const string& prefix, const string& suffix) { // // An explicit reference to another type must always be prefixed with "_M_". // - return "_M_" + getAbsolute(p, "", nameSuffix); + return "_M_" + getAbsolute(p, prefix, suffix); } void @@ -1655,7 +1790,7 @@ Slice::Python::CodeVisitor::writeType(const TypePtr& p) case Builtin::KindObject: case Builtin::KindValue: { - _out << "IcePy._t_Object"; + _out << "IcePy._t_Value"; break; } case Builtin::KindObjectProxy: @@ -1675,7 +1810,15 @@ Slice::Python::CodeVisitor::writeType(const TypePtr& p) ProxyPtr prx = ProxyPtr::dynamicCast(p); if(prx) { - _out << "_M_" << getAbsolute(prx->_class(), "_t_", "Prx"); + ClassDefPtr def = prx->_class()->definition(); + if(def->isInterface() || def->allOperations().size() > 0) + { + _out << "_M_" << getAbsolute(prx->_class(), "_t_", "Prx"); + } + else + { + _out << "IcePy._t_ObjectPrx"; + } return; } @@ -2815,14 +2958,7 @@ Slice::Python::getAbsolute(const ContainedPtr& cont, const string& suffix, const } } - if(suffix.empty()) - { - return scope + fixIdent(cont->name() + nameSuffix); - } - else - { - return scope + suffix + fixIdent(cont->name() + nameSuffix); - } + return scope + suffix + fixIdent(cont->name() + nameSuffix); } void 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()); diff --git a/python/python/Ice.py b/python/python/Ice.py index 2c22d9ca5c7..4c7e80227cf 100644 --- a/python/python/Ice.py +++ b/python/python/Ice.py @@ -291,6 +291,40 @@ _struct_marker = object() # # Core Ice types. # +class Value(object): + def ice_id(): + '''Obtains the type id corresponding to the most-derived Slice +interface supported by the target object. +Returns: + The type id. +''' + return '::Ice::Object' + + @staticmethod + def ice_staticId(): + '''Obtains the type id of this Slice class or interface. +Returns: + The type id. +''' + return '::Ice::Object' + + # + # Do not define these here. They will be invoked if defined by a subclass. + # + #def ice_preMarshal(self): + # pass + # + #def ice_postUnmarshal(self): + # pass + +class InterfaceByValue(Value): + + def __init__(self, id): + self.id = id + + def ice_id(self): + return self.id + class Object(object): def ice_isA(self, id, current=None): '''Determines whether the target object supports the interface denoted @@ -330,15 +364,6 @@ Returns: ''' return '::Ice::Object' - # - # Do not define these here. They will be invoked if defined by a subclass. - # - #def ice_preMarshal(self): - # pass - # - #def ice_postUnmarshal(self): - # pass - def _iceDispatch(self, cb, method, args): # Invoke the given servant method. Exceptions can propagate to the caller. result = method(*args) @@ -511,7 +536,7 @@ class SliceInfo(object): # typeId - string # compactId - int # bytes - string - # objects - tuple of Ice.Object + # objects - tuple of Ice.Value pass # @@ -526,7 +551,7 @@ class PropertiesAdminUpdateCallback(object): def updated(self, props): pass -class UnknownSlicedObject(Object): +class UnknownSlicedValue(Value): # # Members: # @@ -658,6 +683,7 @@ FormatType.SlicedFormat = FormatType(2) # Forward declarations. # IcePy._t_Object = IcePy.declareClass('::Ice::Object') +IcePy._t_Value = IcePy.declareValue('::Ice::Object') IcePy._t_ObjectPrx = IcePy.declareProxy('::Ice::Object') IcePy._t_LocalObject = IcePy.declareClass('::Ice::LocalObject') @@ -1743,7 +1769,8 @@ signal, or False otherwise.''' # # Define Ice::Object and Ice::ObjectPrx. # -IcePy._t_Object = IcePy.defineClass('::Ice::Object', Object, -1, (), False, False, None, (), ()) +IcePy._t_Object = IcePy.defineClass('::Ice::Object', Object, (), None, ()) +IcePy._t_Value = IcePy.defineValue('::Ice::Object', Value, -1, (), False, False, None, ()) IcePy._t_ObjectPrx = IcePy.defineProxy('::Ice::Object', ObjectPrx) Object._ice_type = IcePy._t_Object @@ -1752,10 +1779,10 @@ Object._op_ice_ping = IcePy.Operation('ice_ping', OperationMode.Idempotent, Oper Object._op_ice_ids = IcePy.Operation('ice_ids', OperationMode.Idempotent, OperationMode.Nonmutating, False, None, (), (), (), ((), _t_StringSeq, False, 0), ()) Object._op_ice_id = IcePy.Operation('ice_id', OperationMode.Idempotent, OperationMode.Nonmutating, False, None, (), (), (), ((), IcePy._t_string, False, 0), ()) -IcePy._t_LocalObject = IcePy.defineClass('::Ice::LocalObject', object, -1, (), False, False, None, (), ()) +IcePy._t_LocalObject = IcePy.defineValue('::Ice::LocalObject', object, -1, (), False, False, None, ()) -IcePy._t_UnknownSlicedObject = IcePy.defineClass('::Ice::UnknownSlicedObject', UnknownSlicedObject, -1, (), False, True, None, (), ()) -UnknownSlicedObject._ice_type = IcePy._t_UnknownSlicedObject +IcePy._t_UnknownSlicedValue = IcePy.defineValue('::Ice::UnknownSlicedValue', UnknownSlicedValue, -1, (), True, False, None, ()) +UnknownSlicedValue._ice_type = IcePy._t_UnknownSlicedValue # # Annotate some exceptions. diff --git a/python/test/Ice/acm/TestI.py b/python/test/Ice/acm/TestI.py index a54e13621bb..10565ca9540 100644 --- a/python/test/Ice/acm/TestI.py +++ b/python/test/Ice/acm/TestI.py @@ -9,7 +9,7 @@ import Ice, Test, threading -class RemoteCommunicatorI(Test.RemoteCommunicator): +class RemoteCommunicatorI(Test._RemoteCommunicatorDisp): def createObjectAdapter(self, timeout, close, heartbeat, current=None): com = current.adapter.getCommunicator() properties = com.getProperties() @@ -29,7 +29,7 @@ class RemoteCommunicatorI(Test.RemoteCommunicator): def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() -class RemoteObjectAdapterI(Test.RemoteObjectAdapter): +class RemoteObjectAdapterI(Test._RemoteObjectAdapterDisp): def __init__(self, adapter): self._adapter = adapter self._testIntf = Test.TestIntfPrx.uncheckedCast(adapter.add(TestIntfI(), @@ -51,7 +51,7 @@ class RemoteObjectAdapterI(Test.RemoteObjectAdapter): except Ice.ObjectAdapterDeactivatedException: pass -class TestIntfI(Test.TestIntf): +class TestIntfI(Test._TestIntfDisp): def __init__(self): self.m = threading.Condition() diff --git a/python/test/Ice/adapterDeactivation/TestI.py b/python/test/Ice/adapterDeactivation/TestI.py index 6bbe518e2ea..4ba3f2b07d7 100644 --- a/python/test/Ice/adapterDeactivation/TestI.py +++ b/python/test/Ice/adapterDeactivation/TestI.py @@ -14,7 +14,7 @@ def test(b): if not b: raise RuntimeError('test assertion failed') -class TestI(Test.TestIntf): +class TestI(Test._TestIntfDisp): def transient(self, current=None): communicator = current.adapter.getCommunicator() adapter = communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default -p 9999") diff --git a/python/test/Ice/admin/TestI.py b/python/test/Ice/admin/TestI.py index c040ffbef59..b3667154c4e 100644 --- a/python/test/Ice/admin/TestI.py +++ b/python/test/Ice/admin/TestI.py @@ -13,11 +13,11 @@ def test(b): if not b: raise RuntimeError('test assertion failed') -class TestFacetI(Test.TestFacet): +class TestFacetI(Test._TestFacetDisp): def op(self, current = None): return -class RemoteCommunicatorI(Test.RemoteCommunicator, Ice.PropertiesAdminUpdateCallback): +class RemoteCommunicatorI(Test._RemoteCommunicatorDisp, Ice.PropertiesAdminUpdateCallback): def __init__(self, communicator): self.communicator = communicator self.called = False @@ -61,7 +61,7 @@ class RemoteCommunicatorI(Test.RemoteCommunicator, Ice.PropertiesAdminUpdateCall self.called = True self.m.notify() -class RemoteCommunicatorFactoryI(Test.RemoteCommunicatorFactory): +class RemoteCommunicatorFactoryI(Test._RemoteCommunicatorFactoryDisp): def createCommunicator(self, props, current = None): # diff --git a/python/test/Ice/ami/AllTests.py b/python/test/Ice/ami/AllTests.py index 7675ee8d4fb..549915ee12e 100644 --- a/python/test/Ice/ami/AllTests.py +++ b/python/test/Ice/ami/AllTests.py @@ -446,13 +446,13 @@ def allTests(communicator, collocated): cookie = 5 cbWC = ResponseCallbackWC(cookie) - p.begin_ice_isA(Test.TestIntf.ice_staticId(), cb.isA, cb.ex) + p.begin_ice_isA(Test._TestIntfDisp.ice_staticId(), cb.isA, cb.ex) cb.check() - p.begin_ice_isA(Test.TestIntf.ice_staticId(), lambda r: cbWC.isA(r, cookie), lambda ex: cbWC.ex(ex, cookie)) + p.begin_ice_isA(Test._TestIntfDisp.ice_staticId(), lambda r: cbWC.isA(r, cookie), lambda ex: cbWC.ex(ex, cookie)) cbWC.check() - p.begin_ice_isA(Test.TestIntf.ice_staticId(), cb.isA, cb.ex, context=ctx) + p.begin_ice_isA(Test._TestIntfDisp.ice_staticId(), cb.isA, cb.ex, context=ctx) cb.check() - p.begin_ice_isA(Test.TestIntf.ice_staticId(), lambda r: cbWC.isA(r, cookie), lambda ex: cbWC.ex(ex, cookie), + p.begin_ice_isA(Test._TestIntfDisp.ice_staticId(), lambda r: cbWC.isA(r, cookie), lambda ex: cbWC.ex(ex, cookie), context=ctx) cbWC.check() @@ -563,9 +563,9 @@ def allTests(communicator, collocated): cookie = 5 cbWC = ExceptionCallbackWC(cookie) - i.begin_ice_isA(Test.TestIntf.ice_staticId(), cb.response, cb.ex) + i.begin_ice_isA(Test._TestIntfDisp.ice_staticId(), cb.response, cb.ex) cb.check() - i.begin_ice_isA(Test.TestIntf.ice_staticId(), lambda b: cbWC.response(b, cookie), lambda ex: cbWC.ex(ex, cookie)) + i.begin_ice_isA(Test._TestIntfDisp.ice_staticId(), lambda b: cbWC.response(b, cookie), lambda ex: cbWC.ex(ex, cookie)) cbWC.check() i.begin_ice_ping(cb.response, cb.ex) @@ -604,8 +604,8 @@ def allTests(communicator, collocated): cbWC = ExceptionCallbackWC(cookie) # Ensures no exception is called when response is received. - p.begin_ice_isA(Test.TestIntf.ice_staticId(), cb.nullResponse, cb.noEx) - p.begin_ice_isA(Test.TestIntf.ice_staticId(), lambda b: cbWC.nullResponse(b, cookie), + p.begin_ice_isA(Test._TestIntfDisp.ice_staticId(), cb.nullResponse, cb.noEx) + p.begin_ice_isA(Test._TestIntfDisp.ice_staticId(), lambda b: cbWC.nullResponse(b, cookie), lambda ex: cbWC.noEx(ex, cookie)) p.begin_op(cb.nullResponse, cb.noEx) p.begin_op(lambda: cbWC.nullResponse(cookie), lambda ex: cbWC.noEx(ex, cookie)) @@ -1220,9 +1220,9 @@ def allTestsFuture(communicator, collocated): ctx = {} cb = FutureDoneCallback() - p.ice_isAAsync(Test.TestIntf.ice_staticId()).add_done_callback(cb.isA) + p.ice_isAAsync(Test._TestIntfDisp.ice_staticId()).add_done_callback(cb.isA) cb.check() - p.ice_isAAsync(Test.TestIntf.ice_staticId(), ctx).add_done_callback(cb.isA) + p.ice_isAAsync(Test._TestIntfDisp.ice_staticId(), ctx).add_done_callback(cb.isA) cb.check() p.ice_pingAsync().add_done_callback(cb.ping) @@ -1303,7 +1303,7 @@ def allTestsFuture(communicator, collocated): i = Test.TestIntfPrx.uncheckedCast(p.ice_adapterId("dummy")) cb = FutureExceptionCallback() - i.ice_isAAsync(Test.TestIntf.ice_staticId()).add_done_callback(cb.ex) + i.ice_isAAsync(Test._TestIntfDisp.ice_staticId()).add_done_callback(cb.ex) cb.check() i.ice_pingAsync().add_done_callback(cb.ex) @@ -1330,7 +1330,7 @@ def allTestsFuture(communicator, collocated): cb = FutureExceptionCallback() # Ensures no exception is set when response is received. - p.ice_isAAsync(Test.TestIntf.ice_staticId()).add_done_callback(cb.noEx) + p.ice_isAAsync(Test._TestIntfDisp.ice_staticId()).add_done_callback(cb.noEx) p.opAsync().add_done_callback(cb.noEx) # If response is a user exception, it should be received. diff --git a/python/test/Ice/ami/TestI.py b/python/test/Ice/ami/TestI.py index f37bd47f806..3770a2c6101 100644 --- a/python/test/Ice/ami/TestI.py +++ b/python/test/Ice/ami/TestI.py @@ -9,7 +9,7 @@ import Ice, Test, threading -class TestIntfI(Test.TestIntf): +class TestIntfI(Test._TestIntfDisp): def __init__(self): self._cond = threading.Condition() self._batchCount = 0 @@ -52,7 +52,7 @@ class TestIntfI(Test.TestIntf): def supportsFunctionalTests(self, current=None): return False -class TestIntfControllerI(Test.TestIntfController): +class TestIntfControllerI(Test._TestIntfControllerDisp): def __init__(self, adapter): self._adapter = adapter diff --git a/python/test/Ice/binding/TestI.py b/python/test/Ice/binding/TestI.py index a707b83f191..433865b223a 100644 --- a/python/test/Ice/binding/TestI.py +++ b/python/test/Ice/binding/TestI.py @@ -9,7 +9,7 @@ import Ice, Test -class RemoteCommunicatorI(Test.RemoteCommunicator): +class RemoteCommunicatorI(Test._RemoteCommunicatorDisp): def __init__(self): self._nextPort = 10001 @@ -32,7 +32,7 @@ class RemoteCommunicatorI(Test.RemoteCommunicator): def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() -class RemoteObjectAdapterI(Test.RemoteObjectAdapter): +class RemoteObjectAdapterI(Test._RemoteObjectAdapterDisp): def __init__(self, adapter): self._adapter = adapter self._testIntf = Test.TestIntfPrx.uncheckedCast(self._adapter.add(TestI(), Ice.stringToIdentity("test"))) @@ -47,6 +47,6 @@ class RemoteObjectAdapterI(Test.RemoteObjectAdapter): except Ice.ObjectAdapterDeactivatedException: pass -class TestI(Test.TestIntf): +class TestI(Test._TestIntfDisp): def getAdapterName(self, current=None): return current.adapter.getName() diff --git a/python/test/Ice/blobject/RouterI.py b/python/test/Ice/blobject/RouterI.py index 7b07b36e1da..34767436317 100644 --- a/python/test/Ice/blobject/RouterI.py +++ b/python/test/Ice/blobject/RouterI.py @@ -131,7 +131,7 @@ class ServantLocatorI(Ice.ServantLocator): def deactivate(self, s): pass -class RouterI(Ice.Router): +class RouterI(Ice._RouterDisp): def __init__(self, communicator, sync): self._adapter = communicator.createObjectAdapterWithEndpoints("forward", "default -h 127.0.0.1") if sync: diff --git a/python/test/Ice/blobject/Server.py b/python/test/Ice/blobject/Server.py index 491f0ba9d8e..cd02c163c36 100755 --- a/python/test/Ice/blobject/Server.py +++ b/python/test/Ice/blobject/Server.py @@ -15,7 +15,7 @@ import Ice Ice.loadSlice('Test.ice') import Test -class TestI(Test.Hello): +class TestI(Test._HelloDisp): def sayHello(self, delay, current=None): if delay != 0: time.sleep(delay / 1000.0) diff --git a/python/test/Ice/checksum/Server.py b/python/test/Ice/checksum/Server.py index f2a074ad219..990de16608e 100755 --- a/python/test/Ice/checksum/Server.py +++ b/python/test/Ice/checksum/Server.py @@ -19,7 +19,7 @@ if not slice_dir: Ice.loadSlice("'-I" + slice_dir + "' --checksum Test.ice STypes.ice") import Test -class ChecksumI(Test.Checksum): +class ChecksumI(Test._ChecksumDisp): def getSliceChecksums(self, current=None): return Ice.sliceChecksums diff --git a/python/test/Ice/custom/Server.py b/python/test/Ice/custom/Server.py index 12621d40ca9..0c118c80344 100755 --- a/python/test/Ice/custom/Server.py +++ b/python/test/Ice/custom/Server.py @@ -18,7 +18,7 @@ def test(b): if not b: raise RuntimeError('test assertion failed') -class CustomI(Test.Custom): +class CustomI(Test._CustomDisp): def opByteString1(self, b1, current=None): if sys.version_info[0] == 2: test(isinstance(b1, str)) diff --git a/python/test/Ice/defaultServant/MyObjectI.py b/python/test/Ice/defaultServant/MyObjectI.py index dd102d2c7de..586bffeb41f 100644 --- a/python/test/Ice/defaultServant/MyObjectI.py +++ b/python/test/Ice/defaultServant/MyObjectI.py @@ -9,7 +9,7 @@ import Ice, Test -class MyObjectI(Test.MyObject): +class MyObjectI(Test._MyObjectDisp): def ice_ping(self, current=None): name = current.id.name diff --git a/python/test/Ice/enums/Server.py b/python/test/Ice/enums/Server.py index 40cc8eb8d7f..299e1196301 100755 --- a/python/test/Ice/enums/Server.py +++ b/python/test/Ice/enums/Server.py @@ -18,7 +18,7 @@ def test(b): if not b: raise RuntimeError('test assertion failed') -class TestIntfI(Test.TestIntf): +class TestIntfI(Test._TestIntfDisp): def opByte(self, b1, current=None): return (b1, b1) diff --git a/python/test/Ice/exceptions/AllTests.py b/python/test/Ice/exceptions/AllTests.py index 3c13e06f24c..5672c896d85 100644 --- a/python/test/Ice/exceptions/AllTests.py +++ b/python/test/Ice/exceptions/AllTests.py @@ -13,7 +13,7 @@ def test(b): if not b: raise RuntimeError('test assertion failed') -class EmptyI(Test.Empty): +class EmptyI(Test._EmptyDisp): pass class ServantLocatorI(Ice.ServantLocator): diff --git a/python/test/Ice/exceptions/ServerAMD.py b/python/test/Ice/exceptions/ServerAMD.py index 21238afdcf8..999a41115c8 100755 --- a/python/test/Ice/exceptions/ServerAMD.py +++ b/python/test/Ice/exceptions/ServerAMD.py @@ -23,7 +23,7 @@ def test(b): if not b: raise RuntimeError('test assertion failed') -class ThrowerI(Test.Thrower): +class ThrowerI(Test._ThrowerDisp): def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() diff --git a/python/test/Ice/exceptions/TestI.py b/python/test/Ice/exceptions/TestI.py index ec32708df63..8424a790063 100644 --- a/python/test/Ice/exceptions/TestI.py +++ b/python/test/Ice/exceptions/TestI.py @@ -9,7 +9,7 @@ import Ice, Test, array, sys -class ThrowerI(Test.Thrower): +class ThrowerI(Test._ThrowerDisp): def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() diff --git a/python/test/Ice/facets/AllTests.py b/python/test/Ice/facets/AllTests.py index 4f804da33f7..97a6fd34e53 100644 --- a/python/test/Ice/facets/AllTests.py +++ b/python/test/Ice/facets/AllTests.py @@ -13,7 +13,7 @@ def test(b): if not b: raise RuntimeError('test assertion failed') -class EmptyI(Test.Empty): +class EmptyI(Test._EmptyDisp): pass def allTests(communicator): diff --git a/python/test/Ice/facets/TestI.py b/python/test/Ice/facets/TestI.py index 3d228e4d568..de1a73f4b6e 100644 --- a/python/test/Ice/facets/TestI.py +++ b/python/test/Ice/facets/TestI.py @@ -9,31 +9,31 @@ import Test -class AI(Test.A): +class AI(Test._ADisp): def callA(self, current=None): return "A" -class BI(Test.B, AI): +class BI(Test._BDisp, AI): def callB(self, current=None): return "B" -class CI(Test.C, AI): +class CI(Test._CDisp, AI): def callC(self, current=None): return "C" -class DI(Test.D, BI, CI): +class DI(Test._DDisp, BI, CI): def callD(self, current=None): return "D" -class EI(Test.E): +class EI(Test._EDisp): def callE(self, current=None): return "E" -class FI(Test.F, EI): +class FI(Test._FDisp, EI): def callF(self, current=None): return "F" -class GI(Test.G): +class GI(Test._GDisp): def __init__(self, communicator): self._communicator = communicator @@ -43,7 +43,7 @@ class GI(Test.G): def callG(self, current=None): return "G" -class HI(Test.H, GI): +class HI(Test._HDisp, GI): def __init__(self, communicator): GI.__init__(self, communicator) diff --git a/python/test/Ice/faultTolerance/Server.py b/python/test/Ice/faultTolerance/Server.py index 6e4b6fe0fc4..6185f4e23ac 100755 --- a/python/test/Ice/faultTolerance/Server.py +++ b/python/test/Ice/faultTolerance/Server.py @@ -17,7 +17,7 @@ import Test def usage(n): sys.stderr.write("Usage: " + n + " port\n") -class TestI(Test.TestIntf): +class TestI(Test._TestIntfDisp): def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() diff --git a/python/test/Ice/info/TestI.py b/python/test/Ice/info/TestI.py index 2325156db20..9bdef8847fe 100644 --- a/python/test/Ice/info/TestI.py +++ b/python/test/Ice/info/TestI.py @@ -22,7 +22,7 @@ def getIPConnectionInfo(info): return info info = info.underlying -class MyDerivedClassI(Test.TestIntf): +class MyDerivedClassI(Test._TestIntfDisp): def __init__(self): self.ctx = None diff --git a/python/test/Ice/inheritance/TestI.py b/python/test/Ice/inheritance/TestI.py index e5932e9b5d8..45672fe33b7 100644 --- a/python/test/Ice/inheritance/TestI.py +++ b/python/test/Ice/inheritance/TestI.py @@ -9,39 +9,39 @@ import Ice, Test -class CAI(Test.MA.CA): +class CAI(Test.MA._CADisp): def caop(self, p, current=None): return p -class CBI(Test.MB.CB, CAI): +class CBI(Test.MB._CBDisp, CAI): def cbop(self, p, current=None): return p -class CCI(Test.MA.CC, CBI): +class CCI(Test.MA._CCDisp, CBI): def ccop(self, p, current=None): return p -class IAI(Test.MA.IA): +class IAI(Test.MA._IADisp): def iaop(self, p, current=None): return p -class IB1I(Test.MB.IB1, IAI): +class IB1I(Test.MB._IB1Disp, IAI): def ib1op(self, p, current=None): return p -class IB2I(Test.MB.IB2, IAI): +class IB2I(Test.MB._IB2Disp, IAI): def ib2op(self, p, current=None): return p -class ICI(Test.MA.IC, IB1I, IB2I): +class ICI(Test.MA._ICDisp, IB1I, IB2I): def icop(self, p, current=None): return p -class CDI(Test.MA.CD, CCI, IB1I, IB2I): +class CDI(Test.MA._CDDisp, CCI, IB1I, IB2I): def cdop(self, p, current=None): return p -class InitialI(Test.Initial): +class InitialI(Test._InitialDisp): def __init__(self, adapter): self._ca = Test.MA.CAPrx.uncheckedCast(adapter.addWithUUID(CAI())) self._cb = Test.MB.CBPrx.uncheckedCast(adapter.addWithUUID(CBI())) diff --git a/python/test/Ice/location/AllTests.py b/python/test/Ice/location/AllTests.py index 91519152101..dc0fb5afe5d 100644 --- a/python/test/Ice/location/AllTests.py +++ b/python/test/Ice/location/AllTests.py @@ -9,7 +9,7 @@ import Ice, Test, sys -class HelloI(Test.Hello): +class HelloI(Test._HelloDisp): def sayHello(self, current=None): pass diff --git a/python/test/Ice/location/Server.py b/python/test/Ice/location/Server.py index b9e8f55e9ad..00e91ef3f47 100755 --- a/python/test/Ice/location/Server.py +++ b/python/test/Ice/location/Server.py @@ -19,7 +19,7 @@ if not slice_dir: Ice.loadSlice("'-I" + slice_dir + "' Test.ice") import Test -class ServerLocatorRegistry(Test.TestLocatorRegistry): +class ServerLocatorRegistry(Test._TestLocatorRegistryDisp): def __init__(self): self._adapters = {} self._objects = {} @@ -56,7 +56,7 @@ class ServerLocatorRegistry(Test.TestLocatorRegistry): raise Ice.ObjectNotFoundException() return self._objects[id] -class ServerLocator(Test.TestLocator): +class ServerLocator(Test._TestLocatorDisp): def __init__(self, registry, registryPrx): self._registry = registry @@ -77,7 +77,7 @@ class ServerLocator(Test.TestLocator): def getRequestCount(self, current=None): return self._requestCount -class ServerManagerI(Test.ServerManager): +class ServerManagerI(Test._ServerManagerDisp): def __init__(self, registry, initData): self._registry = registry self._communicators = [] @@ -121,11 +121,11 @@ class ServerManagerI(Test.ServerManager): i.destroy() current.adapter.getCommunicator().shutdown() -class HelloI(Test.Hello): +class HelloI(Test._HelloDisp): def sayHello(self, current=None): pass -class TestI(Test.TestIntf): +class TestI(Test._TestIntfDisp): def __init__(self, adapter, adapter2, registry): self._adapter1 = adapter self._adapter2 = adapter2 diff --git a/python/test/Ice/objects/AllTests.py b/python/test/Ice/objects/AllTests.py index 8f129218307..4137f79e1f9 100644 --- a/python/test/Ice/objects/AllTests.py +++ b/python/test/Ice/objects/AllTests.py @@ -106,7 +106,7 @@ def allTests(communicator): i = initial.getI() test(i) j = initial.getJ() - test(isinstance(j, Test.J)) + test(isinstance(j, TestI.JI)) h = initial.getH() test(isinstance(h, Test.H)) print("ok") diff --git a/python/test/Ice/objects/TestI.py b/python/test/Ice/objects/TestI.py index 7c0be3ae8dd..178182137a4 100644 --- a/python/test/Ice/objects/TestI.py +++ b/python/test/Ice/objects/TestI.py @@ -56,16 +56,18 @@ class FI(Test.F): def checkValues(self, current=None): return self._e1 != None and self._e1 == self.e2 -class II(Test.I): - pass +class II(Ice.InterfaceByValue): + def __init__(self): + Ice.InterfaceByValue.__init__(self, "::Test::I") -class JI(Test.J): - pass +class JI(Ice.InterfaceByValue): + def __init__(self): + Ice.InterfaceByValue.__init__(self, "::Test::J") class HI(Test.H): pass -class InitialI(Test.Initial): +class InitialI(Test._InitialDisp): def __init__(self, adapter): self._adapter = adapter self._b1 = BI() @@ -172,6 +174,6 @@ class InitialI(Test.Initial): def throwInnerSubEx(self, current=None): raise Test.Inner.Sub.Ex("Inner::Sub::Ex") -class UnexpectedObjectExceptionTestI(Test.UnexpectedObjectExceptionTest): +class UnexpectedObjectExceptionTestI(Test._UnexpectedObjectExceptionTestDisp): def op(self, current=None): return Test.AlsoEmpty() diff --git a/python/test/Ice/operations/ServerAMD.py b/python/test/Ice/operations/ServerAMD.py index b2e96b39c96..cc950bb90ec 100755 --- a/python/test/Ice/operations/ServerAMD.py +++ b/python/test/Ice/operations/ServerAMD.py @@ -37,7 +37,7 @@ class FutureThread(threading.Thread): time.sleep(0.01) self.future.set_result(self.result) -class MyDerivedClassI(Test.MyDerivedClass): +class MyDerivedClassI(Test._MyDerivedClassDisp): def __init__(self): self.threads = [] self.threadLock = threading.Lock() @@ -46,19 +46,19 @@ class MyDerivedClassI(Test.MyDerivedClass): def ice_isA(self, id, current=None): test(current.mode == Ice.OperationMode.Nonmutating) - return Test.MyDerivedClass.ice_isA(self, id, current) + return Test._MyDerivedClassDisp.ice_isA(self, id, current) def ice_ping(self, current=None): test(current.mode == Ice.OperationMode.Nonmutating) - Test.MyDerivedClass.ice_ping(self, current) + Test._MyDerivedClassDisp.ice_ping(self, current) def ice_ids(self, current=None): test(current.mode == Ice.OperationMode.Nonmutating) - return Test.MyDerivedClass.ice_ids(self, current) + return Test._MyDerivedClassDisp.ice_ids(self, current) def ice_id(self, current=None): test(current.mode == Ice.OperationMode.Nonmutating) - return Test.MyDerivedClass.ice_id(self, current) + return Test._MyDerivedClassDisp.ice_id(self, current) def shutdown(self, current=None): with self.threadLock: diff --git a/python/test/Ice/operations/TestI.py b/python/test/Ice/operations/TestI.py index 87b1e0b21bc..81a07969058 100644 --- a/python/test/Ice/operations/TestI.py +++ b/python/test/Ice/operations/TestI.py @@ -13,26 +13,26 @@ def test(b): if not b: raise RuntimeError('test assertion failed') -class MyDerivedClassI(Test.MyDerivedClass): +class MyDerivedClassI(Test._MyDerivedClassDisp): def __init__(self): self.lock = threading.Lock() self.opByteSOnewayCount = 0 def ice_isA(self, id, current=None): test(current.mode == Ice.OperationMode.Nonmutating) - return Test.MyDerivedClass.ice_isA(self, id, current) + return Test._MyDerivedClassDisp.ice_isA(self, id, current) def ice_ping(self, current=None): test(current.mode == Ice.OperationMode.Nonmutating) - Test.MyDerivedClass.ice_ping(self, current) + Test._MyDerivedClassDisp.ice_ping(self, current) def ice_ids(self, current=None): test(current.mode == Ice.OperationMode.Nonmutating) - return Test.MyDerivedClass.ice_ids(self, current) + return Test._MyDerivedClassDisp.ice_ids(self, current) def ice_id(self, current=None): test(current.mode == Ice.OperationMode.Nonmutating) - return Test.MyDerivedClass.ice_id(self, current) + return Test._MyDerivedClassDisp.ice_id(self, current) def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() diff --git a/python/test/Ice/optional/AllTests.py b/python/test/Ice/optional/AllTests.py index 8219fe6f428..e08940b82de 100644 --- a/python/test/Ice/optional/AllTests.py +++ b/python/test/Ice/optional/AllTests.py @@ -75,13 +75,13 @@ def allTests(communicator): fs = Test.FixedStruct(78) vs = Test.VarStruct("hello") mo1 = Test.MultiOptional(15, True, 19, 78, 99, 5.5, 1.0, "test", Test.MyEnum.MyEnumMember, \ - Test.MultiOptionalPrx.uncheckedCast(communicator.stringToProxy("test")), \ + communicator.stringToProxy("test"), \ None, [5], ["test", "test2"], {4:3}, {"test":10}, fs, vs, [1], \ [Test.MyEnum.MyEnumMember, Test.MyEnum.MyEnumMember], \ [ fs ], [ vs ], [ oo1 ], \ - [ Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test")) ], \ + [ communicator.stringToProxy("test") ], \ {4:Test.MyEnum.MyEnumMember}, {4:fs}, {5:vs}, {5:Test.OneOptional(15)}, \ - {5:Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test"))}, \ + {5:communicator.stringToProxy("test")}, \ [False, True, False]) test(mo1.a == 15) @@ -93,7 +93,7 @@ def allTests(communicator): test(mo1.g == 1.0) test(mo1.h == "test") test(mo1.i == Test.MyEnum.MyEnumMember) - test(mo1.j == Test.MultiOptionalPrx.uncheckedCast(communicator.stringToProxy("test"))) + test(mo1.j == communicator.stringToProxy("test")) test(mo1.k == None) test(mo1.bs == [5]) test(mo1.ss == ["test", "test2"]) @@ -107,13 +107,13 @@ def allTests(communicator): test(mo1.fss[0] == Test.FixedStruct(78)) test(mo1.vss[0] == Test.VarStruct("hello")) test(mo1.oos[0] == oo1) - test(mo1.oops[0] == Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test"))) + test(mo1.oops[0] == communicator.stringToProxy("test")) test(mo1.ied[4] == Test.MyEnum.MyEnumMember) test(mo1.ifsd[4] == Test.FixedStruct(78)) test(mo1.ivsd[5] == Test.VarStruct("hello")) test(mo1.iood[5].a == 15) - test(mo1.ioopd[5] == Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test"))) + test(mo1.ioopd[5] == communicator.stringToProxy("test")) test(mo1.bos == [False, True, False]) @@ -188,13 +188,13 @@ def allTests(communicator): test(mo5.fss[0] == Test.FixedStruct(78)) test(mo5.vss[0] == Test.VarStruct("hello")) test(mo5.oos[0].a == 15) - test(mo5.oops[0] == Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test"))) + test(mo5.oops[0] == communicator.stringToProxy("test")) test(mo5.ied[4] == Test.MyEnum.MyEnumMember) test(mo5.ifsd[4] == Test.FixedStruct(78)) test(mo5.ivsd[5] == Test.VarStruct("hello")) test(mo5.iood[5].a == 15) - test(mo5.ioopd[5] == Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test"))) + test(mo5.ioopd[5] == communicator.stringToProxy("test")) test(mo5.bos == mo1.bos) @@ -296,13 +296,13 @@ def allTests(communicator): test(mo9.fss is Ice.Unset) test(mo9.vss[0] == Test.VarStruct("hello")) test(mo9.oos is Ice.Unset) - test(mo9.oops[0] == Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test"))) + test(mo9.oops[0] == communicator.stringToProxy("test")) test(mo9.ied[4] == Test.MyEnum.MyEnumMember) test(mo9.ifsd is Ice.Unset) test(mo9.ivsd[5] == Test.VarStruct("hello")) test(mo9.iood is Ice.Unset) - test(mo9.ioopd[5] == Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test"))) + test(mo9.ioopd[5] == communicator.stringToProxy("test")) test(mo9.bos is Ice.Unset) @@ -564,7 +564,7 @@ def allTests(communicator): (p2, p3) = initial.opOneOptionalProxy(Ice.Unset) test(p2 is Ice.Unset and p3 is Ice.Unset) - p1 = Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test")) + p1 = communicator.stringToProxy("test") (p2, p3) = initial.opOneOptionalProxy(p1) test(p2 == p1 and p3 == p1) f = initial.opOneOptionalProxyAsync(p1) diff --git a/python/test/Ice/optional/Server.py b/python/test/Ice/optional/Server.py index 2db847e0b77..c9182ac46a7 100755 --- a/python/test/Ice/optional/Server.py +++ b/python/test/Ice/optional/Server.py @@ -14,7 +14,7 @@ import Ice Ice.loadSlice('Test.ice') import Test -class InitialI(Test.Initial): +class InitialI(Test._InitialDisp): def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() diff --git a/python/test/Ice/optional/ServerAMD.py b/python/test/Ice/optional/ServerAMD.py index d9cc9a9bb4a..65f84d2f269 100755 --- a/python/test/Ice/optional/ServerAMD.py +++ b/python/test/Ice/optional/ServerAMD.py @@ -14,7 +14,7 @@ import Ice Ice.loadSlice('TestAMD.ice') import Test -class InitialI(Test.Initial): +class InitialI(Test._InitialDisp): def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() diff --git a/python/test/Ice/proxy/ServerAMD.py b/python/test/Ice/proxy/ServerAMD.py index b2f71d6fcfa..00a109ef7db 100755 --- a/python/test/Ice/proxy/ServerAMD.py +++ b/python/test/Ice/proxy/ServerAMD.py @@ -19,7 +19,7 @@ if not slice_dir: Ice.loadSlice("'-I" + slice_dir + "' TestAMD.ice") import Test -class MyDerivedClassI(Test.MyDerivedClass): +class MyDerivedClassI(Test._MyDerivedClassDisp): def __init__(self): self.ctx = None @@ -34,7 +34,7 @@ class MyDerivedClassI(Test.MyDerivedClass): def ice_isA(self, s, current): self.ctx = current.ctx - return Test.MyDerivedClass.ice_isA(self, s, current) + return Test._MyDerivedClassDisp.ice_isA(self, s, current) def run(args, communicator): communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp") diff --git a/python/test/Ice/proxy/TestI.py b/python/test/Ice/proxy/TestI.py index 2f73e6e63c2..c446127850f 100644 --- a/python/test/Ice/proxy/TestI.py +++ b/python/test/Ice/proxy/TestI.py @@ -10,7 +10,7 @@ import Ice, Test import time -class MyDerivedClassI(Test.MyDerivedClass): +class MyDerivedClassI(Test._MyDerivedClassDisp): def __init__(self): self.ctx = None @@ -25,4 +25,4 @@ class MyDerivedClassI(Test.MyDerivedClass): def ice_isA(self, s, current): self.ctx = current.ctx - return Test.MyDerivedClass.ice_isA(self, s, current) + return Test._MyDerivedClassDisp.ice_isA(self, s, current) diff --git a/python/test/Ice/servantLocator/TestAMDI.py b/python/test/Ice/servantLocator/TestAMDI.py index 219ce7f3ebc..53346a683df 100644 --- a/python/test/Ice/servantLocator/TestAMDI.py +++ b/python/test/Ice/servantLocator/TestAMDI.py @@ -14,7 +14,7 @@ def test(b): if not b: raise RuntimeError('test assertion failed') -class TestI(Test.TestIntf): +class TestI(Test._TestIntfDisp): def requestFailedException(self, current=None): return None diff --git a/python/test/Ice/servantLocator/TestActivationAMDI.py b/python/test/Ice/servantLocator/TestActivationAMDI.py index d9e2bedc2d0..7b685d1cd1b 100644 --- a/python/test/Ice/servantLocator/TestActivationAMDI.py +++ b/python/test/Ice/servantLocator/TestActivationAMDI.py @@ -11,7 +11,7 @@ import os, sys, traceback, time import Ice, Test, TestAMDI -class TestActivationAMDI(Test.TestActivation): +class TestActivationAMDI(Test._TestActivationDisp): def activateServantLocator(self, activate, current=None): if(activate): diff --git a/python/test/Ice/servantLocator/TestActivationI.py b/python/test/Ice/servantLocator/TestActivationI.py index 357d0a47c2d..295fbcebd16 100644 --- a/python/test/Ice/servantLocator/TestActivationI.py +++ b/python/test/Ice/servantLocator/TestActivationI.py @@ -11,7 +11,7 @@ import os, sys, traceback, time import Ice, Test, TestI -class TestActivationI(Test.TestActivation): +class TestActivationI(Test._TestActivationDisp): def activateServantLocator(self, activate, current=None): if activate: diff --git a/python/test/Ice/servantLocator/TestI.py b/python/test/Ice/servantLocator/TestI.py index b486be66982..f7743c370d1 100644 --- a/python/test/Ice/servantLocator/TestI.py +++ b/python/test/Ice/servantLocator/TestI.py @@ -14,7 +14,7 @@ def test(b): if not b: raise RuntimeError('test assertion failed') -class TestI(Test.TestIntf): +class TestI(Test._TestIntfDisp): def requestFailedException(self, current=None): pass diff --git a/python/test/Ice/slicing/exceptions/AllTests.py b/python/test/Ice/slicing/exceptions/AllTests.py index 5419f08e33e..abdd2c6a761 100644 --- a/python/test/Ice/slicing/exceptions/AllTests.py +++ b/python/test/Ice/slicing/exceptions/AllTests.py @@ -189,7 +189,7 @@ class Callback(CallbackBase): test(False) self.called() -class RelayI(Test.Relay): +class RelayI(Test._RelayDisp): def knownPreservedAsBase(self, current=None): ex = Test.KnownPreservedDerived() ex.b = "base" diff --git a/python/test/Ice/slicing/exceptions/Server.py b/python/test/Ice/slicing/exceptions/Server.py index 29834507e62..d77acfcccca 100755 --- a/python/test/Ice/slicing/exceptions/Server.py +++ b/python/test/Ice/slicing/exceptions/Server.py @@ -13,7 +13,7 @@ import Ice Ice.loadSlice('-I. --all ServerPrivate.ice') import Test -class TestI(Test.TestIntf): +class TestI(Test._TestIntfDisp): def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() diff --git a/python/test/Ice/slicing/exceptions/ServerAMD.py b/python/test/Ice/slicing/exceptions/ServerAMD.py index 6be6fbe5c03..8e821636a60 100755 --- a/python/test/Ice/slicing/exceptions/ServerAMD.py +++ b/python/test/Ice/slicing/exceptions/ServerAMD.py @@ -14,7 +14,7 @@ import Ice Ice.loadSlice('-I. --all ServerPrivateAMD.ice') import Test -class TestI(Test.TestIntf): +class TestI(Test._TestIntfDisp): def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() diff --git a/python/test/Ice/slicing/objects/AllTests.py b/python/test/Ice/slicing/objects/AllTests.py index cc3a321d5fd..5fdc14ed197 100644 --- a/python/test/Ice/slicing/objects/AllTests.py +++ b/python/test/Ice/slicing/objects/AllTests.py @@ -76,7 +76,7 @@ class Callback(CallbackBase): def response_SUnknownAsObject11(self, f): o = f.result() - test(isinstance(o, Ice.UnknownSlicedObject)) + test(isinstance(o, Ice.UnknownSlicedValue)) test(o.unknownTypeId == "::Test::SUnknown") self.called() @@ -532,7 +532,7 @@ def allTests(communicator): try: o = t.SUnknownAsObject() test(t.ice_getEncodingVersion() != Ice.Encoding_1_0) - test(isinstance(o, Ice.UnknownSlicedObject)) + test(isinstance(o, Ice.UnknownSlicedValue)) test(o.unknownTypeId == "::Test::SUnknown") t.checkSUnknown(o) except Ice.NoValueFactoryException: diff --git a/python/test/Ice/slicing/objects/Server.py b/python/test/Ice/slicing/objects/Server.py index 909e836bff4..a8048d2bf8d 100755 --- a/python/test/Ice/slicing/objects/Server.py +++ b/python/test/Ice/slicing/objects/Server.py @@ -18,7 +18,7 @@ def test(b): if not b: raise RuntimeError('test assertion failed') -class TestI(Test.TestIntf): +class TestI(Test._TestIntfDisp): def SBaseAsObject(self, current=None): sb = Test.SBase() sb.sb = "SBase.sb" diff --git a/python/test/Ice/slicing/objects/ServerAMD.py b/python/test/Ice/slicing/objects/ServerAMD.py index db617dd50e1..1f925613b6b 100755 --- a/python/test/Ice/slicing/objects/ServerAMD.py +++ b/python/test/Ice/slicing/objects/ServerAMD.py @@ -18,7 +18,7 @@ def test(b): if not b: raise RuntimeError('test assertion failed') -class TestI(Test.TestIntf): +class TestI(Test._TestIntfDisp): def SBaseAsObject(self, current=None): sb = Test.SBase() sb.sb = "SBase.sb" diff --git a/python/test/Ice/timeout/Server.py b/python/test/Ice/timeout/Server.py index 4db8d04b78f..d607016e64e 100755 --- a/python/test/Ice/timeout/Server.py +++ b/python/test/Ice/timeout/Server.py @@ -29,7 +29,7 @@ class ActivateAdapterThread(threading.Thread): time.sleep(self._timeout / 1000.0) self._adapter.activate() -class TimeoutI(Test.Timeout): +class TimeoutI(Test._TimeoutDisp): def op(self, current=None): pass diff --git a/python/test/Slice/escape/Client.py b/python/test/Slice/escape/Client.py index e3da840e300..6305365602a 100755 --- a/python/test/Slice/escape/Client.py +++ b/python/test/Slice/escape/Client.py @@ -24,19 +24,19 @@ Ice.loadSlice('Clash.ice') import _and -class delI(_and._del): +class delI(_and._delDisp): def _elifAsync(self, _else, current=None): pass -class execI(_and._exec): +class execI(_and._execDisp): def _finally(self, current=None): assert current.operation == "finally" -class forI(_and._for): +class forI(_and._forDisp): def foo(self, _from, current=None): pass -class ifI(_and._if): +class ifI(_and._ifDisp): def _elifAsync(self, _else, current=None): pass def _finally(self, current=None): |