From ea5470824da8c22c682a187bdc62a906af18e33d Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Wed, 30 Sep 2015 12:37:26 +0200 Subject: [PATCH] update v1.0.x docs --- v1.0.x/php__propro__api_8h.html | 47 +++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/v1.0.x/php__propro__api_8h.html b/v1.0.x/php__propro__api_8h.html index d0cf0c3..3158939 100644 --- a/v1.0.x/php__propro__api_8h.html +++ b/v1.0.x/php__propro__api_8h.html @@ -213,17 +213,42 @@ The name of the proxied property.

The userland object.

Return an object instance of php\PropertyProxy to make your C-struct member accessible by reference from PHP userland.

-

Example:

    -
  • ~~~~~~~~~~{.c} static zval *my_read_prop(zval *object, zval *member, int type, zend_literal *key TSRMLS_DC) { my_object_t *obj = zend_object_store_get_object(object TSRMLS_CC); my_prophandler_t *handler; zval *return_value, *copy = my_cast(IS_STRING, member);

    -

    if (SUCCESS == my_get_prophandler(Z_STRVAL_P(copy), Z_STRLEN_P(copy), &handler)) { ALLOC_ZVAL(return_value); Z_SET_REFCOUNT_P(return_value, 0); Z_UNSET_ISREF_P(return_value);

    -

    if (type == BP_VAR_R) { handler->read(obj, return_value TSRMLS_CC); } else { // // This is the interesting part // php_property_proxy_t *proxy; zend_object_value proxy_ov; zend_class_entry *proxy_ce;

    -

    proxy = php_property_proxy_init(object, Z_STRVAL_P(copy), Z_STRLEN_P(copy) TSRMLS_CC); proxy_ce = php_property_proxy_get_class_entry(); proxy_ov = php_property_proxy_object_new_ex(proxy_ce, proxy, NULL TSRMLS_CC); RETVAL_OBJVAL(proxy_ov, 0); } } else { zend_object_handlers *oh = zend_get_std_object_handlers(); return_value = oh->read_property(object, member, type, key TSRMLS_CC); }

    -

    zval_ptr_dtor(&copy);

    -

    return return_value; }

    -
  • -
  • ~~~~~~~~~~
  • -
-
+

Example:

static zval *my_read_prop(zval *object, zval *member, int type, zend_literal *key TSRMLS_DC)
+
{
+
my_object_t *obj = zend_object_store_get_object(object TSRMLS_CC);
+
my_prophandler_t *handler;
+
zval *return_value, *copy = my_cast(IS_STRING, member);
+
+
if (SUCCESS == my_get_prophandler(Z_STRVAL_P(copy), Z_STRLEN_P(copy), &handler)) {
+
ALLOC_ZVAL(return_value);
+
Z_SET_REFCOUNT_P(return_value, 0);
+
Z_UNSET_ISREF_P(return_value);
+
+
if (type == BP_VAR_R) {
+
handler->read(obj, return_value TSRMLS_CC);
+
} else {
+
//
+
// This is the interesting part
+
//
+ +
zend_object_value proxy_ov;
+
zend_class_entry *proxy_ce;
+
+
proxy = php_property_proxy_init(object, Z_STRVAL_P(copy), Z_STRLEN_P(copy) TSRMLS_CC);
+ +
proxy_ov = php_property_proxy_object_new_ex(proxy_ce, proxy, NULL TSRMLS_CC);
+
RETVAL_OBJVAL(proxy_ov, 0);
+
}
+
} else {
+
zend_object_handlers *oh = zend_get_std_object_handlers();
+
return_value = oh->read_property(object, member, type, key TSRMLS_CC);
+
}
+
+
zval_ptr_dtor(&copy);
+
+
return return_value;
+
}
+
Collaboration diagram for php_property_proxy_object:
Collaboration graph
-- 2.30.2