Skip to content

Commit ffc316f

Browse files
committed
Generate arginfo from PHP stub file
1 parent 0c11dae commit ffc316f

File tree

5 files changed

+333
-188
lines changed

5 files changed

+333
-188
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ missing
3030
mkinstalldirs
3131
modules
3232
run-tests.php
33+
gen_stub.php
3334
tests/*/*.diff
3435
tests/*/*.out
3536
tests/*/*.php
3637
tests/*/*.exp
3738
tests/*/*.log
3839
tests/*/*.sh
40+
41+
# Used by gen_stub.php
42+
PHP-Parser-*

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,15 @@ $ make install
143143
Add `extension=vips.so` to `php.ini`, perhaps in `~/vips/lib/php.ini`,
144144
if you configured php as above.
145145

146+
### Development: regenerate `vips_arginfo.h`
147+
148+
Run:
149+
150+
```
151+
$ curl -LO https://github.com/php/php-src/raw/ffacda14b88be797a466f472359f306d626e698f/build/gen_stub.php
152+
$ php gen_stub.php
153+
```
154+
146155
### Links
147156

148157
http://php.net/manual/en/internals2.php

vips.c

+14-188
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
ZEND_DECLARE_MODULE_GLOBALS(vips)
2525
*/
2626

27+
#include "vips_arginfo.h"
28+
2729
/* True global resources - no need for thread safety here */
2830
static int le_gobject;
2931

@@ -1047,7 +1049,7 @@ vips_php_call_array(const char *operation_name, zval *instance,
10471049

10481050
/* }}} */
10491051

1050-
/* {{{ proto mixed vips_php_call(string operation_name, resource instance [, more])
1052+
/* {{{ proto array|long vips_call(string operation_name, resource instance [, mixed args])
10511053
Call any vips operation */
10521054

10531055
PHP_FUNCTION(vips_call)
@@ -1094,7 +1096,7 @@ PHP_FUNCTION(vips_call)
10941096
}
10951097
/* }}} */
10961098

1097-
/* {{{ proto resource vips_image_new_from_file(string filename [, array options])
1099+
/* {{{ proto array|long vips_image_new_from_file(string filename [, array options])
10981100
Open an image from a filename */
10991101
PHP_FUNCTION(vips_image_new_from_file)
11001102
{
@@ -1138,7 +1140,7 @@ PHP_FUNCTION(vips_image_new_from_file)
11381140
}
11391141
/* }}} */
11401142

1141-
/* {{{ proto resource vips_image_new_from_buffer(string buffer [, string option_string, array options])
1143+
/* {{{ proto array|long vips_image_new_from_buffer(string buffer [, string option_string, array options])
11421144
Open an image from a string */
11431145
PHP_FUNCTION(vips_image_new_from_buffer)
11441146
{
@@ -1237,7 +1239,7 @@ PHP_FUNCTION(vips_image_new_from_array)
12371239
}
12381240
/* }}} */
12391241

1240-
/* {{{ proto resource vips_interpolate_new(string name])
1242+
/* {{{ proto resource vips_interpolate_new(string name)
12411243
make a new interpolator */
12421244
PHP_FUNCTION(vips_interpolate_new)
12431245
{
@@ -1260,7 +1262,7 @@ PHP_FUNCTION(vips_interpolate_new)
12601262
}
12611263
/* }}} */
12621264

1263-
/* {{{ proto long vips_image_write_to_file(resource image, string filename [, array options])
1265+
/* {{{ proto array|long vips_image_write_to_file(resource image, string filename [, array options])
12641266
Write an image to a filename */
12651267
PHP_FUNCTION(vips_image_write_to_file)
12661268
{
@@ -1311,7 +1313,7 @@ PHP_FUNCTION(vips_image_write_to_file)
13111313
}
13121314
/* }}} */
13131315

1314-
/* {{{ proto string|long vips_image_write_to_buffer(resource image, string suffix [, array options])
1316+
/* {{{ proto array|long vips_image_write_to_buffer(resource image, string suffix [, array options])
13151317
Write an image to a string */
13161318
PHP_FUNCTION(vips_image_write_to_buffer)
13171319
{
@@ -1354,7 +1356,7 @@ PHP_FUNCTION(vips_image_write_to_buffer)
13541356
}
13551357
/* }}} */
13561358

