summaryrefslogtreecommitdiff
path: root/ext/reflection
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2014-02-10 10:04:30 +0400
committerDmitry Stogov <dmitry@zend.com>2014-02-10 10:04:30 +0400
commitf4cfaf36e23ca47da3e352e1c60909104c059647 (patch)
tree0db3e2a323b12c5bbf1a958c857f92eb58c240d1 /ext/reflection
parent89a9acea1f9d821a9805b3857bf4febbba08690d (diff)
downloadphp-git-f4cfaf36e23ca47da3e352e1c60909104c059647.tar.gz
Use better data structures (incomplete)
Diffstat (limited to 'ext/reflection')
-rw-r--r--ext/reflection/php_reflection.c1144
1 files changed, 557 insertions, 587 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index a24153dc20..e566711c1a 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -42,10 +42,9 @@
#include "zend_extensions.h"
#define reflection_update_property(object, name, value) do { \
- zval *member; \
- MAKE_STD_ZVAL(member); \
- ZVAL_STRINGL(member, name, sizeof(name)-1, 1); \
- zend_std_write_property(object, member, value, NULL TSRMLS_CC); \
+ zval member; \
+ ZVAL_STRINGL(&member, name, sizeof(name)-1); \
+ zend_std_write_property(object, &member, value, NULL TSRMLS_CC); \
Z_DELREF_P(value); \
zval_ptr_dtor(&member); \
} while (0)
@@ -95,12 +94,12 @@ ZEND_DECLARE_MODULE_GLOBALS(reflection)
return; \
#define RETURN_ON_EXCEPTION \
- if (EG(exception) && Z_OBJCE_P(EG(exception)) == reflection_exception_ptr) { \
+ if (EG(exception) && EG(exception)->ce == reflection_exception_ptr) { \
return; \
}
#define GET_REFLECTION_OBJECT_PTR(target) \
- intern = (reflection_object *) zend_object_store_get_object(getThis() TSRMLS_CC); \
+ intern = (reflection_object *) Z_OBJ_P(getThis()); \
if (intern == NULL || intern->ptr == NULL) { \
RETURN_ON_EXCEPTION \
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: Failed to retrieve the reflection object"); \
@@ -207,7 +206,7 @@ typedef struct {
zend_object zo;
void *ptr;
reflection_type_t ref_type;
- zval *obj;
+ zval obj;
zend_class_entry *ce;
unsigned int ignore_visibility:1;
} reflection_object;
@@ -218,13 +217,13 @@ static zend_object_handlers reflection_object_handlers;
static void _default_get_entry(zval *object, char *name, int name_len, zval *return_value TSRMLS_DC) /* {{{ */
{
- zval **value;
+ zval *value;
- if (zend_hash_find(Z_OBJPROP_P(object), name, name_len, (void **) &value) == FAILURE) {
+ if ((value = zend_hash_str_find(Z_OBJPROP_P(object), name, name_len)) == NULL) {
RETURN_FALSE;
}
- MAKE_COPY_ZVAL(value, return_value);
+ ZVAL_DUP(return_value, value);
}
/* }}} */
@@ -260,7 +259,7 @@ static zend_function *_copy_function(zend_function *fptr TSRMLS_DC) /* {{{ */
zend_function *copy_fptr;
copy_fptr = emalloc(sizeof(zend_function));
memcpy(copy_fptr, fptr, sizeof(zend_function));
- copy_fptr->internal_function.function_name = estrdup(fptr->internal_function.function_name);
+ copy_fptr->internal_function.function_name = STR_DUP(fptr->internal_function.function_name, 0);
return copy_fptr;
} else {
/* no copy needed */
@@ -281,7 +280,7 @@ static void _free_function(zend_function *fptr TSRMLS_DC) /* {{{ */
}
/* }}} */
-static void reflection_free_objects_storage(void *object TSRMLS_DC) /* {{{ */
+static void reflection_free_objects_storage(zend_object *object TSRMLS_DC) /* {{{ */
{
reflection_object *intern = (reflection_object *) object;
parameter_reference *reference;
@@ -310,16 +309,13 @@ static void reflection_free_objects_storage(void *object TSRMLS_DC) /* {{{ */
}
}
intern->ptr = NULL;
- if (intern->obj) {
- zval_ptr_dtor(&intern->obj);
- }
- zend_objects_free_object_storage(object TSRMLS_CC);
+ zval_ptr_dtor(&intern->obj);
+//??? zend_objects_free_object_storage(object TSRMLS_CC);
}
/* }}} */
-static zend_object_value reflection_objects_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
+static zend_object *reflection_objects_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
- zend_object_value retval;
reflection_object *intern;
intern = ecalloc(1, sizeof(reflection_object));
@@ -327,21 +323,14 @@ static zend_object_value reflection_objects_new(zend_class_entry *class_type TSR
zend_object_std_init(&intern->zo, class_type TSRMLS_CC);
object_properties_init(&intern->zo, class_type);
- retval.handle = zend_objects_store_put(intern, NULL, reflection_free_objects_storage, NULL TSRMLS_CC);
- retval.handlers = &reflection_object_handlers;
- return retval;
+ intern->zo.handlers = &reflection_object_handlers;
+ return (zend_object*)intern;
}
/* }}} */
static zval * reflection_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC) /* {{{ */
{
- if (!object) {
- ALLOC_ZVAL(object);
- }
- Z_TYPE_P(object) = IS_OBJECT;
object_init_ex(object, pce);
- Z_SET_REFCOUNT_P(object, 1);
- Z_SET_ISREF_P(object);
return object;
}
/* }}} */
@@ -433,17 +422,16 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
string_printf(str, "%s - Constants [%d] {\n", indent, count);
if (count > 0) {
HashPosition pos;
- zval **value;
- char *key;
- uint key_len;
+ zval *value;
+ zend_string *key;
ulong num_index;
zend_hash_internal_pointer_reset_ex(&ce->constants_table, &pos);
- while (zend_hash_get_current_data_ex(&ce->constants_table, (void **) &value, &pos) == SUCCESS) {
- zend_hash_get_current_key_ex(&ce->constants_table, &key, &key_len, &num_index, 0, &pos);
+ while ((value = zend_hash_get_current_data_ex(&ce->constants_table, &pos)) != NULL) {
+ zend_hash_get_current_key_ex(&ce->constants_table, &key, &num_index, 0, &pos);
- _const_string(str, key, *value, indent TSRMLS_CC);
+ _const_string(str, key->val, value, indent TSRMLS_CC);
zend_hash_move_forward_ex(&ce->constants_table, &pos);
}
}
@@ -460,7 +448,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
zend_hash_internal_pointer_reset_ex(&ce->properties_info, &pos);
- while (zend_hash_get_current_data_ex(&ce->properties_info, (void **) &prop, &pos) == SUCCESS) {
+ while ((prop = zend_hash_get_current_data_ptr_ex(&ce->properties_info, &pos)) != NULL) {
if(prop->flags & ZEND_ACC_SHADOW) {
count_shadow_props++;
} else if (prop->flags & ZEND_ACC_STATIC) {
@@ -478,7 +466,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
zend_hash_internal_pointer_reset_ex(&ce->properties_info, &pos);
- while (zend_hash_get_current_data_ex(&ce->properties_info, (void **) &prop, &pos) == SUCCESS) {
+ while ((prop = zend_hash_get_current_data_ptr_ex(&ce->properties_info, &pos)) != NULL) {
if ((prop->flags & ZEND_ACC_STATIC) && !(prop->flags & ZEND_ACC_SHADOW)) {
_property_string(str, prop, NULL, sub_indent.string TSRMLS_CC);
}
@@ -499,7 +487,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
zend_hash_internal_pointer_reset_ex(&ce->function_table, &pos);
- while (zend_hash_get_current_data_ex(&ce->function_table, (void **) &mptr, &pos) == SUCCESS) {
+ while ((mptr = zend_hash_get_current_data_ptr_ex(&ce->function_table, &pos)) != NULL) {
if (mptr->common.fn_flags & ZEND_ACC_STATIC
&& ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce))
{
@@ -517,7 +505,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
zend_hash_internal_pointer_reset_ex(&ce->function_table, &pos);
- while (zend_hash_get_current_data_ex(&ce->function_table, (void **) &mptr, &pos) == SUCCESS) {
+ while ((mptr = zend_hash_get_current_data_ptr_ex(&ce->function_table, &pos)) != NULL) {
if (mptr->common.fn_flags & ZEND_ACC_STATIC
&& ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce))
{
@@ -542,7 +530,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
zend_hash_internal_pointer_reset_ex(&ce->properties_info, &pos);
- while (zend_hash_get_current_data_ex(&ce->properties_info, (void **) &prop, &pos) == SUCCESS) {
+ while ((prop = zend_hash_get_current_data_ptr_ex(&ce->properties_info, &pos)) != NULL) {
if (!(prop->flags & (ZEND_ACC_STATIC|ZEND_ACC_SHADOW))) {
_property_string(str, prop, NULL, sub_indent.string TSRMLS_CC);
}
@@ -564,16 +552,15 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
if (properties && zend_hash_num_elements(properties)) {
zend_hash_internal_pointer_reset_ex(properties, &pos);
- while (zend_hash_get_current_data_ex(properties, (void **) &prop, &pos) == SUCCESS) {
- char *prop_name;
- uint prop_name_size;
+ while ((prop = zend_hash_get_current_data_ptr_ex(properties, &pos)) != NULL) {
+ zend_string *prop_name;
ulong index;
- if (zend_hash_get_current_key_ex(properties, &prop_name, &prop_name_size, &index, 1, &pos) == HASH_KEY_IS_STRING) {
- if (prop_name_size && prop_name[0]) { /* skip all private and protected properties */
- if (!zend_hash_quick_exists(&ce->properties_info, prop_name, prop_name_size, zend_get_hash_value(prop_name, prop_name_size))) {
+ if (zend_hash_get_current_key_ex(properties, &prop_name, &index, 1, &pos) == HASH_KEY_IS_STRING) {
+ if (prop_name->len && prop_name->val[0]) { /* skip all private and protected properties */
+ if (!zend_hash_exists(&ce->properties_info, prop_name)) {
count++;
- _property_string(&dyn, NULL, prop_name, sub_indent.string TSRMLS_CC);
+ _property_string(&dyn, NULL, prop_name->val, sub_indent.string TSRMLS_CC);
}
}
efree(prop_name);
@@ -600,20 +587,19 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
string_init(&dyn);
zend_hash_internal_pointer_reset_ex(&ce->function_table, &pos);
- while (zend_hash_get_current_data_ex(&ce->function_table, (void **) &mptr, &pos) == SUCCESS) {
+ while ((mptr = zend_hash_get_current_data_ptr_ex(&ce->function_table, &pos)) != NULL) {
if ((mptr->common.fn_flags & ZEND_ACC_STATIC) == 0
&& ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce))
{
- char *key;
- uint key_len;
+ zend_string *key;
ulong num_index;
- uint len = strlen(mptr->common.function_name);
+ uint len = mptr->common.function_name->len;
/* Do not display old-style inherited constructors */
if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0
|| mptr->common.scope == ce
- || zend_hash_get_current_key_ex(&ce->function_table, &key, &key_len, &num_index, 0, &pos) != HASH_KEY_IS_STRING
- || zend_binary_strcasecmp(key, key_len-1, mptr->common.function_name, len) == 0)
+ || zend_hash_get_current_key_ex(&ce->function_table, &key, &num_index, 0, &pos) != HASH_KEY_IS_STRING
+ || zend_binary_strcasecmp(key->val, key->len-1, mptr->common.function_name->val, len) == 0)
{
zend_function *closure;
/* see if this is a closure */
@@ -726,33 +712,31 @@ static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg
if (fptr->type == ZEND_USER_FUNCTION && offset >= required) {
zend_op *precv = _get_recv_op((zend_op_array*)fptr, offset);
if (precv && precv->opcode == ZEND_RECV_INIT && precv->op2_type != IS_UNUSED) {
- zval *zv, zv_copy;
+ zval zv, zv_copy;
int use_copy;
string_write(str, " = ", sizeof(" = ")-1);
- ALLOC_ZVAL(zv);
- *zv = *precv->op2.zv;
- zval_copy_ctor(zv);
- INIT_PZVAL(zv);
+ ZVAL_DUP(&zv, precv->op2.zv);
+//??? INIT_PZVAL(zv);
zval_update_constant_ex(&zv, (void*)1, fptr->common.scope TSRMLS_CC);
- if (Z_TYPE_P(zv) == IS_BOOL) {
- if (Z_LVAL_P(zv)) {
+ if (Z_TYPE(zv) == IS_BOOL) {
+ if (Z_LVAL(zv)) {
string_write(str, "true", sizeof("true")-1);
} else {
string_write(str, "false", sizeof("false")-1);
}
- } else if (Z_TYPE_P(zv) == IS_NULL) {
+ } else if (Z_TYPE(zv) == IS_NULL) {
string_write(str, "NULL", sizeof("NULL")-1);
- } else if (Z_TYPE_P(zv) == IS_STRING) {
+ } else if (Z_TYPE(zv) == IS_STRING) {
string_write(str, "'", sizeof("'")-1);
- string_write(str, Z_STRVAL_P(zv), MIN(Z_STRLEN_P(zv), 15));
- if (Z_STRLEN_P(zv) > 15) {
+ string_write(str, Z_STRVAL(zv), MIN(Z_STRLEN(zv), 15));
+ if (Z_STRLEN(zv) > 15) {
string_write(str, "...", sizeof("...")-1);
}
string_write(str, "'", sizeof("'")-1);
- } else if (Z_TYPE_P(zv) == IS_ARRAY) {
+ } else if (Z_TYPE(zv) == IS_ARRAY) {
string_write(str, "Array", sizeof("Array")-1);
} else {
- zend_make_printable_zval(zv, &zv_copy, &use_copy);
+ zend_make_printable_zval(&zv, &zv_copy, &use_copy);
string_write(str, Z_STRVAL(zv_copy), Z_STRLEN(zv_copy));
if (use_copy) {
zval_dtor(&zv_copy);
@@ -792,8 +776,7 @@ static void _function_closure_string(string *str, zend_function *fptr, char* ind
{
zend_uint i, count;
ulong num_index;
- char *key;
- uint key_len;
+ zend_string *key;
HashTable *static_variables;
HashPosition pos;
@@ -813,8 +796,8 @@ static void _function_closure_string(string *str, zend_function *fptr, char* ind
zend_hash_internal_pointer_reset_ex(static_variables, &pos);
i = 0;
while (i < count) {
- zend_hash_get_current_key_ex(static_variables, &key, &key_len, &num_index, 0, &pos);
- string_printf(str, "%s Variable #%d [ $%s ]\n", indent, i++, key);
+ zend_hash_get_current_key_ex(static_variables, &key, &num_index, 0, &pos);
+ string_printf(str, "%s Variable #%d [ $%s ]\n", indent, i++, key->val);
zend_hash_move_forward_ex(static_variables, &pos);
}
string_printf(str, "%s}\n", indent);
@@ -826,7 +809,7 @@ static void _function_string(string *str, zend_function *fptr, zend_class_entry
{
string param_indent;
zend_function *overwrites;
- char *lc_name;
+ zend_string *lc_name;
unsigned int lc_name_len;
/* TBD: Repair indenting of doc comment (or is this to be done in the parser?)
@@ -851,9 +834,10 @@ static void _function_string(string *str, zend_function *fptr, zend_class_entry
if (fptr->common.scope != scope) {
string_printf(str, ", inherits %s", fptr->common.scope->name);
} else if (fptr->common.scope->parent) {
- lc_name_len = strlen(fptr->common.function_name);
- lc_name = zend_str_tolower_dup(fptr->common.function_name, lc_name_len);
- if (zend_hash_find(&fptr->common.scope->parent->function_table, lc_name, lc_name_len + 1, (void**) &overwrites) == SUCCESS) {
+ lc_name_len = fptr->common.function_name->len;
+ lc_name = STR_ALLOC(lc_name_len, 0);
+ zend_str_tolower_copy(lc_name->val, fptr->common.function_name->val, lc_name_len);
+ if ((overwrites = zend_hash_find_ptr(&fptr->common.scope->parent->function_table, lc_name)) != NULL) {
if (fptr->common.scope != overwrites->common.scope) {
string_printf(str, ", overwrites %s", overwrites->common.scope->name);
}
@@ -958,7 +942,7 @@ static void _property_string(string *str, zend_property_info *prop, char *prop_n
string_printf(str, "static ");
}
- zend_unmangle_property_name(prop->name, prop->name_length, &class_name, (const char**)&prop_name);
+ zend_unmangle_property_name(prop->name->val, prop->name->len, &class_name, (const char**)&prop_name);
string_printf(str, "$%s", prop_name);
}
@@ -1026,7 +1010,7 @@ static int _extension_const_string(zend_constant *constant TSRMLS_DC, int num_ar
int *num_classes = va_arg(args, int*);
if (constant->module_number == module->module_number) {
- _const_string(str, constant->name, &constant->value, indent TSRMLS_CC);
+ _const_string(str, constant->name->val, &constant->value, indent TSRMLS_CC);
(*num_classes)++;
}
return ZEND_HASH_APPLY_KEEP;
@@ -1114,7 +1098,7 @@ static void _extension_string(string *str, zend_module_entry *module, char *inde
int first = 1;
zend_hash_internal_pointer_reset_ex(CG(function_table), &iterator);
- while (zend_hash_get_current_data_ex(CG(function_table), (void **) &fptr, &iterator) == SUCCESS) {
+ while ((fptr = zend_hash_get_current_data_ptr_ex(CG(function_table), &iterator)) != NULL) {
if (fptr->common.type==ZEND_INTERNAL_FUNCTION
&& fptr->internal_function.module == module) {
if (first) {
@@ -1191,16 +1175,15 @@ static void _function_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask)
PHPAPI void zend_reflection_class_factory(zend_class_entry *ce, zval *object TSRMLS_DC)
{
reflection_object *intern;
- zval *name;
+ zval name;
- MAKE_STD_ZVAL(name);
- ZVAL_STRINGL(name, ce->name, ce->name_length, 1);
+ ZVAL_STR(&name, STR_COPY(ce->name));
reflection_instantiate(reflection_class_ptr, object TSRMLS_CC);
- intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
+ intern = (reflection_object *) Z_STR_P(object);
intern->ptr = ce;
intern->ref_type = REF_TYPE_OTHER;
intern->ce = ce;
- reflection_update_property(object, "name", name);
+ reflection_update_property(object, "name", &name);
}
/* }}} */
@@ -1208,28 +1191,26 @@ PHPAPI void zend_reflection_class_factory(zend_class_entry *ce, zval *object TSR
static void reflection_extension_factory(zval *object, const char *name_str TSRMLS_DC)
{
reflection_object *intern;
- zval *name;
+ zval name;
int name_len = strlen(name_str);
- char *lcname;
+ zend_string *lcname;
struct _zend_module_entry *module;
- ALLOCA_FLAG(use_heap)
- lcname = do_alloca(name_len + 1, use_heap);
- zend_str_tolower_copy(lcname, name_str, name_len);
- if (zend_hash_find(&module_registry, lcname, name_len + 1, (void **)&module) == FAILURE) {
- free_alloca(lcname, use_heap);
+ lcname = STR_ALLOC(name_len, 0);
+ zend_str_tolower_copy(lcname->val, name_str, name_len);
+ module = zend_hash_find_ptr(&module_registry, lcname);
+ STR_FREE(lcname);
+ if (!module) {
return;
}
- free_alloca(lcname, use_heap);
reflection_instantiate(reflection_extension_ptr, object TSRMLS_CC);
- intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
- MAKE_STD_ZVAL(name);
- ZVAL_STRINGL(name, module->name, name_len, 1);
+ intern = (reflection_object *) Z_OBJ_P(object);
+ ZVAL_STRINGL(&name, module->name, name_len);
intern->ptr = module;
intern->ref_type = REF_TYPE_OTHER;
intern->ce = NULL;
- reflection_update_property(object, "name", name);
+ reflection_update_property(object, "name", &name);
}
/* }}} */
@@ -1238,19 +1219,18 @@ static void reflection_parameter_factory(zend_function *fptr, zval *closure_obje
{
reflection_object *intern;
parameter_reference *reference;
- zval *name;
+ zval name;
if (closure_object) {
Z_ADDREF_P(closure_object);
}
- MAKE_STD_ZVAL(name);
if (arg_info->name) {
- ZVAL_STRINGL(name, arg_info->name, arg_info->name_len, 1);
+ ZVAL_STRINGL(&name, arg_info->name, arg_info->name_len);
} else {
- ZVAL_NULL(name);
+ ZVAL_NULL(&name);
}
reflection_instantiate(reflection_parameter_ptr, object TSRMLS_CC);
- intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
+ intern = (reflection_object *) Z_OBJ_P(object);
reference = (parameter_reference*) emalloc(sizeof(parameter_reference));
reference->arg_info = arg_info;
reference->offset = offset;
@@ -1259,8 +1239,8 @@ static void reflection_parameter_factory(zend_function *fptr, zval *closure_obje
intern->ptr = reference;
intern->ref_type = REF_TYPE_PARAMETER;
intern->ce = fptr->common.scope;
- intern->obj = closure_object;
- reflection_update_property(object, "name", name);
+ ZVAL_COPY_VALUE(&intern->obj, closure_object);
+ reflection_update_property(object, "name", &name);
}
/* }}} */
@@ -1268,21 +1248,20 @@ static void reflection_parameter_factory(zend_function *fptr, zval *closure_obje
static void reflection_function_factory(zend_function *function, zval *closure_object, zval *object TSRMLS_DC)
{
reflection_object *intern;
- zval *name;
+ zval name;
if (closure_object) {
Z_ADDREF_P(closure_object);
}
- MAKE_STD_ZVAL(name);
- ZVAL_STRING(name, function->common.function_name, 1);
+ ZVAL_STR(&name, STR_COPY(function->common.function_name));
reflection_instantiate(reflection_function_ptr, object TSRMLS_CC);
- intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
+ intern = (reflection_object *) Z_OBJ_P(object);
intern->ptr = function;
intern->ref_type = REF_TYPE_FUNCTION;
intern->ce = NULL;
- intern->obj = closure_object;
- reflection_update_property(object, "name", name);
+ ZVAL_COPY_VALUE(&intern->obj, closure_object);
+ reflection_update_property(object, "name", &name);
}
/* }}} */
@@ -1290,25 +1269,23 @@ static void reflection_function_factory(zend_function *function, zval *closure_o
static void reflection_method_factory(zend_class_entry *ce, zend_function *method, zval *closure_object, zval *object TSRMLS_DC)
{
reflection_object *intern;
- zval *name;
- zval *classname;
+ zval name;
+ zval classname;
if (closure_object) {
Z_ADDREF_P(closure_object);
}
- MAKE_STD_ZVAL(name);
- MAKE_STD_ZVAL(classname);
- ZVAL_STRING(name, (method->common.scope && method->common.scope->trait_aliases)?
- zend_resolve_method_name(ce, method) : method->common.function_name, 1);
- ZVAL_STRINGL(classname, method->common.scope->name, method->common.scope->name_length, 1);
+ ZVAL_STR(&name, STR_COPY((method->common.scope && method->common.scope->trait_aliases)?
+ zend_resolve_method_name(ce, method) : method->common.function_name));
+ ZVAL_STR(&classname, STR_COPY(method->common.scope->name));
reflection_instantiate(reflection_method_ptr, object TSRMLS_CC);
- intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
+ intern = (reflection_object *) Z_OBJ_P(object);
intern->ptr = method;
intern->ref_type = REF_TYPE_FUNCTION;
intern->ce = ce;
- intern->obj = closure_object;
- reflection_update_property(object, "name", name);
- reflection_update_property(object, "class", classname);
+ ZVAL_COPY_VALUE(&intern->obj, closure_object);
+ reflection_update_property(object, "name", &name);
+ reflection_update_property(object, "class", &classname);
}
/* }}} */
@@ -1316,19 +1293,19 @@ static void reflection_method_factory(zend_class_entry *ce, zend_function *metho
static void reflection_property_factory(zend_class_entry *ce, zend_property_info *prop, zval *object TSRMLS_DC)
{
reflection_object *intern;
- zval *name;
- zval *classname;
+ zval name;
+ zval classname;
property_reference *reference;
const char *class_name, *prop_name;
- zend_unmangle_property_name(prop->name, prop->name_length, &class_name, &prop_name);
+ zend_unmangle_property_name(prop->name->val, prop->name->len, &class_name, &prop_name);
if (!(prop->flags & ZEND_ACC_PRIVATE)) {
/* we have to search the class hierarchy for this (implicit) public or protected property */
zend_class_entry *tmp_ce = ce, *store_ce = ce;
zend_property_info *tmp_info = NULL;
- while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, prop_name, strlen(prop_name) + 1, (void **) &tmp_info) != SUCCESS) {
+ while (tmp_ce && (tmp_info = zend_hash_str_find_ptr(&tmp_ce->properties_info, prop_name, strlen(prop_name))) == NULL) {
ce = tmp_ce;
tmp_ce = tmp_ce->parent;
}
@@ -1340,13 +1317,11 @@ static void reflection_property_factory(zend_class_entry *ce, zend_property_info
}
}
- MAKE_STD_ZVAL(name);
- MAKE_STD_ZVAL(classname);
- ZVAL_STRING(name, prop_name, 1);
- ZVAL_STRINGL(classname, prop->ce->name, prop->ce->name_length, 1);
+ ZVAL_STRING(&name, prop_name);
+ ZVAL_STR(&classname, STR_COPY(prop->ce->name));
reflection_instantiate(reflection_property_ptr, object TSRMLS_CC);
- intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
+ intern = (reflection_object *) Z_OBJ_P(object);
reference = (property_reference*) emalloc(sizeof(property_reference));
reference->ce = ce;
reference->prop = *prop;
@@ -1354,23 +1329,22 @@ static void reflection_property_factory(zend_class_entry *ce, zend_property_info
intern->ref_type = REF_TYPE_PROPERTY;
intern->ce = ce;
intern->ignore_visibility = 0;
- reflection_update_property(object, "name", name);
- reflection_update_property(object, "class", classname);
+ reflection_update_property(object, "name", &name);
+ reflection_update_property(object, "class", &classname);
}
/* }}} */
/* {{{ _reflection_export */
static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *ce_ptr, int ctor_argc)
{
- zval *reflector_ptr;
+ zval reflector;
zval output, *output_ptr = &output;
zval *argument_ptr, *argument2_ptr;
- zval *retval_ptr, **params[2];
+ zval retval, params[2];
int result;
int return_output = 0;
zend_fcall_info fci;
zend_fcall_info_cache fcc;
- zval fname;
if (ctor_argc == 1) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|b", &argument_ptr, &return_output) == FAILURE) {
@@ -1382,24 +1356,23 @@ static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *c
}
}
- INIT_PZVAL(&output);
+//??? INIT_PZVAL(&output);
/* Create object */
- MAKE_STD_ZVAL(reflector_ptr);
- if (object_and_properties_init(reflector_ptr, ce_ptr, NULL) == FAILURE) {
+ if (object_and_properties_init(&reflector, ce_ptr, NULL) == FAILURE) {
_DO_THROW("Could not create reflector");
}
/* Call __construct() */
- params[0] = &argument_ptr;
- params[1] = &argument2_ptr;
+ ZVAL_COPY_VALUE(&params[0], argument_ptr);
+ ZVAL_COPY_VALUE(&params[1], argument2_ptr);
fci.size = sizeof(fci);
fci.function_table = NULL;
- fci.function_name = NULL;
+ ZVAL_UNDEF(&fci.function_name);
fci.symbol_table = NULL;
- fci.object_ptr = reflector_ptr;
- fci.retval_ptr_ptr = &retval_ptr;
+ fci.object_ptr = &reflector;
+ fci.retval = &retval;
fci.param_count = ctor_argc;
fci.params = params;
fci.no_separation = 1;
@@ -1407,34 +1380,32 @@ static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *c
fcc.initialized = 1;
fcc.function_handler = ce_ptr->constructor;
fcc.calling_scope = ce_ptr;
- fcc.called_scope = Z_OBJCE_P(reflector_ptr);
- fcc.object_ptr = reflector_ptr;
+ fcc.called_scope = Z_OBJCE(reflector);
+ fcc.object_ptr = &reflector;
result = zend_call_function(&fci, &fcc TSRMLS_CC);
- if (retval_ptr) {
- zval_ptr_dtor(&retval_ptr);
- }
+ zval_ptr_dtor(&retval);
if (EG(exception)) {
- zval_ptr_dtor(&reflector_ptr);
+ zval_ptr_dtor(&reflector);
return;
}
if (result == FAILURE) {
- zval_ptr_dtor(&reflector_ptr);
+ zval_ptr_dtor(&reflector);
_DO_THROW("Could not create reflector");
}
/* Call static reflection::export */
ZVAL_BOOL(&output, return_output);
- params[0] = &reflector_ptr;
- params[1] = &output_ptr;
+ ZVAL_COPY_VALUE(&params[0], &reflector);
+ ZVAL_COPY_VALUE(&params[1], output_ptr);
- ZVAL_STRINGL(&fname, "reflection::export", sizeof("reflection::export") - 1, 0);
+//??? ZVAL_STRINGL(&fname, "reflection::export", sizeof("reflection::export") - 1, 0);
+ ZVAL_STRINGL(&fci.function_name, "reflection::export", sizeof("reflection::export") - 1);
fci.function_table = &reflection_ptr->function_table;
- fci.function_name = &fname;
fci.object_ptr = NULL;
- fci.retval_ptr_ptr = &retval_ptr;
+ fci.retval = &retval;
fci.param_count = 2;
fci.params = params;
fci.no_separation = 1;
@@ -1442,19 +1413,19 @@ static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *c
result = zend_call_function(&fci, NULL TSRMLS_CC);
if (result == FAILURE && EG(exception) == NULL) {
- zval_ptr_dtor(&reflector_ptr);
- zval_ptr_dtor(&retval_ptr);
+ zval_ptr_dtor(&reflector);
+ zval_ptr_dtor(&retval);
_DO_THROW("Could not execute reflection::export()");
}
if (return_output) {
- COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
+ COPY_PZVAL_TO_ZVAL(*return_value, &retval);
} else {
- zval_ptr_dtor(&retval_ptr);
+ zval_ptr_dtor(&retval);
}
/* Destruct reflector which is no longer needed */
- zval_ptr_dtor(&reflector_ptr);
+ zval_ptr_dtor(&reflector);
}
/* }}} */
@@ -1464,9 +1435,9 @@ static parameter_reference *_reflection_param_get_default_param(INTERNAL_FUNCTIO
reflection_object *intern;
parameter_reference *param;
- intern = (reflection_object *) zend_object_store_get_object(getThis() TSRMLS_CC);
+ intern = (reflection_object *) Z_OBJ_P(getThis());
if (intern == NULL || intern->ptr == NULL) {
- if (EG(exception) && Z_OBJCE_P(EG(exception)) == reflection_exception_ptr) {
+ if (EG(exception) && EG(exception)->ce == reflection_exception_ptr) {
return NULL;
}
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: Failed to retrieve the reflection object");
@@ -1513,7 +1484,7 @@ ZEND_METHOD(reflection, __clone)
Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
ZEND_METHOD(reflection, export)
{
- zval *object, fname, *retval_ptr;
+ zval *object, fname, retval;
int result;
zend_bool return_output = 0;
@@ -1522,8 +1493,8 @@ ZEND_METHOD(reflection, export)
}
/* Invoke the __toString() method */
- ZVAL_STRINGL(&fname, "__tostring", sizeof("__tostring") - 1, 1);
- result= call_user_function_ex(NULL, &object, &fname, &retval_ptr, 0, NULL, 0, NULL TSRMLS_CC);
+ ZVAL_STRINGL(&fname, "__tostring", sizeof("__tostring") - 1);
+ result= call_user_function_ex(NULL, object, &fname, &retval, 0, NULL, 0, NULL TSRMLS_CC);
zval_dtor(&fname);
if (result == FAILURE) {
@@ -1531,18 +1502,18 @@ ZEND_METHOD(reflection, export)
/* Returns from this function */
}
- if (!retval_ptr) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::__toString() did not return anything", Z_OBJCE_P(object)->name);
+ if (Z_TYPE(retval) == IS_UNDEF) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::__toString() did not return anything", Z_OBJCE_P(object)->name->val);
RETURN_FALSE;
}
if (return_output) {
- COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
+ COPY_PZVAL_TO_ZVAL(*return_value, &retval);
} else {
/* No need for _r variant, return of __toString should always be a string */
- zend_print_zval(retval_ptr, 0);
+ zend_print_zval(&retval, 0);
zend_printf("\n");
- zval_ptr_dtor(&retval_ptr);
+ zval_ptr_dtor(&retval);
}
}
/* }}} */
@@ -1600,7 +1571,7 @@ ZEND_METHOD(reflection_function, export)
Constructor. Throws an Exception in case the given function does not exist */
ZEND_METHOD(reflection_function, __construct)
{
- zval *name;
+ zval name;
zval *object;
zval *closure = NULL;
char *lcname;
@@ -1610,7 +1581,7 @@ ZEND_METHOD(reflection_function, __construct)
int name_len;
object = getThis();
- intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
+ intern = (reflection_object *) Z_OBJ_P(object);
if (intern == NULL) {
return;
}
@@ -1630,7 +1601,7 @@ ZEND_METHOD(reflection_function, __construct)
name_len--;
}
- if (zend_hash_find(EG(function_table), nsname, name_len + 1, (void **)&fptr) == FAILURE) {
+ if ((fptr = zend_hash_str_find_ptr(EG(function_table), nsname, name_len)) == NULL) {
efree(lcname);
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Function %s() does not exist", name_str);
@@ -1641,12 +1612,11 @@ ZEND_METHOD(reflection_function, __construct)
return;
}
- MAKE_STD_ZVAL(name);
- ZVAL_STRING(name, fptr->common.function_name, 1);
- reflection_update_property(object, "name", name);
+ ZVAL_STR(&name, STR_COPY(fptr->common.function_name));
+ reflection_update_property(object, "name", &name);
intern->ptr = fptr;
intern->ref_type = REF_TYPE_FUNCTION;
- intern->obj = closure;
+ ZVAL_COPY_VALUE(&intern->obj, closure);
intern->ce = NULL;
}
/* }}} */
@@ -1665,7 +1635,8 @@ ZEND_METHOD(reflection_function, __toString)
GET_REFLECTION_OBJECT_PTR(fptr);
string_init(&str);
_function_string(&str, fptr, intern->ce, "" TSRMLS_CC);
- RETURN_STRINGL(str.string, str.len - 1, 0);
+//??? RETURN_STRINGL(str.string, str.len - 1, 0);
+ RETURN_STRINGL(str.string, str.len - 1);
}
/* }}} */
@@ -1676,7 +1647,7 @@ ZEND_METHOD(reflection_function, getName)
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- _default_get_entry(getThis(), "name", sizeof("name"), return_value TSRMLS_CC);
+ _default_get_entry(getThis(), "name", sizeof("name")-1, return_value TSRMLS_CC);
}
/* }}} */
@@ -1707,8 +1678,8 @@ ZEND_METHOD(reflection_function, getClosureThis)
return;
}
GET_REFLECTION_OBJECT_PTR(fptr);
- if (intern->obj) {
- closure_this = zend_get_closure_this_ptr(intern->obj TSRMLS_CC);
+ if (Z_TYPE(intern->obj) != IS_UNDEF) {
+ closure_this = zend_get_closure_this_ptr(&intern->obj TSRMLS_CC);
if (closure_this) {
RETURN_ZVAL(closure_this, 1, 0);
}
@@ -1728,8 +1699,8 @@ ZEND_METHOD(reflection_function, getClosureScopeClass)
return;
}
GET_REFLECTION_OBJECT_PTR(fptr);
- if (intern->obj) {
- closure_func = zend_get_closure_method_def(intern->obj TSRMLS_CC);
+ if (Z_TYPE(intern->obj) != IS_UNDEF) {
+ closure_func = zend_get_closure_method_def(&intern->obj TSRMLS_CC);
if (closure_func && closure_func->common.scope) {
zend_reflection_class_factory(closure_func->common.scope, return_value TSRMLS_CC);
}
@@ -1809,7 +1780,7 @@ ZEND_METHOD(reflection_function, getFileName)
}
GET_REFLECTION_OBJECT_PTR(fptr);
if (fptr->type == ZEND_USER_FUNCTION) {
- RETURN_STRING(fptr->op_array.filename, 1);
+ RETURN_STR(STR_COPY(fptr->op_array.filename));
}
RETURN_FALSE;
}
@@ -1863,7 +1834,7 @@ ZEND_METHOD(reflection_function, getDocComment)
}
GET_REFLECTION_OBJECT_PTR(fptr);
if (fptr->type == ZEND_USER_FUNCTION && fptr->op_array.doc_comment) {
- RETURN_STRINGL(fptr->op_array.doc_comment, fptr->op_array.doc_comment_len, 1);
+ RETURN_STR(STR_COPY(fptr->op_array.doc_comment));
}
RETURN_FALSE;
}
@@ -1873,7 +1844,6 @@ ZEND_METHOD(reflection_function, getDocComment)
Returns an associative array containing this function's static variables and their values */
ZEND_METHOD(reflection_function, getStaticVariables)
{
- zval *tmp_copy;
reflection_object *intern;
zend_function *fptr;
@@ -1886,7 +1856,7 @@ ZEND_METHOD(reflection_function, getStaticVariables)
array_init(return_value);
if (fptr->type == ZEND_USER_FUNCTION && fptr->op_array.static_variables != NULL) {
zend_hash_apply_with_argument(fptr->op_array.static_variables, (apply_func_arg_t) zval_update_constant_inline_change, fptr->common.scope TSRMLS_CC);
- zend_hash_copy(Z_ARRVAL_P(return_value), fptr->op_array.static_variables, (copy_ctor_func_t) zval_add_ref, (void *) &tmp_copy, sizeof(zval *));
+ zend_hash_copy(Z_ARRVAL_P(return_value), fptr->op_array.static_variables, zval_add_ref);
}
}
/* }}} */
@@ -1895,8 +1865,9 @@ ZEND_METHOD(reflection_function, getStaticVariables)
Invokes the function */
ZEND_METHOD(reflection_function, invoke)
{
- zval *retval_ptr;
- zval ***params = NULL;
+ zval retval;
+//???
+ zval *params = NULL;
int result, num_args = 0;
zend_fcall_info fci;
zend_fcall_info_cache fcc;
@@ -1912,10 +1883,10 @@ ZEND_METHOD(reflection_function, invoke)
fci.size = sizeof(fci);
fci.function_table = NULL;
- fci.function_name = NULL;
+ ZVAL_UNDEF(&fci.function_name);
fci.symbol_table = NULL;
fci.object_ptr = NULL;
- fci.retval_ptr_ptr = &retval_ptr;
+ fci.retval = &retval;
fci.param_count = num_args;
fci.params = params;
fci.no_separation = 1;
@@ -1938,15 +1909,16 @@ ZEND_METHOD(reflection_function, invoke)
return;
}
- if (retval_ptr) {
- COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
+ if (Z_TYPE(retval) != IS_UNDEF) {
+ COPY_PZVAL_TO_ZVAL(*return_value, &retval);
}
}
/* }}} */
-static int _zval_array_to_c_array(zval **arg, zval ****params TSRMLS_DC) /* {{{ */
+static int _zval_array_to_c_array(zval *arg, zval **params TSRMLS_DC) /* {{{ */
{
- *(*params)++ = arg;
+ ZVAL_COPY_VALUE((*params), arg);
+ (*params)++;
return ZEND_HASH_APPLY_KEEP;
} /* }}} */
@@ -1954,8 +1926,8 @@ static int _zval_array_to_c_array(zval **arg, zval ****params TSRMLS_DC) /* {{{
Invokes the function and pass its arguments as array. */
ZEND_METHOD(reflection_function, invokeArgs)
{
- zval *retval_ptr;
- zval ***params;
+ zval retval;
+ zval *params;
int result;
int argc;
zend_fcall_info fci;
@@ -1973,16 +1945,16 @@ ZEND_METHOD(reflection_function, invokeArgs)
argc = zend_hash_num_elements(Z_ARRVAL_P(param_array));
- params = safe_emalloc(sizeof(zval **), argc, 0);
+ params = safe_emalloc(sizeof(zval), argc, 0);
zend_hash_apply_with_argument(Z_ARRVAL_P(param_array), (apply_func_arg_t)_zval_array_to_c_array, &params TSRMLS_CC);
params -= argc;
fci.size = sizeof(fci);
fci.function_table = NULL;
- fci.function_name = NULL;
+ ZVAL_UNDEF(&fci.function_name);
fci.symbol_table = NULL;
fci.object_ptr = NULL;
- fci.retval_ptr_ptr = &retval_ptr;
+ fci.retval = &retval;
fci.param_count = argc;
fci.params = params;
fci.no_separation = 1;
@@ -2003,8 +1975,8 @@ ZEND_METHOD(reflection_function, invokeArgs)
return;
}
- if (retval_ptr) {
- COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
+ if (Z_TYPE(retval) != IS_UNDEF) {
+ COPY_PZVAL_TO_ZVAL(*return_value, &retval);
}
}
/* }}} */
@@ -2067,11 +2039,10 @@ ZEND_METHOD(reflection_function, getParameters)
array_init(return_value);
for (i = 0; i < fptr->common.num_args; i++) {
- zval *parameter;
+ zval parameter;
- ALLOC_ZVAL(parameter);
- reflection_parameter_factory(_copy_function(fptr TSRMLS_CC), intern->obj, arg_info, i, fptr->common.required_num_args, parameter TSRMLS_CC);
- add_next_index_zval(return_value, parameter);
+ reflection_parameter_factory(_copy_function(fptr TSRMLS_CC), &intern->obj, arg_info, i, fptr->common.required_num_args, &parameter TSRMLS_CC);
+ add_next_index_zval(return_value, &parameter);
arg_info++;
}
@@ -2119,7 +2090,7 @@ ZEND_METHOD(reflection_function, getExtensionName)
internal = (zend_internal_function *)fptr;
if (internal->module) {
- RETURN_STRING(internal->module->name, 1);
+ RETURN_STRING(internal->module->name);
} else {
RETURN_FALSE;
}
@@ -2139,9 +2110,9 @@ ZEND_METHOD(reflection_parameter, export)
ZEND_METHOD(reflection_parameter, __construct)
{
parameter_reference *ref;
- zval *reference, **parameter;
+ zval *reference, *parameter;
zval *object;
- zval *name;
+ zval name;
reflection_object *intern;
zend_function *fptr;
struct _zend_arg_info *arg_info;
@@ -2149,12 +2120,12 @@ ZEND_METHOD(reflection_parameter, __construct)
zend_class_entry *ce = NULL;
zend_bool is_closure = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zZ", &reference, &parameter) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &reference, &parameter) == FAILURE) {
return;
}
object = getThis();
- intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
+ intern = (reflection_object *) Z_OBJ_P(object);
if (intern == NULL) {
return;
}
@@ -2167,7 +2138,7 @@ ZEND_METHOD(reflection_parameter, __construct)
lcname_len = Z_STRLEN_P(reference);
lcname = zend_str_tolower_dup(Z_STRVAL_P(reference), lcname_len);
- if (zend_hash_find(EG(function_table), lcname, lcname_len + 1, (void**) &fptr) == FAILURE) {
+ if ((fptr = zend_hash_str_find_ptr(EG(function_table), lcname, lcname_len)) == NULL) {
efree(lcname);
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Function %s() does not exist", Z_STRVAL_P(reference));
@@ -2179,45 +2150,43 @@ ZEND_METHOD(reflection_parameter, __construct)
break;
case IS_ARRAY: {
- zval **classref;
- zval **method;
- zend_class_entry **pce;
+ zval *classref;
+ zval *method;
unsigned int lcname_len;
char *lcname;
- if ((zend_hash_index_find(Z_ARRVAL_P(reference), 0, (void **) &classref) == FAILURE)
- || (zend_hash_index_find(Z_ARRVAL_P(reference), 1, (void **) &method) == FAILURE))
+ if (((classref =zend_hash_index_find(Z_ARRVAL_P(reference), 0)) == NULL)
+ || ((method = zend_hash_index_find(Z_ARRVAL_P(reference), 1)) == NULL))
{
_DO_THROW("Expected array($object, $method) or array($classname, $method)");
/* returns out of this function */
}
- if (Z_TYPE_PP(classref) == IS_OBJECT) {
- ce = Z_OBJCE_PP(classref);
+ if (Z_TYPE_P(classref) == IS_OBJECT) {
+ ce = Z_OBJCE_P(classref);
} else {
convert_to_string_ex(classref);
- if (zend_lookup_class(Z_STRVAL_PP(classref), Z_STRLEN_PP(classref), &pce TSRMLS_CC) == FAILURE) {
+ if ((ce = zend_lookup_class(Z_STR_P(classref) TSRMLS_CC)) == NULL) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
- "Class %s does not exist", Z_STRVAL_PP(classref));
+ "Class %s does not exist", Z_STRVAL_P(classref));
return;
}
- ce = *pce;
}
convert_to_string_ex(method);
- lcname_len = Z_STRLEN_PP(method);
- lcname = zend_str_tolower_dup(Z_STRVAL_PP(method), lcname_len);
- if (ce == zend_ce_closure && Z_TYPE_PP(classref) == IS_OBJECT
+ lcname_len = Z_STRLEN_P(method);
+ lcname = zend_str_tolower_dup(Z_STRVAL_P(method), lcname_len);
+ if (ce == zend_ce_closure && Z_TYPE_P(classref) == IS_OBJECT
&& (lcname_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1)
&& memcmp(lcname, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0
- && (fptr = zend_get_closure_invoke_method(*classref TSRMLS_CC)) != NULL)
+ && (fptr = zend_get_closure_invoke_method(classref TSRMLS_CC)) != NULL)
{
/* nothing to do. don't set is_closure since is the invoke handler,
- not the closure itself */
- } else if (zend_hash_find(&ce->function_table, lcname, lcname_len + 1, (void **) &fptr) == FAILURE) {
+ } else if ((fptr = zend_hash_str_find_ptr(&ce->function_table, lcname, lcname_len)) == NULL) {
efree(lcname);
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
- "Method %s::%s() does not exist", ce->name, Z_STRVAL_PP(method));
+ "Method %s::%s() does not exist", ce->name->val, Z_STRVAL_P(method));
return;
}
efree(lcname);
@@ -2231,7 +2200,7 @@ ZEND_METHOD(reflection_parameter, __construct)
fptr = (zend_function *)zend_get_closure_method_def(reference TSRMLS_CC);
Z_ADDREF_P(reference);
is_closure = 1;
- } else if (zend_hash_find(&ce->function_table, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME), (void **)&fptr) == FAILURE) {
+ } else if ((fptr = zend_hash_str_find_ptr(&ce->function_table, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME))) == NULL) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Method %s::%s() does not exist", ce->name, ZEND_INVOKE_FUNC_NAME);
return;
@@ -2246,17 +2215,17 @@ ZEND_METHOD(reflection_parameter, __construct)
/* Now, search for the parameter */
arg_info = fptr->common.arg_info;
- if (Z_TYPE_PP(parameter) == IS_LONG) {
- position= Z_LVAL_PP(parameter);
+ if (Z_TYPE_P(parameter) == IS_LONG) {
+ position= Z_LVAL_P(parameter);
if (position < 0 || (zend_uint)position >= fptr->common.num_args) {
if (fptr->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) {
if (fptr->type != ZEND_OVERLOADED_FUNCTION) {
- efree((char*)fptr->common.function_name);
+ STR_RELEASE(fptr->common.function_name);
}
efree(fptr);
}
if (is_closure) {
- zval_ptr_dtor(&reference);
+ zval_ptr_dtor(reference);
}
_DO_THROW("The parameter specified by its offset could not be found");
/* returns out of this function */
@@ -2267,7 +2236,7 @@ ZEND_METHOD(reflection_parameter, __construct)
position= -1;
convert_to_string_ex(parameter);
for (i = 0; i < fptr->common.num_args; i++) {
- if (arg_info[i].name && strcmp(arg_info[i].name, Z_STRVAL_PP(parameter)) == 0) {
+ if (arg_info[i].name && strcmp(arg_info[i].name, Z_STRVAL_P(parameter)) == 0) {
position= i;
break;
}
@@ -2275,25 +2244,24 @@ ZEND_METHOD(reflection_parameter, __construct)
if (position == -1) {
if (fptr->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) {
if (fptr->type != ZEND_OVERLOADED_FUNCTION) {
- efree((char*)fptr->common.function_name);
+ STR_RELEASE(fptr->common.function_name);
}
efree(fptr);
}
if (is_closure) {
- zval_ptr_dtor(&reference);
+ zval_ptr_dtor(reference);
}
_DO_THROW("The parameter specified by its name could not be found");
/* returns out of this function */
}
}
- MAKE_STD_ZVAL(name);
if (arg_info[position].name) {
- ZVAL_STRINGL(name, arg_info[position].name, arg_info[position].name_len, 1);
+ ZVAL_STRINGL(&name, arg_info[position].name, arg_info[position].name_len);
} else {
- ZVAL_NULL(name);
+ ZVAL_NULL(&name);
}
- reflection_update_property(object, "name", name);
+ reflection_update_property(object, "name", &name);
ref = (parameter_reference*) emalloc(sizeof(parameter_reference));
ref->arg_info = &arg_info[position];
@@ -2305,7 +2273,7 @@ ZEND_METHOD(reflection_parameter, __construct)
intern->ref_type = REF_TYPE_PARAMETER;
intern->ce = ce;
if (reference && is_closure) {
- intern->obj = reference;
+ ZVAL_COPY_VALUE(&intern->obj, reference);
}
}
/* }}} */
@@ -2324,7 +2292,8 @@ ZEND_METHOD(reflection_parameter, __toString)
GET_REFLECTION_OBJECT_PTR(param);
string_init(&str);
_parameter_string(&str, param->fptr, param->arg_info, param->offset, param->required, "" TSRMLS_CC);
- RETURN_STRINGL(str.string, str.len - 1, 0);
+///??? RETURN_STRINGL(str.string, str.len - 1, 0);
+ RETURN_STRINGL(str.string, str.len - 1);
}
/* }}} */
@@ -2335,7 +2304,7 @@ ZEND_METHOD(reflection_parameter, getName)
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- _default_get_entry(getThis(), "name", sizeof("name"), return_value TSRMLS_CC);
+ _default_get_entry(getThis(), "name", sizeof("name")-1, return_value TSRMLS_CC);
}
/* }}} */
@@ -2352,9 +2321,9 @@ ZEND_METHOD(reflection_parameter, getDeclaringFunction)
GET_REFLECTION_OBJECT_PTR(param);
if (!param->fptr->common.scope) {
- reflection_function_factory(_copy_function(param->fptr TSRMLS_CC), intern->obj, return_value TSRMLS_CC);
+ reflection_function_factory(_copy_function(param->fptr TSRMLS_CC), &intern->obj, return_value TSRMLS_CC);
} else {
- reflection_method_factory(param->fptr->common.scope, _copy_function(param->fptr TSRMLS_CC), intern->obj, return_value TSRMLS_CC);
+ reflection_method_factory(param->fptr->common.scope, _copy_function(param->fptr TSRMLS_CC), &intern->obj, return_value TSRMLS_CC);
}
}
/* }}} */
@@ -2383,7 +2352,7 @@ ZEND_METHOD(reflection_parameter, getClass)
{
reflection_object *intern;
parameter_reference *param;
- zend_class_entry **pce, *ce;
+ zend_class_entry *ce;
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -2410,7 +2379,6 @@ ZEND_METHOD(reflection_parameter, getClass)
"Parameter uses 'self' as type hint but function is not a class member!");
return;
}
- pce= &ce;
} else if (0 == zend_binary_strcasecmp(param->arg_info->class_name, param->arg_info->class_name_len, "parent", sizeof("parent")- 1)) {
ce = param->fptr->common.scope;
if (!ce) {
@@ -2423,13 +2391,18 @@ ZEND_METHOD(reflection_parameter, getClass)
"Parameter uses 'parent' as type hint although class does not have a parent!");
return;
}
- pce= &ce->parent;
- } else if (zend_lookup_class(param->arg_info->class_name, param->arg_info->class_name_len, &pce TSRMLS_CC) == FAILURE) {
- zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
- "Class %s does not exist", param->arg_info->class_name);
- return;
+ ce = ce->parent;
+ } else {
+ zend_string *name = STR_INIT(param->arg_info->class_name, param->arg_info->class_name_len, 0);
+ ce = zend_lookup_class(name TSRMLS_CC);
+ STR_FREE(name);
+ if (!ce) {
+ zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
+ "Class %s does not exist", param->arg_info->class_name);
+ return;
+ }
}
- zend_reflection_class_factory(*pce, return_value TSRMLS_CC);
+ zend_reflection_class_factory(ce, return_value TSRMLS_CC);
}
}
/* }}} */
@@ -2594,12 +2567,12 @@ ZEND_METHOD(reflection_parameter, getDefaultValue)
return;
}
- *return_value = *precv->op2.zv;
- INIT_PZVAL(return_value);
+ ZVAL_COPY_VALUE(return_value, precv->op2.zv);
+//??? INIT_PZVAL(return_value);
if (!IS_CONSTANT_TYPE(Z_TYPE_P(return_value))) {
zval_copy_ctor(return_value);
}
- zval_update_constant_ex(&return_value, (void*)0, param->fptr->common.scope TSRMLS_CC);
+ zval_update_constant_ex(return_value, (void*)0, param->fptr->common.scope TSRMLS_CC);
}
/* }}} */
@@ -2646,7 +2619,7 @@ ZEND_METHOD(reflection_parameter, getDefaultValueConstantName)
precv = _reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAM_PASSTHRU, param);
if (precv && (Z_TYPE_P(precv->op2.zv) & IS_CONSTANT_TYPE_MASK) == IS_CONSTANT) {
- RETURN_STRINGL(Z_STRVAL_P(precv->op2.zv), Z_STRLEN_P(precv->op2.zv), 1);
+ RETURN_STR(STR_COPY(Z_STR_P(precv->op2.zv)));
}
}
/* }}} */
@@ -2679,11 +2652,10 @@ ZEND_METHOD(reflection_method, export)
Constructor. Throws an Exception in case the given method does not exist */
ZEND_METHOD(reflection_method, __construct)
{
- zval *name, *classname;
+ zval name, *classname;
zval *object, *orig_obj;
reflection_object *intern;
char *lcname;
- zend_class_entry **pce;
zend_class_entry *ce;
zend_function *mptr;
char *name_str, *tmp;
@@ -2700,7 +2672,7 @@ ZEND_METHOD(reflection_method, __construct)
}
classname = &ztmp;
tmp_len = tmp - name_str;
- ZVAL_STRINGL(classname, name_str, tmp_len, 1);
+ ZVAL_STRINGL(classname, name_str, tmp_len);
name_len = name_len - (tmp_len + 2);
name_str = tmp + 2;
orig_obj = NULL;
@@ -2711,7 +2683,7 @@ ZEND_METHOD(reflection_method, __construct)
}
object = getThis();
- intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
+ intern = (reflection_object *) Z_OBJ_P(object);
if (intern == NULL) {
return;
}
@@ -2719,7 +2691,7 @@ ZEND_METHOD(reflection_method, __construct)
/* Find the class entry */
switch (Z_TYPE_P(classname)) {
case IS_STRING:
- if (zend_lookup_class(Z_STRVAL_P(classname), Z_STRLEN_P(classname), &pce TSRMLS_CC) == FAILURE) {
+ if ((ce = zend_lookup_class(Z_STR_P(classname) TSRMLS_CC)) == NULL) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Class %s does not exist", Z_STRVAL_P(classname));
if (classname == &ztmp) {
@@ -2727,7 +2699,6 @@ ZEND_METHOD(reflection_method, __construct)
}
return;
}
- ce = *pce;
break;
case IS_OBJECT:
@@ -2753,22 +2724,18 @@ ZEND_METHOD(reflection_method, __construct)
&& (mptr = zend_get_closure_invoke_method(orig_obj TSRMLS_CC)) != NULL)
{
/* do nothing, mptr already set */
- } else if (zend_hash_find(&ce->function_table, lcname, name_len + 1, (void **) &mptr) == FAILURE) {
+ } else if ((mptr = zend_hash_str_find_ptr(&ce->function_table, lcname, name_len)) == NULL) {
efree(lcname);
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
- "Method %s::%s() does not exist", ce->name, name_str);
+ "Method %s::%s() does not exist", ce->name->val, name_str);
return;
}
efree(lcname);
- MAKE_STD_ZVAL(classname);
- ZVAL_STRINGL(classname, mptr->common.scope->name, mptr->common.scope->name_length, 1);
-
- reflection_update_property(object, "class", classname);
-
- MAKE_STD_ZVAL(name);
- ZVAL_STRING(name, mptr->common.function_name, 1);
- reflection_update_property(object, "name", name);
+ ZVAL_STR(&name, STR_COPY(mptr->common.scope->name));
+ reflection_update_property(object, "class", &name);
+ ZVAL_STR(&name, STR_COPY(mptr->common.function_name));
+ reflection_update_property(object, "name", &name);
intern->ptr = mptr;
intern->ref_type = REF_TYPE_FUNCTION;
intern->ce = ce;
@@ -2789,7 +2756,8 @@ ZEND_METHOD(reflection_method, __toString)
GET_REFLECTION_OBJECT_PTR(mptr);
string_init(&str);
_function_string(&str, mptr, intern->ce, "" TSRMLS_CC);
- RETURN_STRINGL(str.string, str.len - 1, 0);
+//??? RETURN_STRINGL(str.string, str.len - 1, 0);
+ RETURN_STRINGL(str.string, str.len - 1);
}
/* }}} */
@@ -2832,9 +2800,10 @@ ZEND_METHOD(reflection_method, getClosure)
Invokes the method. */
ZEND_METHOD(reflection_method, invoke)
{
- zval *retval_ptr;
- zval ***params = NULL;
- zval *object_ptr;
+ zval retval;
+//???
+ zval *params = NULL;
+ zval object;
reflection_object *intern;
zend_function *mptr;
int result, num_args = 0;
@@ -2875,16 +2844,16 @@ ZEND_METHOD(reflection_method, invoke)
* Else, we verify that the given object is an instance of the class.
*/
if (mptr->common.fn_flags & ZEND_ACC_STATIC) {
- object_ptr = NULL;
+ ZVAL_UNDEF(&object);
obj_ce = mptr->common.scope;
} else {
- if (Z_TYPE_PP(params[0]) != IS_OBJECT) {
+ if (Z_TYPE(params[0]) != IS_OBJECT) {
efree(params);
_DO_THROW("Non-object passed to Invoke()");
/* Returns from this function */
}
- obj_ce = Z_OBJCE_PP(params[0]);
+ obj_ce = Z_OBJCE(params[0]);
if (!instanceof_function(obj_ce, mptr->common.scope TSRMLS_CC)) {
if (params) {
@@ -2894,15 +2863,15 @@ ZEND_METHOD(reflection_method, invoke)
/* Returns from this function */
}
- object_ptr = *params[0];
+ ZVAL_COPY_VALUE(&object, &params[0]);
}
fci.size = sizeof(fci);
fci.function_table = NULL;
- fci.function_name = NULL;
+ ZVAL_UNDEF(&fci.function_name);
fci.symbol_table = NULL;
- fci.object_ptr = object_ptr;
- fci.retval_ptr_ptr = &retval_ptr;
+ fci.object_ptr = &object;
+ fci.retval = &retval;
fci.param_count = num_args - 1;
fci.params = params + 1;
fci.no_separation = 1;
@@ -2911,7 +2880,7 @@ ZEND_METHOD(reflection_method, invoke)
fcc.function_handler = mptr;
fcc.calling_scope = obj_ce;
fcc.called_scope = intern->ce;
- fcc.object_ptr = object_ptr;
+ fcc.object_ptr = &object;
result = zend_call_function(&fci, &fcc TSRMLS_CC);
@@ -2925,8 +2894,8 @@ ZEND_METHOD(reflection_method, invoke)
return;
}
- if (retval_ptr) {
- COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
+ if (Z_TYPE(retval) != IS_UNDEF) {
+ COPY_PZVAL_TO_ZVAL(*return_value, &retval);
}
}
/* }}} */
@@ -2935,8 +2904,8 @@ ZEND_METHOD(reflection_method, invoke)
Invokes the function and pass its arguments as array. */
ZEND_METHOD(reflection_method, invokeArgs)
{
- zval *retval_ptr;
- zval ***params;
+ zval retval;
+ zval *params;
zval *object;
reflection_object *intern;
zend_function *mptr;
@@ -2975,7 +2944,7 @@ ZEND_METHOD(reflection_method, invokeArgs)
argc = zend_hash_num_elements(Z_ARRVAL_P(param_array));
- params = safe_emalloc(sizeof(zval **), argc, 0);
+ params = safe_emalloc(sizeof(zval), argc, 0);
zend_hash_apply_with_argument(Z_ARRVAL_P(param_array), (apply_func_arg_t)_zval_array_to_c_array, &params TSRMLS_CC);
params -= argc;
@@ -3008,10 +2977,10 @@ ZEND_METHOD(reflection_method, invokeArgs)
fci.size = sizeof(fci);
fci.function_table = NULL;
- fci.function_name = NULL;
+ ZVAL_UNDEF(&fci.function_name);
fci.symbol_table = NULL;
fci.object_ptr = object;
- fci.retval_ptr_ptr = &retval_ptr;
+ fci.retval = &retval;
fci.param_count = argc;
fci.params = params;
fci.no_separation = 1;
@@ -3040,8 +3009,8 @@ ZEND_METHOD(reflection_method, invokeArgs)
return;
}
- if (retval_ptr) {
- COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
+ if (Z_TYPE(retval) != IS_UNDEF) {
+ COPY_PZVAL_TO_ZVAL(*return_value, &retval);
}
}
/* }}} */
@@ -3122,18 +3091,18 @@ ZEND_METHOD(reflection_function, isVariadic)
Returns whether this function is defined in namespace */
ZEND_METHOD(reflection_function, inNamespace)
{
- zval **name;
+ zval *name;
const char *backslash;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) {
+ if ((name = zend_hash_str_find(Z_OBJPROP_P(getThis()), "name", sizeof("name")-1)) == NULL) {
RETURN_FALSE;
}
- if (Z_TYPE_PP(name) == IS_STRING
- && (backslash = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name)))
- && backslash > Z_STRVAL_PP(name))
+ if (Z_TYPE_P(name) == IS_STRING
+ && (backslash = zend_memrchr(Z_STRVAL_P(name), '\\', Z_STRLEN_P(name)))
+ && backslash > Z_STRVAL_P(name))
{
RETURN_TRUE;
}
@@ -3145,20 +3114,20 @@ ZEND_METHOD(reflection_function, inNamespace)
Returns the name of namespace where this function is defined */
ZEND_METHOD(reflection_function, getNamespaceName)
{
- zval **name;
+ zval *name;
const char *backslash;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) {
+ if ((name = zend_hash_str_find(Z_OBJPROP_P(getThis()), "name", sizeof("name")-1)) == NULL) {
RETURN_FALSE;
}
- if (Z_TYPE_PP(name) == IS_STRING
- && (backslash = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name)))
- && backslash > Z_STRVAL_PP(name))
+ if (Z_TYPE_P(name) == IS_STRING
+ && (backslash = zend_memrchr(Z_STRVAL_P(name), '\\', Z_STRLEN_P(name)))
+ && backslash > Z_STRVAL_P(name))
{
- RETURN_STRINGL(Z_STRVAL_PP(name), backslash - Z_STRVAL_PP(name), 1);
+ RETURN_STRINGL(Z_STRVAL_P(name), backslash - Z_STRVAL_P(name));
}
RETURN_EMPTY_STRING();
}
@@ -3168,22 +3137,22 @@ ZEND_METHOD(reflection_function, getNamespaceName)
Returns the short name of the function (without namespace part) */
ZEND_METHOD(reflection_function, getShortName)
{
- zval **name;
+ zval *name;
const char *backslash;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) {
+ if ((name = zend_hash_str_find(Z_OBJPROP_P(getThis()), "name", sizeof("name")-1)) == NULL) {
RETURN_FALSE;
}
- if (Z_TYPE_PP(name) == IS_STRING
- && (backslash = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name)))
- && backslash > Z_STRVAL_PP(name))
+ if (Z_TYPE_P(name) == IS_STRING
+ && (backslash = zend_memrchr(Z_STRVAL_P(name), '\\', Z_STRLEN_P(name)))
+ && backslash > Z_STRVAL_P(name))
{
- RETURN_STRINGL(backslash + 1, Z_STRLEN_PP(name) - (backslash - Z_STRVAL_PP(name) + 1), 1);
+ RETURN_STRINGL(backslash + 1, Z_STRLEN_P(name) - (backslash - Z_STRVAL_P(name) + 1));
}
- RETURN_ZVAL(*name, 1, 0);
+ RETURN_ZVAL(name, 1, 0);
}
/* }}} */
@@ -3289,7 +3258,7 @@ ZEND_METHOD(reflection_method, setAccessible)
return;
}
- intern = (reflection_object *) zend_object_store_get_object(getThis() TSRMLS_CC);
+ intern = (reflection_object *) Z_OBJ_P(getThis());
if (intern == NULL) {
return;
@@ -3312,9 +3281,9 @@ static void reflection_class_object_ctor(INTERNAL_FUNCTION_PARAMETERS, int is_ob
{
zval *argument;
zval *object;
- zval *classname;
+ zval classname;
reflection_object *intern;
- zend_class_entry **ce;
+ zend_class_entry *ce;
if (is_object) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &argument) == FAILURE) {
@@ -3327,34 +3296,32 @@ static void reflection_class_object_ctor(INTERNAL_FUNCTION_PARAMETERS, int is_ob
}
object = getThis();
- intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
+ intern = (reflection_object *) Z_OBJ_P(object);
if (intern == NULL) {
return;
}
if (Z_TYPE_P(argument) == IS_OBJECT) {
- MAKE_STD_ZVAL(classname);
- ZVAL_STRINGL(classname, Z_OBJCE_P(argument)->name, Z_OBJCE_P(argument)->name_length, 1);
- reflection_update_property(object, "name", classname);
+ ZVAL_STR(&classname, STR_COPY(Z_OBJCE_P(argument)->name));
+ reflection_update_property(object, "name", &classname);
intern->ptr = Z_OBJCE_P(argument);
if (is_object) {
- intern->obj = argument;
- zval_add_ref(&argument);
+ ZVAL_COPY_VALUE(&intern->obj, argument);
+ zval_add_ref(argument);
}
} else {
- convert_to_string_ex(&argument);
- if (zend_lookup_class(Z_STRVAL_P(argument), Z_STRLEN_P(argument), &ce TSRMLS_CC) == FAILURE) {
+ convert_to_string_ex(argument);
+ if ((ce = zend_lookup_class(Z_STR_P(argument) TSRMLS_CC)) == NULL) {
if (!EG(exception)) {
zend_throw_exception_ex(reflection_exception_ptr, -1 TSRMLS_CC, "Class %s does not exist", Z_STRVAL_P(argument));
}
return;
}
- MAKE_STD_ZVAL(classname);
- ZVAL_STRINGL(classname, (*ce)->name, (*ce)->name_length, 1);
- reflection_update_property(object, "name", classname);
+ ZVAL_STR(&classname, STR_COPY(ce->name));
+ reflection_update_property(object, "name", &classname);
- intern->ptr = *ce;
+ intern->ptr = ce;
}
intern->ref_type = REF_TYPE_OTHER;
}
@@ -3373,14 +3340,13 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value
{
HashPosition pos;
zend_property_info *prop_info;
- zval *prop, *prop_copy;
- char *key;
- uint key_len;
+ zval *prop, prop_copy;
+ zend_string *key;
ulong num_index;
zend_hash_internal_pointer_reset_ex(&ce->properties_info, &pos);
- while (zend_hash_get_current_data_ex(&ce->properties_info, (void **) &prop_info, &pos) == SUCCESS) {
- zend_hash_get_current_key_ex(&ce->properties_info, &key, &key_len, &num_index, 0, &pos);
+ while ((prop_info = zend_hash_get_current_data_ptr_ex(&ce->properties_info, &pos)) != NULL) {
+ zend_hash_get_current_key_ex(&ce->properties_info, &key, &num_index, 0, &pos);
zend_hash_move_forward_ex(&ce->properties_info, &pos);
if (((prop_info->flags & ZEND_ACC_SHADOW) &&
prop_info->ce != ce) ||
@@ -3393,9 +3359,9 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value
prop = NULL;
if (prop_info->offset >= 0) {
if (statics && (prop_info->flags & ZEND_ACC_STATIC) != 0) {
- prop = ce->default_static_members_table[prop_info->offset];
+ prop = &ce->default_static_members_table[prop_info->offset];
} else if (!statics && (prop_info->flags & ZEND_ACC_STATIC) == 0) {
- prop = ce->default_properties_table[prop_info->offset];
+ prop = &ce->default_properties_table[prop_info->offset];
}
}
if (!prop) {
@@ -3403,18 +3369,17 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value
}
/* copy: enforce read only access */
- ALLOC_ZVAL(prop_copy);
- *prop_copy = *prop;
- zval_copy_ctor(prop_copy);
- INIT_PZVAL(prop_copy);
+ ZVAL_DUP(&prop_copy, prop);
+//??? INIT_PZVAL(prop_copy);
/* this is necessary to make it able to work with default array
* properties, returned to user */
- if (IS_CONSTANT_TYPE(Z_TYPE_P(prop_copy))) {
+ if (IS_CONSTANT_TYPE(Z_TYPE(prop_copy))) {
zval_update_constant(&prop_copy, (void *) 1 TSRMLS_CC);
}
- add_assoc_zval(return_value, key, prop_copy);
+//??? add_assoc_zval(return_value, key, &prop_copy);
+ add_assoc_zval(return_value, key->val, &prop_copy);
}
}
/* }}} */
@@ -3445,28 +3410,27 @@ ZEND_METHOD(reflection_class, getStaticPropertyValue)
{
reflection_object *intern;
zend_class_entry *ce;
- char *name;
- int name_len;
- zval **prop, *def_value = NULL;
+ zend_string *name;
+ zval *prop, *def_value = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &name, &name_len, &def_value) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|z", &name, &def_value) == FAILURE) {
return;
}
GET_REFLECTION_OBJECT_PTR(ce);
zend_update_class_constants(ce TSRMLS_CC);
- prop = zend_std_get_static_property(ce, name, name_len, 1, NULL TSRMLS_CC);
+ prop = zend_std_get_static_property(ce, name, 1, NULL TSRMLS_CC);
if (!prop) {
if (def_value) {
RETURN_ZVAL(def_value, 1, 0);
} else {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
- "Class %s does not have a property named %s", ce->name, name);
+ "Class %s does not have a property named %s", ce->name->val, name);
}
return;
} else {
- RETURN_ZVAL(*prop, 1, 0);
+ RETURN_ZVAL(prop, 1, 0);
}
}
/* }}} */
@@ -3477,32 +3441,30 @@ ZEND_METHOD(reflection_class, setStaticPropertyValue)
{
reflection_object *intern;
zend_class_entry *ce;
- char *name;
- int name_len;
- zval **variable_ptr, *value;
- int refcount;
- zend_uchar is_ref;
+ zend_string *name;
+ zval *variable_ptr, *value;
+//??? int refcount;
+//??? zend_uchar is_ref;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", &name, &name_len, &value) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sz", &name, &value) == FAILURE) {
return;
}
GET_REFLECTION_OBJECT_PTR(ce);
zend_update_class_constants(ce TSRMLS_CC);
- variable_ptr = zend_std_get_static_property(ce, name, name_len, 1, NULL TSRMLS_CC);
+ variable_ptr = zend_std_get_static_property(ce, name, 1, NULL TSRMLS_CC);
if (!variable_ptr) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
- "Class %s does not have a property named %s", ce->name, name);
+ "Class %s does not have a property named %s", ce->name->val, name);
return;
}
- refcount = Z_REFCOUNT_PP(variable_ptr);
- is_ref = Z_ISREF_PP(variable_ptr);
- zval_dtor(*variable_ptr);
- **variable_ptr = *value;
- zval_copy_ctor(*variable_ptr);
- Z_SET_REFCOUNT_PP(variable_ptr, refcount);
- Z_SET_ISREF_TO_PP(variable_ptr, is_ref);
+//??? refcount = Z_REFCOUNT_PP(variable_ptr);
+//??? is_ref = Z_ISREF_PP(variable_ptr);
+ zval_dtor(variable_ptr);
+ ZVAL_DUP(variable_ptr, value);
+//??? Z_SET_REFCOUNT_PP(variable_ptr, refcount);
+//??? Z_SET_ISREF_TO_PP(variable_ptr, is_ref);
}
/* }}} */
@@ -3538,8 +3500,9 @@ ZEND_METHOD(reflection_class, __toString)
}
GET_REFLECTION_OBJECT_PTR(ce);
string_init(&str);
- _class_string(&str, ce, intern->obj, "" TSRMLS_CC);
- RETURN_STRINGL(str.string, str.len - 1, 0);
+ _class_string(&str, ce, &intern->obj, "" TSRMLS_CC);
+//??? RETURN_STRINGL(str.string, str.len - 1, 0);
+ RETURN_STRINGL(str.string, str.len - 1);
}
/* }}} */
@@ -3550,7 +3513,7 @@ ZEND_METHOD(reflection_class, getName)
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- _default_get_entry(getThis(), "name", sizeof("name"), return_value TSRMLS_CC);
+ _default_get_entry(getThis(), "name", sizeof("name")-1, return_value TSRMLS_CC);
}
/* }}} */
@@ -3596,7 +3559,7 @@ ZEND_METHOD(reflection_class, getFileName)
}
GET_REFLECTION_OBJECT_PTR(ce);
if (ce->type == ZEND_USER_CLASS) {
- RETURN_STRING(ce->info.user.filename, 1);
+ RETURN_STR(STR_COPY(ce->info.user.filename));
}
RETURN_FALSE;
}
@@ -3650,7 +3613,7 @@ ZEND_METHOD(reflection_class, getDocComment)
}
GET_REFLECTION_OBJECT_PTR(ce);
if (ce->type == ZEND_USER_CLASS && ce->info.user.doc_comment) {
- RETURN_STRINGL(ce->info.user.doc_comment, ce->info.user.doc_comment_len, 1);
+ RETURN_STR(STR_COPY(ce->info.user.doc_comment));
}
RETURN_FALSE;
}
@@ -3694,7 +3657,7 @@ ZEND_METHOD(reflection_class, hasMethod)
lc_name = zend_str_tolower_dup(name, name_len);
if ((ce == zend_ce_closure && (name_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1)
&& memcmp(lc_name, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0)
- || zend_hash_exists(&ce->function_table, lc_name, name_len + 1)) {
+ || zend_hash_str_exists(&ce->function_table, lc_name, name_len)) {
efree(lc_name);
RETURN_TRUE;
} else {
@@ -3722,15 +3685,15 @@ ZEND_METHOD(reflection_class, getMethod)
GET_REFLECTION_OBJECT_PTR(ce);
lc_name = zend_str_tolower_dup(name, name_len);
- if (ce == zend_ce_closure && intern->obj && (name_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1)
+ if (ce == zend_ce_closure && Z_TYPE(intern->obj) != IS_UNDEF && (name_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1)
&& memcmp(lc_name, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0
- && (mptr = zend_get_closure_invoke_method(intern->obj TSRMLS_CC)) != NULL)
+ && (mptr = zend_get_closure_invoke_method(&intern->obj TSRMLS_CC)) != NULL)
{
/* don't assign closure_object since we only reflect the invoke handler
method and not the closure definition itself */
reflection_method_factory(ce, mptr, NULL, return_value TSRMLS_CC);
efree(lc_name);
- } else if (ce == zend_ce_closure && !intern->obj && (name_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1)
+ } else if (ce == zend_ce_closure && Z_TYPE(intern->obj) == IS_UNDEF && (name_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1)
&& memcmp(lc_name, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0
&& object_init_ex(&obj_tmp, ce) == SUCCESS && (mptr = zend_get_closure_invoke_method(&obj_tmp TSRMLS_CC)) != NULL) {
/* don't assign closure_object since we only reflect the invoke handler
@@ -3738,7 +3701,7 @@ ZEND_METHOD(reflection_class, getMethod)
reflection_method_factory(ce, mptr, NULL, return_value TSRMLS_CC);
zval_dtor(&obj_tmp);
efree(lc_name);
- } else if (zend_hash_find(&ce->function_table, lc_name, name_len + 1, (void**) &mptr) == SUCCESS) {
+ } else if ((mptr = zend_hash_str_find_ptr(&ce->function_table, lc_name, name_len)) != NULL) {
reflection_method_factory(ce, mptr, NULL, return_value TSRMLS_CC);
efree(lc_name);
} else {
@@ -3753,14 +3716,13 @@ ZEND_METHOD(reflection_class, getMethod)
/* {{{ _addmethod */
static void _addmethod(zend_function *mptr, zend_class_entry *ce, zval *retval, long filter, zval *obj TSRMLS_DC)
{
- zval *method;
- uint len = strlen(mptr->common.function_name);
+ zval method;
+ uint len = mptr->common.function_name->len;
zend_function *closure;
if (mptr->common.fn_flags & filter) {
- ALLOC_ZVAL(method);
if (ce == zend_ce_closure && obj && (len == sizeof(ZEND_INVOKE_FUNC_NAME)-1)
- && memcmp(mptr->common.function_name, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0
+ && memcmp(mptr->common.function_name->val, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0
&& (closure = zend_get_closure_invoke_method(obj TSRMLS_CC)) != NULL)
{
mptr = closure;
@@ -3768,8 +3730,8 @@ static void _addmethod(zend_function *mptr, zend_class_entry *ce, zval *retval,
/* don't assign closure_object since we only reflect the invoke handler
method and not the closure definition itself, even if we have a
closure */
- reflection_method_factory(ce, mptr, NULL, method TSRMLS_CC);
- add_next_index_zval(retval, method);
+ reflection_method_factory(ce, mptr, NULL, &method TSRMLS_CC);
+ add_next_index_zval(retval, &method);
}
}
/* }}} */
@@ -3810,10 +3772,10 @@ ZEND_METHOD(reflection_class, getMethods)
array_init(return_value);
zend_hash_apply_with_arguments(&ce->function_table TSRMLS_CC, (apply_func_args_t) _addmethod_va, 4, &ce, return_value, filter, intern->obj);
- if (intern->obj && instanceof_function(ce, zend_ce_closure TSRMLS_CC)) {
- zend_function *closure = zend_get_closure_invoke_method(intern->obj TSRMLS_CC);
+ if (Z_TYPE(intern->obj) != IS_UNDEF && instanceof_function(ce, zend_ce_closure TSRMLS_CC)) {
+ zend_function *closure = zend_get_closure_invoke_method(&intern->obj TSRMLS_CC);
if (closure) {
- _addmethod(closure, ce, return_value, filter, intern->obj TSRMLS_CC);
+ _addmethod(closure, ce, return_value, filter, &intern->obj TSRMLS_CC);
_free_function(closure TSRMLS_CC);
}
}
@@ -3827,26 +3789,24 @@ ZEND_METHOD(reflection_class, hasProperty)
reflection_object *intern;
zend_property_info *property_info;
zend_class_entry *ce;
- char *name;
- int name_len;
- zval *property;
+ zend_string *name;
+ zval property;
METHOD_NOTSTATIC(reflection_class_ptr);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &name) == FAILURE) {
return;
}
GET_REFLECTION_OBJECT_PTR(ce);
- if (zend_hash_find(&ce->properties_info, name, name_len+1, (void **) &property_info) == SUCCESS) {
+ if ((property_info = zend_hash_find_ptr(&ce->properties_info, name)) != NULL) {
if (property_info->flags & ZEND_ACC_SHADOW) {
RETURN_FALSE;
}
RETURN_TRUE;
} else {
- if (intern->obj && Z_OBJ_HANDLER_P(intern->obj, has_property)) {
- MAKE_STD_ZVAL(property);
- ZVAL_STRINGL(property, name, name_len, 1);
- if (Z_OBJ_HANDLER_P(intern->obj, has_property)(intern->obj, property, 2, 0 TSRMLS_CC)) {
+ if (Z_TYPE(intern->obj) != IS_UNDEF && Z_OBJ_HANDLER(intern->obj, has_property)) {
+ ZVAL_STR(&property, STR_COPY(name));
+ if (Z_OBJ_HANDLER(intern->obj, has_property)(&intern->obj, &property, 2, 0 TSRMLS_CC)) {
zval_ptr_dtor(&property);
RETURN_TRUE;
}
@@ -3862,75 +3822,77 @@ ZEND_METHOD(reflection_class, hasProperty)
ZEND_METHOD(reflection_class, getProperty)
{
reflection_object *intern;
- zend_class_entry *ce, **pce;
+ zend_class_entry *ce, *ce2;
zend_property_info *property_info;
- char *name, *tmp, *classname;
- int name_len, classname_len;
+ zend_string *name, *classname;
+ char *tmp, *str_name;
+ int classname_len, str_name_len;
METHOD_NOTSTATIC(reflection_class_ptr);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &name) == FAILURE) {
return;
}
GET_REFLECTION_OBJECT_PTR(ce);
- if (zend_hash_find(&ce->properties_info, name, name_len + 1, (void**) &property_info) == SUCCESS) {
+ if ((property_info = zend_hash_find_ptr(&ce->properties_info, name)) != NULL) {
if ((property_info->flags & ZEND_ACC_SHADOW) == 0) {
reflection_property_factory(ce, property_info, return_value TSRMLS_CC);
return;
}
- } else if (intern->obj) {
+ } else if (Z_TYPE(intern->obj) != IS_UNDEF) {
/* Check for dynamic properties */
- if (zend_hash_exists(Z_OBJ_HT_P(intern->obj)->get_properties(intern->obj TSRMLS_CC), name, name_len+1)) {
+ if (zend_hash_exists(Z_OBJ_HT(intern->obj)->get_properties(&intern->obj TSRMLS_CC), name)) {
zend_property_info property_info_tmp;
property_info_tmp.flags = ZEND_ACC_IMPLICIT_PUBLIC;
- property_info_tmp.name = estrndup(name, name_len);
- property_info_tmp.name_length = name_len;
- property_info_tmp.h = zend_get_hash_value(name, name_len+1);
+ property_info_tmp.name = STR_COPY(name);
property_info_tmp.doc_comment = NULL;
property_info_tmp.ce = ce;
reflection_property_factory(ce, &property_info_tmp, return_value TSRMLS_CC);
- intern = (reflection_object *) zend_object_store_get_object(return_value TSRMLS_CC);
+ intern = (reflection_object *) Z_OBJ_P(return_value);
intern->ref_type = REF_TYPE_DYNAMIC_PROPERTY;
return;
}
}
- if ((tmp = strstr(name, "::")) != NULL) {
- classname_len = tmp - name;
- classname = zend_str_tolower_dup(name, classname_len);
- classname[classname_len] = '\0';
- name_len = name_len - (classname_len + 2);
- name = tmp + 2;
-
- if (zend_lookup_class(classname, classname_len, &pce TSRMLS_CC) == FAILURE) {
+ str_name = name->val;
+ str_name_len = name->len;
+ if ((tmp = strstr(name->val, "::")) != NULL) {
+ classname_len = tmp - name->val;
+ classname = STR_ALLOC(classname_len, 0);
+ zend_str_tolower_copy(classname->val, name->val, classname_len);
+ classname->val[classname_len] = '\0';
+ str_name_len = name->len - (classname_len + 2);
+ str_name = tmp + 2;
+
+ ce2 = zend_lookup_class(classname TSRMLS_CC);
+ STR_FREE(classname);
+ if (!ce2) {
if (!EG(exception)) {
zend_throw_exception_ex(reflection_exception_ptr, -1 TSRMLS_CC, "Class %s does not exist", classname);
}
- efree(classname);
return;
}
- efree(classname);
- if (!instanceof_function(ce, *pce TSRMLS_CC)) {
- zend_throw_exception_ex(reflection_exception_ptr, -1 TSRMLS_CC, "Fully qualified property name %s::%s does not specify a base class of %s", (*pce)->name, name, ce->name);
+ if (!instanceof_function(ce, ce2 TSRMLS_CC)) {
+ zend_throw_exception_ex(reflection_exception_ptr, -1 TSRMLS_CC, "Fully qualified property name %s::%s does not specify a base class of %s", ce2->name, str_name, ce->name->val);
return;
}
- ce = *pce;
+ ce = ce2;
- if (zend_hash_find(&ce->properties_info, name, name_len + 1, (void**) &property_info) == SUCCESS && (property_info->flags & ZEND_ACC_SHADOW) == 0) {
+ if ((property_info = zend_hash_str_find_ptr(&ce->properties_info, str_name, str_name_len)) != NULL && (property_info->flags & ZEND_ACC_SHADOW) == 0) {
reflection_property_factory(ce, property_info, return_value TSRMLS_CC);
return;
}
}
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
- "Property %s does not exist", name);
+ "Property %s does not exist", str_name);
}
/* }}} */
/* {{{ _addproperty */
static int _addproperty(zend_property_info *pptr TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
{
- zval *property;
+ zval property;
zend_class_entry *ce = *va_arg(args, zend_class_entry**);
zval *retval = va_arg(args, zval*);
long filter = va_arg(args, long);
@@ -3940,38 +3902,36 @@ static int _addproperty(zend_property_info *pptr TSRMLS_DC, int num_args, va_lis
}
if (pptr->flags & filter) {
- ALLOC_ZVAL(property);
- reflection_property_factory(ce, pptr, property TSRMLS_CC);
- add_next_index_zval(retval, property);
+ reflection_property_factory(ce, pptr, &property TSRMLS_CC);
+ add_next_index_zval(retval, &property);
}
return 0;
}
/* }}} */
/* {{{ _adddynproperty */
-static int _adddynproperty(zval **pptr TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
+static int _adddynproperty(zval *ptr TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
{
- zval *property;
+ zval property;
zend_class_entry *ce = *va_arg(args, zend_class_entry**);
zval *retval = va_arg(args, zval*), member;
/* under some circumstances, the properties hash table may contain numeric
* properties (e.g. when casting from array). This is a WONT FIX bug, at
* least for the moment. Ignore these */
- if (hash_key->nKeyLength == 0) {
+ if (hash_key->key == NULL) {
return 0;
}
- if (hash_key->arKey[0] == '\0') {
+ if (hash_key->key->val[0] == '\0') {
return 0; /* non public cannot be dynamic */
}
- ZVAL_STRINGL(&member, hash_key->arKey, hash_key->nKeyLength-1, 0);
+ ZVAL_STR(&member, hash_key->key);
if (zend_get_property_info(ce, &member, 1 TSRMLS_CC) == &EG(std_property_info)) {
- MAKE_STD_ZVAL(property);
EG(std_property_info).flags = ZEND_ACC_IMPLICIT_PUBLIC;
- reflection_property_factory(ce, &EG(std_property_info), property TSRMLS_CC);
- add_next_index_zval(retval, property);
+ reflection_property_factory(ce, &EG(std_property_info), &property TSRMLS_CC);
+ add_next_index_zval(retval, &property);
}
return 0;
}
@@ -4001,8 +3961,8 @@ ZEND_METHOD(reflection_class, getProperties)
array_init(return_value);
zend_hash_apply_with_arguments(&ce->properties_info TSRMLS_CC, (apply_func_args_t) _addproperty, 3, &ce, return_value, filter);
- if (intern->obj && (filter & ZEND_ACC_PUBLIC) != 0 && Z_OBJ_HT_P(intern->obj)->get_properties) {
- HashTable *properties = Z_OBJ_HT_P(intern->obj)->get_properties(intern->obj TSRMLS_CC);
+ if (Z_TYPE(intern->obj) != IS_UNDEF && (filter & ZEND_ACC_PUBLIC) != 0 && Z_OBJ_HT(intern->obj)->get_properties) {
+ HashTable *properties = Z_OBJ_HT(intern->obj)->get_properties(&intern->obj TSRMLS_CC);
zend_hash_apply_with_arguments(properties TSRMLS_CC, (apply_func_args_t) _adddynproperty, 2, &ce, return_value);
}
}
@@ -4014,16 +3974,15 @@ ZEND_METHOD(reflection_class, hasConstant)
{
reflection_object *intern;
zend_class_entry *ce;
- char *name;
- int name_len;
+ zend_string *name;
METHOD_NOTSTATIC(reflection_class_ptr);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &name) == FAILURE) {
return;
}
GET_REFLECTION_OBJECT_PTR(ce);
- if (zend_hash_exists(&ce->constants_table, name, name_len + 1)) {
+ if (zend_hash_exists(&ce->constants_table, name)) {
RETURN_TRUE;
} else {
RETURN_FALSE;
@@ -4035,7 +3994,6 @@ ZEND_METHOD(reflection_class, hasConstant)
Returns an associative array containing this class' constants and their values */
ZEND_METHOD(reflection_class, getConstants)
{
- zval *tmp_copy;
reflection_object *intern;
zend_class_entry *ce;
@@ -4045,7 +4003,7 @@ ZEND_METHOD(reflection_class, getConstants)
GET_REFLECTION_OBJECT_PTR(ce);
array_init(return_value);
zend_hash_apply_with_argument(&ce->constants_table, (apply_func_arg_t)zval_update_constant_inline_change, ce TSRMLS_CC);
- zend_hash_copy(Z_ARRVAL_P(return_value), &ce->constants_table, (copy_ctor_func_t) zval_add_ref, (void *) &tmp_copy, sizeof(zval *));
+ zend_hash_copy(Z_ARRVAL_P(return_value), &ce->constants_table, zval_add_ref);
}
/* }}} */
@@ -4055,21 +4013,20 @@ ZEND_METHOD(reflection_class, getConstant)
{
reflection_object *intern;
zend_class_entry *ce;
- zval **value;
- char *name;
- int name_len;
+ zval *value;
+ zend_string *name;
METHOD_NOTSTATIC(reflection_class_ptr);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &name) == FAILURE) {
return;
}
GET_REFLECTION_OBJECT_PTR(ce);
zend_hash_apply_with_argument(&ce->constants_table, (apply_func_arg_t)zval_update_constant_inline_change, ce TSRMLS_CC);
- if (zend_hash_find(&ce->constants_table, name, name_len + 1, (void **) &value) == FAILURE) {
+ if ((value = zend_hash_find(&ce->constants_table, name)) == NULL) {
RETURN_FALSE;
}
- MAKE_COPY_ZVAL(value, return_value);
+ ZVAL_DUP(return_value, value);
}
/* }}} */
@@ -4127,11 +4084,11 @@ ZEND_METHOD(reflection_class, isCloneable)
if (ce->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_IMPLICIT_ABSTRACT_CLASS)) {
RETURN_FALSE;
}
- if (intern->obj) {
+ if (Z_TYPE(intern->obj) != IS_UNDEF) {
if (ce->clone) {
RETURN_BOOL(ce->clone->common.fn_flags & ZEND_ACC_PUBLIC);
} else {
- RETURN_BOOL(Z_OBJ_HANDLER_P(intern->obj, clone_obj) != NULL);
+ RETURN_BOOL(Z_OBJ_HANDLER(intern->obj, clone_obj) != NULL);
}
} else {
if (ce->clone) {
@@ -4231,7 +4188,8 @@ ZEND_METHOD(reflection_class, newInstance)
/* Run the constructor if there is one */
if (constructor) {
- zval ***params = NULL;
+//???
+ zval *params = NULL;
int num_args = 0;
zend_fcall_info fci;
zend_fcall_info_cache fcc;
@@ -4252,10 +4210,10 @@ ZEND_METHOD(reflection_class, newInstance)
fci.size = sizeof(fci);
fci.function_table = EG(function_table);
- fci.function_name = NULL;
+ ZVAL_UNDEF(&fci.function_name);
fci.symbol_table = NULL;
fci.object_ptr = return_value;
- fci.retval_ptr_ptr = &retval_ptr;
+ fci.retval = retval_ptr;
fci.param_count = num_args;
fci.params = params;
fci.no_separation = 1;
@@ -4271,14 +4229,14 @@ ZEND_METHOD(reflection_class, newInstance)
efree(params);
}
if (retval_ptr) {
- zval_ptr_dtor(&retval_ptr);
+ zval_ptr_dtor(retval_ptr);
}
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invocation of %s's constructor failed", ce->name);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invocation of %s's constructor failed", ce->name->val);
zval_dtor(return_value);
RETURN_NULL();
}
if (retval_ptr) {
- zval_ptr_dtor(&retval_ptr);
+ zval_ptr_dtor(retval_ptr);
}
if (params) {
efree(params);
@@ -4339,7 +4297,8 @@ ZEND_METHOD(reflection_class, newInstanceArgs)
/* Run the constructor if there is one */
if (constructor) {
- zval ***params = NULL;
+//???
+ zval *params = NULL;
zend_fcall_info fci;
zend_fcall_info_cache fcc;
@@ -4350,17 +4309,17 @@ ZEND_METHOD(reflection_class, newInstanceArgs)
}
if (argc) {
- params = safe_emalloc(sizeof(zval **), argc, 0);
+ params = safe_emalloc(sizeof(zval), argc, 0);
zend_hash_apply_with_argument(args, (apply_func_arg_t)_zval_array_to_c_array, &params TSRMLS_CC);
params -= argc;
}
fci.size = sizeof(fci);
fci.function_table = EG(function_table);
- fci.function_name = NULL;
+ ZVAL_UNDEF(&fci.function_name);
fci.symbol_table = NULL;
fci.object_ptr = return_value;
- fci.retval_ptr_ptr = &retval_ptr;
+ fci.retval = retval_ptr;
fci.param_count = argc;
fci.params = params;
fci.no_separation = 1;
@@ -4376,20 +4335,20 @@ ZEND_METHOD(reflection_class, newInstanceArgs)
efree(params);
}
if (retval_ptr) {
- zval_ptr_dtor(&retval_ptr);
+ zval_ptr_dtor(retval_ptr);
}
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invocation of %s's constructor failed", ce->name);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invocation of %s's constructor failed", ce->name->val);
zval_dtor(return_value);
RETURN_NULL();
}
if (retval_ptr) {
- zval_ptr_dtor(&retval_ptr);
+ zval_ptr_dtor(retval_ptr);
}
if (params) {
efree(params);
}
} else if (argc) {
- zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not have a constructor, so you cannot pass any constructor arguments", ce->name);
+ zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not have a constructor, so you cannot pass any constructor arguments", ce->name->val);
}
}
/* }}} */
@@ -4413,10 +4372,10 @@ ZEND_METHOD(reflection_class, getInterfaces)
zend_uint i;
for (i=0; i < ce->num_interfaces; i++) {
- zval *interface;
- ALLOC_ZVAL(interface);
- zend_reflection_class_factory(ce->interfaces[i], interface TSRMLS_CC);
- add_assoc_zval_ex(return_value, ce->interfaces[i]->name, ce->interfaces[i]->name_length + 1, interface);
+ zval interface;
+ zend_reflection_class_factory(ce->interfaces[i], &interface TSRMLS_CC);
+//???
+ add_assoc_zval_ex(return_value, ce->interfaces[i]->name->val, ce->interfaces[i]->name->len, &interface);
}
}
}
@@ -4439,7 +4398,7 @@ ZEND_METHOD(reflection_class, getInterfaceNames)
array_init(return_value);
for (i=0; i < ce->num_interfaces; i++) {
- add_next_index_stringl(return_value, ce->interfaces[i]->name, ce->interfaces[i]->name_length, 1);
+ add_next_index_str(return_value, STR_COPY(ce->interfaces[i]->name));
}
}
/* }}} */
@@ -4460,10 +4419,10 @@ ZEND_METHOD(reflection_class, getTraits)
array_init(return_value);
for (i=0; i < ce->num_traits; i++) {
- zval *trait;
- ALLOC_ZVAL(trait);
- zend_reflection_class_factory(ce->traits[i], trait TSRMLS_CC);
- add_assoc_zval_ex(return_value, ce->traits[i]->name, ce->traits[i]->name_length + 1, trait);
+ zval trait;
+ zend_reflection_class_factory(ce->traits[i], &trait TSRMLS_CC);
+//???
+ add_assoc_zval_ex(return_value, ce->traits[i]->name->val, ce->traits[i]->name->len, &trait);
}
}
/* }}} */
@@ -4484,7 +4443,7 @@ ZEND_METHOD(reflection_class, getTraitNames)
array_init(return_value);
for (i=0; i < ce->num_traits; i++) {
- add_next_index_stringl(return_value, ce->traits[i]->name, ce->traits[i]->name_length, 1);
+ add_next_index_str(return_value, STR_COPY(ce->traits[i]->name));
}
}
/* }}} */
@@ -4511,8 +4470,9 @@ ZEND_METHOD(reflection_class, getTraitAliases)
zend_trait_method_reference *cur_ref = ce->trait_aliases[i]->trait_method;
if (ce->trait_aliases[i]->alias) {
- method_name_len = spprintf(&method_name, 0, "%s::%s", cur_ref->ce->name, cur_ref->method_name);
- add_assoc_stringl_ex(return_value, ce->trait_aliases[i]->alias, ce->trait_aliases[i]->alias_len + 1, method_name, method_name_len, 0);
+ method_name_len = spprintf(&method_name, 0, "%s::%s", cur_ref->ce->name->val, cur_ref->method_name->val);
+//???
+ add_assoc_stringl_ex(return_value, ce->trait_aliases[i]->alias->val, ce->trait_aliases[i]->alias->len, method_name, method_name_len, 0);
}
i++;
}
@@ -4545,7 +4505,7 @@ ZEND_METHOD(reflection_class, getParentClass)
ZEND_METHOD(reflection_class, isSubclassOf)
{
reflection_object *intern, *argument;
- zend_class_entry *ce, **pce, *class_ce;
+ zend_class_entry *ce, *class_ce;
zval *class_name;
METHOD_NOTSTATIC(reflection_class_ptr);
@@ -4557,16 +4517,15 @@ ZEND_METHOD(reflection_class, isSubclassOf)
switch(class_name->type) {
case IS_STRING:
- if (zend_lookup_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), &pce TSRMLS_CC) == FAILURE) {
+ if ((class_ce = zend_lookup_class(Z_STR_P(class_name) TSRMLS_CC)) == NULL) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Class %s does not exist", Z_STRVAL_P(class_name));
return;
}
- class_ce = *pce;
break;
case IS_OBJECT:
if (instanceof_function(Z_OBJCE_P(class_name), reflection_class_ptr TSRMLS_CC)) {
- argument = (reflection_object *) zend_object_store_get_object(class_name TSRMLS_CC);
+ argument = (reflection_object *) Z_OBJ_P(class_name);
if (argument == NULL || argument->ptr == NULL) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: Failed to retrieve the argument's reflection object");
/* Bails out */
@@ -4590,7 +4549,7 @@ ZEND_METHOD(reflection_class, isSubclassOf)
ZEND_METHOD(reflection_class, implementsInterface)
{
reflection_object *intern, *argument;
- zend_class_entry *ce, *interface_ce, **pce;
+ zend_class_entry *ce, *interface_ce;
zval *interface;
METHOD_NOTSTATIC(reflection_class_ptr);
@@ -4602,16 +4561,15 @@ ZEND_METHOD(reflection_class, implementsInterface)
switch(interface->type) {
case IS_STRING:
- if (zend_lookup_class(Z_STRVAL_P(interface), Z_STRLEN_P(interface), &pce TSRMLS_CC) == FAILURE) {
+ if ((interface_ce = zend_lookup_class(Z_STR_P(interface) TSRMLS_CC)) == NULL) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Interface %s does not exist", Z_STRVAL_P(interface));
return;
}
- interface_ce = *pce;
break;
case IS_OBJECT:
if (instanceof_function(Z_OBJCE_P(interface), reflection_class_ptr TSRMLS_CC)) {
- argument = (reflection_object *) zend_object_store_get_object(interface TSRMLS_CC);
+ argument = (reflection_object *) Z_OBJ_P(interface);
if (argument == NULL || argument->ptr == NULL) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: Failed to retrieve the argument's reflection object");
/* Bails out */
@@ -4688,7 +4646,7 @@ ZEND_METHOD(reflection_class, getExtensionName)
GET_REFLECTION_OBJECT_PTR(ce);
if ((ce->type == ZEND_INTERNAL_CLASS) && ce->info.internal.module) {
- RETURN_STRING(ce->info.internal.module->name, 1);
+ RETURN_STRING(ce->info.internal.module->name);
} else {
RETURN_FALSE;
}
@@ -4699,18 +4657,18 @@ ZEND_METHOD(reflection_class, getExtensionName)
Returns whether this class is defined in namespace */
ZEND_METHOD(reflection_class, inNamespace)
{
- zval **name;
+ zval *name;
const char *backslash;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) {
+ if ((name = zend_hash_str_find(Z_OBJPROP_P(getThis()), "name", sizeof("name")-1)) == NULL) {
RETURN_FALSE;
}
- if (Z_TYPE_PP(name) == IS_STRING
- && (backslash = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name)))
- && backslash > Z_STRVAL_PP(name))
+ if (Z_TYPE_P(name) == IS_STRING
+ && (backslash = zend_memrchr(Z_STRVAL_P(name), '\\', Z_STRLEN_P(name)))
+ && backslash > Z_STRVAL_P(name))
{
RETURN_TRUE;
}
@@ -4722,20 +4680,20 @@ ZEND_METHOD(reflection_class, inNamespace)
Returns the name of namespace where this class is defined */
ZEND_METHOD(reflection_class, getNamespaceName)
{
- zval **name;
+ zval *name;
const char *backslash;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) {
+ if ((name = zend_hash_str_find(Z_OBJPROP_P(getThis()), "name", sizeof("name")-1)) == NULL) {
RETURN_FALSE;
}
- if (Z_TYPE_PP(name) == IS_STRING
- && (backslash = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name)))
- && backslash > Z_STRVAL_PP(name))
+ if (Z_TYPE_P(name) == IS_STRING
+ && (backslash = zend_memrchr(Z_STRVAL_P(name), '\\', Z_STRLEN_P(name)))
+ && backslash > Z_STRVAL_P(name))
{
- RETURN_STRINGL(Z_STRVAL_PP(name), backslash - Z_STRVAL_PP(name), 1);
+ RETURN_STRINGL(Z_STRVAL_P(name), backslash - Z_STRVAL_P(name));
}
RETURN_EMPTY_STRING();
}
@@ -4745,22 +4703,22 @@ ZEND_METHOD(reflection_class, getNamespaceName)
Returns the short name of the class (without namespace part) */
ZEND_METHOD(reflection_class, getShortName)
{
- zval **name;
+ zval *name;
const char *backslash;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- if (zend_hash_find(Z_OBJPROP_P(getThis()), "name", sizeof("name"), (void **) &name) == FAILURE) {
+ if ((name = zend_hash_str_find(Z_OBJPROP_P(getThis()), "name", sizeof("name")-1)) == NULL) {
RETURN_FALSE;
}
- if (Z_TYPE_PP(name) == IS_STRING
- && (backslash = zend_memrchr(Z_STRVAL_PP(name), '\\', Z_STRLEN_PP(name)))
- && backslash > Z_STRVAL_PP(name))
+ if (Z_TYPE_P(name) == IS_STRING
+ && (backslash = zend_memrchr(Z_STRVAL_P(name), '\\', Z_STRLEN_P(name)))
+ && backslash > Z_STRVAL_P(name))
{
- RETURN_STRINGL(backslash + 1, Z_STRLEN_PP(name) - (backslash - Z_STRVAL_PP(name) + 1), 1);
+ RETURN_STRINGL(backslash + 1, Z_STRLEN_P(name) - (backslash - Z_STRVAL_P(name) + 1));
}
- RETURN_ZVAL(*name, 1, 0);
+ RETURN_ZVAL(name, 1, 0);
}
/* }}} */
@@ -4792,13 +4750,12 @@ ZEND_METHOD(reflection_property, export)
Constructor. Throws an Exception in case the given property does not exist */
ZEND_METHOD(reflection_property, __construct)
{
- zval *propname, *classname;
+ zval propname, cname, *classname;
char *name_str;
const char *class_name, *prop_name;
int name_len, dynam_prop = 0;
zval *object;
reflection_object *intern;
- zend_class_entry **pce;
zend_class_entry *ce;
zend_property_info *property_info = NULL;
property_reference *reference;
@@ -4808,7 +4765,7 @@ ZEND_METHOD(reflection_property, __construct)
}
object = getThis();
- intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
+ intern = (reflection_object *) Z_OBJ_P(object);
if (intern == NULL) {
return;
}
@@ -4816,12 +4773,11 @@ ZEND_METHOD(reflection_property, __construct)
/* Find the class entry */
switch (Z_TYPE_P(classname)) {
case IS_STRING:
- if (zend_lookup_class(Z_STRVAL_P(classname), Z_STRLEN_P(classname), &pce TSRMLS_CC) == FAILURE) {
+ if ((ce = zend_lookup_class(Z_STR_P(classname) TSRMLS_CC)) == NULL) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Class %s does not exist", Z_STRVAL_P(classname));
return;
}
- ce = *pce;
break;
case IS_OBJECT:
@@ -4833,10 +4789,10 @@ ZEND_METHOD(reflection_property, __construct)
/* returns out of this function */
}
- if (zend_hash_find(&ce->properties_info, name_str, name_len + 1, (void **) &property_info) == FAILURE || (property_info->flags & ZEND_ACC_SHADOW)) {
+ if ((property_info = zend_hash_str_find_ptr(&ce->properties_info, name_str, name_len)) == NULL || (property_info->flags & ZEND_ACC_SHADOW)) {
/* Check for dynamic properties */
if (property_info == NULL && Z_TYPE_P(classname) == IS_OBJECT && Z_OBJ_HT_P(classname)->get_properties) {
- if (zend_hash_exists(Z_OBJ_HT_P(classname)->get_properties(classname TSRMLS_CC), name_str, name_len+1)) {
+ if (zend_hash_str_exists(Z_OBJ_HT_P(classname)->get_properties(classname TSRMLS_CC), name_str, name_len)) {
dynam_prop = 1;
}
}
@@ -4851,33 +4807,28 @@ ZEND_METHOD(reflection_property, __construct)
zend_class_entry *tmp_ce = ce;
zend_property_info *tmp_info;
- while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, name_str, name_len + 1, (void **) &tmp_info) != SUCCESS) {
+ while (tmp_ce && (tmp_info = zend_hash_str_find_ptr(&tmp_ce->properties_info, name_str, name_len)) == NULL) {
ce = tmp_ce;
property_info = tmp_info;
tmp_ce = tmp_ce->parent;
}
}
- MAKE_STD_ZVAL(classname);
- MAKE_STD_ZVAL(propname);
-
if (dynam_prop == 0) {
- zend_unmangle_property_name(property_info->name, property_info->name_length, &class_name, &prop_name);
- ZVAL_STRINGL(classname, property_info->ce->name, property_info->ce->name_length, 1);
- ZVAL_STRING(propname, prop_name, 1);
+ zend_unmangle_property_name(property_info->name->val, property_info->name->len, &class_name, &prop_name);
+ ZVAL_STR(&cname, STR_COPY(property_info->ce->name));
+ ZVAL_STRING(&propname, prop_name);
} else {
- ZVAL_STRINGL(classname, ce->name, ce->name_length, 1);
- ZVAL_STRINGL(propname, name_str, name_len, 1);
+ ZVAL_STR(&cname, STR_COPY(ce->name));
+ ZVAL_STRINGL(&propname, name_str, name_len);
}
- reflection_update_property(object, "class", classname);
- reflection_update_property(object, "name", propname);
+ reflection_update_property(object, "class", &cname);
+ reflection_update_property(object, "name", &propname);
reference = (property_reference*) emalloc(sizeof(property_reference));
if (dynam_prop) {
reference->prop.flags = ZEND_ACC_IMPLICIT_PUBLIC;
- reference->prop.name = Z_STRVAL_P(propname);
- reference->prop.name_length = Z_STRLEN_P(propname);
- reference->prop.h = zend_get_hash_value(name_str, name_len+1);
+ reference->prop.name = Z_STR(propname);
reference->prop.doc_comment = NULL;
reference->prop.ce = ce;
} else {
@@ -4905,7 +4856,8 @@ ZEND_METHOD(reflection_property, __toString)
GET_REFLECTION_OBJECT_PTR(ref);
string_init(&str);
_property_string(&str, &ref->prop, NULL, "" TSRMLS_CC);
- RETURN_STRINGL(str.string, str.len - 1, 0);
+//??? RETURN_STRINGL(str.string, str.len - 1, 0);
+ RETURN_STRINGL(str.string, str.len - 1);
}
/* }}} */
@@ -4916,7 +4868,7 @@ ZEND_METHOD(reflection_property, getName)
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- _default_get_entry(getThis(), "name", sizeof("name"), return_value TSRMLS_CC);
+ _default_get_entry(getThis(), "name", sizeof("name")-1, return_value TSRMLS_CC);
}
/* }}} */
@@ -5002,7 +4954,7 @@ ZEND_METHOD(reflection_property, getValue)
GET_REFLECTION_OBJECT_PTR(ref);
if (!(ref->prop.flags & (ZEND_ACC_PUBLIC | ZEND_ACC_IMPLICIT_PUBLIC)) && intern->ignore_visibility == 0) {
- _default_get_entry(getThis(), "name", sizeof("name"), &name TSRMLS_CC);
+ _default_get_entry(getThis(), "name", sizeof("name")-1, &name TSRMLS_CC);
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Cannot access non-public member %s::%s", intern->ce->name, Z_STRVAL(name));
zval_dtor(&name);
@@ -5011,25 +4963,25 @@ ZEND_METHOD(reflection_property, getValue)
if ((ref->prop.flags & ZEND_ACC_STATIC)) {
zend_update_class_constants(intern->ce TSRMLS_CC);
- if (!CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]) {
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: Could not find the property %s::%s", intern->ce->name, ref->prop.name);
+ if (Z_TYPE(CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]) == IS_UNDEF) {
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: Could not find the property %s::%s", intern->ce->name->val, ref->prop.name->val);
/* Bails out */
}
- *return_value= *CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset];
- zval_copy_ctor(return_value);
- INIT_PZVAL(return_value);
+ ZVAL_DUP(return_value, &CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]);
+//??? INIT_PZVAL(return_value);
} else {
const char *class_name, *prop_name;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &object) == FAILURE) {
return;
}
- zend_unmangle_property_name(ref->prop.name, ref->prop.name_length, &class_name, &prop_name);
+ zend_unmangle_property_name(ref->prop.name->val, ref->prop.name->len, &class_name, &prop_name);
member_p = zend_read_property(ref->ce, object, prop_name, strlen(prop_name), 1 TSRMLS_CC);
- MAKE_COPY_ZVAL(&member_p, return_value);
- if (member_p != EG(uninitialized_zval_ptr)) {
- zval_add_ref(&member_p);
- zval_ptr_dtor(&member_p);
+ ZVAL_DUP(return_value, member_p);
+//???
+ if (member_p != &EG(uninitialized_zval)) {
+ zval_add_ref(member_p);
+ zval_ptr_dtor(member_p);
}
}
}
@@ -5041,7 +4993,7 @@ ZEND_METHOD(reflection_property, setValue)
{
reflection_object *intern;
property_reference *ref;
- zval **variable_ptr;
+ zval *variable_ptr;
zval *object, name;
zval *value;
zval *tmp;
@@ -5050,7 +5002,7 @@ ZEND_METHOD(reflection_property, setValue)
GET_REFLECTION_OBJECT_PTR(ref);
if (!(ref->prop.flags & ZEND_ACC_PUBLIC) && intern->ignore_visibility == 0) {
- _default_get_entry(getThis(), "name", sizeof("name"), &name TSRMLS_CC);
+ _default_get_entry(getThis(), "name", sizeof("name")-1, &name TSRMLS_CC);
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Cannot access non-public member %s::%s", intern->ce->name, Z_STRVAL(name));
zval_dtor(&name);
@@ -5065,31 +5017,33 @@ ZEND_METHOD(reflection_property, setValue)
}
zend_update_class_constants(intern->ce TSRMLS_CC);
- if (!CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]) {
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: Could not find the property %s::%s", intern->ce->name, ref->prop.name);
+ if (Z_TYPE(CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]) == IS_UNDEF) {
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Internal error: Could not find the property %s::%s", intern->ce->name->val, ref->prop.name->val);
/* Bails out */
}
variable_ptr = &CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset];
- if (*variable_ptr != value) {
- if (PZVAL_IS_REF(*variable_ptr)) {
- zval garbage = **variable_ptr; /* old value should be destroyed */
+ if (variable_ptr != value) {
+ if (Z_ISREF_P(variable_ptr)) {
+ zval garbage;
+
+ ZVAL_COPY_VALUE(&garbage, variable_ptr); /* old value should be destroyed */
/* To check: can't *variable_ptr be some system variable like error_zval here? */
- Z_TYPE_PP(variable_ptr) = Z_TYPE_P(value);
- (*variable_ptr)->value = value->value;
+ ZVAL_COPY_VALUE(variable_ptr, value);
if (Z_REFCOUNT_P(value) > 0) {
- zval_copy_ctor(*variable_ptr);
+ zval_copy_ctor(variable_ptr);
}
zval_dtor(&garbage);
} else {
- zval *garbage = *variable_ptr;
-
+ zval garbage;
+
+ ZVAL_COPY_VALUE(&garbage, variable_ptr);
/* if we assign referenced variable, we should separate it */
Z_ADDREF_P(value);
- if (PZVAL_IS_REF(value)) {
- SEPARATE_ZVAL(&value);
+ if (Z_ISREF_P(value)) {
+ SEPARATE_ZVAL(value);
}
- *variable_ptr = value;
+ ZVAL_COPY_VALUE(variable_ptr, value);
zval_ptr_dtor(&garbage);
}
}
@@ -5099,7 +5053,7 @@ ZEND_METHOD(reflection_property, setValue)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "oz", &object, &value) == FAILURE) {
return;
}
- zend_unmangle_property_name(ref->prop.name, ref->prop.name_length, &class_name, &prop_name);
+ zend_unmangle_property_name(ref->prop.name->val, ref->prop.name->len, &class_name, &prop_name);
zend_update_property(ref->ce, object, prop_name, strlen(prop_name), value TSRMLS_CC);
}
}
@@ -5121,13 +5075,13 @@ ZEND_METHOD(reflection_property, getDeclaringClass)
}
GET_REFLECTION_OBJECT_PTR(ref);
- if (zend_unmangle_property_name(ref->prop.name, ref->prop.name_length, &class_name, &prop_name) != SUCCESS) {
+ if (zend_unmangle_property_name(ref->prop.name->val, ref->prop.name->len, &class_name, &prop_name) != SUCCESS) {
RETURN_FALSE;
}
prop_name_len = strlen(prop_name);
ce = tmp_ce = ref->ce;
- while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, prop_name, prop_name_len + 1, (void **) &tmp_info) == SUCCESS) {
+ while (tmp_ce && (tmp_info = zend_hash_str_find_ptr(&tmp_ce->properties_info, prop_name, prop_name_len)) != NULL) {
if (tmp_info->flags & ZEND_ACC_PRIVATE || tmp_info->flags & ZEND_ACC_SHADOW) {
/* it's a private property, so it can't be inherited */
break;
@@ -5156,7 +5110,7 @@ ZEND_METHOD(reflection_property, getDocComment)
}
GET_REFLECTION_OBJECT_PTR(ref);
if (ref->prop.doc_comment) {
- RETURN_STRINGL(ref->prop.doc_comment, ref->prop.doc_comment_len, 1);
+ RETURN_STR(STR_COPY(ref->prop.doc_comment));
}
RETURN_FALSE;
}
@@ -5173,7 +5127,7 @@ ZEND_METHOD(reflection_property, setAccessible)
return;
}
- intern = (reflection_object *) zend_object_store_get_object(getThis() TSRMLS_CC);
+ intern = (reflection_object *) Z_OBJ_P(getThis());
if (intern == NULL) {
return;
@@ -5195,7 +5149,7 @@ ZEND_METHOD(reflection_extension, export)
Constructor. Throws an Exception in case the given extension does not exist */
ZEND_METHOD(reflection_extension, __construct)
{
- zval *name;
+ zval name;
zval *object;
char *lcname;
reflection_object *intern;
@@ -5209,22 +5163,21 @@ ZEND_METHOD(reflection_extension, __construct)
}
object = getThis();
- intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
+ intern = (reflection_object *) Z_OBJ_P(object);
if (intern == NULL) {
return;
}
lcname = do_alloca(name_len + 1, use_heap);
zend_str_tolower_copy(lcname, name_str, name_len);
- if (zend_hash_find(&module_registry, lcname, name_len + 1, (void **)&module) == FAILURE) {
+ if ((module = zend_hash_str_find_ptr(&module_registry, lcname, name_len)) == NULL) {
free_alloca(lcname, use_heap);
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Extension %s does not exist", name_str);
return;
}
free_alloca(lcname, use_heap);
- MAKE_STD_ZVAL(name);
- ZVAL_STRING(name, module->name, 1);
- reflection_update_property( object, "name", name);
+ ZVAL_STRING(&name, module->name);
+ reflection_update_property(object, "name", &name);
intern->ptr = module;
intern->ref_type = REF_TYPE_OTHER;
intern->ce = NULL;
@@ -5245,7 +5198,8 @@ ZEND_METHOD(reflection_extension, __toString)
GET_REFLECTION_OBJECT_PTR(module);
string_init(&str);
_extension_string(&str, module, "" TSRMLS_CC);
- RETURN_STRINGL(str.string, str.len - 1, 0);
+//??? RETURN_STRINGL(str.string, str.len - 1, 0);
+ RETURN_STRINGL(str.string, str.len - 1);
}
/* }}} */
@@ -5256,7 +5210,7 @@ ZEND_METHOD(reflection_extension, getName)
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- _default_get_entry(getThis(), "name", sizeof("name"), return_value TSRMLS_CC);
+ _default_get_entry(getThis(), "name", sizeof("name")-1, return_value TSRMLS_CC);
}
/* }}} */
@@ -5276,7 +5230,7 @@ ZEND_METHOD(reflection_extension, getVersion)
if (module->version == NO_VERSION_YET) {
RETURN_NULL();
} else {
- RETURN_STRING(module->version, 1);
+ RETURN_STRING(module->version);
}
}
/* }}} */
@@ -5288,7 +5242,7 @@ ZEND_METHOD(reflection_extension, getFunctions)
reflection_object *intern;
zend_module_entry *module;
HashPosition iterator;
- zval *function;
+ zval function;
zend_function *fptr;
if (zend_parse_parameters_none() == FAILURE) {
@@ -5298,12 +5252,12 @@ ZEND_METHOD(reflection_extension, getFunctions)
array_init(return_value);
zend_hash_internal_pointer_reset_ex(CG(function_table), &iterator);
- while (zend_hash_get_current_data_ex(CG(function_table), (void **) &fptr, &iterator) == SUCCESS) {
+ while ((fptr = zend_hash_get_current_data_ptr_ex(CG(function_table), &iterator)) != NULL) {
if (fptr->common.type==ZEND_INTERNAL_FUNCTION
&& fptr->internal_function.module == module) {
- ALLOC_ZVAL(function);
- reflection_function_factory(fptr, NULL, function TSRMLS_CC);
- add_assoc_zval(return_value, fptr->common.function_name, function);
+ reflection_function_factory(fptr, NULL, &function TSRMLS_CC);
+//???
+ add_assoc_zval(return_value, fptr->common.function_name->val, &function);
}
zend_hash_move_forward_ex(CG(function_table), &iterator);
}
@@ -5312,16 +5266,15 @@ ZEND_METHOD(reflection_extension, getFunctions)
static int _addconstant(zend_constant *constant TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
{
- zval *const_val;
+ zval const_val;
zval *retval = va_arg(args, zval*);
int number = va_arg(args, int);
if (number == constant->module_number) {
- ALLOC_ZVAL(const_val);
- *const_val = constant->value;
- zval_copy_ctor(const_val);
- INIT_PZVAL(const_val);
- add_assoc_zval_ex(retval, constant->name, constant->name_len, const_val);
+ ZVAL_DUP(&const_val, &constant->value);
+//??? INIT_PZVAL(const_val);
+//???
+ add_assoc_zval_ex(retval, constant->name->val, constant->name->len, &const_val);
}
return 0;
}
@@ -5381,17 +5334,17 @@ ZEND_METHOD(reflection_extension, getINIEntries)
/* {{{ add_extension_class */
static int add_extension_class(zend_class_entry **pce TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
{
- zval *class_array = va_arg(args, zval*), *zclass;
+ zval *class_array = va_arg(args, zval*), zclass;
struct _zend_module_entry *module = va_arg(args, struct _zend_module_entry*);
int add_reflection_class = va_arg(args, int);
if (((*pce)->type == ZEND_INTERNAL_CLASS) && (*pce)->info.internal.module && !strcasecmp((*pce)->info.internal.module->name, module->name)) {
if (add_reflection_class) {
- ALLOC_ZVAL(zclass);
- zend_reflection_class_factory(*pce, zclass TSRMLS_CC);
- add_assoc_zval_ex(class_array, (*pce)->name, (*pce)->name_length + 1, zclass);
+ zend_reflection_class_factory(*pce, &zclass TSRMLS_CC);
+//???
+ add_assoc_zval_ex(class_array, (*pce)->name->val, (*pce)->name->len, &zclass);
} else {
- add_next_index_stringl(class_array, (*pce)->name, (*pce)->name_length, 1);
+ add_next_index_str(class_array, STR_COPY((*pce)->name));
}
}
return ZEND_HASH_APPLY_KEEP;
@@ -5546,7 +5499,7 @@ ZEND_METHOD(reflection_zend_extension, export)
Constructor. Throws an Exception in case the given Zend extension does not exist */
ZEND_METHOD(reflection_zend_extension, __construct)
{
- zval *name;
+ zval name;
zval *object;
reflection_object *intern;
zend_extension *extension;
@@ -5558,7 +5511,7 @@ ZEND_METHOD(reflection_zend_extension, __construct)
}
object = getThis();
- intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
+ intern = (reflection_object *) Z_OBJ_P(object);
if (intern == NULL) {
return;
}
@@ -5569,9 +5522,8 @@ ZEND_METHOD(reflection_zend_extension, __construct)
"Zend Extension %s does not exist", name_str);
return;
}
- MAKE_STD_ZVAL(name);
- ZVAL_STRING(name, extension->name, 1);
- reflection_update_property(object, "name", name);
+ ZVAL_STRING(&name, extension->name);
+ reflection_update_property(object, "name", &name);
intern->ptr = extension;
intern->ref_type = REF_TYPE_OTHER;
intern->ce = NULL;
@@ -5592,7 +5544,8 @@ ZEND_METHOD(reflection_zend_extension, __toString)
GET_REFLECTION_OBJECT_PTR(extension);
string_init(&str);
_zend_extension_string(&str, extension, "" TSRMLS_CC);
- RETURN_STRINGL(str.string, str.len - 1, 0);
+//??? RETURN_STRINGL(str.string, str.len - 1, 0);
+ RETURN_STRINGL(str.string, str.len - 1);
}
/* }}} */
@@ -5608,7 +5561,7 @@ ZEND_METHOD(reflection_zend_extension, getName)
}
GET_REFLECTION_OBJECT_PTR(extension);
- RETURN_STRING(extension->name, 1);
+ RETURN_STRING(extension->name);
}
/* }}} */
@@ -5624,7 +5577,11 @@ ZEND_METHOD(reflection_zend_extension, getVersion)
}
GET_REFLECTION_OBJECT_PTR(extension);
- RETURN_STRING(extension->version ? extension->version : "", 1);
+ if (extension->version) {
+ RETURN_STRING(extension->version);
+ } else {
+ RETURN_EMPTY_STRING();
+ }
}
/* }}} */
@@ -5640,7 +5597,11 @@ ZEND_METHOD(reflection_zend_extension, getAuthor)
}
GET_REFLECTION_OBJECT_PTR(extension);
- RETURN_STRING(extension->author ? extension->author : "", 1);
+ if (extension->author) {
+ RETURN_STRING(extension->author);
+ } else {
+ RETURN_EMPTY_STRING();
+ }
}
/* }}} */
@@ -5656,7 +5617,11 @@ ZEND_METHOD(reflection_zend_extension, getURL)
}
GET_REFLECTION_OBJECT_PTR(extension);
- RETURN_STRING(extension->URL ? extension->URL : "", 1);
+ if (extension->URL) {
+ RETURN_STRING(extension->URL);
+ } else {
+ RETURN_EMPTY_STRING();
+ }
}
/* }}} */
@@ -5672,7 +5637,11 @@ ZEND_METHOD(reflection_zend_extension, getCopyright)
}
GET_REFLECTION_OBJECT_PTR(extension);
- RETURN_STRING(extension->copyright ? extension->copyright : "", 1);
+ if (extension->copyright) {
+ RETURN_STRING(extension->copyright);
+ } else {
+ RETURN_EMPTY_STRING();
+ }
}
/* }}} */
@@ -6095,7 +6064,7 @@ static zend_object_handlers *zend_std_obj_handlers;
static void _reflection_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC)
{
if ((Z_TYPE_P(member) == IS_STRING)
- && zend_hash_exists(&Z_OBJCE_P(object)->properties_info, Z_STRVAL_P(member), Z_STRLEN_P(member)+1)
+ && zend_hash_exists(&Z_OBJCE_P(object)->properties_info, Z_STR_P(member))
&& ((Z_STRLEN_P(member) == sizeof("name") - 1 && !memcmp(Z_STRVAL_P(member), "name", sizeof("name")))
|| (Z_STRLEN_P(member) == sizeof("class") - 1 && !memcmp(Z_STRVAL_P(member), "class", sizeof("class")))))
{
@@ -6115,11 +6084,12 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */
zend_std_obj_handlers = zend_get_std_object_handlers();
memcpy(&reflection_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ reflection_object_handlers.free_obj = reflection_free_objects_storage;
reflection_object_handlers.clone_obj = NULL;
reflection_object_handlers.write_property = _reflection_write_property;
INIT_CLASS_ENTRY(_reflection_entry, "ReflectionException", reflection_exception_functions);
- reflection_exception_ptr = zend_register_internal_class_ex(&_reflection_entry, zend_exception_get_default(TSRMLS_C), NULL TSRMLS_CC);
+ reflection_exception_ptr = zend_register_internal_class_ex(&_reflection_entry, zend_exception_get_default(TSRMLS_C) TSRMLS_CC);
INIT_CLASS_ENTRY(_reflection_entry, "Reflection", reflection_functions);
reflection_ptr = zend_register_internal_class(&_reflection_entry TSRMLS_CC);
@@ -6135,7 +6105,7 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */
INIT_CLASS_ENTRY(_reflection_entry, "ReflectionFunction", reflection_function_functions);
_reflection_entry.create_object = reflection_objects_new;
- reflection_function_ptr = zend_register_internal_class_ex(&_reflection_entry, reflection_function_abstract_ptr, NULL TSRMLS_CC);
+ reflection_function_ptr = zend_register_internal_class_ex(&_reflection_entry, reflection_function_abstract_ptr TSRMLS_CC);
zend_declare_property_string(reflection_function_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC);
REGISTER_REFLECTION_CLASS_CONST_LONG(function, "IS_DEPRECATED", ZEND_ACC_DEPRECATED);
@@ -6148,7 +6118,7 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */
INIT_CLASS_ENTRY(_reflection_entry, "ReflectionMethod", reflection_method_functions);
_reflection_entry.create_object = reflection_objects_new;
- reflection_method_ptr = zend_register_internal_class_ex(&_reflection_entry, reflection_function_abstract_ptr, NULL TSRMLS_CC);
+ reflection_method_ptr = zend_register_internal_class_ex(&_reflection_entry, reflection_function_abstract_ptr TSRMLS_CC);
zend_declare_property_string(reflection_method_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_string(reflection_method_ptr, "class", sizeof("class")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC);
@@ -6171,7 +6141,7 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */
INIT_CLASS_ENTRY(_reflection_entry, "ReflectionObject", reflection_object_functions);
_reflection_entry.create_object = reflection_objects_new;
- reflection_object_ptr = zend_register_internal_class_ex(&_reflection_entry, reflection_class_ptr, NULL TSRMLS_CC);
+ reflection_object_ptr = zend_register_internal_class_ex(&_reflection_entry, reflection_class_ptr TSRMLS_CC);
INIT_CLASS_ENTRY(_reflection_entry, "ReflectionProperty", reflection_property_functions);
_reflection_entry.create_object = reflection_objects_new;