summaryrefslogtreecommitdiff
path: root/php/src/IcePHP/Communicator.cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2016-03-01 14:33:27 +0100
committerJose <jose@zeroc.com>2016-03-01 14:33:27 +0100
commite283494c906ffac2be14f38422934921ea6ae307 (patch)
treec4b9274845482abd89f84555675d8486a41a71e3 /php/src/IcePHP/Communicator.cpp
parentRework previous fix for 3.6 compatibility (diff)
downloadice-e283494c906ffac2be14f38422934921ea6ae307.tar.bz2
ice-e283494c906ffac2be14f38422934921ea6ae307.tar.xz
ice-e283494c906ffac2be14f38422934921ea6ae307.zip
Ice::identityToString/Ice::stringToIdentity php/ruby/python implementations
Diffstat (limited to 'php/src/IcePHP/Communicator.cpp')
-rw-r--r--php/src/IcePHP/Communicator.cpp52
1 files changed, 52 insertions, 0 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