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

Make API more PSR-compatible #44

Merged
merged 13 commits into from
Sep 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ acinclude.m4
aclocal.m4
autom4te.cache
build
confdefs.h
config.guess
config.h
config.h.in
Expand Down
2 changes: 1 addition & 1 deletion config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ if test "$PHP_V8" != "no"; then
v8.cc \
src/php_v8_a.cc \
src/php_v8_enums.cc \
src/php_v8_exception.cc \
src/php_v8_exception_manager.cc \
src/php_v8_ext_mem_interface.cc \
src/php_v8_try_catch.cc \
src/php_v8_message.cc \
Expand Down
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<file name="src/php_v8_enums.cc" role="src" />
<file name="src/php_v8_enums.h" role="src" />
<file name="src/php_v8_exception.cc" role="src" />
<file name="src/php_v8_exception.h" role="src" />
<file name="src/php_v8_exception_manager.h" role="src" />
<file name="src/php_v8_exceptions.cc" role="src" />
<file name="src/php_v8_exceptions.h" role="src" />
<file name="src/php_v8_ext_mem_interface.cc" role="src" />
Expand Down
3 changes: 3 additions & 0 deletions php_v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ ZEND_END_MODULE_GLOBALS(v8)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, NULL, allow_null)
#endif

#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)
#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)

#define PHP_V8_IS_UP_AND_RUNNING() (zend_is_executing() && !CG(unclean_shutdown))

#define PHP_V8_ME(classname, name, flags) PHP_ME(classname, name, arginfo_##name, flags)
Expand Down
2 changes: 1 addition & 1 deletion src/php_v8_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static PHP_METHOD(Array, length) {
}


ZEND_BEGIN_ARG_INFO_EX(arginfo___construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
PHP_V8_ZEND_BEGIN_ARG_WITH_CONSTRUCTOR_INFO_EX(arginfo___construct, 1)
ZEND_ARG_OBJ_INFO(0, context, V8\\Context, 0)
ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0)
ZEND_END_ARG_INFO()
Expand Down
2 changes: 1 addition & 1 deletion src/php_v8_boolean.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static PHP_METHOD(BooleanValue, value) {
}


ZEND_BEGIN_ARG_INFO_EX(arginfo___construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2)
PHP_V8_ZEND_BEGIN_ARG_WITH_CONSTRUCTOR_INFO_EX(arginfo___construct, 2)
ZEND_ARG_OBJ_INFO(0, isolate, V8\\Isolate, 0)
ZEND_ARG_TYPE_INFO(0, value, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
Expand Down
2 changes: 1 addition & 1 deletion src/php_v8_boolean_object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static PHP_METHOD(BooleanObject, valueOf) {
}


ZEND_BEGIN_ARG_INFO_EX(arginfo___construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2)
PHP_V8_ZEND_BEGIN_ARG_WITH_CONSTRUCTOR_INFO_EX(arginfo___construct, 2)
ZEND_ARG_OBJ_INFO(0, context, V8\\Context, 0)
ZEND_ARG_TYPE_INFO(0, value, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
Expand Down
2 changes: 1 addition & 1 deletion src/php_v8_cached_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static PHP_METHOD(CachedData, isRejected)
}


ZEND_BEGIN_ARG_INFO_EX(arginfo___construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
PHP_V8_ZEND_BEGIN_ARG_WITH_CONSTRUCTOR_INFO_EX(arginfo___construct, 1)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_END_ARG_INFO()

Expand Down
17 changes: 6 additions & 11 deletions src/php_v8_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ static PHP_METHOD(Context, setErrorMessageForCodeGenerationFromStrings)
context->SetErrorMessageForCodeGenerationFromStrings(local_string);
}

ZEND_BEGIN_ARG_INFO_EX(arginfo___construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
PHP_V8_ZEND_BEGIN_ARG_WITH_CONSTRUCTOR_INFO_EX(arginfo___construct, 1)
ZEND_ARG_OBJ_INFO(0, isolate, V8\\Isolate, 0)
ZEND_ARG_OBJ_INFO(0, global_template, V8\\ObjectTemplate, 1)
ZEND_ARG_OBJ_INFO(0, global_object, V8\\ObjectValue, 1)
Expand All @@ -275,32 +275,27 @@ ZEND_END_ARG_INFO()
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_globalObject, ZEND_RETURN_VALUE, 0, V8\\ObjectValue, 0)
ZEND_END_ARG_INFO()

// void method
ZEND_BEGIN_ARG_INFO_EX(arginfo_detachGlobal, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_VOID_INFO_EX(arginfo_detachGlobal, 0)
ZEND_END_ARG_INFO()

// void method
ZEND_BEGIN_ARG_INFO_EX(arginfo_setSecurityToken, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_VOID_INFO_EX(arginfo_setSecurityToken, 1)
ZEND_ARG_OBJ_INFO(0, token, V8\\Value, 0)
ZEND_END_ARG_INFO()

// void method
ZEND_BEGIN_ARG_INFO_EX(arginfo_useDefaultSecurityToken, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_VOID_INFO_EX(arginfo_useDefaultSecurityToken, 0)
ZEND_END_ARG_INFO()

PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_getSecurityToken, ZEND_RETURN_VALUE, 0, V8\\Value, 0)
ZEND_END_ARG_INFO()

// void method
ZEND_BEGIN_ARG_INFO_EX(arginfo_allowCodeGenerationFromStrings, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_VOID_INFO_EX(arginfo_allowCodeGenerationFromStrings, 1)
ZEND_ARG_TYPE_INFO(0, allow, _IS_BOOL, 0)
ZEND_END_ARG_INFO()

PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_isCodeGenerationFromStringsAllowed, ZEND_RETURN_VALUE, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()

// void method
ZEND_BEGIN_ARG_INFO_EX(arginfo_setErrorMessageForCodeGenerationFromStrings, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_VOID_INFO_EX(arginfo_setErrorMessageForCodeGenerationFromStrings, 1)
ZEND_ARG_OBJ_INFO(0, message, V8\\StringValue, 0)
ZEND_END_ARG_INFO()

Expand Down
5 changes: 2 additions & 3 deletions src/php_v8_date.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,15 @@ static PHP_METHOD(Date, dateTimeConfigurationChangeNotification) {
}


ZEND_BEGIN_ARG_INFO_EX(arginfo___construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2)
PHP_V8_ZEND_BEGIN_ARG_WITH_CONSTRUCTOR_INFO_EX(arginfo___construct, 2)
ZEND_ARG_OBJ_INFO(0, context, V8\\Context, 0)
ZEND_ARG_TYPE_INFO(0, time, IS_DOUBLE, 0)
ZEND_END_ARG_INFO()

PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_valueOf, ZEND_RETURN_VALUE, 0, IS_DOUBLE, 0)
ZEND_END_ARG_INFO()

// void method
ZEND_BEGIN_ARG_INFO_EX(arginfo_dateTimeConfigurationChangeNotification, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_VOID_INFO_EX(arginfo_dateTimeConfigurationChangeNotification, 1)
ZEND_ARG_OBJ_INFO(0, isolate, V8\\isolate, 0)
ZEND_END_ARG_INFO()

Expand Down
54 changes: 31 additions & 23 deletions src/php_v8_enums.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,83 +39,91 @@ PHP_MINIT_FUNCTION (php_v8_enums) {
#define this_ce php_v8_access_control_class_entry
INIT_NS_CLASS_ENTRY(ce, PHP_V8_NS, "AccessControl", php_v8_enum_methods);
this_ce = zend_register_internal_class(&ce);
this_ce->ce_flags |= ZEND_ACC_FINAL;

zend_declare_class_constant_long(this_ce, ZEND_STRL("DEFAULT_ACCESS"), v8::AccessControl::DEFAULT);
zend_declare_class_constant_long(this_ce, ZEND_STRL("ALL_CAN_READ"), v8::AccessControl::ALL_CAN_READ);
zend_declare_class_constant_long(this_ce, ZEND_STRL("ALL_CAN_WRITE"), v8::AccessControl::ALL_CAN_WRITE);
zend_declare_class_constant_long(this_ce, ZEND_STRL("ALL_CAN_READ"), v8::AccessControl::ALL_CAN_READ);
zend_declare_class_constant_long(this_ce, ZEND_STRL("ALL_CAN_WRITE"), v8::AccessControl::ALL_CAN_WRITE);
#undef this_ce

//v8::ConstructorBehavior
#define this_ce php_v8_constructor_behavior_class_entry
INIT_NS_CLASS_ENTRY(ce, PHP_V8_NS, "ConstructorBehavior", php_v8_enum_methods);
this_ce = zend_register_internal_class(&ce);
this_ce->ce_flags |= ZEND_ACC_FINAL;

zend_declare_class_constant_long(this_ce, ZEND_STRL("kThrow"), static_cast<long>(v8::ConstructorBehavior::kThrow));
zend_declare_class_constant_long(this_ce, ZEND_STRL("kAllow"), static_cast<long>(v8::ConstructorBehavior::kAllow));
zend_declare_class_constant_long(this_ce, ZEND_STRL("THROW"), static_cast<long>(v8::ConstructorBehavior::kThrow));
zend_declare_class_constant_long(this_ce, ZEND_STRL("ALLOW"), static_cast<long>(v8::ConstructorBehavior::kAllow));

#undef this_ce

// v8::IntegrityLevel
#define this_ce php_v8_integrity_level_class_entry
INIT_NS_CLASS_ENTRY(ce, PHP_V8_NS, "IntegrityLevel", php_v8_enum_methods);
this_ce = zend_register_internal_class(&ce);
this_ce->ce_flags |= ZEND_ACC_FINAL;

zend_declare_class_constant_long(this_ce, ZEND_STRL("kFrozen"), static_cast<zend_long>(v8::IntegrityLevel::kFrozen));
zend_declare_class_constant_long(this_ce, ZEND_STRL("kSealed"), static_cast<zend_long>(v8::IntegrityLevel::kSealed));
zend_declare_class_constant_long(this_ce, ZEND_STRL("FROZEN"), static_cast<zend_long>(v8::IntegrityLevel::kFrozen));
zend_declare_class_constant_long(this_ce, ZEND_STRL("SEALED"), static_cast<zend_long>(v8::IntegrityLevel::kSealed));
#undef this_ce

// v8::PropertyAttribute
#define this_ce php_v8_property_attribute_class_entry
INIT_NS_CLASS_ENTRY(ce, PHP_V8_NS, "PropertyAttribute", php_v8_enum_methods);
this_ce = zend_register_internal_class(&ce);
this_ce->ce_flags |= ZEND_ACC_FINAL;

zend_declare_class_constant_long(this_ce, ZEND_STRL("None"), v8::PropertyAttribute::None);
zend_declare_class_constant_long(this_ce, ZEND_STRL("ReadOnly"), v8::PropertyAttribute::ReadOnly);
zend_declare_class_constant_long(this_ce, ZEND_STRL("DontEnum"), v8::PropertyAttribute::DontEnum);
zend_declare_class_constant_long(this_ce, ZEND_STRL("DontDelete"), v8::PropertyAttribute::DontDelete);
zend_declare_class_constant_long(this_ce, ZEND_STRL("NONE"), v8::PropertyAttribute::None);
zend_declare_class_constant_long(this_ce, ZEND_STRL("READ_ONLY"), v8::PropertyAttribute::ReadOnly);
zend_declare_class_constant_long(this_ce, ZEND_STRL("DONT_ENUM"), v8::PropertyAttribute::DontEnum);
zend_declare_class_constant_long(this_ce, ZEND_STRL("DONT_DELETE"), v8::PropertyAttribute::DontDelete);

#undef this_ce

// v8::PropertyHandlerFlags
#define this_ce php_v8_property_handler_flags_class_entry
INIT_NS_CLASS_ENTRY(ce, PHP_V8_NS, "PropertyHandlerFlags", php_v8_enum_methods);
this_ce = zend_register_internal_class(&ce);
this_ce->ce_flags |= ZEND_ACC_FINAL;

zend_declare_class_constant_long(this_ce, ZEND_STRL("kNone"), static_cast<zend_long>(v8::PropertyHandlerFlags::kNone));
zend_declare_class_constant_long(this_ce, ZEND_STRL("kAllCanRead"), static_cast<zend_long>(v8::PropertyHandlerFlags::kAllCanRead));
zend_declare_class_constant_long(this_ce, ZEND_STRL("kNonMasking"), static_cast<zend_long>(v8::PropertyHandlerFlags::kNonMasking));
zend_declare_class_constant_long(this_ce, ZEND_STRL("kOnlyInterceptStrings"), static_cast<zend_long>(v8::PropertyHandlerFlags::kOnlyInterceptStrings));
zend_declare_class_constant_long(this_ce, ZEND_STRL("NONE"), static_cast<zend_long>(v8::PropertyHandlerFlags::kNone));
zend_declare_class_constant_long(this_ce, ZEND_STRL("ALL_CAN_READ"), static_cast<zend_long>(v8::PropertyHandlerFlags::kAllCanRead));
zend_declare_class_constant_long(this_ce, ZEND_STRL("NON_MASKING"), static_cast<zend_long>(v8::PropertyHandlerFlags::kNonMasking));
zend_declare_class_constant_long(this_ce, ZEND_STRL("ONLY_INTERCEPT_STRINGS"), static_cast<zend_long>(v8::PropertyHandlerFlags::kOnlyInterceptStrings));
#undef this_ce

// v8::PropertyFilter
#define this_ce php_v8_property_filter_class_entry
INIT_NS_CLASS_ENTRY(ce, PHP_V8_NS, "PropertyFilter", php_v8_enum_methods);
this_ce = zend_register_internal_class(&ce);
this_ce->ce_flags |= ZEND_ACC_FINAL;

zend_declare_class_constant_long(this_ce, ZEND_STRL("ALL_PROPERTIES"), v8::PropertyFilter::ALL_PROPERTIES);
zend_declare_class_constant_long(this_ce, ZEND_STRL("ONLY_WRITABLE"), v8::PropertyFilter::ONLY_WRITABLE);
zend_declare_class_constant_long(this_ce, ZEND_STRL("ONLY_ENUMERABLE"), v8::PropertyFilter::ONLY_ENUMERABLE);
zend_declare_class_constant_long(this_ce, ZEND_STRL("ALL_PROPERTIES"), v8::PropertyFilter::ALL_PROPERTIES);
zend_declare_class_constant_long(this_ce, ZEND_STRL("ONLY_WRITABLE"), v8::PropertyFilter::ONLY_WRITABLE);
zend_declare_class_constant_long(this_ce, ZEND_STRL("ONLY_ENUMERABLE"), v8::PropertyFilter::ONLY_ENUMERABLE);
zend_declare_class_constant_long(this_ce, ZEND_STRL("ONLY_CONFIGURABLE"), v8::PropertyFilter::ONLY_CONFIGURABLE);
zend_declare_class_constant_long(this_ce, ZEND_STRL("SKIP_STRINGS"), v8::PropertyFilter::SKIP_STRINGS);
zend_declare_class_constant_long(this_ce, ZEND_STRL("SKIP_SYMBOLS"), v8::PropertyFilter::SKIP_SYMBOLS);
zend_declare_class_constant_long(this_ce, ZEND_STRL("SKIP_STRINGS"), v8::PropertyFilter::SKIP_STRINGS);
zend_declare_class_constant_long(this_ce, ZEND_STRL("SKIP_SYMBOLS"), v8::PropertyFilter::SKIP_SYMBOLS);
#undef this_ce

// v8::KeyCollectionMode
#define this_ce php_v8_key_collection_mode_class_entry
INIT_NS_CLASS_ENTRY(ce, PHP_V8_NS, "KeyCollectionMode", php_v8_enum_methods);
this_ce = zend_register_internal_class(&ce);
this_ce->ce_flags |= ZEND_ACC_FINAL;

zend_declare_class_constant_long(this_ce, ZEND_STRL("kOwnOnly"), static_cast<zend_long>(v8::KeyCollectionMode::kOwnOnly));
zend_declare_class_constant_long(this_ce, ZEND_STRL("kIncludePrototypes"), static_cast<zend_long>(v8::KeyCollectionMode::kIncludePrototypes));
zend_declare_class_constant_long(this_ce, ZEND_STRL("OWN_ONLY"), static_cast<zend_long>(v8::KeyCollectionMode::kOwnOnly));
zend_declare_class_constant_long(this_ce, ZEND_STRL("INCLUDE_PROTOTYPES"), static_cast<zend_long>(v8::KeyCollectionMode::kIncludePrototypes));
#undef this_ce

// v8::IndexFilter
#define this_ce php_v8_index_filter_class_entry
INIT_NS_CLASS_ENTRY(ce, PHP_V8_NS, "IndexFilter", php_v8_enum_methods);
this_ce = zend_register_internal_class(&ce);
this_ce->ce_flags |= ZEND_ACC_FINAL;

zend_declare_class_constant_long(this_ce, ZEND_STRL("kIncludeIndices"), static_cast<zend_long>(v8::IndexFilter::kIncludeIndices));
zend_declare_class_constant_long(this_ce, ZEND_STRL("kSkipIndices"), static_cast<zend_long>(v8::IndexFilter::kSkipIndices));
zend_declare_class_constant_long(this_ce, ZEND_STRL("INCLUDE_INDICES"), static_cast<zend_long>(v8::IndexFilter::kIncludeIndices));
zend_declare_class_constant_long(this_ce, ZEND_STRL("SKIP_INDICES"), static_cast<zend_long>(v8::IndexFilter::kSkipIndices));
#undef this_ce

return SUCCESS;
Expand Down
Loading