当前位置: 首页>>代码示例>>C++>>正文


C++ zval_copy_ctor函数代码示例

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


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

示例1: phalcon_array_update_long

/**
 * Updates values on arrays by long indexes only
 */
int phalcon_array_update_long(zval **arr, ulong index, zval **value, int flags TSRMLS_DC){

	if (Z_TYPE_PP(arr) != IS_ARRAY) {
		php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Cannot use a scalar value as an array");
		return FAILURE;
	}

	if ((flags & PH_CTOR) == PH_CTOR) {
		zval *new_zv;
		Z_DELREF_PP(value);
		ALLOC_ZVAL(new_zv);
		INIT_PZVAL_COPY(new_zv, *value);
		*value = new_zv;
		zval_copy_ctor(new_zv);
	}

	if ((flags & PH_SEPARATE) == PH_SEPARATE) {
		if (Z_REFCOUNT_PP(arr) > 1) {
			zval *new_zv;
			Z_DELREF_PP(arr);
			ALLOC_ZVAL(new_zv);
			INIT_PZVAL_COPY(new_zv, *arr);
			*arr = new_zv;
			zval_copy_ctor(new_zv);
	    }
	}

	if ((flags & PH_COPY) == PH_COPY) {
		Z_ADDREF_PP(value);
	}

	return zend_hash_index_update(Z_ARRVAL_PP(arr), index, value, sizeof(zval *), NULL);
}
开发者ID:fatihzkaratana,项目名称:cphalcon,代码行数:36,代码来源:array.c

示例2: phalcon_array_update_zval

/**
 * Updates values on arrays by string or long indexes
 */
int phalcon_array_update_zval(zval **arr, zval *index, zval **value, int flags TSRMLS_DC){

	if (Z_TYPE_PP(arr) != IS_ARRAY) {
		php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Cannot use a scalar value as an array");
		return FAILURE;
	}

	if (Z_TYPE_P(index) == IS_NULL) {
		convert_to_string(index);
	} else {
		if (Z_TYPE_P(index) == IS_BOOL || Z_TYPE_P(index) == IS_DOUBLE) {
			convert_to_long(index);
		}
	}

	if ((flags & PH_CTOR) == PH_CTOR) {
		zval *new_zv;
		Z_DELREF_PP(value);
		ALLOC_ZVAL(new_zv);
		INIT_PZVAL_COPY(new_zv, *value);
		*value = new_zv;
		zval_copy_ctor(new_zv);
	}

	if ((flags & PH_SEPARATE) == PH_SEPARATE) {
		if (Z_REFCOUNT_PP(arr) > 1) {
			zval *new_zv;
			Z_DELREF_PP(arr);
			ALLOC_ZVAL(new_zv);
			INIT_PZVAL_COPY(new_zv, *arr);
			*arr = new_zv;
			zval_copy_ctor(new_zv);
	    }
	}

	if ((flags & PH_COPY) == PH_COPY) {
		Z_ADDREF_PP(value);
	}

 	if(Z_TYPE_P(index) == IS_STRING){
		return zend_hash_update(Z_ARRVAL_PP(arr), Z_STRVAL_P(index), Z_STRLEN_P(index)+1, value, sizeof(zval *), NULL);
	} else {
		if (Z_TYPE_P(index) == IS_LONG) {
			return zend_hash_index_update(Z_ARRVAL_PP(arr), Z_LVAL_P(index), value, sizeof(zval *), NULL);
		} else {
			php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Illegal offset type");
		}
	}

	return FAILURE;
}
开发者ID:fatihzkaratana,项目名称:cphalcon,代码行数:54,代码来源:array.c

示例3: xmlreader_write_property

