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

Commit 463b618

Browse files
committed
Cleanup obsoleted data and add missed class stub
1 parent e4acbe6 commit 463b618

16 files changed

+51
-67
lines changed

src/php_v8_callbacks.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ void php_v8_callback_call_from_bucket_with_zargs(size_t index, v8::Local<v8::Val
268268
ZVAL_ZVAL(retval, fci.retval, 1, 1);
269269
}
270270

271-
// TODO: what about exceptions? - we let user handle any case of exceptions for themselves
271+
// We let user handle any case of exceptions for themselves
272272

273273
/* Clean up our mess */
274274
zend_fcall_info_args_clear(&fci, 1);

src/php_v8_exceptions.cc

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,9 @@ zend_class_entry* php_v8_time_limit_exception_class_entry;
2727
zend_class_entry* php_v8_memory_limit_exception_class_entry;
2828

2929
zend_class_entry* php_v8_value_exception_class_entry;
30-
zend_class_entry* php_v8_script_exception_class_entry;
3130

3231
void php_v8_create_try_catch_exception(zval *return_value, php_v8_isolate_t *php_v8_isolate, php_v8_context_t *php_v8_context, v8::TryCatch *try_catch);
3332

34-
void php_v8_try_catch_throw_exception(v8::TryCatch *try_catch, const char* message, zend_class_entry *ce) {
35-
if (try_catch->Exception()->IsNull() && try_catch->Message().IsEmpty() && !try_catch->CanContinue() && try_catch->HasTerminated()) {
36-
// TODO: output termination exception somehow
37-
return;
38-
}
39-
40-
v8::String::Utf8Value exception(try_catch->Exception());
41-
42-
PHP_V8_CONVERT_UTF8VALUE_TO_STRING_WITH_CHECK(exception, exception_message);
43-
44-
PHP_V8_THROW_EXCEPTION_CE(exception_message, ce);
45-
}
46-
4733
void php_v8_throw_try_catch_exception(php_v8_isolate_t *php_v8_isolate, php_v8_context_t *php_v8_context, v8::TryCatch *try_catch) {
4834
zval exception_zv;
4935

@@ -256,9 +242,5 @@ PHP_MINIT_FUNCTION(php_v8_exceptions) {
256242
INIT_NS_CLASS_ENTRY(ce, "V8\\Exceptions", "ValueException", php_v8_value_exception_methods);
257243
php_v8_value_exception_class_entry = zend_register_internal_class_ex(&ce, php_v8_generic_exception_class_entry);
258244

259-
// TODO: completely replace ScriptException with TryCatchException
260-
INIT_NS_CLASS_ENTRY(ce, "V8\\Exceptions", "ScriptException", php_v8_script_exception_methods);
261-
php_v8_script_exception_class_entry = zend_register_internal_class_ex(&ce, php_v8_generic_exception_class_entry);
262-
263245
return SUCCESS;
264246
}

src/php_v8_exceptions.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ extern zend_class_entry* php_v8_time_limit_exception_class_entry;
3535
extern zend_class_entry* php_v8_memory_limit_exception_class_entry;
3636

3737
extern zend_class_entry* php_v8_value_exception_class_entry;
38-
extern zend_class_entry* php_v8_script_exception_class_entry;
3938

40-
extern void php_v8_try_catch_throw_exception(v8::TryCatch *try_catch, const char* message, zend_class_entry *ce);
4139
extern void php_v8_throw_try_catch_exception(php_v8_isolate_t *php_v8_isolate, php_v8_context_t *php_v8_context, v8::TryCatch *try_catch);
4240
extern void php_v8_throw_try_catch_exception(php_v8_context_t *php_v8_context, v8::TryCatch *try_catch);
4341

src/php_v8_function.cc

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ bool php_v8_function_unpack_args(zval *arguments_zv, int arg_position, v8::Isola
7575

7676
php_v8_tmp_data = PHP_V8_VALUE_FETCH(pzval);
7777

78-
// NOTE: check for emptiness may be considered redundant while we may catch the fact that value was not properly
79-
// constructed by checking isolates mismatch, but this check serves for user-friendly purposes to throw
80-
// less confusing exception message
78+
// Check for emptiness may be considered redundant while we may catch the fact that value was not properly
79+
// constructed by checking isolates mismatch, but this check serves for user-friendly purposes to throw
80+
// less confusing exception message
8181
if (NULL == php_v8_tmp_data->persistent || php_v8_tmp_data->persistent->IsEmpty()) {
8282
spprintf(&exception_message, 0, PHP_V8_EMPTY_VALUE_MSG ": argument %d passed to %s::%s() at %d offset",
8383
arg_position, ZSTR_VAL(ce_name), get_active_function_name(), i);
@@ -164,9 +164,9 @@ bool php_v8_function_unpack_string_args(zval* arguments_zv, int arg_position, v8
164164

165165
php_v8_tmp_data = PHP_V8_VALUE_FETCH(pzval);
166166

167-
// NOTE: check for emptiness may be considered redundant while we may catch the fact that value was not properly
168-
// constructed by checking isolates mismatch, but this check serves for user-friendly purposes to throw
169-
// less confusing exception message
167+
// Check for emptiness may be considered redundant while we may catch the fact that value was not properly
168+
// constructed by checking isolates mismatch, but this check serves for user-friendly purposes to throw
169+
// less confusing exception message
170170
if (NULL == php_v8_tmp_data->persistent || php_v8_tmp_data->persistent->IsEmpty()) {
171171
spprintf(&exception_message, 0, PHP_V8_EMPTY_VALUE_MSG ": argument %d passed to %s::%s() at %d offset",
172172
arg_position, ZSTR_VAL(ce_name), get_active_function_name(), i);
@@ -253,9 +253,9 @@ bool php_v8_function_unpack_object_args(zval* arguments_zv, int arg_position, v8
253253

254254
php_v8_tmp_data = PHP_V8_VALUE_FETCH(pzval);
255255

256-
// NOTE: check for emptiness may be considered redundant while we may catch the fact that value was not properly
257-
// constructed by checking isolates mismatch, but this check serves for user-friendly purposes to throw
258-
// less confusing exception message
256+
// Check for emptiness may be considered redundant while we may catch the fact that value was not properly
257+
// constructed by checking isolates mismatch, but this check serves for user-friendly purposes to throw
258+
// less confusing exception message
259259
if (NULL == php_v8_tmp_data->persistent || php_v8_tmp_data->persistent->IsEmpty()) {
260260
spprintf(&exception_message, 0, PHP_V8_EMPTY_VALUE_MSG ": argument %d passed to %s::%s() at %d offset",
261261
arg_position, ZSTR_VAL(ce_name), get_active_function_name(), i);
@@ -333,14 +333,7 @@ static PHP_METHOD(V8Function, __construct) {
333333
callback = php_v8_callback_function;
334334
}
335335

336-
// TODO: check length range (PHP uses long, while V8 uses int
337-
338-
v8::MaybeLocal<v8::Function> maybe_local_function = v8::Function::New(
339-
context,
340-
callback,
341-
data,
342-
(int) length
343-
);
336+
v8::MaybeLocal<v8::Function> maybe_local_function = v8::Function::New(context, callback, data, static_cast<int>(length));
344337

345338
if (maybe_local_function.IsEmpty()) {
346339
PHP_V8_THROW_EXCEPTION("Failed to create Function value");

src/php_v8_function_template.cc

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ static void php_v8_function_template_free(zend_object *object) {
7777
* persistent handler and cleanup callbacks. Alternatively, we can detect in weak callback that object is live and
7878
* unmark it as weak and do all that cleanings in free handler. What about if object will be reused after being
7979
* unmarked as week? Note, that the only action on weak handler callback is Reset()ing persistent handler.
80-
*
81-
* */
80+
*/
8281
if (zend_is_executing() && !CG(unclean_shutdown) && php_v8_function_template->persistent_data && !php_v8_function_template->persistent_data->empty()) {
8382
php_v8_function_template_make_weak(php_v8_function_template);
8483
}
@@ -161,13 +160,7 @@ static PHP_METHOD(V8FunctionTemplate, __construct) {
161160
callback = php_v8_callback_function;
162161
}
163162

164-
v8::Local<v8::FunctionTemplate> local_template = v8::FunctionTemplate::New(
165-
isolate,
166-
callback,
167-
data,
168-
signature,
169-
static_cast<int>(length)
170-
);
163+
v8::Local<v8::FunctionTemplate> local_template = v8::FunctionTemplate::New(isolate, callback, data, signature, static_cast<int>(length));
171164

172165
PHP_V8_THROW_VALUE_EXCEPTION_WHEN_EMPTY(local_template, "Failed to create FunctionTemplate value");
173166

src/php_v8_indexed_property_handler_configuration.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ static PHP_METHOD (V8IndexedPropertyHandlerConfiguration, __construct) {
119119
php_v8_handlers->enumerator = php_v8_callback_indexed_property_enumerator;
120120
}
121121

122-
// TODO: php_v8_handlers->flags is long, while flag is zend_long, unify types or cast ???
123-
php_v8_handlers->flags = flags ? flags & PHP_V8_PROPERTY_HANDLER_FLAGS : flags;
122+
php_v8_handlers->flags = static_cast<long>(flags ? flags & PHP_V8_PROPERTY_HANDLER_FLAGS : flags);
124123
}
125124

126125

src/php_v8_indexed_property_handler_configuration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ inline php_v8_indexed_property_handler_configuration_t * php_v8_indexed_property
3838

3939
#define PHP_V8_INDEXED_PROPERTY_HANDLER_FETCH_WITH_CHECK(pzval, into) \
4040
PHP_V8_INDEXED_PROPERTY_HANDLER_FETCH_INTO(pzval, into); \
41-
PHP_V8_CHECK_EMPTY_INDEXED_PROPERTY_HANDLER(into);// TODO: fetch with check
41+
PHP_V8_CHECK_EMPTY_INDEXED_PROPERTY_HANDLER(into);
4242

4343
#define PHP_V8_INDEXED_PROPERTY_HANDLER_STORE_ISOLATE(to_zval, from_isolate_zv) zend_update_property(php_v8_indexed_property_handler_configuration_class_entry, (to_zval), ZEND_STRL("isolate"), (from_isolate_zv));
4444
#define PHP_V8_INDEXED_PROPERTY_HANDLER_READ_ISOLATE(from_zval) zend_read_property(php_v8_indexed_property_handler_configuration_class_entry, (from_zval), ZEND_STRL("isolate"), 0, &rv)

src/php_v8_isolate.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ static void php_v8_fatal_error_handler(const char *location, const char *message
164164
v8::Isolate *isolate = v8::Isolate::GetCurrent();
165165
assert(isolate != NULL); // as we set fatal error handler per-isolate, we should always have at least any of them as current one
166166

167-
// TODO: if there are no entered isolates = fatal error
168-
169167
php_v8_isolate_t *php_v8_isolate = PHP_V8_ISOLATE_FETCH_REFERENCE(isolate);
170168

171169
assert(NULL != php_v8_isolate);

src/php_v8_isolate.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ inline v8::Local<v8::Private> php_v8_isolate_get_key_local(php_v8_isolate_t *php
5757
PHP_V8_CHECK_EMPTY_ISOLATE_HANDLER(into);
5858

5959

60-
// TODO: cover cases when first and/or second are NULLs
6160
#define PHP_V8_ISOLATES_CHECK(first, second) if ((first)->isolate != (second)->isolate) { PHP_V8_THROW_EXCEPTION(PHP_V8_ISOLATES_MISMATCH_MSG); return; }
6261
#define PHP_V8_ISOLATES_CHECK_USING_ISOLATE(first, using_isolate) if ((first)->isolate != (using_isolate)) { PHP_V8_THROW_EXCEPTION(PHP_V8_ISOLATES_MISMATCH_MSG); return; }
6362

src/php_v8_object.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,10 +1189,6 @@ static PHP_METHOD(V8Object, CallAsConstructor) {
11891189
php_v8_get_or_create_value(return_value, local_res, php_v8_value->php_v8_isolate);
11901190
}
11911191

1192-
// Not supported yet
1193-
//static PHP_METHOD(V8Object, Cast) {
1194-
//}
1195-
11961192
/* Non-standard, implementations of AdjustableExternalMemoryInterface::AdjustExternalAllocatedMemory */
11971193
static PHP_METHOD(V8Object, AdjustExternalAllocatedMemory) {
11981194
php_v8_ext_mem_interface_value_AdjustExternalAllocatedMemory(INTERNAL_FUNCTION_PARAM_PASSTHRU);
@@ -1428,9 +1424,6 @@ static const zend_function_entry php_v8_object_methods[] = {
14281424
PHP_ME(V8Object, CallAsFunction, arginfo_v8_object_CallAsFunction, ZEND_ACC_PUBLIC)
14291425
PHP_ME(V8Object, CallAsConstructor, arginfo_v8_object_CallAsConstructor, ZEND_ACC_PUBLIC)
14301426

1431-
// NOTE: Not supported yet
1432-
//PHP_ME(V8Object, Cast, arginfo_v8_object_Cast, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
1433-
14341427
PHP_ME(V8Object, AdjustExternalAllocatedMemory, arginfo_v8_object_AdjustExternalAllocatedMemory, ZEND_ACC_PUBLIC)
14351428
PHP_ME(V8Object, GetExternalAllocatedMemory, arginfo_v8_object_GetExternalAllocatedMemory, ZEND_ACC_PUBLIC)
14361429

0 commit comments

Comments
 (0)