diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/slice2js/Gen.cpp | 81 | ||||
-rw-r--r-- | cpp/src/slice2js/JsUtil.cpp | 16 |
2 files changed, 65 insertions, 32 deletions
diff --git a/cpp/src/slice2js/Gen.cpp b/cpp/src/slice2js/Gen.cpp index 6486624e44a..29c1c9f47dc 100644 --- a/cpp/src/slice2js/Gen.cpp +++ b/cpp/src/slice2js/Gen.cpp @@ -1128,49 +1128,60 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) _out << eb; } _out << eb << ";"; - - const string baseProxy = - !p->isInterface() && base ? (getLocalScope(base->scope()) + "." + base->name() + "Prx") : "Ice.ObjectPrx"; - - _out << sp; - _out << nl << localScope << '.' << prxName << " = class extends " << baseProxy; - _out << sb; - - - if(!bases.empty()) + + // + // Generate a proxy class for interfaces or classes with operations. + // + string proxyType = "undefined"; + if(p->isInterface() || p->allOperations().size() > 0) { + proxyType = localScope + '.' + prxName; + string baseProxy = "Ice.ObjectPrx"; + if(!p->isInterface() && base && base->allOperations().size() > 0) + { + baseProxy = (getLocalScope(base->scope()) + "." + base->name() + "Prx"); + } + _out << sp; - _out << nl << "static get _implements()"; + _out << nl << proxyType << " = class extends " << baseProxy; _out << sb; - _out << nl << "return ["; - - _out.inc(); - for(ClassList::const_iterator q = bases.begin(); q != bases.end();) + + + if(!bases.empty()) { - ClassDefPtr base = *q; - if(base->isInterface()) + _out << sp; + _out << nl << "static get _implements()"; + _out << sb; + _out << nl << "return ["; + + _out.inc(); + for(ClassList::const_iterator q = bases.begin(); q != bases.end();) { - _out << nl << getLocalScope(base->scope()) << "." << base->name() << "Prx"; - if(++q != bases.end()) + ClassDefPtr base = *q; + if(base->isInterface()) { - _out << ", "; + _out << nl << getLocalScope(base->scope()) << "." << base->name() << "Prx"; + if(++q != bases.end()) + { + _out << ", "; + } + } + else + { + q++; } } - else - { - q++; - } + _out.dec(); + _out << "];"; + _out << eb; } - _out.dec(); - _out << "];"; - _out << eb; - } - _out << eb << ";"; + _out << eb << ";"; + } _out << sp << nl << "Slice.defineOperations(" << localScope << "._" << p->name() << "Disp, " - << localScope << '.' << prxName << ", " + << proxyType << ", " << "iceC_" << getLocalScope(scoped, "_") << "_ids, " << scopedPos; @@ -1783,7 +1794,15 @@ Slice::Gen::TypesVisitor::encodeTypeForOperation(const TypePtr& type) ProxyPtr proxy = ProxyPtr::dynamicCast(type); if(proxy) { - return "\"" + fixId(proxy->_class()->scoped() + "Prx") + "\""; + ClassDefPtr def = proxy->_class()->definition(); + if(def->isInterface() || def->allOperations().size() > 0) + { + return "\"" + fixId(proxy->_class()->scoped() + "Prx") + "\""; + } + else + { + return "Ice.ObjectPrx"; + } } SequencePtr seq = SequencePtr::dynamicCast(type); diff --git a/cpp/src/slice2js/JsUtil.cpp b/cpp/src/slice2js/JsUtil.cpp index 8046c115102..674644873d4 100644 --- a/cpp/src/slice2js/JsUtil.cpp +++ b/cpp/src/slice2js/JsUtil.cpp @@ -574,10 +574,24 @@ Slice::JsGenerator::getHelper(const TypePtr& type) return typeToString(type) + "._helper"; } - if(ProxyPtr::dynamicCast(type) || StructPtr::dynamicCast(type)) + if(StructPtr::dynamicCast(type)) { return typeToString(type); } + + ProxyPtr prx = ProxyPtr::dynamicCast(type); + if(prx) + { + ClassDefPtr def = prx->_class()->definition(); + if(def->isInterface() || def->allOperations().size() > 0) + { + return typeToString(type); + } + else + { + return "Ice.ObjectPrx"; + } + } if(SequencePtr::dynamicCast(type) || DictionaryPtr::dynamicCast(type)) { |