Skip to content

Fix GH-9967 Add support for generating custom function, class const, and property attributes in stubs #11978

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 2 commits into from
Aug 26, 2023
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
60 changes: 30 additions & 30 deletions Zend/zend_attributes_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Zend/zend_builtin_functions_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Zend/zend_exceptions_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions Zend/zend_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,28 +269,36 @@ typedef struct {
#define ZEND_TYPE_ALLOW_NULL(t) \
(((t).type_mask & _ZEND_TYPE_NULLABLE_BIT) != 0)

#ifdef __cplusplus
# define _ZEND_TYPE_PREFIX zend_type
#else
/* FIXME: We could add (zend_type) here at some point but this breaks in MSVC because
* (zend_type)(zend_type){} is no longer considered constant. */
# define _ZEND_TYPE_PREFIX
Copy link
Contributor

@dktapps dktapps Sep 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This broke something with C++ extensions with clang on MacOS, I get errors like this on 8.3.0RC1:

/Users/runner/work/PHP-Binaries/PHP-Binaries/install_data/subdir/php/ext/morton/morton.cpp:45:1: error: expected '(' for function-style cast or type construction
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_morton2d_encode, 0, 2, IS_LONG, 0)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/runner/work/PHP-Binaries/PHP-Binaries/install_data/subdir/php/Zend/zend_API.h:202:2: note: expanded from macro 'ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX'
        ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX2(name, return_reference, required_num_args, type, allow_null, 0)
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/runner/work/PHP-Binaries/PHP-Binaries/install_data/subdir/php/Zend/zend_API.h:199:50: note: expanded from macro 'ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX2'
                { (const char*)(uintptr_t)(required_num_args), ZEND_TYPE_INIT_CODE(type, allow_null, _ZEND_ARG_INFO_FLAGS(return_reference, 0, is_tentative_return_type)), NULL },
                                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/runner/work/PHP-Binaries/PHP-Binaries/install_data/subdir/php/Zend/zend_types.h:287:2: note: expanded from macro 'ZEND_TYPE_INIT_CODE'
        ZEND_TYPE_INIT_MASK(((code) == _IS_BOOL ? MAY_BE_BOOL : ( (code) == IS_ITERABLE ? _ZEND_TYPE_ITERABLE_BIT : ((code) == IS_MIXED ? MAY_BE_ANY : (1 << (code))))) \
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/runner/work/PHP-Binaries/PHP-Binaries/install_data/subdir/php/Zend/zend_types.h:284:20: note: expanded from macro 'ZEND_TYPE_INIT_MASK'
        _ZEND_TYPE_PREFIX { NULL, (_type_mask) }
        ~~~~~~~~~~~~~~~~~ ^
/Users/runner/work/PHP-Binaries/PHP-Binaries/install_data/subdir/php/ext/morton/morton.cpp:46:2: error: expected '(' for function-style cast or type construction
        ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0)
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/runner/work/PHP-Binaries/PHP-Binaries/install_data/subdir/php/Zend/zend_API.h:135:11: note: expanded from macro 'ZEND_ARG_TYPE_INFO'
        { #name, ZEND_TYPE_INIT_CODE(type_hint, allow_null, _ZEND_ARG_INFO_FLAGS(pass_by_ref, 0, 0)), NULL },
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/runner/work/PHP-Binaries/PHP-Binaries/install_data/subdir/php/Zend/zend_types.h:287:2: note: expanded from macro 'ZEND_TYPE_INIT_CODE'
        ZEND_TYPE_INIT_MASK(((code) == _IS_BOOL ? MAY_BE_BOOL : ( (code) == IS_ITERABLE ? _ZEND_TYPE_ITERABLE_BIT : ((code) == IS_MIXED ? MAY_BE_ANY : (1 << (code))))) \
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/runner/work/PHP-Binaries/PHP-Binaries/install_data/subdir/php/Zend/zend_types.h:284:20: note: expanded from macro 'ZEND_TYPE_INIT_MASK'
        _ZEND_TYPE_PREFIX { NULL, (_type_mask) }
        ~~~~~~~~~~~~~~~~~ ^

Extension source for reference: https://github.com/pmmp/ext-morton/blob/2532e9f09d3bc6f6975d78b6632086b894dcef75/morton.cpp#L45

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Commented on the wrong line)

#endif

#define ZEND_TYPE_INIT_NONE(extra_flags) \
{ NULL, (extra_flags) }
_ZEND_TYPE_PREFIX { NULL, (extra_flags) }

#define ZEND_TYPE_INIT_MASK(_type_mask) \
{ NULL, (_type_mask) }
_ZEND_TYPE_PREFIX { NULL, (_type_mask) }

#define ZEND_TYPE_INIT_CODE(code, allow_null, extra_flags) \
ZEND_TYPE_INIT_MASK(((code) == _IS_BOOL ? MAY_BE_BOOL : ( (code) == IS_ITERABLE ? _ZEND_TYPE_ITERABLE_BIT : ((code) == IS_MIXED ? MAY_BE_ANY : (1 << (code))))) \
| ((allow_null) ? _ZEND_TYPE_NULLABLE_BIT : 0) | (extra_flags))

#define ZEND_TYPE_INIT_PTR(ptr, type_kind, allow_null, extra_flags) \
{ (void *) (ptr), \
_ZEND_TYPE_PREFIX { (void *) (ptr), \
(type_kind) | ((allow_null) ? _ZEND_TYPE_NULLABLE_BIT : 0) | (extra_flags) }

#define ZEND_TYPE_INIT_PTR_MASK(ptr, type_mask) \
{ (void *) (ptr), (type_mask) }
_ZEND_TYPE_PREFIX { (void *) (ptr), (type_mask) }

#define ZEND_TYPE_INIT_UNION(ptr, extra_flags) \
{ (void *) (ptr), (_ZEND_TYPE_LIST_BIT|_ZEND_TYPE_UNION_BIT) | (extra_flags) }
_ZEND_TYPE_PREFIX { (void *) (ptr), (_ZEND_TYPE_LIST_BIT|_ZEND_TYPE_UNION_BIT) | (extra_flags) }

#define ZEND_TYPE_INIT_INTERSECTION(ptr, extra_flags) \
{ (void *) (ptr), (_ZEND_TYPE_LIST_BIT|_ZEND_TYPE_INTERSECTION_BIT) | (extra_flags) }
_ZEND_TYPE_PREFIX { (void *) (ptr), (_ZEND_TYPE_LIST_BIT|_ZEND_TYPE_INTERSECTION_BIT) | (extra_flags) }

#define ZEND_TYPE_INIT_CLASS(class_name, allow_null, extra_flags) \
ZEND_TYPE_INIT_PTR(class_name, _ZEND_TYPE_NAME_BIT, allow_null, extra_flags)
Expand Down
Loading