mirror of
https://github.com/php/php-src.git
synced 2026-03-28 10:12:18 +01:00
- More work on making objects work
This commit is contained in:
@@ -565,7 +565,7 @@ ZEND_API int _array_init(zval *arg ZEND_FILE_LINE_DC)
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int _object_init_ex(zval *arg, zend_class_entry *class_type ZEND_FILE_LINE_DC TSRMLS_DC)
|
||||
ZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *class_type, HashTable *properties ZEND_FILE_LINE_DC TSRMLS_DC)
|
||||
{
|
||||
zval *tmp;
|
||||
zend_object *object;
|
||||
@@ -578,11 +578,20 @@ ZEND_API int _object_init_ex(zval *arg, zend_class_entry *class_type ZEND_FILE_L
|
||||
arg->type = IS_OBJECT;
|
||||
arg->value.obj = zend_objects_new(&object, class_type);
|
||||
|
||||
zend_hash_copy(object->properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
|
||||
|
||||
if (properties) {
|
||||
object->properties = properties;
|
||||
} else {
|
||||
ALLOC_HASHTABLE_REL(object->properties);
|
||||
zend_hash_init(object->properties, 0, NULL, ZVAL_PTR_DTOR, 0);
|
||||
zend_hash_copy(object->properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
ZEND_API int _object_init_ex(zval *arg, zend_class_entry *class_type ZEND_FILE_LINE_DC TSRMLS_DC)
|
||||
{
|
||||
return _object_and_properties_init(arg, class_type, 0 ZEND_FILE_LINE_CC TSRMLS_CC);
|
||||
}
|
||||
|
||||
ZEND_API int _object_init(zval *arg ZEND_FILE_LINE_DC TSRMLS_DC)
|
||||
{
|
||||
|
||||
@@ -156,9 +156,11 @@ ZEND_API int zend_startup_module(zend_module_entry *module);
|
||||
#define array_init(arg) _array_init((arg) ZEND_FILE_LINE_CC)
|
||||
#define object_init(arg) _object_init((arg) ZEND_FILE_LINE_CC TSRMLS_CC)
|
||||
#define object_init_ex(arg, ce) _object_init_ex((arg), (ce) ZEND_FILE_LINE_CC TSRMLS_CC)
|
||||
#define object_and_properties_init(arg, ce, properties) _object_and_properties_init((arg), (ce), (properties) ZEND_FILE_LINE_CC TSRMLS_CC)
|
||||
ZEND_API int _array_init(zval *arg ZEND_FILE_LINE_DC);
|
||||
ZEND_API int _object_init(zval *arg ZEND_FILE_LINE_DC TSRMLS_DC);
|
||||
ZEND_API int _object_init_ex(zval *arg, zend_class_entry *ce ZEND_FILE_LINE_DC TSRMLS_DC);
|
||||
ZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *ce, HashTable *properties ZEND_FILE_LINE_DC TSRMLS_DC);
|
||||
|
||||
/* no longer supported */
|
||||
ZEND_API int add_assoc_function(zval *arg, char *key, void (*function_ptr)(INTERNAL_FUNCTION_PARAMETERS));
|
||||
|
||||
@@ -48,9 +48,6 @@ zend_object_value zend_objects_new(zend_object **object, zend_class_entry *class
|
||||
*object = &EG(objects).object_buckets[handle].bucket.obj.object;
|
||||
|
||||
(*object)->ce = class_type;
|
||||
/* Try and change ALLOC_HASHTABLE to ALLOC_HASHTABLE_REL by also fixing this function's prototype */
|
||||
ALLOC_HASHTABLE((*object)->properties);
|
||||
zend_hash_init((*object)->properties, 0, NULL, ZVAL_PTR_DTOR, 0);
|
||||
|
||||
retval.handle = handle;
|
||||
retval.handlers = zoh;
|
||||
|
||||
@@ -539,10 +539,7 @@ ZEND_API void convert_to_object(zval *op)
|
||||
/* OBJECTS_OPTIMIZE */
|
||||
TSRMLS_FETCH();
|
||||
|
||||
object_init(op);
|
||||
zend_hash_destroy(Z_OBJPROP_P(op));
|
||||
FREE_HASHTABLE(Z_OBJPROP_P(op));
|
||||
Z_OBJPROP_P(op) = op->value.ht;
|
||||
object_and_properties_init(op, &zend_standard_class_def, op->value.ht);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user