本文整理汇总了C++中zval_add_ref函数的典型用法代码示例。如果您正苦于以下问题:C++ zval_add_ref函数的具体用法?C++ zval_add_ref怎么用?C++ zval_add_ref使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zval_add_ref函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PHP_METHOD
/* {{{ MongoCursor->getCursorInfo: Return information about the current query (by @crodas)
*/
PHP_METHOD(MongoCursor, info)
{
mongo_cursor *cursor = (mongo_cursor*)zend_object_store_get_object(getThis() TSRMLS_CC);
MONGO_CHECK_INITIALIZED(cursor->link, MongoCursor);
array_init(return_value);
add_assoc_string(return_value, "ns", cursor->ns, 1);
add_assoc_long(return_value, "limit", cursor->limit);
add_assoc_long(return_value, "batchSize", cursor->batch_size);
add_assoc_long(return_value, "skip", cursor->skip);
if (cursor->query) {
add_assoc_zval(return_value, "query", cursor->query);
zval_add_ref(&cursor->query);
} else {
add_assoc_null(return_value, "query");
}
if (cursor->fields) {
add_assoc_zval(return_value, "fields", cursor->fields);
zval_add_ref(&cursor->fields);
} else {
add_assoc_null(return_value, "fields");
}
add_assoc_bool(return_value, "started_iterating", cursor->started_iterating);
if (cursor->started_iterating) {
add_assoc_long(return_value, "id", (long)cursor->cursor_id);
add_assoc_long(return_value, "at", cursor->at);
add_assoc_long(return_value, "numReturned", cursor->num);
add_assoc_string(return_value, "server", cursor->server->label, 1);
}
}
示例2: skyray_process_watcher_new
skyray_process_watcher_t * skyray_process_watcher_new(skyray_reactor_t *reactor, zval *zprocess, zval *handler)
{
zval object;
skyray_process_watcher_t *intern;
skyray_process_t *process = skyray_process_from_obj(Z_OBJ_P(zprocess));
if (process->watcher) {
zend_throw_exception_ex(skyray_ce_InvalidParamException, 0, "The process is already under watching, unable to watch again");
return NULL;
}
object_init_ex(&object, skyray_ce_ProcessWatcher);
zend_update_property(skyray_ce_ProcessWatcherHandler, handler, ZEND_STRL("watcher"), &object);
intern = skyray_process_watcher_from_obj(Z_OBJ(object));
intern->process = process;
intern->handler = Z_OBJ_P(handler);
zval_add_ref(handler);
zval_add_ref(zprocess);
process->watcher = intern;
if (skyray_sigchld_count < 0) {
uv_signal_init(&reactor->loop, &skyray_sigchld);
skyray_sigchld_count = 0;
}
if (skyray_sigchld_count == 0) {
uv_signal_start(&skyray_sigchld, signal_cb, SIGCHLD);
}
skyray_sigchld_count ++;
return intern;
}
示例3: PHP_METHOD
/* {{{ MongoDBRef::create()
*
* DB refs are of the form:
* array( '$ref' => <collection>, '$id' => <id>[, $db => <dbname>] )
*/
PHP_METHOD(MongoDBRef, create)
{
zval *zns, *zid, *zdb = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|z", &zns, &zid, &zdb) == FAILURE) {
return;
}
array_init(return_value);
/* add collection name */
convert_to_string(zns);
add_assoc_zval(return_value, "$ref", zns);
zval_add_ref(&zns);
/* add id field */
add_assoc_zval(return_value, "$id", zid);
zval_add_ref(&zid);
/* if we got a database name, add that, too */
if (zdb) {
convert_to_string(zdb);
add_assoc_zval(return_value, "$db", zdb);
zval_add_ref(&zdb);
}
}
示例4: PHP_METHOD
PHP_METHOD(MongoDB, execute)
{
zval *code = NULL, *args = NULL, *options = NULL, *zdata;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|aa", &code, &args, &options) == FAILURE) {
return;
}
/* turn the first argument into MongoCode */
if (Z_TYPE_P(code) != IS_OBJECT ||
Z_OBJCE_P(code) != mongo_ce_Code) {
if (Z_TYPE_P(code) == IS_STRING) {
zval *obj;
MAKE_STD_ZVAL(obj);
object_init_ex(obj, mongo_ce_Code);
MONGO_METHOD1(MongoCode, __construct, return_value, obj, code);
code = obj;
} else { /* This is broken code */
php_error_docref(NULL TSRMLS_CC, E_ERROR, "The argument is neither an object of MongoCode or a string");
return;
}
} else {
zval_add_ref(&code);
}
if (!args) {
MAKE_STD_ZVAL(args);
array_init(args);
} else {
zval_add_ref(&args);
}
/* create { $eval : code, args : [] } */
MAKE_STD_ZVAL(zdata);
array_init(zdata);
add_assoc_zval(zdata, "$eval", code);
add_assoc_zval(zdata, "args", args);
/* Check whether we have nolock as an option */
if (options) {
zval **nolock;
if (zend_hash_find(HASH_P(options), "nolock", strlen("nolock") + 1, (void**) &nolock) == SUCCESS) {
convert_to_boolean_ex(nolock);
zval_add_ref(nolock);
add_assoc_zval(zdata, "nolock", *nolock);
}
}
MONGO_METHOD1(MongoDB, command, return_value, getThis(), zdata);
zval_ptr_dtor(&zdata);
}
示例5: PHP_METHOD
PHP_METHOD(swoole_http_server, on)
{
zval *callback;
zval *event_name;
swServer *serv;
if (SwooleGS->start > 0)
{
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Server is running. Unable to set event callback now.");
RETURN_FALSE;
}
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &event_name, &callback) == FAILURE)
{
return;
}
SWOOLE_GET_SERVER(getThis(), serv);
char *func_name = NULL;
if (!zend_is_callable(callback, 0, &func_name TSRMLS_CC))
{
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Function '%s' is not callable", func_name);
efree(func_name);
RETURN_FALSE;
}
efree(func_name);
if (strncasecmp("request", Z_STRVAL_P(event_name), Z_STRLEN_P(event_name)) == 0)
{
zval_add_ref(&callback);
php_sw_http_server_callbacks[0] = callback;
}
else if (strncasecmp("message", Z_STRVAL_P(event_name), Z_STRLEN_P(event_name)) == 0)
{
zval_add_ref(&callback);
php_sw_http_server_callbacks[1] = callback;
}
else if (strncasecmp("handshake", Z_STRVAL_P(event_name), Z_STRLEN_P(event_name)) == 0)
{
zval_add_ref(&callback);
php_sw_http_server_callbacks[2] = callback;
}
else if (strncasecmp("open", Z_STRVAL_P(event_name), Z_STRLEN_P(event_name)) == 0)
{
zval_add_ref(&callback);
php_sw_http_server_callbacks[3] = callback;
}
else
{
zend_call_method_with_2_params(&getThis(), swoole_server_class_entry_ptr, NULL, "on", &return_value, event_name, callback);
}
}
示例6: php_functional_append_array_value
void php_functional_append_array_value(int hash_key_type, zval **return_value, zval **value, char *string_key, uint string_key_len, int int_key)
{
zval_add_ref(return_value);
zval_add_ref(value);
switch (hash_key_type) {
case HASH_KEY_IS_LONG:
zend_hash_index_update(Z_ARRVAL_PP(return_value), int_key, (void *)value, sizeof(zval *), NULL);
break;
case HASH_KEY_IS_STRING:
zend_hash_update(Z_ARRVAL_PP(return_value), string_key, string_key_len, (void *)value, sizeof(zval *), NULL);
break;
}
}
示例7: PHP_METHOD
PHP_METHOD(MongoCollection, __construct) {
zval *parent, *name, *zns, *w, *wtimeout;
mongo_collection *c;
mongo_db *db;
char *ns, *name_str;
int name_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os", &parent, mongo_ce_DB, &name_str, &name_len) == FAILURE) {
zval *object = getThis();
ZVAL_NULL(object);
return;
}
// check for empty collection name
if (name_len == 0) {
#if ZEND_MODULE_API_NO >= 20060613
zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "MongoDB::__construct(): invalid name %s", name_str);
#else
zend_throw_exception_ex(zend_exception_get_default(), 0 TSRMLS_CC, "MongoDB::__construct(): invalid name %s", name_str);
#endif /* ZEND_MODULE_API_NO >= 20060613 */
return;
}
c = (mongo_collection*)zend_object_store_get_object(getThis() TSRMLS_CC);
PHP_MONGO_GET_DB(parent);
c->link = db->link;
zval_add_ref(&db->link);
c->parent = parent;
zval_add_ref(&parent);
MAKE_STD_ZVAL(name);
ZVAL_STRINGL(name, name_str, name_len, 1);
c->name = name;
spprintf(&ns, 0, "%s.%s", Z_STRVAL_P(db->name), Z_STRVAL_P(name));
MAKE_STD_ZVAL(zns);
ZVAL_STRING(zns, ns, 0);
c->ns = zns;
mongo_read_preference_copy(&db->read_pref, &c->read_pref);
w = zend_read_property(mongo_ce_DB, parent, "w", strlen("w"), NOISY TSRMLS_CC);
zend_update_property_long(mongo_ce_Collection, getThis(), "w", strlen("w"), Z_LVAL_P(w) TSRMLS_CC);
wtimeout = zend_read_property(mongo_ce_DB, parent, "wtimeout", strlen("wtimeout"), NOISY TSRMLS_CC);
zend_update_property_long(mongo_ce_Collection, getThis(), "wtimeout", strlen("wtimeout"), Z_LVAL_P(wtimeout) TSRMLS_CC);
}
示例8: json_path_append_zval
static void json_path_append_zval(json_path_object *intern, json_path *path, zval *zv)
{
if (path->collection_stack.len > 0) {
json_path_stack_elem *stack_elem = simple_vector_get_last(
&intern->path_stack, json_path_stack_elem);
zval *outer_zv = *simple_vector_get_last(
&path->collection_stack, zval *);
zval_add_ref(&zv);
if (stack_elem->type == TYPE_ARRAY) {
add_next_index_zval(outer_zv, zv);
} else {
if (intern->objects_as_arrays) {
add_assoc_zval_ex(outer_zv, stack_elem->key,
stack_elem->key_len+1, zv);
} else {
add_property_zval_ex(outer_zv,
(stack_elem->key_len ? stack_elem->key : "_empty_"),
(stack_elem->key_len ? stack_elem->key_len+1 : sizeof("_empty_")),
zv);
Z_DELREF_P(zv);
}
}
}
示例9: php_mongo_db_construct
void php_mongo_db_construct(zval *z_client, zval *zlink, char *name, int name_len TSRMLS_DC)
{
mongo_db *db;
mongoclient *link;
if (!php_mongo_db_is_valid_dbname(name, name_len TSRMLS_CC)) {
return;
}
db = (mongo_db*)zend_object_store_get_object(z_client TSRMLS_CC);
db->link = zlink;
zval_add_ref(&db->link);
link = (mongoclient*)zend_object_store_get_object(zlink TSRMLS_CC);
if (!(link->servers)) {
zend_throw_exception(mongo_ce_Exception, "The MongoDB object has not been correctly initialized by its constructor", 0 TSRMLS_CC);
return;
}
if (link->servers->options.default_w != -1) {
zend_update_property_long(mongo_ce_DB, z_client, "w", strlen("w"), link->servers->options.default_w TSRMLS_CC);
} else if (link->servers->options.default_wstring != NULL) {
zend_update_property_string(mongo_ce_DB, z_client, "w", strlen("w"), link->servers->options.default_wstring TSRMLS_CC);
}
if (link->servers->options.default_wtimeout != -1) {
zend_update_property_long(mongo_ce_DB, z_client, "wtimeout", strlen("wtimeout"), link->servers->options.default_wtimeout TSRMLS_CC);
}
mongo_read_preference_copy(&link->servers->read_pref, &db->read_pref);
MAKE_STD_ZVAL(db->name);
ZVAL_STRING(db->name, name, 1);
}
示例10: PHP_METHOD
/**
* Replaces the PHP callback on an event.
*
* @param callback
* @return void
*/
PHP_METHOD(Event, setCallback)
{
event_object *obj;
dCALLBACK;
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &callback) != SUCCESS) {
return;
}
CHECK_CALLBACK;
obj = (event_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
/* TODO: Remove? */
assert(obj->callback);
/* Destroy existing callback reference */
if(obj->callback)
{
zval_ptr_dtor(&obj->callback);
}
zval_add_ref(&callback);
obj->callback = callback;
}
示例11: PHP_METHOD
/* {{{ proto MongoCollection MongoDB::dropCollection(string|MongoCollection collection)
Drops a collection and returns the database's response */
PHP_METHOD(MongoDB, dropCollection)
{
zval *collection;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &collection) == FAILURE) {
return;
}
if (Z_TYPE_P(collection) == IS_STRING) {
collection = php_mongo_db_selectcollection(getThis(), Z_STRVAL_P(collection), Z_STRLEN_P(collection) TSRMLS_CC);
if (!collection) {
/* An exception is set in this case */
return;
}
} else if (Z_TYPE_P(collection) == IS_OBJECT && Z_OBJCE_P(collection) == mongo_ce_Collection) {
zval_add_ref(&collection);
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "expects parameter 1 to be an string or MongoCollection");
return;
}
php_mongocollection_drop(collection, return_value TSRMLS_CC);
zval_ptr_dtor(&collection);
}
示例12: PHP_METHOD
/* {{{ MongoDB::__construct
*/
PHP_METHOD(MongoDB, __construct) {
zval *zlink;
char *name;
int name_len;
mongo_db *db;
mongo_link *link;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os", &zlink, mongo_ce_Mongo, &name, &name_len) == FAILURE) {
zval *object = getThis();
ZVAL_NULL(object);
return;
}
if (0 == name_len ||
0 != strchr(name, ' ') || 0 != strchr(name, '.') || 0 != strchr(name, '\\') ||
0 != strchr(name, '/') || 0 != strchr(name, '$')) {
#if ZEND_MODULE_API_NO >= 20060613
zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "MongoDB::__construct(): invalid name %s", name);
#else
zend_throw_exception_ex(zend_exception_get_default(), 0 TSRMLS_CC, "MongoDB::__construct(): invalid name %s", name);
#endif /* ZEND_MODULE_API_NO >= 20060613 */
return;
}
db = (mongo_db*)zend_object_store_get_object(getThis() TSRMLS_CC);
db->link = zlink;
zval_add_ref(&db->link);
PHP_MONGO_GET_LINK(zlink);
db->slave_okay = link->slave_okay;
MAKE_STD_ZVAL(db->name);
ZVAL_STRING(db->name, name, 1);
}
示例13: PHP_METHOD
static PHP_METHOD(swoole_process, signal)
{
zval *callback = NULL;
long signo = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz", &signo, &callback) == FAILURE)
{
return;
}
if (!SWOOLE_G(cli))
{
php_error_docref(NULL TSRMLS_CC, E_ERROR, "cannot use swoole_process::signal here.");
RETURN_FALSE;
}
if (SwooleGS->start)
{
if (signo == SIGTERM || signo == SIGALRM)
{
php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot use swoole_process::signal in swoole_server.");
RETURN_FALSE;
}
}
if (callback == NULL || ZVAL_IS_NULL(callback))
{
php_error_docref(NULL TSRMLS_CC, E_WARNING, "no callback.");
RETURN_FALSE;
}
char *func_name;
if (!zend_is_callable(callback, 0, &func_name TSRMLS_CC))
{
php_error_docref(NULL TSRMLS_CC, E_ERROR, "function '%s' is not callable", func_name);
efree(func_name);
RETURN_FALSE;
}
efree(func_name);
zval_add_ref(&callback);
signal_callback[signo] = callback;
#if PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 4
SwooleG.use_signalfd = 1;
#else
SwooleG.use_signalfd = 0;
#endif
php_swoole_check_reactor();
/**
* for swSignalfd_setup
*/
SwooleG.main_reactor->check_signalfd = 1;
swSignal_add(signo, php_swoole_onSignal);
RETURN_TRUE;
}
示例14: SKYRAY_METHOD
SKYRAY_METHOD(stream_client, createPipe)
{
zend_bool duplex = 0;
zval stream1, stream2;
int fds[2];
int sockret;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &duplex) == FAILURE) {
return;
}
if (duplex) {
sockret = socketpair(AF_UNIX, SOCK_STREAM, 0, fds);
} else {
sockret = pipe(fds);
}
if (sockret == -1) {
RETURN_FALSE;
}
array_init(return_value);
object_init_ex(&stream1, skyray_ce_Stream);
object_init_ex(&stream2, skyray_ce_Stream);
skyray_stream_t * intern1 = skyray_stream_from_obj(Z_OBJ_P(&stream1));
skyray_stream_t * intern2 = skyray_stream_from_obj(Z_OBJ_P(&stream2));
skyray_stream_init_blocking(intern1, SR_PIPE, fds[0], NULL);
skyray_stream_init_blocking(intern2, SR_PIPE, fds[1], NULL);
if (duplex) {
skyray_stream_on_opened(intern1, SR_READABLE | SR_WRITABLE);
skyray_stream_on_opened(intern2, SR_READABLE | SR_WRITABLE);
} else {
skyray_stream_on_opened(intern1, SR_READABLE);
skyray_stream_on_opened(intern2, SR_WRITABLE);
}
add_index_zval(return_value, 0, &stream1);
add_index_zval(return_value, 1, &stream2);
zval_add_ref(&stream1);
zval_add_ref(&stream2);
}
示例15: PHP_METHOD
PHP_METHOD(swoole_http_server, on)
{
zval *callback;
char *event_name;
swServer *serv;
int len;
if (SwooleGS->start > 0)
{
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Server is running. Unable to set event callback now.");
RETURN_FALSE;
}
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", &event_name, &len, &callback) == FAILURE)
{
return;
}
SWOOLE_GET_SERVER(getThis(), serv);
char *func_name = NULL;
if (!zend_is_callable(callback, 0, &func_name TSRMLS_CC))
{
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Function '%s' is not callable", func_name);
efree(func_name);
RETURN_FALSE;
}
efree(func_name);
if (strncasecmp("request", event_name, len) == 0)
{
zval_add_ref(&callback);
php_sw_http_server_callbacks[0] = callback;
}
else if (strncasecmp("message", event_name, len) == 0)
{
zval_add_ref(&callback);
php_sw_http_server_callbacks[1] = callback;
}
else
{
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unknown event types[%s]", event_name);
RETURN_FALSE;
}
}