Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | |
2 | %define CONVERT_BOOL_IN(lvar,t,invar) | |
3 | convert_to_boolean_ex(invar); | |
4 | lvar = (t) Z_LVAL_PP(invar); | |
5 | %enddef | |
6 | ||
7 | %define CONVERT_INT_IN(lvar,t,invar) | |
8 | convert_to_long_ex(invar); | |
9 | lvar = (t) Z_LVAL_PP(invar); | |
10 | %enddef | |
11 | ||
12 | %define CONVERT_INT_OUT(lvar,invar) | |
13 | lvar = (t) Z_LVAL_PP(invar); | |
14 | %enddef | |
15 | ||
16 | %define CONVERT_FLOAT_IN(lvar,t,invar) | |
17 | convert_to_double_ex(invar); | |
18 | lvar = (t) Z_DVAL_PP(invar); | |
19 | %enddef | |
20 | ||
21 | %define CONVERT_CHAR_IN(lvar,t,invar) | |
22 | convert_to_string_ex(invar); | |
23 | lvar = (t) *Z_STRVAL_PP(invar); | |
24 | %enddef | |
25 | ||
26 | %define CONVERT_STRING_IN(lvar,t,invar) | |
27 | convert_to_string_ex(invar); | |
28 | lvar = (t) Z_STRVAL_PP(invar); | |
29 | %enddef | |
30 | ||
31 | %define %pass_by_val( TYPE, CONVERT_IN ) | |
32 | %typemap(in) TYPE | |
33 | { | |
34 | CONVERT_IN($1,$1_ltype,$input); | |
35 | } | |
36 | %enddef | |
37 | ||
38 | %fragment("t_output_helper","header") %{ | |
39 | void | |
40 | t_output_helper( zval **target, zval *o) { | |
41 | if ( (*target)->type == IS_ARRAY ) { | |
42 | /* it's already an array, just append */ | |
43 | add_next_index_zval( *target, o ); | |
44 | return; | |
45 | } | |
46 | if ( (*target)->type == IS_NULL ) { | |
47 | REPLACE_ZVAL_VALUE(target,o,1); | |
48 | return; | |
49 | } | |
50 | zval *tmp; | |
51 | tmp = *target; | |
52 | zval_copy_ctor(tmp); | |
53 | array_init(*target); | |
54 | add_next_index_zval( *target, tmp); | |
55 | add_next_index_zval( *target, o); | |
56 | ||
57 | } | |
58 | %} |