-
Notifications
You must be signed in to change notification settings - Fork 79
/
php_study.h
95 lines (77 loc) · 3.06 KB
/
php_study.h
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
/*
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2016 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: codinghuang |
+----------------------------------------------------------------------+
*/
#ifndef PHP_STUDY_H
#define PHP_STUDY_H
#include "php.h"
#include "php_ini.h"
#include "php_network.h"
#include "php_streams.h"
#include "ext/standard/info.h"
#include "study.h"
#define PHP_STUDY_VERSION "0.1.0"
extern zend_module_entry study_module_entry;
#define phpext_study_ptr &study_module_entry
#ifdef PHP_WIN32
# define PHP_STUDY_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PHP_STUDY_API __attribute__ ((visibility("default")))
#else
# define PHP_STUDY_API
#endif
#ifdef ZTS
#include "TSRM.h"
#endif
/**
* Declare any global variables you may need between the BEGIN and END macros here
*/
ZEND_BEGIN_MODULE_GLOBALS(study)
ZEND_END_MODULE_GLOBALS(study)
void study_coroutine_util_init();
void study_coro_server_init(int module_number);
void study_coro_channel_init();
void study_coro_socket_init(int module_number);
void study_runtime_init();
inline zval *st_zend_read_property(zend_class_entry *class_ptr, zval *obj, const char *s, int len, int silent)
{
zval rv;
return zend_read_property(class_ptr, obj, s, len, silent, &rv);
}
inline zval* st_malloc_zval()
{
return (zval *) emalloc(sizeof(zval));
}
inline zval* st_zval_dup(zval *val)
{
zval *dup = st_malloc_zval();
memcpy(dup, val, sizeof(zval));
return dup;
}
#define ST_SET_CLASS_CREATE(module, _create_object) \
module##_ce_ptr->create_object = _create_object
#define ST_SET_CLASS_FREE(module, _free_obj) \
module##_handlers.free_obj = _free_obj
#define ST_SET_CLASS_CREATE_AND_FREE(module, _create_object, _free_obj) \
ST_SET_CLASS_CREATE(module, _create_object); \
ST_SET_CLASS_FREE(module, _free_obj)
/**
* module##_handlers.offset 保存PHP对象在自定义对象中的偏移量
*/
#define ST_SET_CLASS_CUSTOM_OBJECT(module, _create_object, _free_obj, _struct, _std) \
ST_SET_CLASS_CREATE_AND_FREE(module, _create_object, _free_obj); \
module##_handlers.offset = XtOffsetOf(_struct, _std)
#endif /* PHP_STUDY_H */