From f77e6a449988947a2987679d0e8c9788275f48b9 Mon Sep 17 00:00:00 2001 From: Zeev Suraski Date: Sat, 19 Feb 2000 13:11:39 +0000 Subject: [PATCH] Generalize macros --- Zend/zend_API.c | 4 +-- Zend/zend_API.h | 4 +-- Zend/zend_execute.c | 2 +- Zend/zend_operators.c | 2 +- Zend/zend_operators.h | 58 ++++++++++--------------------------------- 5 files changed, 19 insertions(+), 51 deletions(-) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 4cf4eb6e22..8e5cd4acad 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -35,7 +35,7 @@ static int module_count=0; HashTable list_destructors, module_registry; /* this function doesn't check for too many parameters */ -ZEND_API int zend_get_parameters(int ht, int param_count,...) +ZEND_API int zend_get_parameters(int ht, int param_count, ...) { void **p; int arg_count; @@ -115,7 +115,7 @@ ZEND_API int zend_get_parameters_array(int ht, int param_count, zval **argument_ /* Zend-optimized Extended functions */ /* this function doesn't check for too many parameters */ -ZEND_API int zend_get_parameters_ex(int param_count,...) +ZEND_API int zend_get_parameters_ex(int param_count, ...) { void **p; int arg_count; diff --git a/Zend/zend_API.h b/Zend/zend_API.h index cdd464248f..6222823ed9 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -57,9 +57,9 @@ int zend_next_free_module(void); -ZEND_API int zend_get_parameters(int ht, int param_count,...); +ZEND_API int zend_get_parameters(int ht, int param_count, ...); ZEND_API int zend_get_parameters_array(int ht, int param_count, zval **argument_array); -ZEND_API int zend_get_parameters_ex(int param_count,...); +ZEND_API int zend_get_parameters_ex(int param_count, ...); ZEND_API int zend_get_parameters_array_ex(int param_count, zval ***argument_array); ZEND_API int ParameterPassedByReference(int ht, uint n); diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 017b072cba..12a790b790 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -2023,7 +2023,7 @@ send_by_ref: } switch (opline->op2.u.constant.type) { case IS_NULL: - convert_to_unset(result); + convert_to_null(result); break; case IS_BOOL: convert_to_boolean(result); diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index f76cbb8849..4346fe75f1 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -257,7 +257,7 @@ ZEND_API void convert_to_double(zval *op) } -ZEND_API void convert_to_unset(zval *op) +ZEND_API void convert_to_null(zval *op) { zval_dtor(op); op->type = IS_NULL; diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index e106f1481b..6a00fe7e65 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -55,14 +55,14 @@ BEGIN_EXTERN_C() ZEND_API void convert_scalar_to_number(zval *op); ZEND_API void convert_to_string(zval *op); ZEND_API void convert_to_long(zval *op); +ZEND_API void convert_to_double(zval *op); ZEND_API void convert_to_long_base(zval *op, int base); -ZEND_API void convert_to_unset(zval *op); +ZEND_API void convert_to_null(zval *op); ZEND_API void convert_to_boolean(zval *op); ZEND_API void convert_to_array(zval *op); ZEND_API void convert_to_object(zval *op); ZEND_API int add_char_to_string(zval *result, zval *op1, zval *op2); ZEND_API int add_string_to_string(zval *result, zval *op1, zval *op2); -ZEND_API void convert_to_double(zval *op); END_EXTERN_C() ZEND_API int zval_is_true(zval *op); @@ -77,53 +77,21 @@ ZEND_API int zend_binary_strcasecmp(char *s1, uint len1, char *s2, uint len2); ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2); -#define convert_to_long_ex(ppzv) \ - if ((*ppzv)->type!=IS_LONG) { \ - if (!(*ppzv)->is_ref) { \ - SEPARATE_ZVAL(ppzv); \ - } \ - convert_to_long(*ppzv); \ - } - -#define convert_to_double_ex(ppzv) \ - if ((*ppzv)->type!=IS_DOUBLE) { \ - if (!(*ppzv)->is_ref) { \ +#define convert_to_ex_master(ppzv, lower_type, upper_type) \ + if ((*ppzv)->type!=IS_##upper_type) { \ + if (!(*ppzv)->is_ref) { \ SEPARATE_ZVAL(ppzv); \ } \ - convert_to_double(*ppzv); \ + convert_to_##lower_type(*ppzv); \ } -#define convert_to_string_ex(ppzv) \ - if ((*ppzv)->type!=IS_STRING) { \ - if (!(*ppzv)->is_ref) { \ - SEPARATE_ZVAL(ppzv); \ - } \ - convert_to_string(*ppzv); \ - } - -#define convert_to_array_ex(ppzv) \ - if ((*ppzv)->type!=IS_ARRAY) { \ - if (!(*ppzv)->is_ref) { \ - SEPARATE_ZVAL(ppzv); \ - } \ - convert_to_array(*ppzv); \ - } - -#define convert_to_object_ex(ppzv) \ - if ((*ppzv)->type!=IS_OBJECT) { \ - if (!(*ppzv)->is_ref) { \ - SEPARATE_ZVAL(ppzv); \ - } \ - convert_to_object(*ppzv); \ - } - -#define convert_to_boolean_ex(ppzv) \ - if ((*ppzv)->type!=IS_BOOL) { \ - if (!(*ppzv)->is_ref) { \ - SEPARATE_ZVAL(ppzv); \ - } \ - convert_to_boolean(*ppzv); \ - } +#define convert_to_boolean_ex(ppzv) convert_to_ex_master(ppzv, boolean, BOOL) +#define convert_to_long_ex(ppzv) convert_to_ex_master(ppzv, long, LONG) +#define convert_to_double_ex(ppzv) convert_to_ex_master(ppzv, double, DOUBLE) +#define convert_to_string_ex(ppzv) convert_to_ex_master(ppzv, string, STRING) +#define convert_to_array_ex(ppzv) convert_to_ex_master(ppzv, array, ARRAY) +#define convert_to_object_ex(ppzv) convert_to_ex_master(ppzv, object, OBJECT) +#define convert_to_null_ex(ppzv) convert_to_ex_master(ppzv, null, NULL) #define convert_scalar_to_number_ex(ppzv) \ if ((*ppzv)->type!=IS_LONG && (*ppzv)->type!=IS_DOUBLE) { \ -- 2.50.1