diff options
author | Jose <jose@zeroc.com> | 2016-03-01 15:15:55 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2016-03-01 15:15:55 +0100 |
commit | 354a812c57df4c9229822d3905c80c5aa92c03c6 (patch) | |
tree | 706b046b40f9be789ae9ebad52a13e40682b936d | |
parent | Merge remote-tracking branch 'origin/3.6' (diff) | |
download | ice-354a812c57df4c9229822d3905c80c5aa92c03c6.tar.bz2 ice-354a812c57df4c9229822d3905c80c5aa92c03c6.tar.xz ice-354a812c57df4c9229822d3905c80c5aa92c03c6.zip |
Ice::identityToString/Ice::stringToIdentity for PHP7
-rw-r--r-- | php/src/php7/Communicator.cpp | 53 | ||||
-rw-r--r-- | php/src/php7/Communicator.h | 2 | ||||
-rw-r--r-- | php/src/php7/Init.cpp | 8 |
3 files changed, 61 insertions, 2 deletions
diff --git a/php/src/php7/Communicator.cpp b/php/src/php7/Communicator.cpp index cfe9f2c00ff..d408a5f9842 100644 --- a/php/src/php7/Communicator.cpp +++ b/php/src/php7/Communicator.cpp @@ -1356,6 +1356,59 @@ ZEND_FUNCTION(Ice_getProperties) } } +ZEND_FUNCTION(Ice_identityToString) +{ + zend_class_entry* identityClass = idToClass("::Ice::Identity"); + assert(identityClass); + + zval* zv; + if(zend_parse_parameters(ZEND_NUM_ARGS(), const_cast<char*>("O"), &zv, identityClass) != SUCCESS) + { + RETURN_NULL(); + } + Ice::Identity id; + if(!extractIdentity(zv, id)) + { + RETURN_NULL(); + } + + try + { + string str = _this->getCommunicator()->identityToString(id); + RETURN_STRINGL(STRCAST(str.c_str()), static_cast<int>(str.length())); + } + catch(const IceUtil::Exception& ex) + { + throwException(ex); + RETURN_NULL(); + } +} + +ZEND_FUNCTION(Ice_stringToIdentity) +{ + char* str; + size_t strLen; + if(zend_parse_parameters(ZEND_NUM_ARGS(), const_cast<char*>("s"), &str, &strLen) != SUCCESS) + { + RETURN_NULL(); + } + string s(str, strLen); + + try + { + Ice::Identity id = _this->getCommunicator()->stringToIdentity(s); + if(!createIdentity(return_value, id)) + { + RETURN_NULL(); + } + } + catch(const IceUtil::Exception& ex) + { + throwException(ex); + RETURN_NULL(); + } +} + // // Necessary to suppress warnings from zend_function_entry in php-5.2 // and INI_STR macro. diff --git a/php/src/php7/Communicator.h b/php/src/php7/Communicator.h index a96f8ef7be7..ef7e007b8aa 100644 --- a/php/src/php7/Communicator.h +++ b/php/src/php7/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/php7/Init.cpp b/php/src/php7/Init.cpp index b3c3b4eedb2..1dd89fbfc45 100644 --- a/php/src/php7/Init.cpp +++ b/php/src/php7/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 |