Skip to content

Fix type macros for C++ #11582

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

Closed
wants to merge 3 commits into from
Closed
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
3 changes: 3 additions & 0 deletions Zend/zend_opcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ ZEND_API void destroy_zend_class(zval *zv)
if (prop_info->ce == ce) {
zend_string_release(prop_info->name);
zend_type_release(prop_info->type, /* persistent */ 1);
if (prop_info->attributes) {
zend_hash_release(prop_info->attributes);
}
free(prop_info);
}
} ZEND_HASH_FOREACH_END();
Expand Down
20 changes: 14 additions & 6 deletions Zend/zend_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,28 +263,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
#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