1 /* -----------------------------------------------------------------------------
2 * See the LICENSE file for information on copyright, usage and redistribution
3 * of SWIG, and the README file for authors - http://www.swig.org/release.html.
7 * PHP configuration file
8 * ----------------------------------------------------------------------------- */
10 %runtime "swigrun.swg" // Common C API type-checking code
11 %runtime "phprun.swg" // PHP runtime functions
13 %include <phpinit.swg> // PHP initialization routine.
15 %include <globalvar.i> // Global variables.
18 // use %init %{ "/*code goes here*/ " %}
19 // or %minit %{ "/* code goes here*/ " %} to
20 // insert code in the PHP_MINIT_FUNCTION
21 #define %minit %insert("init")
23 // use %rinit %{ "/* code goes here*/ " %} to
24 // insert code in the PHP_RINIT_FUNCTION
25 #define %rinit %insert("rinit")
27 // use %shutdown %{ " /*code goes here*/ " %} to
28 // insert code in the PHP_MSHUTDOWN_FUNCTION
29 #define %shutdown %insert("shutdown")
30 #define %mshutdown %insert("shutdown")
32 // use %rshutdown %{ " /*code goes here*/" %} to
33 // insert code in the PHP_RSHUTDOWN_FUNCTION
34 #define %rshutdown %insert("rshutdown")
36 /* Typemaps for input parameters by value */
40 %pass_by_val(bool,CONVERT_BOOL_IN);
42 %pass_by_val(size_t, CONVERT_INT_IN);
44 %pass_by_val(enum SWIGTYPE, CONVERT_INT_IN);
46 %pass_by_val(signed int, CONVERT_INT_IN);
47 %pass_by_val(int,CONVERT_INT_IN);
48 %pass_by_val(unsigned int,CONVERT_INT_IN);
50 %pass_by_val(signed short, CONVERT_INT_IN);
51 %pass_by_val(short,CONVERT_INT_IN);
52 %pass_by_val(unsigned short, CONVERT_INT_IN);
54 %pass_by_val(signed long, CONVERT_INT_IN);
55 %pass_by_val(long, CONVERT_INT_IN);
56 %pass_by_val(unsigned long, CONVERT_INT_IN);
58 %pass_by_val(signed char, CONVERT_INT_IN);
59 %pass_by_val(char, CONVERT_CHAR_IN);
60 %pass_by_val(unsigned char, CONVERT_INT_IN);
62 %pass_by_val(float, CONVERT_FLOAT_IN);
64 %pass_by_val(double, CONVERT_FLOAT_IN);
66 %pass_by_val(char *, CONVERT_STRING_IN);
67 %typemap(in) char *& = const char *&;
68 %typemap(directorout) char *& = const char *&;
70 // char array can be in/out, though the passed string may not be big enough...
71 // so we have to size it
72 %typemap(in) char[ANY]
74 convert_to_string_ex($input);
75 $1 = ($1_ltype) Z_STRVAL_PP($input);
78 %typemap(in) (char *STRING, int LENGTH)
80 convert_to_string_ex($input);
81 $1 = ($1_ltype) Z_STRVAL_PP($input);
82 $2 = ($2_ltype) Z_STRLEN_PP($input);
85 /* Object passed by value. Convert to a pointer */
86 %typemap(in) SWIGTYPE ($&1_ltype tmp)
88 if(SWIG_ConvertPtr(*$input, (void **) &tmp, $&1_descriptor, 0) < 0 || tmp == NULL) {
89 SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor");
94 %typemap(directorout) SWIGTYPE ($&1_ltype tmp)
96 if(SWIG_ConvertPtr(*$input, (void **) &tmp, $&1_descriptor, 0) < 0 || tmp == NULL) {
97 SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor");
102 %typemap(in) SWIGTYPE *,
105 if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0) {
106 SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor");
110 %typemap(in) SWIGTYPE &
112 if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0 || $1 == NULL) {
113 SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor");
117 %typemap(in) SWIGTYPE *& ($*ltype temp)
119 if(SWIG_ConvertPtr(*$input, (void **) &temp, $*1_descriptor, 0) < 0) {
120 SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $*1_descriptor");
125 %typemap(in) SWIGTYPE *DISOWN
127 if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, SWIG_POINTER_DISOWN ) < 0) {
128 SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor");
132 %typemap(argout) SWIGTYPE *,
138 if(SWIG_ConvertPtr(*$input, (void **) &$1, 0, 0) < 0) {
139 /* Allow NULL from php for void* */
140 if ((*$input)->type==IS_NULL) $1=0;
142 SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor");
146 /* Special case when void* is passed by reference so it can be made to point
147 to opaque api structs */
148 %typemap(in) void ** ($*1_ltype ptr, int force),
149 void *& ($*1_ltype ptr, int force)
151 /* If they pass NULL by reference, make it into a void*
152 This bit should go in arginit if arginit support init-ing scripting args */
153 if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0) {
154 /* So... we didn't get a ref or ptr, but we'll accept NULL by reference */
155 if (!((*$input)->type==IS_NULL && PZVAL_IS_REF(*$input))) {
156 /* wasn't a pre/ref/thing, OR anything like an int thing */
157 SWIG_PHP_Error(E_ERROR, "Type error in argument $arg of $symname.");
165 ptr=($*1_ltype) calloc(1,sizeof($*1_ltype));
168 /* have to passback arg$arg too */
172 %typemap(argout) void **,
176 SWIG_SetPointerZval( *$input, (void*) ptr$argnum, $*1_descriptor, 1);
180 /* Typemap for output values */
194 ZVAL_LONG(return_value,$1);
197 %typemap(out) const int &,
198 const unsigned int &,
200 const unsigned short &,
202 const unsigned long &,
204 const unsigned char &,
207 const enum SWIGTYPE &
209 ZVAL_LONG(return_value,*$1);
212 %typemap(directorin) int,
223 ZVAL_LONG($input,$1_name);
228 ZVAL_BOOL(return_value,($1)?1:0);
231 %typemap(out) const bool &
233 ZVAL_BOOL(return_value,(*$1)?1:0);
236 %typemap(directorin) bool
238 ZVAL_BOOL($input,($1_name)?1:0);
244 ZVAL_DOUBLE(return_value,$1);
247 %typemap(out) const float &,
250 ZVAL_DOUBLE(return_value,*$1);
253 %typemap(directorin) float,
256 ZVAL_DOUBLE($input,$1_name);
261 ZVAL_STRINGL(return_value,&$1, 1, 1);
264 %typemap(out) const char &
266 ZVAL_STRINGL(return_value,&*$1, 1, 1);
269 %typemap(out) char *,
273 ZVAL_NULL(return_value);
275 ZVAL_STRING(return_value, (char *)$1, 1);
279 %typemap(out) char *&
282 ZVAL_NULL(return_value);
284 ZVAL_STRING(return_value, (char *)*$1, 1);
288 %typemap(out) SWIGTYPE *,
292 SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner);
295 %typemap(out) SWIGTYPE *&
297 SWIG_SetPointerZval(return_value, (void *)*$1, $*1_descriptor, $owner);
300 %typemap(directorin) SWIGTYPE *,
304 SWIG_SetPointerZval($input, (void *)&$1_name, $1_descriptor, $owner);
307 %typemap(out) SWIGTYPE *DYNAMIC,
310 swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1);
311 SWIG_SetPointerZval(return_value, (void *)$1, ty, $owner);
314 %typemap(out) SWIGTYPE
317 $&1_ltype resultobj = new $1_ltype((const $1_ltype &) $1);
318 SWIG_SetPointerZval(return_value, (void *)resultobj, $&1_descriptor, 1);
322 $&1_ltype resultobj = ($&1_ltype) emalloc(sizeof($1_type));
323 memcpy(resultobj, &$1, sizeof($1_type));
324 SWIG_SetPointerZval(return_value, (void *)resultobj, $&1_descriptor, 1);
328 %typemap(directorin) SWIGTYPE
330 SWIG_SetPointerZval($input, SWIG_as_voidptr(&$1_name), $&1_descriptor, 2);
333 /* Array reference typemaps */
334 %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
337 %typemap(out) void "";
339 %typemap(out) char [ANY]
342 while (len < $1_dim0 && $1[len]) ++len;
343 RETVAL_STRINGL($1, len, 1);
346 // This typecheck does hard checking for proper argument type. If you want
347 // an argument to be converted from a different PHP type, you must convert
348 // it yourself before passing it (e.g. (string)4.7 or (int)"6").
349 %define %php_typecheck(_type,_prec,is)
350 %typemap(typecheck,precedence=_prec) _type, const _type &
351 " $1 = (Z_TYPE_PP($input) == is); "
354 %php_typecheck(int,SWIG_TYPECHECK_INTEGER,IS_LONG)
355 %php_typecheck(unsigned int,SWIG_TYPECHECK_UINT32,IS_LONG)
356 %php_typecheck(short,SWIG_TYPECHECK_INT16,IS_LONG)
357 %php_typecheck(unsigned short,SWIG_TYPECHECK_UINT16,IS_LONG)
358 %php_typecheck(long,SWIG_TYPECHECK_INT64,IS_LONG)
359 %php_typecheck(unsigned long,SWIG_TYPECHECK_UINT64,IS_LONG)
360 %php_typecheck(signed char,SWIG_TYPECHECK_INT8,IS_LONG)
361 %php_typecheck(unsigned char,SWIG_TYPECHECK_UINT8,IS_LONG)
362 %php_typecheck(size_t,SWIG_TYPECHECK_INT16,IS_LONG)
363 %php_typecheck(enum SWIGTYPE,SWIG_TYPECHECK_INT8,IS_LONG)
364 %php_typecheck(bool,SWIG_TYPECHECK_BOOL,IS_BOOL)
365 %php_typecheck(float,SWIG_TYPECHECK_FLOAT,IS_DOUBLE)
366 %php_typecheck(double,SWIG_TYPECHECK_BOOL,IS_DOUBLE)
367 %php_typecheck(char,SWIG_TYPECHECK_CHAR,IS_STRING)
369 %typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) char *, char *&, char []
370 " $1 = (Z_TYPE_PP($input) == IS_STRING); "
372 %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE
375 _v = (SWIG_ConvertPtr(*$input, (void **)&tmp, $&1_descriptor, 0) >= 0);
378 %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *,
384 _v = (SWIG_ConvertPtr(*$input, (void**)&tmp, $1_descriptor, 0) >= 0);
387 %typecheck(SWIG_TYPECHECK_VOIDPTR) void *
390 _v = (SWIG_ConvertPtr(*$input, (void**)&tmp, 0, 0) >= 0);
393 /* Exception handling */
395 %typemap(throws) int,
402 sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1);
403 SWIG_PHP_Error(E_ERROR, error_msg);
406 %typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] %{
408 SWIG_PHP_Error(E_ERROR, "C++ $1_type exception thrown");
411 %typemap(throws) char * %{
412 SWIG_PHP_Error(E_ERROR, (char *)$1);