您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ zend_is_true函数代码示例

51自学网 2021-06-03 11:57:08
  C++
这篇教程C++ zend_is_true函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中zend_is_true函数的典型用法代码示例。如果您正苦于以下问题:C++ zend_is_true函数的具体用法?C++ zend_is_true怎么用?C++ zend_is_true使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了zend_is_true函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: PHP_METHOD

/** * Stores cached content into the APC backend and stops the frontend * * @param string $keyName * @param string $content * @param long $lifetime * @param boolean $stopBuffer */PHP_METHOD(Phalcon_Cache_Backend_Apc, save) {    zval *key_name = NULL, *content = NULL, *lifetime = NULL, *stop_buffer = NULL;    zval *last_key = NULL, *prefix, *frontend, *cached_content = NULL;    zval *prepared_content, *ttl = NULL, *is_buffering;    PHALCON_MM_GROW();    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|zzzz", &key_name, &content, &lifetime, &stop_buffer) == FAILURE) {        RETURN_MM_NULL();    }    if (!key_name) {        PHALCON_INIT_VAR(key_name);    }    if (!content) {        PHALCON_INIT_VAR(content);    }    if (!lifetime) {        PHALCON_INIT_VAR(lifetime);    }    if (!stop_buffer) {        PHALCON_INIT_VAR(stop_buffer);        ZVAL_BOOL(stop_buffer, 1);    }    if (Z_TYPE_P(key_name) == IS_NULL) {        PHALCON_OBS_VAR(last_key);        phalcon_read_property_this(&last_key, this_ptr, SL("_lastKey"), PH_NOISY_CC);    } else {        PHALCON_OBS_VAR(prefix);        phalcon_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC);        PHALCON_INIT_NVAR(last_key);        PHALCON_CONCAT_SVV(last_key, "_PHCA", prefix, key_name);    }    if (!zend_is_true(last_key)) {        PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "The cache must be started first");        return;    }    PHALCON_OBS_VAR(frontend);    phalcon_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC);    if (Z_TYPE_P(content) == IS_NULL) {        PHALCON_INIT_VAR(cached_content);        PHALCON_CALL_METHOD(cached_content, frontend, "getcontent");    } else {        PHALCON_CPY_WRT(cached_content, content);    }    PHALCON_INIT_VAR(prepared_content);    PHALCON_CALL_METHOD_PARAMS_1(prepared_content, frontend, "beforestore", cached_content);    if (Z_TYPE_P(lifetime) == IS_NULL) {        PHALCON_INIT_VAR(ttl);        PHALCON_CALL_METHOD(ttl, frontend, "getlifetime");    } else {        PHALCON_CPY_WRT(ttl, lifetime);    }    PHALCON_CALL_FUNC_PARAMS_3_NORETURN("apc_store", last_key, prepared_content, ttl);    PHALCON_INIT_VAR(is_buffering);    PHALCON_CALL_METHOD(is_buffering, frontend, "isbuffering");    if (PHALCON_IS_TRUE(stop_buffer)) {        PHALCON_CALL_METHOD_NORETURN(frontend, "stop");    }    if (PHALCON_IS_TRUE(is_buffering)) {        zend_print_zval(cached_content, 0);    }    phalcon_update_property_bool(this_ptr, SL("_started"), 0 TSRMLS_CC);    PHALCON_MM_RESTORE();}
开发者ID:vguardiola,项目名称:cphalcon,代码行数:86,


示例2: PHP_METHOD

/** * Stores cached content into the Memcached backend and stops the frontend * * @param int|string $keyName * @param string $content * @param long $lifetime * @param boolean $stopBuffer */PHP_METHOD(Phalcon_Cache_Backend_Memcache, save){	zval *key_name = NULL, *content = NULL, *lifetime = NULL, *stop_buffer = NULL, last_key = {}, prefix = {}, cached_content = {}, prepared_content = {}, ttl = {}, flags = {}, success = {};	zval keys = {}, is_buffering = {}, frontend = {}, memcache = {}, options = {}, special_key = {};	phalcon_fetch_params(0, 0, 4, &key_name, &content, &lifetime, &stop_buffer);	if (!key_name || Z_TYPE_P(key_name) == IS_NULL) {		phalcon_return_property(&last_key, getThis(), SL("_lastKey"));	} else {		phalcon_return_property(&prefix, getThis(), SL("_prefix"));		PHALCON_CONCAT_VV(&last_key, &prefix, key_name);	}	if (!zend_is_true(&last_key)) {		PHALCON_THROW_EXCEPTION_STRW(phalcon_cache_exception_ce, "The cache must be started first");		return;	}	phalcon_return_property(&frontend, getThis(), SL("_frontend"));	/** 	 * Check if a connection is created or make a new one	 */	phalcon_return_property(&memcache, getThis(), SL("_memcache"));	if (Z_TYPE(memcache) != IS_OBJECT) {		PHALCON_CALL_METHODW(&memcache, getThis(), "_connect");	}	if (!content || Z_TYPE_P(content) == IS_NULL) {		PHALCON_CALL_METHODW(&cached_content, &frontend, "getcontent");	} else {		PHALCON_CPY_WRT(&cached_content, content);	}	/** 	 * Prepare the content in the frontend	 */	PHALCON_CALL_METHODW(&prepared_content, &frontend, "beforestore", &cached_content);	if (!lifetime || Z_TYPE_P(lifetime) == IS_NULL) {		phalcon_return_property(&ttl, getThis(), SL("_lastLifetime"));		if (Z_TYPE(ttl) == IS_NULL) {			PHALCON_CALL_METHODW(&ttl, &frontend, "getlifetime");		}	} else {		PHALCON_CPY_WRT(&ttl, lifetime);	}	ZVAL_LONG(&flags, 0);	/** 	 * We store without flags	 */	if (phalcon_is_numeric(&cached_content)) {		PHALCON_CALL_METHODW(&success, &memcache, "set", &last_key, &cached_content, &flags, &ttl);	} else {		PHALCON_CALL_METHODW(&success, &memcache, "set", &last_key, &prepared_content, &flags, &ttl);	}	if (!zend_is_true(&success)) {		PHALCON_THROW_EXCEPTION_STRW(phalcon_cache_exception_ce, "Failed to store data in memcached");		return;	}	phalcon_return_property(&options, getThis(), SL("_options"));	if (unlikely(!phalcon_array_isset_fetch_str(&special_key, &options, SL("statsKey")))) {		PHALCON_THROW_EXCEPTION_STRW(phalcon_cache_exception_ce, "Unexpected inconsistency in options");		return;	}	if (Z_TYPE(special_key) != IS_NULL) {		/* Update the stats key */		PHALCON_CALL_METHODW(&keys, &memcache, "get", &special_key);		if (Z_TYPE(keys) != IS_ARRAY) {			array_init(&keys);		}		if (!phalcon_array_isset(&keys, &last_key)) {			phalcon_array_update_zval(&keys, &last_key, &ttl, PH_COPY);			PHALCON_CALL_METHODW(NULL, &memcache, "set", &special_key, &keys);		}	}	PHALCON_CALL_METHODW(&is_buffering, &frontend, "isbuffering");	if (!stop_buffer || PHALCON_IS_TRUE(stop_buffer)) {		PHALCON_CALL_METHODW(NULL, &frontend, "stop");	}//.........这里部分代码省略.........
开发者ID:googlle,项目名称:cphalcon7,代码行数:101,


示例3: PHP_METHOD

/** * Generates a URL * *<code> * * //Generate a URL appending the URI to the base URI * echo $url->get('products/edit/1'); * * //Generate a URL for a predefined route * echo $url->get(array('for' => 'blog-post', 'title' => 'some-cool-stuff', 'year' => '2012')); * echo $url->get(array('for' => 'blog-post', 'hostname' => true, 'title' => 'some-cool-stuff', 'year' => '2012')); * *</code> * * @param string|array $uri * @param array|object args Optional arguments to be appended to the query string * @param bool|null $local * @return string */PHP_METHOD(Phalcon_Mvc_Url, get){	zval *uri = NULL, *args = NULL, *local = NULL, *base_uri = NULL, *router = NULL, *dependency_injector;	zval *service, *route_name, *hostname, *route = NULL, *exception_message;	zval *pattern = NULL, *paths = NULL, *processed_uri = NULL, *query_string;	zval *matched, *regexp;	zval *generator = NULL, *arguments;	PHALCON_MM_GROW();	phalcon_fetch_params(1, 0, 3, &uri, &args, &local);	if (!uri) {		uri = &PHALCON_GLOBAL(z_null);	}	if (!args) {		args = &PHALCON_GLOBAL(z_null);	}	if (!local) {		local = &PHALCON_GLOBAL(z_null);	} else {		PHALCON_SEPARATE_PARAM(local);	}	PHALCON_CALL_METHOD(&base_uri, getThis(), "getbaseuri");	if (Z_TYPE_P(uri) == IS_STRING) {		if (strstr(Z_STRVAL_P(uri), ":")) {			PHALCON_INIT_VAR(matched);			PHALCON_INIT_VAR(regexp);			ZVAL_STRING(regexp, "/^[^:///?#]++:/");			RETURN_MM_ON_FAILURE(phalcon_preg_match(matched, regexp, uri, NULL));			if (zend_is_true(matched)) {				PHALCON_INIT_NVAR(local);				ZVAL_FALSE(local);			}		}		if (Z_TYPE_P(local) == IS_NULL || zend_is_true(local)) {			PHALCON_CONCAT_VV(return_value, base_uri, uri);		} else {			ZVAL_ZVAL(return_value, uri, 1, 0);		}	} else if (Z_TYPE_P(uri) == IS_ARRAY) {		if (!phalcon_array_isset_str_fetch(&route_name, uri, SL("for"))) {			PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_url_exception_ce, "It's necessary to define the route name with the parameter /"for/"");			return;		}		router = phalcon_read_property(getThis(), SL("_router"), PH_NOISY);		/**		 * Check if the router has not previously set		 */		if (Z_TYPE_P(router) != IS_OBJECT) {			dependency_injector = phalcon_read_property(getThis(), SL("_dependencyInjector"), PH_NOISY);			if (!zend_is_true(dependency_injector)) {				PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_url_exception_ce, "A dependency injector container is required to obtain the /"url/" service");				return;			}			PHALCON_INIT_VAR(service);			ZVAL_STR(service, IS(router));			router = NULL;			PHALCON_CALL_METHOD(&router, dependency_injector, "getshared", service);			PHALCON_VERIFY_INTERFACE(router, phalcon_mvc_routerinterface_ce);			phalcon_update_property_this(getThis(), SL("_router"), router);		}		/**		 * Every route is uniquely identified by a name		 */		PHALCON_CALL_METHOD(&route, router, "getroutebyname", route_name);		if (Z_TYPE_P(route) != IS_OBJECT) {			PHALCON_INIT_VAR(exception_message);			PHALCON_CONCAT_SVS(exception_message, "Cannot obtain a route using the name /"", route_name, "/"");			PHALCON_THROW_EXCEPTION_ZVAL(phalcon_mvc_url_exception_ce, exception_message);			return;//.........这里部分代码省略.........
开发者ID:Myleft,项目名称:cphalcon7,代码行数:101,


示例4: PHP_METHOD

/** * Dispatches a controller action taking into account the routing parameters * * @param Phalcon_Request $request * @param Phalcon_Response $response * @param Phalcon_View $view * @param Phalcon_Model_Manager $model * @return Phalcon_Controller */PHP_METHOD(Phalcon_Dispatcher, dispatch){	zval *request = NULL, *response = NULL, *view = NULL, *model = NULL, *controllers_dir = NULL;	zval *value = NULL, *controller = NULL, *number_dispatches = NULL;	zval *controller_name = NULL, *controllers = NULL, *controller_class = NULL;	zval *controller_path = NULL, *params = NULL, *action_name = NULL;	zval *action_method = NULL;	zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL;	zval *r7 = NULL, *r8 = NULL, *r9 = NULL, *r10 = NULL, *r11 = NULL, *r12 = NULL, *r13 = NULL;	zval *r14 = NULL;	zval *t0 = NULL, *t1 = NULL, *t2 = NULL, *t3 = NULL, *t4 = NULL, *t5 = NULL, *t6 = NULL;	zval *t7 = NULL, *t8 = NULL, *t9 = NULL, *t10 = NULL;	zval *c0 = NULL, *c1 = NULL, *c2 = NULL;	zval *i0 = NULL;	zval *a0 = NULL, *a1 = NULL;	zval *p5[] = { NULL, NULL, NULL, NULL, NULL };	int eval_int;	zend_class_entry *ce0;	PHALCON_MM_GROW();		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|zz", &request, &response, &view, &model) == FAILURE) {		PHALCON_MM_RESTORE();		RETURN_NULL();	}	if (!view) {		PHALCON_INIT_VAR(view);		ZVAL_NULL(view);	}		if (!model) {		PHALCON_INIT_VAR(model);		ZVAL_NULL(model);	}		PHALCON_ALLOC_ZVAL_MM(r0);	PHALCON_ALLOC_ZVAL_MM(t0);	phalcon_read_property(&t0, this_ptr, "_basePath", sizeof("_basePath")-1, PHALCON_NOISY TSRMLS_CC);	PHALCON_ALLOC_ZVAL_MM(t1);	phalcon_read_property(&t1, this_ptr, "_controllersDir", sizeof("_controllersDir")-1, PHALCON_NOISY TSRMLS_CC);	PHALCON_CONCAT_VV(r0, t0, t1);	PHALCON_CPY_WRT(controllers_dir, r0);		PHALCON_INIT_VAR(value);	ZVAL_NULL(value);		PHALCON_INIT_VAR(controller);	ZVAL_NULL(controller);		PHALCON_INIT_VAR(number_dispatches);	ZVAL_LONG(number_dispatches, 0);	phalcon_update_property_bool(this_ptr, "_finished", strlen("_finished"), 0 TSRMLS_CC);	ws_e10f_0:				PHALCON_INIT_VAR(t2);		phalcon_read_property(&t2, this_ptr, "_finished", sizeof("_finished")-1, PHALCON_NOISY TSRMLS_CC);		if (zend_is_true(t2)) {			goto we_e10f_0;		}		phalcon_update_property_bool(this_ptr, "_finished", strlen("_finished"), 1 TSRMLS_CC);				PHALCON_INIT_VAR(t3);		phalcon_read_property(&t3, this_ptr, "_controllerName", sizeof("_controllerName")-1, PHALCON_NOISY TSRMLS_CC);		PHALCON_CPY_WRT(controller_name, t3);		if (!zend_is_true(controller_name)) {			PHALCON_INIT_VAR(t4);			phalcon_read_property(&t4, this_ptr, "_defaultController", sizeof("_defaultController")-1, PHALCON_NOISY TSRMLS_CC);			PHALCON_CPY_WRT(controller_name, t4);			phalcon_update_property_zval(this_ptr, "_controllerName", strlen("_controllerName"), controller_name TSRMLS_CC);		}				PHALCON_INIT_VAR(t5);		phalcon_read_property(&t5, this_ptr, "_controllers", sizeof("_controllers")-1, PHALCON_NOISY TSRMLS_CC);		PHALCON_CPY_WRT(controllers, t5);				PHALCON_INIT_VAR(r1);				PHALCON_INIT_VAR(r2);		PHALCON_CALL_STATIC_PARAMS_1(r2, "phalcon_text", "camelize", controller_name);		PHALCON_CONCAT_VS(r1, r2, "Controller");		PHALCON_CPY_WRT(controller_class, r1);		eval_int = phalcon_array_isset(controllers, controller_class);		if (!eval_int) {			PHALCON_INIT_VAR(r3);			PHALCON_INIT_VAR(c0);			ZVAL_BOOL(c0, 0);			PHALCON_CALL_FUNC_PARAMS_2(r3, "class_exists", controller_class, c0, 0x012);			if (!zend_is_true(r3)) {				PHALCON_INIT_VAR(r4);				PHALCON_CONCAT_VVS(r4, controllers_dir, controller_class, ".php");//.........这里部分代码省略.........
开发者ID:andresgutierrez,项目名称:cphalcon,代码行数:101,


示例5: PHP_METHOD

/** * Handles a MVC request * * @param string $uri * @return Phalcon/Http/ResponseInterface */PHP_METHOD(Phalcon_Mvc_Application, handle){	zval *uri = NULL, *dependency_injector, *events_manager;	zval *event_name = NULL, *status = NULL, *service = NULL, *router, *module_name = NULL;	zval *module_object = NULL, *modules, *exception_msg = NULL;	zval *module, *class_name = NULL, *path, *module_params;	zval *implicit_view, *view, *namespace_name;	zval *controller_name = NULL, *action_name = NULL, *params = NULL;	zval *dispatcher, *controller, *returned_response = NULL;	zval *possible_response, *render_status = NULL, *response = NULL;	zval *content;	PHALCON_MM_GROW();	phalcon_fetch_params(1, 0, 1, &uri);		if (!uri) {		PHALCON_INIT_VAR(uri);	}		PHALCON_OBS_VAR(dependency_injector);	phalcon_read_property_this(&dependency_injector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC);	if (Z_TYPE_P(dependency_injector) != IS_OBJECT) {		PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_application_exception_ce, "A dependency injection object is required to access internal services");		return;	}		PHALCON_OBS_VAR(events_manager);	phalcon_read_property_this(&events_manager, this_ptr, SL("_eventsManager"), PH_NOISY_CC);		/** 	 * Call boot event, this allow the developer to perform initialization actions	 */	if (Z_TYPE_P(events_manager) == IS_OBJECT) {			PHALCON_INIT_VAR(event_name);		ZVAL_STRING(event_name, "application:boot", 1);			PHALCON_INIT_VAR(status);		phalcon_call_method_p2(status, events_manager, "fire", event_name, this_ptr);		if (PHALCON_IS_FALSE(status)) {			RETURN_MM_FALSE;		}	}		PHALCON_INIT_VAR(service);	ZVAL_STRING(service, "router", 1);		PHALCON_INIT_VAR(router);	phalcon_call_method_p1(router, dependency_injector, "getshared", service);		/** 	 * Handle the URI pattern (if any)	 */	phalcon_call_method_p1_noret(router, "handle", uri);		/** 	 * Load module config	 */	PHALCON_INIT_VAR(module_name);	phalcon_call_method(module_name, router, "getmodulename");		/** 	 * If the router doesn't return a valid module we use the default module	 */	if (!zend_is_true(module_name)) {		PHALCON_OBS_NVAR(module_name);		phalcon_read_property_this(&module_name, this_ptr, SL("_defaultModule"), PH_NOISY_CC);	}		PHALCON_INIT_VAR(module_object);		/** 	 * Process the module definition	 */	if (zend_is_true(module_name)) {		if (Z_TYPE_P(events_manager) == IS_OBJECT) {				PHALCON_INIT_NVAR(event_name);			ZVAL_STRING(event_name, "application:beforeStartModule", 1);				PHALCON_INIT_NVAR(status);			phalcon_call_method_p3(status, events_manager, "fire", event_name, this_ptr, module_name);			if (PHALCON_IS_FALSE(status)) {				RETURN_MM_FALSE;			}		}			/** 		 * Check if the module passed by the router is registered in the modules container		 */		PHALCON_OBS_VAR(modules);		phalcon_read_property_this(&modules, this_ptr, SL("_modules"), PH_NOISY_CC);		if (!phalcon_array_isset(modules, module_name)) {//.........这里部分代码省略.........
开发者ID:Dinesh-Ramakrishnan,项目名称:cphalcon,代码行数:101,


示例6: PHP_METHOD

/** * Execute a reflection. * * @param int $height * @param int $opacity * @param boolean $fade_in */PHP_METHOD(Phalcon_Image_Adapter_GD, _reflection) {	zval *_height, *opacity, *fade_in, height = {}, tmp = {}, reflection  = {}, line = {}, image = {}, image_width = {}, image_height = {}, dst = {}, filtertype = {};	int h0, h1, tmp_opacity, int_opacity, offset;	double stepping;	phalcon_fetch_params(0, 3, 0, &_height, &opacity, &fade_in);	PHALCON_CPY_WRT_CTOR(&height, _height);	phalcon_return_property(&image, getThis(), SL("_image"));	phalcon_return_property(&image_width, getThis(), SL("_width"));	phalcon_return_property(&image_height, getThis(), SL("_height"));	if (!phalcon_get_constant(&filtertype, SL("IMG_FILTER_COLORIZE"))) {		return;	}	h0 = phalcon_get_intval(&height);	h1 = phalcon_get_intval(&image_height);	if (unlikely(h0 == 0)) {		h0 = 1;	}	tmp_opacity = phalcon_get_intval(opacity);	tmp_opacity = (int)((tmp_opacity * 127 / 100) - 127 + 0.5);	if (tmp_opacity < 0) {		tmp_opacity = -tmp_opacity;	}	if (tmp_opacity < 127) {		stepping = (127 - tmp_opacity) / h0;	} else {		stepping = 127 / h0;	}	ZVAL_DOUBLE(&height, h0 + h1);	PHALCON_CALL_METHODW(&reflection, getThis(), "_create", &image_width, &height);	ZVAL_LONG(&dst, 0);	PHALCON_CALL_FUNCTIONW(NULL, "imagecopy", &reflection, &image, &dst, &dst, &dst, &dst, &image_width, &image_height);	ZVAL_LONG(&tmp, 1);	for (offset = 0; h0 >= offset; offset++) {		zval src_y = {}, dst_y = {}, dst_opacity = {};		ZVAL_LONG(&src_y, h1 - offset - 1);		ZVAL_LONG(&dst_y, h1 + offset);		if (zend_is_true(fade_in)) {			int_opacity = (int)(tmp_opacity + (stepping * (h0 - offset)) + 0.5);			ZVAL_LONG(&dst_opacity, int_opacity);		} else {			int_opacity = (int)(tmp_opacity + (stepping * offset) + 0.5);			ZVAL_LONG(&dst_opacity, int_opacity);		}		PHALCON_CALL_METHODW(&line, getThis(), "_create", &image_width, &tmp);		PHALCON_CALL_FUNCTIONW(NULL, "imagecopy", &line, &image, &dst, &dst, &dst, &src_y, &image_width, &tmp);		PHALCON_CALL_FUNCTIONW(NULL, "imagefilter", &line, &filtertype, &dst, &dst, &dst, &dst_opacity);		PHALCON_CALL_FUNCTIONW(NULL, "imagecopy", &reflection, &line, &dst, &dst_y, &dst, &dst, &image_width, &tmp);	}	PHALCON_CALL_FUNCTIONW(NULL, "imagedestroy", &image);	phalcon_update_property_zval(getThis(), SL("_image"), &reflection);	PHALCON_CALL_FUNCTIONW(&image_width, "imagesx", &reflection);	PHALCON_CALL_FUNCTIONW(&image_height, "imagesy", &reflection);	phalcon_update_property_zval(getThis(), SL("_width"), &image_width);	phalcon_update_property_zval(getThis(), SL("_height"), &image_height);}
开发者ID:dreamsxin,项目名称:cphalcon7,代码行数:84,


示例7: PHP_METHOD

/** * Produce the routing parameters from the rewrite information * * @param string $uri */PHP_METHOD(Phalcon_Mvc_Router_Annotations, handle){	zval *uri = NULL, *real_uri = NULL, *processed, *annotations_service = NULL;	zval *handlers, *controller_sufix, *scope = NULL, *prefix = NULL;	zval *dependency_injector = NULL, *service = NULL, *handler = NULL;	zval *sufixed = NULL, *handler_annotations = NULL, *class_annotations = NULL;	zval *annotations = NULL, *annotation = NULL, *method_annotations = NULL;	zval *lowercased = NULL, *collection = NULL, *method = NULL;	HashTable *ah0, *ah1, *ah2, *ah3;	HashPosition hp0, hp1, hp2, hp3;	zval **hd;	PHALCON_MM_GROW();	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &uri) == FAILURE) {		RETURN_MM_NULL();	}	if (!uri) {		PHALCON_INIT_VAR(uri);	}		if (!zend_is_true(uri)) {		/** 		 * If 'uri' isn't passed as parameter it reads $_GET['_url']		 */		PHALCON_INIT_VAR(real_uri);		PHALCON_CALL_METHOD(real_uri, this_ptr, "_getrewriteuri");	} else {		PHALCON_CPY_WRT(real_uri, uri);	}		PHALCON_OBS_VAR(processed);	phalcon_read_property(&processed, this_ptr, SL("_processed"), PH_NOISY_CC);	if (!zend_is_true(processed)) {			PHALCON_INIT_VAR(annotations_service);			PHALCON_OBS_VAR(handlers);		phalcon_read_property(&handlers, this_ptr, SL("_handlers"), PH_NOISY_CC);			PHALCON_OBS_VAR(controller_sufix);		phalcon_read_property(&controller_sufix, this_ptr, SL("_controllerSufix"), PH_NOISY_CC);			if (!phalcon_is_iterable(handlers, &ah0, &hp0, 0, 0 TSRMLS_CC)) {			return;		}			while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) {				PHALCON_GET_FOREACH_VALUE(scope);				if (Z_TYPE_P(scope) == IS_ARRAY) { 					/** 				 * A prefix (if any) must be in position 0				 */				PHALCON_OBS_NVAR(prefix);				phalcon_array_fetch_long(&prefix, scope, 0, PH_NOISY_CC);				if (Z_TYPE_P(prefix) == IS_STRING) {					if (!phalcon_start_with(real_uri, prefix, NULL)) {						zend_hash_move_forward_ex(ah0, &hp0);						continue;					}				}					if (Z_TYPE_P(annotations_service) != IS_OBJECT) {						PHALCON_OBS_NVAR(dependency_injector);					phalcon_read_property(&dependency_injector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC);					if (Z_TYPE_P(dependency_injector) != IS_OBJECT) {						PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_router_exception_ce, "A dependency injection container is required to access the 'annotations' service");						return;					}						PHALCON_INIT_NVAR(service);					ZVAL_STRING(service, "annotations", 1);						PHALCON_INIT_NVAR(annotations_service);					PHALCON_CALL_METHOD_PARAMS_1(annotations_service, dependency_injector, "getshared", service);				}					/** 				 * The controller must be in position 1				 */				PHALCON_OBS_NVAR(handler);				phalcon_array_fetch_long(&handler, scope, 1, PH_NOISY_CC);				phalcon_update_property_null(this_ptr, SL("_routePrefix") TSRMLS_CC);					PHALCON_INIT_NVAR(sufixed);				PHALCON_CONCAT_VV(sufixed, handler, controller_sufix);					PHALCON_INIT_NVAR(handler_annotations);				PHALCON_CALL_METHOD_PARAMS_1(handler_annotations, annotations_service, "get", sufixed);	//.........这里部分代码省略.........
开发者ID:Gildus,项目名称:cphalcon,代码行数:101,


示例8: php_tcp_sockop_bind

static inline int php_tcp_sockop_bind(php_stream *stream, php_netstream_data_t *sock,		php_stream_xport_param *xparam){	char *host = NULL;	int portno, err;	long sockopts = STREAM_SOCKOP_NONE;	zval *tmpzval = NULL;#ifdef AF_UNIX	if (stream->ops == &php_stream_unix_socket_ops || stream->ops == &php_stream_unixdg_socket_ops) {		struct sockaddr_un unix_addr;		sock->socket = socket(PF_UNIX, stream->ops == &php_stream_unix_socket_ops ? SOCK_STREAM : SOCK_DGRAM, 0);		if (sock->socket == SOCK_ERR) {			if (xparam->want_errortext) {				xparam->outputs.error_text = strpprintf(0, "Failed to create unix%s socket %s",						stream->ops == &php_stream_unix_socket_ops ? "" : "datagram",						strerror(errno));			}			return -1;		}		parse_unix_address(xparam, &unix_addr);		return bind(sock->socket, (const struct sockaddr *)&unix_addr,			(socklen_t) XtOffsetOf(struct sockaddr_un, sun_path) + xparam->inputs.namelen);	}#endif	host = parse_ip_address(xparam, &portno);	if (host == NULL) {		return -1;	}#ifdef IPV6_V6ONLY	if (PHP_STREAM_CONTEXT(stream)		&& (tmpzval = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "socket", "ipv6_v6only")) != NULL		&& Z_TYPE_P(tmpzval) != IS_NULL	) {		sockopts |= STREAM_SOCKOP_IPV6_V6ONLY;		sockopts |= STREAM_SOCKOP_IPV6_V6ONLY_ENABLED * zend_is_true(tmpzval);	}#endif#ifdef SO_REUSEPORT	if (PHP_STREAM_CONTEXT(stream)		&& (tmpzval = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "socket", "so_reuseport")) != NULL		&& zend_is_true(tmpzval)	) {		sockopts |= STREAM_SOCKOP_SO_REUSEPORT;	}#endif#ifdef SO_BROADCAST	if (stream->ops == &php_stream_udp_socket_ops /* SO_BROADCAST is only applicable for UDP */		&& PHP_STREAM_CONTEXT(stream)		&& (tmpzval = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "socket", "so_broadcast")) != NULL		&& zend_is_true(tmpzval)	) {		sockopts |= STREAM_SOCKOP_SO_BROADCAST;	}#endif	sock->socket = php_network_bind_socket_to_local_addr(host, portno,			stream->ops == &php_stream_udp_socket_ops ? SOCK_DGRAM : SOCK_STREAM,			sockopts,			xparam->want_errortext ? &xparam->outputs.error_text : NULL,			&err			);	if (host) {		efree(host);	}	return sock->socket == -1 ? -1 : 0;}
开发者ID:Apfelfrisch,项目名称:php-src,代码行数:78,


示例9: php_tcp_sockop_connect

static inline int php_tcp_sockop_connect(php_stream *stream, php_netstream_data_t *sock,		php_stream_xport_param *xparam){	char *host = NULL, *bindto = NULL;	int portno, bindport = 0;	int err = 0;	int ret;	zval *tmpzval = NULL;	long sockopts = STREAM_SOCKOP_NONE;#ifdef AF_UNIX	if (stream->ops == &php_stream_unix_socket_ops || stream->ops == &php_stream_unixdg_socket_ops) {		struct sockaddr_un unix_addr;		sock->socket = socket(PF_UNIX, stream->ops == &php_stream_unix_socket_ops ? SOCK_STREAM : SOCK_DGRAM, 0);		if (sock->socket == SOCK_ERR) {			if (xparam->want_errortext) {				xparam->outputs.error_text = strpprintf(0, "Failed to create unix socket");			}			return -1;		}		parse_unix_address(xparam, &unix_addr);		ret = php_network_connect_socket(sock->socket,				(const struct sockaddr *)&unix_addr, (socklen_t) XtOffsetOf(struct sockaddr_un, sun_path) + xparam->inputs.namelen,				xparam->op == STREAM_XPORT_OP_CONNECT_ASYNC, xparam->inputs.timeout,				xparam->want_errortext ? &xparam->outputs.error_text : NULL,				&err);		xparam->outputs.error_code = err;		goto out;	}#endif	host = parse_ip_address(xparam, &portno);	if (host == NULL) {		return -1;	}	if (PHP_STREAM_CONTEXT(stream) && (tmpzval = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "socket", "bindto")) != NULL) {		if (Z_TYPE_P(tmpzval) != IS_STRING) {			if (xparam->want_errortext) {				xparam->outputs.error_text = strpprintf(0, "local_addr context option is not a string.");			}			efree(host);			return -1;		}		bindto = parse_ip_address_ex(Z_STRVAL_P(tmpzval), Z_STRLEN_P(tmpzval), &bindport, xparam->want_errortext, &xparam->outputs.error_text);	}#ifdef SO_BROADCAST	if (stream->ops == &php_stream_udp_socket_ops /* SO_BROADCAST is only applicable for UDP */		&& PHP_STREAM_CONTEXT(stream)		&& (tmpzval = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "socket", "so_broadcast")) != NULL		&& zend_is_true(tmpzval)	) {		sockopts |= STREAM_SOCKOP_SO_BROADCAST;	}#endif	if (stream->ops != &php_stream_udp_socket_ops /* TCP_NODELAY is only applicable for TCP */#ifdef AF_UNIX		&& stream->ops != &php_stream_unix_socket_ops		&& stream->ops != &php_stream_unixdg_socket_ops#endif		&& PHP_STREAM_CONTEXT(stream)		&& (tmpzval = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "socket", "tcp_nodelay")) != NULL		&& zend_is_true(tmpzval)	) {		sockopts |= STREAM_SOCKOP_TCP_NODELAY;	}	/* Note: the test here for php_stream_udp_socket_ops is important, because we	 * want the default to be TCP sockets so that the openssl extension can	 * re-use this code. */	sock->socket = php_network_connect_socket_to_host(host, portno,			stream->ops == &php_stream_udp_socket_ops ? SOCK_DGRAM : SOCK_STREAM,			xparam->op == STREAM_XPORT_OP_CONNECT_ASYNC,			xparam->inputs.timeout,			xparam->want_errortext ? &xparam->outputs.error_text : NULL,			&err,			bindto,			bindport,			sockopts			);	ret = sock->socket == -1 ? -1 : 0;	xparam->outputs.error_code = err;	if (host) {		efree(host);	}	if (bindto) {		efree(bindto);	}//.........这里部分代码省略.........
开发者ID:Apfelfrisch,项目名称:php-src,代码行数:101,


示例10: PHP_METHOD

/** * Sets a cookie to be sent at the end of the request * This method overrides any cookie set before with the same name * * @param string $name * @param mixed $value * @param int $expire * @param string $path * @param boolean $secure * @param string $domain * @param boolean $httpOnly * @return Phalcon/Http/Response/Cookies */PHP_METHOD(Phalcon_Http_Response_Cookies, set){	zval *name, *value = NULL, *expire = NULL, *path = NULL, *secure = NULL, *domain = NULL;	zval *http_only = NULL, *cookies, *encryption, *dependency_injector = NULL;	zval *cookie = NULL, *registered, *service, *response = NULL;	PHALCON_MM_GROW();	phalcon_fetch_params(1, 1, 6, &name, &value, &expire, &path, &secure, &domain, &http_only);	if (Z_TYPE_P(name) != IS_STRING) {		PHALCON_THROW_EXCEPTION_STR(phalcon_http_cookie_exception_ce, "The cookie name must be string");		return;	}	if (!value) {		value = PHALCON_GLOBAL(z_null);	}	if (!expire) {		PHALCON_OBS_VAR(expire);		phalcon_read_property_this(&expire, this_ptr, SL("_expire"), PH_NOISY TSRMLS_CC);	}	if (!path) {		PHALCON_OBS_VAR(path);		phalcon_read_property_this(&path, this_ptr, SL("_path"), PH_NOISY TSRMLS_CC);	}	if (!secure) {		PHALCON_OBS_VAR(secure);		phalcon_read_property_this(&secure, this_ptr, SL("_secure"), PH_NOISY TSRMLS_CC);	}	if (!domain) {		PHALCON_OBS_VAR(domain);		phalcon_read_property_this(&domain, this_ptr, SL("_domain"), PH_NOISY TSRMLS_CC);	}	if (!http_only) {		PHALCON_OBS_VAR(http_only);		phalcon_read_property_this(&http_only, this_ptr, SL("_httpOnly"), PH_NOISY TSRMLS_CC);	}	PHALCON_OBS_VAR(cookies);	phalcon_read_property_this(&cookies, this_ptr, SL("_cookies"), PH_NOISY TSRMLS_CC);	PHALCON_OBS_VAR(encryption);	phalcon_read_property_this(&encryption, this_ptr, SL("_useEncryption"), PH_NOISY TSRMLS_CC);	PHALCON_CALL_METHOD(&dependency_injector, this_ptr, "getdi");	/** 	 * Check if the cookie needs to be updated or 	 */	if (!phalcon_array_isset(cookies, name)) {		PHALCON_INIT_VAR(cookie);		object_init_ex(cookie, phalcon_http_cookie_ce);		PHALCON_CALL_METHOD(NULL, cookie, "__construct", name, value, expire, path, secure, domain, http_only);		/** 		 * Pass the DI to created cookies		 */		PHALCON_CALL_METHOD(NULL, cookie, "setdi", dependency_injector);		/** 		 * Enable encryption in the cookie		 */		if (zend_is_true(encryption)) {			PHALCON_CALL_METHOD(NULL, cookie, "useencryption", encryption);		}		phalcon_update_property_array(this_ptr, SL("_cookies"), name, cookie TSRMLS_CC);	} else {		PHALCON_OBS_NVAR(cookie);		phalcon_array_fetch(&cookie, cookies, name, PH_NOISY);		/** 		 * Override any settings in the cookie		 */		PHALCON_CALL_METHOD(NULL, cookie, "setvalue", value);		PHALCON_CALL_METHOD(NULL, cookie, "setexpiration", expire);		PHALCON_CALL_METHOD(NULL, cookie, "setpath", path);		PHALCON_CALL_METHOD(NULL, cookie, "setsecure", secure);		PHALCON_CALL_METHOD(NULL, cookie, "setdomain", domain);		PHALCON_CALL_METHOD(NULL, cookie, "sethttponly", http_only);	}//.........这里部分代码省略.........
开发者ID:Myleft,项目名称:cphalcon,代码行数:101,


示例11: PHP_METHOD

//.........这里部分代码省略.........							PHALCON_INIT_VAR(pos);							phalcon_fast_strpos_str(pos, column_type, SL("datetime") TSRMLS_CC);							if (Z_TYPE_P(pos) != IS_BOOL || (Z_TYPE_P(pos) == IS_BOOL && Z_BVAL_P(pos))) {								phalcon_array_update_string_long(&definition, SL("type"), 4, PH_SEPARATE TSRMLS_CC);							} else {								PHALCON_INIT_VAR(pos);								phalcon_fast_strpos_str(pos, column_type, SL("text") TSRMLS_CC);								if (Z_TYPE_P(pos) != IS_BOOL || (Z_TYPE_P(pos) == IS_BOOL && Z_BVAL_P(pos))) {									phalcon_array_update_string_long(&definition, SL("type"), 6, PH_SEPARATE TSRMLS_CC);								} else {									PHALCON_INIT_VAR(pos);									phalcon_fast_strpos_str(pos, column_type, SL("float") TSRMLS_CC);									if (Z_TYPE_P(pos) != IS_BOOL || (Z_TYPE_P(pos) == IS_BOOL && Z_BVAL_P(pos))) {										phalcon_array_update_string_long(&definition, SL("type"), 7, PH_SEPARATE TSRMLS_CC);										phalcon_array_update_string_bool(&definition, SL("isNumeric"), 1, PH_SEPARATE TSRMLS_CC);									} else {										PHALCON_INIT_VAR(pos);										phalcon_fast_strpos_str(pos, column_type, SL("enum") TSRMLS_CC);										if (Z_TYPE_P(pos) != IS_BOOL || (Z_TYPE_P(pos) == IS_BOOL && Z_BVAL_P(pos))) {											phalcon_array_update_string_long(&definition, SL("type"), 5, PH_SEPARATE TSRMLS_CC);										} else {											phalcon_array_update_string_long(&definition, SL("type"), 2, PH_SEPARATE TSRMLS_CC);										}									}								}							}						}					}				}			}		}				PHALCON_INIT_VAR(pos);		phalcon_fast_strpos_str(pos, column_type, SL("(") TSRMLS_CC);		if (Z_TYPE_P(pos) != IS_BOOL || (Z_TYPE_P(pos) == IS_BOOL && Z_BVAL_P(pos))) {			PHALCON_INIT_VAR(matches);			array_init(matches);						PHALCON_INIT_VAR(c0);			ZVAL_STRING(c0, "#//(([0-9]+)(,[0-9]+)*//)#", 1);			Z_SET_ISREF_P(matches);						PHALCON_INIT_VAR(pos);			PHALCON_CALL_FUNC_PARAMS_3(pos, "preg_match", c0, column_type, matches);			Z_UNSET_ISREF_P(matches);			if (zend_is_true(pos)) {				eval_int = phalcon_array_isset_long(matches, 1);				if (eval_int) {					PHALCON_INIT_VAR(match_one);					phalcon_array_fetch_long(&match_one, matches, 1, PH_NOISY_CC);					phalcon_array_update_string(&definition, SL("size"), &match_one, PH_COPY | PH_SEPARATE TSRMLS_CC);				}			}		}				PHALCON_INIT_VAR(pos);		phalcon_fast_strpos_str(pos, column_type, SL("unsigned") TSRMLS_CC);		if (Z_TYPE_P(pos) != IS_BOOL || (Z_TYPE_P(pos) == IS_BOOL && Z_BVAL_P(pos))) {			phalcon_array_update_string_bool(&definition, SL("unsigned"), 1, PH_SEPARATE TSRMLS_CC);		}				if (!zend_is_true(old_column)) {			phalcon_array_update_string_bool(&definition, SL("first"), 1, PH_SEPARATE TSRMLS_CC);		} else {			phalcon_array_update_string(&definition, SL("after"), &old_column, PH_COPY | PH_SEPARATE TSRMLS_CC);		}				PHALCON_INIT_VAR(attribute);		phalcon_array_fetch_string(&attribute, field, SL("key"), PH_NOISY_CC);		if (PHALCON_COMPARE_STRING(attribute, "PRI")) {			phalcon_array_update_string_bool(&definition, SL("primary"), 1, PH_SEPARATE TSRMLS_CC);		}				PHALCON_INIT_VAR(attribute);		phalcon_array_fetch_string(&attribute, field, SL("null"), PH_NOISY_CC);		if (PHALCON_COMPARE_STRING(attribute, "NO")) {			phalcon_array_update_string_bool(&definition, SL("notNull"), 1, PH_SEPARATE TSRMLS_CC);		}				PHALCON_INIT_VAR(attribute);		phalcon_array_fetch_string(&attribute, field, SL("extra"), PH_NOISY_CC);		if (PHALCON_COMPARE_STRING(attribute, "auto_increment")) {			phalcon_array_update_string_bool(&definition, SL("autoIncrement"), 1, PH_SEPARATE TSRMLS_CC);		}				PHALCON_INIT_VAR(column_name);		phalcon_array_fetch_string(&column_name, field, SL("field"), PH_NOISY_CC);				PHALCON_INIT_VAR(column);		object_init_ex(column, phalcon_db_column_ce);		PHALCON_CALL_METHOD_PARAMS_2_NORETURN(column, "__construct", column_name, definition, PH_CHECK);		phalcon_array_append(&columns, column, PH_SEPARATE TSRMLS_CC);		PHALCON_CPY_WRT(old_column, column_name);		zend_hash_move_forward_ex(ah0, &hp0);		goto fes_ecef_0;	fee_ecef_0:			RETURN_CTOR(columns);}
开发者ID:gplanchat,项目名称:cphalcon,代码行数:101,


示例12: PHP_METHOD

/** * The meta-data is obtained by reading the column descriptions from the database information schema * * @param Phalcon/Mvc/ModelInterface $model * @param Phalcon/DiInterface $dependencyInjector * @return array */PHP_METHOD(Phalcon_Mvc_Model_MetaData_Strategy_Introspection, getMetaData){	zval *model, *dependency_injector, *class_name;	zval *schema, *table, *read_connection, *exists;	zval *complete_table = NULL, *exception_message = NULL;	zval *columns, *attributes, *primary_keys, *non_primary_keys;	zval *numeric_typed, *not_null, *field_types;	zval *field_bind_types, *automatic_default;	zval *identity_field = NULL, *column = NULL, *field_name = NULL, *feature = NULL;	zval *type = NULL, *bind_type = NULL, *model_metadata;	HashTable *ah0;	HashPosition hp0;	zval **hd;	PHALCON_MM_GROW();	phalcon_fetch_params(1, 2, 0, &model, &dependency_injector);		PHALCON_INIT_VAR(class_name);	phalcon_get_class(class_name, model, 0 TSRMLS_CC);		PHALCON_INIT_VAR(schema);	phalcon_call_method(schema, model, "getschema");		PHALCON_INIT_VAR(table);	phalcon_call_method(table, model, "getsource");		/** 	 * Check if the mapped table exists on the database	 */	PHALCON_INIT_VAR(read_connection);	phalcon_call_method(read_connection, model, "getreadconnection");		PHALCON_INIT_VAR(exists);	phalcon_call_method_p2(exists, read_connection, "tableexists", table, schema);	if (!zend_is_true(exists)) {		if (zend_is_true(schema)) {			PHALCON_INIT_VAR(complete_table);			PHALCON_CONCAT_VSV(complete_table, schema, "/"./"", table);		} else {			PHALCON_CPY_WRT(complete_table, table);		}			/** 		 * The table not exists		 */		PHALCON_INIT_VAR(exception_message);		PHALCON_CONCAT_SVSV(exception_message, "Table /"", complete_table, "/" doesn't exist on database when dumping meta-data for ", class_name);		PHALCON_THROW_EXCEPTION_ZVAL(phalcon_mvc_model_exception_ce, exception_message);		return;	}		/** 	 * Try to describe the table	 */	PHALCON_INIT_VAR(columns);	phalcon_call_method_p2(columns, read_connection, "describecolumns", table, schema);	if (!phalcon_fast_count_ev(columns TSRMLS_CC)) {		if (zend_is_true(schema)) {			PHALCON_INIT_NVAR(complete_table);			PHALCON_CONCAT_VSV(complete_table, schema, "/"./"", table);		} else {			PHALCON_CPY_WRT(complete_table, table);		}			/** 		 * The table not exists		 */		PHALCON_INIT_NVAR(exception_message);		PHALCON_CONCAT_SVSV(exception_message, "Cannot obtain table columns for the mapped source /"", complete_table, "/" used in model ", class_name);		PHALCON_THROW_EXCEPTION_ZVAL(phalcon_mvc_model_exception_ce, exception_message);		return;	}		/** 	 * Initialize meta-data	 */	PHALCON_INIT_VAR(attributes);	array_init(attributes);		PHALCON_INIT_VAR(primary_keys);	array_init(primary_keys);		PHALCON_INIT_VAR(non_primary_keys);	array_init(non_primary_keys);		PHALCON_INIT_VAR(numeric_typed);	array_init(numeric_typed);		PHALCON_INIT_VAR(not_null);	array_init(not_null);		PHALCON_INIT_VAR(field_types);//.........这里部分代码省略.........
开发者ID:11mariom,项目名称:cphalcon,代码行数:101,


示例13: PHP_METHOD

/** * Check whether internal resource has rows to fetch * * @return boolean */PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, valid){	zval *type = NULL, *result, *row = NULL, *rows, *underscore, *empty_str;	zval *active_row, *columns_types, *column = NULL, *alias = NULL;	zval *source = NULL, *instance = NULL, *attributes = NULL, *column_map = NULL;	zval *row_model = NULL, *attribute = NULL, *column_alias = NULL, *value = NULL;	zval *model_attribute = NULL, *sql_alias = NULL, *n_alias = NULL;	HashTable *ah0, *ah1;	HashPosition hp0, hp1;	zval **hd;	char *hash_index;	uint hash_index_len;	ulong hash_num;	int hash_type;	int eval_int;	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 (PHALCON_IS_NOT_FALSE(result)) {			PHALCON_INIT_VAR(row);			PHALCON_CALL_METHOD_PARAMS_1(row, result, "fetch", result, PH_NO_CHECK);		} else {			PHALCON_INIT_NVAR(row);			ZVAL_BOOL(row, 0);		}	} else {		PHALCON_INIT_VAR(rows);		phalcon_read_property(&rows, this_ptr, SL("_rows"), PH_NOISY_CC);		Z_SET_ISREF_P(rows);			PHALCON_INIT_NVAR(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);		}	}		if (PHALCON_IS_NOT_FALSE(row)) {		PHALCON_INIT_VAR(underscore);		ZVAL_STRING(underscore, "_", 1);			PHALCON_INIT_VAR(empty_str);		ZVAL_STRING(empty_str, "", 1);			PHALCON_INIT_VAR(active_row);		object_init_ex(active_row, phalcon_mvc_model_row_ce);			PHALCON_INIT_VAR(columns_types);		phalcon_read_property(&columns_types, this_ptr, SL("_columnTypes"), PH_NOISY_CC);			if (!phalcon_valid_foreach(columns_types TSRMLS_CC)) {			return;		}			ah0 = Z_ARRVAL_P(columns_types);		zend_hash_internal_pointer_reset_ex(ah0, &hp0);			ph_cycle_start_0:				if (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS) {				goto ph_cycle_end_0;			}				PHALCON_GET_FOREACH_KEY(alias, ah0, hp0);			PHALCON_GET_FOREACH_VALUE(column);				PHALCON_INIT_NVAR(type);			phalcon_array_fetch_string(&type, column, SL("type"), PH_NOISY_CC);			if (PHALCON_COMPARE_STRING(type, "object")) {				/** 				 * Object columns are assigned column by column				 */				PHALCON_INIT_NVAR(source);				phalcon_array_fetch_string(&source, column, SL("column"), PH_NOISY_CC);					PHALCON_INIT_NVAR(instance);				phalcon_array_fetch_string(&instance, column, SL("instance"), PH_NOISY_CC);					PHALCON_INIT_NVAR(attributes);				phalcon_array_fetch_string(&attributes, column, SL("attributes"), PH_NOISY_CC);					PHALCON_INIT_NVAR(column_map);				phalcon_array_fetch_string(&column_map, column, SL("columnMap"), PH_NOISY_CC);					/** 				 * Assign the values from the _source_attribute notation to its real column name				 *///.........这里部分代码省略.........
开发者ID:Tigerlee1987,项目名称:cphalcon,代码行数:101,


示例14: pgsql_stmt_param_hook

//.........这里部分代码省略.........							zend_hash_num_elements(stmt->bound_param_map),							sizeof(char*));					S->param_lengths = ecalloc(							zend_hash_num_elements(stmt->bound_param_map),							sizeof(int));					S->param_formats = ecalloc(							zend_hash_num_elements(stmt->bound_param_map),							sizeof(int));					S->param_types = ecalloc(							zend_hash_num_elements(stmt->bound_param_map),							sizeof(Oid));				}				if (param->paramno >= 0) {					zval *parameter;					/*					if (param->paramno >= zend_hash_num_elements(stmt->bound_params)) {						pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "parameter was not defined");						return 0;					}					*/					if (Z_ISREF(param->parameter)) {						parameter = Z_REFVAL(param->parameter);					} else {						parameter = &param->parameter;					}					if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_LOB &&							Z_TYPE_P(parameter) == IS_RESOURCE) {						php_stream *stm;						php_stream_from_zval_no_verify(stm, parameter);						if (stm) {							if (php_stream_is(stm, &pdo_pgsql_lob_stream_ops)) {								struct pdo_pgsql_lob_self *self = (struct pdo_pgsql_lob_self*)stm->abstract;								pdo_pgsql_bound_param *P = param->driver_data;								if (P == NULL) {									P = ecalloc(1, sizeof(*P));									param->driver_data = P;								}								P->oid = htonl(self->oid);								S->param_values[param->paramno] = (char*)&P->oid;								S->param_lengths[param->paramno] = sizeof(P->oid);								S->param_formats[param->paramno] = 1;								S->param_types[param->paramno] = OIDOID;								return 1;							} else {								zend_string *str = php_stream_copy_to_mem(stm, PHP_STREAM_COPY_ALL, 0);								if (str != NULL) {									//??SEPARATE_ZVAL_IF_NOT_REF(&param->parameter);									ZVAL_STR(parameter, str);								} else {									ZVAL_EMPTY_STRING(parameter);								}							}						} else {							/* expected a stream resource */							pdo_pgsql_error_stmt(stmt, PGRES_FATAL_ERROR, "HY105");							return 0;						}					}					if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_NULL ||							Z_TYPE_P(parameter) == IS_NULL) {						S->param_values[param->paramno] = NULL;						S->param_lengths[param->paramno] = 0;					} else if (Z_TYPE_P(parameter) == IS_FALSE || Z_TYPE_P(parameter) == IS_TRUE) {						S->param_values[param->paramno] = Z_TYPE_P(parameter) == IS_TRUE ? "t" : "f";						S->param_lengths[param->paramno] = 1;						S->param_formats[param->paramno] = 0;					} else {						//SEPARATE_ZVAL_IF_NOT_REF(&param->parameter);						convert_to_string_ex(parameter);						S->param_values[param->paramno] = Z_STRVAL_P(parameter);						S->param_lengths[param->paramno] = Z_STRLEN_P(parameter);						S->param_formats[param->paramno] = 0;					}					if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_LOB) {						S->param_types[param->paramno] = 0;						S->param_formats[param->paramno] = 1;					} else {						S->param_types[param->paramno] = 0;					}				}				break;		}	} else if (param->is_param) {		/* We need to manually convert to a pg native boolean value */		if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_BOOL &&			((param->param_type & PDO_PARAM_INPUT_OUTPUT) != PDO_PARAM_INPUT_OUTPUT)) {			const char *s = zend_is_true(&param->parameter) ? "t" : "f";			param->param_type = PDO_PARAM_STR;			zval_ptr_dtor(&param->parameter);			ZVAL_STRINGL(&param->parameter, s, 1);		}	}	return 1;}
开发者ID:EnochZg,项目名称:php-src,代码行数:101,


示例15: PHP_METHOD

/** * Stores cached content into the file backend and stops the frontend * * @param int|string $keyName * @param string $content * @param long $lifetime * @param boolean $stopBuffer */PHP_METHOD(Phalcon_Cache_Backend_File, save){	zval *key_name = NULL, *content = NULL, *lifetime = NULL, *stop_buffer = NULL;	zval *last_key = NULL, *prefix, *frontend, *options, *cache_dir;	zval *cache_file, *cached_content = NULL, *prepared_content;	zval *status, *is_buffering;	PHALCON_MM_GROW();	phalcon_fetch_params(1, 0, 4, &key_name, &content, &lifetime, &stop_buffer);		if (!key_name) {		PHALCON_INIT_VAR(key_name);	}		if (!content) {		PHALCON_INIT_VAR(content);	}		if (!lifetime) {		PHALCON_INIT_VAR(lifetime);	}		if (!stop_buffer) {		PHALCON_INIT_VAR(stop_buffer);		ZVAL_BOOL(stop_buffer, 1);	}		if (Z_TYPE_P(key_name) == IS_NULL) {		PHALCON_OBS_VAR(last_key);		phalcon_read_property_this(&last_key, this_ptr, SL("_lastKey"), PH_NOISY_CC);	} else {		PHALCON_OBS_VAR(prefix);		phalcon_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC);			PHALCON_INIT_NVAR(last_key);		PHALCON_CONCAT_VV(last_key, prefix, key_name);	}	if (!zend_is_true(last_key)) {		PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "The cache must be started first");		return;	}		PHALCON_OBS_VAR(frontend);	phalcon_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC);		PHALCON_OBS_VAR(options);	phalcon_read_property_this(&options, this_ptr, SL("_options"), PH_NOISY_CC);		PHALCON_OBS_VAR(cache_dir);	phalcon_array_fetch_string(&cache_dir, options, SL("cacheDir"), PH_NOISY);		PHALCON_INIT_VAR(cache_file);	PHALCON_CONCAT_VV(cache_file, cache_dir, last_key);	if (!zend_is_true(content)) {		PHALCON_INIT_VAR(cached_content);		phalcon_call_method(cached_content, frontend, "getcontent");	} else {		PHALCON_CPY_WRT(cached_content, content);	}		PHALCON_INIT_VAR(prepared_content);	phalcon_call_method_p1(prepared_content, frontend, "beforestore", cached_content);		/** 	 * We use file_put_contents to respect open-base-dir directive	 */	PHALCON_INIT_VAR(status);	phalcon_file_put_contents(status, cache_file, prepared_content TSRMLS_CC);	if (PHALCON_IS_FALSE(status)) {		PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "Cache directory can't be written");		return;	}		PHALCON_INIT_VAR(is_buffering);	phalcon_call_method(is_buffering, frontend, "isbuffering");	if (PHALCON_IS_TRUE(stop_buffer)) {		phalcon_call_method_noret(frontend, "stop");	}		if (PHALCON_IS_TRUE(is_buffering)) {		zend_print_zval(cached_content, 0);	}		phalcon_update_property_bool(this_ptr, SL("_started"), 0 TSRMLS_CC);		PHALCON_MM_RESTORE();}
开发者ID:11mariom,项目名称:cphalcon,代码行数:96,


示例16: PHP_METHOD

/** * Stores cached content into the Mongo backend and stops the frontend * * @param int|string $keyName * @param string $content * @param long $lifetime * @param boolean $stopBuffer */PHP_METHOD(Phalcon_Cache_Backend_Mongo, save){	zval *key_name = NULL, *content = NULL, *lifetime = NULL, *stop_buffer = NULL;	zval *last_key, *frontend, *cached_content = NULL;	zval *prepared_content = NULL, *ttl = NULL, *collection = NULL, *timestamp;	zval *conditions, *document = NULL, *data, *is_buffering = NULL;	PHALCON_MM_GROW();	phalcon_fetch_params(1, 0, 4, &key_name, &content, &lifetime, &stop_buffer);	if (!key_name || Z_TYPE_P(key_name) == IS_NULL) {		last_key = phalcon_read_property(getThis(), SL("_lastKey"), PH_NOISY);	} else {		zval *prefix = phalcon_read_property(getThis(), SL("_prefix"), PH_NOISY);		PHALCON_INIT_VAR(last_key);		PHALCON_CONCAT_VV(last_key, prefix, key_name);	}	if (!zend_is_true(last_key)) {		PHALCON_THROW_EXCEPTION_STR(phalcon_cache_exception_ce, "The cache must be started first");		return;	}	frontend = phalcon_read_property(getThis(), SL("_frontend"), PH_NOISY);	if (!content || Z_TYPE_P(content) == IS_NULL) {		PHALCON_CALL_METHOD(&cached_content, frontend, "getcontent");	} else {		cached_content = content;	}	if (!phalcon_is_numeric(cached_content)) {		PHALCON_CALL_METHOD(&prepared_content, frontend, "beforestore", cached_content);	}	if (!lifetime || Z_TYPE_P(lifetime) == IS_NULL) {		zval *tmp = phalcon_read_property(getThis(), SL("_lastLifetime"), PH_NOISY);		if (Z_TYPE_P(tmp) == IS_NULL) {			PHALCON_CALL_METHOD(&ttl, frontend, "getlifetime");		}		else {			ttl = tmp;		}	} else {		ttl = lifetime;	}	PHALCON_CALL_METHOD(&collection, getThis(), "_getcollection");	PHALCON_INIT_VAR(timestamp);	ZVAL_LONG(timestamp, (long) time(NULL) + phalcon_get_intval(ttl));	PHALCON_INIT_VAR(conditions);	array_init_size(conditions, 1);	phalcon_array_update_str(conditions, SL("key"), last_key, PH_COPY);	PHALCON_CALL_METHOD(&document, collection, "findone", conditions);	if (Z_TYPE_P(document) == IS_ARRAY) { 		phalcon_array_update_str(document, SL("time"), timestamp, PH_COPY);		if (prepared_content) {			phalcon_array_update_str(document, SL("data"), prepared_content, PH_COPY);		} else {			phalcon_array_update_str(document, SL("data"), cached_content, PH_COPY);		}		PHALCON_CALL_METHOD(NULL, collection, "save", document);	} else {		PHALCON_INIT_VAR(data);		array_init_size(data, 3);		phalcon_array_update_str(data, SL("key"), last_key, PH_COPY);		phalcon_array_update_str(data, SL("time"), timestamp, PH_COPY);		if (prepared_content) {			phalcon_array_update_str(data, SL("data"), prepared_content, PH_COPY);		} else {			phalcon_array_update_str(data, SL("data"), cached_content, PH_COPY);		}		PHALCON_CALL_METHOD(NULL, collection, "save", data);	}	PHALCON_CALL_METHOD(&is_buffering, frontend, "isbuffering");	if (!stop_buffer || PHALCON_IS_TRUE(stop_buffer)) {		PHALCON_CALL_METHOD(NULL, frontend, "stop");	}	if (PHALCON_IS_TRUE(is_buffering)) {		zend_print_zval(cached_content, 0);	}//.........这里部分代码省略.........
开发者ID:Myleft,项目名称:cphalcon7,代码行数:101,


示例17: PHP_METHOD

/** * Read the model's column map, this can't be inferred * * @param Phalcon/Mvc/ModelInterface $model * @param Phalcon/DiInterface $dependencyInjector * @return array */PHP_METHOD(Phalcon_Mvc_Model_MetaData_Strategy_Annotations, getColumnMaps){	zval *model, *dependency_injector, *service;	zval *ordered_column_map, *reversed_column_map = NULL;	zval *annotations = NULL, *class_name, *reflection = NULL;	zval *exception_message = NULL, *properties_annotations = NULL;	zval *column_annot_name, *column_map_name;	zval *prop_annotations = NULL, *property = NULL, *has_annotation = NULL;	zval *column_annotation = NULL, *real_property = NULL;	HashTable *ah0;	HashPosition hp0;	zval **hd;	PHALCON_MM_GROW();	phalcon_fetch_params(1, 2, 0, &model, &dependency_injector);	if (!PHALCON_GLOBAL(orm).column_renaming) {		RETURN_MM_NULL();	}	if (Z_TYPE_P(dependency_injector) != IS_OBJECT) {		PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "The dependency injector is invalid");		return;	}	PHALCON_INIT_VAR(service);	ZVAL_STRING(service, "annotations", 1);	PHALCON_CALL_METHOD(&annotations, dependency_injector, "get", service);	PHALCON_INIT_VAR(class_name);	phalcon_get_class(class_name, model, 0 TSRMLS_CC);	PHALCON_CALL_METHOD(&reflection, annotations, "get", class_name);	if (Z_TYPE_P(reflection) != IS_OBJECT) {		PHALCON_INIT_VAR(exception_message);		PHALCON_CONCAT_SV(exception_message, "No annotations were found in class ", class_name);		PHALCON_THROW_EXCEPTION_ZVAL(phalcon_mvc_model_exception_ce, exception_message);		return;	}	/** 	 * Get the properties defined in 	 */	PHALCON_CALL_METHOD(&properties_annotations, reflection, "getpropertiesannotations");	if (!phalcon_fast_count_ev(properties_annotations TSRMLS_CC)) {		PHALCON_INIT_NVAR(exception_message);		PHALCON_CONCAT_SV(exception_message, "No properties with annotations were found in class ", class_name);		PHALCON_THROW_EXCEPTION_ZVAL(phalcon_mvc_model_exception_ce, exception_message);		return;	}	/** 	 * Initialize meta-data	 */	PHALCON_INIT_VAR(ordered_column_map);	array_init(ordered_column_map);	PHALCON_INIT_VAR(reversed_column_map);	array_init(reversed_column_map);	PHALCON_INIT_VAR(column_annot_name);	ZVAL_STRING(column_annot_name, "Column", 1);	PHALCON_INIT_VAR(column_map_name);	ZVAL_STRING(column_map_name, "column", 1);	phalcon_is_iterable(properties_annotations, &ah0, &hp0, 0, 0);	while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) {		PHALCON_GET_HKEY(property, ah0, hp0);		PHALCON_GET_HVALUE(prop_annotations);		/** 		 * All columns marked with the 'Column' annotation are considered columns		 */		PHALCON_CALL_METHOD(&has_annotation, prop_annotations, "has", column_annot_name);		if (!zend_is_true(has_annotation)) {			zend_hash_move_forward_ex(ah0, &hp0);			continue;		}		/** 		 * Fetch the 'column' annotation		 */		PHALCON_CALL_METHOD(&column_annotation, prop_annotations, "get", column_annot_name);		/** 		 * Check column map		 */		PHALCON_CALL_METHOD(&real_property, column_annotation, "getargument", column_map_name);//.........这里部分代码省略.........
开发者ID:Myleft,项目名称:cphalcon,代码行数:101,


示例18: PHP_METHOD

/** * Writes the log to the stream itself * * @param string $message * @param int $type * @param int $time * @param array $context * @see http://www.firephp.org/Wiki/Reference/Protocol */PHP_METHOD(Phalcon_Logger_Adapter_Firephp, logInternal){	zval *message, *type, *time, *context, *formatter = NULL, *applied_format = NULL;	zval *initialized, *index;	sapi_header_line h = { NULL, 0, 0 };	smart_str str      = { NULL, 0, 0 };	int size, offset;	int separate_index = 0;	size_t num_bytes;	const int chunk = 4500;	/* If headers has already been sent, we can do nothing. Exit early. */	if (SG(headers_sent)) {		RETURN_FALSE;	}	PHALCON_MM_GROW();	phalcon_fetch_params(1, 4, 0, &message, &type, &time, &context);	PHALCON_CALL_METHOD(&formatter, this_ptr, "getformatter");	initialized = phalcon_fetch_static_property_ce(phalcon_logger_adapter_firephp_ce, SL("_initialized") TSRMLS_CC);	if (!zend_is_true(initialized)) {		/**		 * Send the required initialization headers.		 * Use Zend API here so that the user can see the progress and because		 * if we delegate this to Phalcon and there will be a fatal errors,		 * chances are that the headers will never ne sent.		 */		h.line     = "X-Wf-Protocol-1: http://meta.wildfirehq.org/Protocol/JsonStream/0.2";		h.line_len = sizeof("X-Wf-Protocol-1: http://meta.wildfirehq.org/Protocol/JsonStream/0.2")-1;		sapi_header_op(SAPI_HEADER_REPLACE, &h TSRMLS_CC);		h.line     = "X-Wf-1-Plugin-1: http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3";		h.line_len = sizeof("X-Wf-1-Plugin-1: http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3")-1;		sapi_header_op(SAPI_HEADER_REPLACE, &h TSRMLS_CC);		h.line     = "X-Wf-1-Structure-1: http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1";		h.line_len = sizeof("X-Wf-1-Structure-1: http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1")-1;		sapi_header_op(SAPI_HEADER_REPLACE, &h TSRMLS_CC);		ZVAL_TRUE(initialized); /* This will also update the property because "initialized" was not separated */	}	PHALCON_CALL_METHOD(&applied_format, formatter, "format", message, type, time, context);	convert_to_string(applied_format);	index = phalcon_fetch_static_property_ce(phalcon_logger_adapter_firephp_ce, SL("_index") TSRMLS_CC);	assert(Z_TYPE_P(index) == IS_LONG);	if (Z_REFCOUNT_P(index) > 1) {		PHALCON_INIT_VAR(index);		separate_index = 1;	}	size   = Z_STRLEN_P(applied_format);	offset = 0;	/**	 * We need to send the data in chunks not exceeding 5,000 bytes.	 * Allocate the smart string once to avoid performance penalties.	 */	smart_str_alloc4(&str, (uint)(size > chunk ? chunk : size), 0, num_bytes);	while (size > 0) {		smart_str_appends(&str, "X-Wf-1-1-1-");		smart_str_append_long(&str, Z_RESVAL_P(index));		smart_str_appends(&str, ": ");		num_bytes = size > chunk ? chunk : size;		if (offset) {			/* This is not the first chunk, prepend the payload with "|" */			smart_str_appendc(&str, '|');		}		/* Grab the chunk from the encoded string */		smart_str_appendl(&str, Z_STRVAL_P(applied_format) + offset, num_bytes);		size   -= num_bytes;		offset += num_bytes;		if (size) {			/* If we have more data to send, append "|/" */			smart_str_appendl(&str, "|//", 2);		}		smart_str_0(&str); /* Not strictly necessary but just to be safe */		/* Send the result */		h.line     = str.c;//.........这里部分代码省略.........
开发者ID:unisys12,项目名称:phalcon-hhvm,代码行数:101,


示例19: zend_dfa_optimize_calls

int zend_dfa_optimize_calls(zend_op_array *op_array, zend_ssa *ssa){	zend_func_info *func_info = ZEND_FUNC_INFO(op_array);	int removed_ops = 0;	if (func_info->callee_info) {		zend_call_info *call_info = func_info->callee_info;		do {			if (call_info->caller_call_opline->opcode == ZEND_DO_ICALL			 && call_info->callee_func			 && ZSTR_LEN(call_info->callee_func->common.function_name) == sizeof("in_array")-1			 && memcmp(ZSTR_VAL(call_info->callee_func->common.function_name), "in_array", sizeof("in_array")-1) == 0			 && (call_info->caller_init_opline->extended_value == 2			  || (call_info->caller_init_opline->extended_value == 3			   && (call_info->caller_call_opline - 1)->opcode == ZEND_SEND_VAL			   && (call_info->caller_call_opline - 1)->op1_type == IS_CONST))) {				zend_op *send_array;				zend_op *send_needly;				zend_bool strict = 0;				if (call_info->caller_init_opline->extended_value == 2) {					send_array = call_info->caller_call_opline - 1;					send_needly = call_info->caller_call_opline - 2;				} else {					if (zend_is_true(CT_CONSTANT_EX(op_array, (call_info->caller_call_opline - 1)->op1.constant))) {						strict = 1;					}					send_array = call_info->caller_call_opline - 2;					send_needly = call_info->caller_call_opline - 3;				}				if (send_array->opcode == ZEND_SEND_VAL				 && send_array->op1_type == IS_CONST				 && Z_TYPE_P(CT_CONSTANT_EX(op_array, send_array->op1.constant)) == IS_ARRAY				 && (send_needly->opcode == ZEND_SEND_VAL				  || send_needly->opcode == ZEND_SEND_VAR)			    ) {					int ok = 1;					HashTable *src = Z_ARRVAL_P(CT_CONSTANT_EX(op_array, send_array->op1.constant));					HashTable *dst;					zval *val, tmp;					zend_ulong idx;					ZVAL_TRUE(&tmp);					dst = zend_new_array(zend_hash_num_elements(src));					if (strict) {						ZEND_HASH_FOREACH_VAL(src, val) {							if (Z_TYPE_P(val) == IS_STRING) {								zend_hash_add(dst, Z_STR_P(val), &tmp);							} else if (Z_TYPE_P(val) == IS_LONG) {								zend_hash_index_add(dst, Z_LVAL_P(val), &tmp);							} else {								zend_array_destroy(dst);								ok = 0;								break;							}						} ZEND_HASH_FOREACH_END();					} else {						ZEND_HASH_FOREACH_VAL(src, val) {							if (Z_TYPE_P(val) != IS_STRING || ZEND_HANDLE_NUMERIC(Z_STR_P(val), idx)) {								zend_array_destroy(dst);								ok = 0;								break;							}							zend_hash_add(dst, Z_STR_P(val), &tmp);						} ZEND_HASH_FOREACH_END();					}					if (ok) {						uint32_t op_num = send_needly - op_array->opcodes;						zend_ssa_op *ssa_op = ssa->ops + op_num;						if (ssa_op->op1_use >= 0) {							/* Reconstruct SSA */							int var_num = ssa_op->op1_use;							zend_ssa_var *var = ssa->vars + var_num;							ZEND_ASSERT(ssa_op->op1_def < 0);							zend_ssa_unlink_use_chain(ssa, op_num, ssa_op->op1_use);							ssa_op->op1_use = -1;							ssa_op->op1_use_chain = -1;							op_num = call_info->caller_call_opline - op_array->opcodes;							ssa_op = ssa->ops + op_num;							ssa_op->op1_use = var_num;							ssa_op->op1_use_chain = var->use_chain;							var->use_chain = op_num;						}						ZVAL_ARR(&tmp, dst);						/* Update opcode */						call_info->caller_call_opline->opcode = ZEND_IN_ARRAY;						call_info->caller_call_opline->extended_value = strict;						call_info->caller_call_opline->op1_type = send_needly->op1_type;						call_info->caller_call_opline->op1.num = send_needly->op1.num;						call_info->caller_call_opline->op2_type = IS_CONST;						call_info->caller_call_opline->op2.constant = zend_optimizer_add_literal(op_array, &tmp);//.........这里部分代码省略.........
开发者ID:AllenJB,项目名称:php-src,代码行数:101,


示例20: PHP_METHOD

/** * Executes validator * * @param Phalcon/Mvc/ModelInterface $record * @return boolean */PHP_METHOD(Phalcon_Mvc_Model_Validator_Inclusionin, validate){	zval *record, *field = NULL, *is_set = NULL, *domain = NULL;	zval *value = NULL, *option, *message = NULL, *joined_domain, *is_set_code = NULL, *code = NULL;	zval *type;	zval *allow_empty = NULL;	PHALCON_MM_GROW();	phalcon_fetch_params(1, 1, 0, &record);		PHALCON_INIT_VAR(option);	ZVAL_STRING(option, "field", 1);		PHALCON_CALL_METHOD(&field, this_ptr, "getoption", option);	if (Z_TYPE_P(field) != IS_STRING) {		PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Field name must be a string");		return;	}		/** 	 * The 'domain' option must be a valid array of not allowed values	 */	PHALCON_INIT_NVAR(option);	ZVAL_STRING(option, "domain", 1);		PHALCON_CALL_METHOD(&is_set, this_ptr, "issetoption", option);	if (PHALCON_IS_FALSE(is_set)) {		PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "The option 'domain' is required for this validator");		return;	}		PHALCON_INIT_NVAR(option);	ZVAL_STRING(option, "domain", 1);		PHALCON_CALL_METHOD(&domain, this_ptr, "getoption", option);	if (Z_TYPE_P(domain) != IS_ARRAY) { 		PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_model_exception_ce, "Option 'domain' must be an array");		return;	}		PHALCON_CALL_METHOD(&value, record, "readattribute", field);	/*	 * Allow empty	 */	PHALCON_INIT_NVAR(option);	ZVAL_STRING(option, "allowEmpty", 1);	PHALCON_CALL_METHOD(&allow_empty, this_ptr, "getoption", option);	if (allow_empty && zend_is_true(allow_empty) && PHALCON_IS_EMPTY(value)) {		RETURN_MM_TRUE;	}		/*	 * Allow empty	 */	PHALCON_INIT_NVAR(option);	ZVAL_STRING(option, "allowEmpty", 1);	PHALCON_CALL_METHOD(&allow_empty, this_ptr, "getoption", option);	if (allow_empty && zend_is_true(allow_empty)) {		if (PHALCON_IS_EMPTY(value)) {			RETURN_MM_TRUE;		}	}		/** 	 * Check if the value is contained in the array	 */	if (!phalcon_fast_in_array(value, domain TSRMLS_CC)) {			/** 		 * Check if the developer has defined a custom message		 */		PHALCON_INIT_NVAR(option);		PHALCON_ZVAL_MAYBE_INTERNED_STRING(option, phalcon_interned_message);			PHALCON_CALL_METHOD(&message, this_ptr, "getoption", option);		if (!zend_is_true(message)) {			PHALCON_INIT_VAR(joined_domain);			phalcon_fast_join_str(joined_domain, SL(", "), domain TSRMLS_CC);				PHALCON_INIT_NVAR(message);			PHALCON_CONCAT_SVSV(message, "Value of field '", field, "' must be part of list: ", joined_domain);		}			PHALCON_INIT_VAR(type);		ZVAL_STRING(type, "Inclusion", 1);		/*		 * Is code set		 *///.........这里部分代码省略.........
开发者ID:Myleft,项目名称:cphalcon,代码行数:101,


示例21: PHP_METHOD

/** * Handle the whole command-line tasks * * @param array $arguments * @return mixed */PHP_METHOD(Phalcon_CLI_Console, handle){	zval *arguments = NULL, *dependency_injector, *events_manager;	zval *service = NULL, *router, *module_name, *event_name = NULL;	zval *status = NULL, *modules, *exception_msg = NULL, *module;	zval *path, *class_name = NULL, *module_object, *task_name;	zval *action_name, *params, *dispatcher, *task;	int eval_int;	PHALCON_MM_GROW();	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &arguments) == FAILURE) {		PHALCON_MM_RESTORE();		RETURN_NULL();	}	if (!arguments) {		PHALCON_INIT_NVAR(arguments);		array_init(arguments);	}		PHALCON_INIT_VAR(dependency_injector);	phalcon_read_property(&dependency_injector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC);	if (Z_TYPE_P(dependency_injector) != IS_OBJECT) {		PHALCON_THROW_EXCEPTION_STR(phalcon_cli_console_exception_ce, "A dependency injection object is required to access internal services");		return;	}		PHALCON_INIT_VAR(events_manager);	phalcon_read_property(&events_manager, this_ptr, SL("_eventsManager"), PH_NOISY_CC);		PHALCON_INIT_VAR(service);	ZVAL_STRING(service, "router", 1);		PHALCON_INIT_VAR(router);	PHALCON_CALL_METHOD_PARAMS_1(router, dependency_injector, "getshared", service, PH_NO_CHECK);	PHALCON_CALL_METHOD_PARAMS_1_NORETURN(router, "handle", arguments, PH_NO_CHECK);		PHALCON_INIT_VAR(module_name);	PHALCON_CALL_METHOD(module_name, router, "getmodulename", PH_NO_CHECK);	if (zend_is_true(module_name)) {		if (Z_TYPE_P(events_manager) == IS_OBJECT) {			PHALCON_INIT_VAR(event_name);			ZVAL_STRING(event_name, "console:beforeStartModule", 1);				PHALCON_INIT_VAR(status);			PHALCON_CALL_METHOD_PARAMS_3(status, events_manager, "fire", event_name, this_ptr, module_name, PH_NO_CHECK);			if (PHALCON_IS_FALSE(status)) {				PHALCON_MM_RESTORE();				RETURN_FALSE;			}		}			PHALCON_INIT_VAR(modules);		phalcon_read_property(&modules, this_ptr, SL("_modules"), PH_NOISY_CC);		eval_int = phalcon_array_isset(modules, module_name);		if (!eval_int) {			PHALCON_INIT_VAR(exception_msg);			PHALCON_CONCAT_SVS(exception_msg, "Module '", module_name, "' isn't registered in the console container");			PHALCON_THROW_EXCEPTION_ZVAL(phalcon_cli_console_exception_ce, exception_msg);			return;		}			PHALCON_INIT_VAR(module);		phalcon_array_fetch(&module, modules, module_name, PH_NOISY_CC);		if (Z_TYPE_P(module) != IS_ARRAY) { 			PHALCON_THROW_EXCEPTION_STR(phalcon_cli_console_exception_ce, "Invalid module definition path");			return;		}			eval_int = phalcon_array_isset_string(module, SS("path"));		if (eval_int) {			PHALCON_INIT_VAR(path);			phalcon_array_fetch_string(&path, module, SL("path"), PH_NOISY_CC);			if (phalcon_file_exists(path TSRMLS_CC) == SUCCESS) {				if (phalcon_require(path TSRMLS_CC) == FAILURE) {					return;				}			} else {				PHALCON_INIT_NVAR(exception_msg);				PHALCON_CONCAT_SVS(exception_msg, "Module definition path '", path, "/" doesn't exist");				PHALCON_THROW_EXCEPTION_ZVAL(phalcon_cli_console_exception_ce, exception_msg);				return;			}		}			eval_int = phalcon_array_isset_string(module, SS("className"));		if (eval_int) {			PHALCON_INIT_VAR(class_name);			phalcon_array_fetch_string(&class_name, module, SL("className"), PH_NOISY_CC);		} else {			PHALCON_INIT_NVAR(class_name);			ZVAL_STRING(class_name, "Module", 1);		}//.........这里部分代码省略.........
开发者ID:Tigerlee1987,项目名称:cphalcon,代码行数:101,


示例22: PHP_METHOD

/** * Builds a SELECT statement * * @param array $definition * @return string */PHP_METHOD(Phalcon_Db_Dialect, select){	zval *definition, *escape_char = NULL, *columns, *selected_columns, *distinct;	zval *column = NULL, *column_sql = NULL;	zval *column_domain_sql = NULL, *column_alias_sql = NULL;	zval *columns_sql = NULL, *tables, *selected_tables;	zval *table = NULL, *sql_table = NULL, *tables_sql = NULL, *sql, *joins;	zval *join = NULL, *type = NULL, *sql_join = NULL, *join_conditions_array = NULL;	zval *join_expressions = NULL, *join_condition = NULL, *join_expression = NULL;	zval *join_conditions = NULL, *where_conditions;	zval *where_expression = NULL, *group_items, *group_fields;	zval *group_field = NULL, *group_expression = NULL, *group_sql;	zval *group_clause, *having_conditions, *having_expression = NULL;	zval *order_fields, *order_items, *order_item = NULL;	zval *order_expression = NULL, *order_sql_item = NULL, *sql_order_type = NULL;	zval *order_sql_item_type = NULL, *order_sql, *tmp1 = NULL, *tmp2 = NULL;	zval *limit_value;	zval *number, *offset;	HashTable *ah0, *ah1, *ah2, *ah3, *ah4, *ah5;	HashPosition hp0, hp1, hp2, hp3, hp4, hp5;	zval **hd;	PHALCON_MM_GROW();	phalcon_fetch_params(1, 1, 0, &definition);	if (Z_TYPE_P(definition) != IS_ARRAY) { 		PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Invalid SELECT definition");		return;	}	if (!phalcon_array_isset_string(definition, SS("tables"))) {		PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "The index 'tables' is required in the definition array");		return;	}		if (!phalcon_array_isset_string_fetch(&columns, definition, SS("columns"))) {		PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "The index 'columns' is required in the definition array");		return;	}		if (PHALCON_GLOBAL(db).escape_identifiers) {		PHALCON_OBS_VAR(escape_char);		phalcon_read_property_this(&escape_char, this_ptr, SL("_escapeChar"), PH_NOISY TSRMLS_CC);	} else {		PHALCON_INIT_NVAR(escape_char);	}		if (Z_TYPE_P(columns) == IS_ARRAY) { 			PHALCON_INIT_VAR(selected_columns);		array_init(selected_columns);			phalcon_is_iterable(columns, &ah0, &hp0, 0, 0);			while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) {			zval *column_item, *column_alias, *column_domain;				PHALCON_GET_HVALUE(column);				/** 			 * Escape column name			 */			if (				    phalcon_array_isset_long_fetch(&column_item, column, 0)				 || phalcon_array_isset_string_fetch(&column_item, column, SS("column"))			) {				if (Z_TYPE_P(column_item) == IS_ARRAY) {					PHALCON_CALL_METHOD(&column_sql, this_ptr, "getsqlexpression", column_item, escape_char);				} else if (PHALCON_IS_STRING(column_item, "*")) {					PHALCON_CPY_WRT(column_sql, column_item);				} else if (PHALCON_GLOBAL(db).escape_identifiers) {					PHALCON_INIT_NVAR(column_sql);					PHALCON_CONCAT_VVV(column_sql, escape_char, column_item, escape_char);				} else {					PHALCON_CPY_WRT(column_sql, column_item);				}			}			else {				PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Invalid SELECT definition");				return;			}				/** 			 * Escape column domain			 */			if (phalcon_array_isset_long_fetch(&column_domain, column, 1)) {				if (zend_is_true(column_domain)) {					if (PHALCON_GLOBAL(db).escape_identifiers) {						PHALCON_INIT_NVAR(column_domain_sql);						PHALCON_CONCAT_VVVSV(column_domain_sql, escape_char, column_domain, escape_char, ".", column_sql);					} else {						PHALCON_INIT_NVAR(column_domain_sql);						PHALCON_CONCAT_VSV(column_domain_sql, column_domain, ".", column_sql);					}//.........这里部分代码省略.........
开发者ID:9466,项目名称:cphalcon,代码行数:101,


示例23: PHP_METHOD

/** * Returns a slice of the resultset to show in the pagination * * @return stdClass */PHP_METHOD(Phalcon_Paginator_Adapter_NativeArray, getPaginate){	zval *one, *config, *items, *show, *page_number = NULL, *page;	zval *number, *rounded_total, *total_pages, *before_page_number;	zval *start, *slice, *compare = NULL, *next = NULL, *before = NULL;	PHALCON_MM_GROW();	/** 	 * TODO: Rewrite the whole method!	 */	PHALCON_INIT_VAR(one);	ZVAL_LONG(one, 1);		PHALCON_OBS_VAR(config);	phalcon_read_property_this(&config, this_ptr, SL("_config"), PH_NOISY_CC);		PHALCON_OBS_VAR(items);	phalcon_array_fetch_string(&items, config, SL("data"), PH_NOISY_CC);	if (Z_TYPE_P(items) != IS_ARRAY) { 		PHALCON_THROW_EXCEPTION_STR(phalcon_paginator_exception_ce, "Invalid data for paginator");		return;	}		PHALCON_OBS_VAR(show);	phalcon_read_property_this(&show, this_ptr, SL("_limitRows"), PH_NOISY_CC);		PHALCON_OBS_VAR(page_number);	phalcon_read_property_this(&page_number, this_ptr, SL("_page"), PH_NOISY_CC);	if (!zend_is_true(page_number)) {		PHALCON_CPY_WRT(page_number, one);	}		PHALCON_INIT_VAR(page);	object_init(page);		PHALCON_INIT_VAR(number);	phalcon_fast_count(number, items TSRMLS_CC);		PHALCON_INIT_VAR(rounded_total);	div_function(rounded_total, number, show TSRMLS_CC);		PHALCON_INIT_VAR(total_pages);	PHALCON_CALL_FUNC_PARAMS_1(total_pages, "intval", rounded_total);		/** 	 * Increase total_pages if wasn't integer	 */	if (!PHALCON_IS_EQUAL(total_pages, rounded_total)) {		PHALCON_SEPARATE_NMO(total_pages);		increment_function(total_pages);	}		PHALCON_INIT_VAR(before_page_number);	sub_function(before_page_number, page_number, one TSRMLS_CC);		PHALCON_INIT_VAR(start);	mul_function(start, show, before_page_number TSRMLS_CC);		PHALCON_INIT_VAR(slice);	PHALCON_CALL_FUNC_PARAMS_3(slice, "array_slice", items, start, show);	phalcon_update_property_zval(page, SL("items"), slice TSRMLS_CC);		PHALCON_INIT_VAR(compare);	is_smaller_function(compare, page_number, total_pages TSRMLS_CC);	if (PHALCON_IS_TRUE(compare)) {		PHALCON_INIT_VAR(next);		phalcon_add_function(next, page_number, one TSRMLS_CC);	} else {		PHALCON_CPY_WRT(next, total_pages);	}		phalcon_update_property_zval(page, SL("next"), next TSRMLS_CC);		is_smaller_function(compare, one, page_number TSRMLS_CC);	if (PHALCON_IS_TRUE(compare)) {		PHALCON_INIT_VAR(before);		sub_function(before, page_number, one TSRMLS_CC);	} else {		PHALCON_CPY_WRT(before, one);	}		phalcon_update_property_zval(page, SL("first"), one TSRMLS_CC);	phalcon_update_property_zval(page, SL("before"), before TSRMLS_CC);	phalcon_update_property_zval(page, SL("current"), page_number TSRMLS_CC);	phalcon_update_property_zval(page, SL("last"), total_pages TSRMLS_CC);	phalcon_update_property_zval(page, SL("total_pages"), total_pages TSRMLS_CC);	phalcon_update_property_zval(page, SL("total_items"), number TSRMLS_CC);		RETURN_CTOR(page);}
开发者ID:angkatan21,项目名称:cphalcon,代码行数:96,


示例24: PHP_METHOD

/**  * Commits the internal transaction  *  */PHP_METHOD(Phalcon_Logger_Adapter_File, commit){	zval *transaction = NULL, *file_handler = NULL, *quenue = NULL, *message = NULL;	zval *message_str = NULL, *type = NULL, *time = NULL, *applied_format = NULL;	zval *applied_eol = NULL;	zval *t0 = NULL;	HashTable *ah0;	HashPosition hp0;	zval **hd;	PHALCON_MM_GROW();	PHALCON_INIT_VAR(transaction);	phalcon_read_property(&transaction, this_ptr, SL("_transaction"), PH_NOISY_CC);	if (!zend_is_true(transaction)) {		PHALCON_THROW_EXCEPTION_STR(phalcon_logger_exception_ce, "There is no active transaction");		return;	}		phalcon_update_property_bool(this_ptr, SL("_transaction"), 0 TSRMLS_CC);		PHALCON_INIT_VAR(file_handler);	phalcon_read_property(&file_handler, this_ptr, SL("_fileHandler"), PH_NOISY_CC);		PHALCON_INIT_VAR(quenue);	phalcon_read_property(&quenue, this_ptr, SL("_quenue"), PH_NOISY_CC);	if (!phalcon_valid_foreach(quenue TSRMLS_CC)) {		return;	}		ah0 = Z_ARRVAL_P(quenue);	zend_hash_internal_pointer_reset_ex(ah0, &hp0);	fes_654f_1:		if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){			goto fee_654f_1;		}				PHALCON_INIT_VAR(message);		ZVAL_ZVAL(message, *hd, 1, 0);		PHALCON_INIT_VAR(message_str);		PHALCON_CALL_METHOD(message_str, message, "getmessage", PH_NO_CHECK);				PHALCON_INIT_VAR(type);		PHALCON_CALL_METHOD(type, message, "gettype", PH_NO_CHECK);				PHALCON_INIT_VAR(time);		PHALCON_CALL_METHOD(time, message, "gettime", PH_NO_CHECK);				PHALCON_INIT_VAR(applied_format);		PHALCON_CALL_METHOD_PARAMS_3(applied_format, this_ptr, "_applyformat", message_str, type, time, PH_NO_CHECK);				PHALCON_INIT_VAR(t0);		zend_get_constant(SL("PHP_EOL"), t0 TSRMLS_CC);				PHALCON_INIT_VAR(applied_eol);		PHALCON_CONCAT_VV(applied_eol, applied_format, t0);		PHALCON_CALL_FUNC_PARAMS_2_NORETURN("fputs", file_handler, applied_eol);		zend_hash_move_forward_ex(ah0, &hp0);		goto fes_654f_1;	fee_654f_1:	if(0){}			PHALCON_MM_RESTORE();}
开发者ID:codeanu,项目名称:cphalcon,代码行数:68,


示例25: PHP_METHOD

//.........这里部分代码省略.........		PHALCON_OBS_VAR(jsonrpc_method);		phalcon_array_fetch_str(&jsonrpc_method, data, SL("method"), PH_NOISY);		if (phalcon_array_isset_str(data, SL("params"))) {			PHALCON_OBS_VAR(jsonrpc_params);			phalcon_array_fetch_str(&jsonrpc_params, data, SL("params"), PH_NOISY);		} else {			PHALCON_INIT_VAR(jsonrpc_params);			array_init(jsonrpc_params);		}		PHALCON_INIT_NVAR(service);		ZVAL_STR(service, IS(url));		PHALCON_CALL_METHOD(&url, dependency_injector, "getshared", service);		PHALCON_VERIFY_INTERFACE(url, phalcon_mvc_urlinterface_ce);		PHALCON_CALL_METHOD(&uri, url, "get", jsonrpc_method);		PHALCON_INIT_NVAR(service);		ZVAL_STR(service, IS(router));		PHALCON_CALL_METHOD(&router, dependency_injector, "getshared", service);		PHALCON_VERIFY_INTERFACE(router, phalcon_mvc_routerinterface_ce);		/* Handle the URI pattern (if any) */		PHALCON_CALL_METHOD(NULL, router, "handle", uri);				/* Load module config */		PHALCON_CALL_METHOD(&module_name, router, "getmodulename");		/* Load module config */		PHALCON_CALL_METHOD(&module_name, router, "getmodulename");				/* If the router doesn't return a valid module we use the default module */		if (!zend_is_true(module_name)) {			module_name = phalcon_read_property(getThis(), SL("_defaultModule"), PH_NOISY);		}				/** 		 * Process the module definition		 */		if (zend_is_true(module_name)) {			if (FAILURE == phalcon_mvc_jsonrpc_fire_event(events_manager, "jsonrpc:beforeStartModule", getThis(), module_name)) {				RETURN_MM_FALSE;			}			/** 			 * Check if the module passed by the router is registered in the modules container			 */			modules = phalcon_read_property(getThis(), SL("_modules"), PH_NOISY);			if (!phalcon_array_isset_fetch(&module, modules, module_name)) {				convert_to_string(module_name);				zend_throw_exception_ex(phalcon_mvc_jsonrpc_exception_ce, 0, "Module %s is not registered in the jsonrpc container", Z_STRVAL_P(module_name));				RETURN_MM();			}					/** 			 * A module definition must be an array or an object			 */			if (Z_TYPE_P(module) != IS_ARRAY && Z_TYPE_P(module) != IS_OBJECT) {				PHALCON_THROW_EXCEPTION_STR(phalcon_mvc_jsonrpc_exception_ce, "Invalid module definition");				return;			}					/* An array module definition contains a path to a module definition class */			if (Z_TYPE_P(module) == IS_ARRAY) { 				/* Class name used to load the module definition */
开发者ID:Myleft,项目名称:cphalcon7,代码行数:67,



注:本文中的zend_is_true函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ zend_make_printable_zval函数代码示例
C++ zend_hash_str_find函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。