diff options
author | Mark Spruiell <mes@zeroc.com> | 2003-11-06 18:10:53 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2003-11-06 18:10:53 +0000 |
commit | 23c8cf8a54e1326bcd78caf8037c98346431645c (patch) | |
tree | 8d02e02bee2a715e7f5c015663dee4e5048da927 /php/src | |
parent | DNSException fix (diff) | |
download | ice-23c8cf8a54e1326bcd78caf8037c98346431645c.tar.bz2 ice-23c8cf8a54e1326bcd78caf8037c98346431645c.tar.xz ice-23c8cf8a54e1326bcd78caf8037c98346431645c.zip |
Fixes for PHP 5.0.0b2. Fixes for Ice 1.2.0. Exception mapping changes:
- Derive from PHP's base Exception class.
- Add support for exception message in constructor.
Diffstat (limited to 'php/src')
-rw-r--r-- | php/src/ice/communicator.cpp | 26 | ||||
-rw-r--r-- | php/src/ice/ice_communicator.h | 4 | ||||
-rw-r--r-- | php/src/ice/ice_proxy.h | 2 | ||||
-rw-r--r-- | php/src/ice/marshal.cpp | 52 | ||||
-rw-r--r-- | php/src/ice/profile.cpp | 75 | ||||
-rw-r--r-- | php/src/ice/proxy.cpp | 42 | ||||
-rw-r--r-- | php/src/ice/util.cpp | 64 |
7 files changed, 156 insertions, 109 deletions
diff --git a/php/src/ice/communicator.cpp b/php/src/ice/communicator.cpp index c01265364d4..df9f1346ba9 100644 --- a/php/src/ice/communicator.cpp +++ b/php/src/ice/communicator.cpp @@ -57,6 +57,7 @@ static function_entry _methods[] = {"addObjectFactory", PHP_FN(Ice_Communicator_addObjectFactory), NULL}, {"removeObjectFactory", PHP_FN(Ice_Communicator_removeObjectFactory), NULL}, {"findObjectFactory", PHP_FN(Ice_Communicator_findObjectFactory), NULL}, + {"flushBatchRequests", PHP_FN(Ice_Communicator_flushBatchRequests), NULL}, {NULL, NULL, NULL} }; @@ -348,6 +349,31 @@ ZEND_FUNCTION(Ice_Communicator_findObjectFactory) phpFactory->findObjectFactory(id, return_value TSRMLS_CC); } +ZEND_FUNCTION(Ice_Communicator_flushBatchRequests) +{ + if(ZEND_NUM_ARGS() != 0) + { + WRONG_PARAM_COUNT; + } + + ice_object* obj = getObject(getThis() TSRMLS_CC); + if(!obj) + { + RETURN_NULL(); + } + assert(obj->ptr); + Ice::CommunicatorPtr* _this = static_cast<Ice::CommunicatorPtr*>(obj->ptr); + + try + { + (*_this)->flushBatchRequests();; + } + catch(const IceUtil::Exception& ex) + { + throwException(ex TSRMLS_CC); + } +} + #ifdef WIN32 extern "C" #endif diff --git a/php/src/ice/ice_communicator.h b/php/src/ice/ice_communicator.h index dfdd4fdf14d..131d2839ece 100644 --- a/php/src/ice/ice_communicator.h +++ b/php/src/ice/ice_communicator.h @@ -28,6 +28,7 @@ ZEND_FUNCTION(Ice_Communicator_proxyToString); ZEND_FUNCTION(Ice_Communicator_addObjectFactory); ZEND_FUNCTION(Ice_Communicator_removeObjectFactory); ZEND_FUNCTION(Ice_Communicator_findObjectFactory); +ZEND_FUNCTION(Ice_Communicator_flushBatchRequests); } #define ICE_PHP_COMMUNICATOR_FUNCTIONS \ @@ -36,7 +37,8 @@ ZEND_FUNCTION(Ice_Communicator_findObjectFactory); ZEND_FE(Ice_Communicator_proxyToString, NULL) \ ZEND_FE(Ice_Communicator_addObjectFactory, NULL) \ ZEND_FE(Ice_Communicator_removeObjectFactory, NULL) \ - ZEND_FE(Ice_Communicator_findObjectFactory, NULL) + ZEND_FE(Ice_Communicator_findObjectFactory, NULL) \ + ZEND_FE(Ice_Communicator_flushBatchRequests, NULL) namespace IcePHP { diff --git a/php/src/ice/ice_proxy.h b/php/src/ice/ice_proxy.h index 9a4cdc56dbf..2df1efe8f81 100644 --- a/php/src/ice/ice_proxy.h +++ b/php/src/ice/ice_proxy.h @@ -48,7 +48,6 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_secure); ZEND_FUNCTION(Ice_ObjectPrx_ice_compress); ZEND_FUNCTION(Ice_ObjectPrx_ice_timeout); ZEND_FUNCTION(Ice_ObjectPrx_ice_default); -ZEND_FUNCTION(Ice_ObjectPrx_ice_flush); ZEND_FUNCTION(Ice_ObjectPrx_ice_uncheckedCast); ZEND_FUNCTION(Ice_ObjectPrx_ice_checkedCast); } @@ -79,7 +78,6 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_checkedCast); ZEND_FE(Ice_ObjectPrx_ice_compress, NULL) \ ZEND_FE(Ice_ObjectPrx_ice_timeout, NULL) \ ZEND_FE(Ice_ObjectPrx_ice_default, NULL) \ - ZEND_FE(Ice_ObjectPrx_ice_flush, NULL) \ ZEND_FE(Ice_ObjectPrx_ice_uncheckedCast, NULL) \ ZEND_FE(Ice_ObjectPrx_ice_checkedCast, NULL) diff --git a/php/src/ice/marshal.cpp b/php/src/ice/marshal.cpp index d34dfd73910..f3fbfd5fb96 100644 --- a/php/src/ice/marshal.cpp +++ b/php/src/ice/marshal.cpp @@ -236,7 +236,7 @@ public: ObjectWriter(zval*, const Slice::SyntaxTreeBasePtr& TSRMLS_DC); ~ObjectWriter(); - virtual void __write(::IceInternal::BasicStream*) const; + virtual void __write(::IceInternal::BasicStream*, bool) const; virtual void __read(::IceInternal::BasicStream*, bool = true); private: @@ -253,7 +253,7 @@ public: ObjectReader(zval*, const Slice::ClassDefPtr& TSRMLS_DC); ~ObjectReader(); - virtual void __write(::IceInternal::BasicStream*) const; + virtual void __write(::IceInternal::BasicStream*, bool) const; virtual void __read(::IceInternal::BasicStream*, bool = true); void setValue(zend_class_entry*, zval*); @@ -1462,7 +1462,7 @@ IcePHP::ObjectWriter::~ObjectWriter() } void -IcePHP::ObjectWriter::__write(IceInternal::BasicStream* os) const +IcePHP::ObjectWriter::__write(IceInternal::BasicStream* os, bool) const { MarshalerMap* marshalerMap = static_cast<MarshalerMap*>(ICE_G(marshalerMap)); @@ -1546,7 +1546,7 @@ IcePHP::ObjectReader::~ObjectReader() } void -IcePHP::ObjectReader::__write(IceInternal::BasicStream* os) const +IcePHP::ObjectReader::__write(IceInternal::BasicStream* os, bool) const { zend_error(E_ERROR, "ObjectReader::__write should never be called"); } @@ -1846,16 +1846,25 @@ IcePHP::PHPObjectFactory::create(const string& scoped) zval* id; MAKE_STD_ZVAL(id); ZVAL_STRINGL(id, const_cast<char*>(scoped.c_str()), scoped.length(), 1); - - zval* create; - MAKE_STD_ZVAL(create); - ZVAL_STRINGL(create, "create", sizeof("create") - 1, 1); - args[0] = &id; + zval* zresult = NULL; - int status = call_user_function_ex(NULL, &p->second, create, &zresult, 1, args, 0, NULL TSRMLS_CC); - zval_ptr_dtor(&create); + zend_fcall_info fci; + fci.size = sizeof(fci); + fci.function_table = NULL; + MAKE_STD_ZVAL(fci.function_name); + ZVAL_STRINGL(fci.function_name, "create", sizeof("create") - 1, 1); + fci.symbol_table = NULL; + fci.retval_ptr_ptr = &zresult; + fci.param_count = 1; + fci.params = args; + fci.object_pp = &p->second; + fci.no_separation = 0; + + int status = zend_call_function(&fci, NULL TSRMLS_CC); + + zval_ptr_dtor(&fci.function_name); zval_ptr_dtor(&id); AutoDestroy destroyResult(zresult); @@ -1951,14 +1960,23 @@ IcePHP::PHPObjectFactory::destroy() // for(map<string, zval*>::iterator p = _factories.begin(); p != _factories.end(); ++p) { - zval* funcName; - MAKE_STD_ZVAL(funcName); - ZVAL_STRINGL(funcName, "destroy", sizeof("destroy") - 1, 1); - zval* result = NULL; - int status = call_user_function_ex(NULL, &p->second, funcName, &result, 0, NULL, 0, NULL TSRMLS_CC); - zval_ptr_dtor(&funcName); + zend_fcall_info fci; + fci.size = sizeof(fci); + fci.function_table = NULL; + MAKE_STD_ZVAL(fci.function_name); + ZVAL_STRINGL(fci.function_name, "destroy", sizeof("destroy") - 1, 1); + fci.symbol_table = NULL; + fci.retval_ptr_ptr = &result; + fci.param_count = 0; + fci.params = NULL; + fci.object_pp = &p->second; + fci.no_separation = 0; + + int status = zend_call_function(&fci, NULL TSRMLS_CC); + + zval_ptr_dtor(&fci.function_name); if(result) { zval_ptr_dtor(&result); diff --git a/php/src/ice/profile.cpp b/php/src/ice/profile.cpp index 6d3e18183f8..d59dd258426 100644 --- a/php/src/ice/profile.cpp +++ b/php/src/ice/profile.cpp @@ -80,32 +80,58 @@ private: // necessary to IcePHP::throwException. // static const char* _coreTypes = - "define(\"ICE_STRING_VERSION\", \"1.1.0\");\n" - "define(\"ICE_INT_VERSION\", 10100);\n" + "define(\"ICE_STRING_VERSION\", \"1.2.0\");\n" + "define(\"ICE_INT_VERSION\", 10200);\n" "\n" - "abstract class Ice_Exception\n" + "abstract class Ice_Exception extends Exception\n" "{\n" + " function __construct($message = '')\n" + " {\n" + " Exception::__construct($message);\n" + " }\n" "}\n" "\n" "abstract class Ice_LocalException extends Ice_Exception\n" "{\n" + " function __construct($message = '')\n" + " {\n" + " Ice_Exception::__construct($message);\n" + " }\n" "}\n" "\n" "class Ice_UnknownException extends Ice_LocalException\n" "{\n" + " function __construct($message = '')\n" + " {\n" + " Ice_LocalException::__construct($message);\n" + " }\n" + "\n" " var $unknown;\n" "}\n" "\n" "class Ice_UnknownLocalException extends Ice_UnknownException\n" "{\n" + " function __construct($message = '')\n" + " {\n" + " Ice_UnknownException::__construct($message);\n" + " }\n" "}\n" "\n" "class Ice_UnknownUserException extends Ice_UnknownException\n" "{\n" + " function __construct($message = '')\n" + " {\n" + " Ice_UnknownException::__construct($message);\n" + " }\n" "}\n" "\n" "class Ice_RequestFailedException extends Ice_LocalException\n" "{\n" + " function __construct($message = '')\n" + " {\n" + " Ice_LocalException::__construct($message);\n" + " }\n" + "\n" " var $id;\n" " var $facet;\n" " var $operation;\n" @@ -113,31 +139,60 @@ static const char* _coreTypes = "\n" "class Ice_ObjectNotExistException extends Ice_RequestFailedException\n" "{\n" + " function __construct($message = '')\n" + " {\n" + " Ice_RequestFailedException::__construct($message);\n" + " }\n" "}\n" "\n" "class Ice_FacetNotExistException extends Ice_RequestFailedException\n" "{\n" + " function __construct($message = '')\n" + " {\n" + " Ice_RequestFailedException::__construct($message);\n" + " }\n" "}\n" "\n" "class Ice_OperationNotExistException extends Ice_RequestFailedException\n" "{\n" + " function __construct($message = '')\n" + " {\n" + " Ice_RequestFailedException::__construct($message);\n" + " }\n" "}\n" "\n" "class Ice_ProtocolException extends Ice_LocalException\n" "{\n" + " function __construct($message = '')\n" + " {\n" + " Ice_LocalException::__construct($message);\n" + " }\n" "}\n" "\n" "class Ice_MarshalException extends Ice_ProtocolException\n" "{\n" + " function __construct($message = '')\n" + " {\n" + " Ice_ProtocolException::__construct($message);\n" + " }\n" "}\n" "\n" "class Ice_NoObjectFactoryException extends Ice_MarshalException\n" "{\n" + " function __construct($message = '')\n" + " {\n" + " Ice_MarshalException::__construct($message);\n" + " }\n" + "\n" " var $type;\n" "}\n" "\n" "abstract class Ice_UserException extends Ice_Exception\n" "{\n" + " function __construct($message = '')\n" + " {\n" + " Ice_Exception::__construct($message);\n" + " }\n" "}\n" "\n" "interface Ice_LocalObject\n" @@ -775,23 +830,29 @@ IcePHP::CodeVisitor::visitExceptionStart(const Slice::ExceptionPtr& p) Slice::ExceptionPtr base = p->base(); _out << "class " << flat << " extends "; + string baseName; if(!base) { if(p->isLocal()) { - _out << "Ice_LocalException"; + baseName = "Ice_LocalException"; } else { - _out << "Ice_UserException"; + baseName = "Ice_UserException"; } } else { - _out << flatten(base->scoped()); + baseName = flatten(base->scoped()); } - _out << endl << '{' << endl; + _out << baseName << endl << '{' << endl; + + _out << "function __construct($message = '')" << endl; + _out << "{" << endl; + _out << " " << baseName << "::__construct($message);" << endl; + _out << "}" << endl; return true; } diff --git a/php/src/ice/proxy.cpp b/php/src/ice/proxy.cpp index 89d567b75b6..96f6914681d 100644 --- a/php/src/ice/proxy.cpp +++ b/php/src/ice/proxy.cpp @@ -166,7 +166,6 @@ static function_entry _methods[] = {"ice_compress", PHP_FN(Ice_ObjectPrx_ice_compress), NULL}, {"ice_timeout", PHP_FN(Ice_ObjectPrx_ice_timeout), NULL}, {"ice_default", PHP_FN(Ice_ObjectPrx_ice_default), NULL}, - {"ice_flush", PHP_FN(Ice_ObjectPrx_ice_flush), NULL}, {"ice_uncheckedCast", PHP_FN(Ice_ObjectPrx_ice_uncheckedCast), NULL}, {"ice_checkedCast", PHP_FN(Ice_ObjectPrx_ice_checkedCast), NULL}, {NULL, NULL, NULL} @@ -988,27 +987,6 @@ ZEND_FUNCTION(Ice_ObjectPrx_ice_default) } } -ZEND_FUNCTION(Ice_ObjectPrx_ice_flush) -{ - 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); - - try - { - _this->getProxy()->ice_flush(); - } - catch(const IceUtil::Exception& ex) - { - throwException(ex TSRMLS_CC); - } -} - static void do_cast(INTERNAL_FUNCTION_PARAMETERS, bool check) { @@ -1162,14 +1140,12 @@ IcePHP::Operation::Operation(const Ice::ObjectPrx& proxy, const string& name, co // // Create an array that indicates how arguments are passed to the operation. - // The first element in the array determines how many follow it. // - zend_uchar* argTypes = new zend_uchar[params.size() + 1]; - argTypes[0] = static_cast<zend_uchar>(params.size()); + zend_arg_info* argInfo = new zend_arg_info[params.size()]; int i; Slice::ParamDeclList::const_iterator p; - for(p = params.begin(), i = 1; p != params.end(); ++p, ++i) + for(p = params.begin(), i = 0; p != params.end(); ++p, ++i) { MarshalerPtr m = Marshaler::createMarshaler((*p)->type() TSRMLS_CC); if(!m) @@ -1177,24 +1153,30 @@ IcePHP::Operation::Operation(const Ice::ObjectPrx& proxy, const string& name, co break; } _paramNames.push_back((*p)->name()); + argInfo[i].name = NULL; + argInfo[i].class_name = NULL; + argInfo[i].allow_null = 1; if((*p)->isOutParam()) { - argTypes[i] = BYREF_FORCE; + argInfo[i].pass_by_reference = 1; _outParams.push_back(m); } else { - argTypes[i] = BYREF_NONE; + 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->arg_types = argTypes; _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->handler = ZEND_FN(Ice_ObjectPrx_call); } @@ -1202,7 +1184,7 @@ IcePHP::Operation::~Operation() { if(_zendFunction) { - delete []_zendFunction->arg_types; + delete []_zendFunction->arg_info; efree(_zendFunction->function_name); efree(_zendFunction); } diff --git a/php/src/ice/util.cpp b/php/src/ice/util.cpp index 83002e49fde..e61c2e73049 100644 --- a/php/src/ice/util.cpp +++ b/php/src/ice/util.cpp @@ -143,10 +143,9 @@ IcePHP::createIdentity(zval* zv, const Ice::Identity& id TSRMLS_DC) return false; } - add_property_stringl_ex(zv, "name", sizeof("name"), const_cast<char*>(id.name.c_str()), - id.name.length(), 1 TSRMLS_CC); - add_property_stringl_ex(zv, "category", sizeof("category"), const_cast<char*>(id.category.c_str()), - id.category.length(), 1 TSRMLS_CC); + zend_update_property_string(cls, zv, "name", sizeof("name") - 1, const_cast<char*>(id.name.c_str()) TSRMLS_CC); + zend_update_property_string(cls, zv, "category", sizeof("category") - 1, + const_cast<char*>(id.category.c_str()) TSRMLS_CC); return true; } @@ -287,15 +286,8 @@ IcePHP::throwException(const IceUtil::Exception& ex TSRMLS_DC) // // Set the unknown member. // - zval* unknown; - MAKE_STD_ZVAL(unknown); - ZVAL_STRINGL(unknown, const_cast<char*>(e.unknown.c_str()), e.unknown.length(), 1); - if(add_property_zval(zex, "unknown", unknown) == FAILURE) - { - zend_error(E_ERROR, "unable to set unknown member of %s", cls->name); - return; - } - zval_ptr_dtor(&unknown); // add_property_zval increments the refcount + zend_update_property_string(cls, zex, "unknown", sizeof("unknown") - 1, + const_cast<char*>(e.unknown.c_str()) TSRMLS_CC); // // Throw the exception. @@ -329,12 +321,7 @@ IcePHP::throwException(const IceUtil::Exception& ex TSRMLS_DC) { return; } - if(add_property_zval(zex, "id", id) == FAILURE) - { - zend_error(E_ERROR, "unable to set id member of %s", cls->name); - return; - } - zval_ptr_dtor(&id); // add_property_zval increments the refcount + zend_update_property(cls, zex, "id", sizeof("id") - 1, id TSRMLS_CC); // // Set the facet member. @@ -351,25 +338,13 @@ IcePHP::throwException(const IceUtil::Exception& ex TSRMLS_DC) ZVAL_STRINGL(val, const_cast<char*>(f.c_str()), f.length(), 1); add_index_zval(facet, i, val); } - if(add_property_zval(zex, "facet", facet) == FAILURE) - { - zend_error(E_ERROR, "unable to set facet member of %s", cls->name); - return; - } - zval_ptr_dtor(&facet); // add_property_zval increments the refcount + zend_update_property(cls, zex, "facet", sizeof("facet") - 1, facet TSRMLS_CC); // // Set the operation member. // - zval* op; - MAKE_STD_ZVAL(op); - ZVAL_STRINGL(op, const_cast<char*>(e.operation.c_str()), e.operation.length(), 1); - if(add_property_zval(zex, "operation", op) == FAILURE) - { - zend_error(E_ERROR, "unable to set operation member of %s", cls->name); - return; - } - zval_ptr_dtor(&op); // add_property_zval increments the refcount + zend_update_property_string(cls, zex, "operation", sizeof("operation") - 1, + const_cast<char*>(e.operation.c_str()) TSRMLS_CC); // // Throw the exception. @@ -397,15 +372,7 @@ IcePHP::throwException(const IceUtil::Exception& ex TSRMLS_DC) // // Set the type member. // - zval* type; - MAKE_STD_ZVAL(type); - ZVAL_STRINGL(type, const_cast<char*>(e.type.c_str()), e.type.length(), 1); - if(add_property_zval(zex, "type", type) == FAILURE) - { - zend_error(E_ERROR, "unable to set type member of %s", cls->name); - return; - } - zval_ptr_dtor(&type); // add_property_zval increments the refcount + zend_update_property_string(cls, zex, "type", sizeof("type") - 1, const_cast<char*>(e.type.c_str()) TSRMLS_CC); // // Throw the exception. @@ -448,18 +415,11 @@ IcePHP::throwException(const IceUtil::Exception& ex TSRMLS_DC) // // Set the unknown member. // - zval* unknown; - MAKE_STD_ZVAL(unknown); ostringstream ostr; e.ice_print(ostr); string str = ostr.str(); - ZVAL_STRINGL(unknown, const_cast<char*>(str.c_str()), str.length(), 1); - if(add_property_zval(zex, "unknown", unknown) == FAILURE) - { - zend_error(E_ERROR, "unable to set unknown member of %s", cls->name); - return; - } - zval_ptr_dtor(&unknown); // add_property_zval increments the refcount + zend_update_property_string(cls, zex, "unknown", sizeof("unknown") - 1, + const_cast<char*>(str.c_str()) TSRMLS_CC); } // |