Skip to content

Commit

Permalink
Using latest Zephir
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgutierrez committed May 4, 2015
1 parent 2287c38 commit 1dd968e
Show file tree
Hide file tree
Showing 47 changed files with 4,593 additions and 2,116 deletions.
166 changes: 0 additions & 166 deletions ext/kernel/concat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1379,89 +1379,6 @@ void zephir_concat_vsvv(zval **result, zval *op1, const char *op2, zend_uint op2

}

void zephir_concat_vsvvv(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, zval *op4, zval *op5, int self_var TSRMLS_DC){

zval result_copy, op1_copy, op3_copy, op4_copy, op5_copy;
int use_copy = 0, use_copy1 = 0, use_copy3 = 0, use_copy4 = 0, use_copy5 = 0;
uint offset = 0, length;

if (Z_TYPE_P(op1) != IS_STRING) {
zend_make_printable_zval(op1, &op1_copy, &use_copy1);
if (use_copy1) {
op1 = &op1_copy;
}
}

if (Z_TYPE_P(op3) != IS_STRING) {
zend_make_printable_zval(op3, &op3_copy, &use_copy3);
if (use_copy3) {
op3 = &op3_copy;
}
}

if (Z_TYPE_P(op4) != IS_STRING) {
zend_make_printable_zval(op4, &op4_copy, &use_copy4);
if (use_copy4) {
op4 = &op4_copy;
}
}

if (Z_TYPE_P(op5) != IS_STRING) {
zend_make_printable_zval(op5, &op5_copy, &use_copy5);
if (use_copy5) {
op5 = &op5_copy;
}
}

length = Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + Z_STRLEN_P(op4) + Z_STRLEN_P(op5);
if (self_var) {

if (Z_TYPE_PP(result) != IS_STRING) {
zend_make_printable_zval(*result, &result_copy, &use_copy);
if (use_copy) {
ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy));
}
}

offset = Z_STRLEN_PP(result);
length += offset;
Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1);

} else {
Z_STRVAL_PP(result) = (char *) emalloc(length + 1);
}

memcpy(Z_STRVAL_PP(result) + offset, Z_STRVAL_P(op1), Z_STRLEN_P(op1));
memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1), op2, op2_len);
memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len, Z_STRVAL_P(op3), Z_STRLEN_P(op3));
memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3), Z_STRVAL_P(op4), Z_STRLEN_P(op4));
memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + op2_len + Z_STRLEN_P(op3) + Z_STRLEN_P(op4), Z_STRVAL_P(op5), Z_STRLEN_P(op5));
Z_STRVAL_PP(result)[length] = 0;
Z_TYPE_PP(result) = IS_STRING;
Z_STRLEN_PP(result) = length;

if (use_copy1) {
zval_dtor(op1);
}

if (use_copy3) {
zval_dtor(op3);
}

if (use_copy4) {
zval_dtor(op4);
}

if (use_copy5) {
zval_dtor(op5);
}

if (use_copy) {
zval_dtor(&result_copy);
}

}

void zephir_concat_vv(zval **result, zval *op1, zval *op2, int self_var TSRMLS_DC){

zval result_copy, op1_copy, op2_copy;
Expand Down Expand Up @@ -1720,89 +1637,6 @@ void zephir_concat_vvv(zval **result, zval *op1, zval *op2, zval *op3, int self_

}

void zephir_concat_vvvsv(zval **result, zval *op1, zval *op2, zval *op3, const char *op4, zend_uint op4_len, zval *op5, int self_var TSRMLS_DC){

zval result_copy, op1_copy, op2_copy, op3_copy, op5_copy;
int use_copy = 0, use_copy1 = 0, use_copy2 = 0, use_copy3 = 0, use_copy5 = 0;
uint offset = 0, length;

if (Z_TYPE_P(op1) != IS_STRING) {
zend_make_printable_zval(op1, &op1_copy, &use_copy1);
if (use_copy1) {
op1 = &op1_copy;
}
}

if (Z_TYPE_P(op2) != IS_STRING) {
zend_make_printable_zval(op2, &op2_copy, &use_copy2);
if (use_copy2) {
op2 = &op2_copy;
}
}

if (Z_TYPE_P(op3) != IS_STRING) {
zend_make_printable_zval(op3, &op3_copy, &use_copy3);
if (use_copy3) {
op3 = &op3_copy;
}
}

if (Z_TYPE_P(op5) != IS_STRING) {
zend_make_printable_zval(op5, &op5_copy, &use_copy5);
if (use_copy5) {
op5 = &op5_copy;
}
}

length = Z_STRLEN_P(op1) + Z_STRLEN_P(op2) + Z_STRLEN_P(op3) + op4_len + Z_STRLEN_P(op5);
if (self_var) {

if (Z_TYPE_PP(result) != IS_STRING) {
zend_make_printable_zval(*result, &result_copy, &use_copy);
if (use_copy) {
ZEPHIR_CPY_WRT_CTOR(*result, (&result_copy));
}
}

offset = Z_STRLEN_PP(result);
length += offset;
Z_STRVAL_PP(result) = (char *) str_erealloc(Z_STRVAL_PP(result), length + 1);

} else {
Z_STRVAL_PP(result) = (char *) emalloc(length + 1);
}

memcpy(Z_STRVAL_PP(result) + offset, Z_STRVAL_P(op1), Z_STRLEN_P(op1));
memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2));
memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + Z_STRLEN_P(op2), Z_STRVAL_P(op3), Z_STRLEN_P(op3));
memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + Z_STRLEN_P(op2) + Z_STRLEN_P(op3), op4, op4_len);
memcpy(Z_STRVAL_PP(result) + offset + Z_STRLEN_P(op1) + Z_STRLEN_P(op2) + Z_STRLEN_P(op3) + op4_len, Z_STRVAL_P(op5), Z_STRLEN_P(op5));
Z_STRVAL_PP(result)[length] = 0;
Z_TYPE_PP(result) = IS_STRING;
Z_STRLEN_PP(result) = length;

if (use_copy1) {
zval_dtor(op1);
}

if (use_copy2) {
zval_dtor(op2);
}

if (use_copy3) {
zval_dtor(op3);
}

if (use_copy5) {
zval_dtor(op5);
}

if (use_copy) {
zval_dtor(&result_copy);
}

}

void zephir_concat_vvvv(zval **result, zval *op1, zval *op2, zval *op3, zval *op4, int self_var TSRMLS_DC){

zval result_copy, op1_copy, op2_copy, op3_copy, op4_copy;
Expand Down
12 changes: 0 additions & 12 deletions ext/kernel/concat.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@
#define ZEPHIR_SCONCAT_VSVV(result, op1, op2, op3, op4) \
zephir_concat_vsvv(&result, op1, op2, sizeof(op2)-1, op3, op4, 1 TSRMLS_CC);

#define ZEPHIR_CONCAT_VSVVV(result, op1, op2, op3, op4, op5) \
zephir_concat_vsvvv(&result, op1, op2, sizeof(op2)-1, op3, op4, op5, 0 TSRMLS_CC);
#define ZEPHIR_SCONCAT_VSVVV(result, op1, op2, op3, op4, op5) \
zephir_concat_vsvvv(&result, op1, op2, sizeof(op2)-1, op3, op4, op5, 1 TSRMLS_CC);

#define ZEPHIR_CONCAT_VV(result, op1, op2) \
zephir_concat_vv(&result, op1, op2, 0 TSRMLS_CC);
#define ZEPHIR_SCONCAT_VV(result, op1, op2) \
Expand All @@ -132,11 +127,6 @@
#define ZEPHIR_SCONCAT_VVV(result, op1, op2, op3) \
zephir_concat_vvv(&result, op1, op2, op3, 1 TSRMLS_CC);

#define ZEPHIR_CONCAT_VVVSV(result, op1, op2, op3, op4, op5) \
zephir_concat_vvvsv(&result, op1, op2, op3, op4, sizeof(op4)-1, op5, 0 TSRMLS_CC);
#define ZEPHIR_SCONCAT_VVVSV(result, op1, op2, op3, op4, op5) \
zephir_concat_vvvsv(&result, op1, op2, op3, op4, sizeof(op4)-1, op5, 1 TSRMLS_CC);

#define ZEPHIR_CONCAT_VVVV(result, op1, op2, op3, op4) \
zephir_concat_vvvv(&result, op1, op2, op3, op4, 0 TSRMLS_CC);
#define ZEPHIR_SCONCAT_VVVV(result, op1, op2, op3, op4) \
Expand Down Expand Up @@ -173,12 +163,10 @@ void zephir_concat_vsvsv(zval **result, zval *op1, const char *op2, zend_uint op
void zephir_concat_vsvsvs(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, const char *op4, zend_uint op4_len, zval *op5, const char *op6, zend_uint op6_len, int self_var TSRMLS_DC);
void zephir_concat_vsvsvsv(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, const char *op4, zend_uint op4_len, zval *op5, const char *op6, zend_uint op6_len, zval *op7, int self_var TSRMLS_DC);
void zephir_concat_vsvv(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, zval *op4, int self_var TSRMLS_DC);
void zephir_concat_vsvvv(zval **result, zval *op1, const char *op2, zend_uint op2_len, zval *op3, zval *op4, zval *op5, int self_var TSRMLS_DC);
void zephir_concat_vv(zval **result, zval *op1, zval *op2, int self_var TSRMLS_DC);
void zephir_concat_vvs(zval **result, zval *op1, zval *op2, const char *op3, zend_uint op3_len, int self_var TSRMLS_DC);
void zephir_concat_vvsv(zval **result, zval *op1, zval *op2, const char *op3, zend_uint op3_len, zval *op4, int self_var TSRMLS_DC);
void zephir_concat_vvv(zval **result, zval *op1, zval *op2, zval *op3, int self_var TSRMLS_DC);
void zephir_concat_vvvsv(zval **result, zval *op1, zval *op2, zval *op3, const char *op4, zend_uint op4_len, zval *op5, int self_var TSRMLS_DC);
void zephir_concat_vvvv(zval **result, zval *op1, zval *op2, zval *op3, zval *op4, int self_var TSRMLS_DC);
void zephir_concat_vvvvsvv(zval **result, zval *op1, zval *op2, zval *op3, zval *op4, const char *op5, zend_uint op5_len, zval *op6, zval *op7, int self_var TSRMLS_DC);
void zephir_concat_vvvvv(zval **result, zval *op1, zval *op2, zval *op3, zval *op4, zval *op5, int self_var TSRMLS_DC);
Expand Down
2 changes: 1 addition & 1 deletion ext/kernel/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ typedef struct _zephir_function_cache {
#ifdef ZTS
#define zephir_nts_static
#else
#define zephir_nts_static
#define zephir_nts_static static
#endif
#else
#define zephir_nts_static
Expand Down
9 changes: 7 additions & 2 deletions ext/kernel/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int zephir_get_class_constant(zval *return_value, zend_class_entry *ce, char *co
}

/**
* Check if class is instance of
* Check if a zval is instance of a class returning its value in a zval
*/
int zephir_instance_of(zval *result, const zval *object, const zend_class_entry *ce TSRMLS_DC) {

Expand All @@ -68,6 +68,9 @@ int zephir_instance_of(zval *result, const zval *object, const zend_class_entry
return SUCCESS;
}

/**
* Check if a zval is instance of a class returning an integer
*/
int zephir_instance_of_ev(const zval *object, const zend_class_entry *ce TSRMLS_DC) {

if (Z_TYPE_P(object) != IS_OBJECT) {
Expand Down Expand Up @@ -101,6 +104,9 @@ int zephir_is_instance_of(zval *object, const char *class_name, unsigned int cla
return 0;
}

/**
* Checks if a zval is traversable
*/
int zephir_zval_is_traversable(zval *object TSRMLS_DC) {

zend_class_entry *ce;
Expand Down Expand Up @@ -1822,4 +1828,3 @@ int zephir_create_closure_ex(zval *return_value, zval *this_ptr, zend_class_entr
#endif
return SUCCESS;
}

4 changes: 2 additions & 2 deletions ext/phalcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ zend_class_entry *phalcon_validation_validatorinterface_ce;
zend_class_entry *phalcon_mvc_model_validatorinterface_ce;
zend_class_entry *phalcon_cache_backendinterface_ce;
zend_class_entry *phalcon_cache_frontendinterface_ce;
zend_class_entry *phalcon_db_dialectinterface_ce;
zend_class_entry *phalcon_dispatcherinterface_ce;
zend_class_entry *phalcon_mvc_model_metadatainterface_ce;
zend_class_entry *phalcon_annotations_adapterinterface_ce;
Expand All @@ -41,7 +42,6 @@ zend_class_entry *phalcon_logger_adapterinterface_ce;
zend_class_entry *phalcon_logger_formatterinterface_ce;
zend_class_entry *phalcon_mvc_model_resultsetinterface_ce;
zend_class_entry *phalcon_assets_filterinterface_ce;
zend_class_entry *phalcon_db_dialectinterface_ce;
zend_class_entry *phalcon_diinterface_ce;
zend_class_entry *phalcon_mvc_viewbaseinterface_ce;
zend_class_entry *phalcon_paginator_adapterinterface_ce;
Expand Down Expand Up @@ -393,6 +393,7 @@ static PHP_MINIT_FUNCTION(phalcon)
ZEPHIR_INIT(Phalcon_Mvc_Model_ValidatorInterface);
ZEPHIR_INIT(Phalcon_Cache_BackendInterface);
ZEPHIR_INIT(Phalcon_Cache_FrontendInterface);
ZEPHIR_INIT(Phalcon_Db_DialectInterface);
ZEPHIR_INIT(Phalcon_DispatcherInterface);
ZEPHIR_INIT(Phalcon_Mvc_Model_MetaDataInterface);
ZEPHIR_INIT(Phalcon_Annotations_AdapterInterface);
Expand All @@ -401,7 +402,6 @@ static PHP_MINIT_FUNCTION(phalcon)
ZEPHIR_INIT(Phalcon_Logger_FormatterInterface);
ZEPHIR_INIT(Phalcon_Mvc_Model_ResultsetInterface);
ZEPHIR_INIT(Phalcon_Assets_FilterInterface);
ZEPHIR_INIT(Phalcon_Db_DialectInterface);
ZEPHIR_INIT(Phalcon_DiInterface);
ZEPHIR_INIT(Phalcon_Mvc_ViewBaseInterface);
ZEPHIR_INIT(Phalcon_Paginator_AdapterInterface);
Expand Down
Loading

0 comments on commit 1dd968e

Please sign in to comment.