Skip to content

Add type hints #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ missing
mkinstalldirs
modules
run-tests.php
gen_stub.php
tests/*/*.diff
tests/*/*.out
tests/*/*.php
tests/*/*.exp
tests/*/*.log
tests/*/*.sh

# Used by gen_stub.php
PHP-Parser-*
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ $ make install
Add `extension=vips.so` to `php.ini`, perhaps in `~/vips/lib/php.ini`,
if you configured php as above.

### Development: regenerate `vips_arginfo.h`

Run:

```
$ curl -LO https://github.com/php/php-src/raw/ffacda14b88be797a466f472359f306d626e698f/build/gen_stub.php
$ php gen_stub.php
```

### Links

http://php.net/manual/en/internals2.php
Expand Down
58 changes: 0 additions & 58 deletions config.h.in~

This file was deleted.

200 changes: 14 additions & 186 deletions vips.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
ZEND_DECLARE_MODULE_GLOBALS(vips)
*/

#include "vips_arginfo.h"

/* True global resources - no need for thread safety here */
static int le_gobject;

Expand Down Expand Up @@ -1047,7 +1049,7 @@ vips_php_call_array(const char *operation_name, zval *instance,

/* }}} */

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

PHP_FUNCTION(vips_call)
Expand Down Expand Up @@ -1094,7 +1096,7 @@ PHP_FUNCTION(vips_call)
}
/* }}} */

/* {{{ proto resource vips_image_new_from_file(string filename [, array options])
/* {{{ proto array|long vips_image_new_from_file(string filename [, array options])
Open an image from a filename */
PHP_FUNCTION(vips_image_new_from_file)
{
Expand Down Expand Up @@ -1138,7 +1140,7 @@ PHP_FUNCTION(vips_image_new_from_file)
}
/* }}} */

/* {{{ proto resource vips_image_new_from_buffer(string buffer [, string option_string, array options])
/* {{{ proto array|long vips_image_new_from_buffer(string buffer [, string option_string, array options])
Open an image from a string */
PHP_FUNCTION(vips_image_new_from_buffer)
{
Expand Down Expand Up @@ -1237,7 +1239,7 @@ PHP_FUNCTION(vips_image_new_from_array)
}
/* }}} */

/* {{{ proto resource vips_interpolate_new(string name])
/* {{{ proto resource vips_interpolate_new(string name)
make a new interpolator */
PHP_FUNCTION(vips_interpolate_new)
{
Expand All @@ -1260,7 +1262,7 @@ PHP_FUNCTION(vips_interpolate_new)
}
/* }}} */

/* {{{ proto long vips_image_write_to_file(resource image, string filename [, array options])
/* {{{ proto array|long vips_image_write_to_file(resource image, string filename [, array options])
Write an image to a filename */
PHP_FUNCTION(vips_image_write_to_file)
{
Expand Down Expand Up @@ -1311,7 +1313,7 @@ PHP_FUNCTION(vips_image_write_to_file)
}
/* }}} */

/* {{{ proto string|long vips_image_write_to_buffer(resource image, string suffix [, array options])
/* {{{ proto array|long vips_image_write_to_buffer(resource image, string suffix [, array options])
Write an image to a string */
PHP_FUNCTION(vips_image_write_to_buffer)
{
Expand Down Expand Up @@ -1354,7 +1356,7 @@ PHP_FUNCTION(vips_image_write_to_buffer)
}
/* }}} */

/* {{{ proto resource vips_image_copy_memory(resource image)
/* {{{ proto array|long vips_image_copy_memory(resource image)
Copy an image to a memory image */
PHP_FUNCTION(vips_image_copy_memory)
{
Expand Down Expand Up @@ -1388,7 +1390,7 @@ PHP_FUNCTION(vips_image_copy_memory)
}
/* }}} */

/* {{{ proto resource vips_image_new_from_memory(string data, integer width, integer height, integer bands, string format)
/* {{{ proto array|long vips_image_new_from_memory(string memory, integer width, integer height, integer bands, string format)
Wrap an image around a memory array. */
PHP_FUNCTION(vips_image_new_from_memory)
{
Expand Down Expand Up @@ -1431,7 +1433,7 @@ PHP_FUNCTION(vips_image_new_from_memory)
}
/* }}} */

/* {{{ proto string vips_image_write_to_memory(resource image)
/* {{{ proto string|long vips_image_write_to_memory(resource image)
Write an image to a memory array. */
PHP_FUNCTION(vips_image_write_to_memory)
{
Expand Down Expand Up @@ -1469,7 +1471,7 @@ PHP_FUNCTION(vips_image_write_to_memory)
APPEND(return_value, p[i]); \
}

/* {{{ proto array vips_image_write_to_array(resource image)
/* {{{ proto array|long vips_image_write_to_array(resource image)
Write an image to a PHP array. */
PHP_FUNCTION(vips_image_write_to_array)
{
Expand Down Expand Up @@ -1588,7 +1590,7 @@ PHP_FUNCTION(vips_foreign_find_load_buffer)
}
/* }}} */

/* {{{ proto array vips_image_get(resource image, string field)
/* {{{ proto array|long vips_image_get(resource image, string field)
Fetch field from image */
PHP_FUNCTION(vips_image_get)
{
Expand Down Expand Up @@ -2195,186 +2197,12 @@ PHP_MINFO_FUNCTION(vips)
}
/* }}} */

