summaryrefslogtreecommitdiff
path: root/Zend/zend_attributes.h
diff options
context:
space:
mode:
authorMartin Schröder <m.schroeder2007@gmail.com>2020-06-28 19:16:33 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-06-29 10:45:51 +0200
commit053ef28b8d0c1e2af2cc5151cfe2bd4369ddde34 (patch)
tree54cebb4dfb10fae058a89f086f914ba93e16d254 /Zend/zend_attributes.h
parent46e38a192751be02ff95d56fb0c6c18ec4d7d6df (diff)
downloadphp-git-053ef28b8d0c1e2af2cc5151cfe2bd4369ddde34.tar.gz
Implement Attribute Amendments.
RFC: https://wiki.php.net/rfc/attribute_amendments Support for attribute grouping is left out, because the short attribute syntax RFC will likely make it obsolete. Closes GH-5751.
Diffstat (limited to 'Zend/zend_attributes.h')
-rw-r--r--Zend/zend_attributes.h40
1 files changed, 35 insertions, 5 deletions
diff --git a/Zend/zend_attributes.h b/Zend/zend_attributes.h
index 0e0136ff6d..16221fa542 100644
--- a/Zend/zend_attributes.h
+++ b/Zend/zend_attributes.h
@@ -1,3 +1,22 @@
+/*
+ +----------------------------------------------------------------------+
+ | Zend Engine |
+ +----------------------------------------------------------------------+
+ | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 2.00 of the Zend license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.zend.com/license/2_00.txt. |
+ | If you did not receive a copy of the Zend license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@zend.com so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Benjamin Eberlei <kontakt@beberlei.de> |
+ | Martin Schröder <m.schroeder2007@gmail.com> |
+ +----------------------------------------------------------------------+
+*/
+
#ifndef ZEND_ATTRIBUTES_H
#define ZEND_ATTRIBUTES_H
@@ -7,13 +26,15 @@
#define ZEND_ATTRIBUTE_TARGET_PROPERTY (1<<3)
#define ZEND_ATTRIBUTE_TARGET_CLASS_CONST (1<<4)
#define ZEND_ATTRIBUTE_TARGET_PARAMETER (1<<5)
-#define ZEND_ATTRIBUTE_TARGET_ALL (1<<6)
+#define ZEND_ATTRIBUTE_TARGET_ALL ((1<<6) - 1)
+#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))
BEGIN_EXTERN_C()
-extern ZEND_API zend_class_entry *zend_ce_php_attribute;
+extern ZEND_API zend_class_entry *zend_ce_attribute;
typedef struct _zend_attribute {
zend_string *name;
@@ -24,7 +45,11 @@ typedef struct _zend_attribute {
zval argv[1];
} zend_attribute;
-typedef void (*zend_attributes_internal_validator)(zend_attribute *attr, int target);
+typedef struct _zend_internal_attribute {
+ zend_class_entry *ce;
+ uint32_t flags;
+ void (*validator)(zend_attribute *attr, uint32_t target, zend_class_entry *scope);
+} zend_internal_attribute;
ZEND_API zend_attribute *zend_get_attribute(HashTable *attributes, zend_string *lcname);
ZEND_API zend_attribute *zend_get_attribute_str(HashTable *attributes, const char *str, size_t len);
@@ -32,8 +57,13 @@ ZEND_API zend_attribute *zend_get_attribute_str(HashTable *attributes, const cha
ZEND_API zend_attribute *zend_get_parameter_attribute(HashTable *attributes, zend_string *lcname, uint32_t offset);
ZEND_API zend_attribute *zend_get_parameter_attribute_str(HashTable *attributes, const char *str, size_t len, uint32_t offset);
-ZEND_API void zend_compiler_attribute_register(zend_class_entry *ce, zend_attributes_internal_validator validator);
-ZEND_API zend_attributes_internal_validator zend_attribute_get_validator(zend_string *lcname);
+ZEND_API int zend_get_attribute_value(zval *ret, zend_attribute *attr, uint32_t i, zend_class_entry *scope);
+
+ZEND_API zend_string *zend_get_attribute_target_names(uint32_t targets);
+ZEND_API zend_bool zend_is_attribute_repeated(HashTable *attributes, zend_attribute *attr);
+
+ZEND_API zend_internal_attribute *zend_internal_attribute_register(zend_class_entry *ce, uint32_t flags);
+ZEND_API zend_internal_attribute *zend_internal_attribute_get(zend_string *lcname);
ZEND_API zend_attribute *zend_add_attribute(HashTable **attributes, zend_bool persistent, uint32_t offset, zend_string *name, uint32_t argc);