/* {{{ xmlreader_write_property */
void xmlreader_write_property(zval *object, zval *member, zval *value, void **cache_slot)
{
	xmlreader_object *obj;
	zval tmp_member;
	xmlreader_prop_handler *hnd = NULL;
	zend_object_handlers *std_hnd;

 	if (Z_TYPE_P(member) != IS_STRING) {
		tmp_member = *member;
		zval_copy_ctor(&tmp_member);
		convert_to_string(&tmp_member);
		member = &tmp_member;
	}

	obj = Z_XMLREADER_P(object);

	if (obj->prop_handler != NULL) {
		hnd = zend_hash_find_ptr(obj->prop_handler, Z_STR_P(member));
	}
	if (hnd != NULL) {
		php_error_docref(NULL, E_WARNING, "Cannot write to read-only property");
	} else {
		std_hnd = zend_get_std_object_handlers();
		std_hnd->write_property(object, member, value, cache_slot);
	}

	if (member == &tmp_member) {
		zval_dtor(member);
	}
}
开发者ID:LTD-Beget,项目名称:php-src,代码行数:31,代码来源:php_xmlreader.c

示例4: zval_copy_ctor

/* {{{ xmlreader_get_property_ptr_ptr */
zval *xmlreader_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot)
{
	xmlreader_object *obj;
	zval tmp_member;
	zval *retval = NULL;
	xmlreader_prop_handler *hnd = NULL;
	zend_object_handlers *std_hnd;

 	if (Z_TYPE_P(member) != IS_STRING) {
		tmp_member = *member;
		zval_copy_ctor(&tmp_member);
		convert_to_string(&tmp_member);
		member = &tmp_member;
	}

	obj = Z_XMLREADER_P(object);

	if (obj->prop_handler != NULL) {
		hnd = zend_hash_find_ptr(obj->prop_handler, Z_STR_P(member));
	}

	if (hnd == NULL) {
		std_hnd = zend_get_std_object_handlers();
		retval = std_hnd->get_property_ptr_ptr(object, member, type, cache_slot);
	}

	if (member == &tmp_member) {
		zval_dtor(member);
	}

	return retval;
}
开发者ID:LTD-Beget,项目名称:php-src,代码行数:33,代码来源:php_xmlreader.c

示例5: zephir_array_update_long

/**
 * @brief Updates value in @a arr at position @a index with @a value
 * @param[in,out] arr Array
 * @param index Index
 * @param[in,out] value Value
 * @param flags Flags
 * @return Whether the operation succeeded
 * @retval @c FAILURE Failure, @a arr is not an array
 * @retval @c SUCCESS Success
 * @throw @c E_WARNING if @c arr is not an array
 *
 * Equivalent to <tt>$arr[$index] = $value</tt> in PHP where @c $index is an integer.
 * Flags may be a bitwise OR of the following values:
 * @arg @c PH_CTOR: create a copy of @a value and work with that copy; @c *value will be updated with the newly constructed value
 * @arg @c PH_SEPARATE: separate @a arr if its reference count is greater than 1; @c *arr will contain the separated version
 * @arg @c PH_COPY: increment the reference count on @c **value
 */
int zephir_array_update_long(zval **arr, unsigned long index, zval **value, int flags ZEPHIR_DEBUG_PARAMS) {

    if (Z_TYPE_PP(arr) != IS_ARRAY) {
        zend_error(E_WARNING, "Cannot use a scalar value as an array in %s on line %d", file, line);
        return FAILURE;
    }

    if ((flags & PH_CTOR) == PH_CTOR) {
        zval *new_zv;
        Z_DELREF_PP(value);
        ALLOC_ZVAL(new_zv);
        INIT_PZVAL_COPY(new_zv, *value);
        *value = new_zv;
        zval_copy_ctor(new_zv);
    }

    if ((flags & PH_SEPARATE) == PH_SEPARATE) {
        SEPARATE_ZVAL_IF_NOT_REF(arr);
    }

    if ((flags & PH_COPY) == PH_COPY) {
        Z_ADDREF_PP(value);
    }

    return zend_hash_index_update(Z_ARRVAL_PP(arr), index, value, sizeof(zval *), NULL);
}
开发者ID:golovanov,项目名称:php-ext-zendxml,代码行数:43,代码来源:array.c

示例6: php_mimepart_alloc

