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:
parent
4297c7de33
commit
627d9faffd
4 changed files with 66 additions and 1 deletions
|
|
@ -1,6 +1,10 @@
|
||||||
Version 1.3.40 (in progress)
|
Version 1.3.40 (in progress)
|
||||||
============================
|
============================
|
||||||
|
|
||||||
|
2009-08-13: wsfulton
|
||||||
|
[PHP] Add const reference typemaps. const reference primitive types are
|
||||||
|
now passed by value rather than pointer like the other target languages.
|
||||||
|
|
||||||
2009-08-08: wsfulton
|
2009-08-08: wsfulton
|
||||||
[Python] More user friendly AttributeError is raised when there are
|
[Python] More user friendly AttributeError is raised when there are
|
||||||
no constructors generated for the proxy class in the event that the
|
no constructors generated for the proxy class in the event that the
|
||||||
|
|
|
||||||
25
Examples/test-suite/php/primitive_ref_runme.php
Normal file
25
Examples/test-suite/php/primitive_ref_runme.php
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require "tests.php";
|
||||||
|
require "primitive_ref.php";
|
||||||
|
|
||||||
|
check::equal(ref_over(3), 3, "ref_over failed");
|
||||||
|
|
||||||
|
check::equal(ref_int(3), 3, "ref_int failed");
|
||||||
|
check::equal(ref_uint(3), 3, "ref_uint failed");
|
||||||
|
check::equal(ref_short(3), 3, "ref_short failed");
|
||||||
|
check::equal(ref_ushort(3), 3, "ref_ushort failed");
|
||||||
|
check::equal(ref_long(3), 3, "ref_long failed");
|
||||||
|
check::equal(ref_ulong(3), 3, "ref_ulong failed");
|
||||||
|
check::equal(ref_schar(3), 3, "ref_schar failed");
|
||||||
|
check::equal(ref_uchar(3), 3, "ref_uchar failed");
|
||||||
|
check::equal(ref_bool(true), true, "ref_bool failed");
|
||||||
|
check::equal(ref_float(3.5), 3.5, "ref_float failed");
|
||||||
|
check::equal(ref_double(3.5), 3.5, "ref_double failed");
|
||||||
|
check::equal(ref_char('x'), 'x', "ref_char failed");
|
||||||
|
//check::equal(ref_longlong(0x123456789ABCDEF0), 0x123456789ABCDEF0, "ref_longlong failed");
|
||||||
|
//check::equal(ref_ulonglong(0xF23456789ABCDEF0), 0xF23456789ABCDEF0, "ref_ulonglong failed");
|
||||||
|
printf("TODO: long long and unsigned long long const reference typemaps\n");
|
||||||
|
|
||||||
|
check::done();
|
||||||
|
?>
|
||||||
|
|
@ -184,6 +184,21 @@
|
||||||
ZVAL_LONG(return_value,$1);
|
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,
|
%typemap(directorin) int,
|
||||||
unsigned int,
|
unsigned int,
|
||||||
short,
|
short,
|
||||||
|
|
@ -203,6 +218,11 @@
|
||||||
ZVAL_BOOL(return_value,($1)?1:0);
|
ZVAL_BOOL(return_value,($1)?1:0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%typemap(out) const bool &
|
||||||
|
{
|
||||||
|
ZVAL_BOOL(return_value,(*$1)?1:0);
|
||||||
|
}
|
||||||
|
|
||||||
%typemap(directorin) bool
|
%typemap(directorin) bool
|
||||||
{
|
{
|
||||||
ZVAL_BOOL($input,($1_name)?1:0);
|
ZVAL_BOOL($input,($1_name)?1:0);
|
||||||
|
|
@ -214,6 +234,12 @@
|
||||||
ZVAL_DOUBLE(return_value,$1);
|
ZVAL_DOUBLE(return_value,$1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%typemap(out) const float &,
|
||||||
|
const double &
|
||||||
|
{
|
||||||
|
ZVAL_DOUBLE(return_value,*$1);
|
||||||
|
}
|
||||||
|
|
||||||
%typemap(directorin) float,
|
%typemap(directorin) float,
|
||||||
double
|
double
|
||||||
{
|
{
|
||||||
|
|
@ -225,6 +251,11 @@
|
||||||
ZVAL_STRINGL(return_value,&$1, 1, 1);
|
ZVAL_STRINGL(return_value,&$1, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%typemap(out) const char &
|
||||||
|
{
|
||||||
|
ZVAL_STRINGL(return_value,&*$1, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
%typemap(out) char *,
|
%typemap(out) char *,
|
||||||
char []
|
char []
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -33,10 +33,15 @@
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
%define %pass_by_val( TYPE, CONVERT_IN )
|
%define %pass_by_val( TYPE, CONVERT_IN )
|
||||||
%typemap(in) TYPE, const TYPE &
|
%typemap(in) TYPE
|
||||||
%{
|
%{
|
||||||
CONVERT_IN($1,$1_ltype,$input);
|
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 &
|
%typemap(directorout) TYPE, const TYPE &
|
||||||
%{
|
%{
|
||||||
CONVERT_IN($result,$1_ltype,$input);
|
CONVERT_IN($result,$1_ltype,$input);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue