summaryrefslogtreecommitdiff
path: root/cpp/src/slice2js
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2017-01-24 10:33:49 +0100
committerJose <jose@zeroc.com>2017-01-24 10:33:49 +0100
commit4a4250603b046265e23869937f30a72d8396fe88 (patch)
treef26243fa9b7add3cb1fe252db75d9a602d6144ef /cpp/src/slice2js
parentDo not add abstract methods to PHP Value classes (diff)
downloadice-4a4250603b046265e23869937f30a72d8396fe88.tar.bz2
ice-4a4250603b046265e23869937f30a72d8396fe88.tar.xz
ice-4a4250603b046265e23869937f30a72d8396fe88.zip
JavaScript: Do not generate proxy types for class less operations
Diffstat (limited to 'cpp/src/slice2js')
-rw-r--r--cpp/src/slice2js/Gen.cpp81
-rw-r--r--cpp/src/slice2js/JsUtil.cpp16
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))
{