From 495c53de87635ba2adf5dd80fff54953ed5df556 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Fri, 18 Jun 2021 12:24:17 +0200 Subject: generate argingo from stub --- .gitignore | 1 + package.xml | 7 ++++-- rpminfo.c | 69 ++++++------------------------------------------------- rpminfo.stub.php | 15 ++++++++++++ rpminfo_arginfo.h | 46 +++++++++++++++++++++++++++++++++++++ 5 files changed, 74 insertions(+), 64 deletions(-) create mode 100644 rpminfo.stub.php create mode 100644 rpminfo_arginfo.h diff --git a/.gitignore b/.gitignore index a934b10..54b9e13 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Object files *.o *.lo +*.dep # Libraries *.lib diff --git a/package.xml b/package.xml index ea80fd5..59c2bb5 100644 --- a/package.xml +++ b/package.xml @@ -24,7 +24,8 @@ Documentation: https://www.php.net/rpminfo PHP 3.01 -- +- generate arginfo from stub +- raise dependency on PHP 7.2 @@ -32,6 +33,8 @@ Documentation: https://www.php.net/rpminfo + + @@ -61,7 +64,7 @@ Documentation: https://www.php.net/rpminfo - 7.0.0 + 7.2.0 1.10.0 diff --git a/rpminfo.c b/rpminfo.c index 2e5cb0e..fa5a8de 100644 --- a/rpminfo.c +++ b/rpminfo.c @@ -32,6 +32,12 @@ #include "php_rpminfo.h" +#ifndef ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE +#define ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(pass_by_ref, name, type_hint, allow_null, default_value) \ + ZEND_ARG_TYPE_INFO(pass_by_ref, name, type_hint, allow_null) +#endif +#include "rpminfo_arginfo.h" + ZEND_DECLARE_MODULE_GLOBALS(rpminfo) static rpmts rpminfo_getts(void) { @@ -199,16 +205,6 @@ static void rpm_header_to_zval(zval *return_value, Header h, zend_bool full) } } -#if PHP_VERSION_ID < 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rpminfo, 0, 1, IS_ARRAY, NULL, 1) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rpminfo, 0, 1, IS_ARRAY, 1) -#endif - ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, full, _IS_BOOL, 0) - ZEND_ARG_TYPE_INFO(1, error, IS_STRING, 1) -ZEND_END_ARG_INFO() - /* {{{ proto array rpminfo(string path [, bool full [, string &$error]) Retrieve information from a RPM file */ PHP_FUNCTION(rpminfo) @@ -267,15 +263,6 @@ PHP_FUNCTION(rpminfo) } /* }}} */ -#if PHP_VERSION_ID < 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rpmdbinfo, 0, 1, IS_ARRAY, NULL, 1) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rpmdbinfo, 0, 1, IS_ARRAY, 1) -#endif - ZEND_ARG_TYPE_INFO(0, nevr, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, full, _IS_BOOL, 0) -ZEND_END_ARG_INFO() - /* {{{ proto array rpmdbinfo(string nevr [, bool full]) Retrieve information from an installed RPM */ PHP_FUNCTION(rpmdbinfo) @@ -363,17 +350,6 @@ static int haveIndex(zend_long tag) { return 0; } -#if PHP_VERSION_ID < 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rpmdbsearch, 0, 1, IS_ARRAY, NULL, 1) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rpmdbsearch, 0, 1, IS_ARRAY, 1) -#endif - ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, rpmtag, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, rpmmire, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, full, _IS_BOOL, 0) -ZEND_END_ARG_INFO() - /* {{{ proto array rpmdbsearch(string pattern [, integer tag_name = RPMTAG_NAME [, integer mode = -1 [, bool full = 0]]]) Search information from installed RPMs */ PHP_FUNCTION(rpmdbsearch) @@ -448,15 +424,6 @@ PHP_FUNCTION(rpmdbsearch) } /* }}} */ -#if PHP_VERSION_ID < 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rpmvercmp, 0, 2, IS_LONG, NULL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rpmvercmp, 0, 2, IS_LONG, 0) -#endif - ZEND_ARG_TYPE_INFO(0, evr1, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, evr2, IS_STRING, 0) -ZEND_END_ARG_INFO() - /* {{{ proto int rpmcmpver(string evr1, string evr2) Compare 2 RPM EVRs (epoch:version-release) strings */ PHP_FUNCTION(rpmvercmp) @@ -526,14 +493,6 @@ PHP_FUNCTION(rpmvercmp) } /* }}} */ -#if PHP_VERSION_ID < 70200 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rpmaddtag, 0, 1, _IS_BOOL, NULL, 0) -#else -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rpmaddtag, 0, 1, _IS_BOOL, 0) -#endif - ZEND_ARG_TYPE_INFO(0, rpmtag, IS_LONG, 0) -ZEND_END_ARG_INFO() - /* {{{ proto int rpmaddtag(int tag) add a tag in the default set */ PHP_FUNCTION(rpmaddtag) @@ -680,20 +639,6 @@ static PHP_GINIT_FUNCTION(rpminfo) /* {{{ */ } /* }}} */ -/* {{{ rpminfo_functions[] - * - * Every user visible function must have an entry in rpminfo_functions[]. - */ -const zend_function_entry rpminfo_functions[] = { - PHP_FE(rpmaddtag, arginfo_rpmaddtag) - PHP_FE(rpmdbinfo, arginfo_rpmdbinfo) - PHP_FE(rpmdbsearch, arginfo_rpmdbsearch) - PHP_FE(rpminfo, arginfo_rpminfo) - PHP_FE(rpmvercmp, arginfo_rpmvercmp) - PHP_FE_END -}; -/* }}} */ - /* {{{ rpminfo_module_entry */ zend_module_entry rpminfo_module_entry = { @@ -701,7 +646,7 @@ zend_module_entry rpminfo_module_entry = { NULL, NULL, "rpminfo", - rpminfo_functions, + ext_functions, PHP_MINIT(rpminfo), NULL, PHP_RINIT(rpminfo), diff --git a/rpminfo.stub.php b/rpminfo.stub.php new file mode 100644 index 0000000..543cc5f --- /dev/null +++ b/rpminfo.stub.php @@ -0,0 +1,15 @@ +