/** * Gets row in a specific position of the resultset * * @param int $index * @return Phalcon\Mvc\Model */ PHP_METHOD(Phalcon_Mvc_Model_Resultset, offsetGet){ zval *index = NULL, *count = NULL, *exists = NULL, *valid = NULL, *current = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &index) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_INIT_VAR(count); PHALCON_CALL_METHOD(count, this_ptr, "count", PH_NO_CHECK); PHALCON_INIT_VAR(exists); is_smaller_function(exists, index, count TSRMLS_CC); if (Z_TYPE_P(exists) == IS_BOOL && Z_BVAL_P(exists)) { PHALCON_CALL_METHOD_PARAMS_1_NORETURN(this_ptr, "seek", index, PH_NO_CHECK); PHALCON_INIT_VAR(valid); PHALCON_CALL_METHOD(valid, this_ptr, "valid", PH_NO_CHECK); if (Z_TYPE_P(valid) != IS_BOOL || (Z_TYPE_P(valid) == IS_BOOL && Z_BVAL_P(valid))) { PHALCON_INIT_VAR(current); PHALCON_CALL_METHOD(current, this_ptr, "current", PH_NO_CHECK); RETURN_CCTOR(current); } else { PHALCON_MM_RESTORE(); RETURN_FALSE; } } PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "The index does not exist in the cursor"); return; }
/** * Renders a view using the template engine * * @param string $path * @param array $params * @param bool $mustClean */ PHP_METHOD(Phalcon_Mvc_View_Engine_Php, render){ zval *path = NULL, *params = NULL, *must_clean = NULL, *value = NULL, *key = NULL, *contents = NULL; zval *view = NULL; HashTable *ah0; HashPosition hp0; zval **hd; char *hash_index; uint hash_index_len; ulong hash_num; int hash_type; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz", &path, ¶ms, &must_clean) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (Z_TYPE_P(must_clean) == IS_BOOL && Z_BVAL_P(must_clean)) { PHALCON_CALL_FUNC_NORETURN("ob_clean"); } if (!phalcon_valid_foreach(params TSRMLS_CC)) { return; } ah0 = Z_ARRVAL_P(params); zend_hash_internal_pointer_reset_ex(ah0, &hp0); fes_1897_0: if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){ goto fee_1897_0; } PHALCON_INIT_VAR(key); PHALCON_GET_FOREACH_KEY(key, ah0, hp0); PHALCON_INIT_VAR(value); ZVAL_ZVAL(value, *hd, 1, 0); if (phalcon_set_symbol(key, value TSRMLS_CC) == FAILURE){ return; } zend_hash_move_forward_ex(ah0, &hp0); goto fes_1897_0; fee_1897_0: if (phalcon_require(path TSRMLS_CC) == FAILURE) { return; } if (Z_TYPE_P(must_clean) == IS_BOOL && Z_BVAL_P(must_clean)) { PHALCON_INIT_VAR(contents); PHALCON_CALL_FUNC(contents, "ob_get_contents"); PHALCON_INIT_VAR(view); phalcon_read_property(&view, this_ptr, SL("_view"), PH_NOISY_CC); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(view, "setcontent", contents, PH_NO_CHECK); } PHALCON_MM_RESTORE(); }
static VALUE get(VALUE self, VALUE key) { zval **value; if(zend_hash_find(EG(active_symbol_table), StringValuePtr(key), RSTRING_LEN(key) + 1, (void **)&value) == SUCCESS) { switch(Z_TYPE_P(*value)) { case IS_NULL: return Qnil; break; case IS_BOOL: if(Z_BVAL_P(*value)) return Qtrue; else return Qfalse; break; case IS_LONG: return INT2NUM(Z_LVAL_P(*value)); break; case IS_DOUBLE: return rb_float_new(Z_DVAL_P(*value)); break; case IS_STRING: return rb_str_new(Z_STRVAL_P(*value), Z_STRLEN_P(*value)); break; default: rb_raise(rb_eRuntimeError, "Whoa, I don't know how to convert that"); } } return Qnil; }
/** * Phalcon\Mvc\Router constructor */ PHP_METHOD(Phalcon_Mvc_Router, __construct) { zval *routes, *_1$$3, *_4$$3; zephir_fcall_cache_entry *_3 = NULL; int ZEPHIR_LAST_CALL_STATUS; zval *defaultRoutes_param = NULL, *_6, *_7, *_0$$3, *_2$$3 = NULL, *_5$$3; zend_bool defaultRoutes; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &defaultRoutes_param); if (!defaultRoutes_param) { defaultRoutes = 1; } else { if (unlikely(Z_TYPE_P(defaultRoutes_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'defaultRoutes' must be a bool") TSRMLS_CC); RETURN_MM_NULL(); } defaultRoutes = Z_BVAL_P(defaultRoutes_param); } ZEPHIR_INIT_VAR(routes); array_init(routes); if (defaultRoutes) { ZEPHIR_INIT_VAR(_0$$3); object_init_ex(_0$$3, phalcon_mvc_router_route_ce); ZEPHIR_INIT_VAR(_1$$3); zephir_create_array(_1$$3, 1, 0 TSRMLS_CC); add_assoc_long_ex(_1$$3, SS("controller"), 1); ZEPHIR_INIT_VAR(_2$$3); ZVAL_STRING(_2$$3, "#^/([\\w0-9\\_\\-]+)[/]{0,1}$#u", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _0$$3, "__construct", &_3, 78, _2$$3, _1$$3); zephir_check_temp_parameter(_2$$3); zephir_check_call_status(); zephir_array_append(&routes, _0$$3, PH_SEPARATE, "phalcon/mvc/router.zep", 119); ZEPHIR_INIT_NVAR(_2$$3); object_init_ex(_2$$3, phalcon_mvc_router_route_ce); ZEPHIR_INIT_VAR(_4$$3); zephir_create_array(_4$$3, 3, 0 TSRMLS_CC); add_assoc_long_ex(_4$$3, SS("controller"), 1); add_assoc_long_ex(_4$$3, SS("action"), 2); add_assoc_long_ex(_4$$3, SS("params"), 3); ZEPHIR_INIT_VAR(_5$$3); ZVAL_STRING(_5$$3, "#^/([\\w0-9\\_\\-]+)/([\\w0-9\\.\\_]+)(/.*)*$#u", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(NULL, _2$$3, "__construct", &_3, 78, _5$$3, _4$$3); zephir_check_temp_parameter(_5$$3); zephir_check_call_status(); zephir_array_append(&routes, _2$$3, PH_SEPARATE, "phalcon/mvc/router.zep", 125); } ZEPHIR_INIT_VAR(_6); array_init(_6); zephir_update_property_this(this_ptr, SL("_params"), _6 TSRMLS_CC); ZEPHIR_INIT_VAR(_7); array_init(_7); zephir_update_property_this(this_ptr, SL("_defaultParams"), _7 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("_routes"), routes TSRMLS_CC); ZEPHIR_MM_RESTORE(); }
static lcb_cas_t cas_from_zval(zval *zv) { char casbuf[64] = { 0 }; char *endptr = NULL; lcb_cas_t ret = 0; /* convert the cas */ if (Z_TYPE_P(zv) == IS_NULL || (Z_TYPE_P(zv) == IS_LONG && Z_LVAL_P(zv) == 0) || (Z_TYPE_P(zv) == IS_BOOL && Z_BVAL_P(zv) == 0)) { /* invalid, but fals-ish */ return 0; } if (IS_STRING != Z_TYPE_P(zv) || Z_STRLEN_P(zv) > sizeof(casbuf)) { goto GT_ERR; } /* TODO: make this portable */ memcpy(casbuf, Z_STRVAL_P(zv), Z_STRLEN_P(zv)); ret = strtoull(casbuf, &endptr, 10); if (*endptr != '\0') { goto GT_ERR; } return ret; GT_ERR: php_error(E_RECOVERABLE_ERROR, "Invalid CAS Specified (must be a numeric string)"); return -1; }
/** * Rewinds resultset to its beginning * */ PHP_METHOD(Phalcon_Model_Resultset, rewind){ zval *result = NULL; zval *t0 = NULL, *t1 = NULL, *t2 = NULL; zval *c0 = NULL; PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, "_type", sizeof("_type")-1, PHALCON_NOISY TSRMLS_CC); if (zend_is_true(t0)) { PHALCON_ALLOC_ZVAL_MM(t1); phalcon_read_property(&t1, this_ptr, "_result", sizeof("_result")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(result, t1); if (Z_TYPE_P(result) != IS_BOOL || (Z_TYPE_P(result) == IS_BOOL && Z_BVAL_P(result))) { phalcon_update_property_long(this_ptr, "pointer", strlen("pointer"), 1 TSRMLS_CC); PHALCON_INIT_VAR(c0); ZVAL_LONG(c0, 0); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(result, "dataseek", c0, PHALCON_NO_CHECK); } } else { PHALCON_ALLOC_ZVAL_MM(t2); phalcon_read_property(&t2, this_ptr, "_rows", sizeof("_rows")-1, PHALCON_NOISY TSRMLS_CC); Z_SET_ISREF_P(t2); PHALCON_CALL_FUNC_PARAMS_1_NORETURN("reset", t2, 0x055); Z_UNSET_ISREF_P(t2); } PHALCON_MM_RESTORE(); }
/** * Gets row in a specific position of the resultset * * @param int $index * @return Phalcon_Model_Base */ PHP_METHOD(Phalcon_Model_Resultset, offsetGet){ zval *index = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &index) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_METHOD(r0, this_ptr, "count", PHALCON_NO_CHECK); PHALCON_INIT_VAR(r1); is_smaller_function(r1, index, r0 TSRMLS_CC); if (zend_is_true(r1)) { PHALCON_CALL_METHOD_PARAMS_1_NORETURN(this_ptr, "seek", index, PHALCON_NO_CHECK); PHALCON_ALLOC_ZVAL_MM(r2); PHALCON_CALL_METHOD(r2, this_ptr, "valid", PHALCON_NO_CHECK); if (Z_TYPE_P(r2) != IS_BOOL || (Z_TYPE_P(r2) == IS_BOOL && Z_BVAL_P(r2))) { PHALCON_ALLOC_ZVAL_MM(r3); PHALCON_CALL_METHOD(r3, this_ptr, "current", PHALCON_NO_CHECK); PHALCON_RETURN_DZVAL(r3); } else { PHALCON_MM_RESTORE(); RETURN_FALSE; } } PHALCON_THROW_EXCEPTION_STR(phalcon_model_exception_ce, "The index does not exist in the cursor"); return; }
/** * Get last row in the resultset * * @return Phalcon_Model_Base */ PHP_METHOD(Phalcon_Model_Resultset, getLast){ zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL; zval *t0 = NULL; PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_METHOD(r0, this_ptr, "count", PHALCON_NO_CHECK); PHALCON_INIT_VAR(t0); ZVAL_LONG(t0, 1); PHALCON_ALLOC_ZVAL_MM(r1); sub_function(r1, r0, t0 TSRMLS_CC); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(this_ptr, "seek", r1, PHALCON_NO_CHECK); PHALCON_ALLOC_ZVAL_MM(r2); PHALCON_CALL_METHOD(r2, this_ptr, "valid", PHALCON_NO_CHECK); if (Z_TYPE_P(r2) != IS_BOOL || (Z_TYPE_P(r2) == IS_BOOL && Z_BVAL_P(r2))) { PHALCON_ALLOC_ZVAL_MM(r3); PHALCON_CALL_METHOD(r3, this_ptr, "current", PHALCON_NO_CHECK); PHALCON_RETURN_DZVAL(r3); } PHALCON_MM_RESTORE(); RETURN_FALSE; }
/** * Serializing a resultset will dump all related rows into a big array * * @return string */ PHP_METHOD(Phalcon_Model_Resultset, serialize){ zval *records = NULL; zval *a0 = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL; PHALCON_MM_GROW(); PHALCON_INIT_VAR(a0); array_init(a0); PHALCON_CPY_WRT(records, a0); PHALCON_CALL_METHOD_NORETURN(this_ptr, "rewind", PHALCON_NO_CHECK); ws_fd08_1: PHALCON_INIT_VAR(r0); PHALCON_CALL_METHOD(r0, this_ptr, "valid", PHALCON_NO_CHECK); if (Z_TYPE_P(r0) != IS_BOOL || (Z_TYPE_P(r0) == IS_BOOL && !Z_BVAL_P(r0))) { goto we_fd08_1; } PHALCON_INIT_VAR(r1); PHALCON_CALL_METHOD(r1, this_ptr, "current", PHALCON_NO_CHECK); phalcon_array_append(&records, r1, PHALCON_SEPARATE_PLZ TSRMLS_CC); PHALCON_CALL_METHOD_NORETURN(this_ptr, "next", PHALCON_NO_CHECK); goto ws_fd08_1; we_fd08_1: PHALCON_ALLOC_ZVAL_MM(r2); PHALCON_CALL_FUNC_PARAMS_1(r2, "serialize", records, 0x057); PHALCON_RETURN_DZVAL(r2); }
/** * Phalcon\Mvc\Model\Resultset constructor * * @param Phalcon\Mvc\Model $model * @param Phalcon\Mvc\Model\Result $result * @param Phalcon\Cache\Backend $cache */ PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, __construct){ zval *model = NULL, *result = NULL, *cache = NULL; zval *c0 = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|z", &model, &result, &cache) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (!cache) { PHALCON_ALLOC_ZVAL_MM(cache); ZVAL_NULL(cache); } phalcon_update_property_zval(this_ptr, SL("_model"), model TSRMLS_CC); phalcon_update_property_zval(this_ptr, SL("_result"), result TSRMLS_CC); phalcon_update_property_zval(this_ptr, SL("_cache"), cache TSRMLS_CC); phalcon_update_property_long(this_ptr, SL("_type"), 1 TSRMLS_CC); if (Z_TYPE_P(result) != IS_BOOL || (Z_TYPE_P(result) == IS_BOOL && Z_BVAL_P(result))) { PHALCON_INIT_VAR(c0); ZVAL_LONG(c0, 1); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(result, "setfetchmode", c0, PH_NO_CHECK); } PHALCON_MM_RESTORE(); }
/** * Get last row in the resultset * * @return Phalcon\Mvc\Model */ PHP_METHOD(Phalcon_Mvc_Model_Resultset, getLast){ zval *count = NULL, *pre_count = NULL, *valid = NULL, *current = NULL; zval *t0 = NULL; PHALCON_MM_GROW(); PHALCON_INIT_VAR(count); PHALCON_CALL_METHOD(count, this_ptr, "count", PH_NO_CHECK); PHALCON_INIT_VAR(t0); ZVAL_LONG(t0, 1); PHALCON_INIT_VAR(pre_count); sub_function(pre_count, count, t0 TSRMLS_CC); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(this_ptr, "seek", pre_count, PH_NO_CHECK); PHALCON_INIT_VAR(valid); PHALCON_CALL_METHOD(valid, this_ptr, "valid", PH_NO_CHECK); if (Z_TYPE_P(valid) != IS_BOOL || (Z_TYPE_P(valid) == IS_BOOL && Z_BVAL_P(valid))) { PHALCON_INIT_VAR(current); PHALCON_CALL_METHOD(current, this_ptr, "current", PH_NO_CHECK); RETURN_CCTOR(current); } PHALCON_MM_RESTORE(); RETURN_FALSE; }
/** * Natural compare with long operandus on right */ int phalcon_compare_strict_long(zval *op1, long op2 TSRMLS_DC){ int bool_result; switch (Z_TYPE_P(op1)) { case IS_LONG: return Z_LVAL_P(op1) == op2; case IS_DOUBLE: return Z_LVAL_P(op1) == (double) op2; case IS_NULL: return 0 == op2; case IS_BOOL: if (Z_BVAL_P(op1)) { return 0 == op2; } else { return 1 == op2; } default: { zval result, op2_tmp; ZVAL_LONG(&op2_tmp, op2); is_equal_function(&result, op1, &op2_tmp TSRMLS_CC); bool_result = Z_BVAL(result); return bool_result; } } return 0; }
/** * Generates the SQL for LIMIT clause * * @param string $sqlQuery * @param int $number * @return string */ PHP_METHOD(Phalcon_Db_Dialect, limit){ zval *sql_query = NULL, *number = NULL, *is_numeric = NULL, *limit = NULL, *sql_limit = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &sql_query, &number) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } PHALCON_INIT_VAR(is_numeric); PHALCON_CALL_FUNC_PARAMS_1(is_numeric, "is_numeric", number); if (Z_TYPE_P(is_numeric) == IS_BOOL && Z_BVAL_P(is_numeric)) { PHALCON_INIT_VAR(limit); PHALCON_CALL_FUNC_PARAMS_1(limit, "intval", number); PHALCON_INIT_VAR(sql_limit); PHALCON_CONCAT_VSV(sql_limit, sql_query, " LIMIT ", limit); RETURN_CTOR(sql_limit); } RETURN_CCTOR(sql_query); }
/** * Rewinds resultset to its beginning * */ PHP_METHOD(Phalcon_Mvc_Model_Resultset, rewind){ zval *type = NULL, *result = NULL, *rows = NULL; zval *c0 = NULL; PHALCON_MM_GROW(); PHALCON_INIT_VAR(type); phalcon_read_property(&type, this_ptr, SL("_type"), PH_NOISY_CC); if (zend_is_true(type)) { PHALCON_INIT_VAR(result); phalcon_read_property(&result, this_ptr, SL("_result"), PH_NOISY_CC); if (Z_TYPE_P(result) != IS_BOOL || (Z_TYPE_P(result) == IS_BOOL && Z_BVAL_P(result))) { phalcon_update_property_long(this_ptr, SL("_pointer"), 1 TSRMLS_CC); PHALCON_INIT_VAR(c0); ZVAL_LONG(c0, 0); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(result, "dataseek", c0, PH_NO_CHECK); } } else { PHALCON_INIT_VAR(rows); phalcon_read_property(&rows, this_ptr, SL("_rows"), PH_NOISY_CC); Z_SET_ISREF_P(rows); PHALCON_CALL_FUNC_PARAMS_1_NORETURN("reset", rows); Z_UNSET_ISREF_P(rows); } PHALCON_MM_RESTORE(); }
bool protobuf_convert_to_bool(zval* from, int8_t* to) { switch (Z_TYPE_P(from)) { case IS_BOOL: *to = (int8_t)Z_BVAL_P(from); break; case IS_LONG: *to = (int8_t)(Z_LVAL_P(from) != 0); break; case IS_DOUBLE: *to = (int8_t)(Z_LVAL_P(from) != 0); break; case IS_STRING: { char* strval = Z_STRVAL_P(from); if (Z_STRLEN_P(from) == 0 || (Z_STRLEN_P(from) == 1 && Z_STRVAL_P(from)[0] == '0')) { *to = 0; } else { *to = 1; } } break; default: { zend_error(E_USER_ERROR, "Given value cannot be converted to bool."); return false; } } return true; }
/** * appid * appkey * fixout true:同一字符串密文任何时候均相同;false: 同一字符串不同时间密文输出不同 */ PHP_METHOD(Fox_MsgCrypt, __construct) { zend_bool fixout; zval *appid, *appkey, *fixout_param = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &appid, &appkey, &fixout_param); if (!fixout_param) { fixout = 0; } else { if (unlikely(Z_TYPE_P(fixout_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'fixout' must be a bool") TSRMLS_CC); RETURN_MM_NULL(); } fixout = Z_BVAL_P(fixout_param); } ZEPHIR_INIT_VAR(_0); zephir_md5(_0, appkey); zephir_update_property_this(this_ptr, SL("appkey"), _0 TSRMLS_CC); zephir_update_property_this(this_ptr, SL("appid"), appid TSRMLS_CC); if (fixout) { zephir_update_property_this(this_ptr, SL("fixout"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("fixout"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } ZEPHIR_MM_RESTORE(); }
static zend_bool s_invoke_device_cb (php_zmq_device_cb_t *cb, uint64_t current_ts TSRMLS_DC) { zend_bool retval = 0; zval **params[1]; zval *retval_ptr = NULL; params [0] = &cb->user_data; cb->fci.params = params; cb->fci.param_count = 1; /* Call the cb */ cb->fci.no_separation = 1; cb->fci.retval_ptr_ptr = &retval_ptr; if (zend_call_function(&(cb->fci), &(cb->fci_cache) TSRMLS_CC) == FAILURE) { if (!EG(exception)) { zend_throw_exception_ex(php_zmq_device_exception_sc_entry_get (), 0 TSRMLS_CC, "Failed to invoke callback %s()", Z_STRVAL_P(cb->fci.function_name)); } } if (retval_ptr) { convert_to_boolean(retval_ptr); if (Z_BVAL_P(retval_ptr)) { retval = 1; } zval_ptr_dtor(&retval_ptr); } cb->scheduled_at = current_ts + cb->timeout; return retval; }
/** * Assigns default values to generated tags by helpers * * <code> * //Assigning "peter" to "name" component * Phalcon\Tag::setDefault("name", "peter"); * * //Later in the view * echo Phalcon\Tag::textField("name"); //Will have the value "peter" by default * </code> * * @param string $id * @param string $value */ PHP_METHOD(Phalcon_Tag, setDefault){ zval *id = NULL, *value = NULL, *is_scalar = NULL; zval *t0 = NULL; PHALCON_MM_GROW(); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &id, &value) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } if (zend_is_true(value)) { PHALCON_INIT_VAR(is_scalar); PHALCON_CALL_FUNC_PARAMS_1(is_scalar, "is_scalar", value); if (Z_TYPE_P(is_scalar) == IS_BOOL && !Z_BVAL_P(is_scalar)) { PHALCON_THROW_EXCEPTION_STR(phalcon_tag_exception_ce, "Only scalar values can be assigned to UI components"); return; } } PHALCON_OBSERVE_VAR(t0); phalcon_read_static_property(&t0, SL("phalcon\\tag"), SL("_displayValues") TSRMLS_CC); if (Z_TYPE_P(t0) != IS_ARRAY) { convert_to_array(t0); } phalcon_array_update_zval(&t0, id, &value, PH_COPY TSRMLS_CC); phalcon_update_static_property(SL("phalcon\\tag"), SL("_displayValues"), t0 TSRMLS_CC); PHALCON_MM_RESTORE(); }
/** {{{ 获取是否出错,返回布尔值 */ PHP_METHOD(HyperMobile, getError) { /* 如果err_msg为空则返回false */ zval *self,*Error; self = getThis(); Error=zend_read_property(Z_OBJCE_P(self),self,ZEND_STRL("error"),0 TSRMLS_CC); RETURN_BOOL(Z_BVAL_P(Error)); //RETURN_FALSE; }
/** * Decrypt a text that is coded as a base64 string */ PHP_METHOD(Phalcon_Crypt, decryptBase64) { zephir_fcall_cache_entry *_6 = NULL; int ZEPHIR_LAST_CALL_STATUS; zephir_nts_static zephir_fcall_cache_entry *_3 = NULL, *_5 = NULL; zend_bool safe; zval *text_param = NULL, *key = NULL, *safe_param = NULL, _0, _1, *_2 = NULL, *_4 = NULL; zval *text = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &text_param, &key, &safe_param); if (unlikely(Z_TYPE_P(text_param) != IS_STRING && Z_TYPE_P(text_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'text' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(text_param) == IS_STRING)) { zephir_get_strval(text, text_param); } else { ZEPHIR_INIT_VAR(text); ZVAL_EMPTY_STRING(text); } if (!key) { key = ZEPHIR_GLOBAL(global_null); } if (!safe_param) { safe = 0; } else { if (unlikely(Z_TYPE_P(safe_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'safe' must be a bool") TSRMLS_CC); RETURN_MM_NULL(); } safe = Z_BVAL_P(safe_param); } if (safe == 1) { ZEPHIR_SINIT_VAR(_0); ZVAL_STRING(&_0, "-_", 0); ZEPHIR_SINIT_VAR(_1); ZVAL_STRING(&_1, "+/", 0); ZEPHIR_CALL_FUNCTION(&_2, "strtr", &_3, text, &_0, &_1); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_4, "base64_decode", &_5, _2); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "decrypt", &_6, _4, key); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_CALL_FUNCTION(&_2, "base64_decode", &_5, text); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "decrypt", &_6, _2, key); zephir_check_call_status(); RETURN_MM(); }
/** {{{ public ZeRecorder::fetch() */ PHP_METHOD(ze_recorder, fetch) { zval * self = NULL; zval * stmt = NULL; long style = 0; zval * style_z = NULL; zval * success = NULL; zval * row = NULL; /* PDO::FETCH_ASSOC */ style = 2; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l" , &style ) == FAILURE) { WRONG_PARAM_COUNT; } /* call execute */ /* call fetch */ self = getThis(); stmt = zend_read_property(ze_recorder_ce, self, ZEND_STRL(ZE_STMT), 0 TSRMLS_CC); do { if (!stmt || Z_TYPE_P(stmt) != IS_OBJECT) { ze_error(E_ERROR TSRMLS_CC, "recorder.fetch.stmt.not_object"); break; } zend_call_method(&stmt, Z_OBJCE_P(stmt), NULL, ZEND_STRL("execute"), &success, 0, NULL, NULL TSRMLS_CC); if (!success || EG(exception)) { zval_dtor(success); FREE_ZVAL(success); break; } convert_to_boolean(success); if (Z_BVAL_P(success) == 1) { ALLOC_INIT_ZVAL(style_z); ZVAL_LONG(style_z, style); zend_call_method(&stmt, NULL, NULL, ZEND_STRL("fetch"), &row, 1, style_z, NULL TSRMLS_CC); zval_dtor(style_z); FREE_ZVAL(style_z); } zval_dtor(success); FREE_ZVAL(success); } while (0); if (row) { RETURN_ZVAL(row, 1, 1); } else { RETURN_FALSE; } }
/** * Encrypts a text returning the result as a base64 string */ PHP_METHOD(Phalcon_Crypt, encryptBase64) { zephir_fcall_cache_entry *_1 = NULL, *_3 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zend_bool safe; zval *text_param = NULL, *key = NULL, *safe_param = NULL, *_0$$3 = NULL, *_2$$3 = NULL, _4$$3 = zval_used_for_init, _5$$3, *_6$$3 = NULL, *_7 = NULL; zval *text = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &text_param, &key, &safe_param); if (UNEXPECTED(Z_TYPE_P(text_param) != IS_STRING && Z_TYPE_P(text_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'text' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(text_param) == IS_STRING)) { zephir_get_strval(text, text_param); } else { ZEPHIR_INIT_VAR(text); ZVAL_EMPTY_STRING(text); } if (!key) { key = ZEPHIR_GLOBAL(global_null); } if (!safe_param) { safe = 0; } else { if (UNEXPECTED(Z_TYPE_P(safe_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'safe' must be a bool") TSRMLS_CC); RETURN_MM_NULL(); } safe = Z_BVAL_P(safe_param); } if (safe == 1) { ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "encrypt", &_1, 0, text, key); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_2$$3, "base64_encode", &_3, 132, _0$$3); zephir_check_call_status(); ZEPHIR_SINIT_VAR(_4$$3); ZVAL_STRING(&_4$$3, "+/", 0); ZEPHIR_SINIT_VAR(_5$$3); ZVAL_STRING(&_5$$3, "-_", 0); ZEPHIR_CALL_FUNCTION(&_6$$3, "strtr", NULL, 27, _2$$3, &_4$$3, &_5$$3); zephir_check_call_status(); ZEPHIR_SINIT_NVAR(_4$$3); ZVAL_STRING(&_4$$3, "=", 0); zephir_fast_trim(return_value, _6$$3, &_4$$3, ZEPHIR_TRIM_RIGHT TSRMLS_CC); RETURN_MM(); } ZEPHIR_CALL_METHOD(&_7, this_ptr, "encrypt", &_1, 0, text, key); zephir_check_call_status(); ZEPHIR_RETURN_CALL_FUNCTION("base64_encode", &_3, 132, _7); zephir_check_call_status(); RETURN_MM(); }
/** * Check whether internal resource has rows to fetch * * @return boolean */ PHP_METHOD(Phalcon_Model_Resultset, valid){ zval *result = NULL, *row = NULL, *rows = NULL; zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL; zval *c0 = NULL, *c1 = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL; PHALCON_MM_GROW(); PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, "_type", sizeof("_type")-1, PHALCON_NOISY TSRMLS_CC); if (zend_is_true(t0)) { PHALCON_ALLOC_ZVAL_MM(t1); phalcon_read_property(&t1, this_ptr, "_result", sizeof("_result")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(result, t1); if (Z_TYPE_P(result) != IS_BOOL || (Z_TYPE_P(result) == IS_BOOL && Z_BVAL_P(result))) { PHALCON_INIT_VAR(c0); ZVAL_LONG(c0, 1); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(result, "setfetchmode", c0, PHALCON_NO_CHECK); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_METHOD_PARAMS_1(r0, result, "fetcharray", result, PHALCON_NO_CHECK); PHALCON_CPY_WRT(row, r0); if (zend_is_true(row)) { PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_ALLOC_ZVAL_MM(t2); phalcon_read_property(&t2, this_ptr, "_model", sizeof("_model")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_STATIC_PARAMS_2(r1, "phalcon_model_base", "dumpresult", t2, row); phalcon_update_property_zval(this_ptr, "_activeRow", strlen("_activeRow"), r1 TSRMLS_CC); PHALCON_MM_RESTORE(); RETURN_TRUE; } else { PHALCON_INIT_VAR(c1); ZVAL_LONG(c1, 2); PHALCON_CALL_METHOD_PARAMS_1_NORETURN(result, "setfetchmode", c1, PHALCON_NO_CHECK); } } } else { PHALCON_ALLOC_ZVAL_MM(t3); phalcon_read_property(&t3, this_ptr, "_rows", sizeof("_rows")-1, PHALCON_NOISY TSRMLS_CC); PHALCON_CPY_WRT(rows, t3); PHALCON_ALLOC_ZVAL_MM(r2); Z_SET_ISREF_P(rows); PHALCON_CALL_FUNC_PARAMS_1(r2, "current", rows, 0x054); Z_UNSET_ISREF_P(rows); PHALCON_CPY_WRT(row, r2); if (zend_is_true(row)) { Z_SET_ISREF_P(rows); PHALCON_CALL_FUNC_PARAMS_1_NORETURN("next", rows, 0x059); Z_UNSET_ISREF_P(rows); phalcon_update_property_zval(this_ptr, "_activeRow", strlen("_activeRow"), row TSRMLS_CC); PHALCON_MM_RESTORE(); RETURN_TRUE; } } PHALCON_MM_RESTORE(); RETURN_FALSE; }
/** * Check whether internal resource has rows to fetch * * @return boolean */ PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, valid){ zval *type = NULL, *result = NULL, *row = NULL, *model = NULL, *active_row = NULL, *rows = NULL; PHALCON_MM_GROW(); PHALCON_INIT_VAR(type); phalcon_read_property(&type, this_ptr, SL("_type"), PH_NOISY_CC); if (zend_is_true(type)) { PHALCON_INIT_VAR(result); phalcon_read_property(&result, this_ptr, SL("_result"), PH_NOISY_CC); if (Z_TYPE_P(result) != IS_BOOL || (Z_TYPE_P(result) == IS_BOOL && Z_BVAL_P(result))) { PHALCON_INIT_VAR(row); PHALCON_CALL_METHOD_PARAMS_1(row, result, "fetcharray", result, PH_NO_CHECK); if (Z_TYPE_P(row) != IS_BOOL || (Z_TYPE_P(row) == IS_BOOL && Z_BVAL_P(row))) { PHALCON_INIT_VAR(model); phalcon_read_property(&model, this_ptr, SL("_model"), PH_NOISY_CC); PHALCON_INIT_VAR(active_row); PHALCON_CALL_STATIC_PARAMS_2(active_row, "phalcon\\mvc\\model", "dumpresult", model, row); phalcon_update_property_zval(this_ptr, SL("_activeRow"), active_row TSRMLS_CC); PHALCON_MM_RESTORE(); RETURN_TRUE; } } } else { PHALCON_INIT_VAR(rows); phalcon_read_property(&rows, this_ptr, SL("_rows"), PH_NOISY_CC); Z_SET_ISREF_P(rows); PHALCON_INIT_VAR(row); PHALCON_CALL_FUNC_PARAMS_1(row, "current", rows); Z_UNSET_ISREF_P(rows); if (zend_is_true(row)) { Z_SET_ISREF_P(rows); PHALCON_CALL_FUNC_PARAMS_1_NORETURN("next", rows); Z_UNSET_ISREF_P(rows); phalcon_update_property_zval(this_ptr, SL("_activeRow"), row TSRMLS_CC); PHALCON_MM_RESTORE(); RETURN_TRUE; } } PHALCON_MM_RESTORE(); RETURN_FALSE; }
/* {{{ MongoCursor::getNext */ PHP_METHOD(MongoCursor, getNext) { MONGO_METHOD(MongoCursor, next, return_value, getThis()); // will be null unless there was an error if (EG(exception) || (Z_TYPE_P(return_value) == IS_BOOL && Z_BVAL_P(return_value) == 0)) { return; } MONGO_METHOD(MongoCursor, current, return_value, getThis()); }
/* {{{ MongoCursor::getNext */ PHP_METHOD(MongoCursor, getNext) { MONGO_METHOD(MongoCursor, next)(INTERNAL_FUNCTION_PARAM_PASSTHRU); // will be null unless there was an error if (Z_TYPE_P(return_value) == IS_BOOL && Z_BVAL_P(return_value) == 0) { return; } MONGO_METHOD(MongoCursor, current)(INTERNAL_FUNCTION_PARAM_PASSTHRU); }
inline int SW_Z_TYPE_P(zval *z){ if(Z_TYPE_P(z)==IS_BOOL){ if((uint8_t) Z_BVAL_P(z)==1){ return IS_TRUE; }else{ return 0; } }else{ return Z_TYPE_P(z); } }
/** * Generates SQL to drop a view */ PHP_METHOD(Phalcon_Db_Dialect_Sqlite, dropView) { zend_bool ifExists; zval *viewName_param = NULL, *schemaName_param = NULL, *ifExists_param = NULL, *sql, *view = NULL; zval *viewName = NULL, *schemaName = NULL, *_0; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 2, &viewName_param, &schemaName_param, &ifExists_param); if (unlikely(Z_TYPE_P(viewName_param) != IS_STRING && Z_TYPE_P(viewName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'viewName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(viewName_param) == IS_STRING)) { zephir_get_strval(viewName, viewName_param); } else { ZEPHIR_INIT_VAR(viewName); ZVAL_EMPTY_STRING(viewName); } if (!schemaName_param) { ZEPHIR_INIT_VAR(schemaName); ZVAL_EMPTY_STRING(schemaName); } else { zephir_get_strval(schemaName, schemaName_param); } if (!ifExists_param) { ifExists = 1; } else { if (unlikely(Z_TYPE_P(ifExists_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'ifExists' must be a bool") TSRMLS_CC); RETURN_MM_NULL(); } ifExists = Z_BVAL_P(ifExists_param); } if (schemaName && Z_STRLEN_P(schemaName)) { ZEPHIR_INIT_VAR(_0); ZEPHIR_CONCAT_VSV(_0, schemaName, "\".\"", viewName); ZEPHIR_CPY_WRT(view, _0); } else { ZEPHIR_CPY_WRT(view, viewName); } ZEPHIR_INIT_VAR(sql); if (ifExists) { ZEPHIR_CONCAT_SVS(sql, "DROP VIEW IF EXISTS \"", view, "\""); } else { ZEPHIR_CONCAT_SVS(sql, "DROP VIEW \"", view, "\""); } RETURN_CCTOR(sql); }
/** * Constructor. * * @param int defaultTtl */ PHP_METHOD(Xpl_Cache_Item, __construct) { int expiry, defaultTtl; zend_bool hit; zval *key_param = NULL, *hit_param = NULL, *value, *expiry_param = NULL, *defaultTtl_param = NULL, *_0; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 2, &key_param, &hit_param, &value, &expiry_param, &defaultTtl_param); if (unlikely(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } if (unlikely(Z_TYPE_P(hit_param) != IS_BOOL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'hit' must be a bool") TSRMLS_CC); RETURN_MM_NULL(); } hit = Z_BVAL_P(hit_param); if (!expiry_param) { expiry = 0; } else { expiry = zephir_get_intval(expiry_param); } if (!defaultTtl_param) { defaultTtl = 0; } else { defaultTtl = zephir_get_intval(defaultTtl_param); } zephir_update_property_this(this_ptr, SL("key"), key TSRMLS_CC); if (hit) { zephir_update_property_this(this_ptr, SL("hit"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC); } else { zephir_update_property_this(this_ptr, SL("hit"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC); } zephir_update_property_this(this_ptr, SL("value"), value TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, expiry); zephir_update_property_this(this_ptr, SL("expires"), _0 TSRMLS_CC); ZEPHIR_INIT_ZVAL_NREF(_0); ZVAL_LONG(_0, defaultTtl); zephir_update_property_this(this_ptr, SL("defaultTtl"), _0 TSRMLS_CC); ZEPHIR_MM_RESTORE(); }
PHP_METHOD(Phalcon_Internal_TestTemp, e15){ zval *a = NULL; PHALCON_MM_GROW(); PHALCON_INIT_VAR(a); ZVAL_BOOL(a, 1); if (Z_TYPE_P(a) != IS_BOOL || (Z_TYPE_P(a) == IS_BOOL && Z_BVAL_P(a))) { php_printf("%ld", (long int) 1); } PHALCON_MM_RESTORE(); }