| |
| |
| // Copyright 2018 Google Inc. All Rights Reserved. |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| |
| // clang-format off |
| |
| // This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY! |
| // Auto-generated from template: bindings/v8c/templates/interface.cc.template |
| |
| #include "cobalt/bindings/testing/v8c_window.h" |
| |
| #include "base/debug/trace_event.h" |
| #include "cobalt/base/polymorphic_downcast.h" |
| #include "cobalt/script/global_environment.h" |
| #include "cobalt/script/script_value.h" |
| #include "cobalt/script/value_handle.h" |
| #include "cobalt/bindings/testing/anonymous_indexed_getter_interface.h" |
| #include "cobalt/bindings/testing/anonymous_named_getter_interface.h" |
| #include "cobalt/bindings/testing/anonymous_named_indexed_getter_interface.h" |
| #include "cobalt/bindings/testing/arbitrary_interface.h" |
| #include "cobalt/bindings/testing/base_interface.h" |
| #include "cobalt/bindings/testing/boolean_type_test_interface.h" |
| #include "cobalt/bindings/testing/callback_function_interface.h" |
| #include "cobalt/bindings/testing/callback_interface_interface.h" |
| #include "cobalt/bindings/testing/conditional_interface.h" |
| #include "cobalt/bindings/testing/constants_interface.h" |
| #include "cobalt/bindings/testing/constructor_interface.h" |
| #include "cobalt/bindings/testing/constructor_with_arguments_interface.h" |
| #include "cobalt/bindings/testing/derived_getter_setter_interface.h" |
| #include "cobalt/bindings/testing/derived_interface.h" |
| #include "cobalt/bindings/testing/dictionary_interface.h" |
| #include "cobalt/bindings/testing/disabled_interface.h" |
| #include "cobalt/bindings/testing/dom_string_test_interface.h" |
| #include "cobalt/bindings/testing/enumeration_interface.h" |
| #include "cobalt/bindings/testing/exception_object_interface.h" |
| #include "cobalt/bindings/testing/exceptions_interface.h" |
| #include "cobalt/bindings/testing/extended_idl_attributes_interface.h" |
| #include "cobalt/bindings/testing/garbage_collection_test_interface.h" |
| #include "cobalt/bindings/testing/global_interface_parent.h" |
| #include "cobalt/bindings/testing/implemented_interface.h" |
| #include "cobalt/bindings/testing/indexed_getter_interface.h" |
| #include "cobalt/bindings/testing/interface_with_any.h" |
| #include "cobalt/bindings/testing/interface_with_any_dictionary.h" |
| #include "cobalt/bindings/testing/interface_with_date.h" |
| #include "cobalt/bindings/testing/interface_with_unsupported_properties.h" |
| #include "cobalt/bindings/testing/named_constructor_interface.h" |
| #include "cobalt/bindings/testing/named_getter_interface.h" |
| #include "cobalt/bindings/testing/named_indexed_getter_interface.h" |
| #include "cobalt/bindings/testing/nested_put_forwards_interface.h" |
| #include "cobalt/bindings/testing/no_constructor_interface.h" |
| #include "cobalt/bindings/testing/no_interface_object_interface.h" |
| #include "cobalt/bindings/testing/nullable_types_test_interface.h" |
| #include "cobalt/bindings/testing/numeric_types_test_interface.h" |
| #include "cobalt/bindings/testing/object_type_bindings_interface.h" |
| #include "cobalt/bindings/testing/operations_test_interface.h" |
| #include "cobalt/bindings/testing/promise_interface.h" |
| #include "cobalt/bindings/testing/put_forwards_interface.h" |
| #include "cobalt/bindings/testing/sequence_user.h" |
| #include "cobalt/bindings/testing/single_operation_interface.h" |
| #include "cobalt/bindings/testing/static_properties_interface.h" |
| #include "cobalt/bindings/testing/stringifier_anonymous_operation_interface.h" |
| #include "cobalt/bindings/testing/stringifier_attribute_interface.h" |
| #include "cobalt/bindings/testing/stringifier_operation_interface.h" |
| #include "cobalt/bindings/testing/target_interface.h" |
| #include "cobalt/bindings/testing/union_types_interface.h" |
| #include "cobalt/bindings/testing/v8c_anonymous_indexed_getter_interface.h" |
| #include "cobalt/bindings/testing/v8c_anonymous_named_getter_interface.h" |
| #include "cobalt/bindings/testing/v8c_anonymous_named_indexed_getter_interface.h" |
| #include "cobalt/bindings/testing/v8c_arbitrary_interface.h" |
| #include "cobalt/bindings/testing/v8c_base_interface.h" |
| #include "cobalt/bindings/testing/v8c_boolean_type_test_interface.h" |
| #include "cobalt/bindings/testing/v8c_callback_function_interface.h" |
| #include "cobalt/bindings/testing/v8c_callback_interface_interface.h" |
| #include "cobalt/bindings/testing/v8c_conditional_interface.h" |
| #include "cobalt/bindings/testing/v8c_constants_interface.h" |
| #include "cobalt/bindings/testing/v8c_constructor_interface.h" |
| #include "cobalt/bindings/testing/v8c_constructor_with_arguments_interface.h" |
| #include "cobalt/bindings/testing/v8c_derived_getter_setter_interface.h" |
| #include "cobalt/bindings/testing/v8c_derived_interface.h" |
| #include "cobalt/bindings/testing/v8c_dictionary_interface.h" |
| #include "cobalt/bindings/testing/v8c_disabled_interface.h" |
| #include "cobalt/bindings/testing/v8c_dom_string_test_interface.h" |
| #include "cobalt/bindings/testing/v8c_enumeration_interface.h" |
| #include "cobalt/bindings/testing/v8c_exception_object_interface.h" |
| #include "cobalt/bindings/testing/v8c_exceptions_interface.h" |
| #include "cobalt/bindings/testing/v8c_extended_idl_attributes_interface.h" |
| #include "cobalt/bindings/testing/v8c_garbage_collection_test_interface.h" |
| #include "cobalt/bindings/testing/v8c_global_interface_parent.h" |
| #include "cobalt/bindings/testing/v8c_implemented_interface.h" |
| #include "cobalt/bindings/testing/v8c_indexed_getter_interface.h" |
| #include "cobalt/bindings/testing/v8c_interface_with_any.h" |
| #include "cobalt/bindings/testing/v8c_interface_with_any_dictionary.h" |
| #include "cobalt/bindings/testing/v8c_interface_with_date.h" |
| #include "cobalt/bindings/testing/v8c_interface_with_unsupported_properties.h" |
| #include "cobalt/bindings/testing/v8c_named_constructor_interface.h" |
| #include "cobalt/bindings/testing/v8c_named_getter_interface.h" |
| #include "cobalt/bindings/testing/v8c_named_indexed_getter_interface.h" |
| #include "cobalt/bindings/testing/v8c_nested_put_forwards_interface.h" |
| #include "cobalt/bindings/testing/v8c_no_constructor_interface.h" |
| #include "cobalt/bindings/testing/v8c_no_interface_object_interface.h" |
| #include "cobalt/bindings/testing/v8c_nullable_types_test_interface.h" |
| #include "cobalt/bindings/testing/v8c_numeric_types_test_interface.h" |
| #include "cobalt/bindings/testing/v8c_object_type_bindings_interface.h" |
| #include "cobalt/bindings/testing/v8c_operations_test_interface.h" |
| #include "cobalt/bindings/testing/v8c_promise_interface.h" |
| #include "cobalt/bindings/testing/v8c_put_forwards_interface.h" |
| #include "cobalt/bindings/testing/v8c_sequence_user.h" |
| #include "cobalt/bindings/testing/v8c_single_operation_interface.h" |
| #include "cobalt/bindings/testing/v8c_static_properties_interface.h" |
| #include "cobalt/bindings/testing/v8c_stringifier_anonymous_operation_interface.h" |
| #include "cobalt/bindings/testing/v8c_stringifier_attribute_interface.h" |
| #include "cobalt/bindings/testing/v8c_stringifier_operation_interface.h" |
| #include "cobalt/bindings/testing/v8c_target_interface.h" |
| #include "cobalt/bindings/testing/v8c_union_types_interface.h" |
| #include "cobalt/bindings/testing/v8c_window.h" |
| #include "cobalt/bindings/testing/window.h" |
| |
| #include "v8c_gen_type_conversion.h" |
| |
| #include "cobalt/script/callback_interface_traits.h" |
| #include "cobalt/script/v8c/callback_function_conversion.h" |
| #include "cobalt/script/v8c/conversion_helpers.h" |
| #include "cobalt/script/v8c/entry_scope.h" |
| #include "cobalt/script/v8c/native_promise.h" |
| #include "cobalt/script/v8c/type_traits.h" |
| #include "cobalt/script/v8c/v8c_callback_function.h" |
| #include "cobalt/script/v8c/v8c_callback_interface_holder.h" |
| #include "cobalt/script/v8c/v8c_exception_state.h" |
| #include "cobalt/script/v8c/v8c_global_environment.h" |
| #include "cobalt/script/v8c/v8c_value_handle.h" |
| #include "cobalt/script/v8c/wrapper_private.h" |
| #include "v8/include/v8.h" |
| |
| |
| namespace { |
| using cobalt::bindings::testing::Window; |
| using cobalt::bindings::testing::V8cWindow; |
| using cobalt::bindings::testing::AnonymousIndexedGetterInterface; |
| using cobalt::bindings::testing::AnonymousNamedGetterInterface; |
| using cobalt::bindings::testing::AnonymousNamedIndexedGetterInterface; |
| using cobalt::bindings::testing::ArbitraryInterface; |
| using cobalt::bindings::testing::BaseInterface; |
| using cobalt::bindings::testing::BooleanTypeTestInterface; |
| using cobalt::bindings::testing::CallbackFunctionInterface; |
| using cobalt::bindings::testing::CallbackInterfaceInterface; |
| #if defined(ENABLE_CONDITIONAL_INTERFACE) |
| using cobalt::bindings::testing::ConditionalInterface; |
| #endif // defined(ENABLE_CONDITIONAL_INTERFACE) |
| using cobalt::bindings::testing::ConstantsInterface; |
| using cobalt::bindings::testing::ConstructorInterface; |
| using cobalt::bindings::testing::ConstructorWithArgumentsInterface; |
| using cobalt::bindings::testing::DOMStringTestInterface; |
| using cobalt::bindings::testing::DerivedGetterSetterInterface; |
| using cobalt::bindings::testing::DerivedInterface; |
| using cobalt::bindings::testing::DictionaryInterface; |
| #if defined(NO_ENABLE_CONDITIONAL_INTERFACE) |
| using cobalt::bindings::testing::DisabledInterface; |
| #endif // defined(NO_ENABLE_CONDITIONAL_INTERFACE) |
| using cobalt::bindings::testing::EnumerationInterface; |
| using cobalt::bindings::testing::ExceptionObjectInterface; |
| using cobalt::bindings::testing::ExceptionsInterface; |
| using cobalt::bindings::testing::ExtendedIDLAttributesInterface; |
| using cobalt::bindings::testing::GarbageCollectionTestInterface; |
| using cobalt::bindings::testing::GlobalInterfaceParent; |
| using cobalt::bindings::testing::ImplementedInterface; |
| using cobalt::bindings::testing::IndexedGetterInterface; |
| using cobalt::bindings::testing::InterfaceWithAny; |
| using cobalt::bindings::testing::InterfaceWithAnyDictionary; |
| using cobalt::bindings::testing::InterfaceWithDate; |
| using cobalt::bindings::testing::InterfaceWithUnsupportedProperties; |
| using cobalt::bindings::testing::NamedConstructorInterface; |
| using cobalt::bindings::testing::NamedGetterInterface; |
| using cobalt::bindings::testing::NamedIndexedGetterInterface; |
| using cobalt::bindings::testing::NestedPutForwardsInterface; |
| using cobalt::bindings::testing::NoConstructorInterface; |
| using cobalt::bindings::testing::NoInterfaceObjectInterface; |
| using cobalt::bindings::testing::NullableTypesTestInterface; |
| using cobalt::bindings::testing::NumericTypesTestInterface; |
| using cobalt::bindings::testing::ObjectTypeBindingsInterface; |
| using cobalt::bindings::testing::OperationsTestInterface; |
| using cobalt::bindings::testing::PromiseInterface; |
| using cobalt::bindings::testing::PutForwardsInterface; |
| using cobalt::bindings::testing::SequenceUser; |
| using cobalt::bindings::testing::SingleOperationInterface; |
| using cobalt::bindings::testing::StaticPropertiesInterface; |
| using cobalt::bindings::testing::StringifierAnonymousOperationInterface; |
| using cobalt::bindings::testing::StringifierAttributeInterface; |
| using cobalt::bindings::testing::StringifierOperationInterface; |
| using cobalt::bindings::testing::TargetInterface; |
| using cobalt::bindings::testing::UnionTypesInterface; |
| using cobalt::bindings::testing::V8cAnonymousIndexedGetterInterface; |
| using cobalt::bindings::testing::V8cAnonymousNamedGetterInterface; |
| using cobalt::bindings::testing::V8cAnonymousNamedIndexedGetterInterface; |
| using cobalt::bindings::testing::V8cArbitraryInterface; |
| using cobalt::bindings::testing::V8cBaseInterface; |
| using cobalt::bindings::testing::V8cBooleanTypeTestInterface; |
| using cobalt::bindings::testing::V8cCallbackFunctionInterface; |
| using cobalt::bindings::testing::V8cCallbackInterfaceInterface; |
| #if defined(ENABLE_CONDITIONAL_INTERFACE) |
| using cobalt::bindings::testing::V8cConditionalInterface; |
| #endif // defined(ENABLE_CONDITIONAL_INTERFACE) |
| using cobalt::bindings::testing::V8cConstantsInterface; |
| using cobalt::bindings::testing::V8cConstructorInterface; |
| using cobalt::bindings::testing::V8cConstructorWithArgumentsInterface; |
| using cobalt::bindings::testing::V8cDOMStringTestInterface; |
| using cobalt::bindings::testing::V8cDerivedGetterSetterInterface; |
| using cobalt::bindings::testing::V8cDerivedInterface; |
| using cobalt::bindings::testing::V8cDictionaryInterface; |
| #if defined(NO_ENABLE_CONDITIONAL_INTERFACE) |
| using cobalt::bindings::testing::V8cDisabledInterface; |
| #endif // defined(NO_ENABLE_CONDITIONAL_INTERFACE) |
| using cobalt::bindings::testing::V8cEnumerationInterface; |
| using cobalt::bindings::testing::V8cExceptionObjectInterface; |
| using cobalt::bindings::testing::V8cExceptionsInterface; |
| using cobalt::bindings::testing::V8cExtendedIDLAttributesInterface; |
| using cobalt::bindings::testing::V8cGarbageCollectionTestInterface; |
| using cobalt::bindings::testing::V8cGlobalInterfaceParent; |
| using cobalt::bindings::testing::V8cImplementedInterface; |
| using cobalt::bindings::testing::V8cIndexedGetterInterface; |
| using cobalt::bindings::testing::V8cInterfaceWithAny; |
| using cobalt::bindings::testing::V8cInterfaceWithAnyDictionary; |
| using cobalt::bindings::testing::V8cInterfaceWithDate; |
| using cobalt::bindings::testing::V8cInterfaceWithUnsupportedProperties; |
| using cobalt::bindings::testing::V8cNamedConstructorInterface; |
| using cobalt::bindings::testing::V8cNamedGetterInterface; |
| using cobalt::bindings::testing::V8cNamedIndexedGetterInterface; |
| using cobalt::bindings::testing::V8cNestedPutForwardsInterface; |
| using cobalt::bindings::testing::V8cNoConstructorInterface; |
| using cobalt::bindings::testing::V8cNoInterfaceObjectInterface; |
| using cobalt::bindings::testing::V8cNullableTypesTestInterface; |
| using cobalt::bindings::testing::V8cNumericTypesTestInterface; |
| using cobalt::bindings::testing::V8cObjectTypeBindingsInterface; |
| using cobalt::bindings::testing::V8cOperationsTestInterface; |
| using cobalt::bindings::testing::V8cPromiseInterface; |
| using cobalt::bindings::testing::V8cPutForwardsInterface; |
| using cobalt::bindings::testing::V8cSequenceUser; |
| using cobalt::bindings::testing::V8cSingleOperationInterface; |
| using cobalt::bindings::testing::V8cStaticPropertiesInterface; |
| using cobalt::bindings::testing::V8cStringifierAnonymousOperationInterface; |
| using cobalt::bindings::testing::V8cStringifierAttributeInterface; |
| using cobalt::bindings::testing::V8cStringifierOperationInterface; |
| using cobalt::bindings::testing::V8cTargetInterface; |
| using cobalt::bindings::testing::V8cUnionTypesInterface; |
| using cobalt::bindings::testing::V8cWindow; |
| using cobalt::bindings::testing::Window; |
| using cobalt::script::CallbackInterfaceTraits; |
| using cobalt::script::GlobalEnvironment; |
| using cobalt::script::ScriptValue; |
| using cobalt::script::ValueHandle; |
| using cobalt::script::ValueHandle; |
| using cobalt::script::ValueHandleHolder; |
| using cobalt::script::Wrappable; |
| |
| using cobalt::script::v8c::EntryScope; |
| using cobalt::script::v8c::EscapableEntryScope; |
| using cobalt::script::v8c::FromJSValue; |
| using cobalt::script::v8c::InterfaceData; |
| using cobalt::script::v8c::kConversionFlagClamped; |
| using cobalt::script::v8c::kConversionFlagNullable; |
| using cobalt::script::v8c::kConversionFlagObjectOnly; |
| using cobalt::script::v8c::kConversionFlagRestricted; |
| using cobalt::script::v8c::kConversionFlagTreatNullAsEmptyString; |
| using cobalt::script::v8c::kConversionFlagTreatUndefinedAsEmptyString; |
| using cobalt::script::v8c::kNoConversionFlags; |
| using cobalt::script::v8c::ToJSValue; |
| using cobalt::script::v8c::TypeTraits; |
| using cobalt::script::v8c::V8cExceptionState; |
| using cobalt::script::v8c::V8cGlobalEnvironment; |
| using cobalt::script::v8c::WrapperFactory; |
| using cobalt::script::v8c::WrapperPrivate; |
| |
| v8::Local<v8::Object> DummyFunctor(v8::Isolate*, const scoped_refptr<Wrappable>&) { |
| NOTIMPLEMENTED(); |
| return {}; |
| } |
| |
| } // namespace |
| |
| namespace cobalt { |
| namespace bindings { |
| namespace testing { |
| |
| |
| namespace { |
| |
| |
| |
| void windowPropertyAttributeGetter( |
| v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value>& info) { |
| v8::Isolate* isolate = info.GetIsolate(); |
| v8::Local<v8::Object> object = info.This(); |
| |
| |
| V8cGlobalEnvironment* global_environment = V8cGlobalEnvironment::GetFromIsolate(isolate); |
| WrapperFactory* wrapper_factory = global_environment->wrapper_factory(); |
| if (!wrapper_factory->DoesObjectImplementInterface( |
| object, base::GetTypeId<Window>())) { |
| V8cExceptionState exception(isolate); |
| exception.SetSimpleException(script::kDoesNotImplementInterface); |
| return; |
| } |
| V8cExceptionState exception_state{isolate}; |
| v8::Local<v8::Value> result_value; |
| |
| WrapperPrivate* wrapper_private = |
| WrapperPrivate::GetFromWrapperObject(object); |
| if (!wrapper_private) { |
| NOTIMPLEMENTED(); |
| return; |
| } |
| Window* impl = |
| wrapper_private->wrappable<Window>().get(); |
| |
| if (!exception_state.is_exception_set()) { |
| ToJSValue(isolate, |
| impl->window_property(), |
| &result_value); |
| } |
| if (!exception_state.is_exception_set()) { |
| info.GetReturnValue().Set(result_value); |
| } |
| } |
| |
| void windowPropertyAttributeSetter( |
| v8::Local<v8::String> property, |
| v8::Local<v8::Value> v8_value, |
| const v8::PropertyCallbackInfo<void>& info) { |
| v8::Isolate* isolate = info.GetIsolate(); |
| v8::Local<v8::Object> object = info.This(); |
| |
| V8cGlobalEnvironment* global_environment = V8cGlobalEnvironment::GetFromIsolate(isolate); |
| WrapperFactory* wrapper_factory = global_environment->wrapper_factory(); |
| if (!wrapper_factory->DoesObjectImplementInterface( |
| object, base::GetTypeId<Window>())) { |
| V8cExceptionState exception(isolate); |
| exception.SetSimpleException(script::kDoesNotImplementInterface); |
| return; |
| } |
| V8cExceptionState exception_state{isolate}; |
| v8::Local<v8::Value> result_value; |
| |
| WrapperPrivate* wrapper_private = |
| WrapperPrivate::GetFromWrapperObject(object); |
| if (!wrapper_private) { |
| NOTIMPLEMENTED(); |
| return; |
| } |
| Window* impl = |
| wrapper_private->wrappable<Window>().get(); |
| TypeTraits<std::string >::ConversionType value; |
| FromJSValue(isolate, v8_value, kNoConversionFlags, &exception_state, |
| &value); |
| if (exception_state.is_exception_set()) { |
| return; |
| } |
| |
| impl->set_window_property(value); |
| result_value = v8::Undefined(isolate); |
| return; |
| } |
| |
| void windowAttributeGetter( |
| v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value>& info) { |
| v8::Isolate* isolate = info.GetIsolate(); |
| v8::Local<v8::Object> object = info.This(); |
| |
| |
| V8cGlobalEnvironment* global_environment = V8cGlobalEnvironment::GetFromIsolate(isolate); |
| WrapperFactory* wrapper_factory = global_environment->wrapper_factory(); |
| if (!wrapper_factory->DoesObjectImplementInterface( |
| object, base::GetTypeId<Window>())) { |
| V8cExceptionState exception(isolate); |
| exception.SetSimpleException(script::kDoesNotImplementInterface); |
| return; |
| } |
| V8cExceptionState exception_state{isolate}; |
| v8::Local<v8::Value> result_value; |
| |
| WrapperPrivate* wrapper_private = |
| WrapperPrivate::GetFromWrapperObject(object); |
| if (!wrapper_private) { |
| NOTIMPLEMENTED(); |
| return; |
| } |
| Window* impl = |
| wrapper_private->wrappable<Window>().get(); |
| |
| if (!exception_state.is_exception_set()) { |
| ToJSValue(isolate, |
| impl->window(), |
| &result_value); |
| } |
| if (!exception_state.is_exception_set()) { |
| info.GetReturnValue().Set(result_value); |
| } |
| } |
| |
| |
| void onEventAttributeGetter( |
| v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value>& info) { |
| v8::Isolate* isolate = info.GetIsolate(); |
| v8::Local<v8::Object> object = info.This(); |
| |
| |
| V8cGlobalEnvironment* global_environment = V8cGlobalEnvironment::GetFromIsolate(isolate); |
| WrapperFactory* wrapper_factory = global_environment->wrapper_factory(); |
| if (!wrapper_factory->DoesObjectImplementInterface( |
| object, base::GetTypeId<Window>())) { |
| V8cExceptionState exception(isolate); |
| exception.SetSimpleException(script::kDoesNotImplementInterface); |
| return; |
| } |
| V8cExceptionState exception_state{isolate}; |
| v8::Local<v8::Value> result_value; |
| |
| WrapperPrivate* wrapper_private = |
| WrapperPrivate::GetFromWrapperObject(object); |
| if (!wrapper_private) { |
| NOTIMPLEMENTED(); |
| return; |
| } |
| Window* impl = |
| wrapper_private->wrappable<Window>().get(); |
| |
| if (!exception_state.is_exception_set()) { |
| ToJSValue(isolate, |
| impl->on_event(), |
| &result_value); |
| } |
| if (!exception_state.is_exception_set()) { |
| info.GetReturnValue().Set(result_value); |
| } |
| } |
| |
| void onEventAttributeSetter( |
| v8::Local<v8::String> property, |
| v8::Local<v8::Value> v8_value, |
| const v8::PropertyCallbackInfo<void>& info) { |
| v8::Isolate* isolate = info.GetIsolate(); |
| v8::Local<v8::Object> object = info.This(); |
| |
| V8cGlobalEnvironment* global_environment = V8cGlobalEnvironment::GetFromIsolate(isolate); |
| WrapperFactory* wrapper_factory = global_environment->wrapper_factory(); |
| if (!wrapper_factory->DoesObjectImplementInterface( |
| object, base::GetTypeId<Window>())) { |
| V8cExceptionState exception(isolate); |
| exception.SetSimpleException(script::kDoesNotImplementInterface); |
| return; |
| } |
| V8cExceptionState exception_state{isolate}; |
| v8::Local<v8::Value> result_value; |
| |
| WrapperPrivate* wrapper_private = |
| WrapperPrivate::GetFromWrapperObject(object); |
| if (!wrapper_private) { |
| NOTIMPLEMENTED(); |
| return; |
| } |
| Window* impl = |
| wrapper_private->wrappable<Window>().get(); |
| TypeTraits<::cobalt::script::CallbackInterfaceTraits<SingleOperationInterface > >::ConversionType value; |
| FromJSValue(isolate, v8_value, (kConversionFlagNullable), &exception_state, |
| &value); |
| if (exception_state.is_exception_set()) { |
| return; |
| } |
| |
| impl->set_on_event(value); |
| result_value = v8::Undefined(isolate); |
| return; |
| } |
| |
| |
| |
| void getStackTraceMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| v8::Isolate* isolate = info.GetIsolate(); |
| v8::Local<v8::Object> object = info.This(); |
| V8cGlobalEnvironment* global_environment = V8cGlobalEnvironment::GetFromIsolate(isolate); |
| WrapperFactory* wrapper_factory = global_environment->wrapper_factory(); |
| if (!wrapper_factory->DoesObjectImplementInterface( |
| object, base::GetTypeId<Window>())) { |
| V8cExceptionState exception(isolate); |
| exception.SetSimpleException(script::kDoesNotImplementInterface); |
| return; |
| } |
| V8cExceptionState exception_state{isolate}; |
| v8::Local<v8::Value> result_value; |
| |
| WrapperPrivate* wrapper_private = |
| WrapperPrivate::GetFromWrapperObject(object); |
| if (!wrapper_private) { |
| NOTIMPLEMENTED(); |
| return; |
| } |
| Window* impl = |
| wrapper_private->wrappable<Window>().get(); |
| V8cGlobalEnvironment* callwith_global_environment = V8cGlobalEnvironment::GetFromIsolate(isolate); |
| |
| if (!exception_state.is_exception_set()) { |
| ToJSValue(isolate, |
| impl->GetStackTrace(callwith_global_environment->GetStackTrace()), |
| &result_value); |
| } |
| if (!exception_state.is_exception_set()) { |
| info.GetReturnValue().Set(result_value); |
| } |
| |
| } |
| |
| |
| |
| void setTimeoutMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| v8::Isolate* isolate = info.GetIsolate(); |
| v8::Local<v8::Object> object = info.This(); |
| V8cGlobalEnvironment* global_environment = V8cGlobalEnvironment::GetFromIsolate(isolate); |
| WrapperFactory* wrapper_factory = global_environment->wrapper_factory(); |
| if (!wrapper_factory->DoesObjectImplementInterface( |
| object, base::GetTypeId<Window>())) { |
| V8cExceptionState exception(isolate); |
| exception.SetSimpleException(script::kDoesNotImplementInterface); |
| return; |
| } |
| V8cExceptionState exception_state{isolate}; |
| v8::Local<v8::Value> result_value; |
| |
| WrapperPrivate* wrapper_private = |
| WrapperPrivate::GetFromWrapperObject(object); |
| if (!wrapper_private) { |
| NOTIMPLEMENTED(); |
| return; |
| } |
| Window* impl = |
| wrapper_private->wrappable<Window>().get(); |
| const size_t kMinArguments = 1; |
| if (info.Length() < kMinArguments) { |
| exception_state.SetSimpleException(script::kInvalidNumberOfArguments); |
| return; |
| } |
| // Non-optional arguments |
| TypeTraits<Window::TimerCallback >::ConversionType handler; |
| // Optional arguments |
| TypeTraits<int32_t >::ConversionType timeout; |
| DCHECK_LT(0, info.Length()); |
| v8::Local<v8::Value> non_optional_value0 = info[0]; |
| FromJSValue(isolate, |
| non_optional_value0, |
| kNoConversionFlags, |
| &exception_state, &handler); |
| if (exception_state.is_exception_set()) { |
| return; |
| } |
| size_t num_set_arguments = 1; |
| if (info.Length() > 1) { |
| v8::Local<v8::Value> optional_value0 = info[1]; |
| FromJSValue(isolate, |
| optional_value0, |
| kNoConversionFlags, |
| &exception_state, |
| &timeout); |
| if (exception_state.is_exception_set()) { |
| return; |
| } |
| ++num_set_arguments; |
| } |
| switch (num_set_arguments) { |
| case 1: |
| { |
| if (!exception_state.is_exception_set()) { |
| ToJSValue(isolate, |
| impl->SetTimeout(handler), |
| &result_value); |
| } |
| if (!exception_state.is_exception_set()) { |
| info.GetReturnValue().Set(result_value); |
| } |
| } |
| break; |
| case 2: |
| { |
| if (!exception_state.is_exception_set()) { |
| ToJSValue(isolate, |
| impl->SetTimeout(handler, timeout), |
| &result_value); |
| } |
| if (!exception_state.is_exception_set()) { |
| info.GetReturnValue().Set(result_value); |
| } |
| } |
| break; |
| default: |
| NOTREACHED(); |
| return; |
| } |
| } |
| |
| |
| |
| void windowOperationMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| v8::Isolate* isolate = info.GetIsolate(); |
| v8::Local<v8::Object> object = info.This(); |
| V8cGlobalEnvironment* global_environment = V8cGlobalEnvironment::GetFromIsolate(isolate); |
| WrapperFactory* wrapper_factory = global_environment->wrapper_factory(); |
| if (!wrapper_factory->DoesObjectImplementInterface( |
| object, base::GetTypeId<Window>())) { |
| V8cExceptionState exception(isolate); |
| exception.SetSimpleException(script::kDoesNotImplementInterface); |
| return; |
| } |
| V8cExceptionState exception_state{isolate}; |
| v8::Local<v8::Value> result_value; |
| |
| WrapperPrivate* wrapper_private = |
| WrapperPrivate::GetFromWrapperObject(object); |
| if (!wrapper_private) { |
| NOTIMPLEMENTED(); |
| return; |
| } |
| Window* impl = |
| wrapper_private->wrappable<Window>().get(); |
| |
| impl->WindowOperation(); |
| result_value = v8::Undefined(isolate); |
| |
| } |
| |
| |
| void InitializeTemplateAndInterfaceObject(v8::Isolate* isolate, InterfaceData* interface_data) { |
| v8::Local<v8::FunctionTemplate> function_template = v8::FunctionTemplate::New(isolate); |
| function_template->SetClassName( |
| v8::String::NewFromUtf8(isolate, "Window", |
| v8::NewStringType::kInternalized).ToLocalChecked()); |
| v8::Local<v8::ObjectTemplate> instance_template = function_template->InstanceTemplate(); |
| instance_template->SetInternalFieldCount(WrapperPrivate::kInternalFieldCount); |
| |
| v8::Local<v8::FunctionTemplate> parent_template = V8cGlobalInterfaceParent::CreateTemplate(isolate); |
| function_template->Inherit(parent_template); |
| |
| v8::Local<v8::ObjectTemplate> prototype_template = function_template->PrototypeTemplate(); |
| |
| |
| instance_template->SetAccessor( |
| v8::String::NewFromUtf8(isolate, "windowProperty", |
| v8::NewStringType::kInternalized) |
| .ToLocalChecked(), |
| windowPropertyAttributeGetter |
| ,windowPropertyAttributeSetter |
| ); |
| instance_template->SetAccessor( |
| v8::String::NewFromUtf8(isolate, "window", |
| v8::NewStringType::kInternalized) |
| .ToLocalChecked(), |
| windowAttributeGetter |
| ); |
| instance_template->SetAccessor( |
| v8::String::NewFromUtf8(isolate, "onEvent", |
| v8::NewStringType::kInternalized) |
| .ToLocalChecked(), |
| onEventAttributeGetter |
| ,onEventAttributeSetter |
| ); |
| |
| { |
| v8::Local<v8::FunctionTemplate> method_template = v8::FunctionTemplate::New(isolate, getStackTraceMethod); |
| method_template->RemovePrototype(); |
| prototype_template->Set( |
| v8::String::NewFromUtf8( |
| isolate, |
| "getStackTrace", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| method_template); |
| } |
| |
| { |
| v8::Local<v8::FunctionTemplate> method_template = v8::FunctionTemplate::New(isolate, setTimeoutMethod); |
| method_template->RemovePrototype(); |
| prototype_template->Set( |
| v8::String::NewFromUtf8( |
| isolate, |
| "setTimeout", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| method_template); |
| } |
| |
| { |
| v8::Local<v8::FunctionTemplate> method_template = v8::FunctionTemplate::New(isolate, windowOperationMethod); |
| method_template->RemovePrototype(); |
| prototype_template->Set( |
| v8::String::NewFromUtf8( |
| isolate, |
| "windowOperation", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| method_template); |
| } |
| |
| |
| interface_data->function_template.Set(isolate, function_template); |
| } |
| |
| inline InterfaceData* GetInterfaceData(V8cGlobalEnvironment* global_environment) { |
| const int kInterfaceUniqueId = 53; |
| // By convention, the |V8cGlobalEnvironment| that we are associated with |
| // will hold our |InterfaceData| at index |kInterfaceUniqueId|, as we asked |
| // for it to be there in the first place, and could not have conflicted with |
| // any other interface. |
| return global_environment->GetInterfaceData(kInterfaceUniqueId); |
| } |
| |
| } // namespace |
| |
| v8::Local<v8::Object> V8cWindow::CreateWrapper(v8::Isolate* isolate, const scoped_refptr<Wrappable>& wrappable) { |
| EscapableEntryScope entry_scope(isolate); |
| v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
| |
| V8cGlobalEnvironment* global_environment = V8cGlobalEnvironment::GetFromIsolate(isolate); |
| InterfaceData* interface_data = GetInterfaceData(global_environment); |
| if (interface_data->function_template.IsEmpty()) { |
| InitializeTemplateAndInterfaceObject(isolate, interface_data); |
| } |
| DCHECK(!interface_data->function_template.IsEmpty()); |
| |
| v8::Local<v8::FunctionTemplate> function_template = interface_data->function_template.Get(isolate); |
| DCHECK(function_template->InstanceTemplate()->InternalFieldCount() == WrapperPrivate::kInternalFieldCount); |
| v8::Local<v8::Object> object = function_template->InstanceTemplate()->NewInstance(context).ToLocalChecked(); |
| DCHECK(object->InternalFieldCount() == WrapperPrivate::kInternalFieldCount); |
| |
| // This |WrapperPrivate|'s lifetime will be managed by V8. |
| new WrapperPrivate(isolate, wrappable, object); |
| return entry_scope.Escape(object); |
| } |
| |
| v8::Local<v8::FunctionTemplate> V8cWindow::CreateTemplate(v8::Isolate* isolate) { |
| V8cGlobalEnvironment* global_environment = V8cGlobalEnvironment::GetFromIsolate(isolate); |
| InterfaceData* interface_data = GetInterfaceData(global_environment); |
| if (interface_data->function_template.IsEmpty()) { |
| InitializeTemplateAndInterfaceObject(isolate, interface_data); |
| } |
| |
| return interface_data->function_template.Get(isolate); |
| } |
| |
| |
| } // namespace testing |
| } // namespace bindings |
| } // namespace cobalt |
| |
| |
| namespace cobalt { |
| namespace script { |
| namespace v8c { |
| |
| template <typename GlobalInterface> |
| void V8cGlobalEnvironment::CreateGlobalObject( |
| const scoped_refptr<GlobalInterface>& global_interface, |
| EnvironmentSettings* environment_settings) { |
| // Intentionally not an |EntryScope|, since the context doesn't exist yet. |
| v8::Isolate::Scope isolate_scope(isolate_); |
| v8::HandleScope handle_scope(isolate_); |
| v8::Local<v8::ObjectTemplate> global_object_template = V8cWindow::CreateTemplate(isolate_)->InstanceTemplate(); |
| |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "AnonymousIndexedGetterInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cAnonymousIndexedGetterInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "AnonymousNamedGetterInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cAnonymousNamedGetterInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "AnonymousNamedIndexedGetterInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cAnonymousNamedIndexedGetterInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "ArbitraryInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cArbitraryInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "BaseInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cBaseInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "BooleanTypeTestInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cBooleanTypeTestInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "CallbackFunctionInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cCallbackFunctionInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "CallbackInterfaceInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cCallbackInterfaceInterface::CreateTemplate(isolate_)); |
| #if defined(ENABLE_CONDITIONAL_INTERFACE) |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "ConditionalInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cConditionalInterface::CreateTemplate(isolate_)); |
| #endif // defined(ENABLE_CONDITIONAL_INTERFACE) |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "ConstantsInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cConstantsInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "ConstructorInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cConstructorInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "ConstructorWithArgumentsInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cConstructorWithArgumentsInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "DOMStringTestInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cDOMStringTestInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "DerivedGetterSetterInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cDerivedGetterSetterInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "DerivedInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cDerivedInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "DictionaryInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cDictionaryInterface::CreateTemplate(isolate_)); |
| #if defined(NO_ENABLE_CONDITIONAL_INTERFACE) |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "DisabledInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cDisabledInterface::CreateTemplate(isolate_)); |
| #endif // defined(NO_ENABLE_CONDITIONAL_INTERFACE) |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "EnumerationInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cEnumerationInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "ExceptionObjectInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cExceptionObjectInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "ExceptionsInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cExceptionsInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "ExtendedIDLAttributesInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cExtendedIDLAttributesInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "GarbageCollectionTestInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cGarbageCollectionTestInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "GlobalInterfaceParent", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cGlobalInterfaceParent::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "ImplementedInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cImplementedInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "IndexedGetterInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cIndexedGetterInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "InterfaceWithAny", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cInterfaceWithAny::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "InterfaceWithAnyDictionary", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cInterfaceWithAnyDictionary::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "InterfaceWithDate", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cInterfaceWithDate::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "InterfaceWithUnsupportedProperties", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cInterfaceWithUnsupportedProperties::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "NamedConstructorInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cNamedConstructorInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "NamedGetterInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cNamedGetterInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "NamedIndexedGetterInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cNamedIndexedGetterInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "NestedPutForwardsInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cNestedPutForwardsInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "NoConstructorInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cNoConstructorInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "NoInterfaceObjectInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cNoInterfaceObjectInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "NullableTypesTestInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cNullableTypesTestInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "NumericTypesTestInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cNumericTypesTestInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "ObjectTypeBindingsInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cObjectTypeBindingsInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "OperationsTestInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cOperationsTestInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "PromiseInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cPromiseInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "PutForwardsInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cPutForwardsInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "SequenceUser", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cSequenceUser::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "StaticPropertiesInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cStaticPropertiesInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "StringifierAnonymousOperationInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cStringifierAnonymousOperationInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "StringifierAttributeInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cStringifierAttributeInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "StringifierOperationInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cStringifierOperationInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "TargetInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cTargetInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "UnionTypesInterface", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cUnionTypesInterface::CreateTemplate(isolate_)); |
| global_object_template->Set( |
| v8::String::NewFromUtf8( |
| isolate_, "Window", |
| v8::NewStringType::kInternalized).ToLocalChecked(), |
| V8cWindow::CreateTemplate(isolate_)); |
| |
| v8::Local<v8::Context> context = |
| v8::Context::New(isolate_, nullptr, global_object_template); |
| context_.Reset(isolate_, context); |
| v8::Context::Scope context_scope(context); |
| |
| DCHECK(!environment_settings_); |
| DCHECK(environment_settings); |
| environment_settings_ = environment_settings; |
| EvaluateAutomatics(); |
| |
| wrapper_factory_->RegisterWrappableType( |
| AnonymousIndexedGetterInterface::AnonymousIndexedGetterInterfaceWrappableType(), |
| base::Bind(V8cAnonymousIndexedGetterInterface::CreateWrapper), |
| base::Bind(V8cAnonymousIndexedGetterInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| AnonymousNamedGetterInterface::AnonymousNamedGetterInterfaceWrappableType(), |
| base::Bind(V8cAnonymousNamedGetterInterface::CreateWrapper), |
| base::Bind(V8cAnonymousNamedGetterInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| AnonymousNamedIndexedGetterInterface::AnonymousNamedIndexedGetterInterfaceWrappableType(), |
| base::Bind(V8cAnonymousNamedIndexedGetterInterface::CreateWrapper), |
| base::Bind(V8cAnonymousNamedIndexedGetterInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| ArbitraryInterface::ArbitraryInterfaceWrappableType(), |
| base::Bind(V8cArbitraryInterface::CreateWrapper), |
| base::Bind(V8cArbitraryInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| BaseInterface::BaseInterfaceWrappableType(), |
| base::Bind(V8cBaseInterface::CreateWrapper), |
| base::Bind(V8cBaseInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| BooleanTypeTestInterface::BooleanTypeTestInterfaceWrappableType(), |
| base::Bind(V8cBooleanTypeTestInterface::CreateWrapper), |
| base::Bind(V8cBooleanTypeTestInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| CallbackFunctionInterface::CallbackFunctionInterfaceWrappableType(), |
| base::Bind(V8cCallbackFunctionInterface::CreateWrapper), |
| base::Bind(V8cCallbackFunctionInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| CallbackInterfaceInterface::CallbackInterfaceInterfaceWrappableType(), |
| base::Bind(V8cCallbackInterfaceInterface::CreateWrapper), |
| base::Bind(V8cCallbackInterfaceInterface::CreateTemplate)); |
| #if defined(ENABLE_CONDITIONAL_INTERFACE) |
| wrapper_factory_->RegisterWrappableType( |
| ConditionalInterface::ConditionalInterfaceWrappableType(), |
| base::Bind(V8cConditionalInterface::CreateWrapper), |
| base::Bind(V8cConditionalInterface::CreateTemplate)); |
| #endif // defined(ENABLE_CONDITIONAL_INTERFACE) |
| wrapper_factory_->RegisterWrappableType( |
| ConstantsInterface::ConstantsInterfaceWrappableType(), |
| base::Bind(V8cConstantsInterface::CreateWrapper), |
| base::Bind(V8cConstantsInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| ConstructorInterface::ConstructorInterfaceWrappableType(), |
| base::Bind(V8cConstructorInterface::CreateWrapper), |
| base::Bind(V8cConstructorInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| ConstructorWithArgumentsInterface::ConstructorWithArgumentsInterfaceWrappableType(), |
| base::Bind(V8cConstructorWithArgumentsInterface::CreateWrapper), |
| base::Bind(V8cConstructorWithArgumentsInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| DOMStringTestInterface::DOMStringTestInterfaceWrappableType(), |
| base::Bind(V8cDOMStringTestInterface::CreateWrapper), |
| base::Bind(V8cDOMStringTestInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| DerivedGetterSetterInterface::DerivedGetterSetterInterfaceWrappableType(), |
| base::Bind(V8cDerivedGetterSetterInterface::CreateWrapper), |
| base::Bind(V8cDerivedGetterSetterInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| DerivedInterface::DerivedInterfaceWrappableType(), |
| base::Bind(V8cDerivedInterface::CreateWrapper), |
| base::Bind(V8cDerivedInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| DictionaryInterface::DictionaryInterfaceWrappableType(), |
| base::Bind(V8cDictionaryInterface::CreateWrapper), |
| base::Bind(V8cDictionaryInterface::CreateTemplate)); |
| #if defined(NO_ENABLE_CONDITIONAL_INTERFACE) |
| wrapper_factory_->RegisterWrappableType( |
| DisabledInterface::DisabledInterfaceWrappableType(), |
| base::Bind(V8cDisabledInterface::CreateWrapper), |
| base::Bind(V8cDisabledInterface::CreateTemplate)); |
| #endif // defined(NO_ENABLE_CONDITIONAL_INTERFACE) |
| wrapper_factory_->RegisterWrappableType( |
| EnumerationInterface::EnumerationInterfaceWrappableType(), |
| base::Bind(V8cEnumerationInterface::CreateWrapper), |
| base::Bind(V8cEnumerationInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| ExceptionObjectInterface::ExceptionObjectInterfaceWrappableType(), |
| base::Bind(V8cExceptionObjectInterface::CreateWrapper), |
| base::Bind(V8cExceptionObjectInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| ExceptionsInterface::ExceptionsInterfaceWrappableType(), |
| base::Bind(V8cExceptionsInterface::CreateWrapper), |
| base::Bind(V8cExceptionsInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| ExtendedIDLAttributesInterface::ExtendedIDLAttributesInterfaceWrappableType(), |
| base::Bind(V8cExtendedIDLAttributesInterface::CreateWrapper), |
| base::Bind(V8cExtendedIDLAttributesInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| GarbageCollectionTestInterface::GarbageCollectionTestInterfaceWrappableType(), |
| base::Bind(V8cGarbageCollectionTestInterface::CreateWrapper), |
| base::Bind(V8cGarbageCollectionTestInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| GlobalInterfaceParent::GlobalInterfaceParentWrappableType(), |
| base::Bind(V8cGlobalInterfaceParent::CreateWrapper), |
| base::Bind(V8cGlobalInterfaceParent::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| ImplementedInterface::ImplementedInterfaceWrappableType(), |
| base::Bind(V8cImplementedInterface::CreateWrapper), |
| base::Bind(V8cImplementedInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| IndexedGetterInterface::IndexedGetterInterfaceWrappableType(), |
| base::Bind(V8cIndexedGetterInterface::CreateWrapper), |
| base::Bind(V8cIndexedGetterInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| InterfaceWithAny::InterfaceWithAnyWrappableType(), |
| base::Bind(V8cInterfaceWithAny::CreateWrapper), |
| base::Bind(V8cInterfaceWithAny::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| InterfaceWithAnyDictionary::InterfaceWithAnyDictionaryWrappableType(), |
| base::Bind(V8cInterfaceWithAnyDictionary::CreateWrapper), |
| base::Bind(V8cInterfaceWithAnyDictionary::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| InterfaceWithDate::InterfaceWithDateWrappableType(), |
| base::Bind(V8cInterfaceWithDate::CreateWrapper), |
| base::Bind(V8cInterfaceWithDate::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| InterfaceWithUnsupportedProperties::InterfaceWithUnsupportedPropertiesWrappableType(), |
| base::Bind(V8cInterfaceWithUnsupportedProperties::CreateWrapper), |
| base::Bind(V8cInterfaceWithUnsupportedProperties::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| NamedConstructorInterface::NamedConstructorInterfaceWrappableType(), |
| base::Bind(V8cNamedConstructorInterface::CreateWrapper), |
| base::Bind(V8cNamedConstructorInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| NamedGetterInterface::NamedGetterInterfaceWrappableType(), |
| base::Bind(V8cNamedGetterInterface::CreateWrapper), |
| base::Bind(V8cNamedGetterInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| NamedIndexedGetterInterface::NamedIndexedGetterInterfaceWrappableType(), |
| base::Bind(V8cNamedIndexedGetterInterface::CreateWrapper), |
| base::Bind(V8cNamedIndexedGetterInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| NestedPutForwardsInterface::NestedPutForwardsInterfaceWrappableType(), |
| base::Bind(V8cNestedPutForwardsInterface::CreateWrapper), |
| base::Bind(V8cNestedPutForwardsInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| NoConstructorInterface::NoConstructorInterfaceWrappableType(), |
| base::Bind(V8cNoConstructorInterface::CreateWrapper), |
| base::Bind(V8cNoConstructorInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| NoInterfaceObjectInterface::NoInterfaceObjectInterfaceWrappableType(), |
| base::Bind(V8cNoInterfaceObjectInterface::CreateWrapper), |
| base::Bind(V8cNoInterfaceObjectInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| NullableTypesTestInterface::NullableTypesTestInterfaceWrappableType(), |
| base::Bind(V8cNullableTypesTestInterface::CreateWrapper), |
| base::Bind(V8cNullableTypesTestInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| NumericTypesTestInterface::NumericTypesTestInterfaceWrappableType(), |
| base::Bind(V8cNumericTypesTestInterface::CreateWrapper), |
| base::Bind(V8cNumericTypesTestInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| ObjectTypeBindingsInterface::ObjectTypeBindingsInterfaceWrappableType(), |
| base::Bind(V8cObjectTypeBindingsInterface::CreateWrapper), |
| base::Bind(V8cObjectTypeBindingsInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| OperationsTestInterface::OperationsTestInterfaceWrappableType(), |
| base::Bind(V8cOperationsTestInterface::CreateWrapper), |
| base::Bind(V8cOperationsTestInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| PromiseInterface::PromiseInterfaceWrappableType(), |
| base::Bind(V8cPromiseInterface::CreateWrapper), |
| base::Bind(V8cPromiseInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| PutForwardsInterface::PutForwardsInterfaceWrappableType(), |
| base::Bind(V8cPutForwardsInterface::CreateWrapper), |
| base::Bind(V8cPutForwardsInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| SequenceUser::SequenceUserWrappableType(), |
| base::Bind(V8cSequenceUser::CreateWrapper), |
| base::Bind(V8cSequenceUser::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| StaticPropertiesInterface::StaticPropertiesInterfaceWrappableType(), |
| base::Bind(V8cStaticPropertiesInterface::CreateWrapper), |
| base::Bind(V8cStaticPropertiesInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| StringifierAnonymousOperationInterface::StringifierAnonymousOperationInterfaceWrappableType(), |
| base::Bind(V8cStringifierAnonymousOperationInterface::CreateWrapper), |
| base::Bind(V8cStringifierAnonymousOperationInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| StringifierAttributeInterface::StringifierAttributeInterfaceWrappableType(), |
| base::Bind(V8cStringifierAttributeInterface::CreateWrapper), |
| base::Bind(V8cStringifierAttributeInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| StringifierOperationInterface::StringifierOperationInterfaceWrappableType(), |
| base::Bind(V8cStringifierOperationInterface::CreateWrapper), |
| base::Bind(V8cStringifierOperationInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| TargetInterface::TargetInterfaceWrappableType(), |
| base::Bind(V8cTargetInterface::CreateWrapper), |
| base::Bind(V8cTargetInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| UnionTypesInterface::UnionTypesInterfaceWrappableType(), |
| base::Bind(V8cUnionTypesInterface::CreateWrapper), |
| base::Bind(V8cUnionTypesInterface::CreateTemplate)); |
| wrapper_factory_->RegisterWrappableType( |
| Window::WindowWrappableType(), |
| base::Bind(DummyFunctor), |
| base::Bind(V8cWindow::CreateTemplate)); |
| |
| } |
| |
| } // namespace v8c |
| |
| template<> |
| void GlobalEnvironment::CreateGlobalObject<Window>( |
| const scoped_refptr<Window>& global_interface, |
| EnvironmentSettings* environment_settings) { |
| base::polymorphic_downcast<v8c::V8cGlobalEnvironment*>(this)->CreateGlobalObject(global_interface, environment_settings); |
| } |
| |
| } // namespace script |
| } // namespace cobalt |
| |
| |