* PHP 4 configuration file
%runtime "swigrun.swg" // Common C API type-checking code
%runtime "php4run.swg" // Php4 runtime functions
%include "php4init.swg" // Php4 initialization routine.
%include "globalvar.i" // Global variables.
// use %init %{ "/*code goes here*/ " %}
// or %minit %{ "/* code goes here*/ " %} to
// insert code in the PHP_MINIT_FUNCTION
#define %minit %insert("init")
// use %rinit %{ "/* code goes here*/ " %} to
// insert code in the PHP_RINIT_FUNCTION
#define %rinit %insert("rinit")
// use %shutdown %{ " /*code goes here*/ " %} to
// insert code in the PHP_MSHUTDOWN_FUNCTION
#define %shutdown %insert("shutdown")
#define %mshutdown %insert("shutdown")
// use %rshutdown %{ " /*code goes here*/" %} to
// insert code in the PHP_RSHUTDOWN_FUNCTION
#define %rshutdown %insert("rshutdown")
/* Typemaps for input parameters by value */
%pass_by_val(bool,CONVERT_BOOL_IN);
%pass_by_val(size_t, CONVERT_INT_IN);
%pass_by_val(enum SWIGTYPE, CONVERT_INT_IN);
%pass_by_val(signed int, CONVERT_INT_IN);
%pass_by_val(int,CONVERT_INT_IN);
%pass_by_val(unsigned int,CONVERT_INT_IN);
%pass_by_val(signed short, CONVERT_INT_IN);
%pass_by_val(short,CONVERT_INT_IN);
%pass_by_val(unsigned short, CONVERT_INT_IN);
%pass_by_val(signed long, CONVERT_INT_IN);
%pass_by_val(long, CONVERT_INT_IN);
%pass_by_val(unsigned long, CONVERT_INT_IN);
%pass_by_val(signed char, CONVERT_INT_IN);
%pass_by_val(char, CONVERT_CHAR_IN);
%pass_by_val(unsigned char, CONVERT_INT_IN);
%pass_by_val(float, CONVERT_FLOAT_IN);
%pass_by_val(double, CONVERT_FLOAT_IN);
%pass_by_val(char *, CONVERT_STRING_IN);
// char array can be in/out, though the passed string may not be big enough...
convert_to_string_ex($input);
$1 = ($1_ltype) Z_STRVAL_PP($input);
/* Object passed by value. Convert to a pointer */
%typemap(in) SWIGTYPE ($&1_ltype tmp)
if(SWIG_ConvertPtr(*$input, (void **) &tmp, $&1_descriptor, 0) < 0) {
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor");
/* typemap(in) SWIGTYPE * */
if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0) {
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor");
%typemap(in) SWIGTYPE *DISOWN
/* typemap(in) SWIGTYPE *DISOWN */
if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, SWIG_POINTER_DISOWN ) < 0) {
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor");
%typemap(argout) SWIGTYPE *,
if(SWIG_ConvertPtr(*$input, (void **) &$1, 0, 0) < 0) {
/* Allow NULL from php for void* */
if ((*$input)->type==IS_NULL) $1=0;
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor");
/* Special case when void* is passed by reference so it can be made to point
%typemap(in) void ** ($*1_ltype ptr, int force),
void *& ($*1_ltype ptr, int force)
/* If they pass NULL by reference, make it into a void*
This bit should go in arginit if arginit support init-ing scripting args */
if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0) {
/* So... we didn't get a ref or ptr, but we'll accept NULL by reference */
if ((*$input)->type==IS_NULL && PZVAL_IS_REF(*$input)) {
ptr=($*1_ltype) calloc(1,sizeof($*1_ltype));
/* have to passback arg$arg too */
} else { /* wasn't a pre/ref/thing, OR anything like an int thing */
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor");
%typemap(argout) void **,
SWIG_SetPointerZval( *$input, (void*) ptr$argnum, $*1_descriptor, 1);
/* Typemap for output values */
ZVAL_LONG(return_value,$1);
ZVAL_BOOL(return_value,($1)?1:0);
ZVAL_DOUBLE(return_value,$1);
ZVAL_STRINGL(return_value,&$1, 1, 1);
ZVAL_STRING(return_value,$1, 1);
%typemap(out) SWIGTYPE *,
SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner);
%typemap(out) SWIGTYPE *DYNAMIC,
swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1);
SWIG_SetPointerZval(return_value, (void *)$1, ty, $owner);
$&1_ltype resultobj = new $1_ltype(($1_ltype &) $1);
SWIG_SetPointerZval(return_value, (void *)resultobj, $&1_descriptor, 1);
$&1_ltype resultobj = ($&1_ltype) emalloc(sizeof($1_type));
memmove(resultobj, &$1, sizeof($1_type));
SWIG_SetPointerZval(return_value, (void *)resultobj, $&1_descriptor, 1);
RETVAL_STRINGL($1,$1_dim0,1);
// This typecheck would do hard checking for proper argument type.
//%define %php_typecheck(_type,_prec,is)
//%typemap(typecheck,precedence=_prec) _type
// " $1 = Z_TYPE_PP($input) == is ? 1 : 0; "
%define %php_typecheck(_type,_prec,is)
%typemap(typecheck,precedence=_prec) _type
" $1 = (Z_TYPE_PP($input) == IS_LONG ||
Z_TYPE_PP($input) == IS_DOUBLE ||
Z_TYPE_PP($input) == IS_STRING) ? 1 : 0; "
%php_typecheck(int,SWIG_TYPECHECK_INTEGER,IS_LONG)
%php_typecheck(unsigned int,SWIG_TYPECHECK_UINT32,IS_LONG)
%php_typecheck(short,SWIG_TYPECHECK_INT16,IS_LONG)
%php_typecheck(unsigned short,SWIG_TYPECHECK_UINT16,IS_LONG)
%php_typecheck(long,SWIG_TYPECHECK_INT64,IS_LONG)
%php_typecheck(unsigned long,SWIG_TYPECHECK_UINT64,IS_LONG)
%php_typecheck(signed char,SWIG_TYPECHECK_INT8,IS_LONG)
%php_typecheck(unsigned char,SWIG_TYPECHECK_UINT8,IS_LONG)
%php_typecheck(size_t,SWIG_TYPECHECK_INT16,IS_LONG)
%php_typecheck(enum SWIGTYPE,SWIG_TYPECHECK_INT8,IS_LONG)
%php_typecheck(bool,SWIG_TYPECHECK_BOOL,IS_BOOL)
%php_typecheck(char,SWIG_TYPECHECK_CHAR,IS_STRING)
%php_typecheck(char *,SWIG_TYPECHECK_STRING,IS_STRING)
%php_typecheck(char [],SWIG_TYPECHECK_STRING,IS_STRING)
%php_typecheck(float,SWIG_TYPECHECK_FLOAT,IS_DOUBLE)
%php_typecheck(double,SWIG_TYPECHECK_BOOL,IS_DOUBLE)
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE
" /* typecheck SWIGTYPE */ "
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *,
/* typecheck SWIGTYPE * */
_v = (SWIG_ConvertPtr( *$input, (void**)&tmp, $1_descriptor, 0) < 0)? 0:1;
%typecheck(SWIG_TYPECHECK_VOIDPTR) void *
" /* tyepcheck void * */ "
sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1);
SWIG_PHP_Error(E_ERROR, error_msg);
%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] %{
SWIG_PHP_Error(E_ERROR, "C++ $1_type exception thrown");
%typemap(throws) char * %{
SWIG_PHP_Error(E_ERROR, (char *)$1);
/* please test and activate */