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 if ((*invar)->type==IS_NULL) { 28 lvar = (t) 0; 29 } else { 30 convert_to_string_ex(invar); 31 lvar = (t) Z_STRVAL_PP(invar); 32 } 33%enddef 34 35%define %pass_by_val( TYPE, CONVERT_IN ) 36%typemap(in) TYPE 37%{ 38 CONVERT_IN($1,$1_ltype,$input); 39%} 40%typemap(in) const TYPE & ($*1_ltype temp) 41%{ 42 CONVERT_IN(temp,$*1_ltype,$input); 43 $1 = &temp; 44%} 45%typemap(directorout) TYPE 46%{ 47 CONVERT_IN($result,$1_ltype,$input); 48%} 49%typemap(directorout) const TYPE & ($*1_ltype temp) 50%{ 51 CONVERT_IN(temp,$*1_ltype,$input); 52 $result = &temp; 53%} 54%enddef 55 56%fragment("t_output_helper","header") %{ 57static void 58t_output_helper( zval **target, zval *o) { 59 if ( (*target)->type == IS_ARRAY ) { 60 /* it's already an array, just append */ 61 add_next_index_zval( *target, o ); 62 return; 63 } 64 if ( (*target)->type == IS_NULL ) { 65 REPLACE_ZVAL_VALUE(target,o,1); 66 FREE_ZVAL(o); 67 return; 68 } 69 zval *tmp; 70 ALLOC_INIT_ZVAL(tmp); 71 *tmp = **target; 72 zval_copy_ctor(tmp); 73 array_init(*target); 74 add_next_index_zval( *target, tmp); 75 add_next_index_zval( *target, o); 76 77} 78%} 79