static php_mimepart *alloc_new_child_part(php_mimepart *parentpart, size_t startpos, int inherit)
{
	php_mimepart *child = php_mimepart_alloc();
	zval child_z;

	parentpart->parsedata.lastpart = child;
	child->parent = parentpart;

	child->source.kind = parentpart->source.kind;
	if (parentpart->source.kind != mpNONE) {
		child->source.zval = parentpart->source.zval;
		zval_copy_ctor(&child->source.zval);
	}

        ZVAL_RES(&child_z, child->rsrc);
	zend_hash_next_index_insert(&parentpart->children, &child_z);
	child->startpos = child->endpos = child->bodystart = child->bodyend = startpos;

	if (inherit) {
		if (parentpart->content_transfer_encoding)
			child->content_transfer_encoding = estrdup(parentpart->content_transfer_encoding);
		if (parentpart->charset)
			child->charset = estrdup(parentpart->charset);
	}

	return child;
}
开发者ID:php,项目名称:pecl-mail-mailparse,代码行数:27,代码来源:php_mailparse_mime.c

示例7: PHP_METHOD

/* {{{ proto int error.next()
   Returns a ref to the next errorObj in the list, or NULL if we reached the last one */
PHP_METHOD(errorObj, next)
{
  zval *zobj = getThis();
  php_error_object *php_error;
  errorObj *error = NULL;

  PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
  if (zend_parse_parameters_none() == FAILURE) {
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    return;
  }
  PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

  php_error = (php_error_object *) zend_object_store_get_object(zobj TSRMLS_CC);

  if (php_error->error->next == NULL)
    RETURN_NULL();

  /* Make sure 'self' is still valid.  It may have been deleted by
   * msResetErrorList() */
  error = msGetErrorObj();
  while(error != php_error->error) {
    if (error->next == NULL) {
      mapscript_throw_exception("Trying to access an errorObj that has expired." TSRMLS_CC);
      return;
    }
    error = error->next;
  }

  php_error->error = php_error->error->next;
  *return_value = *zobj;
  zval_copy_ctor(return_value);
  INIT_PZVAL(return_value);
}
开发者ID:AsgerPetersen,项目名称:mapserver,代码行数:36,代码来源:error.c

示例8: copy_zend_constant

void copy_zend_constant(zend_constant *c)
{
	c->name = zend_strndup(c->name, c->name_len - 1);
	if (!(c->flags & CONST_PERSISTENT)) {
		zval_copy_ctor(&c->value);
	}
}
开发者ID:m4ster-git,项目名称:nginx-on-heroku,代码行数:7,代码来源:zend_constants.c

示例9: pthreads_has_property

/* {{{ check if a thread has a property set, wherever it is available */
int pthreads_has_property(PTHREADS_HAS_PROPERTY_PASSTHRU_D) {
	int isset = 0;
	zval *mstring = NULL;

	PTHREAD pthreads = PTHREADS_FETCH_FROM(object);

	if (Z_TYPE_P(member) != IS_STRING) {
		ALLOC_ZVAL(mstring);
		*mstring = *member;
		zval_copy_ctor(
			mstring
		);
		INIT_PZVAL(mstring);
		convert_to_string(mstring);
		member = mstring;
#if PHP_VERSION_ID > 50399
		key = NULL;
#endif
	}

	if (Z_TYPE_P(member) == IS_STRING) {
		isset = pthreads_store_isset(pthreads->store, Z_STRVAL_P(member), Z_STRLEN_P(member), has_set_exists TSRMLS_CC);
	} else zend_error(E_WARNING, "pthreads has detected an attempt to use an unsupported kind of key in %s", Z_OBJCE_P(object)->name);

	if (mstring != NULL) {
		zval_ptr_dtor(&mstring);
	}

	return isset;
}
开发者ID:ArkeologeN,项目名称:pthreads,代码行数:31,代码来源:handlers.c

示例10: pthreads_unset_property

