diff options
Diffstat (limited to 'php/src')
-rw-r--r-- | php/src/IcePHP/Communicator.cpp | 52 | ||||
-rw-r--r-- | php/src/IcePHP/Communicator.h | 2 | ||||
-rw-r--r-- | php/src/IcePHP/Init.cpp | 8 |
3 files changed, 60 insertions, 2 deletions
diff --git a/php/src/IcePHP/Communicator.cpp b/php/src/IcePHP/Communicator.cpp index e0c7394a73b..d57e8ef40e6 100644 --- a/php/src/IcePHP/Communicator.cpp +++ b/php/src/IcePHP/Communicator.cpp @@ -1109,6 +1109,58 @@ ZEND_FUNCTION(Ice_getProperties) } } +ZEND_FUNCTION(Ice_identityToString) +{ + zend_class_entry* identityClass = idToClass("::Ice::Identity" TSRMLS_CC); + assert(identityClass); + + zval* zv; + if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, const_cast<char*>("O"), &zv, identityClass) != SUCCESS) + { + RETURN_NULL(); + } + Ice::Identity id; + if(!extractIdentity(zv, id TSRMLS_CC)) + { + RETURN_NULL(); + } + + try + { + string str = Ice::identityToString(id); + RETURN_STRINGL(STRCAST(str.c_str()), static_cast<int>(str.length()), 1); + } + catch(const IceUtil::Exception& ex) + { + throwException(ex TSRMLS_CC); + RETURN_NULL(); + } +} + +ZEND_FUNCTION(Ice_stringToIdentity) +{ + char* str; + int strLen; + if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, const_cast<char*>("s"), &str, &strLen) != SUCCESS) + { + RETURN_NULL(); + } + string s(str, strLen); + + try + { + Ice::Identity id = Ice::stringToIdentity(s); + if(!createIdentity(return_value, id TSRMLS_CC)) + { + RETURN_NULL(); + } + } + catch(const IceUtil::Exception& ex) + { + throwException(ex TSRMLS_CC); + RETURN_NULL(); + } +} // // Necessary to suppress warnings from zend_function_entry in php-5.2 diff --git a/php/src/IcePHP/Communicator.h b/php/src/IcePHP/Communicator.h index e29e390e183..7ace90c7747 100644 --- a/php/src/IcePHP/Communicator.h +++ b/php/src/IcePHP/Communicator.h @@ -23,6 +23,8 @@ ZEND_FUNCTION(Ice_register); ZEND_FUNCTION(Ice_unregister); ZEND_FUNCTION(Ice_find); ZEND_FUNCTION(Ice_getProperties); +ZEND_FUNCTION(Ice_identityToString); +ZEND_FUNCTION(Ice_stringToIdentity); } namespace IcePHP diff --git a/php/src/IcePHP/Init.cpp b/php/src/IcePHP/Init.cpp index 782d644b6d7..3732b3d09b5 100644 --- a/php/src/IcePHP/Init.cpp +++ b/php/src/IcePHP/Init.cpp @@ -33,7 +33,9 @@ ZEND_END_ARG_INFO() ZEND_FE(Ice_register, NULL) \ ZEND_FE(Ice_unregister, NULL) \ ZEND_FE(Ice_find, NULL) \ - ZEND_FE(Ice_getProperties, NULL) + ZEND_FE(Ice_getProperties, NULL) \ + ZEND_FE(Ice_identityToString, NULL) \ + ZEND_FE(Ice_stringToIdentity, NULL) \ #ifdef ICEPHP_USE_NAMESPACES # define ICEPHP_COMMUNICATOR_NS_FUNCTIONS \ @@ -41,7 +43,9 @@ ZEND_END_ARG_INFO() ZEND_NS_FALIAS("Ice", register, Ice_register, NULL) \ ZEND_NS_FALIAS("Ice", unregister, Ice_unregister, NULL) \ ZEND_NS_FALIAS("Ice", find, Ice_find, NULL) \ - ZEND_NS_FALIAS("Ice", getProperties, Ice_getProperties, NULL) + ZEND_NS_FALIAS("Ice", getProperties, Ice_getProperties, NULL) \ + ZEND_NS_FALIAS("Ice", identityToString, Ice_identityToString, NULL) \ + ZEND_NS_FALIAS("Ice", stringToIdentity, Ice_stringToIdentity, NULL) #else # define ICEPHP_COMMUNICATOR_NS_FUNCTIONS #endif |