-
-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy pathphp_phalcon.h
180 lines (147 loc) · 4.96 KB
/
php_phalcon.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
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
/*
+------------------------------------------------------------------------+
| Phalcon Framework |
+------------------------------------------------------------------------+
| Copyright (c) 2011-2013 Phalcon Team (http://www.phalconphp.com) |
+------------------------------------------------------------------------+
| This source file is subject to the New BSD License that is bundled |
| with this package in the file docs/LICENSE.txt. |
| |
| If you did not receive a copy of the license and are unable to |
| obtain it through the world-wide-web, please send an email |
| to license@phalconphp.com so we can send you a copy immediately. |
+------------------------------------------------------------------------+
| Authors: Andres Gutierrez <andres@phalconphp.com> |
| Eduar Carvajal <eduar@phalconphp.com> |
+------------------------------------------------------------------------+
*/
#ifndef PHP_PHALCON_H
#define PHP_PHALCON_H 1
#define PHP_PHALCON_VERSION "1.2.0"
#define PHP_PHALCON_EXTNAME "phalcon"
#define PHALCON_MAX_MEMORY_STACK 48
/** Memory frame */
typedef struct _phalcon_memory_entry {
int pointer;
zval ***addresses;
int hash_pointer;
zval ***hash_addresses;
struct _phalcon_memory_entry *prev;
struct _phalcon_memory_entry *next;
} phalcon_memory_entry;
/** Virtual Symbol Table */
typedef struct _phalcon_symbol_table {
struct _phalcon_memory_entry *scope;
HashTable *symbol_table;
struct _phalcon_symbol_table *prev;
} phalcon_symbol_table;
/** ORM options */
typedef struct _phalcon_orm_options {
zend_bool events;
zend_bool virtual_foreign_keys;
zend_bool column_renaming;
zend_bool not_null_validations;
zend_bool exception_on_failed_save;
zend_bool enable_literals;
int cache_level;
int unique_cache_id;
HashTable *parser_cache;
HashTable *ast_cache;
} phalcon_orm_options;
/** DB options */
typedef struct _phalcon_db_options {
zend_bool escape_identifiers;
} phalcon_db_options;
/** DI options */
typedef struct _phalcon_di_options {
zend_bool cache_enabled;
zval **injector;
HashTable *shared_services_cache;
} phalcon_di_options;
ZEND_BEGIN_MODULE_GLOBALS(phalcon)
/** Memory */
phalcon_memory_entry *start_memory;
phalcon_memory_entry *active_memory;
/** Virtual Symbol Tables */
phalcon_symbol_table *active_symbol_table;
/** Function cache */
HashTable *function_cache;
/** Max recursion control */
unsigned int recursive_lock;
/** Stats */
#ifndef PHALCON_RELEASE
unsigned int phalcon_stack_stats;
unsigned int phalcon_number_grows;
unsigned int phalcon_stack_derivate[PHALCON_MAX_MEMORY_STACK];
#endif
/** ORM */
phalcon_orm_options orm;
/** DB */
phalcon_db_options db;
ZEND_END_MODULE_GLOBALS(phalcon)
#ifdef ZTS
#include "TSRM.h"
#endif
ZEND_EXTERN_MODULE_GLOBALS(phalcon)
#ifdef ZTS
#define PHALCON_GLOBAL(v) TSRMG(phalcon_globals_id, zend_phalcon_globals *, v)
#else
#define PHALCON_GLOBAL(v) (phalcon_globals.v)
#endif
#ifdef ZTS
#define PHALCON_VGLOBAL ((zend_phalcon_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(phalcon_globals_id)])
#else
#define PHALCON_VGLOBAL &(phalcon_globals)
#endif
extern zend_module_entry phalcon_module_entry;
#define phpext_phalcon_ptr &phalcon_module_entry
#endif
#if PHP_VERSION_ID >= 50400
#define PHALCON_INIT_FUNCS(class_functions) static const zend_function_entry class_functions[] =
#else
#define PHALCON_INIT_FUNCS(class_functions) static const function_entry class_functions[] =
#endif
#ifndef PHP_FE_END
#define PHP_FE_END { NULL, NULL, NULL, 0, 0 }
#endif
/** Define FASTCALL */
#if defined(__GNUC__) && ZEND_GCC_VERSION >= 3004 && defined(__i386__)
# define PHALCON_FASTCALL __attribute__((fastcall))
#elif defined(_MSC_VER) && defined(_M_IX86)
# define PHALCON_FASTCALL __fastcall
#else
# define PHALCON_FASTCALL
#endif
#define PHALCON_INIT_CLASS(name) \
int phalcon_ ##name## _init(INIT_FUNC_ARGS)
#define PHALCON_INIT(name) \
if (phalcon_ ##name## _init(INIT_FUNC_ARGS_PASSTHRU) == FAILURE) { \
return FAILURE; \
}
/** Macros for branch prediction */
#if defined(__GNUC__) && ZEND_GCC_VERSION >= 3004 && defined(__i386__)
#define likely(x) __builtin_expect((x),1)
#define unlikely(x) __builtin_expect((x),0)
#else
#define likely(x) EXPECTED(x)
#define unlikely(x) UNEXPECTED(x)
#endif
#if defined(__GNUC__) && (defined(__clang__) || ((__GNUC__ * 100 + __GNUC_MINOR__) >= 405))
#define UNREACHABLE() __builtin_unreachable()
#define ASSUME(x) if (x) {} else __builtin_unreachable()
#else
#define UNREACHABLE() assert(0)
#define ASSUME(x) assert(!!(x));
#endif
#ifndef __func__
#define __func__ __FUNCTION__
#endif
#if PHP_VERSION_ID > 50399
# define ZLK_DC , const struct _zend_literal* key
# define ZLK_CC , key
# define ZLK_NULL_CC , NULL
#else
# define ZLK_DC
# define ZLK_CC
# define ZLK_NULL_CC
#endif