You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
2.8 KiB
91 lines
2.8 KiB
From d451e0e42c75429279426e9eb5a7701cd4681d07 Mon Sep 17 00:00:00 2001
|
|
From: Geoff Amey <gamey@datto.com>
|
|
Date: Wed, 15 Jun 2022 17:06:56 -0400
|
|
Subject: [PATCH] php: add arginfo to php bindings
|
|
|
|
Starting with PHP8, arginfo is mandatory for PHP extensions. This patch
|
|
updates the generator for the PHP bindings to generate the arginfo
|
|
structures, using the Zend API macros. Only basic arginfo is added,
|
|
without full documentation of argument and return types, in order to
|
|
ensure compatibility with as many versions of PHP as possible.
|
|
|
|
(cherry picked from commit ec27979398b0871c1a3e0e244849f8435c9c9a8d)
|
|
---
|
|
.gitignore | 1 +
|
|
generator/php.ml | 37 ++++++++++++++++++++++++++++++++++---
|
|
2 files changed, 35 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/.gitignore b/.gitignore
|
|
index a36ccc86a..356c01fbd 100644
|
|
--- a/.gitignore
|
|
+++ b/.gitignore
|
|
@@ -325,6 +325,7 @@ Makefile.in
|
|
/php/extension/configure.in
|
|
/php/extension/env
|
|
/php/extension/guestfs_php.c
|
|
+/php/extension/guestfs_php.dep
|
|
/php/extension/install-sh
|
|
/php/extension/libtool
|
|
/php/extension/ltmain.sh
|
|
diff --git a/generator/php.ml b/generator/php.ml
|
|
index 5c7ef48e8..acdc7b877 100644
|
|
--- a/generator/php.ml
|
|
+++ b/generator/php.ml
|
|
@@ -130,6 +130,37 @@ typedef size_t guestfs_string_length;
|
|
typedef int guestfs_string_length;
|
|
#endif
|
|
|
|
+/* Declare argument info structures */
|
|
+ZEND_BEGIN_ARG_INFO_EX(arginfo_create, 0, 0, 0)
|
|
+ZEND_END_ARG_INFO()
|
|
+
|
|
+ZEND_BEGIN_ARG_INFO_EX(arginfo_last_error, 0, 0, 1)
|
|
+ ZEND_ARG_INFO(0, g)
|
|
+ZEND_END_ARG_INFO()
|
|
+
|
|
+";
|
|
+ List.iter (
|
|
+ fun { name = shortname; style = ret, args, optargs; } ->
|
|
+ let len = List.length args in
|
|
+ pr "ZEND_BEGIN_ARG_INFO_EX(arginfo_%s, 0, 0, %d)\n" shortname (len + 1);
|
|
+ pr " ZEND_ARG_INFO(0, g)\n";
|
|
+ List.iter (
|
|
+ function
|
|
+ | BufferIn n | Bool n | Int n | Int64 n | OptString n
|
|
+ | Pointer(_, n) | String (_, n) | StringList (_, n) ->
|
|
+ pr " ZEND_ARG_INFO(0, %s)\n" n
|
|
+ ) args;
|
|
+
|
|
+ List.iter (
|
|
+ function
|
|
+ | OBool n | OInt n | OInt64 n | OString n | OStringList n ->
|
|
+ pr " ZEND_ARG_INFO(0, %s)\n" n
|
|
+ ) optargs;
|
|
+ pr "ZEND_END_ARG_INFO()\n\n";
|
|
+ ) (actions |> external_functions |> sort);
|
|
+
|
|
+ pr "
|
|
+
|
|
/* Convert array to list of strings.
|
|
* http://marc.info/?l=pecl-dev&m=112205192100631&w=2
|
|
*/
|
|
@@ -204,12 +235,12 @@ PHP_MINIT_FUNCTION (guestfs_php)
|
|
}
|
|
|
|
static zend_function_entry guestfs_php_functions[] = {
|
|
- PHP_FE (guestfs_create, NULL)
|
|
- PHP_FE (guestfs_last_error, NULL)
|
|
+ PHP_FE (guestfs_create, arginfo_create)
|
|
+ PHP_FE (guestfs_last_error, arginfo_last_error)
|
|
";
|
|
|
|
List.iter (
|
|
- fun { name } -> pr " PHP_FE (guestfs_%s, NULL)\n" name
|
|
+ fun { name } -> pr " PHP_FE (guestfs_%s, arginfo_%s)\n" name name
|
|
) (actions |> external_functions |> sort);
|
|
|
|
pr " { NULL, NULL, NULL }
|
|
--
|
|
2.31.1
|
|
|