xref: /ext-ds/php_ds.c (revision c740adb2)
1 #ifdef HAVE_CONFIG_H
2 #include "config.h"
3 #endif
4 
5 #include "php.h"
6 #include "main/php.h"
7 #include "ext/standard/info.h"
8 #include "ext/standard/php_var.h"
9 #include "php_ds.h"
10 
11 #include "src/php/classes/php_hashable_ce.h"
12 #include "src/php/classes/php_collection_ce.h"
13 #include "src/php/classes/php_sequence_ce.h"
14 #include "src/php/classes/php_vector_ce.h"
15 #include "src/php/classes/php_deque_ce.h"
16 #include "src/php/classes/php_set_ce.h"
17 #include "src/php/classes/php_map_ce.h"
18 #include "src/php/classes/php_stack_ce.h"
19 #include "src/php/classes/php_pair_ce.h"
20 #include "src/php/classes/php_priority_queue_ce.h"
21 #include "src/php/classes/php_queue_ce.h"
22 
23 ZEND_DECLARE_MODULE_GLOBALS(ds);
24 
php_ds_init_globals(zend_ds_globals * dsg)25 static inline void php_ds_init_globals(zend_ds_globals *dsg) {
26 	memset(dsg, 0, sizeof(zend_ds_globals));
27 }
28 
PHP_MINIT_FUNCTION(ds)29 PHP_MINIT_FUNCTION(ds)
30 {
31 	ZEND_INIT_MODULE_GLOBALS(ds, php_ds_init_globals, NULL);
32 
33     // Interfaces
34     php_ds_register_hashable();
35     php_ds_register_collection();
36     php_ds_register_sequence();
37 
38     // Classes
39     php_ds_register_vector();
40     php_ds_register_deque();
41     php_ds_register_stack();
42     php_ds_register_queue();
43     php_ds_register_map();
44     php_ds_register_set();
45     php_ds_register_priority_queue();
46     php_ds_register_pair();
47 
48     return SUCCESS;
49 }
50 
PHP_RINIT_FUNCTION(ds)51 PHP_RINIT_FUNCTION(ds)
52 {
53 #if defined(COMPILE_DL_DS) && defined(ZTS)
54     ZEND_TSRMLS_CACHE_UPDATE();
55 #endif
56 
57     return SUCCESS;
58 }
59 
PHP_RSHUTDOWN_FUNCTION(ds)60 PHP_RSHUTDOWN_FUNCTION(ds)
61 {
62     return SUCCESS;
63 }
64 
PHP_MINFO_FUNCTION(ds)65 PHP_MINFO_FUNCTION(ds)
66 {
67     php_info_print_table_start();
68     php_info_print_table_row(2, "ds support", "enabled");
69     php_info_print_table_row(2, "ds version", PHP_DS_VERSION);
70     php_info_print_table_end();
71 }
72 
73 static const zend_module_dep ds_deps[] = {
74     ZEND_MOD_REQUIRED("json")
75     ZEND_MOD_REQUIRED("spl")
76     ZEND_MOD_END
77 };
78 
79 zend_module_entry ds_module_entry = {
80     STANDARD_MODULE_HEADER_EX,
81     NULL,
82     ds_deps,
83     "ds",
84     NULL,
85     PHP_MINIT(ds),
86     NULL,
87     PHP_RINIT(ds),
88     PHP_RSHUTDOWN(ds),
89     PHP_MINFO(ds),
90     PHP_DS_VERSION,
91     STANDARD_MODULE_PROPERTIES
92 };
93 
94 #ifdef COMPILE_DL_DS
95 #ifdef ZTS
96 ZEND_TSRMLS_CACHE_DEFINE();
97 #endif
98 ZEND_GET_MODULE(ds)
99 #endif
100