1357-
/* {{{ proto resource vips_image_copy_memory(resource image)
1359+
/* {{{ proto array|long vips_image_copy_memory(resource image)
13581360
Copy an image to a memory image */
13591361
PHP_FUNCTION(vips_image_copy_memory)
13601362
{
@@ -1388,7 +1390,7 @@ PHP_FUNCTION(vips_image_copy_memory)
13881390
}
13891391
/* }}} */
13901392

1391-
/* {{{ proto resource vips_image_new_from_memory(string data, integer width, integer height, integer bands, string format)
1393+
/* {{{ proto array|long vips_image_new_from_memory(string memory, integer width, integer height, integer bands, string format)
13921394
Wrap an image around a memory array. */
13931395
PHP_FUNCTION(vips_image_new_from_memory)
13941396
{
@@ -1431,7 +1433,7 @@ PHP_FUNCTION(vips_image_new_from_memory)
14311433
}
14321434
/* }}} */
14331435

1434-
/* {{{ proto string vips_image_write_to_memory(resource image)
1436+
/* {{{ proto string|long vips_image_write_to_memory(resource image)
14351437
Write an image to a memory array. */
14361438
PHP_FUNCTION(vips_image_write_to_memory)
14371439
{
@@ -1469,7 +1471,7 @@ PHP_FUNCTION(vips_image_write_to_memory)
14691471
APPEND(return_value, p[i]); \
14701472
}
14711473

1472-
/* {{{ proto array vips_image_write_to_array(resource image)
1474+
/* {{{ proto array|long vips_image_write_to_array(resource image)
14731475
Write an image to a PHP array. */
14741476
PHP_FUNCTION(vips_image_write_to_array)
14751477
{
@@ -1588,7 +1590,7 @@ PHP_FUNCTION(vips_foreign_find_load_buffer)
15881590
}
15891591
/* }}} */
15901592

1591-
/* {{{ proto array vips_image_get(resource image, string field)
1593+
/* {{{ proto array|long vips_image_get(resource image, string field)
15921594
Fetch field from image */
15931595
PHP_FUNCTION(vips_image_get)
15941596
{
@@ -2195,188 +2197,12 @@ PHP_MINFO_FUNCTION(vips)
21952197
}
21962198
/* }}} */
21972199

