This repository was archived by the owner on Oct 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvary.c
320 lines (287 loc) · 14 KB
/
vary.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
/* vary extension for PHP */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "php.h"
#include "ext/standard/info.h"
#include "php_vary.h"
extern zend_class_entry *algorithm_handle;
extern zend_class_entry *_array_handle;
extern zend_class_entry *arrayList_handle;
extern zend_class_entry *setList_handle;
extern zend_class_entry *stack_handle;
extern zend_class_entry *queue_handle;
extern zend_class_entry *deque_handle;
extern zend_class_entry *orderedList_handle;
extern zend_class_entry *_dict_handle;
extern zend_class_entry *mapList_handle;
extern zend_class_entry *conn_handle;
extern zend_class_entry *model_handle;
extern zend_class_entry *router_handle;
#include "./helpers/params.c"
#include "./others/Algorithm.c"
const zend_function_entry algorithm_funcs[] = {
PHP_ME(Algorithm, binarySearch, arginfo_array_integer, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
PHP_ME(Algorithm, shellSort, arginfo_array_function, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
PHP_FE_END
};
#include "./lists/common.c"
#include "./lists/_array.c"
const zend_function_entry _array_funcs[] = {
PHP_ME(_array, __construct, arginfo_array, ZEND_ACC_PUBLIC)
PHP_ME(_array, value, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(_array, length, arginfo_void, ZEND_ACC_PROTECTED)
PHP_ME(_array, index, arginfo_integer, ZEND_ACC_PROTECTED)
PHP_ME(_array, setValue, arginfo_array, ZEND_ACC_PROTECTED)
PHP_ME(_array, removeIndex, arginfo_integer, ZEND_ACC_PROTECTED)
PHP_ME(_array, push, arginfo_any, ZEND_ACC_PROTECTED)
PHP_ME(_array, pop, arginfo_void, ZEND_ACC_PROTECTED)
PHP_ME(_array, unshift, arginfo_any, ZEND_ACC_PROTECTED)
PHP_ME(_array, shift, arginfo_void, ZEND_ACC_PROTECTED)
PHP_ME(_array, splice, arginfo_integer_integer_any, ZEND_ACC_PROTECTED)
PHP_ME(_array, indexOf, arginfo_any, ZEND_ACC_PROTECTED)
PHP_ME(_array, lastIndexOf, arginfo_any, ZEND_ACC_PROTECTED)
PHP_ME(_array, includes, arginfo_any, ZEND_ACC_PROTECTED)
PHP_ME(_array, sort, arginfo_function, ZEND_ACC_PROTECTED)
PHP_ME(_array, reverse, arginfo_void, ZEND_ACC_PROTECTED)
PHP_ME(_array, concat, arginfo_array, ZEND_ACC_PROTECTED)
PHP_ME(_array, slice, arginfo_integer_integer, ZEND_ACC_PROTECTED)
PHP_ME(_array, every, arginfo_function, ZEND_ACC_PROTECTED)
PHP_ME(_array, some, arginfo_function, ZEND_ACC_PROTECTED)
PHP_ME(_array, map, arginfo_function, ZEND_ACC_PROTECTED)
PHP_ME(_array, forEach, arginfo_function, ZEND_ACC_PROTECTED)
PHP_ME(_array, fill, arginfo_any_integer_integer, ZEND_ACC_PROTECTED)
PHP_ME(_array, reduce, arginfo_function_any, ZEND_ACC_PROTECTED)
PHP_ME(_array, reduceRight, arginfo_function_any, ZEND_ACC_PROTECTED)
PHP_ME(_array, filter, arginfo_function, ZEND_ACC_PROTECTED)
PHP_ME(_array, find, arginfo_function, ZEND_ACC_PROTECTED)
PHP_ME(_array, findIndex, arginfo_function, ZEND_ACC_PROTECTED)
PHP_FE_END
};
const zend_function_entry arrayList_funcs[] = {
PHP_ME(_array, length, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(_array, index, arginfo_integer, ZEND_ACC_PUBLIC)
PHP_ME(_array, setValue, arginfo_array, ZEND_ACC_PUBLIC)
PHP_ME(_array, removeIndex, arginfo_integer, ZEND_ACC_PUBLIC)
PHP_ME(_array, push, arginfo_any, ZEND_ACC_PUBLIC)
PHP_ME(_array, pop, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(_array, unshift, arginfo_any, ZEND_ACC_PUBLIC)
PHP_ME(_array, shift, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(_array, splice, arginfo_integer_integer_any, ZEND_ACC_PUBLIC)
PHP_ME(_array, indexOf, arginfo_any, ZEND_ACC_PUBLIC)
PHP_ME(_array, lastIndexOf, arginfo_any, ZEND_ACC_PUBLIC)
PHP_ME(_array, includes, arginfo_any, ZEND_ACC_PUBLIC)
PHP_ME(_array, sort, arginfo_function, ZEND_ACC_PUBLIC)
PHP_ME(_array, reverse, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(_array, concat, arginfo_array, ZEND_ACC_PUBLIC)
PHP_ME(_array, slice, arginfo_integer_integer, ZEND_ACC_PUBLIC)
PHP_ME(_array, every, arginfo_function, ZEND_ACC_PUBLIC)
PHP_ME(_array, some, arginfo_function, ZEND_ACC_PUBLIC)
PHP_ME(_array, map, arginfo_function, ZEND_ACC_PUBLIC)
PHP_ME(_array, forEach, arginfo_function, ZEND_ACC_PUBLIC)
PHP_ME(_array, fill, arginfo_any_integer_integer, ZEND_ACC_PUBLIC)
PHP_ME(_array, reduce, arginfo_function_any, ZEND_ACC_PUBLIC)
PHP_ME(_array, reduceRight, arginfo_function_any, ZEND_ACC_PUBLIC)
PHP_ME(_array, filter, arginfo_function, ZEND_ACC_PUBLIC)
PHP_ME(_array, find, arginfo_function, ZEND_ACC_PUBLIC)
PHP_ME(_array, findIndex, arginfo_function, ZEND_ACC_PUBLIC)
PHP_FE_END
};
const zend_function_entry setList_funcs[] = {
PHP_ME(SetList, __construct, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(SetList, size, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(SetList, has, arginfo_any, ZEND_ACC_PUBLIC)
PHP_ME(SetList, add, arginfo_any, ZEND_ACC_PUBLIC)
PHP_ME(SetList, clear, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(SetList, delete, arginfo_any, ZEND_ACC_PUBLIC)
PHP_FE_END
};
const zend_function_entry stack_funcs[] = {
PHP_ME(_array, length, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(_array, push, arginfo_any, ZEND_ACC_PUBLIC)
PHP_ME(_array, pop, arginfo_void, ZEND_ACC_PUBLIC)
PHP_FE_END
};
const zend_function_entry queue_funcs[] = {
PHP_ME(_array, length, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(_array, push, arginfo_any, ZEND_ACC_PUBLIC)
PHP_ME(_array, shift, arginfo_void, ZEND_ACC_PUBLIC)
PHP_FE_END
};
const zend_function_entry deque_funcs[] = {
PHP_ME(_array, length, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(_array, push, arginfo_any, ZEND_ACC_PUBLIC)
PHP_ME(_array, pop, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(_array, unshift, arginfo_any, ZEND_ACC_PUBLIC)
PHP_ME(_array, shift, arginfo_void, ZEND_ACC_PUBLIC)
PHP_FE_END
};
const zend_function_entry orderedList_funcs[] = {
PHP_ME(OrderedList, __construct, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(_array, length, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(_array, index, arginfo_integer, ZEND_ACC_PUBLIC)
PHP_ME(_array, removeIndex, arginfo_integer, ZEND_ACC_PUBLIC)
PHP_ME(_array, pop, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(_array, shift, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(OrderedList, add, arginfo_integer, ZEND_ACC_PUBLIC)
PHP_ME(OrderedList, remove, arginfo_integer, ZEND_ACC_PUBLIC)
PHP_ME(OrderedList, indexOf, arginfo_integer, ZEND_ACC_PUBLIC)
PHP_FE_END
};
#include "./lists/_dict.c"
const zend_function_entry _dict_funcs[] = {
PHP_ME(_dict, __construct, arginfo_array, ZEND_ACC_PUBLIC)
PHP_ME(_dict, size, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(_dict, value, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(_dict, setValue, arginfo_array, ZEND_ACC_PUBLIC)
PHP_ME(_dict, has, arginfo_any, ZEND_ACC_PUBLIC)
PHP_ME(_dict, get, arginfo_any, ZEND_ACC_PUBLIC)
PHP_ME(_dict, set, arginfo_any_any, ZEND_ACC_PUBLIC)
PHP_ME(_dict, delete, arginfo_any, ZEND_ACC_PUBLIC)
PHP_ME(_dict, clear, arginfo_void, ZEND_ACC_PUBLIC)
PHP_FE_END
};
const zend_function_entry mapList_funcs[] = {
PHP_FE_END
};
#include "./web/conn.c"
#include "./web/model.c"
#include "./web/router.c"
const zend_function_entry conn_funcs[] = {
PHP_ME(Conn, getConn, arginfo_void, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
PHP_ME(Conn, setConn, arginfo_array, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
PHP_FE_END
};
const zend_function_entry model_funcs[] = {
PHP_ME(Model, config, arginfo_void, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
PHP_ME(Model, useTable, arginfo_string, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
PHP_ME(Model, usePrimary, arginfo_string, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
PHP_ME(Model, __construct, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(Model, __set, arginfo_string_any, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL)
PHP_ME(Model, list, arginfo_array, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
PHP_ME(Model, get, arginfo_any, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
PHP_ME(Model, updating, arginfo_array, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
PHP_ME(Model, deleting, arginfo_array, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
PHP_ME(Model, create, arginfo_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL)
PHP_ME(Model, update, arginfo_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL)
PHP_ME(Model, delete, arginfo_void, ZEND_ACC_PUBLIC | ZEND_ACC_FINAL)
PHP_ME(Model, beforeCreate, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(Model, beforeUpdate, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(Model, afterCreate, arginfo_void, ZEND_ACC_PUBLIC)
PHP_ME(Model, afterUpdate, arginfo_void, ZEND_ACC_PUBLIC)
PHP_FE_END
};
const zend_function_entry router_funcs[] = {
PHP_ME(Router, get, arginfo_string_string_string, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
PHP_ME(Router, post, arginfo_string_string_string, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
PHP_ME(Router, put, arginfo_string_string_string, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
PHP_ME(Router, patch, arginfo_string_string_string, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
PHP_ME(Router, delete, arginfo_string_string_string, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
PHP_ME(Router, handle, arginfo_string, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC | ZEND_ACC_FINAL)
PHP_FE_END
};
PHP_MINIT_FUNCTION(vary)
{
/*
* Data Structure
* _array:
* ArrayList, SetList, Stack, Queue, Deque, OrderedList
* _dict:
* MapList
*/
zend_class_entry _array_ce;
INIT_NS_CLASS_ENTRY(_array_ce, "Vary", "_array", _array_funcs);
_array_handle = zend_register_internal_class(&_array_ce TSRMLS_CC);
zend_class_entry arrayList_ce;
INIT_NS_CLASS_ENTRY(arrayList_ce, "Vary", "ArrayList", arrayList_funcs);
arrayList_handle = zend_register_internal_class_ex(&arrayList_ce, _array_handle);
zend_class_entry setList_ce;
INIT_NS_CLASS_ENTRY(setList_ce, "Vary", "SetList", setList_funcs);
setList_handle = zend_register_internal_class_ex(&setList_ce, _array_handle);
zend_class_entry stack_ce;
INIT_NS_CLASS_ENTRY(stack_ce, "Vary", "Stack", stack_funcs);
stack_handle = zend_register_internal_class_ex(&stack_ce, _array_handle);
zend_class_entry queue_ce;
INIT_NS_CLASS_ENTRY(queue_ce, "Vary", "Queue", queue_funcs);
queue_handle = zend_register_internal_class_ex(&queue_ce, _array_handle);
zend_class_entry deque_ce;
INIT_NS_CLASS_ENTRY(deque_ce, "Vary", "Deque", deque_funcs);
deque_handle = zend_register_internal_class_ex(&deque_ce, _array_handle);
zend_class_entry orderedList_ce;
INIT_NS_CLASS_ENTRY(orderedList_ce, "Vary", "OrderedList", orderedList_funcs);
orderedList_handle = zend_register_internal_class_ex(&orderedList_ce, _array_handle);
zend_class_entry _dict_ce;
INIT_NS_CLASS_ENTRY(_dict_ce, "Vary", "_dict", _dict_funcs);
_dict_handle = zend_register_internal_class(&_dict_ce TSRMLS_CC);
zend_class_entry mapList_ce;
INIT_NS_CLASS_ENTRY(mapList_ce, "Vary", "MapList", mapList_funcs);
mapList_handle = zend_register_internal_class_ex(&mapList_ce, _dict_handle);
/*
* Algorithm Functions
* binarySearch, shellShort
*/
zend_class_entry algorithm_ce;
INIT_NS_CLASS_ENTRY(algorithm_ce, "Vary", "Algorithm", algorithm_funcs);
algorithm_handle = zend_register_internal_class(&algorithm_ce TSRMLS_CC);
/*
* Web
* Conn, Model
*/
zend_class_entry conn_ce;
INIT_NS_CLASS_ENTRY(conn_ce, "Vary", "Conn", conn_funcs);
conn_handle = zend_register_internal_class(&conn_ce TSRMLS_CC);
zend_declare_property_null(conn_handle, "__host__", sizeof("__host__") - 1, ZEND_ACC_PROTECTED | ZEND_ACC_STATIC TSRMLS_CC);
zend_declare_property_long(conn_handle, "__port__", sizeof("__port__") - 1, 3306, ZEND_ACC_PROTECTED | ZEND_ACC_STATIC TSRMLS_CC);
zend_declare_property_null(conn_handle, "__database__", sizeof("__database__") - 1, ZEND_ACC_PROTECTED | ZEND_ACC_STATIC TSRMLS_CC);
zend_declare_property_string(conn_handle, "__username__", sizeof("__username__") - 1, "root", ZEND_ACC_PROTECTED | ZEND_ACC_STATIC TSRMLS_CC);
zend_declare_property_string(conn_handle, "__password__", sizeof("__password__") - 1, "", ZEND_ACC_PROTECTED | ZEND_ACC_STATIC TSRMLS_CC);
zend_declare_property_null(conn_handle, "__conn__", sizeof("__conn__") - 1, ZEND_ACC_PROTECTED | ZEND_ACC_STATIC TSRMLS_CC);
zend_class_entry model_ce;
INIT_NS_CLASS_ENTRY(model_ce, "Vary", "Model", model_funcs);
model_handle = zend_register_internal_class(&model_ce TSRMLS_CC);
zend_declare_property_null(model_handle, "__table__", sizeof("__table__") - 1, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC TSRMLS_CC);
zend_declare_property_null(model_handle, "__primary__", sizeof("__primary__") - 1, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC TSRMLS_CC);
zend_declare_property_null(model_handle, "__columns__", sizeof("__columns__") - 1, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC TSRMLS_CC);
zend_declare_property_null(model_handle, "__origin__", sizeof("__origin__") - 1, ZEND_ACC_PUBLIC TSRMLS_CC);
zend_class_entry router_ce;
INIT_NS_CLASS_ENTRY(router_ce, "Vary", "Router", router_funcs);
router_handle = zend_register_internal_class(&router_ce TSRMLS_CC);
zend_declare_property_null(router_handle, "__get__", sizeof("__get__") - 1, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC TSRMLS_CC);
zend_declare_property_null(router_handle, "__post__", sizeof("__post__") - 1, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC TSRMLS_CC);
zend_declare_property_null(router_handle, "__put__", sizeof("__put__") - 1, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC TSRMLS_CC);
zend_declare_property_null(router_handle, "__patch__", sizeof("__patch__") - 1, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC TSRMLS_CC);
zend_declare_property_null(router_handle, "__delete__", sizeof("__delete__") - 1, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC TSRMLS_CC);
return SUCCESS;
}
PHP_RINIT_FUNCTION(vary)
{
#if defined(ZTS) && defined(COMPILE_DL_VARY)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
return SUCCESS;
}
PHP_MINFO_FUNCTION(vary)
{
php_info_print_table_start();
php_info_print_table_header(2, "Library Name", "Vary");
php_info_print_table_header(2, "Author", "Baozier");
php_info_print_table_end();
}
zend_module_entry vary_module_entry = {
STANDARD_MODULE_HEADER,
"vary",
NULL,
PHP_MINIT(vary),
NULL,
PHP_RINIT(vary),
NULL,
PHP_MINFO(vary),
PHP_VARY_VERSION,
STANDARD_MODULE_PROPERTIES
};
#ifdef COMPILE_DL_VARY
# ifdef ZTS
ZEND_TSRMLS_CACHE_DEFINE()
# endif
ZEND_GET_MODULE(vary)
#endif