Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

Commit 67fa362

Browse files
authored
Merge pull request #44 from pinepain/refactoring
Make API more PSR-compatible
2 parents 058effe + a968c64 commit 67fa362

File tree

205 files changed

+1550
-497
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+1550
-497
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ acinclude.m4
1313
aclocal.m4
1414
autom4te.cache
1515
build
16+
confdefs.h
1617
config.guess
1718
config.h
1819
config.h.in

config.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ if test "$PHP_V8" != "no"; then
161161
v8.cc \
162162
src/php_v8_a.cc \
163163
src/php_v8_enums.cc \
164-
src/php_v8_exception.cc \
164+
src/php_v8_exception_manager.cc \
165165
src/php_v8_ext_mem_interface.cc \
166166
src/php_v8_try_catch.cc \
167167
src/php_v8_message.cc \

package.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<file name="src/php_v8_enums.cc" role="src" />
7272
<file name="src/php_v8_enums.h" role="src" />
7373
<file name="src/php_v8_exception.cc" role="src" />
74-
<file name="src/php_v8_exception.h" role="src" />
74+
<file name="src/php_v8_exception_manager.h" role="src" />
7575
<file name="src/php_v8_exceptions.cc" role="src" />
7676
<file name="src/php_v8_exceptions.h" role="src" />
7777
<file name="src/php_v8_ext_mem_interface.cc" role="src" />

php_v8.h

+3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ ZEND_END_MODULE_GLOBALS(v8)
7676
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, NULL, allow_null)
7777
#endif
7878

79+
#define PHP_V8_ZEND_BEGIN_ARG_WITH_CONSTRUCTOR_INFO_EX(name, required_num_args) ZEND_BEGIN_ARG_INFO_EX(name, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, required_num_args)
80+
#define PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_VOID_INFO_EX(name, required_num_args) ZEND_BEGIN_ARG_INFO_EX(name, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, required_num_args)
81+
7982
#define PHP_V8_IS_UP_AND_RUNNING() (zend_is_executing() && !CG(unclean_shutdown))
8083

8184
#define PHP_V8_ME(classname, name, flags) PHP_ME(classname, name, arginfo_##name, flags)

src/php_v8_array.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static PHP_METHOD(Array, length) {
6060
}
6161

6262

63-
ZEND_BEGIN_ARG_INFO_EX(arginfo___construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
63+
PHP_V8_ZEND_BEGIN_ARG_WITH_CONSTRUCTOR_INFO_EX(arginfo___construct, 1)
6464
ZEND_ARG_OBJ_INFO(0, context, V8\\Context, 0)
6565
ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0)
6666
ZEND_END_ARG_INFO()

src/php_v8_boolean.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static PHP_METHOD(BooleanValue, value) {
5555
}
5656

5757

58-
ZEND_BEGIN_ARG_INFO_EX(arginfo___construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2)
58+
PHP_V8_ZEND_BEGIN_ARG_WITH_CONSTRUCTOR_INFO_EX(arginfo___construct, 2)
5959
ZEND_ARG_OBJ_INFO(0, isolate, V8\\Isolate, 0)
6060
ZEND_ARG_TYPE_INFO(0, value, _IS_BOOL, 0)
6161
ZEND_END_ARG_INFO()

src/php_v8_boolean_object.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static PHP_METHOD(BooleanObject, valueOf) {
5858
}
5959

6060

61-
ZEND_BEGIN_ARG_INFO_EX(arginfo___construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2)
61+
PHP_V8_ZEND_BEGIN_ARG_WITH_CONSTRUCTOR_INFO_EX(arginfo___construct, 2)
6262
ZEND_ARG_OBJ_INFO(0, context, V8\\Context, 0)
6363
ZEND_ARG_TYPE_INFO(0, value, _IS_BOOL, 0)
6464
ZEND_END_ARG_INFO()

src/php_v8_cached_data.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static PHP_METHOD(CachedData, isRejected)
106106
}
107107

108108

