root/ext/dom/xml_common.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. php_dom_obj_from_obj

   1 /*
   2   +----------------------------------------------------------------------+
   3   | PHP Version 7                                                        |
   4   +----------------------------------------------------------------------+
   5   | Copyright (c) 1997-2016 The PHP Group                                |
   6   +----------------------------------------------------------------------+
   7   | This source file is subject to version 3.01 of the PHP license,      |
   8   | that is bundled with this package in the file LICENSE, and is        |
   9   | available through the world-wide-web at the following url:           |
  10   | http://www.php.net/license/3_01.txt                                  |
  11   | If you did not receive a copy of the PHP license and are unable to   |
  12   | obtain it through the world-wide-web, please send a note to          |
  13   | license@php.net so we can mail you a copy immediately.               |
  14   +----------------------------------------------------------------------+
  15   | Authors: Christian Stocker <chregu@php.net>                          |
  16   |          Rob Richards <rrichards@php.net>                            |
  17   +----------------------------------------------------------------------+
  18 */
  19 
  20 /* $Id$ */
  21 
  22 #ifndef PHP_XML_COMMON_H
  23 #define PHP_XML_COMMON_H
  24 
  25 #include "ext/libxml/php_libxml.h"
  26 
  27 typedef libxml_doc_props *dom_doc_propsptr;
  28 
  29 typedef struct _dom_object {
  30         void *ptr;
  31         php_libxml_ref_obj *document;
  32         HashTable *prop_handler;
  33         zend_object std;
  34 } dom_object;
  35 
  36 static inline dom_object *php_dom_obj_from_obj(zend_object *obj) {
  37         return (dom_object*)((char*)(obj) - XtOffsetOf(dom_object, std));
  38 }
  39 
  40 #define Z_DOMOBJ_P(zv)  php_dom_obj_from_obj(Z_OBJ_P((zv)))
  41 
  42 #ifdef PHP_WIN32
  43 #       ifdef DOM_EXPORTS
  44 #               define PHP_DOM_EXPORT __declspec(dllexport)
  45 #       elif !defined(DOM_LOCAL_DEFINES) /* Allow to counteract LNK4049 warning. */
  46 #               define PHP_DOM_EXPORT __declspec(dllimport)
  47 #   else
  48 #               define PHP_DOM_EXPORT
  49 #       endif /* DOM_EXPORTS */
  50 #elif defined(__GNUC__) && __GNUC__ >= 4
  51 #       define PHP_DOM_EXPORT __attribute__ ((visibility("default")))
  52 #elif defined(PHPAPI)
  53 #   define PHP_DOM_EXPORT PHPAPI
  54 #else
  55 #   define PHP_DOM_EXPORT
  56 #endif
  57 
  58 PHP_DOM_EXPORT extern zend_class_entry *dom_node_class_entry;
  59 PHP_DOM_EXPORT dom_object *php_dom_object_get_data(xmlNodePtr obj);
  60 PHP_DOM_EXPORT zend_bool php_dom_create_object(xmlNodePtr obj, zval* return_value, dom_object *domobj);
  61 PHP_DOM_EXPORT xmlNodePtr dom_object_get_node(dom_object *obj);
  62 
  63 #define DOM_XMLNS_NAMESPACE \
  64     (const xmlChar *) "http://www.w3.org/2000/xmlns/"
  65 
  66 #define NODE_GET_OBJ(__ptr, __id, __prtype, __intern) { \
  67         __intern = Z_LIBXML_NODE_P(__id); \
  68         if (__intern->node == NULL || !(__ptr = (__prtype)__intern->node->node)) { \
  69                 php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", \
  70                         ZSTR_VAL(__intern->std.ce->name));\
  71                 RETURN_NULL();\
  72         } \
  73 }
  74 
  75 #define DOC_GET_OBJ(__ptr, __id, __prtype, __intern) { \
  76         __intern = Z_LIBXML_NODE_P(__id); \
  77         if (__intern->document != NULL) { \
  78                 if (!(__ptr = (__prtype)__intern->document->ptr)) { \
  79                         php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", __intern->std.ce->name);\
  80                         RETURN_NULL();\
  81                 } \
  82         } \
  83 }
  84 
  85 #define DOM_RET_OBJ(obj, ret, domobject) \
  86         *ret = php_dom_create_object(obj, return_value, domobject)
  87 
  88 #define DOM_GET_THIS(zval) \
  89         if (NULL == (zval = getThis())) { \
  90                 php_error_docref(NULL, E_WARNING, "Underlying object missing"); \
  91                 RETURN_FALSE; \
  92         }
  93 
  94 #define DOM_GET_THIS_OBJ(__ptr, __id, __prtype, __intern) \
  95         DOM_GET_THIS(__id); \
  96         DOM_GET_OBJ(__ptr, __id, __prtype, __intern);
  97 
  98 #endif
  99 
 100 /*
 101  * Local variables:
 102  * tab-width: 4
 103  * c-basic-offset: 4
 104  * End:
 105  * vim600: noet sw=4 ts=4 fdm=marker
 106  * vim<600: noet sw=4 ts=4
 107  */

/* [<][>][^][v][top][bottom][index][help] */