本文整理汇总了C++中RETVAL_ZVAL函数的典型用法代码示例。如果您正苦于以下问题:C++ RETVAL_ZVAL函数的具体用法?C++ RETVAL_ZVAL怎么用?C++ RETVAL_ZVAL使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RETVAL_ZVAL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PHP_METHOD
/**
* Validates a value against the class constants.
*
* If value is a valid constant name, returns the corresponding value.
*
* If value is null and a default is set, returns the default value.
*
* @param mixed value
*
* @return mixed
*
* @throws \RuntimeException if value is null and no default exists, or if given an invalid value.
*/
PHP_METHOD(Xpl_Enum, filterValidateValue) {
int ZEPHIR_LAST_CALL_STATUS;
zval *value = NULL, *reflection = NULL, *constants = NULL, *_0, *_2 = NULL, *_1$$6;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 0, 1, &value);
if (!value) {
ZEPHIR_CPY_WRT(value, ZEPHIR_GLOBAL(global_null));
} else {
ZEPHIR_SEPARATE_PARAM(value);
}
ZEPHIR_INIT_VAR(reflection);
object_init_ex(reflection, zephir_get_internal_ce(SS("reflectionclass") TSRMLS_CC));
ZEPHIR_INIT_VAR(_0);
zephir_get_class(_0, this_ptr, 0 TSRMLS_CC);
ZEPHIR_CALL_METHOD(NULL, reflection, "__construct", NULL, 63, _0);
zephir_check_call_status();
ZEPHIR_CALL_METHOD(&constants, reflection, "getconstants", NULL, 100);
zephir_check_call_status();
if (Z_TYPE_P(value) == IS_NULL) {
ZEPHIR_OBS_NVAR(value);
if (zephir_array_isset_string_fetch(&value, constants, SS("_default"), 0 TSRMLS_CC)) {
RETVAL_ZVAL(value, 1, 0);
RETURN_MM();
}
ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_RuntimeException, "Missing value: no default exists", "xpl/enum.zep", 177);
return;
}
if (Z_TYPE_P(value) == IS_STRING) {
if (zephir_array_isset(constants, value)) {
zephir_array_fetch(&_1$$6, constants, value, PH_NOISY | PH_READONLY, "xpl/enum.zep", 183 TSRMLS_CC);
ZEPHIR_CPY_WRT(value, _1$$6);
}
if ((zephir_method_exists(this_ptr, value TSRMLS_CC) == SUCCESS)) {
ZEPHIR_RETURN_CALL_METHOD_ZVAL(this_ptr, value, NULL, 0);
zephir_check_call_status();
RETURN_MM();
}
}
ZEPHIR_CALL_FUNCTION(&_2, "in_array", NULL, 2, value, constants, ZEPHIR_GLOBAL(global_true));
zephir_check_call_status();
if (!(zephir_is_true(_2))) {
ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_RuntimeException, "Invalid enum value", "xpl/enum.zep", 193);
return;
}
RETVAL_ZVAL(value, 1, 0);
RETURN_MM();
}
示例2: function
/*
* This is PHP code snippet handling extend()s calls :
$extended = function ($c) use ($callable, $factory) {
return $callable($factory($c), $c);
};
*/
PHP_METHOD(PimpleClosure, invoker)
{
zval *arg = NULL, retval = {0}, newretval = {0};
zend_fcall_info fci = {0};
zval args[2];
FETCH_CUSTOM_OBJ_THIS(pimple_closure_object)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &arg) == FAILURE) {
OBJ_RELEASE((zend_object*)execute_data->func->common.prototype);
return;
}
ZVAL_COPY_VALUE(&args[0], arg);
fci.function_name = obj->factory;
fci.params = args;
fci.param_count = 1;
fci.retval = &retval;
fci.size = sizeof(fci);
if (zend_call_function(&fci, NULL) == FAILURE || EG(exception)) {
OBJ_RELEASE((zend_object*)execute_data->func->common.prototype);
RETVAL_ZVAL(&EG(uninitialized_zval), 1, 0);
return;
}
memset(&fci, 0, sizeof(fci));
fci.size = sizeof(fci);
ZVAL_COPY_VALUE(&args[0], &retval);
ZVAL_COPY_VALUE(&args[1], arg);
fci.function_name = obj->callable;
fci.params = args;
fci.param_count = 2;
fci.retval = &newretval;
if (zend_call_function(&fci, NULL) == FAILURE || EG(exception)) {
zval_ptr_dtor(&retval);
OBJ_RELEASE((zend_object*)execute_data->func->common.prototype);
RETVAL_ZVAL(&EG(uninitialized_zval), 1, 0);
return;
}
zval_ptr_dtor(&retval);
RETVAL_ZVAL(&newretval, 0 ,0);
OBJ_RELEASE((zend_object*)execute_data->func->common.prototype);
}
示例3: PHP_METHOD
/* {{{ MongoDate::toDateTime()
* Returns a DateTime object with the same information as the MongoDate object */
PHP_METHOD(MongoDate, toDateTime)
{
mongo_date *date;
int64_t sec;
int64_t usec;
double dusec;
char *str;
int str_len;
zval datetime_object;
php_date_obj *datetime_obj;
zval *datetime_object_ptr = &datetime_object;
date = (mongo_date*) zend_object_store_get_object(getThis() TSRMLS_CC);
php_date_instantiate(php_date_get_date_ce(), &datetime_object TSRMLS_CC);
mongo_date_to_parts(date, &sec, &usec, &dusec);
#ifdef WIN32
str_len = spprintf(&str, 0, "@%I64d", (int64_t) sec);
#else
str_len = spprintf(&str, 0, "@%lld", (long long int) sec);
#endif
datetime_obj = zend_object_store_get_object(&datetime_object TSRMLS_CC);
php_date_initialize(datetime_obj, str, str_len, NULL, NULL, 0 TSRMLS_CC);
efree(str);
datetime_obj->time->f = dusec;
RETVAL_ZVAL(datetime_object_ptr, 0, 0);
}
示例4: PHP_METHOD
PHP_METHOD(MongoDB, repair)
{
zend_bool cloned=0, original=0;
zval *cmd, *retval;
mongo_db *db;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|bb", &cloned, &original) == FAILURE) {
return;
}
PHP_MONGO_GET_DB(getThis());
MAKE_STD_ZVAL(cmd);
array_init(cmd);
add_assoc_long(cmd, "repairDatabase", 1);
add_assoc_bool(cmd, "preserveClonedFilesOnFailure", cloned);
add_assoc_bool(cmd, "backupOriginalFiles", original);
retval = php_mongo_runcommand(db->link, &db->read_pref, Z_STRVAL_P(db->name), Z_STRLEN_P(db->name), cmd, NULL, 0, NULL TSRMLS_CC);
zval_ptr_dtor(&cmd);
if (retval) {
RETVAL_ZVAL(retval, 0, 1);
}
}
示例5: PHP_METHOD
/**
* Returns a cached content
*
* @param string $keyName
* @param long $lifetime
* @return mixed
*/
PHP_METHOD(Phalcon_Cache_Backend_Memory, get){
zval *key_name, *lifetime = NULL;
zval *data, *cached_content, *frontend, *last_key;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 1, 1, &key_name, &lifetime);
if (Z_TYPE_P(key_name) == IS_NULL) {
last_key = phalcon_fetch_nproperty_this(this_ptr, SL("_lastKey"), PH_NOISY TSRMLS_CC);
} else {
zval *prefix = phalcon_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY TSRMLS_CC);
PHALCON_INIT_VAR(last_key);
PHALCON_CONCAT_VV(last_key, prefix, key_name);
phalcon_update_property_this(this_ptr, SL("_lastKey"), last_key TSRMLS_CC);
}
data = phalcon_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY TSRMLS_CC);
if (phalcon_array_isset_fetch(&cached_content, data, last_key)) {
if (Z_TYPE_P(cached_content) != IS_NULL) {
if (phalcon_is_numeric(cached_content)) {
RETVAL_ZVAL(cached_content, 1, 0);
} else {
frontend = phalcon_fetch_nproperty_this(this_ptr, SL("_frontend"), PH_NOISY TSRMLS_CC);
PHALCON_RETURN_CALL_METHOD(frontend, "afterretrieve", cached_content);
}
}
}
PHALCON_MM_RESTORE();
}
示例6: PHP_METHOD
/**
* Escapes a string with htmlentities
*/
PHP_METHOD(Phalcon_Debug, _escapeString) {
int ZEPHIR_LAST_CALL_STATUS;
zephir_nts_static zephir_fcall_cache_entry *_5 = NULL;
zval *value, *_0, _1, _2, _3, _4;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 1, 0, &value);
if (Z_TYPE_P(value) == IS_STRING) {
ZEPHIR_INIT_VAR(_0);
ZEPHIR_SINIT_VAR(_1);
ZVAL_STRING(&_1, "\n", 0);
ZEPHIR_SINIT_VAR(_2);
ZVAL_STRING(&_2, "\\n", 0);
zephir_fast_str_replace(&_0, &_1, &_2, value TSRMLS_CC);
ZEPHIR_SINIT_VAR(_3);
ZVAL_LONG(&_3, 2);
ZEPHIR_SINIT_VAR(_4);
ZVAL_STRING(&_4, "utf-8", 0);
ZEPHIR_RETURN_CALL_FUNCTION("htmlentities", &_5, _0, &_3, &_4);
zephir_check_call_status();
RETURN_MM();
}
RETVAL_ZVAL(value, 1, 0);
RETURN_MM();
}
示例7: PHP_METHOD
/* {{{ proto Riak\BucketPropertyList Riak\Bucket->getPropertyList()
Fetch and return a RiakBucketProperties object with properties for this bucket */
PHP_METHOD(RiakBucket, getPropertyList)
{
riak_connection *connection;
RIACK_STRING bucketName;
uint32_t nVal = 3;
uint8_t allowMult = 0;
int riackResult;
zval *zBucketProps, *zAllowMult, *zNVal;
GET_RIAK_CONNECTION_RETURN_EXC_ON_ERROR(connection)
bucketName = riack_name_from_bucket(getThis() TSRMLS_CC);
riackResult = riack_get_bucket_props(connection->client, bucketName, &nVal, &allowMult);
CHECK_RIACK_STATUS_THROW_AND_RETURN_ON_ERROR(connection, riackResult);
MAKE_STD_ZVAL(zNVal);
ZVAL_LONG(zNVal, nVal);
MAKE_STD_ZVAL(zAllowMult);
ZVAL_BOOL(zAllowMult, allowMult);
MAKE_STD_ZVAL(zBucketProps);
object_init_ex(zBucketProps, riak_bucket_properties_ce);
RIAK_CALL_METHOD2(RiakBucketProperties, __construct, zBucketProps, zBucketProps, zNVal, zAllowMult);
RETVAL_ZVAL(zBucketProps, 0, 1);
zval_ptr_dtor(&zNVal);
zval_ptr_dtor(&zAllowMult);
}
示例8: PHP_METHOD
/**
* Returns an option
*/
PHP_METHOD(Phalcon_Mvc_Model_Validator, getOption) {
zval *option_param = NULL, *defaultValue = NULL, *options, *value;
zval *option = NULL;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 1, 1, &option_param, &defaultValue);
if (unlikely(Z_TYPE_P(option_param) != IS_STRING && Z_TYPE_P(option_param) != IS_NULL)) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'option' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
if (likely(Z_TYPE_P(option_param) == IS_STRING)) {
zephir_get_strval(option, option_param);
} else {
ZEPHIR_INIT_VAR(option);
ZVAL_EMPTY_STRING(option);
}
if (!defaultValue) {
ZEPHIR_INIT_VAR(defaultValue);
ZVAL_STRING(defaultValue, "", 1);
}
options = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC);
if (zephir_array_isset_fetch(&value, options, option, 1 TSRMLS_CC)) {
RETURN_CTOR(value);
}
RETVAL_ZVAL(defaultValue, 1, 0);
RETURN_MM();
}
示例9: PHP_METHOD
PHP_METHOD(Phalcon_Debug, getFileLink) {
zval **file, **line, **format;
phalcon_fetch_params_ex(3, 0, &file, &line, &format);
PHALCON_ENSURE_IS_STRING(file);
PHALCON_ENSURE_IS_STRING(line);
if (Z_TYPE_PP(format) == IS_STRING) {
char *tmp, *link;
int tmp_len, link_len;
zval z_link = zval_used_for_init;
tmp = php_str_to_str_ex(Z_STRVAL_PP(format), Z_STRLEN_PP(format), SL("%f"), Z_STRVAL_PP(file), Z_STRLEN_PP(file), &tmp_len, 1, NULL);
link = php_str_to_str_ex(tmp, tmp_len, SL("%l"), Z_STRVAL_PP(line), Z_STRLEN_PP(line), &link_len, 1, NULL);
ZVAL_STRINGL(&z_link, link, link_len, 0);
efree(tmp);
PHALCON_CONCAT_SVSVS(return_value, "<a href=\"", &z_link, "\">", *file, "</a>");
efree(link);
}
else {
RETVAL_ZVAL(*file, 1, 0);
}
}
示例10: PHP_METHOD
/**
* Get an action parameter
*
* @param string $key
* @param mixed $default Default value to use if key not found
* @return mixed
*/
PHP_METHOD(Yaf_Request_Abstract, getParam) {
zval *_0 = NULL;
zval *name = NULL, *tmpDefault = NULL, *_1, *_2, *_3;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 1, 1, &name, &tmpDefault);
ZEPHIR_SEPARATE_PARAM(name);
if (!tmpDefault) {
tmpDefault = ZEPHIR_GLOBAL(global_null);
}
zephir_get_strval(_0, name);
ZEPHIR_CPY_WRT(name, _0);
_1 = zephir_fetch_nproperty_this(this_ptr, SL("params"), PH_NOISY_CC);
if (zephir_array_isset(_1, name)) {
_2 = zephir_fetch_nproperty_this(this_ptr, SL("params"), PH_NOISY_CC);
zephir_array_fetch(&_3, _2, name, PH_NOISY | PH_READONLY, "yaf/request_abstract.zep", 196 TSRMLS_CC);
RETURN_CTOR(_3);
}
RETVAL_ZVAL(tmpDefault, 1, 0);
RETURN_MM();
}
示例11: PHP_METHOD
/**
* Escapes a column/table/schema name
*
* @param string|array identifier
* @return string
*/
PHP_METHOD(Phalcon_Db_Adapter_Pdo_Mysql, escapeIdentifier) {
zval *identifier, *domain, *name;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 1, 0, &identifier);
if (Z_TYPE_P(identifier) == IS_ARRAY) {
ZEPHIR_OBS_VAR(domain);
zephir_array_fetch_long(&domain, identifier, 0, PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 63 TSRMLS_CC);
ZEPHIR_OBS_VAR(name);
zephir_array_fetch_long(&name, identifier, 1, PH_NOISY, "phalcon/db/adapter/pdo/mysql.zep", 64 TSRMLS_CC);
if (ZEPHIR_GLOBAL(db).escape_identifiers) {
ZEPHIR_CONCAT_SVSVS(return_value, "`", domain, "`.`", name, "`");
RETURN_MM();
}
ZEPHIR_CONCAT_VSV(return_value, domain, ".", name);
RETURN_MM();
}
if (ZEPHIR_GLOBAL(db).escape_identifiers) {
ZEPHIR_CONCAT_SVS(return_value, "`", identifier, "`");
RETURN_MM();
}
RETVAL_ZVAL(identifier, 1, 0);
RETURN_MM();
}
示例12: PHP_METHOD
/**
* Gets an attribute from the configuration, if the attribute isn't defined returns null
* If the value is exactly null or is not defined the default value will be used instead
*
*<code>
* echo $config->get('controllersDir', '../app/controllers/');
*</code>
*/
PHP_METHOD(Phalcon_Config, get) {
int ZEPHIR_LAST_CALL_STATUS;
zval *index = NULL, *defaultValue = NULL, *_0 = NULL, *_1;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 1, 1, &index, &defaultValue);
ZEPHIR_SEPARATE_PARAM(index);
if (!defaultValue) {
defaultValue = ZEPHIR_GLOBAL(global_null);
}
ZEPHIR_CALL_FUNCTION(&_0, "strval", NULL, 20, index);
zephir_check_call_status();
ZEPHIR_CPY_WRT(index, _0);
if (zephir_isset_property_zval(this_ptr, index TSRMLS_CC)) {
ZEPHIR_OBS_VAR(_1);
zephir_read_property_zval(&_1, this_ptr, index, PH_NOISY_CC);
RETURN_CCTOR(_1);
}
RETVAL_ZVAL(defaultValue, 1, 0);
RETURN_MM();
}
示例13: PHP_METHOD
/**
* Get label for field
*
* @param string field
* @return string
*/
PHP_METHOD(Phalcon_Validation, getLabel) {
zend_bool _0;
zval *field, *labels = NULL, *value = NULL;
zephir_fetch_params(0, 1, 0, &field);
labels = zephir_fetch_nproperty_this(this_ptr, SL("_labels"), PH_NOISY_CC);
_0 = Z_TYPE_P(labels) == IS_ARRAY;
if (_0) {
_0 = Z_TYPE_P(field) != IS_ARRAY;
}
if (_0) {
if (zephir_array_isset_fetch(&value, labels, field, 1 TSRMLS_CC)) {
RETURN_CTORW(value);
}
} else if (Z_TYPE_P(field) == IS_ARRAY) {
zephir_fast_join_str(return_value, SL(", "), field TSRMLS_CC);
return;
}
RETVAL_ZVAL(field, 1, 0);
return;
}
示例14: PHP_METHOD
PHP_METHOD(MongoDB, setProfilingLevel) {
long level;
zval *data, *cmd_return;
zval **ok;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &level) == FAILURE) {
return;
}
MAKE_STD_ZVAL(data);
array_init(data);
add_assoc_long(data, "profile", level);
MAKE_STD_ZVAL(cmd_return);
MONGO_CMD(cmd_return, getThis());
zval_ptr_dtor(&data);
if (EG(exception)) {
zval_ptr_dtor(&cmd_return);
return;
}
if (zend_hash_find(HASH_P(cmd_return), "ok", 3, (void**)&ok) == SUCCESS &&
((Z_TYPE_PP(ok) == IS_BOOL && Z_BVAL_PP(ok)) || Z_DVAL_PP(ok) == 1)) {
zend_hash_find(HASH_P(cmd_return), "was", 4, (void**)&ok);
RETVAL_ZVAL(*ok, 1, 0);
}
else {
RETVAL_NULL();
}
zval_ptr_dtor(&cmd_return);
}
示例15: PHP_METHOD
/**
* Sets a service using a raw Phalcon\Di\Service definition
*/
PHP_METHOD(Phalcon_Di, setRaw) {
zval *name_param = NULL, *rawDefinition;
zval *name = NULL;
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 2, 0, &name_param, &rawDefinition);
if (unlikely(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) {
zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be a string") TSRMLS_CC);
RETURN_MM_NULL();
}
if (likely(Z_TYPE_P(name_param) == IS_STRING)) {
zephir_get_strval(name, name_param);
} else {
ZEPHIR_INIT_VAR(name);
ZVAL_EMPTY_STRING(name);
}
zephir_update_property_array(this_ptr, SL("_services"), name, rawDefinition TSRMLS_CC);
RETVAL_ZVAL(rawDefinition, 1, 0);
RETURN_MM();
}