6 #include <Zend/Zend_API.h>
10 PSI_Compiler
*PSI_CompilerInit(PSI_Compiler
*C
, PSI_Validator
*V
)
13 C
= malloc(sizeof(*C
));
15 memset(C
, 0, sizeof(*C
));
17 PSI_DataExchange((PSI_Data
*) C
, (PSI_Data
*) V
);
21 typedef struct PSI_ClosureData
{
25 static inline size_t impl_num_min_args(impl
*impl
) {
26 size_t i
, n
= impl
->func
->args
->count
;
28 for (i
= 0; i
< impl
->func
->args
->count
; ++i
) {
29 if (impl
->func
->args
->args
[i
]->def
) {
35 void PSI_Closure(jit_type_t signature
, void *result
, void **args
, void *user_data
)
37 zend_execute_data
*execute_data
= args
[0];
38 zval
*return_value
= args
[1];
39 PSI_ClosureData
*data
= user_data
;
42 if (!data
->impl
->func
->args
->count
) {
43 if (SUCCESS
!= zend_parse_parameters_none()) {
47 ZEND_PARSE_PARAMETERS_START(impl_num_min_args(data
->impl
), data
->impl
->func
->args
->count
)
49 iarg
= data
->impl
->func
->args
->args
[_i
];
53 if (PSI_T_BOOL
== iarg
->type
->type
) {
55 iarg
->val
.bval
= iarg
->def
->type
== PSI_T_TRUE
? 1 : 0;
57 Z_PARAM_BOOL(iarg
->val
.bval
);
58 } else if (PSI_T_INT
== iarg
->type
->type
) {
60 iarg
->val
.lval
= atol(iarg
->def
->text
);
62 Z_PARAM_LONG(iarg
->val
.lval
);
63 } else if (PSI_T_FLOAT
== iarg
->type
->type
) {
65 iarg
->val
.dval
= strtod(iarg
->def
->text
, NULL
);
67 Z_PARAM_DOUBLE(iarg
->val
.dval
);
68 } else if (PSI_T_STRING
== iarg
->type
->type
) {
71 iarg
->val
.str
.len
= strlen(iarg
->def
->text
) - 2;
72 iarg
->val
.str
.val
= &iarg
->def
->text
[1];
74 Z_PARAM_STRING(iarg
->val
.str
.val
, iarg
->val
.str
.len
);
76 error_code
= ZPP_ERROR_FAILURE
;
80 ZEND_PARSE_PARAMETERS_END();