summaryrefslogtreecommitdiff
path: root/ext/intl/msgformat/msgformat_class.c
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2011-01-03 03:58:57 +0000
committerStanislav Malyshev <stas@php.net>2011-01-03 03:58:57 +0000
commit28584c233e12da4265bbd41c48b26cd8a51baceb (patch)
tree142510dd4fa1d9734d50419f9238c56d5233fba8 /ext/intl/msgformat/msgformat_class.c
parente9bb7bbbd1e658a880e9d2ad284a88b43b3c669b (diff)
downloadphp-git-28584c233e12da4265bbd41c48b26cd8a51baceb.tar.gz
Imlement clone for formatters that support it
# also some test fixes, more to follow
Diffstat (limited to 'ext/intl/msgformat/msgformat_class.c')
-rwxr-xr-xext/intl/msgformat/msgformat_class.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/ext/intl/msgformat/msgformat_class.c b/ext/intl/msgformat/msgformat_class.c
index 522d59060c..59e222a4fc 100755
--- a/ext/intl/msgformat/msgformat_class.c
+++ b/ext/intl/msgformat/msgformat_class.c
@@ -73,6 +73,30 @@ zend_object_value MessageFormatter_object_create(zend_class_entry *ce TSRMLS_DC)
}
/* }}} */
+/* {{{ MessageFormatter_object_clone */
+zend_object_value MessageFormatter_object_clone(zval *object TSRMLS_DC)
+{
+ zend_object_value new_obj_val;
+ zend_object_handle handle = Z_OBJ_HANDLE_P(object);
+ MessageFormatter_object *mfo, *new_mfo;
+
+ MSG_FORMAT_METHOD_FETCH_OBJECT;
+ new_obj_val = MessageFormatter_ce_ptr->create_object(MessageFormatter_ce_ptr TSRMLS_CC);
+ new_mfo = (MessageFormatter_object *)zend_object_store_get_object_by_handle(new_obj_val.handle TSRMLS_CC);
+ /* clone standard parts */
+ zend_objects_clone_members(&new_mfo->zo, new_obj_val, &mfo->zo, handle TSRMLS_CC);
+ /* clone formatter object */
+ MSG_FORMAT_OBJECT(new_mfo) = umsg_clone(MSG_FORMAT_OBJECT(mfo), &INTL_DATA_ERROR_CODE(new_mfo));
+ if(U_FAILURE(INTL_DATA_ERROR_CODE(new_mfo))) {
+ /* set up error in case error handler is interested */
+ intl_error_set( NULL, INTL_DATA_ERROR_CODE(new_mfo), "Failed to clone MessageFormatter object", 0 TSRMLS_CC );
+ MessageFormatter_object_dtor(new_mfo, new_obj_val.handle TSRMLS_CC); /* free new object */
+ zend_error(E_ERROR, "Failed to clone MessageFormatter object");
+ }
+ return new_obj_val;
+}
+/* }}} */
+
/*
* 'MessageFormatter' class registration structures & functions
*/
@@ -138,7 +162,7 @@ void msgformat_register_class( TSRMLS_D )
memcpy(&MessageFormatter_handlers, zend_get_std_object_handlers(),
sizeof MessageFormatter_handlers);
- MessageFormatter_handlers.clone_obj = NULL;
+ MessageFormatter_handlers.clone_obj = MessageFormatter_object_clone;
/* Declare 'MessageFormatter' class properties. */
if( !MessageFormatter_ce_ptr )