summaryrefslogtreecommitdiff
path: root/ext/intl/msgformat/msgformat_class.c
diff options
context:
space:
mode:
authorXinchen Hui <laruence@php.net>2014-06-28 00:02:50 +0800
committerXinchen Hui <laruence@php.net>2014-06-28 00:02:50 +0800
commit4fbaddb4f8b041769bea7efdd12313641387bd14 (patch)
tree7e3a8f8fd232dd52e0a666ef5b9e9b27734ddde1 /ext/intl/msgformat/msgformat_class.c
parentf609d8c1c677d03d9ae380480ae72383c5a98106 (diff)
downloadphp-git-4fbaddb4f8b041769bea7efdd12313641387bd14.tar.gz
Refactoring ext/intl (incompleted)
Diffstat (limited to 'ext/intl/msgformat/msgformat_class.c')
-rw-r--r--ext/intl/msgformat/msgformat_class.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/ext/intl/msgformat/msgformat_class.c b/ext/intl/msgformat/msgformat_class.c
index bb3b55f39c..71504bce2c 100644
--- a/ext/intl/msgformat/msgformat_class.c
+++ b/ext/intl/msgformat/msgformat_class.c
@@ -34,60 +34,50 @@ static zend_object_handlers MessageFormatter_handlers;
*/
/* {{{ MessageFormatter_objects_dtor */
-static void MessageFormatter_object_dtor(void *object, zend_object_handle handle TSRMLS_DC )
+static void MessageFormatter_object_dtor(zend_object *object TSRMLS_DC )
{
- zend_objects_destroy_object( object, handle TSRMLS_CC );
+ zend_objects_destroy_object( object TSRMLS_CC );
}
/* }}} */
/* {{{ MessageFormatter_objects_free */
void MessageFormatter_object_free( zend_object *object TSRMLS_DC )
{
- MessageFormatter_object* mfo = (MessageFormatter_object*)object;
+ MessageFormatter_object* mfo = php_intl_messageformatter_fetch_object(object);
zend_object_std_dtor( &mfo->zo TSRMLS_CC );
msgformat_data_free( &mfo->mf_data TSRMLS_CC );
-
- efree( mfo );
}
/* }}} */
/* {{{ MessageFormatter_object_create */
-zend_object_value MessageFormatter_object_create(zend_class_entry *ce TSRMLS_DC)
+zend_object *MessageFormatter_object_create(zend_class_entry *ce TSRMLS_DC)
{
- zend_object_value retval;
MessageFormatter_object* intern;
- intern = ecalloc( 1, sizeof(MessageFormatter_object) );
+ intern = ecalloc( 1, sizeof(MessageFormatter_object) + sizeof(zval) * (ce->default_properties_count - 1));
msgformat_data_init( &intern->mf_data TSRMLS_CC );
zend_object_std_init( &intern->zo, ce TSRMLS_CC );
object_properties_init(&intern->zo, ce);
- retval.handle = zend_objects_store_put(
- intern,
- MessageFormatter_object_dtor,
- (zend_objects_free_object_storage_t)MessageFormatter_object_free,
- NULL TSRMLS_CC );
-
- retval.handlers = &MessageFormatter_handlers;
+ intern->zo.handlers = &MessageFormatter_handlers;
- return retval;
+ return &intern->zo;
}
/* }}} */
/* {{{ MessageFormatter_object_clone */
-zend_object_value MessageFormatter_object_clone(zval *object TSRMLS_DC)
+zend_object *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;
+ zend_object *new_obj;
MSG_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK;
- new_obj_val = MessageFormatter_ce_ptr->create_object(Z_OBJCE_P(object) TSRMLS_CC);
- new_mfo = (MessageFormatter_object *)zend_object_store_get_object_by_handle(new_obj_val.handle TSRMLS_CC);
+ new_obj = MessageFormatter_ce_ptr->create_object(Z_OBJCE_P(object) TSRMLS_CC);
+ new_mfo = php_intl_messageformatter_fetch_object(new_obj);
/* clone standard parts */
- zend_objects_clone_members(&new_mfo->zo, new_obj_val, &mfo->zo, handle TSRMLS_CC);
+ zend_objects_clone_members(&new_mfo->zo, &mfo->zo TSRMLS_CC);
/* clone formatter object */
if (MSG_FORMAT_OBJECT(mfo) != NULL) {
@@ -102,7 +92,7 @@ zend_object_value MessageFormatter_object_clone(zval *object TSRMLS_DC)
} else {
zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Cannot clone unconstructed MessageFormatter");
}
- return new_obj_val;
+ return new_obj;
}
/* }}} */
@@ -171,7 +161,11 @@ void msgformat_register_class( TSRMLS_D )
memcpy(&MessageFormatter_handlers, zend_get_std_object_handlers(),
sizeof MessageFormatter_handlers);
+ MessageFormatter_handlers.offset = XtOffsetOf(MessageFormatter_object, zo);
MessageFormatter_handlers.clone_obj = MessageFormatter_object_clone;
+ MessageFormatter_handlers.dtor_obj = MessageFormatter_object_dtor;
+ MessageFormatter_handlers.free_obj = MessageFormatter_object_free;
+
/* Declare 'MessageFormatter' class properties. */
if( !MessageFormatter_ce_ptr )