ZEND_BEGIN_ARG_INFO(arginfo_vips_image_new_from_file, 0)
ZEND_ARG_INFO(0, filename)
ZEND_ARG_INFO(0, options)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_image_new_from_buffer, 0)
ZEND_ARG_INFO(0, buffer)
ZEND_ARG_INFO(0, option_string)
ZEND_ARG_INFO(0, options)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_image_new_from_array, 0)
ZEND_ARG_INFO(0, array)
ZEND_ARG_INFO(0, scale)
ZEND_ARG_INFO(0, offset)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_image_write_to_file, 0)
ZEND_ARG_INFO(0, image)
ZEND_ARG_INFO(0, filename)
ZEND_ARG_INFO(0, options)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_image_write_to_buffer, 0)
ZEND_ARG_INFO(0, image)
ZEND_ARG_INFO(0, options)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_image_copy_memory, 0)
ZEND_ARG_INFO(0, image)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_image_new_from_memory, 0)
ZEND_ARG_INFO(0, array)
ZEND_ARG_INFO(0, width)
ZEND_ARG_INFO(0, height)
ZEND_ARG_INFO(0, bands)
ZEND_ARG_INFO(0, format)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_image_write_to_memory, 0)
ZEND_ARG_INFO(0, image)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_image_write_to_array, 0)
ZEND_ARG_INFO(0, image)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_foreign_find_load, 0)
ZEND_ARG_INFO(0, filename)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_interpolate_new, 0)
ZEND_ARG_INFO(0, name)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_foreign_find_load_buffer, 0)
ZEND_ARG_INFO(0, buffer)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_call, 0)
ZEND_ARG_INFO(0, operation_name)
ZEND_ARG_INFO(0, instance)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_image_get, 0)
ZEND_ARG_INFO(0, image)
ZEND_ARG_INFO(0, field)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_image_get_typeof, 0)
ZEND_ARG_INFO(0, image)
ZEND_ARG_INFO(0, field)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_image_set, 0)
ZEND_ARG_INFO(0, image)
ZEND_ARG_INFO(0, field)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_type_from_name, 0)
ZEND_ARG_INFO(0, name)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_image_set_type, 0)
ZEND_ARG_INFO(0, image)
ZEND_ARG_INFO(0, type)
ZEND_ARG_INFO(0, field)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_image_remove, 0)
ZEND_ARG_INFO(0, image)
ZEND_ARG_INFO(0, field)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_error_buffer, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_cache_set_max, 0)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_cache_set_max_mem, 0)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_cache_set_max_files, 0)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_concurrency_set, 0)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_cache_get_max, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_cache_get_max_mem, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_cache_get_max_files, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_cache_get_size, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_concurrency_get, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO(arginfo_vips_version, 0)
ZEND_END_ARG_INFO()
/* {{{ vips_functions[]
*
* Every user visible function must have an entry in vips_functions[].
*/
const zend_function_entry vips_functions[] = {
PHP_FE(vips_image_new_from_file, arginfo_vips_image_new_from_file)
PHP_FE(vips_image_new_from_buffer, arginfo_vips_image_new_from_buffer)
PHP_FE(vips_image_new_from_array, arginfo_vips_image_new_from_array)
PHP_FE(vips_image_write_to_file, arginfo_vips_image_write_to_file)
PHP_FE(vips_image_write_to_buffer, arginfo_vips_image_write_to_buffer)
PHP_FE(vips_image_copy_memory, arginfo_vips_image_copy_memory)
PHP_FE(vips_image_new_from_memory, arginfo_vips_image_new_from_memory)
PHP_FE(vips_image_write_to_memory, arginfo_vips_image_write_to_memory)
PHP_FE(vips_image_write_to_array, arginfo_vips_image_write_to_array)
PHP_FE(vips_foreign_find_load, arginfo_vips_foreign_find_load)
PHP_FE(vips_foreign_find_load_buffer, arginfo_vips_foreign_find_load_buffer)
PHP_FE(vips_interpolate_new, arginfo_vips_interpolate_new)

PHP_FE(vips_call, arginfo_vips_call)
PHP_FE(vips_image_get, arginfo_vips_image_get)
PHP_FE(vips_image_get_typeof, arginfo_vips_image_get_typeof)
PHP_FE(vips_image_set, arginfo_vips_image_set)
PHP_FE(vips_type_from_name, arginfo_vips_type_from_name)
PHP_FE(vips_image_set_type, arginfo_vips_image_set_type)
PHP_FE(vips_image_remove, arginfo_vips_image_remove)
PHP_FE(vips_error_buffer, arginfo_vips_error_buffer)
PHP_FE(vips_cache_set_max, arginfo_vips_cache_set_max)
PHP_FE(vips_cache_set_max_mem, arginfo_vips_cache_set_max_mem)
PHP_FE(vips_cache_set_max_files, arginfo_vips_cache_set_max_files)
PHP_FE(vips_concurrency_set, arginfo_vips_concurrency_set)
PHP_FE(vips_cache_get_max, arginfo_vips_cache_get_max)
PHP_FE(vips_cache_get_max_mem, arginfo_vips_cache_get_max_mem)
PHP_FE(vips_cache_get_max_files, arginfo_vips_cache_get_max_files)
PHP_FE(vips_cache_get_size, arginfo_vips_cache_get_size)
PHP_FE(vips_concurrency_get, arginfo_vips_concurrency_get)
PHP_FE(vips_version, arginfo_vips_version)

PHP_FE_END /* Must be the last line in vips_functions[] */
};
/* }}} */

/* {{{ vips_module_entry
*/
zend_module_entry vips_module_entry = {
STANDARD_MODULE_HEADER,
"vips",
vips_functions,
ext_functions,
PHP_MINIT(vips),
PHP_MSHUTDOWN(vips),
PHP_RINIT(vips), /* Replace with NULL if there's nothing to do at request start */
Expand Down
Loading