/* {{{ unset an object property */
void pthreads_unset_property(PTHREADS_UNSET_PROPERTY_PASSTHRU_D) {
	zval *mstring = NULL;
	PTHREAD pthreads = PTHREADS_FETCH_FROM(object);

	if (Z_TYPE_P(member) != IS_STRING) {
		ALLOC_ZVAL(mstring);
		*mstring = *member;
		zval_copy_ctor(
			mstring
		);
		INIT_PZVAL(mstring);
		convert_to_string(mstring);
		member = mstring;
#if PHP_VERSION_ID > 50399
		key = NULL;
#endif
	}

	if (Z_TYPE_P(member) == IS_STRING) {
		if (pthreads_store_delete(pthreads->store, Z_STRVAL_P(member), Z_STRLEN_P(member) TSRMLS_CC)!=SUCCESS){
			zend_error(
				E_WARNING, 
				"pthreads has experienced an internal error while deleting %s::$%s", 
				Z_OBJCE_P(object)->name, Z_STRVAL_P(member)
			);
		}
	} else zend_error(E_WARNING, "pthreads detected an attempt to use an unsupported kind of key in %s", Z_OBJCE_P(object)->name);
	
	if (mstring != NULL) {
		zval_ptr_dtor(&mstring);
	}
}
开发者ID:ArkeologeN,项目名称:pthreads,代码行数:33,代码来源:handlers.c

示例11: on_data_available

static size_t on_data_available(char *data, size_t size, size_t nmemb, void *ctx)
{
	php_stream *stream = (php_stream *) ctx;
	php_curl_stream *curlstream = (php_curl_stream *) stream->abstract;
	size_t wrote;
	TSRMLS_FETCH();

	/* TODO: I'd like to deprecate this.
	 * This code is here because until we start getting real data, we don't know
	 * if we have had all of the headers 
	 * */
	if (curlstream->readbuffer.writepos == 0) {
		zval *sym;

		if (!EG(active_symbol_table)) {
			zend_rebuild_symbol_table(TSRMLS_C);
		}
		MAKE_STD_ZVAL(sym);
		*sym = *curlstream->headers;
		zval_copy_ctor(sym);
		ZEND_SET_SYMBOL(EG(active_symbol_table), "http_response_header", sym);
	}
	
	php_stream_seek(curlstream->readbuffer.buf, curlstream->readbuffer.writepos, SEEK_SET);
	wrote = php_stream_write(curlstream->readbuffer.buf, data, size * nmemb);
	curlstream->readbuffer.writepos = php_stream_tell(curlstream->readbuffer.buf);

	return wrote;
}
开发者ID:Calado,项目名称:php-src,代码行数:29,代码来源:streams.c

示例12: php_config_ini_parser_cb

static void php_config_ini_parser_cb(zval *arg1, zval *arg2, int callback_type, void *arg)
{
	switch (callback_type) {
		case ZEND_INI_PARSER_ENTRY: {
				zval *entry;

				if (!arg2) {
					break;
				}
				if (!strcasecmp(Z_STRVAL_P(arg1), "extension")) { /* load function module */
					zval copy;
					
					copy = *arg2;
					zval_copy_ctor(&copy);
					copy.refcount = 0;
					zend_llist_add_element(&extension_lists.functions, &copy); 
				} else if (!strcasecmp(Z_STRVAL_P(arg1), ZEND_EXTENSION_TOKEN)) { /* load Zend extension */
					char *extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2));
					
					zend_llist_add_element(&extension_lists.engine, &extension_name);
				} else {
					zend_hash_update(&configuration_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, arg2, sizeof(zval), (void **) &entry);
					Z_STRVAL_P(entry) = zend_strndup(Z_STRVAL_P(entry), Z_STRLEN_P(entry));
				}
			}
			break;
		case ZEND_INI_PARSER_SECTION:
			break;
	}
}
开发者ID:jehurodrig,项目名称:PHP-4.0.6-16-07-2009,代码行数:30,代码来源:php_ini.c

示例13: zend_get_parameters_array

