29
29
#include "internal_helpers.h"
30
30
#include "php_dom_arginfo.h"
31
31
#include "dom_properties.h"
32
+ #include "token_list.h"
32
33
#include "zend_interfaces.h"
33
34
#include "lexbor/lexbor/core/types.h"
34
35
#include "lexbor/lexbor/core/lexbor.h"
@@ -79,6 +80,7 @@ PHP_DOM_EXPORT zend_class_entry *dom_modern_entityreference_class_entry;
79
80
PHP_DOM_EXPORT zend_class_entry * dom_processinginstruction_class_entry ;
80
81
PHP_DOM_EXPORT zend_class_entry * dom_modern_processinginstruction_class_entry ;
81
82
PHP_DOM_EXPORT zend_class_entry * dom_abstract_base_document_class_entry ;
83
+ PHP_DOM_EXPORT zend_class_entry * dom_token_list_class_entry ;
82
84
#ifdef LIBXML_XPATH_ENABLED
83
85
PHP_DOM_EXPORT zend_class_entry * dom_xpath_class_entry ;
84
86
PHP_DOM_EXPORT zend_class_entry * dom_modern_xpath_class_entry ;
@@ -94,6 +96,7 @@ static zend_object_handlers dom_modern_nodelist_object_handlers;
94
96
static zend_object_handlers dom_html_collection_object_handlers ;
95
97
static zend_object_handlers dom_object_namespace_node_handlers ;
96
98
static zend_object_handlers dom_modern_domimplementation_object_handlers ;
99
+ static zend_object_handlers dom_token_list_object_handlers ;
97
100
#ifdef LIBXML_XPATH_ENABLED
98
101
zend_object_handlers dom_xpath_object_handlers ;
99
102
#endif
@@ -129,6 +132,7 @@ static HashTable dom_modern_entity_prop_handlers;
129
132
static HashTable dom_processinginstruction_prop_handlers ;
130
133
static HashTable dom_modern_processinginstruction_prop_handlers ;
131
134
static HashTable dom_namespace_node_prop_handlers ;
135
+ static HashTable dom_token_list_prop_handlers ;
132
136
#ifdef LIBXML_XPATH_ENABLED
133
137
static HashTable dom_xpath_prop_handlers ;
134
138
#endif
@@ -627,6 +631,18 @@ static zend_object *dom_object_namespace_node_clone_obj(zend_object *zobject)
627
631
return clone ;
628
632
}
629
633
634
+ static zend_object * dom_token_list_new (zend_class_entry * class_type )
635
+ {
636
+ dom_token_list_object * intern = zend_object_alloc (sizeof (* intern ), class_type );
637
+
638
+ intern -> dom .prop_handler = & dom_token_list_prop_handlers ;
639
+
640
+ zend_object_std_init (& intern -> dom .std , class_type );
641
+ object_properties_init (& intern -> dom .std , class_type );
642
+
643
+ return & intern -> dom .std ;
644
+ }
645
+
630
646
static const zend_module_dep dom_deps [] = {
631
647
ZEND_MOD_REQUIRED ("libxml" )
632
648
ZEND_MOD_CONFLICTS ("domxml" )
@@ -652,7 +668,6 @@ zend_module_entry dom_module_entry = { /* {{{ */
652
668
ZEND_GET_MODULE (dom )
653
669
#endif
654
670
655
- void dom_objects_free_storage (zend_object * object );
656
671
void dom_nnodemap_objects_free_storage (zend_object * object );
657
672
static zval * dom_nodelist_read_dimension (zend_object * object , zval * offset , int type , zval * rv );
658
673
static int dom_nodelist_has_dimension (zend_object * object , zval * member , int check_empty );
@@ -726,6 +741,15 @@ PHP_MINIT_FUNCTION(dom)
726
741
dom_object_namespace_node_handlers .free_obj = dom_object_namespace_node_free_storage ;
727
742
dom_object_namespace_node_handlers .clone_obj = dom_object_namespace_node_clone_obj ;
728
743
744
+ memcpy (& dom_token_list_object_handlers , & dom_object_handlers , sizeof (zend_object_handlers ));
745
+ dom_token_list_object_handlers .offset = XtOffsetOf (dom_token_list_object , dom .std );
746
+ dom_token_list_object_handlers .free_obj = dom_token_list_free_obj ;
747
+ /* The IDL has the [SameObject] constraint, which is incompatible with cloning because it imposes that there is only
748
+ * one instance per parent object. */
749
+ dom_token_list_object_handlers .clone_obj = NULL ;
750
+ dom_token_list_object_handlers .read_dimension = dom_token_list_read_dimension ;
751
+ dom_token_list_object_handlers .has_dimension = dom_token_list_has_dimension ;
752
+
729
753
zend_hash_init (& classes , 0 , NULL , NULL , true);
730
754
731
755
dom_domexception_class_entry = register_class_DOMException (zend_ce_exception );
@@ -1022,6 +1046,7 @@ PHP_MINIT_FUNCTION(dom)
1022
1046
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "tagName" , dom_element_tag_name_read , NULL );
1023
1047
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "id" , dom_element_id_read , dom_element_id_write );
1024
1048
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "className" , dom_element_class_name_read , dom_element_class_name_write );
1049
+ DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "classList" , dom_element_class_list_read , NULL );
1025
1050
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "attributes" , dom_node_attributes_read , NULL );
1026
1051
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "firstElementChild" , dom_parent_node_first_element_child_read , NULL );
1027
1052
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "lastElementChild" , dom_parent_node_last_element_child_read , NULL );
@@ -1210,6 +1235,16 @@ PHP_MINIT_FUNCTION(dom)
1210
1235
zend_hash_add_new_ptr (& classes , dom_modern_xpath_class_entry -> name , & dom_xpath_prop_handlers );
1211
1236
#endif
1212
1237
1238
+ dom_token_list_class_entry = register_class_Dom_TokenList (zend_ce_aggregate , zend_ce_countable );
1239
+ dom_token_list_class_entry -> create_object = dom_token_list_new ;
1240
+ dom_token_list_class_entry -> default_object_handlers = & dom_token_list_object_handlers ;
1241
+ dom_token_list_class_entry -> get_iterator = dom_token_list_get_iterator ;
1242
+
1243
+ zend_hash_init (& dom_token_list_prop_handlers , 0 , NULL , NULL , true);
1244
+ DOM_REGISTER_PROP_HANDLER (& dom_token_list_prop_handlers , "length" , dom_token_list_length_read , NULL );
1245
+ DOM_REGISTER_PROP_HANDLER (& dom_token_list_prop_handlers , "value" , dom_token_list_value_read , dom_token_list_value_write );
1246
+ zend_hash_add_new_ptr (& classes , dom_token_list_class_entry -> name , & dom_token_list_prop_handlers );
1247
+
1213
1248
register_php_dom_symbols (module_number );
1214
1249
1215
1250
php_libxml_register_export (dom_node_class_entry , php_dom_export_node );
@@ -1275,6 +1310,7 @@ PHP_MSHUTDOWN_FUNCTION(dom) /* {{{ */
1275
1310
zend_hash_destroy (& dom_modern_entity_prop_handlers );
1276
1311
zend_hash_destroy (& dom_processinginstruction_prop_handlers );
1277
1312
zend_hash_destroy (& dom_modern_processinginstruction_prop_handlers );
1313
+ zend_hash_destroy (& dom_token_list_prop_handlers );
1278
1314
#ifdef LIBXML_XPATH_ENABLED
1279
1315
zend_hash_destroy (& dom_xpath_prop_handlers );
1280
1316
#endif
0 commit comments