Example #1
0
File: berg.c Project: henryzxj/berg
/* {{{ proto ProtocolBuffers_DescriptorBuilder ProtocolBuffers_DescriptorBuilder::__construct()
*/
PHP_METHOD(berg_buffers, __construct)
{
	zval *instance = getThis();
	zval fields,options,extension_ranges,*tmp;
	array_init(&fields);
	add_next_index_double(&fields,42.00);
	add_next_index_long(&fields,42);
	php_var_dump(&fields,1);
	zend_update_property(Z_OBJCE_P(instance),instance,ZEND_STRL("fields"),&fields);
	zval_ptr_dtor(&fields);

//	array_init(&options);
//	zend_update_property(berg_buffers_class_entry,instance,ZEND_STRL("options"),&options);
//	zval_ptr_dtor(&options);
//
//	array_init(&extension_ranges);
//	zend_update_property(berg_buffers_class_entry,instance,ZEND_STRL("extension_ranges"),&extension_ranges);
//	zval_ptr_dtor(&extension_ranges);

	zend_string *key = zend_string_init(ZEND_STRL("fields"),0);
	if((tmp=zend_hash_find(Z_OBJPROP_P(instance), key))!=NULL){
		php_var_dump(tmp,1);
	}
	zend_string_release(key);
	//>gdb
	//(gdb) p fields1->u2
	//$1 = {var_flags = 4294967295, next = 4294967295, cache_slot = 4294967295, lineno = 4294967295, num_args = 4294967295, fe_pos = 4294967295, fe_iter_idx = 4294967295}
	//(gdb) p fields1->value->arr->nNumUsed
	//$4 = 1
	//(gdb) p fields1->value->arr->nTableSize
	//$5 = 4294956704
	//(gdb) p fields1->value->arr->nNumOfElements
	//$6 = 0
}
Example #2
0
File: var.c Project: 20uf/php-src
static void php_object_property_dump(zval *zv, zend_ulong index, zend_string *key, int level) /* {{{ */
{
	const char *prop_name, *class_name;

	if (key == NULL) { /* numeric key */
		php_printf("%*c[" ZEND_LONG_FMT "]=>\n", level + 1, ' ', index);
	} else { /* string key */
		int unmangle = zend_unmangle_property_name(key, &class_name, &prop_name);
		php_printf("%*c[", level + 1, ' ');

		if (class_name && unmangle == SUCCESS) {
			if (class_name[0] == '*') {
				php_printf("\"%s\":protected", prop_name);
			} else {
				php_printf("\"%s\":\"%s\":private", prop_name, class_name);
			}
		} else {
			php_printf("\"");
			PHPWRITE(ZSTR_VAL(key), ZSTR_LEN(key));
			php_printf("\"");
		}
		ZEND_PUTS("]=>\n");
	}
	php_var_dump(zv, level + 2);
}
Example #3
0
/*
 * Print info about variable: php var_dump()
 */