ZEND_API int zend_get_parameters_array(int ht, int param_count, zval **argument_array)
{
	void **p;
	int arg_count;
	zval *param_ptr;
	ELS_FETCH();

	p = EG(argument_stack).top_element-2;
	arg_count = (ulong) *p;

	if (param_count>arg_count) {
		return FAILURE;
	}

	while (param_count-->0) {
		param_ptr = *(p-arg_count);
		if (!PZVAL_IS_REF(param_ptr) && param_ptr->refcount>1) {
			zval *new_tmp;

			ALLOC_ZVAL(new_tmp);
			*new_tmp = *param_ptr;
			zval_copy_ctor(new_tmp);
			INIT_PZVAL(new_tmp);
			param_ptr = new_tmp;
			((zval *) *(p-arg_count))->refcount--;
			*(p-arg_count) = param_ptr;
		}
		*(argument_array++) = param_ptr;
		arg_count--;
	}

	return SUCCESS;
}
开发者ID:jehurodrig,项目名称:PHP-4.0.6-16-07-2009,代码行数:33,代码来源:zend_API.c

示例14: util_array_flatten

void util_array_flatten(zval* arr, zval* result, zend_bool preserve_keys) {
	zval **zvalue;
	char *key;
	uint keylen;
	ulong idx;
	int type;
	HashTable* arr_hash;
	HashPosition pointer;

	// Copy a temp array
	zval temp;
	temp = *arr;
	zval_copy_ctor(&temp);

	arr_hash = Z_ARRVAL_P(&temp);
	zend_hash_internal_pointer_reset_ex(arr_hash, &pointer);
	while (zend_hash_get_current_data_ex(arr_hash, (void**) &zvalue, &pointer) == SUCCESS) {
		if (Z_TYPE_P(*zvalue) == IS_ARRAY) {
			util_array_flatten(*zvalue, result, preserve_keys);
		} else {
			type = zend_hash_get_current_key_ex(arr_hash, &key, &keylen, &idx, 0, &pointer);
			if (preserve_keys && type != HASH_KEY_IS_LONG) {
				add_assoc_zval(result, key, *zvalue);
			} else {
				add_next_index_zval(result, *zvalue);
			}
		}
		zend_hash_move_forward_ex(arr_hash, &pointer);
		//ALLOC_INIT_ZVAL(*zvalue);
	}
}
开发者ID:CraryPrimitiveMan,项目名称:util,代码行数:31,代码来源:util.c

示例15: zephir_array_update_quick_string

/**
 * @brief Updates value in @a arr at position @a index with @a value using the precomputed hash @a key
 * @param[in,out] arr Array
 * @param index Index
 * @param index_length Length of the index, should include the trailing zero
 * @param key Precomputed hash of @c value
 * @param value Value
 * @param flags Flags
 * @return Whether the operation succeeded
 * @retval @c FAILURE Failure, @a arr is not an array
 * @retval @c SUCCESS Success
 * @throw @c E_WARNING if @a arr is not an array
 *
 * Equivalent to <tt>$arr[$index] = $value</tt> in PHP.
 *
 * Flags may be a bitwise OR of the following values:
 * @arg @c PH_CTOR: create a copy of @a value and work with that copy; @c *value will be updated with the newly constructed value
 * @arg @c PH_SEPARATE: separate @a arr if its reference count is greater than 1; @c *arr will contain the separated version
 * @arg @c PH_COPY: increment the reference count on @c **value
 */
int zephir_array_update_quick_string(zval **arr, const char *index, uint index_length, unsigned long key, zval **value, int flags) {

    if (Z_TYPE_PP(arr) != IS_ARRAY) {
        zend_error(E_WARNING, "Cannot use a scalar value as an array (3)");
        return FAILURE;
    }

    if ((flags & PH_CTOR) == PH_CTOR) {
        zval *new_zv;
        Z_DELREF_PP(value);
        ALLOC_ZVAL(new_zv);
        INIT_PZVAL_COPY(new_zv, *value);
        *value = new_zv;
        zval_copy_ctor(new_zv);
    }

    if ((flags & PH_SEPARATE) == PH_SEPARATE) {
        SEPARATE_ZVAL_IF_NOT_REF(arr);
    }

    if ((flags & PH_COPY) == PH_COPY) {
        Z_ADDREF_PP(value);
    }

    return zend_hash_quick_update(Z_ARRVAL_PP(arr), index, index_length, key, value, sizeof(zval *), NULL);
}
开发者ID:golovanov,项目名称:php-ext-zendxml,代码行数:46,代码来源:array.c


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