Skip to content

Commit 0bb4d66

Browse files
committed
Move code from zend_default_classes.c to zend_attributes.c
1 parent db7f5fc commit 0bb4d66

File tree

5 files changed

+45
-39
lines changed

5 files changed

+45
-39
lines changed

Zend/zend_attributes.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include "zend.h"
2+
#include "zend_API.h"
3+
#include "zend_attributes.h"
4+
5+
void zend_attribute_validate_phpattribute(zval *attribute)
6+
{
7+
}
8+
9+
void zend_attribute_validate_phpcompilerattribute(zval *attribute)
10+
{
11+
zend_error(E_COMPILE_ERROR, "The PhpCompilerAttribute can only be used by internal classes, use PhpAttribute instead");
12+
}
13+
14+
void zend_register_attribute_ce(void)
15+
{
16+
zend_hash_init(&zend_attributes_internal_validators, 8, NULL, NULL, 1);
17+
18+
zend_class_entry ce;
19+
zend_attributes_internal_validator cb;
20+
21+
INIT_CLASS_ENTRY(ce, "PhpAttribute", NULL);
22+
zend_ce_php_attribute = zend_register_internal_class(&ce);
23+
zend_ce_php_attribute->ce_flags |= ZEND_ACC_FINAL;
24+
25+
cb = zend_attribute_validate_phpattribute;
26+
zend_compiler_attribute_register(zend_ce_php_attribute, &cb);
27+
28+
INIT_CLASS_ENTRY(ce, "PhpCompilerAttribute", NULL);
29+
zend_ce_php_compiler_attribute = zend_register_internal_class(&ce);
30+
zend_ce_php_compiler_attribute->ce_flags |= ZEND_ACC_FINAL;
31+
32+
cb = zend_attribute_validate_phpcompilerattribute;
33+
zend_compiler_attribute_register(zend_ce_php_compiler_attribute, &cb);
34+
}
35+
36+
void zend_compiler_attribute_register(zend_class_entry *ce, zend_attributes_internal_validator *validator)
37+
{
38+
zend_string *attribute_name = zend_string_tolower_ex(ce->name, 1);
39+
40+
zend_hash_update_mem(&zend_attributes_internal_validators, attribute_name, validator, sizeof(zend_attributes_internal_validator));
41+
}

Zend/zend_attributes.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ zend_class_entry *zend_ce_php_compiler_attribute;
77
typedef void (*zend_attributes_internal_validator)(zval *attribute);
88
HashTable zend_attributes_internal_validators;
99

10-
static void zend_compiler_attribute_register(zend_class_entry *ce, zend_attributes_internal_validator *validator)
11-
{
12-
zend_string *attribute_name = zend_string_tolower_ex(ce->name, 1);
13-
14-
zend_hash_update_mem(&zend_attributes_internal_validators, attribute_name, validator, sizeof(zend_attributes_internal_validator));
15-
}
10+
void zend_compiler_attribute_register(zend_class_entry *ce, zend_attributes_internal_validator *validator);
11+
void zend_register_attribute_ce(void);
1612
#endif

Zend/zend_default_classes.c

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,37 +27,6 @@
2727
#include "zend_generators.h"
2828
#include "zend_weakrefs.h"
2929

30-
void zend_attribute_validate_phpattribute(zval *attribute)
31-
{
32-
}
33-
34-
void zend_attribute_validate_phpcompilerattribute(zval *attribute)
35-
{
36-
zend_error(E_COMPILE_ERROR, "The PhpCompilerAttribute can only be used by internal classes, use PhpAttribute instead");
37-
}
38-
39-
static void zend_register_attribute_ce(void)
40-
{
41-
zend_hash_init(&zend_attributes_internal_validators, 8, NULL, NULL, 1);
42-
43-
zend_class_entry ce;
44-
zend_attributes_internal_validator cb;
45-
46-
INIT_CLASS_ENTRY(ce, "PhpAttribute", NULL);
47-
zend_ce_php_attribute = zend_register_internal_class(&ce);
48-
zend_ce_php_attribute->ce_flags |= ZEND_ACC_FINAL;
49-
50-
cb = zend_attribute_validate_phpattribute;
51-
zend_compiler_attribute_register(zend_ce_php_attribute, &cb);
52-
53-
INIT_CLASS_ENTRY(ce, "PhpCompilerAttribute", NULL);
54-
zend_ce_php_compiler_attribute = zend_register_internal_class(&ce);
55-
zend_ce_php_compiler_attribute->ce_flags |= ZEND_ACC_FINAL;
56-
57-
cb = zend_attribute_validate_phpcompilerattribute;
58-
zend_compiler_attribute_register(zend_ce_php_compiler_attribute, &cb);
59-
}
60-
6130
ZEND_API void zend_register_default_classes(void)
6231
{
6332
zend_register_interfaces();

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ PHP_ADD_SOURCES(Zend, \
14591459
zend_execute_API.c zend_highlight.c zend_llist.c \
14601460
zend_vm_opcodes.c zend_opcode.c zend_operators.c zend_ptr_stack.c zend_stack.c \
14611461
zend_variables.c zend.c zend_API.c zend_extensions.c zend_hash.c \
1462-
zend_list.c zend_builtin_functions.c \
1462+
zend_list.c zend_builtin_functions.c zend_attributes.c \
14631463
zend_ini.c zend_sort.c zend_multibyte.c zend_ts_hash.c zend_stream.c \
14641464
zend_iterators.c zend_interfaces.c zend_exceptions.c zend_strtod.c zend_gc.c \
14651465
zend_closures.c zend_weakrefs.c zend_float.c zend_string.c zend_signal.c zend_generators.c \

win32/build/config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ ADD_SOURCES("Zend", "zend_language_parser.c zend_language_scanner.c \
230230
zend_execute_API.c zend_highlight.c \
231231
zend_llist.c zend_vm_opcodes.c zend_opcode.c zend_operators.c zend_ptr_stack.c \
232232
zend_stack.c zend_variables.c zend.c zend_API.c zend_extensions.c \
233-
zend_hash.c zend_list.c zend_builtin_functions.c \
233+
zend_hash.c zend_list.c zend_builtin_functions.c zend_attributes.c \
234234
zend_ini.c zend_sort.c zend_multibyte.c zend_ts_hash.c \
235235
zend_stream.c zend_iterators.c zend_interfaces.c zend_objects.c \
236236
zend_object_handlers.c zend_objects_API.c \

0 commit comments

Comments
 (0)