Skip to content
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

use standard way to generate arginfo - discussion #423

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions imagick.c
Original file line number Diff line number Diff line change
Expand Up @@ -2312,7 +2312,7 @@ const zend_function_entry *php_imagickpixeliterator_class_methods = class_Imagic
// { NULL, NULL, NULL, 0, 0 }
//};

#include "ImagickPixel_arginfo.h"
#include "imagickpixel_class_arginfo.h"

const zend_function_entry *php_imagickpixel_class_methods = class_ImagickPixel_methods;

Expand Down Expand Up @@ -2902,7 +2902,7 @@ const zend_function_entry *php_imagick_class_methods = class_Imagick_methods;
// { NULL, NULL, NULL, 0, 0 }
//};

#include "ImagickKernel_arginfo.h"
#include "imagickkernel_class_arginfo.h"

const zend_function_entry *php_imagickkernel_class_methods = class_ImagickKernel_methods;

Expand Down Expand Up @@ -3978,7 +3978,9 @@ PHP_MINFO_FUNCTION(imagick)

PHP_MSHUTDOWN_FUNCTION(imagick)
{
#ifndef HAVE_OMP_PAUSE_RESOURCE_ALL
int i;
#endif

// This suppresses an 'unused parameter' warning.
(void)type;
Expand Down
2 changes: 1 addition & 1 deletion imagickkernel_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ PHP_METHOD(ImagickKernel, scale)
{
php_imagickkernel_object *internp;
double scale;
im_long normalize_flag;
im_long normalize_flag = 0;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|l", &scale, &normalize_flag) == FAILURE) {
return;
Expand Down
2 changes: 1 addition & 1 deletion ImagickKernel.stub.php → imagickkernel_class.stub.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static function fromMatrix(array $matrix, ?array $origin): ImagickKernel
public function getMatrix(): array {}

// NORMALIZE_KERNEL_
public function scale(float $scale, ?int $normalize_kernel): void {}
public function scale(float $scale, ?int $normalize_kernel = 0): void {}

public function separate(): array {}
}
Expand Down
92 changes: 10 additions & 82 deletions ImagickKernel_arginfo.h → imagickkernel_class_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,113 +1,41 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: regen with 'sh regen_arginfo.sh'
* file has been fixedup for different versions */
* Stub hash: 2b1addfe7bec455d316aac0f8a51bac5c4c9c591 */

#if defined(IMAGICK_WITH_KERNEL)

#if PHP_VERSION_ID >= 80000
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ImagickKernel_addKernel, 0, 1, IS_VOID, 0)
#else
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ImagickKernel_addKernel, 0, 0, 1)
#endif

ZEND_ARG_OBJ_INFO(0, kernel, ImagickKernel, 0)
ZEND_END_ARG_INFO()
#endif

#if defined(IMAGICK_WITH_KERNEL)

#if PHP_VERSION_ID >= 80000
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ImagickKernel_addUnityKernel, 0, 1, IS_VOID, 0)
#else
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ImagickKernel_addUnityKernel, 0, 0, 1)
#endif


#if PHP_VERSION_ID >= 80000
ZEND_ARG_TYPE_INFO(0, scale, IS_DOUBLE, 0)
#else
ZEND_ARG_INFO(0, scale)
#endif
ZEND_ARG_TYPE_INFO(0, scale, IS_DOUBLE, 0)
ZEND_END_ARG_INFO()
#endif

#if defined(IMAGICK_WITH_KERNEL)

#if PHP_VERSION_ID >= 80000
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_ImagickKernel_fromBuiltin, 0, 2, ImagickKernel, 0)
#else
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ImagickKernel_fromBuiltin, 0, 0, 2)
#endif


#if PHP_VERSION_ID >= 80000
ZEND_ARG_TYPE_INFO(0, kernel, IS_LONG, 0)
#else
ZEND_ARG_INFO(0, kernel)
#endif

#if PHP_VERSION_ID >= 80000
ZEND_ARG_TYPE_INFO(0, shape, IS_STRING, 0)
#else
ZEND_ARG_INFO(0, shape)
#endif
ZEND_ARG_TYPE_INFO(0, kernel, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, shape, IS_STRING, 0)
ZEND_END_ARG_INFO()
#endif

#if defined(IMAGICK_WITH_KERNEL)

