summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2014-07-23 16:49:37 -0700
committerMark Spruiell <mes@zeroc.com>2014-07-23 16:49:37 -0700
commit771644c88e34713961ae998ddac507553af5cddb (patch)
tree95f404c423571069b9f790e0f7e70b681677c777
parentMerge branch 'master' of ssh://git.zeroc.com/home/git/ice (diff)
downloadice-771644c88e34713961ae998ddac507553af5cddb.tar.bz2
ice-771644c88e34713961ae998ddac507553af5cddb.tar.xz
ice-771644c88e34713961ae998ddac507553af5cddb.zip
ICE-5515 - proxy support for ice_staticId
-rw-r--r--cpp/src/slice2php/Main.cpp10
-rw-r--r--php/lib/Ice.php18
-rw-r--r--php/lib/Ice_ns.php18
-rw-r--r--php/test/Ice/facets/Client.php45
-rw-r--r--php/test/Ice/operations/Client.php15
-rw-r--r--py/modules/IcePy/Proxy.cpp11
-rw-r--r--py/test/Ice/operations/Twoways.py4
-rw-r--r--rb/src/IceRuby/Proxy.cpp14
-rw-r--r--rb/test/Ice/facets/AllTests.rb38
-rw-r--r--rb/test/Ice/operations/Twoways.rb4
10 files changed, 162 insertions, 15 deletions
diff --git a/cpp/src/slice2php/Main.cpp b/cpp/src/slice2php/Main.cpp
index 5cd4afc6a5c..5e6a98becad 100644
--- a/cpp/src/slice2php/Main.cpp
+++ b/cpp/src/slice2php/Main.cpp
@@ -186,7 +186,14 @@ CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << sp << nl << "if(!interface_exists('" << escapeName(abs) << "'))";
_out << sb;
_out << nl << "interface " << name;
- if(!bases.empty())
+ if(bases.empty())
+ {
+ if(!p->isLocal())
+ {
+ _out << " extends " << scopedToName("::Ice::Object", _ns);
+ }
+ }
+ else
{
_out << " extends ";
for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
@@ -213,6 +220,7 @@ CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
}
_out << ");";
}
+
_out << eb;
}
else
diff --git a/php/lib/Ice.php b/php/lib/Ice.php
index 3bbc3070631..37447a61935 100644
--- a/php/lib/Ice.php
+++ b/php/lib/Ice.php
@@ -87,6 +87,24 @@ abstract class Ice_ObjectImpl implements Ice_Object
}
}
+class Ice_ObjectPrxHelper
+{
+ public static function checkedCast($proxy, $facetOrCtx=null, $ctx=null)
+ {
+ return $proxy->ice_checkedCast('::Ice::Object', $facetOrCtx, $ctx);
+ }
+
+ public static function uncheckedCast($proxy, $facet=null)
+ {
+ return $proxy->ice_uncheckedCast('::Ice::Object', $facet);
+ }
+
+ public static function ice_staticId()
+ {
+ return '::Ice::Object';
+ }
+}
+
$Ice__t_Object = IcePHP_defineClass('::Ice::Object', "Ice_Object", -1, true, false, null, null, null);
$Ice__t_ObjectSeq = IcePHP_defineSequence('::Ice::ObjectSeq', $Ice__t_Object);
$Ice__t_LocalObject = IcePHP_defineClass('::Ice::LocalObject', "Ice_LocalObject", -1, true, false, null, null, null);
diff --git a/php/lib/Ice_ns.php b/php/lib/Ice_ns.php
index 77caad431af..6218cbf1c45 100644
--- a/php/lib/Ice_ns.php
+++ b/php/lib/Ice_ns.php
@@ -92,6 +92,24 @@ namespace Ice
}
}
+ class ObjectPrxHelper
+ {
+ public static function checkedCast($proxy, $facetOrCtx=null, $ctx=null)
+ {
+ return $proxy->ice_checkedCast('::Ice::Object', $facetOrCtx, $ctx);
+ }
+
+ public static function uncheckedCast($proxy, $facet=null)
+ {
+ return $proxy->ice_uncheckedCast('::Ice::Object', $facet);
+ }
+
+ public static function ice_staticId()
+ {
+ return '::Ice::Object';
+ }
+ }
+
$Ice__t_Object = IcePHP_defineClass('::Ice::Object', "\\Ice\\Object", -1, true, false, null, null, null);
$Ice__t_ObjectSeq = IcePHP_defineSequence('::Ice::ObjectSeq', $Ice__t_Object);
$Ice__t_LocalObject = IcePHP_defineClass('::Ice::LocalObject', "\\Ice\\LocalObject", -1, true, false, null, null, null);
diff --git a/php/test/Ice/facets/Client.php b/php/test/Ice/facets/Client.php
index cacfcd3f048..431736ee751 100644
--- a/php/test/Ice/facets/Client.php
+++ b/php/test/Ice/facets/Client.php
@@ -31,6 +31,8 @@ function test($b)
function allTests($communicator)
{
+ global $NS;
+
echo "testing stringToProxy... ";
flush();
$ref = "d:default -p 12010";
@@ -38,12 +40,47 @@ function allTests($communicator)
test($db != null);
echo "ok\n";
+ $objectHelper = $NS ? "Ice\\ObjectPrxHelper" : "Ice_ObjectPrxHelper";
+ $dHelper = $NS ? "Test\\DPrxHelper" : "Test_DPrxHelper";
+
+ echo "testing unchecked cast... ";
+ flush();
+ $prx = $objectHelper::uncheckedCast($db);
+ test($prx->ice_getFacet() == "");
+ $prx = $objectHelper::uncheckedCast($db, "facetABCD");
+ test($prx->ice_getFacet() == "facetABCD");
+ $prx2 = $objectHelper::uncheckedCast($prx);
+ test($prx2->ice_getFacet() == "facetABCD");
+ $prx3 = $objectHelper::uncheckedCast($prx, "");
+ test($prx3->ice_getFacet() == "");
+ $d = $dHelper::uncheckedCast($db);
+ test($d->ice_getFacet() == "");
+ $df = $dHelper::uncheckedCast($db, "facetABCD");
+ test($df->ice_getFacet() == "facetABCD");
+ $df2 = $dHelper::uncheckedCast($df);
+ test($df2->ice_getFacet() == "facetABCD");
+ $df3 = $dHelper::uncheckedCast($df, "");
+ test($df3->ice_getFacet() == "");
+ echo "ok\n";
+
echo "testing checked cast... ";
flush();
- $d = $db->ice_checkedCast("::Test::D");
- test($d != null);
- test($d == $db);
- test($db->ice_checkedCast("::Test::D", "bogus") == null);
+ $prx = $objectHelper::checkedCast($db);
+ test($prx->ice_getFacet() == "");
+ $prx = $objectHelper::checkedCast($db, "facetABCD");
+ test($prx->ice_getFacet() == "facetABCD");
+ $prx2 = $objectHelper::checkedCast($prx);
+ test($prx2->ice_getFacet() == "facetABCD");
+ $prx3 = $objectHelper::checkedCast($prx, "");
+ test($prx3->ice_getFacet() == "");
+ $d = $dHelper::checkedCast($db);
+ test($d->ice_getFacet() == "");
+ $df = $dHelper::checkedCast($db, "facetABCD");
+ test($df->ice_getFacet() == "facetABCD");
+ $df2 = $dHelper::checkedCast($df);
+ test($df2->ice_getFacet() == "facetABCD");
+ $df3 = $dHelper::checkedCast($df, "");
+ test($df3->ice_getFacet() == "");
echo "ok\n";
echo "testing non-facets A, B, C, and D... ";
diff --git a/php/test/Ice/operations/Client.php b/php/test/Ice/operations/Client.php
index 6a71e960724..a7a4933565b 100644
--- a/php/test/Ice/operations/Client.php
+++ b/php/test/Ice/operations/Client.php
@@ -37,17 +37,26 @@ function twoways($communicator, $p)
$enum2 = $NS ? constant("Test\\MyEnum::enum2") : constant("Test_MyEnum::enum2");
$enum3 = $NS ? constant("Test\\MyEnum::enum3") : constant("Test_MyEnum::enum3");
+ $myDerivedClassPrxHelper = $NS ? "Test\\MyDerivedClassPrxHelper" : "Test_MyDerivedClassPrxHelper";
+ $myDerivedClass = $NS ? "Test\\MyDerivedClass" : "Test_MyDerivedClass";
+ $myClass = $NS ? "Test\\MyClass" : "Test_MyClass";
+ $objectPrxHelper = $NS ? "Ice\\ObjectPrxHelper" : "Ice_ObjectPrxHelper";
+
{
$p->ice_ping();
}
{
- test(Test_MyDerivedClassPrxHelper::ice_staticId() == Test_MyDerivedClass::ice_staticId());
+ test($myDerivedClassPrxHelper::ice_staticId() == $myDerivedClass::ice_staticId());
+ test($objectPrxHelper::ice_staticId() == "::Ice::Object");
+ }
+
+ {
+ test($p->ice_isA($myClass::ice_staticId()));
}
-
{
- test($p->ice_isA("::Test::MyClass"));
+ test($p->ice_id() == $myDerivedClass::ice_staticId());
}
{
diff --git a/py/modules/IcePy/Proxy.cpp b/py/modules/IcePy/Proxy.cpp
index 6d6b8fe7cba..e0f61858496 100644
--- a/py/modules/IcePy/Proxy.cpp
+++ b/py/modules/IcePy/Proxy.cpp
@@ -2294,6 +2294,15 @@ proxyUncheckedCast(PyObject* /*self*/, PyObject* args)
}
}
+#ifdef WIN32
+extern "C"
+#endif
+static PyObject*
+proxyIceStaticId(PyObject* /*self*/)
+{
+ return createString(Ice::Object::ice_staticId());
+}
+
static PyMethodDef ProxyMethods[] =
{
{ STRCAST("ice_getCommunicator"), reinterpret_cast<PyCFunction>(proxyIceGetCommunicator), METH_NOARGS,
@@ -2440,6 +2449,8 @@ static PyMethodDef ProxyMethods[] =
PyDoc_STR(STRCAST("checkedCast(proxy) -> proxy")) },
{ STRCAST("uncheckedCast"), reinterpret_cast<PyCFunction>(proxyUncheckedCast), METH_VARARGS | METH_STATIC,
PyDoc_STR(STRCAST("uncheckedCast(proxy) -> proxy")) },
+ { STRCAST("ice_staticId"), reinterpret_cast<PyCFunction>(proxyIceStaticId), METH_NOARGS | METH_STATIC,
+ PyDoc_STR(STRCAST("ice_staticId() -> string")) },
{ 0, 0 } /* sentinel */
};
diff --git a/py/test/Ice/operations/Twoways.py b/py/test/Ice/operations/Twoways.py
index e155fbad8e3..bc33b03d69a 100644
--- a/py/test/Ice/operations/Twoways.py
+++ b/py/test/Ice/operations/Twoways.py
@@ -38,12 +38,12 @@ def twoways(communicator, p):
#
test(p.ice_id() == Test.MyDerivedClass.ice_staticId())
-
#
# Prx ice_staticId
#
+ test(Test.MyClassPrx.ice_staticId() == Test.MyClass.ice_staticId())
test(Test.MyDerivedClassPrx.ice_staticId() == Test.MyDerivedClass.ice_staticId())
-
+ test(Ice.ObjectPrx.ice_staticId() == Ice.Object.ice_staticId())
#
# opVoid
diff --git a/rb/src/IceRuby/Proxy.cpp b/rb/src/IceRuby/Proxy.cpp
index c0caa326aa0..e239414f1f8 100644
--- a/rb/src/IceRuby/Proxy.cpp
+++ b/rb/src/IceRuby/Proxy.cpp
@@ -18,7 +18,6 @@
#include <Ice/Proxy.h>
#include <Ice/Router.h>
-
using namespace std;
using namespace IceRuby;
@@ -1198,6 +1197,18 @@ IceRuby_ObjectPrx_ice_uncheckedCast(VALUE self, VALUE obj, VALUE facet)
extern "C"
VALUE
+IceRuby_ObjectPrx_ice_staticId(VALUE self)
+{
+ ICE_RUBY_TRY
+ {
+ return createString(Ice::Object::ice_staticId());
+ }
+ ICE_RUBY_CATCH
+ return Qnil;
+}
+
+extern "C"
+VALUE
IceRuby_ObjectPrx_new(int /*argc*/, VALUE* /*args*/, VALUE self)
{
ICE_RUBY_TRY
@@ -1288,6 +1299,7 @@ IceRuby::initProxy(VALUE iceModule)
rb_define_singleton_method(_proxyClass, "uncheckedCast", CAST_METHOD(IceRuby_ObjectPrx_uncheckedCast), -1);
rb_define_singleton_method(_proxyClass, "ice_checkedCast", CAST_METHOD(IceRuby_ObjectPrx_ice_checkedCast), 4);
rb_define_singleton_method(_proxyClass, "ice_uncheckedCast", CAST_METHOD(IceRuby_ObjectPrx_ice_uncheckedCast), 2);
+ rb_define_singleton_method(_proxyClass, "ice_staticId", CAST_METHOD(IceRuby_ObjectPrx_ice_staticId), 0);
rb_define_singleton_method(_proxyClass, "new", CAST_METHOD(IceRuby_ObjectPrx_new), -1);
}
diff --git a/rb/test/Ice/facets/AllTests.rb b/rb/test/Ice/facets/AllTests.rb
index 598a0504562..4e42455c6b4 100644
--- a/rb/test/Ice/facets/AllTests.rb
+++ b/rb/test/Ice/facets/AllTests.rb
@@ -43,12 +43,44 @@ def allTests(communicator)
test(db)
puts "ok"
+ print "testing unchecked cast... "
+ STDOUT.flush
+ obj = Ice::ObjectPrx::uncheckedCast(db)
+ test(obj.ice_getFacet() == "")
+ obj = Ice::ObjectPrx::uncheckedCast(db, "facetABCD")
+ test(obj.ice_getFacet() == "facetABCD")
+ obj2 = Ice::ObjectPrx::uncheckedCast(obj)
+ test(obj2.ice_getFacet() == "facetABCD")
+ obj3 = Ice::ObjectPrx::uncheckedCast(obj, "")
+ test(obj3.ice_getFacet() == "")
+ d = Test::DPrx::uncheckedCast(db)
+ test(d.ice_getFacet() == "")
+ df = Test::DPrx::uncheckedCast(db, "facetABCD")
+ test(df.ice_getFacet() == "facetABCD")
+ df2 = Test::DPrx::uncheckedCast(df)
+ test(df2.ice_getFacet() == "facetABCD")
+ df3 = Test::DPrx::uncheckedCast(df, "")
+ test(df3.ice_getFacet() == "")
+ puts "ok"
+
print "testing checked cast... "
STDOUT.flush
+ obj = Ice::ObjectPrx::checkedCast(db)
+ test(obj.ice_getFacet() == "")
+ obj = Ice::ObjectPrx::checkedCast(db, "facetABCD")
+ test(obj.ice_getFacet() == "facetABCD")
+ obj2 = Ice::ObjectPrx::checkedCast(obj)
+ test(obj2.ice_getFacet() == "facetABCD")
+ obj3 = Ice::ObjectPrx::checkedCast(obj, "")
+ test(obj3.ice_getFacet() == "")
d = Test::DPrx::checkedCast(db)
- test(d)
- test(d == db)
- test(Test::DPrx::checkedCast(d, "bogus") == nil)
+ test(d.ice_getFacet() == "")
+ df = Test::DPrx::checkedCast(db, "facetABCD")
+ test(df.ice_getFacet() == "facetABCD")
+ df2 = Test::DPrx::checkedCast(df)
+ test(df2.ice_getFacet() == "facetABCD")
+ df3 = Test::DPrx::checkedCast(df, "")
+ test(df3.ice_getFacet() == "")
puts "ok"
print "testing non-facets A, B, C, and D... "
diff --git a/rb/test/Ice/operations/Twoways.rb b/rb/test/Ice/operations/Twoways.rb
index 17ea26dd225..92f04fd4c88 100644
--- a/rb/test/Ice/operations/Twoways.rb
+++ b/rb/test/Ice/operations/Twoways.rb
@@ -35,7 +35,9 @@ def twoways(communicator, p)
#
# Proxy ice_staticId
#
- test(Test::MyDerivedClassPrx::ice_staticId() == Test::MyDerivedClass::ice_staticId())
+ test(Test::MyClassPrx::ice_staticId() == Test::MyClass::ice_staticId())
+ test(Test::MyDerivedClassPrx::ice_staticId() == Test::MyDerivedClass::ice_staticId())
+ test(Ice::ObjectPrx::ice_staticId() == Ice::Object::ice_staticId())
#
# opVoid