diff options
author | Andi Gutmans <andi@php.net> | 2001-08-11 18:26:47 +0000 |
---|---|---|
committer | Andi Gutmans <andi@php.net> | 2001-08-11 18:26:47 +0000 |
commit | 76a7a5bc18deadd5d4aa4e9cc3fdd72bcd54b764 (patch) | |
tree | f044277ee8ef73f63900340689bc3504a457f288 | |
parent | 532677e7ac34678d11f8d768fb05dfbd0a9ca8fa (diff) | |
download | php-git-76a7a5bc18deadd5d4aa4e9cc3fdd72bcd54b764.tar.gz |
- More work on making objects work
-rw-r--r-- | Zend/zend_API.c | 15 | ||||
-rw-r--r-- | Zend/zend_API.h | 2 | ||||
-rw-r--r-- | Zend/zend_objects.c | 3 | ||||
-rw-r--r-- | Zend/zend_operators.c | 5 |
4 files changed, 15 insertions, 10 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index b6a2012e18..3145ce5987 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -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) { diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 2da610dc65..695a951c1b 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -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)); diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c index 2756c4993d..38348df54c 100644 --- a/Zend/zend_objects.c +++ b/Zend/zend_objects.c @@ -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; diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 59cd316ffc..8ac4164420 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -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; } |