summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2011-05-04 17:51:35 -0700
committerMark Spruiell <mes@zeroc.com>2011-05-04 17:51:35 -0700
commit9afd50c19bceeb2be64bf0c7c6d7a0c2c126dde8 (patch)
tree44786ffd2f2bf17f6872f97ea109cb09243d9cf9 /py
parentminor doc fixes for RHEL (diff)
downloadice-9afd50c19bceeb2be64bf0c7c6d7a0c2c126dde8.tar.bz2
ice-9afd50c19bceeb2be64bf0c7c6d7a0c2c126dde8.tar.xz
ice-9afd50c19bceeb2be64bf0c7c6d7a0c2c126dde8.zip
bug 4976 - inconsistent operation mode for pseudo ops
Diffstat (limited to 'py')
-rw-r--r--py/modules/IcePy/Operation.cpp14
-rw-r--r--py/python/Ice.py4
-rw-r--r--py/test/Ice/operations/Oneways.py15
-rw-r--r--py/test/Ice/operations/OnewaysAMI.py26
-rw-r--r--py/test/Ice/operations/OnewaysNewAMI.py8
-rwxr-xr-xpy/test/Ice/operations/ServerAMD.py24
-rw-r--r--py/test/Ice/operations/Test.ice4
-rw-r--r--py/test/Ice/operations/TestAMD.ice4
-rw-r--r--py/test/Ice/operations/TestI.py22
-rw-r--r--py/test/Ice/operations/Twoways.py33
-rw-r--r--py/test/Ice/operations/TwowaysAMI.py34
-rw-r--r--py/test/Ice/operations/TwowaysNewAMI.py16
12 files changed, 200 insertions, 4 deletions
diff --git a/py/modules/IcePy/Operation.cpp b/py/modules/IcePy/Operation.cpp
index 71a081e6e7c..c787f53c9e3 100644
--- a/py/modules/IcePy/Operation.cpp
+++ b/py/modules/IcePy/Operation.cpp
@@ -71,6 +71,7 @@ public:
string dispatchName;
bool sendsClasses;
bool returnsClasses;
+ bool pseudoOp;
private:
@@ -1055,6 +1056,11 @@ IcePy::Operation::Operation(const char* n, PyObject* m, PyObject* sm, int amdFla
{
exceptions.push_back(getException(PyTuple_GET_ITEM(ex, i)));
}
+
+ //
+ // Does the operation name start with "ice_"?
+ //
+ pseudoOp = name.find("ice_") == 0;
}
void
@@ -3695,7 +3701,13 @@ IcePy::TypedServantWrapper::ice_invoke_async(const Ice::AMD_Object_ice_invokePtr
}
}
- __checkMode(op->mode, current.mode);
+ //
+ // See bug 4976.
+ //
+ if(!op->pseudoOp)
+ {
+ __checkMode(op->mode, current.mode);
+ }
UpcallPtr up = new TypedUpcall(op, cb, current.adapter->getCommunicator());
up->dispatch(_servant, inParams, current);
diff --git a/py/python/Ice.py b/py/python/Ice.py
index b60dbba31e6..bfe2b58a988 100644
--- a/py/python/Ice.py
+++ b/py/python/Ice.py
@@ -81,7 +81,7 @@ Arguments:
Returns:
True if the target object supports the interface, or false otherwise.
'''
- return id in self.ice_ids()
+ return id in self.ice_ids(current)
def ice_ping(self, current=None):
'''A reachability test for the target object.'''
@@ -93,7 +93,7 @@ that are supported by the target object.
Returns:
A list of type ids.
'''
- return [ self.ice_id() ]
+ return [ self.ice_id(current) ]
def ice_id(self, current=None):
'''Obtains the type id corresponding to the most-derived Slice
diff --git a/py/test/Ice/operations/Oneways.py b/py/test/Ice/operations/Oneways.py
index aa8a1e41efc..05a9b45c679 100644
--- a/py/test/Ice/operations/Oneways.py
+++ b/py/test/Ice/operations/Oneways.py
@@ -18,11 +18,26 @@ def oneways(communicator, p):
p = Test.MyClassPrx.uncheckedCast(p.ice_oneway())
#
+ # ice_ping
+ #
+ p.ice_ping()
+
+ #
# opVoid
#
p.opVoid()
#
+ # opIdempotent
+ #
+ p.opIdempotent()
+
+ #
+ # opNonmutating
+ #
+ p.opNonmutating()
+
+ #
# opByte
#
try:
diff --git a/py/test/Ice/operations/OnewaysAMI.py b/py/test/Ice/operations/OnewaysAMI.py
index ceeb1d7c192..f29115a2f48 100644
--- a/py/test/Ice/operations/OnewaysAMI.py
+++ b/py/test/Ice/operations/OnewaysAMI.py
@@ -43,6 +43,26 @@ class AMI_MyClass_opVoidI(CallbackBase):
def ice_exception(self, ex):
test(False)
+class AMI_MyClass_opIdempotentI(CallbackBase):
+ def __init__(self):
+ CallbackBase.__init__(self)
+
+ def ice_response(self):
+ self.called()
+
+ def ice_exception(self, ex):
+ test(False)
+
+class AMI_MyClass_opNonmutatingI(CallbackBase):
+ def __init__(self):
+ CallbackBase.__init__(self)
+
+ def ice_response(self):
+ self.called()
+
+ def ice_exception(self, ex):
+ test(False)
+
class AMI_MyClass_opVoidExI(CallbackBase):
def __init__(self):
CallbackBase.__init__(self)
@@ -74,6 +94,12 @@ def onewaysAMI(communicator, p):
# Let's check if we can reuse the same callback object for another call.
p.opVoid_async(cb)
+ cb = AMI_MyClass_opIdempotentI()
+ p.opIdempotent_async(cb)
+
+ cb = AMI_MyClass_opNonmutatingI()
+ p.opNonmutating_async(cb)
+
# Check that a call to a void operation raises NoEndpointException
# in the ice_exception() callback instead of at the point of call.
indirect = Test.MyClassPrx.uncheckedCast(p.ice_adapterId("dummy"))
diff --git a/py/test/Ice/operations/OnewaysNewAMI.py b/py/test/Ice/operations/OnewaysNewAMI.py
index 89c9672fae7..54cd0b918a4 100644
--- a/py/test/Ice/operations/OnewaysNewAMI.py
+++ b/py/test/Ice/operations/OnewaysNewAMI.py
@@ -70,6 +70,14 @@ def onewaysNewAMI(communicator, proxy):
p.begin_opVoid(None, cb.noException, cb.sent)
cb.check()
+ cb = Callback()
+ p.begin_opIdempotent(None, cb.noException, cb.sent)
+ cb.check()
+
+ cb = Callback()
+ p.begin_opNonmutating(None, cb.noException, cb.sent)
+ cb.check()
+
try:
p.begin_opByte(0xff, 0x0f)
test(False)
diff --git a/py/test/Ice/operations/ServerAMD.py b/py/test/Ice/operations/ServerAMD.py
index ad430a75ed6..75c8dcebc9c 100755
--- a/py/test/Ice/operations/ServerAMD.py
+++ b/py/test/Ice/operations/ServerAMD.py
@@ -36,6 +36,22 @@ class MyDerivedClassI(Test.MyDerivedClass):
self.opVoidThread = None
self.opVoidThreadLock = threading.Lock()
+ def ice_isA(self, id, current=None):
+ test(current.mode == Ice.OperationMode.Nonmutating)
+ return Test.MyDerivedClass.ice_isA(self, id, current)
+
+ def ice_ping(self, current=None):
+ test(current.mode == Ice.OperationMode.Nonmutating)
+ Test.MyDerivedClass.ice_ping(self, current)
+
+ def ice_ids(self, current=None):
+ test(current.mode == Ice.OperationMode.Nonmutating)
+ return Test.MyDerivedClass.ice_ids(self, current)
+
+ def ice_id(self, current=None):
+ test(current.mode == Ice.OperationMode.Nonmutating)
+ return Test.MyDerivedClass.ice_id(self, current)
+
def shutdown_async(self, cb, current=None):
self.opVoidThreadLock.acquire()
if self.opVoidThread:
@@ -223,6 +239,14 @@ class MyDerivedClassI(Test.MyDerivedClass):
def opContext_async(self, cb, current=None):
cb.ice_response(current.ctx)
+ def opIdempotent_async(self, cb, current=None):
+ test(current.mode == Ice.OperationMode.Idempotent)
+ cb.ice_response()
+
+ def opNonmutating_async(self, cb, current=None):
+ test(current.mode == Ice.OperationMode.Nonmutating)
+ cb.ice_response()
+
def opDerived_async(self, cb, current=None):
cb.ice_response()
diff --git a/py/test/Ice/operations/Test.ice b/py/test/Ice/operations/Test.ice
index 936db9da713..9268458857e 100644
--- a/py/test/Ice/operations/Test.ice
+++ b/py/test/Ice/operations/Test.ice
@@ -164,6 +164,10 @@ dictionary<MyStruct, MyEnum> MyStructMyEnumD;
Ice::Context opContext();
void opDoubleMarshaling(double p1, DoubleS p2);
+
+ idempotent void opIdempotent();
+
+ ["nonmutating"] idempotent void opNonmutating();
};
["ami"] class MyDerivedClass extends MyClass
diff --git a/py/test/Ice/operations/TestAMD.ice b/py/test/Ice/operations/TestAMD.ice
index 9d90bec0cd8..c21a82381c8 100644
--- a/py/test/Ice/operations/TestAMD.ice
+++ b/py/test/Ice/operations/TestAMD.ice
@@ -162,6 +162,10 @@ dictionary<MyStruct, MyEnum> MyStructMyEnumD;
StringStringD opContext();
void opDoubleMarshaling(double p1, DoubleS p2);
+
+ idempotent void opIdempotent();
+
+ ["nonmutating"] idempotent void opNonmutating();
};
["ami", "amd"] class MyDerivedClass extends MyClass
diff --git a/py/test/Ice/operations/TestI.py b/py/test/Ice/operations/TestI.py
index 29ad24ce266..1ac8d24e89b 100644
--- a/py/test/Ice/operations/TestI.py
+++ b/py/test/Ice/operations/TestI.py
@@ -14,6 +14,22 @@ def test(b):
raise RuntimeError('test assertion failed')
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)
+
+ def ice_ping(self, current=None):
+ test(current.mode == Ice.OperationMode.Nonmutating)
+ Test.MyDerivedClass.ice_ping(self, current)
+
+ def ice_ids(self, current=None):
+ test(current.mode == Ice.OperationMode.Nonmutating)
+ return Test.MyDerivedClass.ice_ids(self, current)
+
+ def ice_id(self, current=None):
+ test(current.mode == Ice.OperationMode.Nonmutating)
+ return Test.MyDerivedClass.ice_id(self, current)
+
def shutdown(self, current=None):
current.adapter.getCommunicator().shutdown()
@@ -185,5 +201,11 @@ class MyDerivedClassI(Test.MyDerivedClass):
for i in p2:
test(i == d)
+ def opIdempotent(self, current=None):
+ test(current.mode == Ice.OperationMode.Idempotent)
+
+ def opNonmutating(self, current=None):
+ test(current.mode == Ice.OperationMode.Nonmutating)
+
def opDerived(self, current=None):
pass
diff --git a/py/test/Ice/operations/Twoways.py b/py/test/Ice/operations/Twoways.py
index c895841c17b..9f0e2c871c7 100644
--- a/py/test/Ice/operations/Twoways.py
+++ b/py/test/Ice/operations/Twoways.py
@@ -15,6 +15,30 @@ def test(b):
def twoways(communicator, p):
#
+ # ice_ping
+ #
+ p.ice_ping()
+
+ #
+ # ice_isA
+ #
+ test(p.ice_isA(Test.MyClass.ice_staticId()))
+
+ #
+ # ice_ids
+ #
+ ids = p.ice_ids()
+ test(len(ids) == 3)
+ test(ids[0] == "::Ice::Object")
+ test(ids[1] == "::Test::MyClass")
+ test(ids[2] == "::Test::MyDerivedClass")
+
+ #
+ # ice_id
+ #
+ test(p.ice_id() == Test.MyDerivedClass.ice_staticId())
+
+ #
# opVoid
#
p.opVoid()
@@ -650,3 +674,12 @@ def twoways(communicator, p):
ds.append(d);
p.opDoubleMarshaling(d, ds);
+ #
+ # opIdempotent
+ #
+ p.opIdempotent()
+
+ #
+ # opNonmutating
+ #
+ p.opNonmutating()
diff --git a/py/test/Ice/operations/TwowaysAMI.py b/py/test/Ice/operations/TwowaysAMI.py
index 23792521a1e..d98f8876bb5 100644
--- a/py/test/Ice/operations/TwowaysAMI.py
+++ b/py/test/Ice/operations/TwowaysAMI.py
@@ -551,6 +551,26 @@ class AMI_MyClass_opContextNotEqualI(CallbackBase):
def ice_exception(self, ex):
test(False)
+class AMI_MyClass_opIdempotentI(CallbackBase):
+ def __init__(self):
+ CallbackBase.__init__(self)
+
+ def ice_response(self):
+ self.called()
+
+ def ice_exception(self, ex):
+ test(False)
+
+class AMI_MyClass_opNonmutatingI(CallbackBase):
+ def __init__(self):
+ CallbackBase.__init__(self)
+
+ def ice_response(self):
+ self.called()
+
+ def ice_exception(self, ex):
+ test(False)
+
class AMI_MyDerivedClass_opDerivedI(CallbackBase):
def __init__(self):
CallbackBase.__init__(self)
@@ -929,6 +949,20 @@ def twowaysAMI(communicator, p):
ic.destroy()
+ #
+ # opIdempotent
+ #
+ cb = AMI_MyClass_opIdempotentI()
+ p.opIdempotent_async(cb)
+ cb.check()
+
+ #
+ # opNonmutating
+ #
+ cb = AMI_MyClass_opNonmutatingI()
+ p.opNonmutating_async(cb)
+ cb.check()
+
derived = Test.MyDerivedClassPrx.checkedCast(p)
test(derived)
cb = AMI_MyDerivedClass_opDerivedI()
diff --git a/py/test/Ice/operations/TwowaysNewAMI.py b/py/test/Ice/operations/TwowaysNewAMI.py
index 1ba06674086..635e0fb053f 100644
--- a/py/test/Ice/operations/TwowaysNewAMI.py
+++ b/py/test/Ice/operations/TwowaysNewAMI.py
@@ -345,6 +345,12 @@ class Callback(CallbackBase):
test(r[j] == -j)
self.called()
+ def opIdempotent(self):
+ self.called()
+
+ def opNonmutating(self):
+ self.called()
+
def opDerived(self):
self.called()
@@ -357,7 +363,7 @@ def twowaysNewAMI(communicator, p):
cb.check()
cb = Callback()
- p.begin_ice_isA("::Test::MyClass", cb.isA, cb.exCB)
+ p.begin_ice_isA(Test.MyClass.ice_staticId(), cb.isA, cb.exCB)
cb.check()
cb = Callback()
@@ -619,6 +625,14 @@ def twowaysNewAMI(communicator, p):
ic.destroy()
+ cb = Callback()
+ p.begin_opIdempotent(cb.opIdempotent, cb.exCB)
+ cb.check()
+
+ cb = Callback()
+ p.begin_opNonmutating(cb.opNonmutating, cb.exCB)
+ cb.check()
+
derived = Test.MyDerivedClassPrx.checkedCast(p)
test(derived)
cb = Callback()