Add PHP const ref typemaps for primitive types

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11549 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2009-08-13 21:41:23 +00:00
commit 627d9faffd
4 changed files with 66 additions and 1 deletions

View file

@ -184,6 +184,21 @@
ZVAL_LONG(return_value,$1);
}
%typemap(out) const int &,
const unsigned int &,
const short &,
const unsigned short &,
const long &,
const unsigned long &,
const signed char &,
const unsigned char &,
const bool &,
const size_t &,
const enum SWIGTYPE &
{
ZVAL_LONG(return_value,*$1);
}
%typemap(directorin) int,
unsigned int,
short,
@ -203,6 +218,11 @@
ZVAL_BOOL(return_value,($1)?1:0);
}
%typemap(out) const bool &
{
ZVAL_BOOL(return_value,(*$1)?1:0);
}
%typemap(directorin) bool
{
ZVAL_BOOL($input,($1_name)?1:0);
@ -214,6 +234,12 @@
ZVAL_DOUBLE(return_value,$1);
}
%typemap(out) const float &,
const double &
{
ZVAL_DOUBLE(return_value,*$1);
}
%typemap(directorin) float,
double
{
@ -225,6 +251,11 @@
ZVAL_STRINGL(return_value,&$1, 1, 1);
}
%typemap(out) const char &
{
ZVAL_STRINGL(return_value,&*$1, 1, 1);
}
%typemap(out) char *,
char []
{

View file

@ -33,10 +33,15 @@
%enddef
%define %pass_by_val( TYPE, CONVERT_IN )
%typemap(in) TYPE, const TYPE &
%typemap(in) TYPE
%{
CONVERT_IN($1,$1_ltype,$input);
%}
%typemap(in) const TYPE &($*1_ltype temp)
%{
CONVERT_IN(temp,$*1_ltype,$input);
$1 = &temp;
%}
%typemap(directorout) TYPE, const TYPE &
%{
CONVERT_IN($result,$1_ltype,$input);