27
27
#include "internal_helpers.h"
28
28
#include "php_dom_arginfo.h"
29
29
#include "dom_properties.h"
30
+ #include "token_list.h"
30
31
#include "zend_interfaces.h"
31
32
#include "lexbor/lexbor/core/types.h"
32
33
#include "lexbor/lexbor/core/lexbor.h"
@@ -77,6 +78,7 @@ PHP_DOM_EXPORT zend_class_entry *dom_modern_entityreference_class_entry;
77
78
PHP_DOM_EXPORT zend_class_entry * dom_processinginstruction_class_entry ;
78
79
PHP_DOM_EXPORT zend_class_entry * dom_modern_processinginstruction_class_entry ;
79
80
PHP_DOM_EXPORT zend_class_entry * dom_abstract_base_document_class_entry ;
81
+ PHP_DOM_EXPORT zend_class_entry * dom_token_list_class_entry ;
80
82
#ifdef LIBXML_XPATH_ENABLED
81
83
PHP_DOM_EXPORT zend_class_entry * dom_xpath_class_entry ;
82
84
PHP_DOM_EXPORT zend_class_entry * dom_modern_xpath_class_entry ;
@@ -91,6 +93,7 @@ static zend_object_handlers dom_modern_nnodemap_object_handlers;
91
93
static zend_object_handlers dom_modern_nodelist_object_handlers ;
92
94
static zend_object_handlers dom_object_namespace_node_handlers ;
93
95
static zend_object_handlers dom_modern_domimplementation_object_handlers ;
96
+ static zend_object_handlers dom_token_list_object_handlers ;
94
97
#ifdef LIBXML_XPATH_ENABLED
95
98
zend_object_handlers dom_xpath_object_handlers ;
96
99
#endif
@@ -124,6 +127,7 @@ static HashTable dom_modern_entity_prop_handlers;
124
127
static HashTable dom_processinginstruction_prop_handlers ;
125
128
static HashTable dom_modern_processinginstruction_prop_handlers ;
126
129
static HashTable dom_namespace_node_prop_handlers ;
130
+ static HashTable dom_token_list_prop_handlers ;
127
131
#ifdef LIBXML_XPATH_ENABLED
128
132
static HashTable dom_xpath_prop_handlers ;
129
133
#endif
@@ -623,6 +627,18 @@ static zend_object *dom_object_namespace_node_clone_obj(zend_object *zobject)
623
627
return clone ;
624
628
}
625
629
630
+ static zend_object * dom_token_list_new (zend_class_entry * class_type )
631
+ {
632
+ dom_token_list_object * intern = zend_object_alloc (sizeof (* intern ), class_type );
633
+
634
+ intern -> dom .prop_handler = & dom_token_list_prop_handlers ;
635
+
636
+ zend_object_std_init (& intern -> dom .std , class_type );
637
+ object_properties_init (& intern -> dom .std , class_type );
638
+
639
+ return & intern -> dom .std ;
640
+ }
641
+
626
642
static const zend_module_dep dom_deps [] = {
627
643
ZEND_MOD_REQUIRED ("libxml" )
628
644
ZEND_MOD_CONFLICTS ("domxml" )
@@ -648,7 +664,6 @@ zend_module_entry dom_module_entry = { /* {{{ */
648
664
ZEND_GET_MODULE (dom )
649
665
#endif
650
666
651
- void dom_objects_free_storage (zend_object * object );
652
667
void dom_nnodemap_objects_free_storage (zend_object * object );
653
668
static zval * dom_nodelist_read_dimension (zend_object * object , zval * offset , int type , zval * rv );
654
669
static int dom_nodelist_has_dimension (zend_object * object , zval * member , int check_empty );
@@ -721,6 +736,15 @@ PHP_MINIT_FUNCTION(dom)
721
736
dom_object_namespace_node_handlers .free_obj = dom_object_namespace_node_free_storage ;
722
737
dom_object_namespace_node_handlers .clone_obj = dom_object_namespace_node_clone_obj ;
723
738
739
+ memcpy (& dom_token_list_object_handlers , & dom_object_handlers , sizeof (zend_object_handlers ));
740
+ dom_token_list_object_handlers .offset = XtOffsetOf (dom_token_list_object , dom .std );
741
+ dom_token_list_object_handlers .free_obj = dom_token_list_free_obj ;
742
+ /* The IDL has the [SameObject] constraint, which is incompatible with cloning because it imposes that there is only
743
+ * one instance per parent object. */
744
+ dom_token_list_object_handlers .clone_obj = NULL ;
745
+ dom_token_list_object_handlers .read_dimension = dom_token_list_read_dimension ;
746
+ dom_token_list_object_handlers .has_dimension = dom_token_list_has_dimension ;
747
+
724
748
zend_hash_init (& classes , 0 , NULL , NULL , true);
725
749
726
750
dom_domexception_class_entry = register_class_DOMException (zend_ce_exception );
@@ -1017,6 +1041,7 @@ PHP_MINIT_FUNCTION(dom)
1017
1041
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "tagName" , dom_element_tag_name_read , NULL );
1018
1042
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "id" , dom_element_id_read , dom_element_id_write );
1019
1043
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "className" , dom_element_class_name_read , dom_element_class_name_write );
1044
+ DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "classList" , dom_element_class_list_read , NULL );
1020
1045
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "attributes" , dom_node_attributes_read , NULL );
1021
1046
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "firstElementChild" , dom_parent_node_first_element_child_read , NULL );
1022
1047
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "lastElementChild" , dom_parent_node_last_element_child_read , NULL );
@@ -1191,6 +1216,16 @@ PHP_MINIT_FUNCTION(dom)
1191
1216
zend_hash_add_new_ptr (& classes , dom_modern_xpath_class_entry -> name , & dom_xpath_prop_handlers );
1192
1217
#endif
1193
1218
1219
+ dom_token_list_class_entry = register_class_DOM_TokenList (zend_ce_aggregate , zend_ce_countable );
1220
+ dom_token_list_class_entry -> create_object = dom_token_list_new ;
1221
+ dom_token_list_class_entry -> default_object_handlers = & dom_token_list_object_handlers ;
1222
+ dom_token_list_class_entry -> get_iterator = dom_token_list_get_iterator ;
1223
+
1224
+ zend_hash_init (& dom_token_list_prop_handlers , 0 , NULL , NULL , true);
1225
+ DOM_REGISTER_PROP_HANDLER (& dom_token_list_prop_handlers , "length" , dom_token_list_length_read , NULL );
1226
+ DOM_REGISTER_PROP_HANDLER (& dom_token_list_prop_handlers , "value" , dom_token_list_value_read , dom_token_list_value_write );
1227
+ zend_hash_add_new_ptr (& classes , dom_token_list_class_entry -> name , & dom_token_list_prop_handlers );
1228
+
1194
1229
register_php_dom_symbols (module_number );
1195
1230
1196
1231
php_libxml_register_export (dom_node_class_entry , php_dom_export_node );
@@ -1254,6 +1289,7 @@ PHP_MSHUTDOWN_FUNCTION(dom) /* {{{ */
1254
1289
zend_hash_destroy (& dom_modern_entity_prop_handlers );
1255
1290
zend_hash_destroy (& dom_processinginstruction_prop_handlers );
1256
1291
zend_hash_destroy (& dom_modern_processinginstruction_prop_handlers );
1292
+ zend_hash_destroy (& dom_token_list_prop_handlers );
1257
1293
#ifdef LIBXML_XPATH_ENABLED
1258
1294
zend_hash_destroy (& dom_xpath_prop_handlers );
1259
1295
#endif
0 commit comments