flush
[m6w6/ext-psi] / php_psi.h
1
2 #ifndef PHP_PSI_H
3 #define PHP_PSI_H
4
5 extern zend_module_entry psi_module_entry;
6 #define phpext_psi_ptr &psi_module_entry
7
8 #define PHP_PSI_VERSION "0.1.0"
9
10 #ifdef PHP_WIN32
11 # define PHP_PSI_API __declspec(dllexport)
12 #elif defined(__GNUC__) && __GNUC__ >= 4
13 # define PHP_PSI_API __attribute__ ((visibility("default")))
14 #else
15 # define PHP_PSI_API
16 #endif
17
18 #ifdef ZTS
19 #include "TSRM.h"
20 #endif
21
22 #include "context.h"
23 #include "parser.h"
24
25 void psi_error(int type, const char *msg, ...);
26
27 static inline int psi_check_env(const char *var) {
28 char *set = getenv(var);
29 return (set && *set && '0' != *set);
30 }
31
32 typedef struct psi_object {
33 void *data;
34 size_t size;
35 zend_object std;
36 } psi_object;
37
38 static inline psi_object *PSI_OBJ(zval *zv, zend_object *zo) {
39 if (zv) {
40 zo = Z_OBJ_P(zv);
41 }
42 return (void *) (((char *) zo) - zo->handlers->offset);
43 }
44
45 size_t psi_t_alignment(token_t t);
46 size_t psi_t_size(token_t t);
47 size_t psi_t_align(token_t t, size_t s);
48
49 int psi_internal_type(impl_type *type);
50 zend_internal_arg_info *psi_internal_arginfo(impl *impl);
51 size_t psi_num_min_args(impl *impl);
52
53 void psi_to_void(zval *return_value, set_value *set, impl_val *ret_val);
54 void psi_to_bool(zval *return_value, set_value *set, impl_val *ret_val);
55 void psi_to_int(zval *return_value, set_value *set, impl_val *ret_val);
56 void psi_to_double(zval *return_value, set_value *set, impl_val *ret_val);
57 void psi_to_string(zval *return_value, set_value *set, impl_val *ret_val);
58 void psi_to_array(zval *return_value, set_value *set, impl_val *ret_val);
59 void psi_to_object(zval *return_value, set_value *set, impl_val *ret_val);
60
61 void psi_call(zend_execute_data *execute_data, zval *return_value, impl *impl);
62
63 ZEND_BEGIN_MODULE_GLOBALS(psi)
64 char *engine;
65 char *directory;
66 PSI_Context context;
67 ZEND_END_MODULE_GLOBALS(psi);
68
69 #define PSI_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(psi, v)
70
71 #if defined(ZTS) && defined(COMPILE_DL_PSI)
72 ZEND_TSRMLS_CACHE_EXTERN();
73 #endif
74
75 #endif /* PHP_PSI_H */
76
77
78 /*
79 * Local variables:
80 * tab-width: 4
81 * c-basic-offset: 4
82 * End:
83 * vim600: noet sw=4 ts=4 fdm=marker
84 * vim<600: noet sw=4 ts=4
85 */