summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2005-06-23 11:28:25 (GMT)
committerPierre Joye <pajoye@php.net>2005-06-23 11:28:25 (GMT)
commit8c1c4865acf12fdac68c0cb5a420f3253bf82410 (patch)
tree363ab40d5daad9584e53e5d7b7e3e85cbb60fae2 /ext
parentcfe01e1b0601850b4d3313d7d327f53b513f14e5 (diff)
downloadphp-8c1c4865acf12fdac68c0cb5a420f3253bf82410.tar.gz
- Add OO interface
- some {{{ fixes
Diffstat (limited to 'ext')
-rw-r--r--ext/xmlwriter/TODO5
-rw-r--r--ext/xmlwriter/package.xml23
-rw-r--r--ext/xmlwriter/php_xmlwriter.c908
-rw-r--r--ext/xmlwriter/php_xmlwriter.h13
4 files changed, 789 insertions, 160 deletions
diff --git a/ext/xmlwriter/TODO b/ext/xmlwriter/TODO
index dd3235f..bfc895d 100644
--- a/ext/xmlwriter/TODO
+++ b/ext/xmlwriter/TODO
@@ -1,4 +1,5 @@
- Fix up config file for PHP 5 to use libxml extension configuration
-- Add OOP support
-
+- Add tests for Namespace functions/methods
+- Sync with xmlwriter (new dtd func?)
+- Write documentations in docbook
diff --git a/ext/xmlwriter/package.xml b/ext/xmlwriter/package.xml
index 3fecce8..cbe8143 100644
--- a/ext/xmlwriter/package.xml
+++ b/ext/xmlwriter/package.xml
@@ -24,6 +24,17 @@
<role>developer</role>
</maintainer>
<release>
+ <version>1.1.0</version>
+ <date>2005-05-24</date>
+ <state>beta</state>
+ <notes>
+ Add OO interface (php5 only)
+ Add test cases
+ </notes>
+ </release>
+
+ <changelog>
+ <release>
<version>1.0</version>
<date>2005-05-02</date>
<state>stable</state>
@@ -34,8 +45,6 @@
Add support for xmlTextWriterStart/EndComment
</notes>
</release>
-
- <changelog>
<release>
<version>0.1</version>
<date>2004-07-20</date>
@@ -58,6 +67,16 @@
<file role="src" name="config.w32"/>
<file role="src" name="php_xmlwriter.c"/>
<file role="src" name="php_xmlwriter.h"/>
+ <dir name="tests" role="test">
+ <file name="001.phpt"/>
+ <file name="002.phpt"/>
+ <file name="003.phpt"/>
+ <file name="004.phpt"/>
+ <file name="OO_001.phpt"/>
+ <file name="OO_002.phpt"/>
+ <file name="OO_003.phpt"/>
+ <file name="OO_004.phpt"/>
+ </dir>
</filelist>
<deps>
<dep type="php" rel="ge" version="4.3.0" />
diff --git a/ext/xmlwriter/php_xmlwriter.c b/ext/xmlwriter/php_xmlwriter.c
index cb45373..6eaed9e 100644
--- a/ext/xmlwriter/php_xmlwriter.c
+++ b/ext/xmlwriter/php_xmlwriter.c
@@ -28,8 +28,88 @@
#include "ext/standard/info.h"
#include "php_xmlwriter.h"
+/* {{{ XMLWRITER_FROM_OBJECT */
+#define XMLWRITER_FROM_OBJECT(intern, object) \
+ { \
+ ze_xmlwriter_object *obj = (ze_xmlwriter_object*) zend_object_store_get_object(object TSRMLS_CC); \
+ intern = obj->xmlwriter_ptr; \
+ if (!intern) { \
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid or unitialized XMLWriter object"); \
+ RETURN_FALSE; \
+ } \
+ }
+/* }}} */
+
zend_class_entry *xmlwriter_class_entry;
+static zend_object_handlers xmlwriter_object_handlers;
+
+/* {{{ xmlwriter_object_free_storage */
+static void xmlwriter_free_resource_ptr(xmlwriter_object *intern TSRMLS_DC)
+{
+ if (intern) {
+ if (intern->ptr) {
+ xmlFreeTextWriter(intern->ptr);
+ intern->ptr = NULL;
+ }
+ if (intern->output) {
+ xmlBufferFree(intern->output);
+ intern->output = NULL;
+ }
+ efree(intern);
+ }
+}
+/* }}} */
+
+/* {{{ xmlwriter_object_free_storage */
+static void xmlwriter_object_free_storage(void *object TSRMLS_DC)
+{
+ ze_xmlwriter_object * intern = (ze_xmlwriter_object *) object;
+ if (!intern) {
+ return;
+ }
+ if (intern->xmlwriter_ptr) {
+ xmlwriter_free_resource_ptr(intern->xmlwriter_ptr TSRMLS_CC);
+ }
+ intern->xmlwriter_ptr = NULL;
+ if (intern->zo.properties) {
+ zend_hash_destroy(intern->zo.properties);
+ FREE_HASHTABLE(intern->zo.properties);
+ }
+
+ efree(intern);
+}
+/* }}} */
+/* {{{ xmlwriter_object_new */
+PHP_XMLWRITER_API zend_object_value xmlwriter_object_new(zend_class_entry *class_type TSRMLS_DC)
+{
+ ze_xmlwriter_object *intern;
+ zval *tmp;
+ zend_object_value retval;
+
+ intern = emalloc(sizeof(ze_xmlwriter_object));
+ intern->zo.ce = class_type;
+ intern->zo.in_get = 0;
+ intern->zo.in_set = 0;
+ intern->zo.properties = NULL;
+
+ ALLOC_HASHTABLE(intern->zo.properties);
+ zend_hash_init(intern->zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
+ zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref,
+ (void *) &tmp, sizeof(zval *));
+
+ retval.handle = zend_objects_store_put(intern,
+ NULL,
+ (zend_objects_free_object_storage_t) xmlwriter_object_free_storage,
+ NULL TSRMLS_CC);
+
+ retval.handlers = (zend_object_handlers *) & xmlwriter_object_handlers;
+
+ return retval;
+}
+/* }}} */
+
+/* {{{ xmlwriter_functions */
static zend_function_entry xmlwriter_functions[] = {
PHP_FE(xmlwriter_open_uri, NULL)
PHP_FE(xmlwriter_open_memory, NULL)
@@ -71,6 +151,51 @@ static zend_function_entry xmlwriter_functions[] = {
PHP_FE(xmlwriter_flush, NULL)
{NULL, NULL, NULL}
};
+/* }}} */
+
+/* {{{ xmlwriter_class_functions */
+static zend_function_entry xmlwriter_class_functions[] = {
+ PHP_ME_MAPPING(openUri, xmlwriter_open_uri, NULL)
+ PHP_ME_MAPPING(openMemory, xmlwriter_open_memory, NULL)
+#if LIBXML_VERSION >= 20605
+ PHP_ME_MAPPING(setIndent, xmlwriter_set_indent, NULL)
+ PHP_ME_MAPPING(setIndentString, xmlwriter_set_indent_string, NULL)
+#endif
+#if LIBXML_VERSION >= 20607
+ PHP_ME_MAPPING(startComment, xmlwriter_start_comment, NULL)
+ PHP_ME_MAPPING(endComment, xmlwriter_end_comment, NULL)
+#endif
+ PHP_ME_MAPPING(startAttribute, xmlwriter_start_attribute, NULL)
+ PHP_ME_MAPPING(endAttribute, xmlwriter_end_attribute, NULL)
+ PHP_ME_MAPPING(writeAttribute, xmlwriter_write_attribute, NULL)
+#if LIBXML_VERSION > 20617
+ PHP_ME_MAPPING(startAttributeNs, xmlwriter_start_attribute_ns,NULL)
+#endif
+ PHP_ME_MAPPING(startElement, xmlwriter_start_element, NULL)
+ PHP_ME_MAPPING(endElement, xmlwriter_end_element, NULL)
+ PHP_ME_MAPPING(startElementNs, xmlwriter_start_element_ns, NULL)
+ PHP_ME_MAPPING(writeElement, xmlwriter_write_element, NULL)
+ PHP_ME_MAPPING(writeElementNs, xmlwriter_write_element_ns, NULL)
+ PHP_ME_MAPPING(startPi, xmlwriter_start_pi, NULL)
+ PHP_ME_MAPPING(endPi, xmlwriter_end_pi, NULL)
+ PHP_ME_MAPPING(writePi, xmlwriter_write_pi, NULL)
+ PHP_ME_MAPPING(startCdata, xmlwriter_start_cdata, NULL)
+ PHP_ME_MAPPING(endCdata, xmlwriter_end_cdata, NULL)
+ PHP_ME_MAPPING(writeCdata, xmlwriter_write_cdata, NULL)
+ PHP_ME_MAPPING(text, xmlwriter_text, NULL)
+ PHP_ME_MAPPING(startDocument, xmlwriter_start_document, NULL)
+ PHP_ME_MAPPING(endDocument, xmlwriter_end_document, NULL)
+ PHP_ME_MAPPING(writeComment, xmlwriter_write_comment, NULL)
+ PHP_ME_MAPPING(startDtd, xmlwriter_start_dtd, NULL)
+ PHP_ME_MAPPING(endDtd, xmlwriter_end_dtd, NULL)
+ PHP_ME_MAPPING(writeDtd, xmlwriter_write_dtd, NULL)
+ PHP_ME_MAPPING(startDtdElement, xmlwriter_start_dtd_element, NULL)
+ PHP_ME_MAPPING(endDtdElement, xmlwriter_end_dtd_element, NULL)
+ PHP_ME_MAPPING(outputMemory, xmlwriter_output_memory, NULL)
+ PHP_ME_MAPPING(flush, xmlwriter_flush, NULL)
+ {NULL, NULL, NULL}
+};
+/* }}} */
/* {{{ function prototypes */
PHP_MINIT_FUNCTION(xmlwriter);
@@ -78,9 +203,11 @@ PHP_MSHUTDOWN_FUNCTION(xmlwriter);
PHP_MINFO_FUNCTION(xmlwriter);
static int le_xmlwriter;
+/* }}} */
/* _xmlwriter_get_valid_file_path should be made a
common function in libxml extension as code is common to a few xml extensions */
+/* {{{ _xmlwriter_get_valid_file_path */
char *_xmlwriter_get_valid_file_path(char *source, char *resolved_path, int resolved_path_len TSRMLS_DC) {
xmlURI *uri;
xmlChar *escsource;
@@ -125,11 +252,13 @@ char *_xmlwriter_get_valid_file_path(char *source, char *resolved_path, int reso
return file_dest;
}
+/* }}} */
#ifndef ZEND_ENGINE_2
/* Channel libxml file io layer through the PHP streams subsystem.
* This allows use of ftps:// and https:// urls */
+/* {{{ php_xmlwriter_streams_IO_open_write_wrapper */
static void *php_xmlwriter_streams_IO_open_write_wrapper(const char *filename TSRMLS_DC)
{
php_stream_wrapper *wrapper = NULL;
@@ -138,18 +267,23 @@ static void *php_xmlwriter_streams_IO_open_write_wrapper(const char *filename TS
ret_val = php_stream_open_wrapper_ex((char *)filename, "wb", ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL, NULL);
return ret_val;
}
+/* }}} */
+/* {{{ php_xmlwriter_streams_IO_write */
int php_xmlwriter_streams_IO_write(void *context, const char *buffer, int len)
{
TSRMLS_FETCH();
return php_stream_write((php_stream*)context, buffer, len);
}
+/* }}} */
+/* {{{ xmlwriter_objects_clone */
int php_xmlwriter_streams_IO_close(void *context)
{
TSRMLS_FETCH();
return php_stream_close((php_stream*)context);
}
+/* }}} */
#endif
/* {{{ xmlwriter_module_entry
@@ -179,21 +313,12 @@ void xmlwriter_objects_clone(void *object, void **object_clone TSRMLS_DC)
}
/* }}} */
+/* {{{ xmlwriter_dtor */
static void xmlwriter_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
xmlwriter_object *intern;
intern = (xmlwriter_object *) rsrc->ptr;
- if (intern) {
- if (intern->ptr) {
- xmlFreeTextWriter(intern->ptr);
- intern->ptr = NULL;
- }
- if (intern->output) {
- xmlBufferFree(intern->output);
- intern->output = NULL;
- }
- efree(intern);
- }
+ xmlwriter_free_resource_ptr(intern TSRMLS_CC);
}
/* }}} */
@@ -208,11 +333,23 @@ PHP_FUNCTION(xmlwriter_set_indent)
int retval;
zend_bool indent;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rb", &pind, &indent) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &pind, &indent) == FAILURE) {
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rb", &pind, &indent) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -236,11 +373,25 @@ PHP_FUNCTION(xmlwriter_set_indent_string)
char *indent;
int indent_len, retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind, &indent, &indent_len) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &indent, &indent_len) == FAILURE) {
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind, &indent, &indent_len) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+
ptr = intern->ptr;
if (ptr) {
@@ -265,18 +416,30 @@ PHP_FUNCTION(xmlwriter_start_attribute)
xmlTextWriterPtr ptr;
char *name;
int name_len, retval;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind, &name, &name_len) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind, &name, &name_len) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
+
retval = xmlValidateName((xmlChar *) name, 0);
if (retval != 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Attribute Name");
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -285,7 +448,7 @@ PHP_FUNCTION(xmlwriter_start_attribute)
RETURN_TRUE;
}
}
-
+
RETURN_FALSE;
}
/* }}} */
@@ -298,12 +461,20 @@ PHP_FUNCTION(xmlwriter_end_attribute)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
int retval;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -327,10 +498,22 @@ PHP_FUNCTION(xmlwriter_start_attribute_ns)
xmlTextWriterPtr ptr;
char *name, *prefix, *uri;
int name_len, prefix_len, uri_len, retval;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsss", &pind,
- &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss",
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsss", &pind,
+ &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
retval = xmlValidateName((xmlChar *) name, 0);
@@ -339,7 +522,7 @@ PHP_FUNCTION(xmlwriter_start_attribute_ns)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+
ptr = intern->ptr;
if (ptr) {
@@ -364,9 +547,23 @@ PHP_FUNCTION(xmlwriter_write_attribute)
char *name, *content;
int name_len, content_len, retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind,
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
+ &name, &name_len, &content, &content_len) == FAILURE) {
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind,
+ &name, &name_len, &content, &content_len) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
retval = xmlValidateName((xmlChar *) name, 0);
@@ -375,7 +572,6 @@ PHP_FUNCTION(xmlwriter_write_attribute)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -399,9 +595,23 @@ PHP_FUNCTION(xmlwriter_write_attribute_ns)
char *name, *prefix, *uri, *content;
int name_len, prefix_len, uri_len, content_len, retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rssss", &pind,
- &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssss",
+ &name, &name_len, &content, &content_len) == FAILURE) {
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rssss", &pind,
+ &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
retval = xmlValidateName((xmlChar *) name, 0);
@@ -410,7 +620,6 @@ PHP_FUNCTION(xmlwriter_write_attribute_ns)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -433,9 +642,21 @@ PHP_FUNCTION(xmlwriter_start_element)
xmlTextWriterPtr ptr;
char *name;
int name_len, retval;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind, &name, &name_len) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind, &name, &name_len) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
retval = xmlValidateName((xmlChar *) name, 0);
@@ -444,7 +665,6 @@ PHP_FUNCTION(xmlwriter_start_element)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -467,10 +687,23 @@ PHP_FUNCTION(xmlwriter_start_element_ns)
xmlTextWriterPtr ptr;
char *name, *prefix, *uri;
int name_len, prefix_len, uri_len, retval;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsss", &pind,
- &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss",
+ &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsss", &pind,
+ &prefix, &prefix_len, &name, &name_len, &uri, &uri_len) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
retval = xmlValidateName((xmlChar *) name, 0);
@@ -479,7 +712,7 @@ PHP_FUNCTION(xmlwriter_start_element_ns)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+
ptr = intern->ptr;
if (ptr) {
@@ -501,12 +734,20 @@ PHP_FUNCTION(xmlwriter_end_element)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
int retval;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -529,10 +770,23 @@ PHP_FUNCTION(xmlwriter_write_element)
xmlTextWriterPtr ptr;
char *name, *content;
int name_len, content_len, retval;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind,
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
+ &name, &name_len, &content, &content_len) == FAILURE) {
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind,
+ &name, &name_len, &content, &content_len) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
retval = xmlValidateName((xmlChar *) name, 0);
@@ -541,7 +795,6 @@ PHP_FUNCTION(xmlwriter_write_element)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -565,9 +818,23 @@ PHP_FUNCTION(xmlwriter_write_element_ns)
char *name, *prefix, *uri, *content;
int name_len, prefix_len, uri_len, content_len, retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rssss", &pind,
- &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rssss",
+ &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rssss", &pind,
+ &prefix, &prefix_len, &name, &name_len, &uri, &uri_len, &content, &content_len) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
retval = xmlValidateName((xmlChar *) name, 0);
@@ -576,7 +843,6 @@ PHP_FUNCTION(xmlwriter_write_element_ns)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -600,8 +866,21 @@ PHP_FUNCTION(xmlwriter_start_pi)
char *target;
int target_len, retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind, &target, &target_len) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &target, &target_len) == FAILURE) {
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind, &target, &target_len) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
retval = xmlValidateName((xmlChar *) target, 0);
@@ -610,7 +889,6 @@ PHP_FUNCTION(xmlwriter_start_pi)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -633,11 +911,20 @@ PHP_FUNCTION(xmlwriter_end_pi)
xmlTextWriterPtr ptr;
int retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -661,9 +948,23 @@ PHP_FUNCTION(xmlwriter_write_pi)
char *target, *content;
int target_len, content_len, retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind,
- &target, &target_len, &content, &content_len) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
+ &target, &target_len, &content, &content_len) == FAILURE) {
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind,
+ &target, &target_len, &content, &content_len) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
retval = xmlValidateName((xmlChar *) target, 0);
@@ -672,7 +973,6 @@ PHP_FUNCTION(xmlwriter_write_pi)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -694,12 +994,20 @@ PHP_FUNCTION(xmlwriter_start_cdata)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
int retval;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -722,11 +1030,20 @@ PHP_FUNCTION(xmlwriter_end_cdata)
xmlTextWriterPtr ptr;
int retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -750,12 +1067,24 @@ PHP_FUNCTION(xmlwriter_write_cdata)
char *content;
int content_len, retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind,
- &content, &content_len) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &content, &content_len) == FAILURE) {
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind,
+ &content, &content_len) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -779,11 +1108,24 @@ PHP_FUNCTION(xmlwriter_text)
char *content;
int content_len, retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind, &content, &content_len) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &content, &content_len) == FAILURE) {
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind, &content, &content_len) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -806,12 +1148,20 @@ PHP_FUNCTION(xmlwriter_start_comment)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
int retval;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -834,11 +1184,20 @@ PHP_FUNCTION(xmlwriter_end_comment)
xmlTextWriterPtr ptr;
int retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -864,12 +1223,26 @@ PHP_FUNCTION(xmlwriter_write_comment)
char *content;
int content_len, retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind,
- &content, &content_len) == FAILURE) {
- return;
+
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
+ &content, &content_len) == FAILURE) {
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind,
+ &content, &content_len) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -893,11 +1266,23 @@ PHP_FUNCTION(xmlwriter_start_document)
char *version = NULL, *enc = NULL, *alone = NULL;
int version_len, enc_len, alone_len, retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|s!s!s!", &pind, &version, &version_len, &enc, &enc_len, &alone, &alone_len) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!s!", &version, &version_len, &enc, &enc_len, &alone, &alone_len) == FAILURE) {
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|s!s!s!", &pind, &version, &version_len, &enc, &enc_len, &alone, &alone_len) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -919,12 +1304,20 @@ PHP_FUNCTION(xmlwriter_end_document)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
int retval;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
- return;
+ if (this) {
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -948,11 +1341,24 @@ PHP_FUNCTION(xmlwriter_start_dtd)
char *name, *pubid = NULL, *sysid = NULL;
int name_len, pubid_len, sysid_len, retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|s!s!", &pind, &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len) == FAILURE) {
- return;
- }
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|s!s!", &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len) == FAILURE) {
+ return;
+ }
+
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|s!s!", &pind, &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ }
ptr = intern->ptr;
if (ptr) {
@@ -974,12 +1380,20 @@ PHP_FUNCTION(xmlwriter_end_dtd)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
int retval;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
- return;
+ if (this) {
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
-
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -1003,11 +1417,25 @@ PHP_FUNCTION(xmlwriter_write_dtd)
char *name, *pubid = NULL, *sysid = NULL, *subset = NULL;
int name_len, pubid_len, sysid_len, subset_len, retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|s!s!s!", &pind, &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len, &subset, &subset_len) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!s!s!", &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len, &subset, &subset_len) == FAILURE) {
+ return;
+ }
+
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|s!s!s!", &pind, &name, &name_len, &pubid, &pubid_len, &sysid, &sysid_len, &subset, &subset_len) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -1031,8 +1459,21 @@ PHP_FUNCTION(xmlwriter_start_dtd_element)
char *name;
int name_len, retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind, &name, &name_len) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind, &name, &name_len) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
retval = xmlValidateName((xmlChar *) name, 0);
@@ -1041,7 +1482,6 @@ PHP_FUNCTION(xmlwriter_start_dtd_element)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -1064,11 +1504,20 @@ PHP_FUNCTION(xmlwriter_end_dtd_element)
xmlTextWriterPtr ptr;
int retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
- return;
- }
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ if (this) {
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ }
ptr = intern->ptr;
if (ptr) {
@@ -1092,9 +1541,22 @@ PHP_FUNCTION(xmlwriter_write_dtd_element)
char *name, *content;
int name_len, content_len, retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind,
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind,
+ &name, &name_len, &content, &content_len) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
retval = xmlValidateName((xmlChar *) name, 0);
@@ -1103,7 +1565,6 @@ PHP_FUNCTION(xmlwriter_write_dtd_element)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -1127,8 +1588,21 @@ PHP_FUNCTION(xmlwriter_start_dtd_attlist)
char *name;
int name_len, retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind, &name, &name_len) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pind, &name, &name_len) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
retval = xmlValidateName((xmlChar *) name, 0);
@@ -1137,7 +1611,6 @@ PHP_FUNCTION(xmlwriter_start_dtd_attlist)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -1160,11 +1633,20 @@ PHP_FUNCTION(xmlwriter_end_dtd_attlist)
xmlTextWriterPtr ptr;
int retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
- return;
- }
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ if (this) {
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ }
ptr = intern->ptr;
if (ptr) {
@@ -1188,9 +1670,24 @@ PHP_FUNCTION(xmlwriter_write_dtd_attlist)
char *name, *content;
int name_len, content_len, retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind,
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
+
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
+ &name, &name_len, &content, &content_len) == FAILURE) {
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind,
+ &name, &name_len, &content, &content_len) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
retval = xmlValidateName((xmlChar *) name, 0);
@@ -1199,7 +1696,7 @@ PHP_FUNCTION(xmlwriter_write_dtd_attlist)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+
ptr = intern->ptr;
if (ptr) {
@@ -1224,8 +1721,22 @@ PHP_FUNCTION(xmlwriter_start_dtd_entity)
int name_len, retval;
zend_bool isparm;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsb", &pind, &name, &name_len, &isparm) == FAILURE) {
- return;
+
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sb", &name, &name_len, &isparm) == FAILURE) {
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsb", &pind, &name, &name_len, &isparm) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
retval = xmlValidateName((xmlChar *) name, 0);
@@ -1234,7 +1745,6 @@ PHP_FUNCTION(xmlwriter_start_dtd_entity)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -1256,12 +1766,20 @@ PHP_FUNCTION(xmlwriter_end_dtd_entity)
xmlwriter_object *intern;
xmlTextWriterPtr ptr;
int retval;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
- return;
+ if (this) {
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &pind) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
-
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -1285,9 +1803,23 @@ PHP_FUNCTION(xmlwriter_write_dtd_entity)
char *name, *content;
int name_len, content_len, retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind,
- &name, &name_len, &content, &content_len) == FAILURE) {
- return;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
+ &name, &name_len, &content, &content_len) == FAILURE) {
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &pind,
+ &name, &name_len, &content, &content_len) == FAILURE) {
+ return;
+ }
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
}
retval = xmlValidateName((xmlChar *) name, 0);
@@ -1296,7 +1828,6 @@ PHP_FUNCTION(xmlwriter_write_dtd_entity)
RETURN_FALSE;
}
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
ptr = intern->ptr;
if (ptr) {
@@ -1320,6 +1851,12 @@ PHP_FUNCTION(xmlwriter_open_uri)
char *source;
char resolved_path[MAXPATHLEN + 1];
int source_len;
+
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+ ze_xmlwriter_object *ze_obj;
+#endif
+
#ifndef ZEND_ENGINE_2
xmlOutputBufferPtr out_buffer;
void *ioctx;
@@ -1329,6 +1866,18 @@ PHP_FUNCTION(xmlwriter_open_uri)
WRONG_PARAM_COUNT;
return;
}
+
+#ifdef ZEND_ENGINE_2
+ if (this) {
+ // We do not use XMLWRITER_FROM_OBJECT, xmlwriter init function here
+ ze_obj = (ze_xmlwriter_object*) zend_object_store_get_object(this TSRMLS_CC);
+ }
+#endif
+
+ if (source_len == 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty string as source");
+ RETURN_FALSE;
+ }
valid_file = _xmlwriter_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC);
if (!valid_file) {
@@ -1352,7 +1901,8 @@ PHP_FUNCTION(xmlwriter_open_uri)
#else
ptr = xmlNewTextWriterFilename(valid_file, 0);
#endif
- if (! ptr) {
+
+ if (!ptr) {
RETURN_FALSE;
}
@@ -1361,10 +1911,15 @@ PHP_FUNCTION(xmlwriter_open_uri)
intern->output = NULL;
#ifndef ZEND_ENGINE_2
intern->uri_output = out_buffer;
+#else
+ if (this) {
+ ze_obj->xmlwriter_ptr = intern;
+ RETURN_TRUE;
+ } else
#endif
-
- ZEND_REGISTER_RESOURCE(return_value,intern,le_xmlwriter);
-
+ {
+ ZEND_REGISTER_RESOURCE(return_value,intern,le_xmlwriter);
+ }
}
/* }}} */
@@ -1376,6 +1931,18 @@ PHP_FUNCTION(xmlwriter_open_memory)
xmlTextWriterPtr ptr;
xmlBufferPtr buffer;
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+ ze_xmlwriter_object *ze_obj;
+#endif
+
+#ifdef ZEND_ENGINE_2
+ if (this) {
+ // We do not use XMLWRITER_FROM_OBJECT, xmlwriter init function here
+ ze_obj = (ze_xmlwriter_object*) zend_object_store_get_object(this TSRMLS_CC);
+ }
+#endif
+
buffer = xmlBufferCreate();
if (buffer == NULL) {
@@ -1394,13 +1961,20 @@ PHP_FUNCTION(xmlwriter_open_memory)
intern->output = buffer;
#ifndef ZEND_ENGINE_2
intern->uri_output = NULL;
+#else
+ if (this) {
+ ze_obj->xmlwriter_ptr = intern;
+ RETURN_TRUE;
+ } else
#endif
-
- ZEND_REGISTER_RESOURCE(return_value,intern,le_xmlwriter);
+ {
+ ZEND_REGISTER_RESOURCE(return_value,intern,le_xmlwriter);
+ }
}
/* }}} */
+/* {{{ php_xmlwriter_flush */
static void php_xmlwriter_flush(INTERNAL_FUNCTION_PARAMETERS, int force_string) {
zval *pind;
xmlwriter_object *intern;
@@ -1409,11 +1983,24 @@ static void php_xmlwriter_flush(INTERNAL_FUNCTION_PARAMETERS, int force_string)
zend_bool empty = 1;
int output_bytes;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|b", &pind, &empty) == FAILURE) {
- return;
- }
- ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+#ifdef ZEND_ENGINE_2
+ zval *this = getThis();
+
+ if (this) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &empty) == FAILURE) {
+ return;
+ }
+ XMLWRITER_FROM_OBJECT(intern, this);
+ } else
+#endif
+ {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|b", &pind, &empty) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(intern,xmlwriter_object *, &pind, -1, "XMLWriter", le_xmlwriter);
+ }
ptr = intern->ptr;
if (ptr) {
@@ -1435,6 +2022,7 @@ static void php_xmlwriter_flush(INTERNAL_FUNCTION_PARAMETERS, int force_string)
RETURN_EMPTY_STRING();
}
+/* }}} */
/* {{{ proto string xmlwriter_output_memory(resource xmlwriter [,bool flush])
Output current buffer as string */
@@ -1459,6 +2047,14 @@ PHP_MINIT_FUNCTION(xmlwriter)
le_xmlwriter = zend_register_list_destructors_ex(xmlwriter_dtor, NULL, "xmlwriter", module_number);
+#ifdef ZEND_ENGINE_2
+ zend_class_entry ce;
+ memcpy(&xmlwriter_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ xmlwriter_object_handlers.clone_obj = NULL;
+ INIT_CLASS_ENTRY(ce, "XMLWriter", xmlwriter_class_functions);
+ ce.create_object = xmlwriter_object_new;
+ xmlwriter_class_entry_ce = zend_register_internal_class(&ce TSRMLS_CC);
+#endif
return SUCCESS;
}
/* }}} */
diff --git a/ext/xmlwriter/php_xmlwriter.h b/ext/xmlwriter/php_xmlwriter.h
index d4f0e33..1c3687e 100644
--- a/ext/xmlwriter/php_xmlwriter.h
+++ b/ext/xmlwriter/php_xmlwriter.h
@@ -38,6 +38,7 @@ extern zend_module_entry xmlwriter_module_entry;
#include <libxml/xmlwriter.h>
#include <libxml/uri.h>
+/* Resource struct, not the object :) */
typedef struct _xmlwriter_object {
xmlTextWriterPtr ptr;
xmlBufferPtr output;
@@ -46,6 +47,18 @@ typedef struct _xmlwriter_object {
#endif
} xmlwriter_object;
+
+/* Extends zend object */
+typedef struct _ze_xmlwriter_object {
+ zend_object zo;
+ xmlwriter_object *xmlwriter_ptr;
+} ze_xmlwriter_object;
+
+static void xmlwriter_free_resource_ptr(xmlwriter_object *intern TSRMLS_DC);
+static void xmlwriter_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC);
+
+zend_class_entry *xmlwriter_class_entry_ce;
+
#if LIBXML_VERSION >= 20605
PHP_FUNCTION(xmlwriter_set_indent);
PHP_FUNCTION(xmlwriter_set_indent_string);