diff options
author | Rob Richards <rrichards@php.net> | 2005-10-13 21:20:12 +0000 |
---|---|---|
committer | Rob Richards <rrichards@php.net> | 2005-10-13 21:20:12 +0000 |
commit | 709f73aea7ce9919989040cb5beb88870cf9d761 (patch) | |
tree | 340fc89b2fd56167ab6a75b122727929a63f94a2 /ext/xmlreader | |
parent | 646500bfe956af0f3f19f93355916f71025af055 (diff) | |
download | php-git-709f73aea7ce9919989040cb5beb88870cf9d761.tar.gz |
MFH: move constants to class
Diffstat (limited to 'ext/xmlreader')
-rw-r--r-- | ext/xmlreader/examples/xmlreader_file.php | 4 | ||||
-rw-r--r-- | ext/xmlreader/examples/xmlreader_string.php | 4 | ||||
-rw-r--r-- | ext/xmlreader/examples/xmlreader_validatedtd.php | 4 | ||||
-rw-r--r-- | ext/xmlreader/php_xmlreader.c | 53 | ||||
-rw-r--r-- | ext/xmlreader/php_xmlreader.h | 2 |
5 files changed, 35 insertions, 32 deletions
diff --git a/ext/xmlreader/examples/xmlreader_file.php b/ext/xmlreader/examples/xmlreader_file.php index 480b152d7e..531e20b6f8 100644 --- a/ext/xmlreader/examples/xmlreader_file.php +++ b/ext/xmlreader/examples/xmlreader_file.php @@ -2,11 +2,11 @@ $reader = new XMLReader(); $reader->open('xmlreader.xml'); while ($reader->read()) { - if ($reader->nodeType != XMLREADER_END_ELEMENT) { + if ($reader->nodeType != XMLREADER::END_ELEMENT) { print "Node Name: ".$reader->name."\n"; print "Node Value: ".$reader->value."\n"; print "Node Depth: ".$reader->depth."\n"; - if ($reader->nodeType==XMLREADER_ELEMENT && $reader->hasAttributes) { + if ($reader->nodeType==XMLREADER::ELEMENT && $reader->hasAttributes) { $attr = $reader->moveToFirstAttribute(); while ($attr) { print " Attribute Name: ".$reader->name."\n"; diff --git a/ext/xmlreader/examples/xmlreader_string.php b/ext/xmlreader/examples/xmlreader_string.php index d545c22c8b..f267245fd9 100644 --- a/ext/xmlreader/examples/xmlreader_string.php +++ b/ext/xmlreader/examples/xmlreader_string.php @@ -13,11 +13,11 @@ $xmlstring = '<books> $reader = new XMLReader(); $reader->XML($xmlstring); while ($reader->read()) { - if ($reader->nodeType != XMLREADER_END_ELEMENT) { + if ($reader->nodeType != XMLREADER::END_ELEMENT) { print "Node Name: ".$reader->name."\n"; print "Node Value: ".$reader->value."\n"; print "Node Depth: ".$reader->depth."\n"; - if ($reader->nodeType==XMLREADER_ELEMENT && $reader->hasAttributes) { + if ($reader->nodeType==XMLREADER::ELEMENT && $reader->hasAttributes) { $attr = $reader->moveToFirstAttribute(); while ($attr) { print " Attribute Name: ".$reader->name."\n"; diff --git a/ext/xmlreader/examples/xmlreader_validatedtd.php b/ext/xmlreader/examples/xmlreader_validatedtd.php index 5173154f5a..520a61ee30 100644 --- a/ext/xmlreader/examples/xmlreader_validatedtd.php +++ b/ext/xmlreader/examples/xmlreader_validatedtd.php @@ -3,8 +3,8 @@ $indent = 5; /* Number of spaces to indent per level */ $xml = new XMLReader(); $xml->open("dtdexample.xml"); -$xml->setParserProperty(XMLREADER_LOADDTD, TRUE); -$xml->setParserProperty(XMLREADER_VALIDATE, TRUE); +$xml->setParserProperty(XMLREADER::LOADDTD, TRUE); +$xml->setParserProperty(XMLREADER::VALIDATE, TRUE); while($xml->read()) { /* Print node name indenting it based on depth and $indent var */ print str_repeat(" ", $xml->depth * $indent).$xml->name."\n"; diff --git a/ext/xmlreader/php_xmlreader.c b/ext/xmlreader/php_xmlreader.c index 89448739eb..36754f40ca 100644 --- a/ext/xmlreader/php_xmlreader.c +++ b/ext/xmlreader/php_xmlreader.c @@ -1104,36 +1104,37 @@ PHP_MINIT_FUNCTION(xmlreader) xmlreader_register_prop_handler(&xmlreader_prop_handlers, "xmlLang", NULL, xmlTextReaderXmlLang, IS_STRING TSRMLS_CC); /* Constants for NodeType - cannot define common types to share with dom as there are differences in these types */ - REGISTER_LONG_CONSTANT("XMLREADER_NONE", XML_READER_TYPE_NONE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_ELEMENT", XML_READER_TYPE_ELEMENT, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_ATTRIBUTE", XML_READER_TYPE_ATTRIBUTE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_TEXT", XML_READER_TYPE_TEXT, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_CDATA", XML_READER_TYPE_CDATA, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_ENTITY_REF", XML_READER_TYPE_ENTITY_REFERENCE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_ENTITY", XML_READER_TYPE_ENTITY, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_PI", XML_READER_TYPE_PROCESSING_INSTRUCTION, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_COMMENT", XML_READER_TYPE_COMMENT, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_DOC", XML_READER_TYPE_DOCUMENT, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_DOC_TYPE", XML_READER_TYPE_DOCUMENT_TYPE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_DOC_FRAGMENT", XML_READER_TYPE_DOCUMENT_FRAGMENT, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_NOTATION", XML_READER_TYPE_NOTATION, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_WHITESPACE", XML_READER_TYPE_WHITESPACE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_SIGNIFICANT_WHITESPACE", XML_READER_TYPE_SIGNIFICANT_WHITESPACE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_END_ELEMENT", XML_READER_TYPE_END_ELEMENT, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_END_ENTITY", XML_READER_TYPE_END_ENTITY, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_XML_DECLARATION", XML_READER_TYPE_XML_DECLARATION, CONST_CS | CONST_PERSISTENT); + + REGISTER_XMLREADER_CLASS_CONST_LONG("NONE", XML_READER_TYPE_NONE); + REGISTER_XMLREADER_CLASS_CONST_LONG("ELEMENT", XML_READER_TYPE_ELEMENT); + REGISTER_XMLREADER_CLASS_CONST_LONG("ATTRIBUTE", XML_READER_TYPE_ATTRIBUTE); + REGISTER_XMLREADER_CLASS_CONST_LONG("TEXT", XML_READER_TYPE_TEXT); + REGISTER_XMLREADER_CLASS_CONST_LONG("CDATA", XML_READER_TYPE_CDATA); + REGISTER_XMLREADER_CLASS_CONST_LONG("ENTITY_REF", XML_READER_TYPE_ENTITY_REFERENCE); + REGISTER_XMLREADER_CLASS_CONST_LONG("ENTITY", XML_READER_TYPE_ENTITY); + REGISTER_XMLREADER_CLASS_CONST_LONG("PI", XML_READER_TYPE_PROCESSING_INSTRUCTION); + REGISTER_XMLREADER_CLASS_CONST_LONG("COMMENT", XML_READER_TYPE_COMMENT); + REGISTER_XMLREADER_CLASS_CONST_LONG("DOC", XML_READER_TYPE_DOCUMENT); + REGISTER_XMLREADER_CLASS_CONST_LONG("DOC_TYPE", XML_READER_TYPE_DOCUMENT_TYPE); + REGISTER_XMLREADER_CLASS_CONST_LONG("DOC_FRAGMENT", XML_READER_TYPE_DOCUMENT_FRAGMENT); + REGISTER_XMLREADER_CLASS_CONST_LONG("NOTATION", XML_READER_TYPE_NOTATION); + REGISTER_XMLREADER_CLASS_CONST_LONG("WHITESPACE", XML_READER_TYPE_WHITESPACE); + REGISTER_XMLREADER_CLASS_CONST_LONG("SIGNIFICANT_WHITESPACE", XML_READER_TYPE_SIGNIFICANT_WHITESPACE); + REGISTER_XMLREADER_CLASS_CONST_LONG("END_ELEMENT", XML_READER_TYPE_END_ELEMENT); + REGISTER_XMLREADER_CLASS_CONST_LONG("END_ENTITY", XML_READER_TYPE_END_ENTITY); + REGISTER_XMLREADER_CLASS_CONST_LONG("XML_DECLARATION", XML_READER_TYPE_XML_DECLARATION); /* Constants for Parser options */ - REGISTER_LONG_CONSTANT("XMLREADER_LOADDTD", XML_PARSER_LOADDTD, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_DEFAULTATTRS", XML_PARSER_DEFAULTATTRS, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_VALIDATE", XML_PARSER_VALIDATE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_SUBST_ENTITIES", XML_PARSER_SUBST_ENTITIES, CONST_CS | CONST_PERSISTENT); + REGISTER_XMLREADER_CLASS_CONST_LONG("LOADDTD", XML_PARSER_LOADDTD); + REGISTER_XMLREADER_CLASS_CONST_LONG("DEFAULTATTRS", XML_PARSER_DEFAULTATTRS); + REGISTER_XMLREADER_CLASS_CONST_LONG("VALIDATE", XML_PARSER_VALIDATE); + REGISTER_XMLREADER_CLASS_CONST_LONG("SUBST_ENTITIES", XML_PARSER_SUBST_ENTITIES); /* Constants for Errors when loading - not yet used until we implement custom error handling - REGISTER_LONG_CONSTANT("XMLREADER_VALIDITY_WARNING", XML_PARSER_SEVERITY_VALIDITY_WARNING, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_VALIDITY_ERROR", XML_PARSER_SEVERITY_VALIDITY_ERROR, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_WARNING", XML_PARSER_SEVERITY_WARNING, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XMLREADER_ERROR", XML_PARSER_SEVERITY_ERROR, CONST_CS | CONST_PERSISTENT); + REGISTER_XMLREADER_CLASS_CONST_LONG("VALIDITY_WARNING", XML_PARSER_SEVERITY_VALIDITY_WARNING, CONST_CS | CONST_PERSISTENT); + REGISTER_XMLREADER_CLASS_CONST_LONG("VALIDITY_ERROR", XML_PARSER_SEVERITY_VALIDITY_ERROR, CONST_CS | CONST_PERSISTENT); + REGISTER_XMLREADER_CLASS_CONST_LONG("WARNING", XML_PARSER_SEVERITY_WARNING, CONST_CS | CONST_PERSISTENT); + REGISTER_XMLREADER_CLASS_CONST_LONG("ERROR", XML_PARSER_SEVERITY_ERROR, CONST_CS | CONST_PERSISTENT); */ return SUCCESS; diff --git a/ext/xmlreader/php_xmlreader.h b/ext/xmlreader/php_xmlreader.h index c41112fa38..1191794181 100644 --- a/ext/xmlreader/php_xmlreader.h +++ b/ext/xmlreader/php_xmlreader.h @@ -53,6 +53,8 @@ PHP_MINIT_FUNCTION(xmlreader); PHP_MSHUTDOWN_FUNCTION(xmlreader); PHP_MINFO_FUNCTION(xmlreader); +#define REGISTER_XMLREADER_CLASS_CONST_LONG(const_name, value) \ + zend_declare_class_constant_long(xmlreader_class_entry, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC); #ifdef ZTS #define XMLREADER_G(v) TSRMG(xmlreader_globals_id, zend_xmlreader_globals *, v) |