Overload resolution now works in PHP out of the box.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9305 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Olly Betts 2006-09-20 06:59:07 +00:00
commit 5baafd12c0
6 changed files with 28 additions and 20 deletions

View file

@ -229,17 +229,12 @@
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; "
//%enddef
// This typecheck does hard checking for proper argument type. If you want
// an argument to be converted from a different PHP type, you must convert
// it yourself before passing it (e.g. (string)4.7 or (int)"6").
%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; "
" $1 = (Z_TYPE_PP($input) == is); "
%enddef
%php_typecheck(int,SWIG_TYPECHECK_INTEGER,IS_LONG)
@ -269,11 +264,11 @@
SWIGTYPE &
{
void *tmp;
_v = (SWIG_ConvertPtr( *$input, (void**)&tmp, $1_descriptor, 0) < 0)? 0:1;
_v = (SWIG_ConvertPtr( *$input, (void**)&tmp, $1_descriptor, 0) >= 0);
}
%typecheck(SWIG_TYPECHECK_VOIDPTR) void *
" /* tyepcheck void * */ "
" /* typecheck void * */ "
/* Exception handling */

View file

@ -159,14 +159,14 @@ SWIG_ZTS_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags TSRMLS_DC
if (zend_hash_find(HASH_OF(z),"_cPtr",sizeof("_cPtr"),(void**)&_cPtr)==SUCCESS) {
if ((*_cPtr)->type==IS_RESOURCE) {
*ptr = SWIG_ZTS_ConvertResourcePtr(*_cPtr, ty, flags TSRMLS_CC);
return (ptr == NULL ? -1 : 0);
return (*ptr == NULL ? -1 : 0);
}
}
break;
}
case IS_RESOURCE:
*ptr = SWIG_ZTS_ConvertResourcePtr(z, ty, flags TSRMLS_CC);
return (ptr == NULL ? -1 : 0);
return (*ptr == NULL ? -1 : 0);
case IS_NULL:
*ptr = 0;
return 0;