[php] Generate PHP type declarations
We now automatically generate PHP type declarations for PHP >= 8.0. The generated code still compiles with PHP 7.x but without type declarations.
This commit is contained in:
parent
76d5a9ec27
commit
1f1349741f
12 changed files with 536 additions and 196 deletions
|
|
@ -27,7 +27,7 @@ namespace std {
|
|||
$1 = (Z_TYPE($input) == IS_STRING) ? 1 : 0;
|
||||
%}
|
||||
|
||||
%typemap(in) string %{
|
||||
%typemap(in, phptype="string") string %{
|
||||
convert_to_string(&$input);
|
||||
$1.assign(Z_STRVAL($input), Z_STRLEN($input));
|
||||
%}
|
||||
|
|
@ -37,7 +37,7 @@ namespace std {
|
|||
$result.assign(Z_STRVAL_P($input), Z_STRLEN_P($input));
|
||||
%}
|
||||
|
||||
%typemap(out) string %{
|
||||
%typemap(out, phptype="string") string %{
|
||||
ZVAL_STRINGL($result, $1.data(), $1.size());
|
||||
%}
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ namespace std {
|
|||
ZVAL_STRINGL($input, $1.data(), $1.size());
|
||||
%}
|
||||
|
||||
%typemap(out) const string & %{
|
||||
%typemap(out, phptype="string") const string & %{
|
||||
ZVAL_STRINGL($result, $1->data(), $1->size());
|
||||
%}
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ namespace std {
|
|||
return;
|
||||
%}
|
||||
|
||||
%typemap(in) const string & ($*1_ltype temp) %{
|
||||
%typemap(in, phptype="string") const string & ($*1_ltype temp) %{
|
||||
convert_to_string(&$input);
|
||||
temp.assign(Z_STRVAL($input), Z_STRLEN($input));
|
||||
$1 = &temp;
|
||||
|
|
@ -62,7 +62,7 @@ namespace std {
|
|||
|
||||
/* These next two handle a function which takes a non-const reference to
|
||||
* a std::string and modifies the string. */
|
||||
%typemap(in,byref=1) string & ($*1_ltype temp) %{
|
||||
%typemap(in,byref=1, phptype="string") string & ($*1_ltype temp) %{
|
||||
{
|
||||
zval * p = Z_ISREF($input) ? Z_REFVAL($input) : &$input;
|
||||
convert_to_string(p);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue