Skip to content

Commit

Permalink
Taking advantage of return_value when possible, adding Forms\ElementI…
Browse files Browse the repository at this point in the history
…nterface [ci skip]
  • Loading branch information
phalcon committed Jul 12, 2013
1 parent 9813b6e commit 09d4970
Show file tree
Hide file tree
Showing 61 changed files with 1,018 additions and 759 deletions.
7 changes: 3 additions & 4 deletions ext/cache/backend/apc.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ PHP_METHOD(Phalcon_Cache_Backend_Apc, queryKeys){
#else
zval *itkey = NULL;
#endif
zend_object_iterator *it;

PHALCON_MM_GROW();

Expand Down Expand Up @@ -305,7 +304,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Apc, queryKeys){
/* APCIterator implements Iterator */
assert(instanceof_function_ex(ce0, zend_ce_iterator, 1 TSRMLS_CC));

it = ce0->get_iterator(ce0, iterator, 0 TSRMLS_CC);
zend_object_iterator* it = ce0->get_iterator(ce0, iterator, 0 TSRMLS_CC);

This comment has been minimized.

Copy link
@phalcon

phalcon Jul 12, 2013

Collaborator

Ok, question, gen-build.php must be executed in a 64bits processor? or if I execute it in a 32bits processor it also works?


/* APCIterator is an iterator */
assert(it != NULL);
Expand All @@ -324,15 +323,15 @@ PHP_METHOD(Phalcon_Cache_Backend_Apc, queryKeys){
* Note that str_key_len includes the trailing zero.
* Remove the _PHCA prefix.
*/
ZVAL_STRINGL(key, str_key+5, str_key_len-5-1, 1);
ZVAL_STRINGL(key, str_key + 5, str_key_len - 5 - 1, 1);

phalcon_array_append(&keys, key, PH_SEPARATE);
}
#else
PHALCON_INIT_NVAR(itkey);
it->funcs->get_current_key(it, itkey TSRMLS_CC);
if (likely(Z_TYPE_P(itkey) == IS_STRING)) {
ZVAL_STRINGL(key, Z_STRVAL_P(itkey)+5, Z_STRLEN_P(itkey)-5, 1);
ZVAL_STRINGL(key, Z_STRVAL_P(itkey) + 5, Z_STRLEN_P(itkey) - 5, 1);
phalcon_array_append(&keys, key, PH_SEPARATE);
}
#endif
Expand Down
15 changes: 5 additions & 10 deletions ext/cache/backend/memcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ PHP_METHOD(Phalcon_Cache_Backend_Memcache, get){

zval *key_name, *lifetime = NULL, *memcache = NULL, *frontend;
zval *prefix, *prefixed_key, *cached_content;
zval *content;

PHALCON_MM_GROW();

Expand Down Expand Up @@ -224,10 +223,8 @@ PHP_METHOD(Phalcon_Cache_Backend_Memcache, get){
RETURN_MM_NULL();
}

PHALCON_INIT_VAR(content);
phalcon_call_method_p1(content, frontend, "afterretrieve", cached_content);

RETURN_CCTOR(content);
phalcon_call_method_p1(return_value, frontend, "afterretrieve", cached_content);
RETURN_MM();
}

/**
Expand Down Expand Up @@ -373,7 +370,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Memcache, save){
PHP_METHOD(Phalcon_Cache_Backend_Memcache, delete){

zval *key_name, *memcache = NULL, *prefix, *prefixed_key;
zval *options, *special_key, *keys, *success;
zval *options, *special_key, *keys;

PHALCON_MM_GROW();

Expand Down Expand Up @@ -410,10 +407,8 @@ PHP_METHOD(Phalcon_Cache_Backend_Memcache, delete){
/**
* Delete the key from memcached
*/
PHALCON_INIT_VAR(success);
phalcon_call_method_p1(success, memcache, "delete", prefixed_key);

RETURN_CCTOR(success);
phalcon_call_method_p1(return_value, memcache, "delete", prefixed_key);
RETURN_MM();
}

