summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/Proxy.cpp20
-rw-r--r--cpp/src/Slice/Parser.cpp23
-rw-r--r--cpp/src/slice2cpp/Gen.cpp8
-rw-r--r--cpp/src/slice2java/Gen.cpp8
4 files changed, 59 insertions, 0 deletions
diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp
index 780cff5e38c..bf8ba20d935 100644
--- a/cpp/src/Ice/Proxy.cpp
+++ b/cpp/src/Ice/Proxy.cpp
@@ -54,6 +54,10 @@ void IceInternal::decRef(::IceDelegateD::Ice::Object* p) { p->__decRef(); }
void
IceInternal::checkedCast(const ObjectPrx& b, ObjectPrx& d)
{
+ if(b)
+ {
+ b->__checkTwowayOnly("checkedCast");
+ }
d = b;
}
@@ -134,6 +138,7 @@ IceProxy::Ice::Object::ice_isA(const string& __id, const Context& __context)
{
try
{
+ __checkTwowayOnly("ice_isA");
Handle< ::IceDelegate::Ice::Object> __del = __getDelegate();
return __del->ice_isA(__id, __context);
}
@@ -162,6 +167,7 @@ IceProxy::Ice::Object::ice_ping(const Context& __context)
{
try
{
+ __checkTwowayOnly("ice_ping");
Handle< ::IceDelegate::Ice::Object> __del = __getDelegate();
__del->ice_ping(__context);
return;
@@ -191,6 +197,7 @@ IceProxy::Ice::Object::ice_ids(const Context& __context)
{
try
{
+ __checkTwowayOnly("ice_ids");
Handle< ::IceDelegate::Ice::Object> __del = __getDelegate();
return __del->ice_ids(__context);
}
@@ -219,6 +226,7 @@ IceProxy::Ice::Object::ice_id(const Context& __context)
{
try
{
+ __checkTwowayOnly("ice_id");
Handle< ::IceDelegate::Ice::Object> __del = __getDelegate();
return __del->ice_id(__context);
}
@@ -247,6 +255,7 @@ IceProxy::Ice::Object::ice_facets(const Context& __context)
{
try
{
+ __checkTwowayOnly("ice_facets");
Handle< ::IceDelegate::Ice::Object> __del = __getDelegate();
return __del->ice_facets(__context);
}
@@ -758,6 +767,17 @@ IceProxy::Ice::Object::__rethrowException(const LocalException& ex)
ex.ice_throw();
}
+void
+IceProxy::Ice::Object::__checkTwowayOnly(const char* name) const
+{
+ if(!ice_isTwoway())
+ {
+ TwowayOnlyException ex(__FILE__, __LINE__);
+ ex.operation = name;
+ throw ex;
+ }
+}
+
Handle< ::IceDelegate::Ice::Object>
IceProxy::Ice::Object::__getDelegate()
{
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp
index 312d8ff62c8..5b99481a082 100644
--- a/cpp/src/Slice/Parser.cpp
+++ b/cpp/src/Slice/Parser.cpp
@@ -3739,6 +3739,29 @@ Slice::Operation::returnsClasses() const
return false;
}
+bool
+Slice::Operation::returnsData() const
+{
+ TypePtr t = returnType();
+ if(t)
+ {
+ return true;
+ }
+ ParamDeclList pdl = parameters();
+ for(ParamDeclList::const_iterator i = pdl.begin(); i != pdl.end(); ++i)
+ {
+ if((*i)->isOutParam())
+ {
+ return true;
+ }
+ }
+ if(!throws().empty())
+ {
+ return true;
+ }
+ return false;
+}
+
string
Slice::Operation::kindOf() const
{
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 7ec8e902650..994c62dc707 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -1395,6 +1395,10 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
C << sb;
C << nl << "try";
C << sb;
+ if(p->returnsData())
+ {
+ C << "__checkTwowayOnly(\"" << p->name() << "\");";
+ }
C << nl << "::IceInternal::Handle< ::IceDelegate::Ice::Object> __delBase = __getDelegate();";
C << nl << "::IceDelegate" << thisPointer << " __del = dynamic_cast< ::IceDelegate"
<< thisPointer << ">(__delBase.get());";
@@ -1452,6 +1456,10 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
C << sb;
C << nl << "try";
C << sb;
+ if(p->returnsData())
+ {
+ C << "__checkTwowayOnly(\"" << p->name() << "\");";
+ }
C << nl << "::IceInternal::Handle< ::IceDelegate::Ice::Object> __delBase = __getDelegate();";
C << nl << "::IceDelegate" << thisPointer << " __del = dynamic_cast< ::IceDelegate"
<< thisPointer << ">(__delBase.get());";
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index 6698c948f9c..916b1cc635e 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -2403,6 +2403,10 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
out << sb;
out << nl << "try";
out << sb;
+ if(op->returnsData())
+ {
+ out << "__checkTwowayOnly(\"" << opName << "\");";
+ }
out << nl << "Ice._ObjectDel __delBase = __getDelegate();";
out << nl << '_' << name << "Del __del = (_" << name << "Del)__delBase;";
out << nl;
@@ -2462,6 +2466,10 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
out << sb;
out << nl << "try";
out << sb;
+ if(op->returnsData())
+ {
+ out << "__checkTwowayOnly(\"" << opName << "\");";
+ }
out << nl << "Ice._ObjectDel __delBase = __getDelegate();";
out << nl << '_' << name << "Del __del = (_" << name
<< "Del)__delBase;";