So many lines, but my question is very clear: how do I implement a write zval property handler?

Unfortunately, I didn't find any samples in the PHP source.
Standard zend_std_write_property function does roughly the same. But my stuff isn't working correctly.

On 07/20/2013 09:50 PM, Ruslan Osmanov wrote:
Hi,

I have a mixed read-write property here:
http://docs.php.net/manual/en/class.evwatcher.php#evwatcher.props.data

The property write handler
https://bitbucket.org/osmanov/pecl-ev/src/589ccf73896ea0c2763e8923ea054ccc825a732c/pe.c?at=master#cl-240

calls php_ev_prop_write_zval.


static inline void php_ev_prop_write_zval(zval **ppz, zval *value)
{
     if (!*ppz) {
         MAKE_STD_ZVAL(*ppz);
     }

     REPLACE_ZVAL_VALUE(ppz, value, 1);
}

Should I call REPLACE_ZVAL_VALUE with or without "copy"(1)? I suspect it
should be 0.

Let's look at some PHP code. The following script outputs "123".

```
<?php
class indicator {
     public function __destruct() {
         echo "2";
     }
}

class A {
     public $data;
}

function test() {
     $a = new A();

     $indicator = new indicator();
     $a->data = $indicator;

     debug_zval_dump($indicator);
     debug_zval_dump($a);
     $indicator = null;

     echo "1";
     $a = null;
     echo "3";
}

test();
echo "\n";
```

But the code below outputs:
13
2

However, when I change the last argument of REPLACE_ZVAL_VALUE to zero,
both scripts output the same "123" string.

So should I call `REPLACE_ZVAL_VALUE(ppz, value, 0);` instead?




--
Regards,

Ruslan Osmanov

--
PECL development discussion Mailing List (http://pecl.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to