GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Make zend_type into a struct with pointer + type_mask by nikic · Pull Request #4728 · php/php-src Conversation
|
|
@dstogov This is ready for a look now. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
5f95cda to
de02cc3
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, this patch doesn't make any value, except for preparation for "union types".
It makes things more complex and messed + increases memory usage.
I won't agree with this patch alone.
It may fit into PHP together with "union types", however, I afraid they will bring much more mess.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| new_arg_info[i].type = | ||
| ZEND_TYPE_ENCODE_CLASS( | ||
| name, ZEND_TYPE_ALLOW_NULL(arg_info[i].type)); | ||
| ZEND_TYPE_SET_PTR(new_arg_info[i].type, name); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Would be better to name macro ZEND_TYPE_SET_CLASS_NAME()
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| ZEND_ASSERT(prop_ce && prop_ce->type == ZEND_INTERNAL_CLASS); | ||
| prop_info->type = ZEND_TYPE_ENCODE_CE(prop_ce, ZEND_TYPE_ALLOW_NULL(prop_info->type)); | ||
| prop_info->type = (zend_type) ZEND_TYPE_INIT_CE(prop_ce, ZEND_TYPE_ALLOW_NULL(prop_info->type), 0); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how modern C implements dynamic structure initializes.
I would recommend to use old style explicit macro initializers (like ZEND_LONG).
ZEND_TYPE_INIT_CE(rop_info->type, prop_ce, ZEND_TYPE_ALLOW_NULL(prop_info->type), 0);
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment) /* {{{ */ | ||
| { | ||
| return zend_declare_typed_property(ce, name, property, access_type, doc_comment, ZEND_TYPE_ENCODE_NONE()); | ||
| return zend_declare_typed_property(ce, name, property, access_type, doc_comment, (zend_type) ZEND_TYPE_INIT_NONE(0)); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
"big" structure is passed by value. This is not efficient.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| static const zend_internal_arg_info name[] = { \ | ||
| { (const char*)(zend_uintptr_t)(required_num_args), ZEND_TYPE_ENCODE_CLASS_CONST(#class_name, allow_null), return_reference, 0 }, | ||
| { (const char*)(zend_uintptr_t)(required_num_args), \ | ||
| ZEND_TYPE_INIT_CLASS_CONST(#class_name, allow_null, _ZEND_ARG_INFO_FLAGS(return_reference, 0)) }, |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It's OK to use static initializers for constants.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| if (ast->kind == ZEND_AST_TYPE) { | ||
| return ZEND_TYPE_ENCODE_CODE(ast->attr, allow_null); | ||
| return (zend_type) ZEND_TYPE_INIT_CODE(ast->attr, allow_null, 0); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Return "big" structure by value is not efficient.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } else { | ||
| zend_type type = ZEND_TYPE_WITHOUT_NULL(arg_info->type); | ||
| switch (ZEND_TYPE_MASK(type)) { | ||
| uint32_t type_mask = ZEND_TYPE_PURE_MASK_WITHOUT_NULL(arg_info->type); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This PURE_MASK and FULL_MASK names are not intuitive.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * | ||
| * ZEND_TYPE_IS_SET() - checks if type-hint exists | ||
| * ZEND_TYPE_IS_MASK() - checks if type-hint refer to standard type | ||
| * ZEND_TYPE_IS_ONLY_MASK() - checks if type-hint refer to standard type |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We don't have union types yet. I don't understand the meaning of "ONLY"?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Part of #4838 now. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.