[php-src] PR #22183: ext/*: Make `X_from_obj(zend_object *obj)` functions macros
| From: | TimWolla | Date: | Fri, 29 May 2026 15:40:20 +0000 |
| Subject: | [php-src] PR #22183: ext/*: Make `X_from_obj(zend_object *obj)` functions macros | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36258@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22183
Author: TimWolla
With the introduction of the
ZEND_CONTAINER_OF() macro we can now preserve whether or
not the zend_object * is const when extracting the class-specific struct.
This change will allow to use const zend_object * in more locations.
Changes performed with Coccinelle followed by some manual cleanup for comment and whitespace
formatting:
@a@
attribute name zend_always_inline;
type T;
identifier obj;
identifier f;
typedef zend_object;
@@
T* f(zend_object *obj) { return ZEND_CONTAINER_OF(obj, T, std); }
+ #define f(obj) ZEND_CONTAINER_OF(obj, T, std)
@@
identifier a.f;
@@
- f(...) { ... }
@b@
attribute name zend_always_inline;
type T;
identifier obj;
identifier f;
typedef zend_object;
@@
T* f(zend_object *obj) { return ZEND_CONTAINER_OF(obj, T, zo); }
+ #define f(obj) ZEND_CONTAINER_OF(obj, T, zo)
@@
identifier b.f;
@@
- f(...) { ... }