summaryrefslogtreecommitdiff
path: root/php/src/IcePHP/Proxy.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2009-06-23 17:47:58 -0700
committerMark Spruiell <mes@zeroc.com>2009-06-23 17:47:58 -0700
commita2e794a1366fcd71f04496c206869ffa158547ac (patch)
tree4c9d6554f3dc658aeaa76892aeecfc3d7eb56b61 /php/src/IcePHP/Proxy.cpp
parentAdd x64 configurations to C++ projects (diff)
downloadice-a2e794a1366fcd71f04496c206869ffa158547ac.tar.bz2
ice-a2e794a1366fcd71f04496c206869ffa158547ac.tar.xz
ice-a2e794a1366fcd71f04496c206869ffa158547ac.zip
PHP changes:
- static translation - more traditional language mapping (multiple communicators, etc.) - support for registered (persistent) communicators - support for PHP namespaces (PHP 5.3 or later)
Diffstat (limited to 'php/src/IcePHP/Proxy.cpp')
-rw-r--r--php/src/IcePHP/Proxy.cpp1994
1 files changed, 409 insertions, 1585 deletions
diff --git a/php/src/IcePHP/Proxy.cpp b/php/src/IcePHP/Proxy.cpp
index 9b22aca798e..65bb3cd9e6d 100644
--- a/php/src/IcePHP/Proxy.cpp
+++ b/php/src/IcePHP/Proxy.cpp
@@ -7,11 +7,9 @@
//
// **********************************************************************
-#include <IceUtil/DisableWarnings.h>
#include <Proxy.h>
-#include <Communicator.h>
-#include <Marshal.h>
-#include <Profile.h>
+#include <Connection.h>
+#include <Endpoint.h>
#include <Util.h>
using namespace std;
@@ -22,28 +20,25 @@ ZEND_EXTERN_MODULE_GLOBALS(ice)
//
// Here's a brief description of how proxies are handled by this extension.
//
-// A single PHP class, Ice_ObjectPrx, is registered. This is an "internal" class,
+// A single PHP class, ObjectPrx, is registered. This is an "internal" class,
// i.e., implemented by this extension, and it is used to represent all proxies
// regardless of interface type.
//
// Like in C++, a proxy is only capable of invoking the Ice::ObjectPrx operations
// until it is narrowed with a checked or unchecked cast. Unlike C++, no PHP classes
-// are created for proxies, because all marshaling activity is driven by the Slice
+// are created for proxies, because all marshaling activity is driven by the type
// definitions, not by statically-generated code.
//
-// In order to perform a checked or unchecked cast, the user invokes ice_checkedCast
-// or ice_uncheckedCast on the proxy to be narrowed, supplying a scoped name for the
-// desired type. Internally, the proxy validates the scoped name and returns a new
-// proxy containing the Slice class or interface definition. This proxy is considered
+// In order to perform a checked or unchecked cast, the generated code invokes
+// ice_checkedCast or ice_uncheckedCast on the proxy to be narrowed, supplying a scoped
+// name for the desired type. Internally, the proxy validates the scoped name and returns
+// a new proxy containing the class or interface definition. This proxy is considered
// to be narrowed to that interface and therefore supports user-defined operations.
//
-// Naturally, there are many predefined proxy methods (e.g., ice_isA, etc.), but
+// Naturally, there are many predefined proxy methods (e.g., ice_getIdentity, etc.), but
// the proxy also needs to support user-defined operations (if it has type information).
// We use a Zend API hook that allows us to intercept the invocation of unknown methods
-// on the proxy object. At this point, the proxy checks the interface definition for
-// an operation with the given name, and then creates an Operation object (see below)
-// that is responsible for invoking the operation. The proxy caches the Operation objects
-// for future reuse.
+// on the proxy object.
//
//
@@ -52,346 +47,73 @@ ZEND_EXTERN_MODULE_GLOBALS(ice)
namespace IcePHP
{
zend_class_entry* proxyClassEntry = 0;
-zend_class_entry* endpointClassEntry = 0;
-zend_class_entry* connectionClassEntry = 0;
}
//
-// Ice::ObjectPrx and Ice::Endpoint support.
+// Ice::ObjectPrx support.
//
-static zend_object_handlers _proxyHandlers;
-static zend_object_handlers _endpointHandlers;
-static zend_object_handlers _connectionHandlers;
+static zend_object_handlers _handlers;
extern "C"
{
-static zend_object_value handleProxyAlloc(zend_class_entry* TSRMLS_DC);
-static void handleProxyFreeStorage(void* TSRMLS_DC);
-static zend_object_value handleProxyClone(zval* TSRMLS_DC);
-static union _zend_function* handleProxyGetMethod(zval**, char*, int TSRMLS_DC);
-static int handleProxyCompare(zval*, zval* TSRMLS_DC);
-ZEND_FUNCTION(Ice_ObjectPrx_call);
-
-static zend_object_value handleEndpointAlloc(zend_class_entry* TSRMLS_DC);
-static void handleEndpointFreeStorage(void* TSRMLS_DC);
-
-static zend_object_value handleConnectionAlloc(zend_class_entry* TSRMLS_DC);
-static void handleConnectionFreeStorage(void* TSRMLS_DC);
-static int handleConnectionCompare(zval*, zval* TSRMLS_DC);
+static zend_object_value handleAlloc(zend_class_entry* TSRMLS_DC);
+static void handleFreeStorage(void* TSRMLS_DC);
+static zend_object_value handleClone(zval* TSRMLS_DC);
+static union _zend_function* handleGetMethod(zval**, char*, int TSRMLS_DC);
+static int handleCompare(zval*, zval* TSRMLS_DC);
}
-static bool lookupClass(const string&, Slice::ClassDefPtr& TSRMLS_DC);
+static ClassInfoPtr lookupClass(const string& TSRMLS_DC);
namespace IcePHP
{
//
-// Encapsulates an operation description.
-//
-class Operation : public IceUtil::SimpleShared
-{
-public:
- Operation(const Ice::ObjectPrx&, const string&, const Slice::OperationPtr&, const Ice::CommunicatorPtr&
- TSRMLS_DC);
- virtual ~Operation();
-
- zend_function* getZendFunction() const;
- void invoke(INTERNAL_FUNCTION_PARAMETERS);
-
-private:
- void throwUserException(Ice::InputStreamPtr& TSRMLS_DC);
-
- Ice::ObjectPrx _proxy;
- string _name; // Local name, not the on-the-wire name
- Slice::OperationPtr _op;
- Ice::CommunicatorPtr _communicator;
-#ifdef ZTS
- TSRMLS_D;
-#endif
- vector<string> _paramNames;
- MarshalerPtr _result;
- vector<MarshalerPtr> _inParams;
- vector<MarshalerPtr> _outParams;
- zend_internal_function* _zendFunction;
-};
-typedef IceUtil::Handle<Operation> OperationPtr;
-
-//
// Encapsulates proxy and type information.
//
-class Proxy
+class Proxy : public IceUtil::Shared
{
public:
- Proxy(const Ice::ObjectPrx&, const Slice::ClassDefPtr& TSRMLS_DC);
- ~Proxy();
- const Ice::ObjectPrx& getProxy() const;
- const Slice::ClassDefPtr& getClass() const;
-
- OperationPtr getOperation(const string&);
+ Proxy(const Ice::ObjectPrx&, const ClassInfoPtr&, const CommunicatorInfoPtr& TSRMLS_DC);
+ ~Proxy();
- string toString() const;
+ bool clone(zval*, const Ice::ObjectPrx& TSRMLS_DC);
+ bool cloneUntyped(zval*, const Ice::ObjectPrx& TSRMLS_DC);
+ static bool create(zval*, const Ice::ObjectPrx&, const ClassInfoPtr&, const CommunicatorInfoPtr& TSRMLS_DC);
-private:
- Ice::ObjectPrx _proxy;
- Slice::ClassDefPtr _class;
-#ifdef ZTS
+ Ice::ObjectPrx proxy;
+ ClassInfoPtr info;
+ CommunicatorInfoPtr communicator;
+ zval* connection;
+ zval* cachedConnection;
+#if ZTS
TSRMLS_D;
#endif
- zval _communicatorZval;
- Ice::CommunicatorPtr _communicator;
- Slice::OperationList _classOps;
- map<string, OperationPtr> _ops;
};
+typedef IceUtil::Handle<Proxy> ProxyPtr;
} // End of namespace IcePHP
-//
-// Predefined methods for Ice_ObjectPrx.
-//
-static function_entry _proxyMethods[] =
-{
- {"__construct", PHP_FN(Ice_ObjectPrx___construct), 0},
- {"__tostring", PHP_FN(Ice_ObjectPrx___tostring), 0},
- {"ice_getCommunicator", PHP_FN(Ice_ObjectPrx_ice_getCommunicator), 0},
- {"ice_toString", PHP_FN(Ice_ObjectPrx_ice_toString), 0},
- {"ice_isA", PHP_FN(Ice_ObjectPrx_ice_isA), 0},
- {"ice_ping", PHP_FN(Ice_ObjectPrx_ice_ping), 0},
- {"ice_id", PHP_FN(Ice_ObjectPrx_ice_id), 0},
- {"ice_ids", PHP_FN(Ice_ObjectPrx_ice_ids), 0},
- {"ice_getIdentity", PHP_FN(Ice_ObjectPrx_ice_getIdentity), 0},
- {"ice_newIdentity", PHP_FN(Ice_ObjectPrx_ice_identity), 0},
- {"ice_identity", PHP_FN(Ice_ObjectPrx_ice_identity), 0},
- {"ice_getContext", PHP_FN(Ice_ObjectPrx_ice_getContext), 0},
- {"ice_newContext", PHP_FN(Ice_ObjectPrx_ice_context), 0},
- {"ice_context", PHP_FN(Ice_ObjectPrx_ice_context), 0},
- {"ice_getFacet", PHP_FN(Ice_ObjectPrx_ice_getFacet), 0},
- {"ice_newFacet", PHP_FN(Ice_ObjectPrx_ice_facet), 0},
- {"ice_facet", PHP_FN(Ice_ObjectPrx_ice_facet), 0},
- {"ice_getAdapterId", PHP_FN(Ice_ObjectPrx_ice_getAdapterId), 0},
- {"ice_newAdapterId", PHP_FN(Ice_ObjectPrx_ice_adapterId), 0},
- {"ice_adapterId", PHP_FN(Ice_ObjectPrx_ice_adapterId), 0},
- {"ice_getEndpoints", PHP_FN(Ice_ObjectPrx_ice_getEndpoints), 0},
- {"ice_newEndpoints", PHP_FN(Ice_ObjectPrx_ice_endpoints), 0},
- {"ice_endpoints", PHP_FN(Ice_ObjectPrx_ice_endpoints), 0},
- {"ice_getLocatorCacheTimeout", PHP_FN(Ice_ObjectPrx_ice_getLocatorCacheTimeout), 0},
- {"ice_locatorCacheTimeout", PHP_FN(Ice_ObjectPrx_ice_locatorCacheTimeout), 0},
- {"ice_isConnectionCached", PHP_FN(Ice_ObjectPrx_ice_isConnectionCached), 0},
- {"ice_connectionCached", PHP_FN(Ice_ObjectPrx_ice_connectionCached), 0},
- {"ice_getEndpointSelection", PHP_FN(Ice_ObjectPrx_ice_getEndpointSelection), 0},
- {"ice_endpointSelection", PHP_FN(Ice_ObjectPrx_ice_endpointSelection), 0},
- {"ice_isSecure", PHP_FN(Ice_ObjectPrx_ice_isSecure), 0},
- {"ice_secure", PHP_FN(Ice_ObjectPrx_ice_secure), 0},
- {"ice_isPreferSecure", PHP_FN(Ice_ObjectPrx_ice_isPreferSecure), 0},
- {"ice_preferSecure", PHP_FN(Ice_ObjectPrx_ice_preferSecure), 0},
- {"ice_getRouter", PHP_FN(Ice_ObjectPrx_ice_getRouter), 0},
- {"ice_router", PHP_FN(Ice_ObjectPrx_ice_router), 0},
- {"ice_getLocator", PHP_FN(Ice_ObjectPrx_ice_getLocator), 0},
- {"ice_locator", PHP_FN(Ice_ObjectPrx_ice_locator), 0},
- {"ice_twoway", PHP_FN(Ice_ObjectPrx_ice_twoway), 0},
- {"ice_isTwoway", PHP_FN(Ice_ObjectPrx_ice_isTwoway), 0},
- {"ice_oneway", PHP_FN(Ice_ObjectPrx_ice_oneway), 0},
- {"ice_isOneway", PHP_FN(Ice_ObjectPrx_ice_isOneway), 0},
- {"ice_batchOneway", PHP_FN(Ice_ObjectPrx_ice_batchOneway), 0},
- {"ice_isBatchOneway", PHP_FN(Ice_ObjectPrx_ice_isBatchOneway), 0},
- {"ice_datagram", PHP_FN(Ice_ObjectPrx_ice_datagram), 0},
- {"ice_isDatagram", PHP_FN(Ice_ObjectPrx_ice_isDatagram), 0},
- {"ice_batchDatagram", PHP_FN(Ice_ObjectPrx_ice_batchDatagram), 0},
- {"ice_isBatchDatagram", PHP_FN(Ice_ObjectPrx_ice_isBatchDatagram), 0},
- {"ice_compress", PHP_FN(Ice_ObjectPrx_ice_compress), 0},
- {"ice_timeout", PHP_FN(Ice_ObjectPrx_ice_timeout), 0},
- {"ice_connectionId", PHP_FN(Ice_ObjectPrx_ice_connectionId), 0},
- {"ice_getConnection", PHP_FN(Ice_ObjectPrx_ice_getConnection), 0},
- {"ice_getCachedConnection", PHP_FN(Ice_ObjectPrx_ice_getCachedConnection), 0},
- {"ice_uncheckedCast", PHP_FN(Ice_ObjectPrx_ice_uncheckedCast), 0},
- {"ice_checkedCast", PHP_FN(Ice_ObjectPrx_ice_checkedCast), 0},
- {0, 0, 0}
-};
-
-//
-// Predefined methods for Ice_Endpoint.
-//
-static function_entry _endpointMethods[] =
-{
- {"__construct", PHP_FN(Ice_Endpoint___construct), 0},
- {"__tostring", PHP_FN(Ice_Endpoint___tostring), 0},
- {"toString", PHP_FN(Ice_Endpoint_toString), 0},
- {0, 0, 0}
-};
-
-//
-// Predefined methods for Ice_Connection.
-//
-static function_entry _connectionMethods[] =
-{
- {"__construct", PHP_FN(Ice_Connection___construct), 0},
- {"__tostring", PHP_FN(Ice_Connection___tostring), 0},
- {"close", PHP_FN(Ice_Connection_close), 0},
- {"flushBatchRequests", PHP_FN(Ice_Connection_flushBatchRequests), 0},
- {"type", PHP_FN(Ice_Connection_type), 0},
- {"timeout", PHP_FN(Ice_Connection_timeout), 0},
- {"toString", PHP_FN(Ice_Connection_toString), 0},
- {0, 0, 0}
-};
-
-bool
-IcePHP::proxyInit(TSRMLS_D)
-{
- //
- // Register the Ice_ObjectPrx class.
- //
- zend_class_entry ce;
- INIT_CLASS_ENTRY(ce, "Ice_ObjectPrx", _proxyMethods);
- ce.create_object = handleProxyAlloc;
- proxyClassEntry = zend_register_internal_class(&ce TSRMLS_CC);
- memcpy(&_proxyHandlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
- _proxyHandlers.clone_obj = handleProxyClone;
- _proxyHandlers.get_method = handleProxyGetMethod;
- _proxyHandlers.compare_objects = handleProxyCompare;
-
- //
- // Register the Ice_Endpoint class.
- //
- INIT_CLASS_ENTRY(ce, "Ice_Endpoint", _endpointMethods);
- ce.create_object = handleEndpointAlloc;
- endpointClassEntry = zend_register_internal_class(&ce TSRMLS_CC);
- memcpy(&_endpointHandlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
-
- //
- // Register the Ice_Connection class.
- //
- INIT_CLASS_ENTRY(ce, "Ice_Connection", _connectionMethods);
- ce.create_object = handleConnectionAlloc;
- connectionClassEntry = zend_register_internal_class(&ce TSRMLS_CC);
- memcpy(&_connectionHandlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
- _connectionHandlers.compare_objects = handleConnectionCompare;
-
- return true;
-}
-
-bool
-IcePHP::createProxy(zval* zv, const Ice::ObjectPrx& p TSRMLS_DC)
-{
- return createProxy(zv, p, 0 TSRMLS_CC);
-}
-
-bool
-IcePHP::createProxy(zval* zv, const Ice::ObjectPrx& p, const Slice::ClassDefPtr& def TSRMLS_DC)
-{
- if(object_init_ex(zv, proxyClassEntry) != SUCCESS)
- {
- php_error_docref(0 TSRMLS_CC, E_ERROR, "unable to initialize proxy");
- return false;
- }
-
- ice_object* zprx = static_cast<ice_object*>(zend_object_store_get_object(zv TSRMLS_CC));
- assert(!zprx->ptr);
- zprx->ptr = new Proxy(p, def TSRMLS_CC);
-
- return true;
-}
-
-bool
-IcePHP::fetchProxy(zval* zv, Ice::ObjectPrx& prx, Slice::ClassDefPtr& def TSRMLS_DC)
-{
- if(!ZVAL_IS_NULL(zv))
- {
- void* p = zend_object_store_get_object(zv TSRMLS_CC);
- if(!p)
- {
- php_error_docref(0 TSRMLS_CC, E_ERROR, "unable to retrieve proxy object from object store");
- return false;
- }
- if(Z_OBJCE_P(zv) != proxyClassEntry)
- {
- php_error_docref(0 TSRMLS_CC, E_ERROR, "value is not a proxy");
- return false;
- }
- ice_object* obj = static_cast<ice_object*>(p);
- assert(obj->ptr);
- Proxy* proxy = static_cast<Proxy*>(obj->ptr);
- prx = proxy->getProxy();
- def = proxy->getClass();
- }
- return true;
-}
-
-static bool
-createEndpoint(zval* zv, const Ice::EndpointPtr& p TSRMLS_DC)
-{
- if(object_init_ex(zv, endpointClassEntry) != SUCCESS)
- {
- php_error_docref(0 TSRMLS_CC, E_ERROR, "unable to initialize endpoint");
- return false;
- }
-
- ice_object* ze = static_cast<ice_object*>(zend_object_store_get_object(zv TSRMLS_CC));
- assert(!ze->ptr);
- ze->ptr = new Ice::EndpointPtr(p);
-
- return true;
-}
-
-static bool
-fetchEndpoint(zval* zv, Ice::EndpointPtr& endpoint TSRMLS_DC)
-{
- if(!ZVAL_IS_NULL(zv))
- {
- void* p = zend_object_store_get_object(zv TSRMLS_CC);
- if(!p)
- {
- php_error_docref(0 TSRMLS_CC, E_ERROR, "unable to retrieve endpoint object from object store");
- return false;
- }
- if(Z_OBJCE_P(zv) != endpointClassEntry)
- {
- php_error_docref(0 TSRMLS_CC, E_ERROR, "value is not an endpoint");
- return false;
- }
- ice_object* obj = static_cast<ice_object*>(p);
- assert(obj->ptr);
- Ice::EndpointPtr* pe = static_cast<Ice::EndpointPtr*>(obj->ptr);
- endpoint = *pe;
- }
- return true;
-}
-
-static bool
-createConnection(zval* zv, const Ice::ConnectionPtr& p TSRMLS_DC)
-{
- if(object_init_ex(zv, connectionClassEntry) != SUCCESS)
- {
- php_error_docref(0 TSRMLS_CC, E_ERROR, "unable to initialize connection");
- return false;
- }
-
- ice_object* ze = static_cast<ice_object*>(zend_object_store_get_object(zv TSRMLS_CC));
- assert(!ze->ptr);
- ze->ptr = new Ice::ConnectionPtr(p);
-
- return true;
-}
-
-ZEND_FUNCTION(Ice_ObjectPrx___construct)
+ZEND_METHOD(Ice_ObjectPrx, __construct)
{
- php_error_docref(0 TSRMLS_CC, E_ERROR, "Ice_ObjectPrx cannot be instantiated, use $ICE->stringToProxy()");
+ runtimeError("proxies cannot be instantiated, use stringToProxy()" TSRMLS_CC);
}
-ZEND_FUNCTION(Ice_ObjectPrx___tostring)
+ZEND_METHOD(Ice_ObjectPrx, __toString)
{
if(ZEND_NUM_ARGS() > 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- string str = _this->toString();
- RETURN_STRINGL(const_cast<char*>(str.c_str()), str.length(), 1);
+ string str = _this->proxy->ice_toString();
+ RETURN_STRINGL(STRCAST(str.c_str()), str.length(), 1);
}
catch(const IceUtil::Exception& ex)
{
@@ -400,242 +122,43 @@ ZEND_FUNCTION(Ice_ObjectPrx___tostring)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_getCommunicator)
-{
- zval* zc = getCommunicatorZval(TSRMLS_C);
-
- Z_TYPE_P(return_value) = IS_OBJECT;
- return_value->value.obj = zc->value.obj;
- Z_OBJ_HT_P(return_value)->add_ref(return_value TSRMLS_CC);
-}
-
-ZEND_FUNCTION(Ice_ObjectPrx_ice_toString)
-{
- ZEND_FN(Ice_ObjectPrx___tostring)(INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-
-ZEND_FUNCTION(Ice_ObjectPrx_ice_isA)
-{
- if(ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 2)
- {
- WRONG_PARAM_COUNT;
- }
-
- char* id;
- int len;
- zval* arr = 0;
-
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|a", &id, &len, &arr) == FAILURE)
- {
- RETURN_FALSE;
- }
-
- //
- // Populate the context (if necessary).
- //
- Ice::Context ctx;
- if(arr && !extractContext(arr, ctx TSRMLS_CC))
- {
- RETURN_FALSE;
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
-
- try
- {
- bool b;
- if(arr)
- {
- b = _this->getProxy()->ice_isA(id, ctx);
- }
- else
- {
- b = _this->getProxy()->ice_isA(id);
- }
-
- RETURN_BOOL(b ? 1 : 0);
- }
- catch(const IceUtil::Exception& ex)
- {
- throwException(ex TSRMLS_CC);
- RETVAL_FALSE;
- }
-}
-
-ZEND_FUNCTION(Ice_ObjectPrx_ice_ping)
+ZEND_METHOD(Ice_ObjectPrx, ice_getCommunicator)
{
- if(ZEND_NUM_ARGS() > 1)
- {
- WRONG_PARAM_COUNT;
- }
-
- zval* arr = 0;
-
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a", &arr) == FAILURE)
- {
- RETURN_NULL();
- }
-
- //
- // Populate the context (if necessary).
- //
- Ice::Context ctx;
- if(arr && !extractContext(arr, ctx TSRMLS_CC))
- {
- RETURN_NULL();
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
-
- try
- {
- if(arr)
- {
- _this->getProxy()->ice_ping(ctx);
- }
- else
- {
- _this->getProxy()->ice_ping();
- }
- }
- catch(const IceUtil::Exception& ex)
- {
- throwException(ex TSRMLS_CC);
- }
-
- RETURN_NULL();
-}
-
-ZEND_FUNCTION(Ice_ObjectPrx_ice_id)
-{
- if(ZEND_NUM_ARGS() > 1)
+ if(ZEND_NUM_ARGS() > 0)
{
WRONG_PARAM_COUNT;
}
- zval* arr = 0;
-
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a", &arr) == FAILURE)
- {
- RETURN_NULL();
- }
-
- //
- // Populate the context (if necessary).
- //
- Ice::Context ctx;
- if(arr && !extractContext(arr, ctx TSRMLS_CC))
- {
- RETURN_NULL();
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
- try
- {
- string id;
- if(arr)
- {
- id = _this->getProxy()->ice_id(ctx);
- }
- else
- {
- id = _this->getProxy()->ice_id();
- }
- RETURN_STRINGL(const_cast<char*>(id.c_str()), id.length(), 1);
- }
- catch(const IceUtil::Exception& ex)
- {
- throwException(ex TSRMLS_CC);
- RETURN_NULL();
- }
+ _this->communicator->getZval(return_value TSRMLS_CC);
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_ids)
+ZEND_METHOD(Ice_ObjectPrx, ice_toString)
{
- if(ZEND_NUM_ARGS() > 1)
- {
- WRONG_PARAM_COUNT;
- }
-
- zval* arr = 0;
-
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a", &arr) == FAILURE)
- {
- RETURN_NULL();
- }
-
- //
- // Populate the context (if necessary).
- //
- Ice::Context ctx;
- if(arr && !extractContext(arr, ctx TSRMLS_CC))
- {
- RETURN_NULL();
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
-
- try
- {
- vector<string> ids;
- if(arr)
- {
- ids = _this->getProxy()->ice_ids(ctx);
- }
- else
- {
- ids = _this->getProxy()->ice_ids();
- }
-
- array_init(return_value);
- uint idx = 0;
- for(vector<string>::const_iterator p = ids.begin(); p != ids.end(); ++p, ++idx)
- {
- add_index_stringl(return_value, idx, const_cast<char*>((*p).c_str()), (*p).length(), 1);
- }
- }
- catch(const IceUtil::Exception& ex)
- {
- throwException(ex TSRMLS_CC);
- RETURN_NULL();
- }
+ ZEND_MN(Ice_ObjectPrx___toString)(INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_getIdentity)
+ZEND_METHOD(Ice_ObjectPrx, ice_getIdentity)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
- createIdentity(return_value, _this->getProxy()->ice_getIdentity() TSRMLS_CC);
+ createIdentity(return_value, _this->proxy->ice_getIdentity() TSRMLS_CC);
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_identity)
+ZEND_METHOD(Ice_ObjectPrx, ice_identity)
{
- if(ZEND_NUM_ARGS() != 1)
- {
- WRONG_PARAM_COUNT;
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
- zend_class_entry* cls = findClass("Ice_Identity" TSRMLS_CC);
+ zend_class_entry* cls = idToClass("::Ice::Identity" TSRMLS_CC);
assert(cls);
zval *zid;
@@ -650,8 +173,7 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_identity)
{
try
{
- Ice::ObjectPrx prx = _this->getProxy()->ice_identity(id);
- if(!createProxy(return_value, prx TSRMLS_CC))
+ if(!_this->cloneUntyped(return_value, _this->proxy->ice_identity(id) TSRMLS_CC))
{
RETURN_NULL();
}
@@ -664,27 +186,24 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_identity)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_getContext)
+ZEND_METHOD(Ice_ObjectPrx, ice_getContext)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
-
- createContext(return_value, _this->getProxy()->ice_getContext() TSRMLS_CC);
-}
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
-ZEND_FUNCTION(Ice_ObjectPrx_ice_context)
-{
- if(ZEND_NUM_ARGS() != 1)
+ if(!createStringMap(return_value, _this->proxy->ice_getContext() TSRMLS_CC))
{
- WRONG_PARAM_COUNT;
+ RETURN_NULL();
}
+}
+ZEND_METHOD(Ice_ObjectPrx, ice_context)
+{
zval* arr = 0;
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &arr) == FAILURE)
@@ -696,19 +215,17 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_context)
// Populate the context.
//
Ice::Context ctx;
- if(arr && !extractContext(arr, ctx TSRMLS_CC))
+ if(arr && !extractStringMap(arr, ctx TSRMLS_CC))
{
RETURN_NULL();
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- Ice::ObjectPrx prx = _this->getProxy()->ice_context(ctx);
- if(!createProxy(return_value, prx, _this->getClass() TSRMLS_CC))
+ if(!_this->clone(return_value, _this->proxy->ice_context(ctx) TSRMLS_CC))
{
RETURN_NULL();
}
@@ -720,21 +237,20 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_context)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_getFacet)
+ZEND_METHOD(Ice_ObjectPrx, ice_getFacet)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- string facet = _this->getProxy()->ice_getFacet();
- ZVAL_STRINGL(return_value, const_cast<char*>(facet.c_str()), facet.length(), 1);
+ string facet = _this->proxy->ice_getFacet();
+ ZVAL_STRINGL(return_value, STRCAST(facet.c_str()), facet.length(), 1);
}
catch(const IceUtil::Exception& ex)
{
@@ -743,13 +259,8 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_getFacet)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_facet)
+ZEND_METHOD(Ice_ObjectPrx, ice_facet)
{
- if(ZEND_NUM_ARGS() != 1)
- {
- WRONG_PARAM_COUNT;
- }
-
char* name;
int len;
@@ -758,14 +269,12 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_facet)
RETURN_NULL();
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- Ice::ObjectPrx prx = _this->getProxy()->ice_facet(name);
- if(!createProxy(return_value, prx TSRMLS_CC))
+ if(!_this->cloneUntyped(return_value, _this->proxy->ice_facet(name) TSRMLS_CC))
{
RETURN_NULL();
}
@@ -777,21 +286,20 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_facet)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_getAdapterId)
+ZEND_METHOD(Ice_ObjectPrx, ice_getAdapterId)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- string id = _this->getProxy()->ice_getAdapterId();
- ZVAL_STRINGL(return_value, const_cast<char*>(id.c_str()), id.length(), 1);
+ string id = _this->proxy->ice_getAdapterId();
+ ZVAL_STRINGL(return_value, STRCAST(id.c_str()), id.length(), 1);
}
catch(const IceUtil::Exception& ex)
{
@@ -800,16 +308,10 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_getAdapterId)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_adapterId)
+ZEND_METHOD(Ice_ObjectPrx, ice_adapterId)
{
- if(ZEND_NUM_ARGS() != 1)
- {
- WRONG_PARAM_COUNT;
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
char* id;
int len;
@@ -821,8 +323,7 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_adapterId)
try
{
- Ice::ObjectPrx prx = _this->getProxy()->ice_adapterId(id);
- if(!createProxy(return_value, prx, _this->getClass() TSRMLS_CC))
+ if(!_this->clone(return_value, _this->proxy->ice_adapterId(id) TSRMLS_CC))
{
RETURN_NULL();
}
@@ -834,20 +335,19 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_adapterId)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_getEndpoints)
+ZEND_METHOD(Ice_ObjectPrx, ice_getEndpoints)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- Ice::EndpointSeq endpoints = _this->getProxy()->ice_getEndpoints();
+ Ice::EndpointSeq endpoints = _this->proxy->ice_getEndpoints();
array_init(return_value);
uint idx = 0;
@@ -870,16 +370,10 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_getEndpoints)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_endpoints)
+ZEND_METHOD(Ice_ObjectPrx, ice_endpoints)
{
- if(ZEND_NUM_ARGS() != 1)
- {
- WRONG_PARAM_COUNT;
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
zval* zv;
@@ -901,7 +395,7 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_endpoints)
if(Z_TYPE_PP(val) != IS_OBJECT)
{
- php_error_docref(0 TSRMLS_CC, E_ERROR, "expected an element of type Ice_Endpoint");
+ runtimeError("expected an element of type Ice::Endpoint" TSRMLS_CC);
RETURN_NULL();
}
@@ -918,8 +412,7 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_endpoints)
try
{
- Ice::ObjectPrx prx = _this->getProxy()->ice_endpoints(seq);
- if(!createProxy(return_value, prx, _this->getClass() TSRMLS_CC))
+ if(!_this->clone(return_value, _this->proxy->ice_endpoints(seq) TSRMLS_CC))
{
RETURN_NULL();
}
@@ -931,20 +424,19 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_endpoints)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_getLocatorCacheTimeout)
+ZEND_METHOD(Ice_ObjectPrx, ice_getLocatorCacheTimeout)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- Ice::Int timeout = _this->getProxy()->ice_getLocatorCacheTimeout();
+ Ice::Int timeout = _this->proxy->ice_getLocatorCacheTimeout();
ZVAL_LONG(return_value, static_cast<long>(timeout));
}
catch(const IceUtil::Exception& ex)
@@ -954,16 +446,10 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_getLocatorCacheTimeout)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_locatorCacheTimeout)
+ZEND_METHOD(Ice_ObjectPrx, ice_locatorCacheTimeout)
{
- if(ZEND_NUM_ARGS() != 1)
- {
- WRONG_PARAM_COUNT;
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
long l;
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &l) != SUCCESS)
@@ -973,8 +459,7 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_locatorCacheTimeout)
try
{
- Ice::ObjectPrx prx = _this->getProxy()->ice_locatorCacheTimeout(l);
- if(!createProxy(return_value, prx, _this->getClass() TSRMLS_CC))
+ if(!_this->clone(return_value, _this->proxy->ice_locatorCacheTimeout(l) TSRMLS_CC))
{
RETURN_NULL();
}
@@ -986,20 +471,19 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_locatorCacheTimeout)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_isConnectionCached)
+ZEND_METHOD(Ice_ObjectPrx, ice_isConnectionCached)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- bool b = _this->getProxy()->ice_isConnectionCached();
+ bool b = _this->proxy->ice_isConnectionCached();
ZVAL_BOOL(return_value, b ? 1 : 0);
}
catch(const IceUtil::Exception& ex)
@@ -1009,16 +493,10 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_isConnectionCached)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_connectionCached)
+ZEND_METHOD(Ice_ObjectPrx, ice_connectionCached)
{
- if(ZEND_NUM_ARGS() != 1)
- {
- WRONG_PARAM_COUNT;
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
zend_bool b;
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &b) != SUCCESS)
@@ -1028,8 +506,7 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_connectionCached)
try
{
- Ice::ObjectPrx prx = _this->getProxy()->ice_connectionCached(b ? true : false);
- if(!createProxy(return_value, prx, _this->getClass() TSRMLS_CC))
+ if(!_this->clone(return_value, _this->proxy->ice_connectionCached(b ? true : false) TSRMLS_CC))
{
RETURN_NULL();
}
@@ -1041,20 +518,19 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_connectionCached)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_getEndpointSelection)
+ZEND_METHOD(Ice_ObjectPrx, ice_getEndpointSelection)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- Ice::EndpointSelectionType type = _this->getProxy()->ice_getEndpointSelection();
+ Ice::EndpointSelectionType type = _this->proxy->ice_getEndpointSelection();
ZVAL_LONG(return_value, type == Ice::Random ? 0 : 1);
}
catch(const IceUtil::Exception& ex)
@@ -1064,16 +540,10 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_getEndpointSelection)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_endpointSelection)
+ZEND_METHOD(Ice_ObjectPrx, ice_endpointSelection)
{
- if(ZEND_NUM_ARGS() != 1)
- {
- WRONG_PARAM_COUNT;
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
long l;
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &l) != SUCCESS)
@@ -1083,14 +553,14 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_endpointSelection)
if(l < 0 || l > 1)
{
- php_error_docref(0 TSRMLS_CC, E_ERROR, "expecting Random or Ordered");
+ runtimeError("expecting Random or Ordered" TSRMLS_CC);
RETURN_NULL();
}
try
{
- Ice::ObjectPrx prx = _this->getProxy()->ice_endpointSelection(l == 0 ? Ice::Random : Ice::Ordered);
- if(!createProxy(return_value, prx, _this->getClass() TSRMLS_CC))
+ Ice::EndpointSelectionType type = l == 0 ? Ice::Random : Ice::Ordered;
+ if(!_this->clone(return_value, _this->proxy->ice_endpointSelection(type) TSRMLS_CC))
{
RETURN_NULL();
}
@@ -1102,20 +572,19 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_endpointSelection)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_isSecure)
+ZEND_METHOD(Ice_ObjectPrx, ice_isSecure)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- bool b = _this->getProxy()->ice_isSecure();
+ bool b = _this->proxy->ice_isSecure();
RETURN_BOOL(b ? 1 : 0);
}
catch(const IceUtil::Exception& ex)
@@ -1125,16 +594,10 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_isSecure)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_secure)
+ZEND_METHOD(Ice_ObjectPrx, ice_secure)
{
- if(ZEND_NUM_ARGS() != 1)
- {
- WRONG_PARAM_COUNT;
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
zend_bool b;
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &b TSRMLS_CC) != SUCCESS)
@@ -1144,8 +607,7 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_secure)
try
{
- Ice::ObjectPrx prx = _this->getProxy()->ice_secure(b ? true : false);
- if(!createProxy(return_value, prx, _this->getClass() TSRMLS_CC))
+ if(!_this->clone(return_value, _this->proxy->ice_secure(b ? true : false) TSRMLS_CC))
{
RETURN_NULL();
}
@@ -1157,20 +619,19 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_secure)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_isPreferSecure)
+ZEND_METHOD(Ice_ObjectPrx, ice_isPreferSecure)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- bool b = _this->getProxy()->ice_isPreferSecure();
+ bool b = _this->proxy->ice_isPreferSecure();
RETURN_BOOL(b ? 1 : 0);
}
catch(const IceUtil::Exception& ex)
@@ -1180,16 +641,10 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_isPreferSecure)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_preferSecure)
+ZEND_METHOD(Ice_ObjectPrx, ice_preferSecure)
{
- if(ZEND_NUM_ARGS() != 1)
- {
- WRONG_PARAM_COUNT;
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
zend_bool b;
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &b TSRMLS_CC) != SUCCESS)
@@ -1199,8 +654,7 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_preferSecure)
try
{
- Ice::ObjectPrx prx = _this->getProxy()->ice_preferSecure(b ? true : false);
- if(!createProxy(return_value, prx, _this->getClass() TSRMLS_CC))
+ if(!_this->clone(return_value, _this->proxy->ice_preferSecure(b ? true : false) TSRMLS_CC))
{
RETURN_NULL();
}
@@ -1212,31 +666,30 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_preferSecure)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_getRouter)
+ZEND_METHOD(Ice_ObjectPrx, ice_getRouter)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- Ice::RouterPrx router = _this->getProxy()->ice_getRouter();
+ Ice::RouterPrx router = _this->proxy->ice_getRouter();
if(router)
{
- Slice::ClassDefPtr def;
- if(!lookupClass("Ice::Router", def TSRMLS_CC))
+ ClassInfoPtr info = lookupClass("::Ice::Router" TSRMLS_CC);
+ if(!info)
{
RETURN_NULL();
}
- assert(def);
+ assert(info);
- if(!createProxy(return_value, router, def TSRMLS_CC))
+ if(!createProxy(return_value, router, info, _this->communicator TSRMLS_CC))
{
RETURN_NULL();
}
@@ -1253,16 +706,10 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_getRouter)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_router)
+ZEND_METHOD(Ice_ObjectPrx, ice_router)
{
- if(ZEND_NUM_ARGS() != 1)
- {
- WRONG_PARAM_COUNT;
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
zval* zprx;
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O!", &zprx, proxyClassEntry TSRMLS_CC) != SUCCESS)
@@ -1271,7 +718,7 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_router)
}
Ice::ObjectPrx proxy;
- Slice::ClassDefPtr def;
+ ClassInfoPtr def;
if(zprx && !fetchProxy(zprx, proxy, def TSRMLS_CC))
{
RETURN_NULL();
@@ -1282,7 +729,7 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_router)
{
if(!def || !def->isA("::Ice::Router"))
{
- php_error_docref(0 TSRMLS_CC, E_ERROR, "ice_router requires a proxy narrowed to Ice::Router");
+ runtimeError("ice_router requires a proxy narrowed to Ice::Router" TSRMLS_CC);
RETURN_NULL();
}
router = Ice::RouterPrx::uncheckedCast(proxy);
@@ -1290,8 +737,7 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_router)
try
{
- Ice::ObjectPrx prx = _this->getProxy()->ice_router(router);
- if(!createProxy(return_value, prx, _this->getClass() TSRMLS_CC))
+ if(!_this->clone(return_value, _this->proxy->ice_router(router) TSRMLS_CC))
{
RETURN_NULL();
}
@@ -1303,31 +749,28 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_router)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_getLocator)
+ZEND_METHOD(Ice_ObjectPrx, ice_getLocator)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- Ice::LocatorPrx locator = _this->getProxy()->ice_getLocator();
+ Ice::LocatorPrx locator = _this->proxy->ice_getLocator();
if(locator)
{
- Slice::ClassDefPtr def;
- if(!lookupClass("Ice::Locator", def TSRMLS_CC))
+ ClassInfoPtr info = lookupClass("::Ice::Locator" TSRMLS_CC);
+ if(!info)
{
RETURN_NULL();
}
- assert(def);
-
- if(!createProxy(return_value, locator, def TSRMLS_CC))
+ if(!createProxy(return_value, locator, info, _this->communicator TSRMLS_CC))
{
RETURN_NULL();
}
@@ -1344,16 +787,10 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_getLocator)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_locator)
+ZEND_METHOD(Ice_ObjectPrx, ice_locator)
{
- if(ZEND_NUM_ARGS() != 1)
- {
- WRONG_PARAM_COUNT;
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
zval* zprx;
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O!", &zprx, proxyClassEntry TSRMLS_CC) != SUCCESS)
@@ -1362,7 +799,7 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_locator)
}
Ice::ObjectPrx proxy;
- Slice::ClassDefPtr def;
+ ClassInfoPtr def;
if(zprx && !fetchProxy(zprx, proxy, def TSRMLS_CC))
{
RETURN_NULL();
@@ -1373,7 +810,7 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_locator)
{
if(!def || !def->isA("::Ice::Locator"))
{
- php_error_docref(0 TSRMLS_CC, E_ERROR, "ice_locator requires a proxy narrowed to Ice::Locator");
+ runtimeError("ice_locator requires a proxy narrowed to Ice::Locator" TSRMLS_CC);
RETURN_NULL();
}
locator = Ice::LocatorPrx::uncheckedCast(proxy);
@@ -1381,8 +818,7 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_locator)
try
{
- Ice::ObjectPrx prx = _this->getProxy()->ice_locator(locator);
- if(!createProxy(return_value, prx, _this->getClass() TSRMLS_CC))
+ if(!_this->clone(return_value, _this->proxy->ice_locator(locator) TSRMLS_CC))
{
RETURN_NULL();
}
@@ -1394,21 +830,19 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_locator)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_twoway)
+ZEND_METHOD(Ice_ObjectPrx, ice_twoway)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- Ice::ObjectPrx prx = _this->getProxy()->ice_twoway();
- if(!createProxy(return_value, prx, _this->getClass() TSRMLS_CC))
+ if(!_this->clone(return_value, _this->proxy->ice_twoway() TSRMLS_CC))
{
RETURN_NULL();
}
@@ -1420,20 +854,19 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_twoway)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_isTwoway)
+ZEND_METHOD(Ice_ObjectPrx, ice_isTwoway)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- bool b = _this->getProxy()->ice_isTwoway();
+ bool b = _this->proxy->ice_isTwoway();
RETURN_BOOL(b ? 1 : 0);
}
catch(const IceUtil::Exception& ex)
@@ -1443,21 +876,19 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_isTwoway)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_oneway)
+ZEND_METHOD(Ice_ObjectPrx, ice_oneway)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- Ice::ObjectPrx prx = _this->getProxy()->ice_oneway();
- if(!createProxy(return_value, prx, _this->getClass() TSRMLS_CC))
+ if(!_this->clone(return_value, _this->proxy->ice_oneway() TSRMLS_CC))
{
RETURN_NULL();
}
@@ -1469,20 +900,19 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_oneway)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_isOneway)
+ZEND_METHOD(Ice_ObjectPrx, ice_isOneway)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- bool b = _this->getProxy()->ice_isOneway();
+ bool b = _this->proxy->ice_isOneway();
RETURN_BOOL(b ? 1 : 0);
}
catch(const IceUtil::Exception& ex)
@@ -1492,21 +922,19 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_isOneway)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_batchOneway)
+ZEND_METHOD(Ice_ObjectPrx, ice_batchOneway)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- Ice::ObjectPrx prx = _this->getProxy()->ice_batchOneway();
- if(!createProxy(return_value, prx, _this->getClass() TSRMLS_CC))
+ if(!_this->clone(return_value, _this->proxy->ice_batchOneway() TSRMLS_CC))
{
RETURN_NULL();
}
@@ -1518,20 +946,19 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_batchOneway)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_isBatchOneway)
+ZEND_METHOD(Ice_ObjectPrx, ice_isBatchOneway)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- bool b = _this->getProxy()->ice_isBatchOneway();
+ bool b = _this->proxy->ice_isBatchOneway();
RETURN_BOOL(b ? 1 : 0);
}
catch(const IceUtil::Exception& ex)
@@ -1541,21 +968,19 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_isBatchOneway)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_datagram)
+ZEND_METHOD(Ice_ObjectPrx, ice_datagram)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- Ice::ObjectPrx prx = _this->getProxy()->ice_datagram();
- if(!createProxy(return_value, prx, _this->getClass() TSRMLS_CC))
+ if(!_this->clone(return_value, _this->proxy->ice_datagram() TSRMLS_CC))
{
RETURN_NULL();
}
@@ -1567,20 +992,19 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_datagram)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_isDatagram)
+ZEND_METHOD(Ice_ObjectPrx, ice_isDatagram)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- bool b = _this->getProxy()->ice_isDatagram();
+ bool b = _this->proxy->ice_isDatagram();
RETURN_BOOL(b ? 1 : 0);
}
catch(const IceUtil::Exception& ex)
@@ -1590,21 +1014,19 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_isDatagram)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_batchDatagram)
+ZEND_METHOD(Ice_ObjectPrx, ice_batchDatagram)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- Ice::ObjectPrx prx = _this->getProxy()->ice_batchDatagram();
- if(!createProxy(return_value, prx, _this->getClass() TSRMLS_CC))
+ if(!_this->clone(return_value, _this->proxy->ice_batchDatagram() TSRMLS_CC))
{
RETURN_NULL();
}
@@ -1616,20 +1038,19 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_batchDatagram)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_isBatchDatagram)
+ZEND_METHOD(Ice_ObjectPrx, ice_isBatchDatagram)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- bool b = _this->getProxy()->ice_isBatchDatagram();
+ bool b = _this->proxy->ice_isBatchDatagram();
RETURN_BOOL(b ? 1 : 0);
}
catch(const IceUtil::Exception& ex)
@@ -1639,16 +1060,10 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_isBatchDatagram)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_compress)
+ZEND_METHOD(Ice_ObjectPrx, ice_compress)
{
- if(ZEND_NUM_ARGS() != 1)
- {
- WRONG_PARAM_COUNT;
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
zend_bool b;
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &b) != SUCCESS)
@@ -1658,8 +1073,7 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_compress)
try
{
- Ice::ObjectPrx prx = _this->getProxy()->ice_compress(b ? true : false);
- if(!createProxy(return_value, prx, _this->getClass() TSRMLS_CC))
+ if(!_this->clone(return_value, _this->proxy->ice_compress(b ? true : false) TSRMLS_CC))
{
RETURN_NULL();
}
@@ -1671,16 +1085,10 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_compress)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_timeout)
+ZEND_METHOD(Ice_ObjectPrx, ice_timeout)
{
- if(ZEND_NUM_ARGS() != 1)
- {
- WRONG_PARAM_COUNT;
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
@@ -1690,8 +1098,7 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_timeout)
RETURN_NULL();
}
// TODO: range check?
- Ice::ObjectPrx prx = _this->getProxy()->ice_timeout(l);
- if(!createProxy(return_value, prx, _this->getClass() TSRMLS_CC))
+ if(!_this->clone(return_value, _this->proxy->ice_timeout(l) TSRMLS_CC))
{
RETURN_NULL();
}
@@ -1703,16 +1110,10 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_timeout)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_connectionId)
+ZEND_METHOD(Ice_ObjectPrx, ice_connectionId)
{
- if(ZEND_NUM_ARGS() != 1)
- {
- WRONG_PARAM_COUNT;
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
@@ -1722,8 +1123,7 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_connectionId)
{
RETURN_NULL();
}
- Ice::ObjectPrx prx = _this->getProxy()->ice_connectionId(id);
- if(!createProxy(return_value, prx, _this->getClass() TSRMLS_CC))
+ if(!_this->clone(return_value, _this->proxy->ice_connectionId(id) TSRMLS_CC))
{
RETURN_NULL();
}
@@ -1735,20 +1135,19 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_connectionId)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_getConnection)
+ZEND_METHOD(Ice_ObjectPrx, ice_getConnection)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- Ice::ConnectionPtr con = _this->getProxy()->ice_getConnection();
+ Ice::ConnectionPtr con = _this->proxy->ice_getConnection();
if(!createConnection(return_value, con TSRMLS_CC))
{
RETURN_NULL();
@@ -1761,20 +1160,19 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_getConnection)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_getCachedConnection)
+ZEND_METHOD(Ice_ObjectPrx, ice_getCachedConnection)
{
if(ZEND_NUM_ARGS() != 0)
{
WRONG_PARAM_COUNT;
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
try
{
- Ice::ConnectionPtr con = _this->getProxy()->ice_getCachedConnection();
+ Ice::ConnectionPtr con = _this->proxy->ice_getCachedConnection();
if(!con || !createConnection(return_value, con TSRMLS_CC))
{
RETURN_NULL();
@@ -1787,88 +1185,28 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_getCachedConnection)
}
}
-static bool
-lookupClass(const string& id, Slice::ClassDefPtr& def TSRMLS_DC)
+static ClassInfoPtr
+lookupClass(const string& id TSRMLS_DC)
{
- def = 0;
-
- try
+ ClassInfoPtr info = getClassInfoById(id TSRMLS_CC);
+ if(!info)
{
- Slice::TypePtr type;
- Profile* profile = static_cast<Profile*>(ICE_G(profile));
- if(profile)
- {
- type = profile->lookupType(id);
- }
-
- if(!type)
+ if(!id.empty() && id[id.size() - 1] == '*')
{
- php_error_docref(0 TSRMLS_CC, E_ERROR, "no Slice definition found for type %s", id.c_str());
- return false;
+ info = getClassInfoById(id.substr(0, id.size() - 1) TSRMLS_CC);
}
+ }
- Slice::BuiltinPtr b = Slice::BuiltinPtr::dynamicCast(type);
- if(b && b->kind() != Slice::Builtin::KindObject && b->kind() != Slice::Builtin::KindObjectProxy)
- {
- php_error_docref(0 TSRMLS_CC, E_ERROR, "type %s is not a class or interface", id.c_str());
- return false;
- }
-
- if(!b)
- {
- //
- // Allow the use of "::Type" (ClassDecl) or "::Type*" (Proxy).
- //
- Slice::ClassDeclPtr decl;
- Slice::ProxyPtr proxy = Slice::ProxyPtr::dynamicCast(type);
- if(proxy)
- {
- decl = proxy->_class();
- }
- else
- {
- decl = Slice::ClassDeclPtr::dynamicCast(type);
- }
-
- if(!decl)
- {
- php_error_docref(0 TSRMLS_CC, E_ERROR, "type %s is not a class or interface", id.c_str());
- return false;
- }
-
- if(decl->isLocal())
- {
- php_error_docref(0 TSRMLS_CC, E_ERROR, "%s is a local type", id.c_str());
- return false;
- }
-
- def = decl->definition();
- if(!def)
- {
- php_error_docref(0 TSRMLS_CC, E_ERROR, "%s is declared but not defined", id.c_str());
- return false;
- }
-
- string scoped = decl->scoped();
-
- //
- // Verify that the script has compiled the Slice definition for this type.
- //
- if(findClassScoped(scoped TSRMLS_CC) == 0)
- {
- php_error_docref(0 TSRMLS_CC, E_ERROR, "the Slice definition for type %s has not been compiled",
- scoped.c_str());
- return false;
- }
- }
+ if(info && !info->defined)
+ {
+ runtimeError("%s is declared but not defined" TSRMLS_CC, id.c_str());
}
- catch(const IceUtil::Exception& ex)
+ else if(!info)
{
- throwException(ex TSRMLS_CC);
- return false;
+ runtimeError("no definition found for class or interface %s" TSRMLS_CC, id.c_str());
}
- return true;
+ return info;
}
static void
@@ -1889,11 +1227,11 @@ do_cast(INTERNAL_FUNCTION_PARAMETERS, bool check)
int facetLen;
zval* arr = 0;
- if(zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "s|sa", &id, &idLen, &facet,
+ if(zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "s|s!a!", &id, &idLen, &facet,
&facetLen, &arr) == FAILURE)
{
facet = 0;
- if(zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "s|a", &id, &idLen, &arr) ==
+ if(zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "s|a!", &id, &idLen, &arr) ==
FAILURE)
{
php_error(E_ERROR, "%s() requires a type id followed by an optional facet and/or context",
@@ -1902,28 +1240,27 @@ do_cast(INTERNAL_FUNCTION_PARAMETERS, bool check)
}
}
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
//
// Populate the context.
//
Ice::Context ctx;
- if(arr && !extractContext(arr, ctx TSRMLS_CC))
+ if(arr && !extractStringMap(arr, ctx TSRMLS_CC))
{
RETURN_NULL();
}
try
{
- Slice::ClassDefPtr def;
- if(!lookupClass(id, def TSRMLS_CC))
+ ClassInfoPtr info = lookupClass(id TSRMLS_CC);
+ if(!info)
{
RETURN_NULL();
}
- Ice::ObjectPrx prx = _this->getProxy();
+ Ice::ObjectPrx prx = _this->proxy;
if(facet)
{
prx = prx->ice_facet(facet);
@@ -1936,19 +1273,16 @@ do_cast(INTERNAL_FUNCTION_PARAMETERS, bool check)
if(check)
{
- string scoped = def ? def->declaration()->scoped() : "::Ice::Object";
-
//
- // Verify that the object supports the requested type. We don't use id here,
- // because it might contain a proxy type (e.g., "::MyClass*").
+ // Verify that the object supports the requested type.
//
- if(!prx->ice_isA(scoped))
+ if(!prx->ice_isA(info->id))
{
RETURN_NULL();
}
}
- if(!createProxy(return_value, prx, def TSRMLS_CC))
+ if(!createProxy(return_value, prx, info, _this->communicator TSRMLS_CC))
{
RETURN_NULL();
}
@@ -1960,601 +1294,94 @@ do_cast(INTERNAL_FUNCTION_PARAMETERS, bool check)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_uncheckedCast)
+ZEND_METHOD(Ice_ObjectPrx, ice_uncheckedCast)
{
do_cast(INTERNAL_FUNCTION_PARAM_PASSTHRU, false);
}
-ZEND_FUNCTION(Ice_ObjectPrx_ice_checkedCast)
+ZEND_METHOD(Ice_ObjectPrx, ice_checkedCast)
{
do_cast(INTERNAL_FUNCTION_PARAM_PASSTHRU, true);
}
-ZEND_FUNCTION(Ice_Endpoint___construct)
-{
- php_error_docref(0 TSRMLS_CC, E_ERROR, "Ice_Endpoint cannot be instantiated");
-}
-
-ZEND_FUNCTION(Ice_Endpoint___tostring)
-{
- if(ZEND_NUM_ARGS() > 0)
- {
- WRONG_PARAM_COUNT;
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Ice::EndpointPtr* _this = static_cast<Ice::EndpointPtr*>(obj->ptr);
-
- try
- {
- string str = (*_this)->toString();
- RETURN_STRINGL(const_cast<char*>(str.c_str()), str.length(), 1);
- }
- catch(const IceUtil::Exception& ex)
- {
- throwException(ex TSRMLS_CC);
- RETURN_NULL();
- }
-}
-
-ZEND_FUNCTION(Ice_Endpoint_toString)
-{
- ZEND_FN(Ice_Endpoint___tostring)(INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-
-ZEND_FUNCTION(Ice_Connection___construct)
-{
- php_error_docref(0 TSRMLS_CC, E_ERROR, "Ice_Connection cannot be instantiated");
-}
-
-ZEND_FUNCTION(Ice_Connection___tostring)
-{
- if(ZEND_NUM_ARGS() > 0)
- {
- WRONG_PARAM_COUNT;
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Ice::ConnectionPtr* _this = static_cast<Ice::ConnectionPtr*>(obj->ptr);
-
- try
- {
- string str = (*_this)->toString();
- RETURN_STRINGL(const_cast<char*>(str.c_str()), str.length(), 1);
- }
- catch(const IceUtil::Exception& ex)
- {
- throwException(ex TSRMLS_CC);
- RETURN_NULL();
- }
-}
-
-ZEND_FUNCTION(Ice_Connection_close)
-{
- if(ZEND_NUM_ARGS() != 1)
- {
- WRONG_PARAM_COUNT;
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Ice::ConnectionPtr* _this = static_cast<Ice::ConnectionPtr*>(obj->ptr);
-
- zend_bool b;
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &b TSRMLS_CC) != SUCCESS)
- {
- RETURN_NULL();
- }
-
- try
- {
- (*_this)->close(b ? true : false);
- }
- catch(const IceUtil::Exception& ex)
- {
- throwException(ex TSRMLS_CC);
- RETURN_NULL();
- }
-}
-
-ZEND_FUNCTION(Ice_Connection_flushBatchRequests)
-{
- if(ZEND_NUM_ARGS() > 0)
- {
- WRONG_PARAM_COUNT;
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Ice::ConnectionPtr* _this = static_cast<Ice::ConnectionPtr*>(obj->ptr);
-
- try
- {
- (*_this)->flushBatchRequests();
- }
- catch(const IceUtil::Exception& ex)
- {
- throwException(ex TSRMLS_CC);
- RETURN_NULL();
- }
-}
-
-ZEND_FUNCTION(Ice_Connection_type)
-{
- if(ZEND_NUM_ARGS() > 0)
- {
- WRONG_PARAM_COUNT;
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Ice::ConnectionPtr* _this = static_cast<Ice::ConnectionPtr*>(obj->ptr);
-
- try
- {
- string str = (*_this)->type();
- RETURN_STRINGL(const_cast<char*>(str.c_str()), str.length(), 1);
- }
- catch(const IceUtil::Exception& ex)
- {
- throwException(ex TSRMLS_CC);
- RETURN_NULL();
- }
-}
-
-ZEND_FUNCTION(Ice_Connection_timeout)
-{
- if(ZEND_NUM_ARGS() != 0)
- {
- WRONG_PARAM_COUNT;
- }
-
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Ice::ConnectionPtr* _this = static_cast<Ice::ConnectionPtr*>(obj->ptr);
-
- try
- {
- Ice::Int timeout = (*_this)->timeout();
- ZVAL_LONG(return_value, static_cast<long>(timeout));
- }
- catch(const IceUtil::Exception& ex)
- {
- throwException(ex TSRMLS_CC);
- RETURN_NULL();
- }
-}
-
-ZEND_FUNCTION(Ice_Connection_toString)
-{
- ZEND_FN(Ice_Connection___tostring)(INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
-
-IcePHP::Operation::Operation(const Ice::ObjectPrx& proxy, const string& name, const Slice::OperationPtr& op,
- const Ice::CommunicatorPtr& communicator TSRMLS_DC) :
- _proxy(proxy), _name(name), _op(op), _communicator(communicator), _zendFunction(0)
+IcePHP::Proxy::Proxy(const Ice::ObjectPrx& p, const ClassInfoPtr& i, const CommunicatorInfoPtr& comm TSRMLS_DC) :
+ proxy(p), info(i), communicator(comm), connection(0), cachedConnection(0)
{
#ifdef ZTS
this->TSRMLS_C = TSRMLS_C;
#endif
- //
- // Create Marshaler objects for return type and parameters.
- //
- Slice::TypePtr ret = op->returnType();
- if(ret)
- {
- _result = Marshaler::createMarshaler(ret TSRMLS_CC);
- if(!_result)
- {
- return;
- }
- }
- Slice::ParamDeclList params = op->parameters();
-
- //
- // Create an array that indicates how arguments are passed to the operation.
//
- zend_arg_info* argInfo = new zend_arg_info[params.size()];
-
- int i;
- Slice::ParamDeclList::const_iterator p;
- for(p = params.begin(), i = 0; p != params.end(); ++p, ++i)
- {
- Slice::TypePtr paramType = (*p)->type();
- MarshalerPtr m = Marshaler::createMarshaler(paramType TSRMLS_CC);
- if(!m)
- {
- break;
- }
- _paramNames.push_back((*p)->name());
- argInfo[i].name = 0;
- argInfo[i].class_name = 0;
- argInfo[i].allow_null = 1;
- Slice::ContainedPtr cont = Slice::ContainedPtr::dynamicCast(paramType);
- if(cont)
- {
- argInfo[i].array_type_hint = ((cont->containedType() == Slice::Contained::ContainedTypeSequence ||
- cont->containedType() == Slice::Contained::ContainedTypeDictionary) ? 1 : 0);
- }
- else
- {
- argInfo[i].array_type_hint = 0;
- }
- argInfo[i].return_reference = 0;
- argInfo[i].required_num_args = static_cast<zend_uint>(params.size());
- if((*p)->isOutParam())
- {
- argInfo[i].pass_by_reference = 1;
- _outParams.push_back(m);
- }
- else
- {
- argInfo[i].pass_by_reference = 0;
- _inParams.push_back(m);
- }
- }
-
- _zendFunction = static_cast<zend_internal_function*>(emalloc(sizeof(zend_internal_function)));
- _zendFunction->type = ZEND_INTERNAL_FUNCTION;
- _zendFunction->function_name = estrndup(const_cast<char*>(name.c_str()), name.length());
- _zendFunction->scope = proxyClassEntry;
- _zendFunction->fn_flags = ZEND_ACC_PUBLIC;
- _zendFunction->prototype = 0;
- _zendFunction->num_args = static_cast<zend_uint>(params.size());
- _zendFunction->arg_info = argInfo;
- _zendFunction->pass_rest_by_reference = 0;
- _zendFunction->required_num_args = _zendFunction->num_args;
- _zendFunction->return_reference = 0;
- _zendFunction->handler = ZEND_FN(Ice_ObjectPrx_call);
-}
-
-IcePHP::Operation::~Operation()
-{
- if(_zendFunction)
- {
- delete []_zendFunction->arg_info;
- efree(_zendFunction->function_name);
- efree(_zendFunction);
- }
-}
-
-zend_function*
-IcePHP::Operation::getZendFunction() const
-{
- return reinterpret_cast<zend_function*>(_zendFunction);
-}
-
-void
-IcePHP::Operation::invoke(INTERNAL_FUNCTION_PARAMETERS)
-{
- Ice::OperationMode mode = (Ice::OperationMode)_op->sendMode();
- int i;
-
- //
- // Verify that the expected number of arguments are supplied. The context argument is optional.
- //
- int numParams = static_cast<int>(_inParams.size() + _outParams.size());
- if(ZEND_NUM_ARGS() != numParams && ZEND_NUM_ARGS() != numParams + 1)
- {
- php_error_docref(0 TSRMLS_CC, E_ERROR, "incorrect number of parameters (%d)", numParams);
- return;
- }
-
- //
- // Retrieve the arguments.
- //
- zval*** args = static_cast<zval***>(emalloc(ZEND_NUM_ARGS() * sizeof(zval**)));
- AutoEfree autoArgs(args); // Call efree on return
- if(zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE)
- {
- php_error_docref(0 TSRMLS_CC, E_ERROR, "unable to get arguments");
- return;
- }
-
- //
- // Verify that the zvals for out parameters are passed by reference.
+ // We want to ensure that the PHP object corresponding to the communicator is
+ // not destroyed until after this proxy is destroyed.
//
- for(i = static_cast<int>(_inParams.size()); i < numParams; ++i)
- {
- if(!PZVAL_IS_REF(*args[i]))
- {
- php_error_docref(0 TSRMLS_CC, E_ERROR, "argument for out parameter %s must be passed by reference",
- _paramNames[i].c_str());
- return;
- }
- }
-
- try
- {
- //
- // Marshal the arguments.
- //
- Ice::OutputStreamPtr os = Ice::createOutputStream(_communicator);
- ObjectMap objectMap;
- vector<MarshalerPtr>::iterator p;
- for(i = 0, p = _inParams.begin(); p != _inParams.end(); ++i, ++p)
- {
- if(!(*p)->marshal(*args[i], os, objectMap TSRMLS_CC))
- {
- return;
- }
- }
-
- if(_op->sendsClasses())
- {
- os->writePendingObjects();
- }
-
- Ice::ByteSeq params;
- os->finished(params);
-
- //
- // Populate the context (if necessary).
- //
- Ice::Context ctx;
- bool haveContext = false;
- if(ZEND_NUM_ARGS() == numParams + 1)
- {
- if(extractContext(*args[numParams], ctx TSRMLS_CC))
- {
- haveContext = true;
- }
- else
- {
- return;
- }
- }
-
- //
- // Invoke the operation. Don't use _name here.
- //
- Ice::ByteSeq result;
- bool status;
- if(haveContext)
- {
- status = _proxy->ice_invoke(_op->name(), mode, params, result, ctx);
- }
- else
- {
- status = _proxy->ice_invoke(_op->name(), mode, params, result);
- }
-
- //
- // Process the reply.
- //
- if(_proxy->ice_isTwoway())
- {
- Ice::InputStreamPtr is = Ice::createInputStream(_communicator, result);
-
- if(status)
- {
- //
- // Unmarshal the results.
- //
- // TODO: Check for oneway/datagram errors
- //
- for(i = _inParams.size(), p = _outParams.begin(); p != _outParams.end(); ++i, ++p)
- {
- //
- // We must explicitly destroy the existing contents of all zvals passed
- // as out parameters, otherwise leaks occur.
- //
- zval_dtor(*args[i]);
- if(!(*p)->unmarshal(*args[i], is TSRMLS_CC))
- {
- return;
- }
- }
- if(_result)
- {
- if(!_result->unmarshal(return_value, is TSRMLS_CC))
- {
- return;
- }
- }
- if(_op->returnsClasses())
- {
- is->readPendingObjects();
- }
- }
- else
- {
- //
- // Unmarshal and "throw" a user exception.
- //
- throwUserException(is TSRMLS_CC);
- }
- }
- }
- catch(const AbortMarshaling&)
- {
- //
- // We use AbortMarshaling to escape from any nesting depth if
- // a PHP exception has already been set.
- //
- assert(EG(exception));
- }
- catch(const IceUtil::Exception& ex)
- {
- throwException(ex TSRMLS_CC);
- }
+ communicator->addRef(TSRMLS_C);
}
-void
-IcePHP::Operation::throwUserException(Ice::InputStreamPtr& is TSRMLS_DC)
+IcePHP::Proxy::~Proxy()
{
- Slice::UnitPtr unit = _op->unit();
-
- is->readBool(); // usesClasses
-
- string id = is->readString();
- const string origId = id;
-
- while(!id.empty())
+ communicator->decRef(TSRMLS_C);
+ if(connection)
{
- //
- // Look for a definition of this type.
- //
- Slice::ExceptionPtr ex = unit->lookupException(id, false);
- if(ex)
- {
- if(ex->isLocal())
- {
- php_error_docref(0 TSRMLS_CC, E_ERROR, "cannot unmarshal local exception %s", id.c_str());
- return;
- }
-
- MarshalerPtr m = Marshaler::createExceptionMarshaler(ex TSRMLS_CC);
- assert(m);
-
- zval* zex;
- MAKE_STD_ZVAL(zex);
- if(m->unmarshal(zex, is TSRMLS_CC))
- {
- if(ex->usesClasses())
- {
- is->readPendingObjects();
- }
- zend_throw_exception_object(zex TSRMLS_CC);
- }
- else
- {
- zval_dtor(zex);
- }
-
- return;
- }
- else
- {
- is->skipSlice();
-
- try
- {
- id = is->readString();
- }
- catch(Ice::UnmarshalOutOfBoundsException& ex)
- {
- //
- // When readString raises this exception it means we've reached the last slice,
- // so we set the reason member to a more helpful value.
- //
- ex.reason = "unknown exception type `" + origId + "'";
- throw;
- }
- }
+ zval_ptr_dtor(&connection);
}
- //
- // Getting here should be impossible: we can get here only if the
- // sender has marshaled a sequence of type IDs, none of which we
- // have a factory for. This means that sender and receiver disagree
- // about the Slice definitions they use.
- //
- throw Ice::UnknownUserException(__FILE__, __LINE__);
-}
-
-IcePHP::Proxy::Proxy(const Ice::ObjectPrx& proxy, const Slice::ClassDefPtr& cls TSRMLS_DC) :
- _proxy(proxy), _class(cls)
-{
-#ifdef ZTS
- this->TSRMLS_C = TSRMLS_C;
-#endif
-
- //
- // We want to ensure that the PHP object corresponding to the communicator is
- // not destroyed until after this proxy is destroyed. We keep a copy of the
- // communicator's zval because the symbol table holding the communicator's zval
- // may be destroyed before this proxy, therefore our destructor cannot rely on
- // symbol table lookup when it needs to decrement the reference count.
- //
- zval* zc = getCommunicatorZval(TSRMLS_C);
- _communicatorZval = *zc; // This is legal - it simply copies the object's handle
- Z_OBJ_HT(_communicatorZval)->add_ref(&_communicatorZval TSRMLS_CC);
-
- _communicator = getCommunicator(TSRMLS_C);
-
- if(cls)
+ if(cachedConnection)
{
- _classOps = _class->allOperations();
+ zval_ptr_dtor(&cachedConnection);
}
}
-IcePHP::Proxy::~Proxy()
-{
- //
- // In order to avoid the communicator's "leak warning", we have to ensure that we
- // remove any references to the communicator or its supporting objects. This must
- // be done prior to invoking del_ref(), because the C++ communicator object may
- // be destroyed during this call.
- //
- _communicator = 0;
- _ops.clear();
- _proxy = 0;
- Z_OBJ_HT(_communicatorZval)->del_ref(&_communicatorZval TSRMLS_CC);
-}
-
-const Ice::ObjectPrx&
-IcePHP::Proxy::getProxy() const
+bool
+IcePHP::Proxy::clone(zval* zv, const Ice::ObjectPrx& p TSRMLS_DC)
{
- return _proxy;
+ return create(zv, p, info, communicator TSRMLS_CC);
}
-const Slice::ClassDefPtr&
-IcePHP::Proxy::getClass() const
+bool
+IcePHP::Proxy::cloneUntyped(zval* zv, const Ice::ObjectPrx& p TSRMLS_DC)
{
- return _class;
+ return create(zv, p, 0, communicator TSRMLS_CC);
}
-OperationPtr
-IcePHP::Proxy::getOperation(const string& name)
+bool
+IcePHP::Proxy::create(zval* zv, const Ice::ObjectPrx& p, const ClassInfoPtr& info, const CommunicatorInfoPtr& comm
+ TSRMLS_DC)
{
- OperationPtr result;
-
- string n = lowerCase(name);
- map<string, OperationPtr>::const_iterator p = _ops.find(n);
- if(p == _ops.end())
+ ClassInfoPtr cls = info;
+ if(!cls)
{
- for(Slice::OperationList::const_iterator q = _classOps.begin(); q != _classOps.end(); ++q)
- {
- string opName = lowerCase(fixIdent((*q)->name()));
- if(n == opName)
- {
- result = new Operation(_proxy, opName, *q, _communicator TSRMLS_CC);
- _ops[opName] = result;
- break;
- }
- }
+ cls = getClassInfoById("::Ice::Object" TSRMLS_CC);
+ assert(cls);
}
- else
+
+ if(object_init_ex(zv, proxyClassEntry) != SUCCESS)
{
- result = p->second;
+ runtimeError("unable to initialize proxy" TSRMLS_CC);
+ return false;
}
- return result;
-}
+ Wrapper<ProxyPtr>* obj = Wrapper<ProxyPtr>::extract(zv TSRMLS_CC);
+ ProxyPtr proxy = new Proxy(p, cls, comm TSRMLS_CC);
+ assert(!obj->ptr);
+ obj->ptr = new ProxyPtr(proxy);
-string
-IcePHP::Proxy::toString() const
-{
- return _communicator->proxyToString(_proxy);
+ return true;
}
#ifdef _WIN32
extern "C"
#endif
static zend_object_value
-handleProxyAlloc(zend_class_entry* ce TSRMLS_DC)
+handleAlloc(zend_class_entry* ce TSRMLS_DC)
{
zend_object_value result;
- ice_object* obj = newObject(ce TSRMLS_CC);
+ Wrapper<ProxyPtr>* obj = Wrapper<ProxyPtr>::create(ce TSRMLS_CC);
assert(obj);
- result.handle = zend_objects_store_put(obj, 0, (zend_objects_free_object_storage_t)handleProxyFreeStorage,
+ result.handle = zend_objects_store_put(obj, 0, (zend_objects_free_object_storage_t)handleFreeStorage,
0 TSRMLS_CC);
- result.handlers = &_proxyHandlers;
+ result.handlers = &_handlers;
return result;
}
@@ -2563,13 +1390,10 @@ handleProxyAlloc(zend_class_entry* ce TSRMLS_DC)
extern "C"
#endif
static void
-handleProxyFreeStorage(void* p TSRMLS_DC)
+handleFreeStorage(void* p TSRMLS_DC)
{
- ice_object* obj = static_cast<ice_object*>(p);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
-
- delete _this;
-
+ Wrapper<ProxyPtr>* obj = static_cast<Wrapper<ProxyPtr>*>(p);
+ delete obj->ptr;
zend_objects_free_object_storage(static_cast<zend_object*>(p) TSRMLS_CC);
}
@@ -2577,7 +1401,7 @@ handleProxyFreeStorage(void* p TSRMLS_DC)
extern "C"
#endif
static zend_object_value
-handleProxyClone(zval* zv TSRMLS_DC)
+handleClone(zval* zv TSRMLS_DC)
{
//
// Create a new object that shares a C++ proxy instance with this object.
@@ -2586,22 +1410,16 @@ handleProxyClone(zval* zv TSRMLS_DC)
zend_object_value result;
memset(&result, 0, sizeof(zend_object_value));
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(zv TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr obj = Wrapper<ProxyPtr>::value(zv TSRMLS_CC);
+ assert(obj);
zval* clone;
MAKE_STD_ZVAL(clone);
- if(object_init_ex(clone, IcePHP::proxyClassEntry) != SUCCESS)
+ if(!obj->clone(clone, obj->proxy TSRMLS_CC))
{
- php_error_docref(0 TSRMLS_CC, E_ERROR, "unable to initialize proxy");
return result;
}
- ice_object* cobj = static_cast<ice_object*>(zend_object_store_get_object(clone TSRMLS_CC));
- assert(!cobj->ptr);
- cobj->ptr = new Proxy(_this->getProxy(), _this->getClass() TSRMLS_CC);
-
//
// We only need to return the new object's handle, so we must destroy the zval containing
// a reference to the new object. We increment the object's reference count to ensure it
@@ -2619,7 +1437,7 @@ handleProxyClone(zval* zv TSRMLS_DC)
extern "C"
#endif
static union _zend_function*
-handleProxyGetMethod(zval** zv, char* method, int len TSRMLS_DC)
+handleGetMethod(zval** zv, char* method, int len TSRMLS_DC)
{
zend_function* result;
@@ -2631,27 +1449,23 @@ handleProxyGetMethod(zval** zv, char* method, int len TSRMLS_DC)
result = zend_get_std_object_handlers()->get_method(zv, method, len TSRMLS_CC);
if(!result)
{
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(*zv TSRMLS_CC));
+ Wrapper<ProxyPtr>* obj = Wrapper<ProxyPtr>::extract(*zv TSRMLS_CC);
assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
+ ProxyPtr _this = *obj->ptr;
- Slice::ClassDefPtr def = _this->getClass();
- if(!def)
- {
- php_error_docref(0 TSRMLS_CC, E_ERROR, "unknown method %s invoked on untyped proxy", method);
- return 0;
- }
+ ClassInfoPtr info = _this->info;
+ assert(info);
- OperationPtr op = _this->getOperation(method);
+ OperationPtr op = info->getOperation(method);
if(!op)
{
- string scoped = def->scoped();
- php_error_docref(0 TSRMLS_CC, E_ERROR, "unknown operation %s invoked on proxy of type %s", method,
- scoped.c_str());
+ //
+ // Returning 0 causes PHP to report an "undefined method" error.
+ //
return 0;
}
- result = op->getZendFunction();
+ result = op->function();
}
return result;
@@ -2661,21 +1475,21 @@ handleProxyGetMethod(zval** zv, char* method, int len TSRMLS_DC)
extern "C"
#endif
static int
-handleProxyCompare(zval* zobj1, zval* zobj2 TSRMLS_DC)
+handleCompare(zval* zobj1, zval* zobj2 TSRMLS_DC)
{
//
// PHP guarantees that the objects have the same class.
//
- ice_object* obj1 = static_cast<ice_object*>(zend_object_store_get_object(zobj1 TSRMLS_CC));
+ Wrapper<ProxyPtr>* obj1 = Wrapper<ProxyPtr>::extract(zobj1 TSRMLS_CC);
assert(obj1->ptr);
- Proxy* _this1 = static_cast<Proxy*>(obj1->ptr);
- Ice::ObjectPrx prx1 = _this1->getProxy();
+ ProxyPtr _this1 = *obj1->ptr;
+ Ice::ObjectPrx prx1 = _this1->proxy;
- ice_object* obj2 = static_cast<ice_object*>(zend_object_store_get_object(zobj2 TSRMLS_CC));
+ Wrapper<ProxyPtr>* obj2 = Wrapper<ProxyPtr>::extract(zobj2 TSRMLS_CC);
assert(obj2->ptr);
- Proxy* _this2 = static_cast<Proxy*>(obj2->ptr);
- Ice::ObjectPrx prx2 = _this2->getProxy();
+ ProxyPtr _this2 = *obj2->ptr;
+ Ice::ObjectPrx prx2 = _this2->proxy;
if(prx1 == prx2)
{
@@ -2691,112 +1505,122 @@ handleProxyCompare(zval* zobj1, zval* zobj2 TSRMLS_DC)
}
}
-ZEND_FUNCTION(Ice_ObjectPrx_call)
+//
+// Predefined methods for ObjectPrx.
+//
+static function_entry _proxyMethods[] =
{
- ice_object* obj = static_cast<ice_object*>(zend_object_store_get_object(getThis() TSRMLS_CC));
- assert(obj->ptr);
- Proxy* _this = static_cast<Proxy*>(obj->ptr);
-
- OperationPtr op = _this->getOperation(get_active_function_name(TSRMLS_C));
- assert(op); // handleGetethod should have already verified the operation's existence.
-
- op->invoke(INTERNAL_FUNCTION_PARAM_PASSTHRU);
-}
+ ZEND_ME(Ice_ObjectPrx, __construct, NULL, ZEND_ACC_PRIVATE|ZEND_ACC_CTOR)
+ ZEND_ME(Ice_ObjectPrx, __toString, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_getCommunicator, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_toString, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_getIdentity, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_identity, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_getContext, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_context, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_getFacet, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_facet, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_getAdapterId, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_adapterId, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_getEndpoints, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_endpoints, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_getLocatorCacheTimeout, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_locatorCacheTimeout, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_isConnectionCached, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_connectionCached, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_getEndpointSelection, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_endpointSelection, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_isSecure, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_secure, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_isPreferSecure, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_preferSecure, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_getRouter, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_router, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_getLocator, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_locator, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_twoway, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_isTwoway, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_oneway, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_isOneway, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_batchOneway, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_isBatchOneway, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_datagram, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_isDatagram, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_batchDatagram, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_isBatchDatagram, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_compress, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_timeout, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_connectionId, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_getConnection, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_getCachedConnection, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_uncheckedCast, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_ObjectPrx, ice_checkedCast, NULL, ZEND_ACC_PUBLIC)
+ {0, 0, 0}
+};
-#ifdef _WIN32
-extern "C"
-#endif
-static zend_object_value
-handleEndpointAlloc(zend_class_entry* ce TSRMLS_DC)
+bool
+IcePHP::proxyInit(TSRMLS_D)
{
- zend_object_value result;
-
- ice_object* obj = newObject(ce TSRMLS_CC);
- assert(obj);
-
- result.handle = zend_objects_store_put(obj, 0, (zend_objects_free_object_storage_t)handleEndpointFreeStorage,
- 0 TSRMLS_CC);
- result.handlers = &_endpointHandlers;
+ //
+ // Register the ObjectPrx class.
+ //
+ zend_class_entry ce;
+#ifdef ICEPHP_USE_NAMESPACES
+ INIT_NS_CLASS_ENTRY(ce, STRCAST("Ice"), STRCAST("ObjectPrx"), _proxyMethods);
+#else
+ INIT_CLASS_ENTRY(ce, "Ice_ObjectPrx", _proxyMethods);
+#endif
+ ce.create_object = handleAlloc;
+ proxyClassEntry = zend_register_internal_class(&ce TSRMLS_CC);
+ //proxyClassEntry->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS;
+ memcpy(&_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ _handlers.clone_obj = handleClone;
+ _handlers.get_method = handleGetMethod;
+ _handlers.compare_objects = handleCompare;
- return result;
+ return true;
}
-#ifdef _WIN32
-extern "C"
-#endif
-static void
-handleEndpointFreeStorage(void* p TSRMLS_DC)
+bool
+IcePHP::createProxy(zval* zv, const Ice::ObjectPrx& p, const CommunicatorInfoPtr& comm TSRMLS_DC)
{
- ice_object* obj = static_cast<ice_object*>(p);
- Ice::EndpointPtr* _this = static_cast<Ice::EndpointPtr*>(obj->ptr);
-
- delete _this;
-
- zend_objects_free_object_storage(static_cast<zend_object*>(p) TSRMLS_CC);
+ return Proxy::create(zv, p, 0, comm TSRMLS_CC);
}
-#ifdef _WIN32
-extern "C"
-#endif
-static zend_object_value
-handleConnectionAlloc(zend_class_entry* ce TSRMLS_DC)
+bool
+IcePHP::createProxy(zval* zv, const Ice::ObjectPrx& p, const ClassInfoPtr& info, const CommunicatorInfoPtr& comm
+ TSRMLS_DC)
{
- zend_object_value result;
-
- ice_object* obj = newObject(ce TSRMLS_CC);
- assert(obj);
-
- result.handle = zend_objects_store_put(obj, 0, (zend_objects_free_object_storage_t)handleConnectionFreeStorage,
- 0 TSRMLS_CC);
- result.handlers = &_connectionHandlers;
-
- return result;
+ return Proxy::create(zv, p, info, comm TSRMLS_CC);
}
-#ifdef _WIN32
-extern "C"
-#endif
-static void
-handleConnectionFreeStorage(void* p TSRMLS_DC)
+bool
+IcePHP::fetchProxy(zval* zv, Ice::ObjectPrx& prx, ClassInfoPtr& cls TSRMLS_DC)
{
- ice_object* obj = static_cast<ice_object*>(p);
- Ice::ConnectionPtr* _this = static_cast<Ice::ConnectionPtr*>(obj->ptr);
-
- delete _this;
-
- zend_objects_free_object_storage(static_cast<zend_object*>(p) TSRMLS_CC);
+ CommunicatorInfoPtr comm;
+ return fetchProxy(zv, prx, cls, comm TSRMLS_CC);
}
-#ifdef _WIN32
-extern "C"
-#endif
-static int
-handleConnectionCompare(zval* zobj1, zval* zobj2 TSRMLS_DC)
+bool
+IcePHP::fetchProxy(zval* zv, Ice::ObjectPrx& prx, ClassInfoPtr& cls, CommunicatorInfoPtr& comm TSRMLS_DC)
{
- //
- // PHP guarantees that the objects have the same class.
- //
-
- ice_object* obj1 = static_cast<ice_object*>(zend_object_store_get_object(zobj1 TSRMLS_CC));
- assert(obj1->ptr);
- Ice::ConnectionPtr* _this1 = static_cast<Ice::ConnectionPtr*>(obj1->ptr);
- Ice::ConnectionPtr con1 = *_this1;
-
- ice_object* obj2 = static_cast<ice_object*>(zend_object_store_get_object(zobj2 TSRMLS_CC));
- assert(obj2->ptr);
- Ice::ConnectionPtr* _this2 = static_cast<Ice::ConnectionPtr*>(obj2->ptr);
- Ice::ConnectionPtr con2 = *_this2;
-
- if(con1 == con2)
- {
- return 0;
- }
- else if(con1 < con2)
- {
- return -1;
- }
- else
+ if(!ZVAL_IS_NULL(zv))
{
- return 1;
+ if(Z_TYPE_P(zv) != IS_OBJECT || Z_OBJCE_P(zv) != proxyClassEntry)
+ {
+ invalidArgument("value is not a proxy" TSRMLS_CC);
+ return false;
+ }
+ Wrapper<ProxyPtr>* obj = Wrapper<ProxyPtr>::extract(zv TSRMLS_CC);
+ if(!obj)
+ {
+ runtimeError("unable to retrieve proxy object from object store" TSRMLS_CC);
+ return false;
+ }
+ assert(obj->ptr);
+ prx = (*obj->ptr)->proxy;
+ cls = (*obj->ptr)->info;
+ comm = (*obj->ptr)->communicator;
}
+ return true;
}