Add rvalue reference typemaps

This commit is contained in:
William S Fulton 2013-01-24 20:18:18 +00:00
commit d3769a1fd4
3 changed files with 25 additions and 7 deletions

View file

@ -31,6 +31,7 @@
%typemap(consttab) SWIGTYPE *, %typemap(consttab) SWIGTYPE *,
SWIGTYPE &, SWIGTYPE &,
SWIGTYPE &&,
SWIGTYPE [] { SWIGTYPE [] {
/* This actually registers it as a global variable and constant. I don't /* This actually registers it as a global variable and constant. I don't
* like it, but I can't figure out the zend_constant code... */ * like it, but I can't figure out the zend_constant code... */

View file

@ -80,7 +80,7 @@
sizeof(zval *), NULL); sizeof(zval *), NULL);
} }
%typemap(varinit) SWIGTYPE, SWIGTYPE & %typemap(varinit) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&
{ {
zval *z_var; zval *z_var;
@ -210,7 +210,7 @@
} }
%typemap(varin) SWIGTYPE *, SWIGTYPE & %typemap(varin) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&
{ {
zval **z_var; zval **z_var;
$1_ltype _temp; $1_ltype _temp;
@ -336,7 +336,7 @@ deliberate error cos this code looks bogus to me
} }
} }
%typemap(varout) SWIGTYPE *, SWIGTYPE & %typemap(varout) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&
{ {
zval **z_var; zval **z_var;

View file

@ -115,6 +115,13 @@
} }
} }
%typemap(in) SWIGTYPE &&
{
if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0 || $1 == NULL) {
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor");
}
}
%typemap(in) SWIGTYPE *const& ($*ltype temp) %typemap(in) SWIGTYPE *const& ($*ltype temp)
{ {
if(SWIG_ConvertPtr(*$input, (void **) &temp, $*1_descriptor, 0) < 0) { if(SWIG_ConvertPtr(*$input, (void **) &temp, $*1_descriptor, 0) < 0) {
@ -132,7 +139,8 @@
%typemap(argout) SWIGTYPE *, %typemap(argout) SWIGTYPE *,
SWIGTYPE [], SWIGTYPE [],
SWIGTYPE&; SWIGTYPE &,
SWIGTYPE &&;
%typemap(in) void * %typemap(in) void *
{ {
@ -241,6 +249,11 @@
ZVAL_LONG(return_value, (long)*$1); ZVAL_LONG(return_value, (long)*$1);
} }
%typemap(out) const enum SWIGTYPE &&
{
ZVAL_LONG(return_value, (long)*$1);
}
%typemap(out) const long long & %typemap(out) const long long &
%{ %{
if ((long long)LONG_MIN <= *$1 && *$1 <= (long long)LONG_MAX) { if ((long long)LONG_MIN <= *$1 && *$1 <= (long long)LONG_MAX) {
@ -347,7 +360,8 @@
%typemap(out) SWIGTYPE *, %typemap(out) SWIGTYPE *,
SWIGTYPE [], SWIGTYPE [],
SWIGTYPE & SWIGTYPE &,
SWIGTYPE &&
%{ %{
SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner); SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner);
%} %}
@ -359,7 +373,8 @@
%typemap(directorin) SWIGTYPE *, %typemap(directorin) SWIGTYPE *,
SWIGTYPE [], SWIGTYPE [],
SWIGTYPE & SWIGTYPE &,
SWIGTYPE &&
%{ %{
SWIG_SetPointerZval($input, (void *)&$1_name, $1_descriptor, $owner); SWIG_SetPointerZval($input, (void *)&$1_name, $1_descriptor, $owner);
%} %}
@ -454,6 +469,7 @@
SWIGTYPE *, SWIGTYPE *,
SWIGTYPE [], SWIGTYPE [],
SWIGTYPE &, SWIGTYPE &,
SWIGTYPE &&,
SWIGTYPE *const& SWIGTYPE *const&
{ {
void *tmp; void *tmp;
@ -478,7 +494,7 @@
return; return;
} }
%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] %{ %typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] %{
(void)$1; (void)$1;
zend_throw_exception(NULL, const_cast<char*>("C++ $1_type exception thrown"), 0 TSRMLS_CC); zend_throw_exception(NULL, const_cast<char*>("C++ $1_type exception thrown"), 0 TSRMLS_CC);
return; return;
@ -491,6 +507,7 @@
/* Array reference typemaps */ /* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
/* const pointers */ /* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const } %apply SWIGTYPE * { SWIGTYPE *const }