109-
ZEND_BEGIN_ARG_INFO_EX(arginfo___construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
109+
PHP_V8_ZEND_BEGIN_ARG_WITH_CONSTRUCTOR_INFO_EX(arginfo___construct, 1)
110110
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
111111
ZEND_END_ARG_INFO()
112112

src/php_v8_context.cc

+6-11
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ static PHP_METHOD(Context, setErrorMessageForCodeGenerationFromStrings)
262262
context->SetErrorMessageForCodeGenerationFromStrings(local_string);
263263
}
264264

265-
ZEND_BEGIN_ARG_INFO_EX(arginfo___construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
265+
PHP_V8_ZEND_BEGIN_ARG_WITH_CONSTRUCTOR_INFO_EX(arginfo___construct, 1)
266266
ZEND_ARG_OBJ_INFO(0, isolate, V8\\Isolate, 0)
267267
ZEND_ARG_OBJ_INFO(0, global_template, V8\\ObjectTemplate, 1)
268268
ZEND_ARG_OBJ_INFO(0, global_object, V8\\ObjectValue, 1)
@@ -275,32 +275,27 @@ ZEND_END_ARG_INFO()
275275
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_globalObject, ZEND_RETURN_VALUE, 0, V8\\ObjectValue, 0)
276276
ZEND_END_ARG_INFO()
277277

278-
// void method
279-
ZEND_BEGIN_ARG_INFO_EX(arginfo_detachGlobal, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
278+
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_VOID_INFO_EX(arginfo_detachGlobal, 0)
280279
ZEND_END_ARG_INFO()
281280

282-
// void method
283-
ZEND_BEGIN_ARG_INFO_EX(arginfo_setSecurityToken, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
281+
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_VOID_INFO_EX(arginfo_setSecurityToken, 1)
284282
ZEND_ARG_OBJ_INFO(0, token, V8\\Value, 0)
285283
ZEND_END_ARG_INFO()
286284

287-
// void method
288-
ZEND_BEGIN_ARG_INFO_EX(arginfo_useDefaultSecurityToken, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
285+
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_VOID_INFO_EX(arginfo_useDefaultSecurityToken, 0)
289286
ZEND_END_ARG_INFO()
290287

291288
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_getSecurityToken, ZEND_RETURN_VALUE, 0, V8\\Value, 0)
292289
ZEND_END_ARG_INFO()
293290

294-
// void method
295-
ZEND_BEGIN_ARG_INFO_EX(arginfo_allowCodeGenerationFromStrings, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
291+
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_VOID_INFO_EX(arginfo_allowCodeGenerationFromStrings, 1)
296292
ZEND_ARG_TYPE_INFO(0, allow, _IS_BOOL, 0)
297293
ZEND_END_ARG_INFO()
298294

299295
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_isCodeGenerationFromStringsAllowed, ZEND_RETURN_VALUE, 0, _IS_BOOL, 0)
300296
ZEND_END_ARG_INFO()
301297

302-
// void method
303-
ZEND_BEGIN_ARG_INFO_EX(arginfo_setErrorMessageForCodeGenerationFromStrings, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
298+
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_VOID_INFO_EX(arginfo_setErrorMessageForCodeGenerationFromStrings, 1)
304299
ZEND_ARG_OBJ_INFO(0, message, V8\\StringValue, 0)
305300
ZEND_END_ARG_INFO()
306301

src/php_v8_date.cc

+2-3
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,15 @@ static PHP_METHOD(Date, dateTimeConfigurationChangeNotification) {
7272
}
7373

7474

75-
ZEND_BEGIN_ARG_INFO_EX(arginfo___construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2)
75+
PHP_V8_ZEND_BEGIN_ARG_WITH_CONSTRUCTOR_INFO_EX(arginfo___construct, 2)
7676
ZEND_ARG_OBJ_INFO(0, context, V8\\Context, 0)
7777
ZEND_ARG_TYPE_INFO(0, time, IS_DOUBLE, 0)
7878
ZEND_END_ARG_INFO()
7979

8080
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_valueOf, ZEND_RETURN_VALUE, 0, IS_DOUBLE, 0)
8181
ZEND_END_ARG_INFO()
8282

83-
// void method
84-
ZEND_BEGIN_ARG_INFO_EX(arginfo_dateTimeConfigurationChangeNotification, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
83+
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_VOID_INFO_EX(arginfo_dateTimeConfigurationChangeNotification, 1)
8584
ZEND_ARG_OBJ_INFO(0, isolate, V8\\isolate, 0)
8685
ZEND_END_ARG_INFO()
8786

src/php_v8_enums.cc

+31-23
Original file line numberDiff line numberDiff line change
@@ -39,83 +39,91 @@ PHP_MINIT_FUNCTION (php_v8_enums) {
3939
#define this_ce php_v8_access_control_class_entry
4040
INIT_NS_CLASS_ENTRY(ce, PHP_V8_NS, "AccessControl", php_v8_enum_methods);
4141
this_ce = zend_register_internal_class(&ce);
42+
this_ce->ce_flags |= ZEND_ACC_FINAL;
4243

4344
zend_declare_class_constant_long(this_ce, ZEND_STRL("DEFAULT_ACCESS"), v8::AccessControl::DEFAULT);
44-
zend_declare_class_constant_long(this_ce, ZEND_STRL("ALL_CAN_READ"), v8::AccessControl::ALL_CAN_READ);
45-
zend_declare_class_constant_long(this_ce, ZEND_STRL("ALL_CAN_WRITE"), v8::AccessControl::ALL_CAN_WRITE);
45+
zend_declare_class_constant_long(this_ce, ZEND_STRL("ALL_CAN_READ"), v8::AccessControl::ALL_CAN_READ);
46+
zend_declare_class_constant_long(this_ce, ZEND_STRL("ALL_CAN_WRITE"), v8::AccessControl::ALL_CAN_WRITE);
4647
#undef this_ce
4748

4849
//v8::ConstructorBehavior
4950
#define this_ce php_v8_constructor_behavior_class_entry
5051
INIT_NS_CLASS_ENTRY(ce, PHP_V8_NS, "ConstructorBehavior", php_v8_enum_methods);
5152
this_ce = zend_register_internal_class(&ce);
53+
this_ce->ce_flags |= ZEND_ACC_FINAL;
5254

53-
zend_declare_class_constant_long(this_ce, ZEND_STRL("kThrow"), static_cast<long>(v8::ConstructorBehavior::kThrow));
54-
zend_declare_class_constant_long(this_ce, ZEND_STRL("kAllow"), static_cast<long>(v8::ConstructorBehavior::kAllow));
55+
zend_declare_class_constant_long(this_ce, ZEND_STRL("THROW"), static_cast<long>(v8::ConstructorBehavior::kThrow));
56+
zend_declare_class_constant_long(this_ce, ZEND_STRL("ALLOW"), static_cast<long>(v8::ConstructorBehavior::kAllow));
5557

5658
#undef this_ce
5759

5860
// v8::IntegrityLevel
5961
#define this_ce php_v8_integrity_level_class_entry
6062
INIT_NS_CLASS_ENTRY(ce, PHP_V8_NS, "IntegrityLevel", php_v8_enum_methods);
6163
this_ce = zend_register_internal_class(&ce);
64+
this_ce->ce_flags |= ZEND_ACC_FINAL;
6265

63-
zend_declare_class_constant_long(this_ce, ZEND_STRL("kFrozen"), static_cast<zend_long>(v8::IntegrityLevel::kFrozen));
64-
zend_declare_class_constant_long(this_ce, ZEND_STRL("kSealed"), static_cast<zend_long>(v8::IntegrityLevel::kSealed));
66+
zend_declare_class_constant_long(this_ce, ZEND_STRL("FROZEN"), static_cast<zend_long>(v8::IntegrityLevel::kFrozen));
67+
zend_declare_class_constant_long(this_ce, ZEND_STRL("SEALED"), static_cast<zend_long>(v8::IntegrityLevel::kSealed));
6568
#undef this_ce
6669

6770
// v8::PropertyAttribute
6871
#define this_ce php_v8_property_attribute_class_entry
6972
INIT_NS_CLASS_ENTRY(ce, PHP_V8_NS, "PropertyAttribute", php_v8_enum_methods);
7073
this_ce = zend_register_internal_class(&ce);
74+
this_ce->ce_flags |= ZEND_ACC_FINAL;
7175

72-
zend_declare_class_constant_long(this_ce, ZEND_STRL("None"), v8::PropertyAttribute::None);
73-
zend_declare_class_constant_long(this_ce, ZEND_STRL("ReadOnly"), v8::PropertyAttribute::ReadOnly);
74-
zend_declare_class_constant_long(this_ce, ZEND_STRL("DontEnum"), v8::PropertyAttribute::DontEnum);
75-
zend_declare_class_constant_long(this_ce, ZEND_STRL("DontDelete"), v8::PropertyAttribute::DontDelete);
76+
zend_declare_class_constant_long(this_ce, ZEND_STRL("NONE"), v8::PropertyAttribute::None);
77+
zend_declare_class_constant_long(this_ce, ZEND_STRL("READ_ONLY"), v8::PropertyAttribute::ReadOnly);
78+
zend_declare_class_constant_long(this_ce, ZEND_STRL("DONT_ENUM"), v8::PropertyAttribute::DontEnum);
79+
zend_declare_class_constant_long(this_ce, ZEND_STRL("DONT_DELETE"), v8::PropertyAttribute::DontDelete);
7680

7781
#undef this_ce
7882

7983
// v8::PropertyHandlerFlags
8084
#define this_ce php_v8_property_handler_flags_class_entry
8185
INIT_NS_CLASS_ENTRY(ce, PHP_V8_NS, "PropertyHandlerFlags", php_v8_enum_methods);
8286
this_ce = zend_register_internal_class(&ce);
87+
this_ce->ce_flags |= ZEND_ACC_FINAL;
8388

84-
zend_declare_class_constant_long(this_ce, ZEND_STRL("kNone"), static_cast<zend_long>(v8::PropertyHandlerFlags::kNone));
85-
zend_declare_class_constant_long(this_ce, ZEND_STRL("kAllCanRead"), static_cast<zend_long>(v8::PropertyHandlerFlags::kAllCanRead));
86-
zend_declare_class_constant_long(this_ce, ZEND_STRL("kNonMasking"), static_cast<zend_long>(v8::PropertyHandlerFlags::kNonMasking));
87-
zend_declare_class_constant_long(this_ce, ZEND_STRL("kOnlyInterceptStrings"), static_cast<zend_long>(v8::PropertyHandlerFlags::kOnlyInterceptStrings));
89+
zend_declare_class_constant_long(this_ce, ZEND_STRL("NONE"), static_cast<zend_long>(v8::PropertyHandlerFlags::kNone));
90+
zend_declare_class_constant_long(this_ce, ZEND_STRL("ALL_CAN_READ"), static_cast<zend_long>(v8::PropertyHandlerFlags::kAllCanRead));
91+
zend_declare_class_constant_long(this_ce, ZEND_STRL("NON_MASKING"), static_cast<zend_long>(v8::PropertyHandlerFlags::kNonMasking));
92+
zend_declare_class_constant_long(this_ce, ZEND_STRL("ONLY_INTERCEPT_STRINGS"), static_cast<zend_long>(v8::PropertyHandlerFlags::kOnlyInterceptStrings));
8893
#undef this_ce
8994

9095
// v8::PropertyFilter
9196
#define this_ce php_v8_property_filter_class_entry
9297
INIT_NS_CLASS_ENTRY(ce, PHP_V8_NS, "PropertyFilter", php_v8_enum_methods);
9398
this_ce = zend_register_internal_class(&ce);
99+
this_ce->ce_flags |= ZEND_ACC_FINAL;
94100

95-
zend_declare_class_constant_long(this_ce, ZEND_STRL("ALL_PROPERTIES"), v8::PropertyFilter::ALL_PROPERTIES);
96-
zend_declare_class_constant_long(this_ce, ZEND_STRL("ONLY_WRITABLE"), v8::PropertyFilter::ONLY_WRITABLE);
97-
zend_declare_class_constant_long(this_ce, ZEND_STRL("ONLY_ENUMERABLE"), v8::PropertyFilter::ONLY_ENUMERABLE);
101+
zend_declare_class_constant_long(this_ce, ZEND_STRL("ALL_PROPERTIES"), v8::PropertyFilter::ALL_PROPERTIES);
102+
zend_declare_class_constant_long(this_ce, ZEND_STRL("ONLY_WRITABLE"), v8::PropertyFilter::ONLY_WRITABLE);
103+
zend_declare_class_constant_long(this_ce, ZEND_STRL("ONLY_ENUMERABLE"), v8::PropertyFilter::ONLY_ENUMERABLE);
98104
zend_declare_class_constant_long(this_ce, ZEND_STRL("ONLY_CONFIGURABLE"), v8::PropertyFilter::ONLY_CONFIGURABLE);
99-
zend_declare_class_constant_long(this_ce, ZEND_STRL("SKIP_STRINGS"), v8::PropertyFilter::SKIP_STRINGS);
100-
zend_declare_class_constant_long(this_ce, ZEND_STRL("SKIP_SYMBOLS"), v8::PropertyFilter::SKIP_SYMBOLS);
105+
zend_declare_class_constant_long(this_ce, ZEND_STRL("SKIP_STRINGS"), v8::PropertyFilter::SKIP_STRINGS);
106+
zend_declare_class_constant_long(this_ce, ZEND_STRL("SKIP_SYMBOLS"), v8::PropertyFilter::SKIP_SYMBOLS);
101107
#undef this_ce
102108

103109
// v8::KeyCollectionMode
104110
#define this_ce php_v8_key_collection_mode_class_entry
105111
INIT_NS_CLASS_ENTRY(ce, PHP_V8_NS, "KeyCollectionMode", php_v8_enum_methods);
106112
this_ce = zend_register_internal_class(&ce);
113+
this_ce->ce_flags |= ZEND_ACC_FINAL;
107114

108-
zend_declare_class_constant_long(this_ce, ZEND_STRL("kOwnOnly"), static_cast<zend_long>(v8::KeyCollectionMode::kOwnOnly));
109-
zend_declare_class_constant_long(this_ce, ZEND_STRL("kIncludePrototypes"), static_cast<zend_long>(v8::KeyCollectionMode::kIncludePrototypes));
115+
zend_declare_class_constant_long(this_ce, ZEND_STRL("OWN_ONLY"), static_cast<zend_long>(v8::KeyCollectionMode::kOwnOnly));
116+
zend_declare_class_constant_long(this_ce, ZEND_STRL("INCLUDE_PROTOTYPES"), static_cast<zend_long>(v8::KeyCollectionMode::kIncludePrototypes));
110117
#undef this_ce
111118

112119
// v8::IndexFilter
113120
#define this_ce php_v8_index_filter_class_entry
114121
INIT_NS_CLASS_ENTRY(ce, PHP_V8_NS, "IndexFilter", php_v8_enum_methods);
115122
this_ce = zend_register_internal_class(&ce);
123+
this_ce->ce_flags |= ZEND_ACC_FINAL;
116124

117-
zend_declare_class_constant_long(this_ce, ZEND_STRL("kIncludeIndices"), static_cast<zend_long>(v8::IndexFilter::kIncludeIndices));
118-
zend_declare_class_constant_long(this_ce, ZEND_STRL("kSkipIndices"), static_cast<zend_long>(v8::IndexFilter::kSkipIndices));
125+
zend_declare_class_constant_long(this_ce, ZEND_STRL("INCLUDE_INDICES"), static_cast<zend_long>(v8::IndexFilter::kIncludeIndices));
126+
zend_declare_class_constant_long(this_ce, ZEND_STRL("SKIP_INDICES"), static_cast<zend_long>(v8::IndexFilter::kSkipIndices));
119127
#undef this_ce
120128

121129
return SUCCESS;

0 commit comments

Comments
 (0)