From: Andi Gutmans Date: Thu, 27 Dec 2001 16:35:07 +0000 (+0000) Subject: - Use two underscores for __construct(), __clone and friends... X-Git-Tag: PRE_ISSET_PATCH~389 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e322abdd63cae86495713657c5cdc0d207fa1892;p=php - Use two underscores for __construct(), __clone and friends... --- diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 4e45411edf..c2b261c3b4 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -741,6 +741,10 @@ void zend_do_free(znode *op1 TSRMLS_DC) } } +#define ZEND_CLONE_FUNC_NAME "__clone" +#define ZEND_CONSTRUCTOR_FUNC_NAME "__construct" +#define ZEND_DESTRUCTOR_FUNC_NAME "__destruct" + void zend_do_begin_function_declaration(znode *function_token, znode *function_name, int is_method, int return_reference TSRMLS_DC) { zend_op_array op_array; @@ -761,11 +765,11 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n zend_hash_update(&CG(active_class_entry)->function_table, name, name_len+1, &op_array, sizeof(zend_op_array), (void **) &CG(active_op_array)); if ((CG(active_class_entry)->name_length == (uint) name_len) && (!memcmp(CG(active_class_entry)->name, name, name_len))) { CG(active_class_entry)->constructor = (zend_function *) CG(active_op_array); - } else if ((function_name->u.constant.value.str.len == sizeof("_construct")-1) && (!memcmp(function_name->u.constant.value.str.val, "_construct", sizeof("_construct")))) { + } else if ((function_name->u.constant.value.str.len == sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) && (!memcmp(function_name->u.constant.value.str.val, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)))) { CG(active_class_entry)->constructor = (zend_function *) CG(active_op_array); - } else if ((function_name->u.constant.value.str.len == sizeof("_destruct")-1) && (!memcmp(function_name->u.constant.value.str.val, "_destruct", sizeof("_destruct")))) { + } else if ((function_name->u.constant.value.str.len == sizeof(ZEND_DESTRUCTOR_FUNC_NAME)-1) && (!memcmp(function_name->u.constant.value.str.val, ZEND_DESTRUCTOR_FUNC_NAME, sizeof(ZEND_DESTRUCTOR_FUNC_NAME)))) { CG(active_class_entry)->destructor = (zend_function *) CG(active_op_array); - } else if ((function_name->u.constant.value.str.len == sizeof("_clone")-1) && (!memcmp(function_name->u.constant.value.str.val, "_clone", sizeof("_clone")))) { + } else if ((function_name->u.constant.value.str.len == sizeof(ZEND_CLONE_FUNC_NAME)-1) && (!memcmp(function_name->u.constant.value.str.val, ZEND_CLONE_FUNC_NAME, sizeof(ZEND_CLONE_FUNC_NAME)))) { CG(active_class_entry)->clone = (zend_function *) CG(active_op_array); } } else { @@ -897,8 +901,8 @@ void zend_do_begin_method_call(znode *left_bracket TSRMLS_DC) last_op_number = get_next_op_number(CG(active_op_array))-1; last_op = &CG(active_op_array)->opcodes[last_op_number]; - if ((last_op->op2.op_type == IS_CONST) && (last_op->op2.u.constant.value.str.len == sizeof("_clone")-1) - && !memcmp(last_op->op2.u.constant.value.str.val, "_clone", sizeof("_clone"))) { + if ((last_op->op2.op_type == IS_CONST) && (last_op->op2.u.constant.value.str.len == sizeof(ZEND_CLONE_FUNC_NAME)-1) + && !memcmp(last_op->op2.u.constant.value.str.val, ZEND_CLONE_FUNC_NAME, sizeof(ZEND_CLONE_FUNC_NAME))) { last_op->opcode = ZEND_CLONE; left_bracket->u.constant.value.lval = ZEND_CLONE; zend_stack_push(&CG(function_call_stack), (void *) &ptr, sizeof(zend_function *)); @@ -1019,7 +1023,7 @@ void zend_do_end_function_call(znode *function_name, znode *result, znode *argum if (is_method && function_name && function_name->u.constant.value.lval == ZEND_CLONE) { if (argument_list->u.constant.value.lval > 0) { - zend_error(E_ERROR, "Can't pass arguments to _clone()"); + zend_error(E_ERROR, "Can't pass arguments to __clone()"); } /* FIXME: throw_list */ zend_stack_del_top(&CG(function_call_stack)); diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c index 1242a5a7a3..4ff6bab921 100644 --- a/Zend/zend_objects.c +++ b/Zend/zend_objects.c @@ -45,8 +45,8 @@ static inline void zend_objects_destroy_object(zend_object *object, zend_object_ /* 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; + destructor_func_name->value.str.val = estrndup("__destruct", sizeof("__destruct")-1); + destructor_func_name->value.str.len = sizeof("__destruct")-1; ZEND_INIT_SYMTABLE(&symbol_table); @@ -218,8 +218,8 @@ zend_object_value zend_objects_clone_obj(zend_object_handle handle) /* 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; + clone_func_name->value.str.val = estrndup("__clone", sizeof("__clone")-1); + clone_func_name->value.str.len = sizeof("__clone")-1; ALLOC_HASHTABLE(new_object->properties); zend_hash_init(new_object->properties, 0, NULL, ZVAL_PTR_DTOR, 0);