Skip to content

Commit

Permalink
Add rvalue reference typemaps
Browse files Browse the repository at this point in the history
  • Loading branch information
wsfulton committed Jan 24, 2013
1 parent 8bdfcda commit d3769a1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
1 change: 1 addition & 0 deletions Lib/php/const.i
Expand Up @@ -31,6 +31,7 @@

%typemap(consttab) SWIGTYPE *,
SWIGTYPE &,
SWIGTYPE &&,
SWIGTYPE [] {
/* 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... */
Expand Down
6 changes: 3 additions & 3 deletions Lib/php/globalvar.i
Expand Up @@ -80,7 +80,7 @@
sizeof(zval *), NULL);
}

%typemap(varinit) SWIGTYPE, SWIGTYPE &
%typemap(varinit) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&
{
zval *z_var;

Expand Down Expand Up @@ -210,7 +210,7 @@

}

%typemap(varin) SWIGTYPE *, SWIGTYPE &
%typemap(varin) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&
{
zval **z_var;
$1_ltype _temp;
Expand Down Expand Up @@ -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;

Expand Down
25 changes: 21 additions & 4 deletions Lib/php/php.swg
Expand Up @@ -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)
{
if(SWIG_ConvertPtr(*$input, (void **) &temp, $*1_descriptor, 0) < 0) {
Expand All @@ -132,7 +139,8 @@

%typemap(argout) SWIGTYPE *,
SWIGTYPE [],
SWIGTYPE&;
SWIGTYPE &,
SWIGTYPE &&;

%typemap(in) void *
{
Expand Down Expand Up @@ -241,6 +249,11 @@
ZVAL_LONG(return_value, (long)*$1);
}

%typemap(out) const enum SWIGTYPE &&
{
ZVAL_LONG(return_value, (long)*$1);
}

%typemap(out) const long long &
%{
if ((long long)LONG_MIN <= *$1 && *$1 <= (long long)LONG_MAX) {
Expand Down Expand Up @@ -347,7 +360,8 @@

%typemap(out) SWIGTYPE *,
SWIGTYPE [],
SWIGTYPE &
SWIGTYPE &,
SWIGTYPE &&
%{
SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner);
%}
Expand All @@ -359,7 +373,8 @@

%typemap(directorin) SWIGTYPE *,
SWIGTYPE [],
SWIGTYPE &
SWIGTYPE &,
SWIGTYPE &&
%{
SWIG_SetPointerZval($input, (void *)&$1_name, $1_descriptor, $owner);
%}
Expand Down Expand Up @@ -454,6 +469,7 @@
SWIGTYPE *,
SWIGTYPE [],
SWIGTYPE &,
SWIGTYPE &&,
SWIGTYPE *const&
{
void *tmp;
Expand All @@ -478,7 +494,7 @@
return;
}

%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] %{
%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] %{
(void)$1;
zend_throw_exception(NULL, const_cast<char*>("C++ $1_type exception thrown"), 0 TSRMLS_CC);
return;
Expand All @@ -491,6 +507,7 @@

/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }

/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
Expand Down

0 comments on commit d3769a1

Please sign in to comment.