/**
Expand Down
9 changes: 3 additions & 6 deletions ext/cache/backend/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ PHALCON_INIT_CLASS(Phalcon_Cache_Backend_Memory){
PHP_METHOD(Phalcon_Cache_Backend_Memory, get){

zval *key_name, *lifetime = NULL, *last_key = NULL, *prefix, *data;
zval *cached_content, *frontend, *processed;
zval *cached_content, *frontend;

PHALCON_MM_GROW();

Expand Down Expand Up @@ -119,11 +119,8 @@ PHP_METHOD(Phalcon_Cache_Backend_Memory, get){

PHALCON_OBS_VAR(frontend);
phalcon_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC);

PHALCON_INIT_VAR(processed);
phalcon_call_method_p1(processed, frontend, "afterretrieve", cached_content);

RETURN_CCTOR(processed);
phalcon_call_method_p1(return_value, frontend, "afterretrieve", cached_content);
RETURN_MM();
}

/**
Expand Down
23 changes: 8 additions & 15 deletions ext/cache/backend/mongo.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Mongo, get){
zval *key_name, *lifetime = NULL, *frontend, *prefix, *prefixed_key;
zval *collection, *conditions, *document, *timestamp;
zval *ttl = NULL, *modified_time, *difference, *not_expired;
zval *cached_content, *content;
zval *cached_content;

PHALCON_MM_GROW();

Expand Down Expand Up @@ -295,11 +295,8 @@ PHP_METHOD(Phalcon_Cache_Backend_Mongo, get){

PHALCON_OBS_VAR(cached_content);
phalcon_array_fetch_string(&cached_content, document, SL("data"), PH_NOISY);

PHALCON_INIT_VAR(content);
phalcon_call_method_p1(content, frontend, "afterretrieve", cached_content);

RETURN_CCTOR(content);
phalcon_call_method_p1(return_value, frontend, "afterretrieve", cached_content);
RETURN_MM();
}
}

Expand Down Expand Up @@ -427,7 +424,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Mongo, save){
PHP_METHOD(Phalcon_Cache_Backend_Mongo, delete){

zval *key_name, *prefix, *prefixed_key, *collection;
zval *conditions, *success;
zval *conditions;

PHALCON_MM_GROW();

Expand All @@ -445,9 +442,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Mongo, delete){
PHALCON_INIT_VAR(conditions);
array_init_size(conditions, 1);
phalcon_array_update_string(&conditions, SL("key"), &prefixed_key, PH_COPY | PH_SEPARATE);

PHALCON_INIT_VAR(success);
phalcon_call_method_p1(success, collection, "remove", conditions);
phalcon_call_method_p1_noret(collection, "remove", conditions);
RETURN_MM_TRUE;
}

Expand Down Expand Up @@ -539,7 +534,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Mongo, queryKeys){
PHP_METHOD(Phalcon_Cache_Backend_Mongo, exists){

zval *key_name = NULL, *lifetime = NULL, *last_key = NULL, *prefix, *collection;
zval *conditions, *number, *zero, *exists;
zval *conditions, *number, *zero;

PHALCON_MM_GROW();

Expand Down Expand Up @@ -576,10 +571,8 @@ PHP_METHOD(Phalcon_Cache_Backend_Mongo, exists){

PHALCON_INIT_VAR(zero);
ZVAL_LONG(zero, 0);

PHALCON_INIT_VAR(exists);
is_smaller_function(exists, zero, number TSRMLS_CC);
RETURN_NCTOR(exists);
is_smaller_function(return_value, zero, number TSRMLS_CC);
RETURN_MM();
}

RETURN_MM_FALSE;
Expand Down
14 changes: 6 additions & 8 deletions ext/cache/frontend/base64.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,14 @@ PHP_METHOD(Phalcon_Cache_Frontend_Base64, stop){
*/
PHP_METHOD(Phalcon_Cache_Frontend_Base64, beforeStore){

zval *data, *serialized;
zval *data;

PHALCON_MM_GROW();

phalcon_fetch_params(1, 1, 0, &data);

PHALCON_INIT_VAR(serialized);
phalcon_base64_encode(serialized, data);
RETURN_CTOR(serialized);
phalcon_base64_encode(return_value, data);
RETURN_MM();
}

/**
Expand All @@ -201,14 +200,13 @@ PHP_METHOD(Phalcon_Cache_Frontend_Base64, beforeStore){
*/
PHP_METHOD(Phalcon_Cache_Frontend_Base64, afterRetrieve){

zval *data, *unserialized;
zval *data;

PHALCON_MM_GROW();

phalcon_fetch_params(1, 1, 0, &data);

PHALCON_INIT_VAR(unserialized);
phalcon_base64_decode(unserialized, data);
RETURN_CTOR(unserialized);
phalcon_base64_decode(return_value, data);
RETURN_MM();
}

14 changes: 6 additions & 8 deletions ext/cache/frontend/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,14 @@ PHP_METHOD(Phalcon_Cache_Frontend_Data, stop){
*/
PHP_METHOD(Phalcon_Cache_Frontend_Data, beforeStore){

zval *data, *serialized;
zval *data;

PHALCON_MM_GROW();

phalcon_fetch_params(1, 1, 0, &data);

PHALCON_INIT_VAR(serialized);
phalcon_serialize(serialized, &data TSRMLS_CC);
RETURN_CTOR(serialized);
phalcon_serialize(return_value, &data TSRMLS_CC);
RETURN_MM();
}

/**
Expand All @@ -205,14 +204,13 @@ PHP_METHOD(Phalcon_Cache_Frontend_Data, beforeStore){
*/
PHP_METHOD(Phalcon_Cache_Frontend_Data, afterRetrieve){

zval *data, *unserialized;
zval *data;

PHALCON_MM_GROW();

phalcon_fetch_params(1, 1, 0, &data);

PHALCON_INIT_VAR(unserialized);
phalcon_unserialize(unserialized, data TSRMLS_CC);
RETURN_CTOR(unserialized);
phalcon_unserialize(return_value, data TSRMLS_CC);
RETURN_MM();
}

14 changes: 6 additions & 8 deletions ext/cache/frontend/igbinary.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,14 @@ PHALCON_INIT_CLASS(Phalcon_Cache_Frontend_Igbinary){
*/
PHP_METHOD(Phalcon_Cache_Frontend_Igbinary, beforeStore){

zval *data, *serialized;
zval *data;

PHALCON_MM_GROW();

phalcon_fetch_params(1, 1, 0, &data);

PHALCON_INIT_VAR(serialized);
phalcon_call_func_p1(serialized, "igbinary_serialize", data);
RETURN_CCTOR(serialized);
phalcon_call_func_p1(return_value, "igbinary_serialize", data);
RETURN_MM();
}

/**
Expand All @@ -114,14 +113,13 @@ PHP_METHOD(Phalcon_Cache_Frontend_Igbinary, beforeStore){
*/
PHP_METHOD(Phalcon_Cache_Frontend_Igbinary, afterRetrieve){

zval *data, *unserialized;
zval *data;

PHALCON_MM_GROW();

phalcon_fetch_params(1, 1, 0, &data);

PHALCON_INIT_VAR(unserialized);
phalcon_call_func_p1(unserialized, "igbinary_unserialize", data);
RETURN_CCTOR(unserialized);
phalcon_call_func_p1(return_value, "igbinary_unserialize", data);
RETURN_MM();
}

14 changes: 6 additions & 8 deletions ext/cache/frontend/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,14 @@ PHP_METHOD(Phalcon_Cache_Frontend_Json, stop){
*/
PHP_METHOD(Phalcon_Cache_Frontend_Json, beforeStore){

zval *data, *serialized;
zval *data;

PHALCON_MM_GROW();

phalcon_fetch_params(1, 1, 0, &data);

PHALCON_INIT_VAR(serialized);
phalcon_call_func_p1(serialized, "json_encode", data);
RETURN_CCTOR(serialized);
phalcon_call_func_p1(return_value, "json_encode", data);
RETURN_MM();
}

/**
Expand All @@ -197,14 +196,13 @@ PHP_METHOD(Phalcon_Cache_Frontend_Json, beforeStore){
*/
PHP_METHOD(Phalcon_Cache_Frontend_Json, afterRetrieve){

zval *data, *unserialized;
zval *data;

PHALCON_MM_GROW();

phalcon_fetch_params(1, 1, 0, &data);

PHALCON_INIT_VAR(unserialized);
phalcon_call_func_p1(unserialized, "json_decode", data);
RETURN_CCTOR(unserialized);
phalcon_call_func_p1(return_value, "json_decode", data);
RETURN_MM();
}

1 change: 1 addition & 0 deletions ext/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ forms/element/submit.c \
forms/element/date.c \
forms/exception.c \
forms/element.c \
forms/elementinterface.c \
http/response.c \
http/requestinterface.c \
http/request.c \
Expand Down
2 changes: 1 addition & 1 deletion ext/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if (PHP_PHALCON != "no") {
ADD_SOURCES("ext/phalcon/db/profiler", "item.c", "phalcon")
ADD_SOURCES("ext/phalcon/db/adapter/pdo", "sqlite.c mysql.c oracle.c postgresql.c", "phalcon")
ADD_SOURCES("ext/phalcon/db/adapter", "pdo.c", "phalcon")
ADD_SOURCES("ext/phalcon/forms", "form.c manager.c exception.c element.c", "phalcon")
ADD_SOURCES("ext/phalcon/forms", "form.c manager.c exception.c element.c elementinterface.c", "phalcon")
ADD_SOURCES("ext/phalcon/forms/element", "file.c email.c hidden.c password.c text.c select.c textarea.c check.c numeric.c submit.c date.c", "phalcon")
ADD_SOURCES("ext/phalcon/http", "response.c requestinterface.c request.c cookie.c responseinterface.c", "phalcon")
ADD_SOURCES("ext/phalcon/http/request", "file.c exception.c fileinterface.c", "phalcon")
Expand Down
4 changes: 2 additions & 2 deletions ext/db/adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ PHP_METHOD(Phalcon_Db_Adapter, update){
if (phalcon_array_isset_string(where_condition, SS("bind"))) {
PHALCON_OBS_VAR(where_bind);
phalcon_array_fetch_string(&where_bind, where_condition, SL("bind"), PH_NOISY);
phalcon_merge_append(update_values, where_bind);
phalcon_merge_append(update_values, where_bind TSRMLS_CC);
}

/**
Expand All @@ -647,7 +647,7 @@ PHP_METHOD(Phalcon_Db_Adapter, update){
if (phalcon_array_isset_string(where_condition, SS("bindTypes"))) {
PHALCON_OBS_VAR(where_types);
phalcon_array_fetch_string(&where_types, where_condition, SL("bindTypes"), PH_NOISY);
phalcon_merge_append(bind_data_types, where_types);
phalcon_merge_append(bind_data_types, where_types TSRMLS_CC);
}
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions ext/db/adapter/pdo.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ PHP_METHOD(Phalcon_Db_Adapter_Pdo, connect){
PHALCON_INIT_VAR(dsn_parts);
array_init(dsn_parts);

if (!phalcon_is_iterable_ex(descriptor, &ah0, &hp0, 0, 0)) {
if (!phalcon_is_iterable_ex(descriptor, &ah0, &hp0, 0, 0 TSRMLS_CC)) {
return;
}

Expand Down Expand Up @@ -302,7 +302,7 @@ PHP_METHOD(Phalcon_Db_Adapter_Pdo, executePrepared){
PHALCON_INIT_VAR(one);
ZVAL_LONG(one, 1);

if (!phalcon_is_iterable_ex(placeholders, &ah0, &hp0, 0, 0)) {
if (!phalcon_is_iterable_ex(placeholders, &ah0, &hp0, 0, 0 TSRMLS_CC)) {
return;
}

Expand Down
9 changes: 4 additions & 5 deletions ext/db/column.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ PHP_METHOD(Phalcon_Db_Column, __set_state){

zval *data, *definition, *column_name, *column_type;
zval *not_null, *primary, *size, *dunsigned, *after;
zval *is_numeric, *first, *bind_type, *column;
zval *is_numeric, *first, *bind_type;

PHALCON_MM_GROW();

Expand Down Expand Up @@ -474,10 +474,9 @@ PHP_METHOD(Phalcon_Db_Column, __set_state){
phalcon_array_update_string(&definition, SL("bindType"), &bind_type, PH_COPY | PH_SEPARATE);
}

PHALCON_INIT_VAR(column);
object_init_ex(column, phalcon_db_column_ce);
phalcon_call_method_p2_noret(column, "__construct", column_name, definition);
object_init_ex(return_value, phalcon_db_column_ce);
phalcon_call_method_p2_noret(return_value, "__construct", column_name, definition);

RETURN_CTOR(column);
RETURN_MM();
}

Loading

0 comments on commit 09d4970

Please sign in to comment.