summaryrefslogtreecommitdiff
path: root/Zend/zend_attributes.h
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-04-06 12:46:52 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-07-31 15:53:36 +0200
commitd92229d8c78aac25925284e23aa7903dca9ed005 (patch)
treeec01712dbe44a11cb7368492388cb39ab04dac17 /Zend/zend_attributes.h
parent9a71d47d7334b9e2f83db48498047750c04cd192 (diff)
downloadphp-git-d92229d8c78aac25925284e23aa7903dca9ed005.tar.gz
Implement named parameters
From an engine perspective, named parameters mainly add three concepts: * The SEND_* opcodes now accept a CONST op2, which is the argument name. For now, it is looked up by linear scan and runtime cached. * This may leave UNDEF arguments on the stack. To avoid having to deal with them in other places, a CHECK_UNDEF_ARGS opcode is used to either replace them with defaults, or error. * For variadic functions, EX(extra_named_params) are collected and need to be freed based on ZEND_CALL_HAS_EXTRA_NAMED_PARAMS. RFC: https://wiki.php.net/rfc/named_params Closes GH-5357.
Diffstat (limited to 'Zend/zend_attributes.h')
-rw-r--r--Zend/zend_attributes.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/Zend/zend_attributes.h b/Zend/zend_attributes.h
index 16221fa542..6b7150a363 100644
--- a/Zend/zend_attributes.h
+++ b/Zend/zend_attributes.h
@@ -30,19 +30,25 @@
#define ZEND_ATTRIBUTE_IS_REPEATABLE (1<<6)
#define ZEND_ATTRIBUTE_FLAGS ((1<<7) - 1)
-#define ZEND_ATTRIBUTE_SIZE(argc) (sizeof(zend_attribute) + sizeof(zval) * (argc) - sizeof(zval))
+#define ZEND_ATTRIBUTE_SIZE(argc) \
+ (sizeof(zend_attribute) + sizeof(zend_attribute_arg) * (argc) - sizeof(zend_attribute_arg))
BEGIN_EXTERN_C()
extern ZEND_API zend_class_entry *zend_ce_attribute;
+typedef struct {
+ zend_string *name;
+ zval value;
+} zend_attribute_arg;
+
typedef struct _zend_attribute {
zend_string *name;
zend_string *lcname;
/* Parameter offsets start at 1, everything else uses 0. */
uint32_t offset;
uint32_t argc;
- zval argv[1];
+ zend_attribute_arg args[1];
} zend_attribute;
typedef struct _zend_internal_attribute {