Files
Tim Düsterhus 69e023fd84 ext/*: Make X_from_obj(zend_object *obj) functions macros (#22183)
* ext/*: Make `X_from_obj(zend_object *obj)` functions macros

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(...) { ... }

* sockets: Fix build

* odbc: Fix build
2026-06-01 10:21:03 +02:00

45 lines
1.5 KiB
C

/*
+----------------------------------------------------------------------+
| Copyright © The PHP Group and Contributors. |
+----------------------------------------------------------------------+
| This source file is subject to the Modified BSD License that is |
| bundled with this package in the file LICENSE, and is available |
| through the World Wide Web at <https://www.php.net/license/>. |
| |
| SPDX-License-Identifier: BSD-3-Clause |
+----------------------------------------------------------------------+
| Author: Rob Richards <rrichards@php.net> |
| Pierre-A. Joye <pajoye@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_XMLWRITER_H
#define PHP_XMLWRITER_H
extern zend_module_entry xmlwriter_module_entry;
#define phpext_xmlwriter_ptr &xmlwriter_module_entry
#include "php_version.h"
#define PHP_XMLWRITER_VERSION PHP_VERSION
#ifdef ZTS
#include "TSRM.h"
#endif
#include <libxml/tree.h>
#include <libxml/xmlwriter.h>
#include <libxml/uri.h>
/* Extends zend object */
typedef struct _ze_xmlwriter_object {
xmlTextWriterPtr ptr;
smart_str *output;
zend_object std;
} ze_xmlwriter_object;
#define php_xmlwriter_fetch_object(obj) ZEND_CONTAINER_OF(obj, ze_xmlwriter_object, std)
#define Z_XMLWRITER_P(zv) php_xmlwriter_fetch_object(Z_OBJ_P((zv)))
#endif /* PHP_XMLWRITER_H */