diff options
author | Remi Collet <remi@remirepo.net> | 2021-06-18 12:24:17 +0200 |
---|---|---|
committer | Remi Collet <remi@remirepo.net> | 2021-06-18 12:24:17 +0200 |
commit | 495c53de87635ba2adf5dd80fff54953ed5df556 (patch) | |
tree | 5a7eef800472b837cadc42f5fe009dcccb4549b2 | |
parent | 55668fe2653259743aef7959100b43b58165bdb5 (diff) |
generate argingo from stub
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | package.xml | 7 | ||||
-rw-r--r-- | rpminfo.c | 69 | ||||
-rw-r--r-- | rpminfo.stub.php | 15 | ||||
-rw-r--r-- | rpminfo_arginfo.h | 46 |
5 files changed, 74 insertions, 64 deletions
@@ -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 </stability> <license>PHP 3.01</license> <notes> -- +- generate arginfo from stub +- raise dependency on PHP 7.2 </notes> <contents> <dir name="/"> @@ -32,6 +33,8 @@ Documentation: https://www.php.net/rpminfo <file name="config.m4" role="src"/> <file name="php_rpminfo.h" role="src" /> <file name="rpminfo.c" role="src"/> + <file name="rpminfo.stub.php" role="src"/> + <file name="rpminfo_arginfo.h" role="src"/> <!-- documentation --> <file name="CREDITS" role="doc"/> <file name="LICENSE" role="doc"/> @@ -61,7 +64,7 @@ Documentation: https://www.php.net/rpminfo <dependencies> <required> <php> - <min>7.0.0</min> + <min>7.2.0</min> </php> <pearinstaller> <min>1.10.0</min> @@ -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 @@ +<?php + +/** @generate-function-entries */ + +function rpmaddtag(int $rpmtag): bool {} + +function rpmdbinfo(string $nevr, bool $full = false): Array|null {} + +function rpmdbsearch(string $pattern, int $rpmtag = RPMTAG_NAME, int $rpmmire = -1, bool $full = false): Array|null {} + +function rpminfo(string $path, bool $full = false, ?string &$error = null): Array|null {} + +function rpmvercmp(string $evr1, string $evr2): int {} + + diff --git a/rpminfo_arginfo.h b/rpminfo_arginfo.h new file mode 100644 index 0000000..20c501f --- /dev/null +++ b/rpminfo_arginfo.h @@ -0,0 +1,46 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: 6b4dfeada2b5de5c5453d2b38c1a861e01bf958e */ + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rpmaddtag, 0, 1, _IS_BOOL, 0) + ZEND_ARG_TYPE_INFO(0, rpmtag, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rpmdbinfo, 0, 1, IS_ARRAY, 1) + ZEND_ARG_TYPE_INFO(0, nevr, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, full, _IS_BOOL, 0, "false") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rpmdbsearch, 0, 1, IS_ARRAY, 1) + ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, rpmtag, IS_LONG, 0, "RPMTAG_NAME") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, rpmmire, IS_LONG, 0, "-1") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, full, _IS_BOOL, 0, "false") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rpminfo, 0, 1, IS_ARRAY, 1) + ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, full, _IS_BOOL, 0, "false") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(1, error, IS_STRING, 1, "null") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rpmvercmp, 0, 2, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, evr1, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, evr2, IS_STRING, 0) +ZEND_END_ARG_INFO() + + +ZEND_FUNCTION(rpmaddtag); +ZEND_FUNCTION(rpmdbinfo); +ZEND_FUNCTION(rpmdbsearch); +ZEND_FUNCTION(rpminfo); +ZEND_FUNCTION(rpmvercmp); + + +static const zend_function_entry ext_functions[] = { + ZEND_FE(rpmaddtag, arginfo_rpmaddtag) + ZEND_FE(rpmdbinfo, arginfo_rpmdbinfo) + ZEND_FE(rpmdbsearch, arginfo_rpmdbsearch) + ZEND_FE(rpminfo, arginfo_rpminfo) + ZEND_FE(rpmvercmp, arginfo_rpmvercmp) + ZEND_FE_END +}; |