Skip to content

Commit

Permalink
Fixing warning using annotations strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
phalcon committed Oct 20, 2014
1 parent 450ad38 commit e0b84b9
Show file tree
Hide file tree
Showing 25 changed files with 180 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ before_script:
- (cd php-tests/library/Twig; git checkout master)
- (cd vendor/phalcon/zephir; ./unit-tests/ci/before_install.sh; ./install)
- ./vendor/bin/zephir generate
- (cd ext; export CFLAGS="-g3 -O1 -std=gnu90 -Wall"; phpize && ./configure --enable-phalcon && make --silent -j4 && sudo make --silent install && phpenv config-add ../unit-tests/ci/phalcon.ini)
- (cd ext; export CFLAGS="-g3 -O1 -std=gnu90 -Wall -DZEPHIR_RELEASE=1"; phpize && ./configure --enable-phalcon && make --silent -j4 && sudo make --silent install && phpenv config-add ../unit-tests/ci/phalcon.ini)
- ulimit -c unlimited || true

script:
Expand Down
2 changes: 1 addition & 1 deletion ext/install
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
export CC="gcc"
export CFLAGS="-O2 -Wall -fvisibility=hidden -flto"
export CFLAGS="-O2 -Wall -fvisibility=hidden -flto -DZEPHIR_RELEASE=1"
if [ -f Makefile ]; then
sudo make --silent clean
sudo phpize --silent --clean
Expand Down
27 changes: 9 additions & 18 deletions ext/kernel/fcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,17 +432,8 @@ int zephir_call_user_function(zval **object_pp, zend_class_entry *obj_ce, zephir

if (!cache_entry || !*cache_entry) {
if (EXPECTED(status != FAILURE) && fcall_key && !temp_cache_entry) {
#ifndef ZEPHIR_RELEASE
zephir_fcall_cache_entry *temp_cache_entry = malloc(sizeof(zephir_fcall_cache_entry));
cache_entry->f = fcic.function_handler;
cache_entry->times = 0;
#else
zephir_fcall_cache_entry *temp_cache_entry = fcic.function_handler;
#endif
if (FAILURE == zend_hash_quick_add(zephir_globals_ptr->fcache, fcall_key, fcall_key_len, fcall_key_hash, &temp_cache_entry, sizeof(zephir_fcall_cache_entry*), NULL)) {
#ifndef ZEPHIR_RELEASE
free(temp_cache_entry);
#endif
} else {
#if PHP_VERSION_ID < 50600
if (cache_entry) {
Expand Down Expand Up @@ -586,7 +577,7 @@ int zephir_call_class_method_aparams(zval **return_value_ptr, zend_class_entry *

case zephir_fcall_ce:
assert(ce != NULL);
add_next_index_stringl(fn, ce->name, ce->name_length, !IS_INTERNED(ce->name));
add_next_index_stringl(fn, ce->name, ce->name_length, 1);
break;

case zephir_fcall_method:
Expand All @@ -598,23 +589,23 @@ int zephir_call_class_method_aparams(zval **return_value_ptr, zend_class_entry *
}

ALLOC_INIT_ZVAL(mn);
ZVAL_STRINGL(mn, method_name, method_len, 0);
ZVAL_STRINGL(mn, method_name, method_len, 1);
add_next_index_zval(fn, mn);

} else {
ZVAL_STRINGL(fn, "undefined", sizeof("undefined")-1, 0);
ZVAL_STRINGL(fn, "undefined", sizeof("undefined")-1, 1);
}

status = zephir_call_user_function(object ? &object : NULL, ce, type, fn, rvp, cache_entry, param_count, params TSRMLS_CC);

if (Z_TYPE_P(fn) == IS_ARRAY) {
/*if (Z_TYPE_P(fn) == IS_ARRAY) {
if (Z_REFCOUNT_P(mn) > 1) {
zval_copy_ctor(mn);
} else {
ZVAL_NULL(mn);
}
zval_ptr_dtor(&mn);
}
}*/
//zval_ptr_dtor(&mn);
//}

if (status == FAILURE && !EG(exception)) {
switch (type) {
Expand All @@ -638,9 +629,9 @@ int zephir_call_class_method_aparams(zval **return_value_ptr, zend_class_entry *
zval_ptr_dtor(&rv);
}

if (Z_TYPE_P(fn) == IS_STRING) {
/*if (Z_TYPE_P(fn) == IS_STRING) {
ZVAL_NULL(fn);
}
}*/
zval_ptr_dtor(&fn);

return status;
Expand Down
5 changes: 3 additions & 2 deletions ext/kernel/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ typedef struct _zephir_memory_entry {
struct _zephir_memory_entry *prev;
struct _zephir_memory_entry *next;
#ifndef ZEPHIR_RELEASE
int permanent;
const char *func;
#endif
} zephir_memory_entry;
Expand Down Expand Up @@ -83,14 +84,14 @@ typedef struct _zephir_function_cache {
#endif

#ifndef INIT_PZVAL_COPY
# define INIT_PZVAL_COPY(z, v) \
#define INIT_PZVAL_COPY(z, v) \
ZVAL_COPY_VALUE(z, v); \
Z_SET_REFCOUNT_P(z, 1); \
Z_UNSET_ISREF_P(z);
#endif

#ifndef ZVAL_COPY_VALUE
# define ZVAL_COPY_VALUE(z, v) \
#define ZVAL_COPY_VALUE(z, v) \
(z)->value = (v)->value; \
Z_TYPE_P(z) = Z_TYPE_P(v);
#endif
Expand Down
35 changes: 22 additions & 13 deletions ext/kernel/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ int zephir_read_property(zval **result, zval *object, const char *property_name,
}

ALLOC_INIT_ZVAL(*result);
ZVAL_NULL(*result);
return FAILURE;
}

Expand Down Expand Up @@ -1253,7 +1254,7 @@ int zephir_update_property_array_string(zval *object, char *property, unsigned i
INIT_PZVAL_COPY(new_zv, tmp);
tmp = new_zv;
zval_copy_ctor(new_zv);
Z_SET_REFCOUNT_P(tmp, 1);
Z_SET_REFCOUNT_P(tmp, 0);
Z_UNSET_ISREF_P(tmp);
separated = 1;
}
Expand All @@ -1269,7 +1270,7 @@ int zephir_update_property_array_string(zval *object, char *property, unsigned i
INIT_PZVAL_COPY(new_zv, tmp);
tmp = new_zv;
zval_copy_ctor(new_zv);
Z_SET_REFCOUNT_P(tmp, 1);
Z_SET_REFCOUNT_P(tmp, 0);
Z_UNSET_ISREF_P(tmp);
array_init(tmp);
separated = 1;
Expand Down Expand Up @@ -1480,14 +1481,19 @@ zval* zephir_fetch_static_property_ce(zend_class_entry *ce, const char *property
}

int zephir_read_static_property_ce(zval **result, zend_class_entry *ce, const char *property, int len TSRMLS_DC) {
assert(ce != NULL);

*result = zephir_fetch_static_property_ce(ce, property, len TSRMLS_CC);
if (*result) {
Z_ADDREF_PP(result);
zval *tmp;
tmp = zephir_fetch_static_property_ce(ce, property, len TSRMLS_CC);
if (tmp) {
if (!Z_ISREF_P(tmp)) {
*result = tmp;
Z_ADDREF_PP(result);
} else {
ALLOC_INIT_ZVAL(*result);
ZVAL_ZVAL(*result, tmp, 1, 0);
}
return SUCCESS;
}

ALLOC_INIT_ZVAL(*result);
return FAILURE;
}

Expand All @@ -1511,7 +1517,7 @@ static zval **zephir_std_get_static_property(zend_class_entry *ce, const char *p
}

#ifndef ZEPHIR_RELEASE
if (UNEXPECTED(!zend_verify_property_access(temp_property_info, ce TSRMLS_CC))) {
/*if (UNEXPECTED(!zend_verify_property_access(temp_property_info, ce TSRMLS_CC))) {
if (!silent) {
zend_error_noreturn(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(temp_property_info->flags), ce->name, property_name);
}
Expand All @@ -1523,7 +1529,7 @@ static zval **zephir_std_get_static_property(zend_class_entry *ce, const char *p
zend_error_noreturn(E_ERROR, "Access to undeclared static property: %s::$%s", ce->name, property_name);
}
return NULL;
}
}*/
#endif

zend_update_class_constants(ce TSRMLS_CC);
Expand Down Expand Up @@ -1656,9 +1662,12 @@ int zephir_update_static_property_array_multi_ce(zend_class_entry *ce, const cha
int i, j, l, ll, re_update, must_continue, wrap_tmp;
int separated = 0;

zephir_read_static_property_ce(&tmp_arr, ce, property, property_length TSRMLS_CC);

Z_DELREF_P(tmp_arr);
tmp_arr = zephir_fetch_static_property_ce(ce, property, property_length TSRMLS_CC);
if (!tmp_arr) {
ALLOC_INIT_ZVAL(tmp_arr);
array_init(tmp_arr);
separated = 1;
}

/** Separation only when refcount > 1 */
if (Z_REFCOUNT_P(tmp_arr) > 1) {
Expand Down
15 changes: 7 additions & 8 deletions ext/phalcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ void zephir_initialize_memory(zend_zephir_globals_def *zephir_globals_ptr TSRMLS
Z_SET_REFCOUNT_P(zephir_globals_ptr->global_true, 2);
ZVAL_TRUE(zephir_globals_ptr->global_true);

//zephir_globals_ptr->initialized = 1;
zephir_globals_ptr->initialized = 1;
}

int zephir_cleanup_fcache(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
Expand Down Expand Up @@ -469,17 +469,15 @@ void zephir_deinitialize_memory(TSRMLS_D)
size_t i;
zend_zephir_globals_def *zephir_globals_ptr = ZEPHIR_VGLOBAL;

//if (zephir_globals_ptr->initialized != 1) {
// zephir_globals_ptr->initialized = 0;
// return;
//}
if (zephir_globals_ptr->initialized != 1) {
zephir_globals_ptr->initialized = 0;
return;
}

if (zephir_globals_ptr->start_memory != NULL) {
zephir_clean_restore_stack(TSRMLS_C);
}

//zephir_orm_destroy_cache(TSRMLS_C);

zend_hash_apply_with_arguments(zephir_globals_ptr->fcache TSRMLS_CC, zephir_cleanup_fcache, 0);

#ifndef ZEPHIR_RELEASE
Expand All @@ -504,7 +502,7 @@ void zephir_deinitialize_memory(TSRMLS_D)
zval_ptr_dtor(&zephir_globals_ptr->global_true);
}

//zephir_globals_ptr->initialized = 0;
zephir_globals_ptr->initialized = 0;
}

static PHP_MINIT_FUNCTION(phalcon)
Expand Down Expand Up @@ -882,6 +880,7 @@ static PHP_MSHUTDOWN_FUNCTION(phalcon)
*/
static void php_zephir_init_globals(zend_phalcon_globals *zephir_globals TSRMLS_DC)
{
zephir_globals->initialized = 0;

/* Memory options */
zephir_globals->active_memory = NULL;
Expand Down
2 changes: 1 addition & 1 deletion ext/phalcon/cli/router/route.zep.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ext/phalcon/debug.zep.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ext/phalcon/di.zep.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ext/phalcon/di/factorydefault.zep.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ext/phalcon/di/factorydefault/cli.zep.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ext/phalcon/image/adapter/gd.zep.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ext/phalcon/image/adapter/imagick.zep.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e0b84b9

Please sign in to comment.