summaryrefslogtreecommitdiff
path: root/ext/xmlreader/php_xmlreader.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/xmlreader/php_xmlreader.c')
-rw-r--r--ext/xmlreader/php_xmlreader.c79
1 files changed, 35 insertions, 44 deletions
diff --git a/ext/xmlreader/php_xmlreader.c b/ext/xmlreader/php_xmlreader.c
index 6c1da2761d..38343e514b 100644
--- a/ext/xmlreader/php_xmlreader.c
+++ b/ext/xmlreader/php_xmlreader.c
@@ -61,11 +61,14 @@ typedef struct _xmlreader_prop_handler {
static void xmlreader_register_prop_handler(HashTable *prop_handler, char *name, xmlreader_read_int_t read_int_func, xmlreader_read_const_char_t read_char_func, int rettype)
{
xmlreader_prop_handler hnd;
+ zend_string *str;
hnd.read_char_func = read_char_func;
hnd.read_int_func = read_int_func;
hnd.type = rettype;
- zend_hash_str_add_mem(prop_handler, name, strlen(name), &hnd, sizeof(xmlreader_prop_handler));
+ str = zend_string_init_interned(name, strlen(name), 1);
+ zend_hash_add_mem(prop_handler, str, &hnd, sizeof(xmlreader_prop_handler));
+ zend_string_release_ex(str, 1);
}
/* }}} */
@@ -119,12 +122,9 @@ zval *xmlreader_get_property_ptr_ptr(zval *object, zval *member, int type, void
zval tmp_member;
zval *retval = NULL;
xmlreader_prop_handler *hnd = NULL;
- zend_object_handlers *std_hnd;
if (Z_TYPE_P(member) != IS_STRING) {
- tmp_member = *member;
- zval_copy_ctor(&tmp_member);
- convert_to_string(&tmp_member);
+ ZVAL_STR(&tmp_member, zval_get_string_func(member));
member = &tmp_member;
}
@@ -135,12 +135,11 @@ zval *xmlreader_get_property_ptr_ptr(zval *object, zval *member, int type, void
}
if (hnd == NULL) {
- std_hnd = zend_get_std_object_handlers();
- retval = std_hnd->get_property_ptr_ptr(object, member, type, cache_slot);
+ retval = zend_std_get_property_ptr_ptr(object, member, type, cache_slot);
}
if (member == &tmp_member) {
- zval_dtor(member);
+ zval_ptr_dtor_str(&tmp_member);
}
return retval;
@@ -154,12 +153,9 @@ zval *xmlreader_read_property(zval *object, zval *member, int type, void **cache
zval tmp_member;
zval *retval = NULL;
xmlreader_prop_handler *hnd = NULL;
- zend_object_handlers *std_hnd;
if (Z_TYPE_P(member) != IS_STRING) {
- tmp_member = *member;
- zval_copy_ctor(&tmp_member);
- convert_to_string(&tmp_member);
+ ZVAL_STR(&tmp_member, zval_get_string_func(member));
member = &tmp_member;
}
@@ -176,12 +172,11 @@ zval *xmlreader_read_property(zval *object, zval *member, int type, void **cache
retval = rv;
}
} else {
- std_hnd = zend_get_std_object_handlers();
- retval = std_hnd->read_property(object, member, type, cache_slot, rv);
+ retval = zend_std_read_property(object, member, type, cache_slot, rv);
}
if (member == &tmp_member) {
- zval_dtor(member);
+ zval_ptr_dtor_str(&tmp_member);
}
return retval;
}
@@ -193,12 +188,9 @@ void xmlreader_write_property(zval *object, zval *member, zval *value, void **ca
xmlreader_object *obj;
zval tmp_member;
xmlreader_prop_handler *hnd = NULL;
- zend_object_handlers *std_hnd;
if (Z_TYPE_P(member) != IS_STRING) {
- tmp_member = *member;
- zval_copy_ctor(&tmp_member);
- convert_to_string(&tmp_member);
+ ZVAL_STR(&tmp_member, zval_get_string_func(member));
member = &tmp_member;
}
@@ -210,12 +202,11 @@ void xmlreader_write_property(zval *object, zval *member, zval *value, void **ca
if (hnd != NULL) {
php_error_docref(NULL, E_WARNING, "Cannot write to read-only property");
} else {
- std_hnd = zend_get_std_object_handlers();
- std_hnd->write_property(object, member, value, cache_slot);
+ zend_std_write_property(object, member, value, cache_slot);
}
if (member == &tmp_member) {
- zval_dtor(member);
+ zval_ptr_dtor_str(&tmp_member);
}
}
/* }}} */
@@ -386,7 +377,7 @@ zend_object *xmlreader_objects_new(zend_class_entry *class_type)
{
xmlreader_object *intern;
- intern = ecalloc(1, sizeof(xmlreader_object) + zend_object_properties_size(class_type));
+ intern = zend_object_alloc(sizeof(xmlreader_object), class_type);
zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
intern->prop_handler = &xmlreader_prop_handlers;
@@ -532,7 +523,7 @@ static void php_xmlreader_set_relaxng_schema(INTERNAL_FUNCTION_PARAMETERS, int t
}
/* }}} */
-/* {{{ proto boolean XMLReader::close()
+/* {{{ proto bool XMLReader::close()
Closes xmlreader - current frees resources until xmlTextReaderClose is fixed in libxml */
PHP_METHOD(xmlreader, close)
{
@@ -615,7 +606,7 @@ PHP_METHOD(xmlreader, getAttributeNs)
}
/* }}} */
-/* {{{ proto boolean XMLReader::getParserProperty(int property)
+/* {{{ proto bool XMLReader::getParserProperty(int property)
Indicates whether given property (one of the parser option constants) is set or not on parser */
PHP_METHOD(xmlreader, getParserProperty)
{
@@ -643,7 +634,7 @@ PHP_METHOD(xmlreader, getParserProperty)
}
/* }}} */
-/* {{{ proto boolean XMLReader::isValid()
+/* {{{ proto bool XMLReader::isValid()
Returns boolean indicating if parsed document is valid or not.
Must set XMLREADER_LOADDTD or XMLREADER_VALIDATE parser option prior to the first call to read
or this method will always return FALSE */
@@ -661,7 +652,7 @@ PHP_METHOD(xmlreader, lookupNamespace)
}
/* }}} */
-/* {{{ proto boolean XMLReader::moveToAttribute(string name)
+/* {{{ proto bool XMLReader::moveToAttribute(string name)
Positions reader at specified attribute - Returns TRUE on success and FALSE on failure */
PHP_METHOD(xmlreader, moveToAttribute)
{
@@ -694,7 +685,7 @@ PHP_METHOD(xmlreader, moveToAttribute)
}
/* }}} */
-/* {{{ proto boolean XMLReader::moveToAttributeNo(int index)
+/* {{{ proto bool XMLReader::moveToAttributeNo(int index)
Positions reader at attribute at specified index.
Returns TRUE on success and FALSE on failure */
PHP_METHOD(xmlreader, moveToAttributeNo)
@@ -722,7 +713,7 @@ PHP_METHOD(xmlreader, moveToAttributeNo)
}
/* }}} */
-/* {{{ proto boolean XMLReader::moveToAttributeNs(string name, string namespaceURI)
+/* {{{ proto bool XMLReader::moveToAttributeNs(string name, string namespaceURI)
Positions reader at attribute spcified by name and namespaceURI.
Returns TRUE on success and FALSE on failure */
PHP_METHOD(xmlreader, moveToAttributeNs)
@@ -756,7 +747,7 @@ PHP_METHOD(xmlreader, moveToAttributeNs)
}
/* }}} */
-/* {{{ proto boolean XMLReader::moveToElement()
+/* {{{ proto bool XMLReader::moveToElement()
Moves the position of the current instance to the node that contains the current Attribute node. */
PHP_METHOD(xmlreader, moveToElement)
{
@@ -764,7 +755,7 @@ PHP_METHOD(xmlreader, moveToElement)
}
/* }}} */
-/* {{{ proto boolean XMLReader::moveToFirstAttribute()
+/* {{{ proto bool XMLReader::moveToFirstAttribute()
Moves the position of the current instance to the first attribute associated with the current node. */
PHP_METHOD(xmlreader, moveToFirstAttribute)
{
@@ -772,7 +763,7 @@ PHP_METHOD(xmlreader, moveToFirstAttribute)
}
/* }}} */
-/* {{{ proto boolean XMLReader::moveToNextAttribute()
+/* {{{ proto bool XMLReader::moveToNextAttribute()
Moves the position of the current instance to the next attribute associated with the current node. */
PHP_METHOD(xmlreader, moveToNextAttribute)
{
@@ -780,7 +771,7 @@ PHP_METHOD(xmlreader, moveToNextAttribute)
}
/* }}} */
-/* {{{ proto boolean XMLReader::read()
+/* {{{ proto bool XMLReader::read()
Moves the position of the current instance to the next node in the stream. */
PHP_METHOD(xmlreader, read)
{
@@ -804,7 +795,7 @@ PHP_METHOD(xmlreader, read)
}
/* }}} */
-/* {{{ proto boolean XMLReader::next([string localname])
+/* {{{ proto bool XMLReader::next([string localname])
Moves the position of the current instance to the next node in the stream. */
PHP_METHOD(xmlreader, next)
{
@@ -846,7 +837,7 @@ PHP_METHOD(xmlreader, next)
}
/* }}} */
-/* {{{ proto boolean XMLReader::open(string URI [, string encoding [, int options]])
+/* {{{ proto bool XMLReader::open(string URI [, string encoding [, int options]])
Sets the URI that the XMLReader will parse. */
PHP_METHOD(xmlreader, open)
{
@@ -919,7 +910,7 @@ PHP_METHOD(xmlreader, readInnerXml)
}
/* }}} */
-/* {{{ proto boolean XMLReader::readOuterXml()
+/* {{{ proto bool XMLReader::readOuterXml()
Reads the contents of the current node, including child nodes and markup. */
PHP_METHOD(xmlreader, readOuterXml)
{
@@ -927,7 +918,7 @@ PHP_METHOD(xmlreader, readOuterXml)
}
/* }}} */
-/* {{{ proto boolean XMLReader::readString()
+/* {{{ proto bool XMLReader::readString()
Reads the contents of an element or a text node as a string. */
PHP_METHOD(xmlreader, readString)
{
@@ -935,7 +926,7 @@ PHP_METHOD(xmlreader, readString)
}
/* }}} */
-/* {{{ proto boolean XMLReader::setSchema(string filename)
+/* {{{ proto bool XMLReader::setSchema(string filename)
Use W3C XSD schema to validate the document as it is processed. Activation is only possible before the first Read(). */
PHP_METHOD(xmlreader, setSchema)
{
@@ -978,7 +969,7 @@ PHP_METHOD(xmlreader, setSchema)
/* }}} */
#endif
-/* {{{ proto boolean XMLReader::setParserProperty(int property, boolean value)
+/* {{{ proto bool XMLReader::setParserProperty(int property, bool value)
Sets parser property (one of the parser option constants).
Properties must be set after open() or XML() and before the first read() is called */
PHP_METHOD(xmlreader, setParserProperty)
@@ -1008,7 +999,7 @@ PHP_METHOD(xmlreader, setParserProperty)
}
/* }}} */
-/* {{{ proto boolean XMLReader::setRelaxNGSchema(string filename)
+/* {{{ proto bool XMLReader::setRelaxNGSchema(string filename)
Sets the string that the XMLReader will parse. */
PHP_METHOD(xmlreader, setRelaxNGSchema)
{
@@ -1016,7 +1007,7 @@ PHP_METHOD(xmlreader, setRelaxNGSchema)
}
/* }}} */
-/* {{{ proto boolean XMLReader::setRelaxNGSchemaSource(string source)
+/* {{{ proto bool XMLReader::setRelaxNGSchemaSource(string source)
Sets the string that the XMLReader will parse. */
PHP_METHOD(xmlreader, setRelaxNGSchemaSource)
{
@@ -1030,7 +1021,7 @@ XMLPUBFUN int XMLCALL
xmlSchemaPtr schema);
*/
-/* {{{ proto boolean XMLReader::XML(string source [, string encoding [, int options]])
+/* {{{ proto bool XMLReader::XML(string source [, string encoding [, int options]])
Sets the string that the XMLReader will parse. */
PHP_METHOD(xmlreader, XML)
{
@@ -1116,7 +1107,7 @@ PHP_METHOD(xmlreader, XML)
}
/* }}} */
-/* {{{ proto boolean XMLReader::expand()
+/* {{{ proto bool XMLReader::expand()
Moves the position of the current instance to the next node in the stream. */
PHP_METHOD(xmlreader, expand)
{
@@ -1306,7 +1297,7 @@ PHP_MINIT_FUNCTION(xmlreader)
zend_class_entry ce;
- memcpy(&xmlreader_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ memcpy(&xmlreader_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
xmlreader_object_handlers.offset = XtOffsetOf(xmlreader_object, std);
xmlreader_object_handlers.dtor_obj = zend_objects_destroy_object;
xmlreader_object_handlers.free_obj = xmlreader_objects_free_storage;