Skip to content

Commit

Permalink
Make they are in the same style of Z_ISREF
Browse files Browse the repository at this point in the history
  • Loading branch information
laruence committed May 3, 2014
1 parent 5984f95 commit d8651fb
Show file tree
Hide file tree
Showing 30 changed files with 246 additions and 241 deletions.
1 change: 0 additions & 1 deletion Zend/zend_API.h
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,6 @@ END_EXTERN_C()

#define HASH_OF(p) (Z_TYPE_P(p)==IS_ARRAY ? Z_ARRVAL_P(p) : ((Z_TYPE_P(p)==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties((p) TSRMLS_CC) : NULL)))
#define ZVAL_IS_NULL(z) (Z_TYPE_P(z) == IS_NULL)
#define ZVAL_IS_UNDEF(z) (Z_TYPE_P(z) == IS_UNDEF)

/* For compatibility */
#define ZEND_MINIT ZEND_MODULE_STARTUP_N
Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_interfaces.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ ZEND_API void zend_user_it_invalidate_current(zend_object_iterator *_iter TSRMLS
{
zend_user_iterator *iter = (zend_user_iterator*)_iter;

if (!ZVAL_IS_UNDEF(&iter->value)) {
if (!Z_ISUNDEF(iter->value)) {
zval_ptr_dtor(&iter->value);
ZVAL_UNDEF(&iter->value);
}
Expand Down Expand Up @@ -182,7 +182,7 @@ ZEND_API zval *zend_user_it_get_current_data(zend_object_iterator *_iter TSRMLS_
zend_user_iterator *iter = (zend_user_iterator*)_iter;
zval *object = &iter->it.data;

if (ZVAL_IS_UNDEF(&iter->value)) {
if (Z_ISUNDEF(iter->value)) {
zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs.zf_current, "current", &iter->value);
}
return &iter->value;
Expand Down
6 changes: 6 additions & 0 deletions Zend/zend_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,12 @@ static inline zend_uchar zval_get_type(const zval* pz) {
#define Z_ISREF(zval) (Z_TYPE(zval) == IS_REFERENCE)
#define Z_ISREF_P(zval_p) Z_ISREF(*(zval_p))

#define Z_ISUNDEF(zval) (Z_TYPE(zval) == IS_UNDEF)
#define Z_ISUNDEF_P(zval_p) Z_ISUNDEF(*(zval_p))

#define Z_ISNULL(zval) (Z_TYPE(zval) == IS_NULL)
#define Z_ISNULL_P(zval_p) Z_ISNULL(*(zval_p))

#define Z_LVAL(zval) (zval).value.lval
#define Z_LVAL_P(zval_p) Z_LVAL(*(zval_p))

Expand Down
2 changes: 1 addition & 1 deletion ext/dom/php_dom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ static void dom_nnodemap_object_dtor(zend_object *object TSRMLS_DC) /* {{{ */
if (objmap->ns) {
xmlFree(objmap->ns);
}
if (!ZVAL_IS_UNDEF(&objmap->baseobj_zv)) {
if (!Z_ISUNDEF(objmap->baseobj_zv)) {
zval_ptr_dtor(&objmap->baseobj_zv);
}
efree(objmap);
Expand Down
8 changes: 4 additions & 4 deletions ext/libxml/libxml.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ static void _php_libxml_destroy_fci(zend_fcall_info *fci, zval *object)
zval_ptr_dtor(&fci->function_name);
fci->size = 0;
}
if (!ZVAL_IS_UNDEF(object)) {
if (!Z_ISUNDEF_P(object)) {
zval_ptr_dtor(object);
ZVAL_UNDEF(object);
}
Expand Down Expand Up @@ -337,7 +337,7 @@ static void *php_libxml_streams_IO_open_wrapper(const char *filename, const char
}
}

context = php_stream_context_from_zval(ZVAL_IS_UNDEF(&LIBXML(stream_context))? NULL : &LIBXML(stream_context), 0);
context = php_stream_context_from_zval(Z_ISUNDEF(LIBXML(stream_context))? NULL : &LIBXML(stream_context), 0);

ret_val = php_stream_open_wrapper_ex(path_to_open, (char *)mode, REPORT_ERRORS, NULL, context);
if (isescaped) {
Expand Down Expand Up @@ -606,7 +606,7 @@ static xmlParserInputPtr _php_libxml_external_entity_loader(const char *URL,
fci->no_separation = 1;

status = zend_call_function(fci, &LIBXML(entity_loader).fcc TSRMLS_CC);
if (status != SUCCESS || ZVAL_IS_UNDEF(&retval)) {
if (status != SUCCESS || Z_ISUNDEF(retval)) {
php_libxml_ctx_error(context,
"Call to user entity loader callback '%s' has failed",
Z_STRVAL(fci->function_name));
Expand Down Expand Up @@ -929,7 +929,7 @@ static PHP_FUNCTION(libxml_set_streams_context)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg) == FAILURE) {
return;
}
if (!ZVAL_IS_UNDEF(&LIBXML(stream_context))) {
if (!Z_ISUNDEF(LIBXML(stream_context))) {
zval_ptr_dtor(&LIBXML(stream_context));
ZVAL_UNDEF(&LIBXML(stream_context));
}
Expand Down
2 changes: 1 addition & 1 deletion ext/mbstring/mbstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -3256,7 +3256,7 @@ PHP_FUNCTION(mb_detect_encoding)
/* make encoding list */
list = NULL;
size = 0;
if (ZEND_NUM_ARGS() >= 2 && !ZVAL_IS_NULL(encoding_list)) {
if (ZEND_NUM_ARGS() >= 2 && !Z_ISNULL_P(encoding_list)) {
switch (Z_TYPE_P(encoding_list)) {
case IS_ARRAY:
if (FAILURE == php_mb_parse_encoding_array(encoding_list, &list, &size, 0 TSRMLS_CC)) {
Expand Down
10 changes: 5 additions & 5 deletions ext/mbstring/php_mbregex.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ PHP_RSHUTDOWN_FUNCTION(mb_regex)
{
MBREX(current_mbctype) = MBREX(default_mbctype);

if (!ZVAL_IS_UNDEF(&MBREX(search_str))) {
if (!Z_ISUNDEF(MBREX(search_str))) {
zval_ptr_dtor(&MBREX(search_str));
ZVAL_UNDEF(&MBREX(search_str));
}
Expand Down Expand Up @@ -970,7 +970,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp
arg_replace_fci.params = args;
arg_replace_fci.retval = &retval;
if (zend_call_function(&arg_replace_fci, &arg_replace_fci_cache TSRMLS_CC) == SUCCESS &&
!ZVAL_IS_UNDEF(&retval)) {
!Z_ISUNDEF(retval)) {
convert_to_string_ex(&retval);
smart_str_appendl(&out_buf, Z_STRVAL(retval), Z_STRLEN(retval));
if (eval_buf.s) {
Expand Down Expand Up @@ -1208,7 +1208,7 @@ _php_mb_regex_ereg_search_exec(INTERNAL_FUNCTION_PARAMETERS, int mode)
pos = MBREX(search_pos);
str = NULL;
len = 0;
if (!ZVAL_IS_UNDEF(&MBREX(search_str)) && Z_TYPE(MBREX(search_str)) == IS_STRING){
if (!Z_ISUNDEF(MBREX(search_str)) && Z_TYPE(MBREX(search_str)) == IS_STRING){
str = (OnigUChar *)Z_STRVAL(MBREX(search_str));
len = Z_STRLEN(MBREX(search_str));
}
Expand Down Expand Up @@ -1340,7 +1340,7 @@ PHP_FUNCTION(mb_ereg_search_init)
}
}

if (!ZVAL_IS_NULL(&MBREX(search_str))) {
if (!Z_ISNULL(MBREX(search_str))) {
zval_ptr_dtor(&MBREX(search_str));
}

Expand Down Expand Up @@ -1404,7 +1404,7 @@ PHP_FUNCTION(mb_ereg_search_setpos)
return;
}

if (position < 0 || (!ZVAL_IS_UNDEF(&MBREX(search_str)) && Z_TYPE(MBREX(search_str)) == IS_STRING && position >= Z_STRLEN(MBREX(search_str)))) {
if (position < 0 || (!Z_ISUNDEF(MBREX(search_str)) && Z_TYPE(MBREX(search_str)) == IS_STRING && position >= Z_STRLEN(MBREX(search_str)))) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Position is out of range");
MBREX(search_pos) = 0;
RETURN_FALSE;
Expand Down
2 changes: 1 addition & 1 deletion ext/mysql/php_mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -2209,7 +2209,7 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type,
if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) {
zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "Could not execute %s::%s()", ce->name->val, ce->constructor->common.function_name->val);
} else {
if (!ZVAL_IS_UNDEF(&retval)) {
if (!Z_ISUNDEF(retval)) {
zval_ptr_dtor(&retval);
}
}
Expand Down
14 changes: 7 additions & 7 deletions ext/pdo/pdo_dbh.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,14 @@ PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt TSRMLS_DC) /* {{{
zend_update_property_string(def_ex, &ex, "message", sizeof("message") - 1, message TSRMLS_CC);
zend_update_property_string(def_ex, &ex, "code", sizeof("code") - 1, *pdo_err TSRMLS_CC);

if (!ZVAL_IS_UNDEF(&info)) {
if (!Z_ISUNDEF(info)) {
zend_update_property(pdo_ex, &ex, "errorInfo", sizeof("errorInfo") - 1, &info TSRMLS_CC);
}

zend_throw_exception_object(&ex TSRMLS_CC);
}

if (!ZVAL_IS_UNDEF(&info)) {
if (!Z_ISUNDEF(info)) {
zval_ptr_dtor(&info);
}

Expand Down Expand Up @@ -425,7 +425,7 @@ static PHP_METHOD(PDO, dbh_constructor)

static zval *pdo_stmt_instantiate(pdo_dbh_t *dbh, zval *object, zend_class_entry *dbstmt_ce, zval *ctor_args TSRMLS_DC) /* {{{ */
{
if (!ZVAL_IS_UNDEF(ctor_args)) {
if (!Z_ISUNDEF_P(ctor_args)) {
if (Z_TYPE_P(ctor_args) != IS_ARRAY) {
pdo_raise_impl_error(dbh, NULL, "HY000", "constructor arguments must be passed as an array" TSRMLS_CC);
return NULL;
Expand Down Expand Up @@ -480,7 +480,7 @@ static void pdo_stmt_construct(pdo_stmt_t *stmt, zval *object, zend_class_entry
if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) {
Z_OBJ_P(object) = NULL;
object = NULL; /* marks failure */
} else if (!ZVAL_IS_UNDEF(&retval)) {
} else if (!Z_ISUNDEF(retval)) {
zval_ptr_dtor(&retval);
}

Expand Down Expand Up @@ -803,7 +803,7 @@ static int pdo_dbh_attribute_set(pdo_dbh_t *dbh, long attr, zval *value TSRMLS_D
return FAILURE;
}
dbh->def_stmt_ce = pce;
if (!ZVAL_IS_UNDEF(&dbh->def_stmt_ctor_args)) {
if (!Z_ISUNDEF(dbh->def_stmt_ctor_args)) {
zval_ptr_dtor(&dbh->def_stmt_ctor_args);
ZVAL_UNDEF(&dbh->def_stmt_ctor_args);
}
Expand Down Expand Up @@ -902,7 +902,7 @@ static PHP_METHOD(PDO, getAttribute)
case PDO_ATTR_STATEMENT_CLASS:
array_init(return_value);
add_next_index_str(return_value, STR_COPY(dbh->def_stmt_ce->name));
if (!ZVAL_IS_UNDEF(&dbh->def_stmt_ctor_args)) {
if (!Z_ISUNDEF(dbh->def_stmt_ctor_args)) {
Z_ADDREF(dbh->def_stmt_ctor_args);
add_next_index_zval(return_value, &dbh->def_stmt_ctor_args);
}
Expand Down Expand Up @@ -1518,7 +1518,7 @@ static void dbh_free(pdo_dbh_t *dbh TSRMLS_DC)
pefree((char *)dbh->persistent_id, dbh->is_persistent);
}

if (!ZVAL_IS_UNDEF(&dbh->def_stmt_ctor_args)) {
if (!Z_ISUNDEF(dbh->def_stmt_ctor_args)) {
zval_ptr_dtor(&dbh->def_stmt_ctor_args);
}

Expand Down
42 changes: 21 additions & 21 deletions ext/pdo/pdo_stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ int pdo_stmt_describe_columns(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */

static void get_lazy_object(pdo_stmt_t *stmt, zval *return_value TSRMLS_DC) /* {{{ */
{
if (ZVAL_IS_UNDEF(&stmt->lazy_object_ref)) {
if (Z_ISUNDEF(stmt->lazy_object_ref)) {
pdo_row_t *row = ecalloc(1, sizeof(pdo_row_t));
row->stmt = stmt;
zend_object_std_init(&row->std, pdo_row_ce TSRMLS_CC);
Expand All @@ -282,11 +282,11 @@ static void param_dtor(zval *el) /* {{{ */
STR_RELEASE(param->name);
}

if (!ZVAL_IS_UNDEF(&param->parameter)) {
if (!Z_ISUNDEF(param->parameter)) {
zval_ptr_dtor(&param->parameter);
ZVAL_UNDEF(&param->parameter);
}
if (!ZVAL_IS_UNDEF(&param->driver_params)) {
if (!Z_ISUNDEF(param->driver_params)) {
zval_ptr_dtor(&param->driver_params);
}
efree(param);
Expand Down Expand Up @@ -318,7 +318,7 @@ static int really_register_bound_param(struct pdo_bound_param_data *param, pdo_s
parameter = Z_REFVAL(param->parameter);
}

if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_STR && param->max_value_len <= 0 && !ZVAL_IS_NULL(parameter)) {
if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_STR && param->max_value_len <= 0 && !Z_ISNULL_P(parameter)) {
if (Z_TYPE_P(parameter) == IS_DOUBLE) {
char *p;
int len = spprintf(&p, 0, "%.*H", (int) EG(precision), Z_DVAL_P(parameter));
Expand Down Expand Up @@ -479,7 +479,7 @@ static PHP_METHOD(PDOStatement, execute)
ZVAL_COPY(&param.parameter, tmp);

if (!really_register_bound_param(&param, stmt, 1 TSRMLS_CC)) {
if (!ZVAL_IS_UNDEF(&param.parameter)) {
if (!Z_ISUNDEF(param.parameter)) {
zval_ptr_dtor(&param.parameter);
}
RETURN_FALSE;
Expand Down Expand Up @@ -759,7 +759,7 @@ static int do_fetch_class_prepare(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
fcc->calling_scope = EG(scope);
fcc->called_scope = ce;
return 1;
} else if (!ZVAL_IS_UNDEF(&stmt->fetch.cls.ctor_args)) {
} else if (!Z_ISUNDEF(stmt->fetch.cls.ctor_args)) {
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied class does not have a constructor, use NULL for the ctor_params parameter, or simply omit it" TSRMLS_CC);
return 0;
} else {
Expand Down Expand Up @@ -816,7 +816,7 @@ static int do_fetch_opt_finish(pdo_stmt_t *stmt, int free_ctor_agrs TSRMLS_DC) /
}

stmt->fetch.cls.fci.size = 0;
if (!ZVAL_IS_UNDEF(&stmt->fetch.cls.ctor_args) && free_ctor_agrs) {
if (!Z_ISUNDEF(stmt->fetch.cls.ctor_args) && free_ctor_agrs) {
zval_ptr_dtor(&stmt->fetch.cls.ctor_args);
ZVAL_UNDEF(&stmt->fetch.cls.ctor_args);
stmt->fetch.cls.fci.param_count = 0;
Expand Down Expand Up @@ -959,7 +959,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "could not call class constructor" TSRMLS_CC);
return 0;
} else {
if (!ZVAL_IS_UNDEF(&stmt->fetch.cls.retval)) {
if (!Z_ISUNDEF(stmt->fetch.cls.retval)) {
zval_ptr_dtor(&stmt->fetch.cls.retval);
ZVAL_UNDEF(&stmt->fetch.cls.retval);
}
Expand All @@ -969,7 +969,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_
break;

case PDO_FETCH_INTO:
if (ZVAL_IS_UNDEF(&stmt->fetch.into)) {
if (Z_ISUNDEF(stmt->fetch.into)) {
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "No fetch-into object specified." TSRMLS_CC);
return 0;
break;
Expand All @@ -983,7 +983,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_
break;

case PDO_FETCH_FUNC:
if (ZVAL_IS_UNDEF(&stmt->fetch.func.function)) {
if (Z_ISUNDEF(stmt->fetch.func.function)) {
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "No fetch function specified" TSRMLS_CC);
return 0;
}
Expand Down Expand Up @@ -1156,7 +1156,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "could not call class constructor" TSRMLS_CC);
return 0;
} else {
if (!ZVAL_IS_UNDEF(&stmt->fetch.cls.retval)) {
if (!Z_ISUNDEF(stmt->fetch.cls.retval)) {
zval_ptr_dtor(&stmt->fetch.cls.retval);
}
}
Expand All @@ -1179,7 +1179,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_
if (return_all) {
zval_ptr_dtor(return_value); /* we don't need that */
ZVAL_COPY_VALUE(return_value, &retval);
} else if (!ZVAL_IS_UNDEF(&retval)) {
} else if (!Z_ISUNDEF(retval)) {
ZVAL_COPY_VALUE(return_value, &retval);
}
}
Expand Down Expand Up @@ -1579,7 +1579,7 @@ static int register_bound_param(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt,

ZVAL_COPY(&param.parameter, parameter);
if (!really_register_bound_param(&param, stmt, is_param TSRMLS_CC)) {
if (!ZVAL_IS_UNDEF(&param.parameter)) {
if (!Z_ISUNDEF(param.parameter)) {
zval_ptr_dtor(&(param.parameter));
}
return 0;
Expand Down Expand Up @@ -1617,7 +1617,7 @@ static PHP_METHOD(PDOStatement, bindValue)

ZVAL_COPY(&param.parameter, parameter);
if (!really_register_bound_param(&param, stmt, TRUE TSRMLS_CC)) {
if (!ZVAL_IS_UNDEF(&param.parameter)) {
if (!Z_ISUNDEF(param.parameter)) {
zval_ptr_dtor(&(param.parameter));
ZVAL_UNDEF(&param.parameter);
}
Expand Down Expand Up @@ -1856,7 +1856,7 @@ int pdo_stmt_setup_fetch_mode(INTERNAL_FUNCTION_PARAMETERS, pdo_stmt_t *stmt, in

switch (stmt->default_fetch_type) {
case PDO_FETCH_INTO:
if (!ZVAL_IS_UNDEF(&stmt->fetch.into)) {
if (!Z_ISUNDEF(stmt->fetch.into)) {
zval_ptr_dtor(&stmt->fetch.into);
ZVAL_UNDEF(&stmt->fetch.into);
}
Expand Down Expand Up @@ -2344,13 +2344,13 @@ static void free_statement(pdo_stmt_t *stmt TSRMLS_DC)
stmt->columns = NULL;
}

if (!ZVAL_IS_UNDEF(&stmt->fetch.into) && stmt->default_fetch_type == PDO_FETCH_INTO) {
if (!Z_ISUNDEF(stmt->fetch.into) && stmt->default_fetch_type == PDO_FETCH_INTO) {
ZVAL_UNDEF(&stmt->fetch.into);
}

do_fetch_opt_finish(stmt, 1 TSRMLS_CC);

if (!ZVAL_IS_UNDEF(&stmt->database_object_handle)) {
if (!Z_ISUNDEF(stmt->database_object_handle)) {
zval_ptr_dtor(&stmt->database_object_handle);
}
zend_object_std_dtor(&stmt->std TSRMLS_CC);
Expand Down Expand Up @@ -2390,7 +2390,7 @@ static void pdo_stmt_iter_dtor(zend_object_iterator *iter TSRMLS_DC)

zval_ptr_dtor(&I->iter.data);

if (!ZVAL_IS_UNDEF(&I->fetch_ahead)) {
if (!Z_ISUNDEF(I->fetch_ahead)) {
zval_ptr_dtor(&I->fetch_ahead);
}
}
Expand All @@ -2399,15 +2399,15 @@ static int pdo_stmt_iter_valid(zend_object_iterator *iter TSRMLS_DC)
{
struct php_pdo_iterator *I = (struct php_pdo_iterator*)iter;

return ZVAL_IS_UNDEF(&I->fetch_ahead) ? FAILURE : SUCCESS;
return Z_ISUNDEF(I->fetch_ahead) ? FAILURE : SUCCESS;
}

static zval *pdo_stmt_iter_get_data(zend_object_iterator *iter TSRMLS_DC)
{
struct php_pdo_iterator *I = (struct php_pdo_iterator*)iter;

/* sanity */
if (ZVAL_IS_UNDEF(&I->fetch_ahead)) {
if (Z_ISUNDEF(I->fetch_ahead)) {
return NULL;
}

Expand All @@ -2430,7 +2430,7 @@ static void pdo_stmt_iter_move_forwards(zend_object_iterator *iter TSRMLS_DC)
struct php_pdo_iterator *I = (struct php_pdo_iterator*)iter;
pdo_stmt_t *stmt = Z_PDO_STMT_P(&I->iter.data); /* for PDO_HANDLE_STMT_ERR() */

if (!ZVAL_IS_UNDEF(&I->fetch_ahead)) {
if (!Z_ISUNDEF(I->fetch_ahead)) {
zval_ptr_dtor(&I->fetch_ahead);
}

Expand Down
Loading

0 comments on commit d8651fb

Please sign in to comment.