void php_var_dump(PHP_VALUE_NODE *node, int ident, int ref)
{
	for(int i = 0; i < ident;i++) {
		printf("\t");
	}
	if ( ref ) printf("&");
	switch(node->type) {
		case PHP_VAL_BOOL: printf("bool(%s)\n", node->int_val ? "true" : "false"); break;
		case PHP_VAL_INT: printf("int(%"PRIu64")\n", node->int_val); break;
		case PHP_VAL_FLOAT: printf("float(%f)\n", node->float_val); break;
		case PHP_VAL_STRING: printf("string(%d) \"%s\"\n", (int)strlen(node->str_val), node->str_val); break;
		case PHP_VAL_OBJECT: printf("Object(%s)\n", node->obj_val.class_name); break;
		case PHP_VAL_ARRAY: {
			int arr_size = array_get_size(node);
			printf("array(%d) {\n", arr_size);
			for(int i = 0; i < arr_size;i++) {
				const std::string &curr_key = array_get_ith_key(node, i);
				PHP_VAR_NODE *curr_val = array_get_by_str_key(node, curr_key);
				printf("\t[%s]=>\n", curr_key.c_str());
				php_var_dump(&curr_val->value, ident+1, curr_val->ref_count > 1);
			}
			for(int i = 0; i < ident;i++) {
				printf("\t");
			}
			printf("}\n");
			break;
		}
		case PHP_VAL_NONE: printf("NULL\n"); break;
		case PHP_VAL_VAR_NODE:
		case PHP_VAL_INT_DATA: assert(0); break;
	}
}
Example #4
0
void php_native_var_dump(PHP_VALUE_NODE *)
{
	PHP_SCOPE_ITEM *si = get_scope_item(g_current_scope, "__param_0");
	if ( si ) {
		assert((si->type == PHP_SCOPE_VAR)||(si->type == PHP_SCOPE_PARAM));
		php_var_dump(&si->var->value, 0, 0);
	} else {
		php_report_error(PHP_ERROR, "Invalid or missing argument");
	}
}
Example #5
0
File: var.c Project: 20uf/php-src
static void php_array_element_dump(zval *zv, zend_ulong index, zend_string *key, int level) /* {{{ */
{
	if (key == NULL) { /* numeric key */
		php_printf("%*c[" ZEND_LONG_FMT "]=>\n", level + 1, ' ', index);
	} else { /* string key */
		php_printf("%*c[\"", level + 1, ' ');
		PHPWRITE(ZSTR_VAL(key), ZSTR_LEN(key));
		php_printf("\"]=>\n");
	}
	php_var_dump(zv, level + 2);
}
Example #6
0
static void php_array_element_dump(zval *zv, zend_ulong index, zend_string *key, int level TSRMLS_DC) /* {{{ */
{
	if (key == NULL) { /* numeric key */
		php_printf("%*c[" ZEND_LONG_FMT "]=>\n", level + 1, ' ', index);
	} else { /* string key */
		php_printf("%*c[\"", level + 1, ' ');
		PHPWRITE(key->val, key->len);
		php_printf("\"]=>\n");
		}
	php_var_dump(zv, level + 2 TSRMLS_CC);
}
Example #7
0
ZEND_METHOD(myclass_child, __construct)
{
	zval *prop1, *prop2;
	zend_class_entry *ce;
	ce = Z_OBJCE_P(getThis());
	if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &prop1, &prop2) == FAILURE) {
		php_printf("Parameter Error\n");
		RETURN_NULL();
	}

	zend_update_property(ce, getThis(), "prop1", sizeof("prop1") - 1, prop1 TSRMLS_CC); //更新对象属性
	zend_update_static_property(ce, "prop2", sizeof("prop2") - 1, prop2 TSRMLS_CC); //更新类静态属性(与具体对象无关)

	prop1 = NULL;
	prop2 = NULL;

	prop1 = zend_read_property(ce, getThis(), "prop1", sizeof("prop1") - 1, 0 TSRMLS_DC);
	php_var_dump(&prop1, 1 TSRMLS_CC);

	prop2 = zend_read_static_property(ce, "prop2", sizeof("prop2") - 1, 0 TSRMLS_DC);
	php_var_dump(&prop2, 1 TSRMLS_CC);
}
Example #8
0
ZEND_METHOD( myclass , update_get_member ) //在c扩展中操纵PHP对象的成员
{
    php_printf("我是update_get_member方法:\n");
	zval *var;
    zend_class_entry *ce;
    ce = Z_OBJCE_P(getThis());
    if( zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &var) == FAILURE )
    {
        php_printf("Error\n");
        RETURN_NULL();
    }
    zend_update_property(ce, getThis(), "public_var", sizeof("public_var")-1, var TSRMLS_CC);
     
    var = NULL;
     
    var = zend_read_property(ce, getThis(), "public_var", sizeof("public_var")-1, 0 TSRMLS_CC);
    php_var_dump(&var, 1 TSRMLS_CC);
     
}
Example #9
0
static void php_object_property_dump(zend_property_info *prop_info, zval *zv, zend_ulong index, zend_string *key, int level) /* {{{ */
{
	const char *prop_name, *class_name;

	if (key == NULL) { /* numeric key */
		php_printf("%*c[" ZEND_LONG_FMT "]=>\n", level + 1, ' ', index);
	} else { /* string key */
		int unmangle = zend_unmangle_property_name(key, &class_name, &prop_name);
		php_printf("%*c[", level + 1, ' ');

		if (class_name && unmangle == SUCCESS) {
			if (class_name[0] == '*') {
				php_printf("\"%s\":protected", prop_name);
			} else {
				php_printf("\"%s\":\"%s\":private", prop_name, class_name);
			}
		} else {
			php_printf("\"");
			PHPWRITE(ZSTR_VAL(key), ZSTR_LEN(key));
			php_printf("\"");
		}
		ZEND_PUTS("]=>\n");
	}

	if (Z_TYPE_P(zv) == IS_UNDEF) {
		ZEND_ASSERT(prop_info->type);
		php_printf("%*cuninitialized(%s%s)\n",
			level + 1, ' ',
			ZEND_TYPE_ALLOW_NULL(prop_info->type) ? "?" : "",
			ZEND_TYPE_IS_CLASS(prop_info->type) ?
				ZSTR_VAL(ZEND_TYPE_IS_CE(prop_info->type) ? ZEND_TYPE_CE(prop_info->type)->name : ZEND_TYPE_NAME(prop_info->type)) :
				zend_get_type_by_const(ZEND_TYPE_CODE(prop_info->type)));
	} else {
		php_var_dump(zv, level + 2);
	}
}
Example #10
0
/**
 * var_dump outputs php variables without using the PHP userland
 */
void phalcon_var_dump(zval *var) {
    php_var_dump(var, 1);
}
Example #11
0
void xdebug_php_var_dump(zval **struc, int level TSRMLS_DC)
{
	php_var_dump(struc, 1, 1 TSRMLS_CC);
}