zval *return_value, *copy = php_http_ztyp(IS_STRING, member);
if (SUCCESS == php_http_message_object_get_prophandler(Z_STRVAL_P(copy), Z_STRLEN_P(copy), &handler)) {
- if (type == BP_VAR_W) {
- zval_ptr_dtor(©);
+ if (type == BP_VAR_R) {
+ ALLOC_ZVAL(return_value);
+ Z_SET_REFCOUNT_P(return_value, 0);
+ Z_UNSET_ISREF_P(return_value);
+
+ handler->read(obj, return_value TSRMLS_CC);
+ } else {
zend_error(E_ERROR, "Cannot access HttpMessage properties by reference or array key/index");
- return NULL;
+ return_value = NULL;
}
-
- ALLOC_ZVAL(return_value);
- Z_SET_REFCOUNT_P(return_value, 0);
- Z_UNSET_ISREF_P(return_value);
-
- handler->read(obj, return_value TSRMLS_CC);
-
} else {
return_value = zend_get_std_object_handlers()->read_property(object, member, type, literal_key TSRMLS_CC);
}
#include "php_http_api.h"
+#ifndef PHP_HTTP_PPDBG
+# define PHP_HTTP_PPDBG 1
+#endif
+
php_http_property_proxy_t *php_http_property_proxy_init(php_http_property_proxy_t *proxy, zval *object, zval *member TSRMLS_DC)
{
if (!proxy) {
proxy->object = object;
proxy->member = php_http_ztyp(IS_STRING, member);
+#if PHP_HTTP_PPDBG
+ fprintf(stderr, "proxy_init: %s\n", Z_STRVAL_P(proxy->member));
+#endif
return proxy;
}
{
php_http_property_proxy_object_t *obj = zend_object_store_get_object(*object TSRMLS_CC);
- zend_update_property(Z_OBJCE_P(obj->proxy->object), obj->proxy->object, Z_STRVAL_P(obj->proxy->member), Z_STRLEN_P(obj->proxy->member), value TSRMLS_CC);
+#if PHP_HTTP_PPDBG
+ fprintf(stderr, "proxy_set: %s\n", Z_STRVAL_P(obj->proxy->member));
+#endif
+ if (Z_TYPE_P(obj->proxy->object) == IS_OBJECT) {
+ zend_update_property(Z_OBJCE_P(obj->proxy->object), obj->proxy->object, Z_STRVAL_P(obj->proxy->member), Z_STRLEN_P(obj->proxy->member), value TSRMLS_CC);
+ } else {
+ Z_ADDREF_P(value);
+ zend_symtable_update(Z_ARRVAL_P(obj->proxy->object), Z_STRVAL_P(obj->proxy->member), Z_STRLEN_P(obj->proxy->member)+1, (void *) &value, sizeof(zval *), NULL);
+ }
}
static zval *php_http_property_proxy_object_get(zval *object TSRMLS_DC)
{
php_http_property_proxy_object_t *obj = zend_object_store_get_object(object TSRMLS_CC);
- return zend_read_property(Z_OBJCE_P(obj->proxy->object), obj->proxy->object, Z_STRVAL_P(obj->proxy->member), Z_STRLEN_P(obj->proxy->member), 0 TSRMLS_CC);
+#if PHP_HTTP_PPDBG
+ fprintf(stderr, "proxy_get: %s\n", Z_STRVAL_P(obj->proxy->member));
+#endif
+ if (Z_TYPE_P(obj->proxy->object) == IS_OBJECT) {
+ return zend_read_property(Z_OBJCE_P(obj->proxy->object), obj->proxy->object, Z_STRVAL_P(obj->proxy->member), Z_STRLEN_P(obj->proxy->member), 0 TSRMLS_CC);
+ } else {
+ zval **data = NULL;
+
+ if (SUCCESS == zend_symtable_find(Z_ARRVAL_P(obj->proxy->object), Z_STRVAL_P(obj->proxy->member), Z_STRLEN_P(obj->proxy->member)+1, (void *) &data)) {
+ Z_ADDREF_PP(data);
+ } else {
+ zval *unset;
+
+ MAKE_STD_ZVAL(unset);
+ ZVAL_NULL(unset);
+ zend_symtable_update(Z_ARRVAL_P(obj->proxy->object), Z_STRVAL_P(obj->proxy->member), Z_STRLEN_P(obj->proxy->member)+1, (void *) &unset, sizeof(zval *), (void *) &data);
+ }
+
+ return *data;
+ }
+
+ return NULL;
}
static STATUS php_http_property_proxy_object_cast(zval *object, zval *return_value, int type TSRMLS_DC)
{
zval *retval = NULL, *property = php_http_property_proxy_object_get(object TSRMLS_CC);
- if (Z_TYPE_P(property) == IS_ARRAY) {
+#if PHP_HTTP_PPDBG
+ php_http_property_proxy_object_t *obj = zend_object_store_get_object(object TSRMLS_CC);
+ zval *ocpy = php_http_ztyp(IS_STRING, offset);
+ fprintf(stderr, "read_dimension: %s.%s (%d)\n", Z_STRVAL_P(obj->proxy->member), Z_STRVAL_P(ocpy), type);
+ zval_ptr_dtor(&ocpy);
+#endif
+ if (type != BP_VAR_R) {
+ Z_ADDREF_P(property);
+ retval = php_http_property_proxy_init(NULL, property, offset TSRMLS_CC)->myself;
+ } else if (Z_TYPE_P(property) == IS_ARRAY) {
zval **data = NULL;
if (Z_TYPE_P(offset) == IS_LONG) {
}
}
zval_ptr_dtor(&property);
-
+if(retval)Z_SET_ISREF_P(retval);
return retval;
}
{
zval *property = php_http_property_proxy_object_get(object TSRMLS_CC);
+#if PHP_HTTP_PPDBG
+ php_http_property_proxy_object_t *obj = zend_object_store_get_object(object TSRMLS_CC);
+ zval *ocpy = offset ? php_http_ztyp(IS_STRING, offset) : offset;
+ fprintf(stderr, "write_dimension: %s.%s (%d)\n", Z_STRVAL_P(obj->proxy->member), ocpy?Z_STRVAL_P(ocpy):"", Z_TYPE_P(property));
+ if(ocpy)zval_ptr_dtor(&ocpy);
+#endif
switch (Z_TYPE_P(property)) {
case IS_NULL:
array_init(property);