-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello devs,

On Friday 24 Sep 2004 09:39, Andrey Hristov wrote:
>   Hi,
> can we have a macro that implements this equality check - whether
> 2 zvals point to the same object?

Would these do?  Copied from a pretty borked ext, but still work :-)

+ static inline zend_bool zend_compare_object (zval **ob1, zval **ob2)
+ {
+   return Z_OBJ_HT_PP(ob1) == Z_OBJ_HT_PP(ob2);
+ }
+
+ static inline zend_bool zend_compare_objid (zval **ob1, zval **ob2)
+ {
+   return Z_OBJ_HANDLE_PP(ob2) == Z_OBJ_HANDLE_PP(ob2);
+ }

Is this missing a is_ref check, too?  Or, further more, is that really needed?  
Also, is pointer arith. minus a void* cast good for portability?

#define's might be better, just prefer inline's for debugging.. ;-)

Elfyn

> Andi Gutmans wrote:
> > You also have to compare Z_OBJ_HT_P(objA) == Z_OBJ_HT_P(objB) in
> > addition to Z_OBJ_HANDLE_P.
> > After checking both of these your code will work.
> >
> > At 10:57 PM 9/23/2004 -0700, Robert Silva wrote:
> >> Just wondering if there is a better way to test for reference equality
> >> than
> >> what is listed below.
> >>
> >> zval *objA;
> >> zval *objB;
> >>
> >> if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "oo", &objA,
> >> &objB) ==
> >> FAILURE)
> >> {
> >>         return;
> >> }
> >>
> >> // Reference equality only
> >> if (Z_OBJ_HANDLE_P(objA) == Z_OBJ_HANDLE_P(objB))
> >> {
> >>     RETURN_TRUE
> >> }
> >> RETURN_FALSE
> >>
> >>
> >> Also, should one be using zend_parse_method_parameters instead of the
> >> older
> >> zend_parse_parameters now for object method functions or does it really
> >> matter?
> >>
> >> Thanks
> >>
> >> Bob Silva aka Salty```

- -- 
Elfyn McBratney
beu on irc.freenode.net/savannah.[non]gnu.org

PGP Key ID: 0x456548B4
PGP Key Fingerprint:
  29D5 91BB 8748 7CC9 650F 31FE 6888 0C2A 4565 48B4
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBVFmvaIgMKkVlSLQRAvEkAJ9AP+5gIBGEiHvvl0UjASNPwGCJgACfWxhe
GdvsQIeM0TdX6LXLAs7PqEI=
=jEXm
-----END PGP SIGNATURE-----

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to