#if PHP_VERSION_ID >= 80000
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_ImagickKernel_fromMatrix, 0, 2, ImagickKernel, 0)
#else
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ImagickKernel_fromMatrix, 0, 0, 2)
#endif


#if PHP_VERSION_ID >= 80000
ZEND_ARG_TYPE_INFO(0, matrix, IS_ARRAY, 0)
#else
ZEND_ARG_INFO(0, matrix)
#endif

#if PHP_VERSION_ID >= 80000
ZEND_ARG_TYPE_INFO(0, origin, IS_ARRAY, 1)
#else
ZEND_ARG_INFO(0, origin)
#endif
ZEND_ARG_TYPE_INFO(0, matrix, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, origin, IS_ARRAY, 1)
ZEND_END_ARG_INFO()
#endif

#if defined(IMAGICK_WITH_KERNEL)

#if PHP_VERSION_ID >= 80000
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ImagickKernel_getMatrix, 0, 0, IS_ARRAY, 0)
#else
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ImagickKernel_getMatrix, 0, 0, 0)
#endif

ZEND_END_ARG_INFO()
#endif

#if defined(IMAGICK_WITH_KERNEL)

#if PHP_VERSION_ID >= 80000
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ImagickKernel_scale, 0, 2, IS_VOID, 0)
#else
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ImagickKernel_scale, 0, 0, 2)
#endif


#if PHP_VERSION_ID >= 80000
ZEND_ARG_TYPE_INFO(0, scale, IS_DOUBLE, 0)
#else
ZEND_ARG_INFO(0, scale)
#endif

#if PHP_VERSION_ID >= 80000
ZEND_ARG_TYPE_INFO(0, normalize_kernel, IS_LONG, 1)
#else
ZEND_ARG_INFO(0, normalize_kernel)
#endif
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ImagickKernel_scale, 0, 1, IS_VOID, 0)
ZEND_ARG_TYPE_INFO(0, scale, IS_DOUBLE, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, normalize_kernel, IS_LONG, 1, "0")
ZEND_END_ARG_INFO()
#endif

Expand Down Expand Up @@ -162,4 +90,4 @@ static const zend_function_entry class_ImagickKernel_methods[] = {
ZEND_ME(ImagickKernel, separate, arginfo_class_ImagickKernel_separate, ZEND_ACC_PUBLIC)
#endif
ZEND_FE_END
};
};
21 changes: 15 additions & 6 deletions ImagickPixel.stub.php → imagickpixel_class.stub.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

/** @generate-function-entries */


class ImagickPixel
{
public function __construct(?string $color) {}
public function __construct(?string $color = null) {}

public function clear(): bool {}

Expand All @@ -20,15 +21,19 @@ public function getColorCount(): int {}
public function getColorQuantum(): array {}

// COLOR_*
public function getColorValue(int $color): IMAGICK_QUANTUM_TYPE {}
public function getColorValue(int $color): float {}

/**
* @param int $color // COLOR_*
* @return mixed
* return type:
* - Float if IM compiled with HDRI
* - int if IM compiled with fixed point math
*/
public function getColorValueQuantum(int $color): IMAGICK_QUANTUM_TYPE {}
#if MAGICKCORE_HDRI_ENABLE
public function getColorValueQuantum(int $color): float {}
#else
public function getColorValueQuantum(int $color): int {}
#endif

public function getHSL(): array {}

Expand Down Expand Up @@ -66,13 +71,17 @@ public function setColorValue(int $color, float $value): bool {}
* - int if IM compiled with fixed point math
*
*/
public function setColorValueQuantum(int $color, IMAGICK_QUANTUM_TYPE $value): bool{}
#if MAGICKCORE_HDRI_ENABLE
public function setColorValueQuantum(int $color, float $value): bool{}
#else
public function setColorValueQuantum(int $color, int $value): bool{}
#endif

public function setHSL(float $hue, float $saturation , float $luminosity): bool{}

// This function could be described more clearly...
// https://imagemagick.org/api/pixel-wand.php#PixelSetIndex
public function setIndex(IMAGICK_QUANTUM_TYPE $index): bool {}
public function setIndex(int $index): bool {}

//// Not in docs.
#if MagickLibVersion >= 0x693
Expand Down
Loading