diff options
author | SVN Migration <svn@php.net> | 2003-08-07 17:53:49 +0000 |
---|---|---|
committer | SVN Migration <svn@php.net> | 2003-08-07 17:53:49 +0000 |
commit | 9936cda064c3b8c11c60e04a75ace4b0a45f6ff6 (patch) | |
tree | 38905f6ef41580c6c8d5754e4b8d275bc61793d9 /Zend/zend_objects.c | |
parent | a123efb6edd7100c24438e5d088f6acdfda6d2bb (diff) | |
download | php-git-RELEASE_0_5_3.tar.gz |
This commit was manufactured by cvs2svn to create tag 'RELEASE_0_5_3'.RELEASE_0_5_3
Diffstat (limited to 'Zend/zend_objects.c')
-rw-r--r-- | Zend/zend_objects.c | 180 |
1 files changed, 0 insertions, 180 deletions
diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c deleted file mode 100644 index 7749baf7db..0000000000 --- a/Zend/zend_objects.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Zend Engine | - +----------------------------------------------------------------------+ - | Copyright (c) 1998-2003 Zend Technologies Ltd. (http://www.zend.com) | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.00 of the Zend license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.zend.com/license/2_00.txt. | - | If you did not receive a copy of the Zend license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@zend.com so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Andi Gutmans <andi@zend.com> | - | Zeev Suraski <zeev@zend.com> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#include "zend.h" -#include "zend_globals.h" -#include "zend_variables.h" -#include "zend_API.h" - -static inline void zend_nuke_object(zend_object *object TSRMLS_DC) -{ - zend_hash_destroy(object->properties); - FREE_HASHTABLE(object->properties); - efree(object); -} - -ZEND_API void zend_objects_destroy_object(zend_object *object, zend_object_handle handle TSRMLS_DC) -{ - zend_function *destructor = object->ce->destructor; - - if (destructor) { - zval *obj; - zval *destructor_func_name; - zval *retval_ptr; - HashTable symbol_table; - - if (destructor->op_array.fn_flags & (ZEND_ACC_PRIVATE|ZEND_ACC_PROTECTED)) { - if (destructor->op_array.fn_flags & ZEND_ACC_PRIVATE) { - /* Ensure that if we're calling a private function, we're allowed to do so. - */ - if (object->ce != EG(scope)) { - zend_nuke_object(object TSRMLS_CC); /* unfortunately we *must* destroy it now anyway */ - /* this is a E_ERROR in real but we can't do that right now because of problems in shutdown */ - zend_error(E_WARNING, "Call to private destructor from context '%s'", EG(scope) ? EG(scope)->name : ""); - return; - } - } else { - /* Ensure that if we're calling a protected function, we're allowed to do so. - */ - if (!zend_check_protected(destructor->common.scope, EG(scope))) { - zend_nuke_object(object TSRMLS_CC); /* unfortunately we *must* destroy it now anyway */ - zend_error(E_WARNING, "Call to protected destructor from context '%s'", EG(scope) ? EG(scope)->name : ""); - return; - } - } - } - - MAKE_STD_ZVAL(obj); - obj->type = IS_OBJECT; - obj->value.obj.handle = handle; - obj->value.obj.handlers = &std_object_handlers; - zval_copy_ctor(obj); - - ZEND_INIT_SYMTABLE(&symbol_table); - - /* FIXME: Optimize this so that we use the old_object->ce->destructor function pointer instead of the name */ - MAKE_STD_ZVAL(destructor_func_name); - destructor_func_name->type = IS_STRING; - destructor_func_name->value.str.val = estrndup("__destruct", sizeof("__destruct")-1); - destructor_func_name->value.str.len = sizeof("__destruct")-1; - - call_user_function_ex(NULL, &obj, destructor_func_name, &retval_ptr, 0, NULL, 0, &symbol_table TSRMLS_CC); - - zend_hash_destroy(&symbol_table); - zval_ptr_dtor(&obj); - zval_ptr_dtor(&destructor_func_name); - if (retval_ptr) { - zval_ptr_dtor(&retval_ptr); - } - } - zend_nuke_object(object TSRMLS_CC); -} - -ZEND_API zend_object_value zend_objects_new(zend_object **object, zend_class_entry *class_type TSRMLS_DC) -{ - zend_object_value retval; - - *object = emalloc(sizeof(zend_object)); - (*object)->ce = class_type; - retval.handle = zend_objects_store_put(*object, (zend_objects_store_dtor_t) zend_objects_destroy_object, NULL TSRMLS_CC); - retval.handlers = &std_object_handlers; - (*object)->in_get = 0; - (*object)->in_set = 0; - return retval; -} - -ZEND_API zend_object *zend_objects_get_address(zval *zobject TSRMLS_DC) -{ - return (zend_object *)zend_object_store_get_object(zobject TSRMLS_CC); -} - -ZEND_API void zend_objects_clone_members(zend_object *new_object, zend_object_value new_obj_val, zend_object *old_object, zend_object_handle handle TSRMLS_DC) -{ - if (old_object->ce->clone) { - zval *old_obj; - zval *new_obj; - zval *clone_func_name; - zval *retval_ptr; - HashTable symbol_table; - zend_class_entry *ce = old_object->ce; - - zend_hash_copy(new_object->properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); - - MAKE_STD_ZVAL(new_obj); - new_obj->type = IS_OBJECT; - new_obj->value.obj = new_obj_val; - zval_copy_ctor(new_obj); - - MAKE_STD_ZVAL(old_obj); - old_obj->type = IS_OBJECT; - old_obj->value.obj.handle = handle; - old_obj->value.obj.handlers = &std_object_handlers; /* If we reached here than the handlers are standrd */ - zval_copy_ctor(old_obj); - - /* FIXME: Optimize this so that we use the old_object->ce->clone function pointer instead of the name */ - MAKE_STD_ZVAL(clone_func_name); - clone_func_name->type = IS_STRING; - clone_func_name->value.str.val = estrndup("__clone", sizeof("__clone")-1); - clone_func_name->value.str.len = sizeof("__clone")-1; - - ZEND_INIT_SYMTABLE(&symbol_table); - ZEND_SET_SYMBOL(&symbol_table, "that", old_obj); - - call_user_function_ex(NULL, &new_obj, clone_func_name, &retval_ptr, 0, NULL, 0, &symbol_table TSRMLS_CC); - - zend_hash_destroy(&symbol_table); - zval_ptr_dtor(&new_obj); - zval_ptr_dtor(&clone_func_name); - if(retval_ptr) { - zval_ptr_dtor(&retval_ptr); - } - } else { - zend_hash_copy(new_object->properties, old_object->properties, (copy_ctor_func_t) zval_add_ref, (void *) NULL /* Not used anymore */, sizeof(zval *)); - } -} - -ZEND_API zend_object_value zend_objects_clone_obj(zval *zobject TSRMLS_DC) -{ - zend_object_value new_obj_val; - zend_object *old_object; - zend_object *new_object; - zend_object_handle handle = Z_OBJ_HANDLE_P(zobject); - - /* assume that create isn't overwritten, so when clone depends on the - * overwritten one then it must itself be overwritten */ - old_object = zend_objects_get_address(zobject TSRMLS_CC); - new_obj_val = zend_objects_new(&new_object, old_object->ce TSRMLS_CC); - - ALLOC_HASHTABLE(new_object->properties); - zend_hash_init(new_object->properties, 0, NULL, ZVAL_PTR_DTOR, 0); - - zend_objects_clone_members(new_object, new_obj_val, old_object, handle TSRMLS_CC); - - return new_obj_val; -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * indent-tabs-mode: t - * End: - */ |