30
30
#include "internal_helpers.h"
31
31
#include "php_dom_arginfo.h"
32
32
#include "dom_properties.h"
33
+ #include "token_list.h"
33
34
#include "zend_interfaces.h"
34
35
#include "lexbor/lexbor/core/types.h"
35
36
#include "lexbor/lexbor/core/lexbor.h"
@@ -81,6 +82,7 @@ PHP_DOM_EXPORT zend_class_entry *dom_modern_entityreference_class_entry;
81
82
PHP_DOM_EXPORT zend_class_entry * dom_processinginstruction_class_entry ;
82
83
PHP_DOM_EXPORT zend_class_entry * dom_modern_processinginstruction_class_entry ;
83
84
PHP_DOM_EXPORT zend_class_entry * dom_abstract_base_document_class_entry ;
85
+ PHP_DOM_EXPORT zend_class_entry * dom_token_list_class_entry ;
84
86
#ifdef LIBXML_XPATH_ENABLED
85
87
PHP_DOM_EXPORT zend_class_entry * dom_xpath_class_entry ;
86
88
PHP_DOM_EXPORT zend_class_entry * dom_modern_xpath_class_entry ;
@@ -97,6 +99,7 @@ static zend_object_handlers dom_modern_nodelist_object_handlers;
97
99
static zend_object_handlers dom_html_collection_object_handlers ;
98
100
static zend_object_handlers dom_object_namespace_node_handlers ;
99
101
static zend_object_handlers dom_modern_domimplementation_object_handlers ;
102
+ static zend_object_handlers dom_token_list_object_handlers ;
100
103
#ifdef LIBXML_XPATH_ENABLED
101
104
zend_object_handlers dom_xpath_object_handlers ;
102
105
#endif
@@ -132,6 +135,7 @@ static HashTable dom_modern_entity_prop_handlers;
132
135
static HashTable dom_processinginstruction_prop_handlers ;
133
136
static HashTable dom_modern_processinginstruction_prop_handlers ;
134
137
static HashTable dom_namespace_node_prop_handlers ;
138
+ static HashTable dom_token_list_prop_handlers ;
135
139
#ifdef LIBXML_XPATH_ENABLED
136
140
static HashTable dom_xpath_prop_handlers ;
137
141
#endif
@@ -633,6 +637,18 @@ static zend_object *dom_object_namespace_node_clone_obj(zend_object *zobject)
633
637
return clone ;
634
638
}
635
639
640
+ static zend_object * dom_token_list_new (zend_class_entry * class_type )
641
+ {
642
+ dom_token_list_object * intern = zend_object_alloc (sizeof (* intern ), class_type );
643
+
644
+ intern -> dom .prop_handler = & dom_token_list_prop_handlers ;
645
+
646
+ zend_object_std_init (& intern -> dom .std , class_type );
647
+ object_properties_init (& intern -> dom .std , class_type );
648
+
649
+ return & intern -> dom .std ;
650
+ }
651
+
636
652
static const zend_module_dep dom_deps [] = {
637
653
ZEND_MOD_REQUIRED ("libxml" )
638
654
ZEND_MOD_CONFLICTS ("domxml" )
@@ -658,7 +674,6 @@ zend_module_entry dom_module_entry = { /* {{{ */
658
674
ZEND_GET_MODULE (dom )
659
675
#endif
660
676
661
- void dom_objects_free_storage (zend_object * object );
662
677
void dom_nnodemap_objects_free_storage (zend_object * object );
663
678
static zval * dom_nodelist_read_dimension (zend_object * object , zval * offset , int type , zval * rv );
664
679
static int dom_nodelist_has_dimension (zend_object * object , zval * member , int check_empty );
@@ -732,6 +747,15 @@ PHP_MINIT_FUNCTION(dom)
732
747
dom_object_namespace_node_handlers .free_obj = dom_object_namespace_node_free_storage ;
733
748
dom_object_namespace_node_handlers .clone_obj = dom_object_namespace_node_clone_obj ;
734
749
750
+ memcpy (& dom_token_list_object_handlers , & dom_object_handlers , sizeof (zend_object_handlers ));
751
+ dom_token_list_object_handlers .offset = XtOffsetOf (dom_token_list_object , dom .std );
752
+ dom_token_list_object_handlers .free_obj = dom_token_list_free_obj ;
753
+ /* The IDL has the [SameObject] constraint, which is incompatible with cloning because it imposes that there is only
754
+ * one instance per parent object. */
755
+ dom_token_list_object_handlers .clone_obj = NULL ;
756
+ dom_token_list_object_handlers .read_dimension = dom_token_list_read_dimension ;
757
+ dom_token_list_object_handlers .has_dimension = dom_token_list_has_dimension ;
758
+
735
759
zend_hash_init (& classes , 0 , NULL , NULL , true);
736
760
737
761
dom_adjacent_position_class_entry = register_class_Dom_AdjacentPosition ();
@@ -1033,6 +1057,7 @@ PHP_MINIT_FUNCTION(dom)
1033
1057
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "tagName" , dom_element_tag_name_read , NULL );
1034
1058
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "id" , dom_element_id_read , dom_element_id_write );
1035
1059
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "className" , dom_element_class_name_read , dom_element_class_name_write );
1060
+ DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "classList" , dom_element_class_list_read , NULL );
1036
1061
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "attributes" , dom_node_attributes_read , NULL );
1037
1062
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "firstElementChild" , dom_parent_node_first_element_child_read , NULL );
1038
1063
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "lastElementChild" , dom_parent_node_last_element_child_read , NULL );
@@ -1226,6 +1251,16 @@ PHP_MINIT_FUNCTION(dom)
1226
1251
zend_hash_add_new_ptr (& classes , dom_modern_xpath_class_entry -> name , & dom_xpath_prop_handlers );
1227
1252
#endif
1228
1253
1254
+ dom_token_list_class_entry = register_class_Dom_TokenList (zend_ce_aggregate , zend_ce_countable );
1255
+ dom_token_list_class_entry -> create_object = dom_token_list_new ;
1256
+ dom_token_list_class_entry -> default_object_handlers = & dom_token_list_object_handlers ;
1257
+ dom_token_list_class_entry -> get_iterator = dom_token_list_get_iterator ;
1258
+
1259
+ zend_hash_init (& dom_token_list_prop_handlers , 0 , NULL , NULL , true);
1260
+ DOM_REGISTER_PROP_HANDLER (& dom_token_list_prop_handlers , "length" , dom_token_list_length_read , NULL );
1261
+ DOM_REGISTER_PROP_HANDLER (& dom_token_list_prop_handlers , "value" , dom_token_list_value_read , dom_token_list_value_write );
1262
+ zend_hash_add_new_ptr (& classes , dom_token_list_class_entry -> name , & dom_token_list_prop_handlers );
1263
+
1229
1264
register_php_dom_symbols (module_number );
1230
1265
1231
1266
php_libxml_register_export (dom_node_class_entry , php_dom_export_node );
@@ -1291,6 +1326,7 @@ PHP_MSHUTDOWN_FUNCTION(dom) /* {{{ */
1291
1326
zend_hash_destroy (& dom_modern_entity_prop_handlers );
1292
1327
zend_hash_destroy (& dom_processinginstruction_prop_handlers );
1293
1328
zend_hash_destroy (& dom_modern_processinginstruction_prop_handlers );
1329
+ zend_hash_destroy (& dom_token_list_prop_handlers );
1294
1330
#ifdef LIBXML_XPATH_ENABLED
1295
1331
zend_hash_destroy (& dom_xpath_prop_handlers );
1296
1332
#endif
0 commit comments