2198-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_image_new_from_file, 0, 0, 1)
2199-
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
2200-
ZEND_ARG_ARRAY_INFO(0, options, 0)
2201-
ZEND_END_ARG_INFO()
2202-
2203-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_image_new_from_buffer, 0, 0, 1)
2204-
ZEND_ARG_TYPE_INFO(0, buffer, IS_STRING, 0)
2205-
ZEND_ARG_TYPE_INFO(0, option_string, IS_STRING, 0)
2206-
ZEND_ARG_ARRAY_INFO(0, options, 0)
2207-
ZEND_END_ARG_INFO()
2208-
2209-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_image_new_from_array, 0, 0, 1)
2210-
ZEND_ARG_ARRAY_INFO(0, array, 0)
2211-
ZEND_ARG_TYPE_INFO(0, scale, IS_DOUBLE, 0)
2212-
ZEND_ARG_TYPE_INFO(0, offset, IS_DOUBLE, 0)
2213-
ZEND_END_ARG_INFO()
2214-
2215-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_image_write_to_file, 0, 0, 1)
2216-
ZEND_ARG_TYPE_INFO(0, image, IS_RESOURCE, 0)
2217-
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
2218-
ZEND_ARG_ARRAY_INFO(0, options, 0)
2219-
ZEND_END_ARG_INFO()
2220-
2221-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_image_write_to_buffer, 0, 0, 2)
2222-
ZEND_ARG_TYPE_INFO(0, image, IS_RESOURCE, 0)
2223-
ZEND_ARG_TYPE_INFO(0, suffix, IS_STRING, 0)
2224-
ZEND_ARG_ARRAY_INFO(0, options, 0)
2225-
ZEND_END_ARG_INFO()
2226-
2227-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_image_copy_memory, 0, 0, 1)
2228-
ZEND_ARG_TYPE_INFO(0, image, IS_RESOURCE, 0)
2229-
ZEND_END_ARG_INFO()
2230-
2231-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_image_new_from_memory, 0, 0, 5)
2232-
ZEND_ARG_TYPE_INFO(0, memory, IS_STRING, 0)
2233-
ZEND_ARG_TYPE_INFO(0, width, IS_LONG, 0)
2234-
ZEND_ARG_TYPE_INFO(0, height, IS_LONG, 0)
2235-
ZEND_ARG_TYPE_INFO(0, bands, IS_LONG, 0)
2236-
ZEND_ARG_TYPE_INFO(0, format, IS_STRING, 0)
2237-
ZEND_END_ARG_INFO()
2238-
2239-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_image_write_to_memory, 0, 0, 1)
2240-
ZEND_ARG_TYPE_INFO(0, image, IS_RESOURCE, 0)
2241-
ZEND_END_ARG_INFO()
2242-
2243-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_image_write_to_array, 0, 0, 1)
2244-
ZEND_ARG_TYPE_INFO(0, image, IS_RESOURCE, 0)
2245-
ZEND_END_ARG_INFO()
2246-
2247-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_foreign_find_load, 0, 0, 1)
2248-
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
2249-
ZEND_END_ARG_INFO()
2250-
2251-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_interpolate_new, 0, 0, 1)
2252-
ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
2253-
ZEND_END_ARG_INFO()
2254-
2255-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_foreign_find_load_buffer, 0, 0, 1)
2256-
ZEND_ARG_TYPE_INFO(0, buffer, IS_STRING, 0)
2257-
ZEND_END_ARG_INFO()
2258-
2259-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_call, 0, 0, 2)
2260-
ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
2261-
ZEND_ARG_TYPE_INFO(0, resource, IS_RESOURCE, 1)
2262-
ZEND_ARG_VARIADIC_INFO(0, vars)
2263-
ZEND_END_ARG_INFO()
2264-
2265-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_image_get, 0, 0, 2)
2266-
ZEND_ARG_TYPE_INFO(0, image, IS_RESOURCE, 0)
2267-
ZEND_ARG_TYPE_INFO(0, field, IS_STRING, 0)
2268-
ZEND_END_ARG_INFO()
2269-
2270-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_image_get_typeof, 0, 0, 2)
2271-
ZEND_ARG_TYPE_INFO(0, image, IS_RESOURCE, 0)
2272-
ZEND_ARG_TYPE_INFO(0, field, IS_STRING, 0)
2273-
ZEND_END_ARG_INFO()
2274-
2275-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_image_set, 0, 0, 3)
2276-
ZEND_ARG_TYPE_INFO(0, image, IS_RESOURCE, 0)
2277-
ZEND_ARG_TYPE_INFO(0, field, IS_STRING, 0)
2278-
ZEND_ARG_INFO(0, value)
2279-
ZEND_END_ARG_INFO()
2280-
2281-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_type_from_name, 0, 0, 1)
2282-
ZEND_ARG_TYPE_INFO(0, field, IS_STRING, 0)
2283-
ZEND_END_ARG_INFO()
2284-
2285-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_image_set_type, 0, 0, 4)
2286-
ZEND_ARG_TYPE_INFO(0, image, IS_RESOURCE, 0)
2287-
ZEND_ARG_TYPE_MASK(0, type, MAY_BE_LONG|MAY_BE_STRING, NULL)
2288-
ZEND_ARG_TYPE_INFO(0, field, IS_STRING, 0)
2289-
ZEND_ARG_INFO(0, value)
2290-
ZEND_END_ARG_INFO()
2291-
2292-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_image_remove, 0, 0, 2)
2293-
ZEND_ARG_TYPE_INFO(0, image, IS_RESOURCE, 0)
2294-
ZEND_ARG_TYPE_INFO(0, field, IS_STRING, 0)
2295-
ZEND_END_ARG_INFO()
2296-
2297-
ZEND_BEGIN_ARG_INFO(arginfo_vips_error_buffer, 0)
2298-
ZEND_END_ARG_INFO()
2299-
2300-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_cache_set_max, 0, 0, 1)
2301-
ZEND_ARG_TYPE_INFO(0, value, IS_LONG, 0)
2302-
ZEND_END_ARG_INFO()
2303-
2304-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_cache_set_max_mem, 0, 0, 1)
2305-
ZEND_ARG_TYPE_INFO(0, value, IS_LONG, 0)
2306-
ZEND_END_ARG_INFO()
2307-
2308-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_cache_set_max_files, 0, 0, 1)
2309-
ZEND_ARG_TYPE_INFO(0, value, IS_LONG, 0)
2310-
ZEND_END_ARG_INFO()
2311-
2312-
ZEND_BEGIN_ARG_INFO_EX(arginfo_vips_concurrency_set, 0, 0, 1)
2313-
ZEND_ARG_TYPE_INFO(0, value, IS_LONG, 0)
2314-
ZEND_END_ARG_INFO()
2315-
2316-
ZEND_BEGIN_ARG_INFO(arginfo_vips_cache_get_max, 0)
2317-
ZEND_END_ARG_INFO()
2318-
2319-
ZEND_BEGIN_ARG_INFO(arginfo_vips_cache_get_max_mem, 0)
2320-
ZEND_END_ARG_INFO()
2321-
2322-
ZEND_BEGIN_ARG_INFO(arginfo_vips_cache_get_max_files, 0)
2323-
ZEND_END_ARG_INFO()
2324-
2325-
ZEND_BEGIN_ARG_INFO(arginfo_vips_cache_get_size, 0)
2326-
ZEND_END_ARG_INFO()
2327-
2328-
ZEND_BEGIN_ARG_INFO(arginfo_vips_concurrency_get, 0)
2329-
ZEND_END_ARG_INFO()
2330-
2331-
ZEND_BEGIN_ARG_INFO(arginfo_vips_version, 0)
2332-
ZEND_END_ARG_INFO()
2333-
/* {{{ vips_functions[]
2334-
*
2335-
* Every user visible function must have an entry in vips_functions[].
2336-
*/
2337-
const zend_function_entry vips_functions[] = {
2338-
PHP_FE(vips_image_new_from_file, arginfo_vips_image_new_from_file)
2339-
PHP_FE(vips_image_new_from_buffer, arginfo_vips_image_new_from_buffer)
2340-
PHP_FE(vips_image_new_from_array, arginfo_vips_image_new_from_array)
2341-
PHP_FE(vips_image_write_to_file, arginfo_vips_image_write_to_file)
2342-
PHP_FE(vips_image_write_to_buffer, arginfo_vips_image_write_to_buffer)
2343-
PHP_FE(vips_image_copy_memory, arginfo_vips_image_copy_memory)
2344-
PHP_FE(vips_image_new_from_memory, arginfo_vips_image_new_from_memory)
2345-
PHP_FE(vips_image_write_to_memory, arginfo_vips_image_write_to_memory)
2346-
PHP_FE(vips_image_write_to_array, arginfo_vips_image_write_to_array)
2347-
PHP_FE(vips_foreign_find_load, arginfo_vips_foreign_find_load)
2348-
PHP_FE(vips_foreign_find_load_buffer, arginfo_vips_foreign_find_load_buffer)
2349-
PHP_FE(vips_interpolate_new, arginfo_vips_interpolate_new)
2350-
2351-
PHP_FE(vips_call, arginfo_vips_call)
2352-
PHP_FE(vips_image_get, arginfo_vips_image_get)
2353-
PHP_FE(vips_image_get_typeof, arginfo_vips_image_get_typeof)
2354-
PHP_FE(vips_image_set, arginfo_vips_image_set)
2355-
PHP_FE(vips_type_from_name, arginfo_vips_type_from_name)
2356-
PHP_FE(vips_image_set_type, arginfo_vips_image_set_type)
2357-
PHP_FE(vips_image_remove, arginfo_vips_image_remove)
2358-
PHP_FE(vips_error_buffer, arginfo_vips_error_buffer)
2359-
PHP_FE(vips_cache_set_max, arginfo_vips_cache_set_max)
2360-
PHP_FE(vips_cache_set_max_mem, arginfo_vips_cache_set_max_mem)
2361-
PHP_FE(vips_cache_set_max_files, arginfo_vips_cache_set_max_files)
2362-
PHP_FE(vips_concurrency_set, arginfo_vips_concurrency_set)
2363-
PHP_FE(vips_cache_get_max, arginfo_vips_cache_get_max)
2364-
PHP_FE(vips_cache_get_max_mem, arginfo_vips_cache_get_max_mem)
2365-
PHP_FE(vips_cache_get_max_files, arginfo_vips_cache_get_max_files)
2366-
PHP_FE(vips_cache_get_size, arginfo_vips_cache_get_size)
2367-
PHP_FE(vips_concurrency_get, arginfo_vips_concurrency_get)
2368-
PHP_FE(vips_version, arginfo_vips_version)
2369-
2370-
PHP_FE_END /* Must be the last line in vips_functions[] */
2371-
};
2372-
/* }}} */
2373-
23742200
/* {{{ vips_module_entry
23752201
*/
23762202
zend_module_entry vips_module_entry = {
23772203
STANDARD_MODULE_HEADER,
23782204
"vips",
2379-
vips_functions,
2205+
ext_functions,
23802206
PHP_MINIT(vips),
23812207
PHP_MSHUTDOWN(vips),
23822208
PHP_RINIT(vips), /* Replace with NULL if there's nothing to do at request start */

0 commit comments

Comments
 (0)