summaryrefslogtreecommitdiff
path: root/php/src/php5/Connection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'php/src/php5/Connection.cpp')
-rw-r--r--php/src/php5/Connection.cpp162
1 files changed, 94 insertions, 68 deletions
diff --git a/php/src/php5/Connection.cpp b/php/src/php5/Connection.cpp
index bf0c57307c2..8a894b2457a 100644
--- a/php/src/php5/Connection.cpp
+++ b/php/src/php5/Connection.cpp
@@ -29,7 +29,6 @@ static zend_class_entry* tcpConnectionInfoClassEntry = 0;
static zend_class_entry* udpConnectionInfoClassEntry = 0;
static zend_class_entry* wsConnectionInfoClassEntry = 0;
static zend_class_entry* sslConnectionInfoClassEntry = 0;
-static zend_class_entry* wssConnectionInfoClassEntry = 0;
//
// Ice::Connection support.
@@ -79,15 +78,22 @@ ZEND_METHOD(Ice_Connection, close)
Ice::ConnectionPtr _this = Wrapper<Ice::ConnectionPtr>::value(getThis() TSRMLS_CC);
assert(_this);
- zend_bool b;
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, const_cast<char*>("b"), &b TSRMLS_CC) != SUCCESS)
+ zval* mode;
+ if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, const_cast<char*>("z"), &mode TSRMLS_CC) != SUCCESS)
{
RETURN_NULL();
}
+ if(Z_TYPE_P(mode) != IS_LONG)
+ {
+ invalidArgument("value for 'mode' argument must be an enumerator of ConnectionClose" TSRMLS_CC);
+ RETURN_NULL();
+ }
+ Ice::ConnectionClose cc = static_cast<Ice::ConnectionClose>(Z_LVAL_P(mode));
+
try
{
- _this->close(b ? true : false);
+ _this->close(cc);
}
catch(const IceUtil::Exception& ex)
{
@@ -122,6 +128,35 @@ ZEND_METHOD(Ice_Connection, getEndpoint)
ZEND_METHOD(Ice_Connection, flushBatchRequests)
{
+ zval* compress;
+ if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, const_cast<char*>("z"), &compress TSRMLS_CC) != SUCCESS)
+ {
+ RETURN_NULL();
+ }
+
+ if(Z_TYPE_P(compress) != IS_LONG)
+ {
+ invalidArgument("value for 'compress' argument must be an enumerator of CompressBatch" TSRMLS_CC);
+ RETURN_NULL();
+ }
+ Ice::CompressBatch cb = static_cast<Ice::CompressBatch>(Z_LVAL_P(compress));
+
+ Ice::ConnectionPtr _this = Wrapper<Ice::ConnectionPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
+
+ try
+ {
+ _this->flushBatchRequests(cb);
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ throwException(ex TSRMLS_CC);
+ RETURN_NULL();
+ }
+}
+
+ZEND_METHOD(Ice_Connection, heartbeat)
+{
if(ZEND_NUM_ARGS() > 0)
{
WRONG_PARAM_COUNT;
@@ -132,7 +167,7 @@ ZEND_METHOD(Ice_Connection, flushBatchRequests)
try
{
- _this->flushBatchRequests();
+ _this->heartbeat();
}
catch(const IceUtil::Exception& ex)
{
@@ -407,18 +442,19 @@ static zend_function_entry _interfaceMethods[] =
};
static zend_function_entry _connectionClassMethods[] =
{
- ZEND_ME(Ice_Connection, __construct, NULL, ZEND_ACC_PRIVATE|ZEND_ACC_CTOR)
- ZEND_ME(Ice_Connection, __toString, NULL, ZEND_ACC_PUBLIC)
- ZEND_ME(Ice_Connection, close, NULL, ZEND_ACC_PUBLIC)
- ZEND_ME(Ice_Connection, getEndpoint, NULL, ZEND_ACC_PUBLIC)
- ZEND_ME(Ice_Connection, flushBatchRequests, NULL, ZEND_ACC_PUBLIC)
- ZEND_ME(Ice_Connection, setACM, NULL, ZEND_ACC_PUBLIC)
- ZEND_ME(Ice_Connection, getACM, NULL, ZEND_ACC_PUBLIC)
- ZEND_ME(Ice_Connection, type, NULL, ZEND_ACC_PUBLIC)
- ZEND_ME(Ice_Connection, timeout, NULL, ZEND_ACC_PUBLIC)
- ZEND_ME(Ice_Connection, toString, NULL, ZEND_ACC_PUBLIC)
- ZEND_ME(Ice_Connection, getInfo, NULL, ZEND_ACC_PUBLIC)
- ZEND_ME(Ice_Connection, setBufferSize, NULL, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_Connection, __construct, ICE_NULLPTR, ZEND_ACC_PRIVATE|ZEND_ACC_CTOR)
+ ZEND_ME(Ice_Connection, __toString, ICE_NULLPTR, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_Connection, close, ICE_NULLPTR, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_Connection, getEndpoint, ICE_NULLPTR, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_Connection, flushBatchRequests, ICE_NULLPTR, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_Connection, heartbeat, ICE_NULLPTR, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_Connection, setACM, ICE_NULLPTR, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_Connection, getACM, ICE_NULLPTR, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_Connection, type, ICE_NULLPTR, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_Connection, timeout, ICE_NULLPTR, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_Connection, toString, ICE_NULLPTR, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_Connection, getInfo, ICE_NULLPTR, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_Connection, setBufferSize, ICE_NULLPTR, ZEND_ACC_PUBLIC)
{0, 0, 0}
};
@@ -432,7 +468,7 @@ ZEND_METHOD(Ice_ConnectionInfo, __construct)
//
static zend_function_entry _connectionInfoClassMethods[] =
{
- ZEND_ME(Ice_ConnectionInfo, __construct, NULL, ZEND_ACC_PRIVATE|ZEND_ACC_CTOR)
+ ZEND_ME(Ice_ConnectionInfo, __construct, ICE_NULLPTR, ZEND_ACC_PRIVATE|ZEND_ACC_CTOR)
{0, 0, 0}
};
//
@@ -512,6 +548,8 @@ IcePHP::connectionInit(TSRMLS_D)
ce.create_object = handleConnectionInfoAlloc;
connectionInfoClassEntry = zend_register_internal_class(&ce TSRMLS_CC);
memcpy(&_connectionInfoHandlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ zend_declare_property_null(connectionInfoClassEntry, STRCAST("underlying"), sizeof("underlying") - 1,
+ ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_bool(connectionInfoClassEntry, STRCAST("incoming"), sizeof("incoming") - 1, 0,
ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_string(connectionInfoClassEntry, STRCAST("adapterName"), sizeof("adapterName") - 1,
@@ -521,12 +559,12 @@ IcePHP::connectionInit(TSRMLS_D)
// Register the IPConnectionInfo class.
//
#ifdef ICEPHP_USE_NAMESPACES
- INIT_NS_CLASS_ENTRY(ce, "Ice", "IPConnectionInfo", NULL);
+ INIT_NS_CLASS_ENTRY(ce, "Ice", "IPConnectionInfo", ICE_NULLPTR);
#else
- INIT_CLASS_ENTRY(ce, "Ice_IPConnectionInfo", NULL);
+ INIT_CLASS_ENTRY(ce, "Ice_IPConnectionInfo", ICE_NULLPTR);
#endif
ce.create_object = handleConnectionInfoAlloc;
- ipConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, connectionInfoClassEntry, NULL TSRMLS_CC);
+ ipConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, connectionInfoClassEntry, ICE_NULLPTR TSRMLS_CC);
zend_declare_property_string(ipConnectionInfoClassEntry, STRCAST("localAddress"), sizeof("localAddress") - 1,
STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_long(ipConnectionInfoClassEntry, STRCAST("localPort"), sizeof("localPort") - 1, 0,
@@ -540,23 +578,23 @@ IcePHP::connectionInit(TSRMLS_D)
// Register the TCPConnectionInfo class.
//
#ifdef ICEPHP_USE_NAMESPACES
- INIT_NS_CLASS_ENTRY(ce, "Ice", "TCPConnectionInfo", NULL);
+ INIT_NS_CLASS_ENTRY(ce, "Ice", "TCPConnectionInfo", ICE_NULLPTR);
#else
- INIT_CLASS_ENTRY(ce, "Ice_TCPConnectionInfo", NULL);
+ INIT_CLASS_ENTRY(ce, "Ice_TCPConnectionInfo", ICE_NULLPTR);
#endif
ce.create_object = handleConnectionInfoAlloc;
- tcpConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, ipConnectionInfoClassEntry, NULL TSRMLS_CC);
+ tcpConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, ipConnectionInfoClassEntry, ICE_NULLPTR TSRMLS_CC);
//
// Register the UDPConnectionInfo class.
//
#ifdef ICEPHP_USE_NAMESPACES
- INIT_NS_CLASS_ENTRY(ce, "Ice", "UDPConnectionInfo", NULL);
+ INIT_NS_CLASS_ENTRY(ce, "Ice", "UDPConnectionInfo", ICE_NULLPTR);
#else
- INIT_CLASS_ENTRY(ce, "Ice_UDPConnectionInfo", NULL);
+ INIT_CLASS_ENTRY(ce, "Ice_UDPConnectionInfo", ICE_NULLPTR);
#endif
ce.create_object = handleConnectionInfoAlloc;
- udpConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, ipConnectionInfoClassEntry, NULL TSRMLS_CC);
+ udpConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, ipConnectionInfoClassEntry, ICE_NULLPTR TSRMLS_CC);
zend_declare_property_string(udpConnectionInfoClassEntry, STRCAST("mcastAddress"), sizeof("mcastAddress") - 1,
STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_long(udpConnectionInfoClassEntry, STRCAST("mcastPort"), sizeof("mcastPort") - 1, 0,
@@ -566,12 +604,12 @@ IcePHP::connectionInit(TSRMLS_D)
// Register the WSConnectionInfo class.
//
#ifdef ICEPHP_USE_NAMESPACES
- INIT_NS_CLASS_ENTRY(ce, "Ice", "WSConnectionInfo", NULL);
+ INIT_NS_CLASS_ENTRY(ce, "Ice", "WSConnectionInfo", ICE_NULLPTR);
#else
- INIT_CLASS_ENTRY(ce, "Ice_WSConnectionInfo", NULL);
+ INIT_CLASS_ENTRY(ce, "Ice_WSConnectionInfo", ICE_NULLPTR);
#endif
ce.create_object = handleConnectionInfoAlloc;
- wsConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, ipConnectionInfoClassEntry, NULL TSRMLS_CC);
+ wsConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, connectionInfoClassEntry, ICE_NULLPTR TSRMLS_CC);
zend_declare_property_string(wsConnectionInfoClassEntry, STRCAST("headers"), sizeof("headers") - 1,
STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC);
@@ -579,12 +617,12 @@ IcePHP::connectionInit(TSRMLS_D)
// Register the SSLConnectionInfo class.
//
#ifdef ICEPHP_USE_NAMESPACES
- INIT_NS_CLASS_ENTRY(ce, "Ice", "SSLConnectionInfo", NULL);
+ INIT_NS_CLASS_ENTRY(ce, "Ice", "SSLConnectionInfo", ICE_NULLPTR);
#else
- INIT_CLASS_ENTRY(ce, "Ice_SSLConnectionInfo", NULL);
+ INIT_CLASS_ENTRY(ce, "Ice_SSLConnectionInfo", ICE_NULLPTR);
#endif
ce.create_object = handleConnectionInfoAlloc;
- sslConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, ipConnectionInfoClassEntry, NULL TSRMLS_CC);
+ sslConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, connectionInfoClassEntry, ICE_NULLPTR TSRMLS_CC);
zend_declare_property_string(sslConnectionInfoClassEntry, STRCAST("cipher"), sizeof("cipher") - 1,
STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_string(sslConnectionInfoClassEntry, STRCAST("certs"), sizeof("certs") - 1,
@@ -592,20 +630,6 @@ IcePHP::connectionInit(TSRMLS_D)
zend_declare_property_bool(sslConnectionInfoClassEntry, STRCAST("verified"), sizeof("verified") - 1, 0,
ZEND_ACC_PUBLIC TSRMLS_CC);
- //
- // Register the WSConnectionInfo class.
- //
-#ifdef ICEPHP_USE_NAMESPACES
- INIT_NS_CLASS_ENTRY(ce, "Ice", "WSSConnectionInfo", NULL);
-#else
- INIT_CLASS_ENTRY(ce, "Ice_WSSConnectionInfo", NULL);
-#endif
- ce.create_object = handleConnectionInfoAlloc;
- wssConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, sslConnectionInfoClassEntry, NULL TSRMLS_CC);
- zend_declare_property_string(wssConnectionInfoClassEntry, STRCAST("headers"), sizeof("headers") - 1,
- STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC);
-
-
return true;
}
@@ -653,6 +677,12 @@ IcePHP::fetchConnection(zval* zv, Ice::ConnectionPtr& connection TSRMLS_DC)
bool
IcePHP::createConnectionInfo(zval* zv, const Ice::ConnectionInfoPtr& p TSRMLS_DC)
{
+ if(!p)
+ {
+ ZVAL_NULL(zv);
+ return true;
+ }
+
int status;
if(Ice::WSConnectionInfoPtr::dynamicCast(p))
{
@@ -674,7 +704,12 @@ IcePHP::createConnectionInfo(zval* zv, const Ice::ConnectionInfoPtr& p TSRMLS_DC
}
else if(Ice::TCPConnectionInfoPtr::dynamicCast(p))
{
- status = object_init_ex(zv, tcpConnectionInfoClassEntry);
+ Ice::TCPConnectionInfoPtr info = Ice::TCPConnectionInfoPtr::dynamicCast(p);
+ if((status = object_init_ex(zv, tcpConnectionInfoClassEntry)) == SUCCESS)
+ {
+ add_property_long(zv, STRCAST("rcvSize"), static_cast<long>(info->rcvSize));
+ add_property_long(zv, STRCAST("sndSize"), static_cast<long>(info->sndSize));
+ }
}
else if(Ice::UDPConnectionInfoPtr::dynamicCast(p))
{
@@ -683,24 +718,8 @@ IcePHP::createConnectionInfo(zval* zv, const Ice::ConnectionInfoPtr& p TSRMLS_DC
{
add_property_string(zv, STRCAST("mcastAddress"), const_cast<char*>(info->mcastAddress.c_str()), 1);
add_property_long(zv, STRCAST("mcastPort"), static_cast<long>(info->mcastPort));
- }
- }
- else if(IceSSL::WSSConnectionInfoPtr::dynamicCast(p))
- {
- IceSSL::WSSConnectionInfoPtr info = IceSSL::WSSConnectionInfoPtr::dynamicCast(p);
- if((status = object_init_ex(zv, wssConnectionInfoClassEntry)) == SUCCESS)
- {
- zval* zmap;
- MAKE_STD_ZVAL(zmap);
- AutoDestroy mapDestroyer(zmap);
- if(createStringMap(zmap, info->headers TSRMLS_CC))
- {
- add_property_zval(zv, STRCAST("headers"), zmap);
- }
- else
- {
- return false;
- }
+ add_property_long(zv, STRCAST("rcvSize"), static_cast<long>(info->rcvSize));
+ add_property_long(zv, STRCAST("sndSize"), static_cast<long>(info->sndSize));
}
}
else if(IceSSL::ConnectionInfoPtr::dynamicCast(p))
@@ -750,10 +769,17 @@ IcePHP::createConnectionInfo(zval* zv, const Ice::ConnectionInfoPtr& p TSRMLS_DC
add_property_long(zv, STRCAST("remotePort"), static_cast<long>(info->remotePort));
}
+ zval* underlying;
+ MAKE_STD_ZVAL(underlying);
+ AutoDestroy underlyingDestroyer(underlying);
+ if(!createConnectionInfo(underlying, p->underlying TSRMLS_CC))
+ {
+ runtimeError("unable to initialize connection info" TSRMLS_CC);
+ return false;
+ }
+ add_property_zval(zv, STRCAST("underlying"), underlying);
add_property_bool(zv, STRCAST("incoming"), p->incoming ? 1 : 0);
add_property_string(zv, STRCAST("adapterName"), const_cast<char*>(p->adapterName.c_str()), 1);
- add_property_long(zv, STRCAST("rcvSize"), static_cast<long>(p->rcvSize));
- add_property_long(zv, STRCAST("sndSize"), static_cast<long>(p->sndSize));
Wrapper<Ice::ConnectionInfoPtr>* obj = Wrapper<Ice::ConnectionInfoPtr>::extract(zv TSRMLS_CC);
assert(obj);