Skip to content

Commit 27a2caa

Browse files
authored
zend_attributes: add const qualifiers (#20448)
1 parent aa96baa commit 27a2caa

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

Zend/zend_attributes.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static zend_object_handlers attributes_object_handlers_sensitive_parameter_value
3838

3939
static HashTable internal_attributes;
4040

41-
uint32_t zend_attribute_attribute_get_flags(zend_attribute *attr, zend_class_entry *scope)
41+
uint32_t zend_attribute_attribute_get_flags(const zend_attribute *attr, zend_class_entry *scope)
4242
{
4343
// TODO: More proper signature validation: Too many args, incorrect arg names.
4444
if (attr->argc > 0) {
@@ -265,7 +265,7 @@ ZEND_METHOD(NoDiscard, __construct)
265265
}
266266
}
267267

268-
static zend_attribute *get_attribute(HashTable *attributes, zend_string *lcname, uint32_t offset)
268+
static zend_attribute *get_attribute(const HashTable *attributes, const zend_string *lcname, uint32_t offset)
269269
{
270270
if (attributes) {
271271
zend_attribute *attr;
@@ -280,7 +280,7 @@ static zend_attribute *get_attribute(HashTable *attributes, zend_string *lcname,
280280
return NULL;
281281
}
282282

283-
static zend_attribute *get_attribute_str(HashTable *attributes, const char *str, size_t len, uint32_t offset)
283+
static zend_attribute *get_attribute_str(const HashTable *attributes, const char *str, size_t len, uint32_t offset)
284284
{
285285
if (attributes) {
286286
zend_attribute *attr;
@@ -295,27 +295,27 @@ static zend_attribute *get_attribute_str(HashTable *attributes, const char *str,
295295
return NULL;
296296
}
297297

298-
ZEND_API zend_attribute *zend_get_attribute(HashTable *attributes, zend_string *lcname)
298+
ZEND_API zend_attribute *zend_get_attribute(const HashTable *attributes, const zend_string *lcname)
299299
{
300300
return get_attribute(attributes, lcname, 0);
301301
}
302302

303-
ZEND_API zend_attribute *zend_get_attribute_str(HashTable *attributes, const char *str, size_t len)
303+
ZEND_API zend_attribute *zend_get_attribute_str(const HashTable *attributes, const char *str, size_t len)
304304
{
305305
return get_attribute_str(attributes, str, len, 0);
306306
}
307307

308-
ZEND_API zend_attribute *zend_get_parameter_attribute(HashTable *attributes, zend_string *lcname, uint32_t offset)
308+
ZEND_API zend_attribute *zend_get_parameter_attribute(const HashTable *attributes, const zend_string *lcname, uint32_t offset)
309309
{
310310
return get_attribute(attributes, lcname, offset + 1);
311311
}
312312

313-
ZEND_API zend_attribute *zend_get_parameter_attribute_str(HashTable *attributes, const char *str, size_t len, uint32_t offset)
313+
ZEND_API zend_attribute *zend_get_parameter_attribute_str(const HashTable *attributes, const char *str, size_t len, uint32_t offset)
314314
{
315315
return get_attribute_str(attributes, str, len, offset + 1);
316316
}
317317

318-
ZEND_API zend_result zend_get_attribute_value(zval *ret, zend_attribute *attr, uint32_t i, zend_class_entry *scope)
318+
ZEND_API zend_result zend_get_attribute_value(zval *ret, const zend_attribute *attr, uint32_t i, zend_class_entry *scope)
319319
{
320320
if (i >= attr->argc) {
321321
return FAILURE;
@@ -447,7 +447,7 @@ ZEND_API zend_string *zend_get_attribute_target_names(uint32_t flags)
447447
return smart_str_extract(&str);
448448
}
449449

450-
ZEND_API bool zend_is_attribute_repeated(HashTable *attributes, zend_attribute *attr)
450+
ZEND_API bool zend_is_attribute_repeated(const HashTable *attributes, const zend_attribute *attr)
451451
{
452452
zend_attribute *other;
453453

Zend/zend_attributes.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,17 @@ typedef struct _zend_internal_attribute {
7777
zend_string* (*validator)(zend_attribute *attr, uint32_t target, zend_class_entry *scope);
7878
} zend_internal_attribute;
7979

80-
ZEND_API zend_attribute *zend_get_attribute(HashTable *attributes, zend_string *lcname);
81-
ZEND_API zend_attribute *zend_get_attribute_str(HashTable *attributes, const char *str, size_t len);
80+
ZEND_API zend_attribute *zend_get_attribute(const HashTable *attributes, const zend_string *lcname);
81+
ZEND_API zend_attribute *zend_get_attribute_str(const HashTable *attributes, const char *str, size_t len);
8282

83-
ZEND_API zend_attribute *zend_get_parameter_attribute(HashTable *attributes, zend_string *lcname, uint32_t offset);
84-
ZEND_API zend_attribute *zend_get_parameter_attribute_str(HashTable *attributes, const char *str, size_t len, uint32_t offset);
83+
ZEND_API zend_attribute *zend_get_parameter_attribute(const HashTable *attributes, const zend_string *lcname, uint32_t offset);
84+
ZEND_API zend_attribute *zend_get_parameter_attribute_str(const HashTable *attributes, const char *str, size_t len, uint32_t offset);
8585

86-
ZEND_API zend_result zend_get_attribute_value(zval *ret, zend_attribute *attr, uint32_t i, zend_class_entry *scope);
86+
ZEND_API zend_result zend_get_attribute_value(zval *ret, const zend_attribute *attr, uint32_t i, zend_class_entry *scope);
8787
ZEND_API zend_result zend_get_attribute_object(zval *out, zend_class_entry *attribute_ce, zend_attribute *attribute_data, zend_class_entry *scope, zend_string *filename);
8888

8989
ZEND_API zend_string *zend_get_attribute_target_names(uint32_t targets);
90-
ZEND_API bool zend_is_attribute_repeated(HashTable *attributes, zend_attribute *attr);
90+
ZEND_API bool zend_is_attribute_repeated(const HashTable *attributes, const zend_attribute *attr);
9191

9292
ZEND_API zend_internal_attribute *zend_mark_internal_attribute(zend_class_entry *ce);
9393
ZEND_API zend_internal_attribute *zend_internal_attribute_register(zend_class_entry *ce, uint32_t flags);
@@ -97,7 +97,7 @@ ZEND_API zend_attribute *zend_add_attribute(
9797
HashTable **attributes, zend_string *name, uint32_t argc,
9898
uint32_t flags, uint32_t offset, uint32_t lineno);
9999

100-
uint32_t zend_attribute_attribute_get_flags(zend_attribute *attr, zend_class_entry *scope);
100+
uint32_t zend_attribute_attribute_get_flags(const zend_attribute *attr, zend_class_entry *scope);
101101

102102
END_EXTERN_C()
103103

@@ -119,13 +119,13 @@ static zend_always_inline zend_attribute *zend_add_parameter_attribute(zend_func
119119
return zend_add_attribute(&func->common.attributes, name, argc, flags, offset + 1, 0);
120120
}
121121

122-
static zend_always_inline zend_attribute *zend_add_property_attribute(zend_class_entry *ce, zend_property_info *info, zend_string *name, uint32_t argc)
122+
static zend_always_inline zend_attribute *zend_add_property_attribute(const zend_class_entry *ce, zend_property_info *info, zend_string *name, uint32_t argc)
123123
{
124124
uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0;
125125
return zend_add_attribute(&info->attributes, name, argc, flags, 0, 0);
126126
}
127127

128-
static zend_always_inline zend_attribute *zend_add_class_constant_attribute(zend_class_entry *ce, zend_class_constant *c, zend_string *name, uint32_t argc)
128+
static zend_always_inline zend_attribute *zend_add_class_constant_attribute(const zend_class_entry *ce, zend_class_constant *c, zend_string *name, uint32_t argc)
129129
{
130130
uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0;
131131
return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0);

0 commit comments

Comments
 (0)