Import Cobalt 8.22891
diff --git a/src/base/third_party/nspr/prcpucfg_starboard.h b/src/base/third_party/nspr/prcpucfg_starboard.h
index 3aaa298..2113b0f 100644
--- a/src/base/third_party/nspr/prcpucfg_starboard.h
+++ b/src/base/third_party/nspr/prcpucfg_starboard.h
@@ -95,6 +95,7 @@
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
+
#elif SB_IS(ARCH_X86) && SB_IS(64_BIT)
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
@@ -135,6 +136,7 @@
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
+
#elif SB_IS(ARCH_X86) && SB_IS(32_BIT)
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
@@ -175,6 +177,7 @@
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
+
#elif SB_IS(ARCH_MIPS) && SB_IS(32_BIT)
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
@@ -215,6 +218,7 @@
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
+
#elif SB_IS(ARCH_ARM) && SB_IS(32_BIT)
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
@@ -255,6 +259,48 @@
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
+
+#elif SB_IS(ARCH_ARM) && SB_IS(64_BIT)
+#define PR_BYTES_PER_BYTE 1
+#define PR_BYTES_PER_SHORT 2
+#define PR_BYTES_PER_INT 4
+#define PR_BYTES_PER_INT64 8
+#define PR_BYTES_PER_LONG 8
+#define PR_BYTES_PER_FLOAT 4
+#define PR_BYTES_PER_DOUBLE 8
+#define PR_BYTES_PER_WORD 8
+#define PR_BYTES_PER_DWORD 8
+
+#define PR_BITS_PER_BYTE 8
+#define PR_BITS_PER_SHORT 16
+#define PR_BITS_PER_INT 32
+#define PR_BITS_PER_INT64 64
+#define PR_BITS_PER_LONG 64
+#define PR_BITS_PER_FLOAT 32
+#define PR_BITS_PER_DOUBLE 64
+#define PR_BITS_PER_WORD 64
+
+#define PR_BITS_PER_BYTE_LOG2 3
+#define PR_BITS_PER_SHORT_LOG2 4
+#define PR_BITS_PER_INT_LOG2 5
+#define PR_BITS_PER_INT64_LOG2 6
+#define PR_BITS_PER_LONG_LOG2 6
+#define PR_BITS_PER_FLOAT_LOG2 5
+#define PR_BITS_PER_DOUBLE_LOG2 6
+#define PR_BITS_PER_WORD_LOG2 6
+
+#define PR_ALIGN_OF_SHORT 2
+#define PR_ALIGN_OF_INT 4
+#define PR_ALIGN_OF_LONG 4
+#define PR_ALIGN_OF_INT64 4
+#define PR_ALIGN_OF_FLOAT 4
+#define PR_ALIGN_OF_DOUBLE 4
+#define PR_ALIGN_OF_POINTER 4
+#define PR_ALIGN_OF_WORD 4
+
+#define PR_BYTES_PER_WORD_LOG2 3
+#define PR_BYTES_PER_DWORD_LOG2 3
+
#else
# error "No configuration definition for Starboard ARCH + BITS."
#endif
diff --git a/src/cobalt/base/tokens.h b/src/cobalt/base/tokens.h
index 5c42945..3ae1cdc 100644
--- a/src/cobalt/base/tokens.h
+++ b/src/cobalt/base/tokens.h
@@ -31,9 +31,12 @@
MacroOpWithNameOnly(all) \
MacroOpWithNameOnly(animationend) \
MacroOpWithNameOnly(assertive) \
+ MacroOpWithNameOnly(attribute) \
MacroOpWithNameOnly(blur) \
MacroOpWithNameOnly(canplay) \
MacroOpWithNameOnly(canplaythrough) \
+ MacroOpWithNameOnly(characterData) \
+ MacroOpWithNameOnly(childList) \
MacroOpWithNameOnly(close) \
MacroOpWithNameOnly(durationchange) \
MacroOpWithNameOnly(emptied) \
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCAnonymousIndexedGetterInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCAnonymousIndexedGetterInterface.cc
deleted file mode 100644
index 7f862f5..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCAnonymousIndexedGetterInterface.cc
+++ /dev/null
@@ -1,860 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCAnonymousIndexedGetterInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::AnonymousIndexedGetterInterface;
-using cobalt::bindings::testing::JSCAnonymousIndexedGetterInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSlength(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-JSC::JSValue IndexedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, uint32_t index);
-void IndexedPropertySetter(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::JSValue value);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCAnonymousIndexedGetterInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCAnonymousIndexedGetterInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCAnonymousIndexedGetterInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCAnonymousIndexedGetterInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCAnonymousIndexedGetterInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCAnonymousIndexedGetterInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCAnonymousIndexedGetterInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCAnonymousIndexedGetterInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCAnonymousIndexedGetterInterface::InterfaceObject::s_info = {
- "AnonymousIndexedGetterInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCAnonymousIndexedGetterInterface::InterfaceObject)
-}; // JSCAnonymousIndexedGetterInterface::InterfaceObject::s_info
-
-void JSCAnonymousIndexedGetterInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCAnonymousIndexedGetterInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCAnonymousIndexedGetterInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "AnonymousIndexedGetterInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCAnonymousIndexedGetterInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCAnonymousIndexedGetterInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCAnonymousIndexedGetterInterface::Prototype::property_table_values[] = {
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCAnonymousIndexedGetterInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCAnonymousIndexedGetterInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCAnonymousIndexedGetterInterface::Prototype::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCAnonymousIndexedGetterInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCAnonymousIndexedGetterInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCAnonymousIndexedGetterInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCAnonymousIndexedGetterInterface::Prototype::s_info = {
- "AnonymousIndexedGetterInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCAnonymousIndexedGetterInterface::Prototype)
-}; // JSCAnonymousIndexedGetterInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCAnonymousIndexedGetterInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCAnonymousIndexedGetterInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCAnonymousIndexedGetterInterface::Prototype class
-
-const JSC::HashTableValue JSCAnonymousIndexedGetterInterface::property_table_values[] = {
- { "length",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJSlength),
- 0,
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCAnonymousIndexedGetterInterface::property_table_values
-
-// static
-const JSC::HashTable JSCAnonymousIndexedGetterInterface::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCAnonymousIndexedGetterInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCAnonymousIndexedGetterInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCAnonymousIndexedGetterInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCAnonymousIndexedGetterInterface::NonTrivialStaticFields>
- JSCAnonymousIndexedGetterInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCAnonymousIndexedGetterInterface::s_info = {
- "AnonymousIndexedGetterInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCAnonymousIndexedGetterInterface)
-}; // JSCAnonymousIndexedGetterInterface::s_info
-
-// static
-JSC::JSObject* JSCAnonymousIndexedGetterInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCAnonymousIndexedGetterInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCAnonymousIndexedGetterInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCAnonymousIndexedGetterInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == AnonymousIndexedGetterInterface::AnonymousIndexedGetterInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match AnonymousIndexedGetterInterface::AnonymousIndexedGetterInterfaceWrappableType()";
- return NULL;
- }
- AnonymousIndexedGetterInterface* impl_ptr =
- base::polymorphic_downcast<AnonymousIndexedGetterInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCAnonymousIndexedGetterInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCAnonymousIndexedGetterInterface>(global_data.heap))
- JSCAnonymousIndexedGetterInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCAnonymousIndexedGetterInterface::JSCAnonymousIndexedGetterInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<AnonymousIndexedGetterInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCAnonymousIndexedGetterInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCAnonymousIndexedGetterInterface::~JSCAnonymousIndexedGetterInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCAnonymousIndexedGetterInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCAnonymousIndexedGetterInterface* this_object = JSC::jsCast<JSCAnonymousIndexedGetterInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCAnonymousIndexedGetterInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// static
-bool JSCAnonymousIndexedGetterInterface::getOwnPropertySlotByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::PropertySlot& slot) {
- AnonymousIndexedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousIndexedGetterInterface>(exec_state, cell);
- if (!impl) {
- return false;
- }
- if (index < impl->length()) {
- slot.setCustomIndex(cell, index, IndexedPropertyGetter);
- return true;
- }
- if (s_has_named_getter) {
- JSCAnonymousIndexedGetterInterface* this_object = JSC::jsCast<JSCAnonymousIndexedGetterInterface*>(cell);
- JSC::PropertyName property_name = JSC::Identifier::from(exec_state, index);
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property) {
- if (QueryNamedProperty(this_object, exec_state, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- return true;
- }
- }
- }
- return Base::getOwnPropertySlotByIndex(cell, exec_state, index, slot);
-}
-
-void JSCAnonymousIndexedGetterInterface::getOwnPropertyNames(JSC::JSObject* object,
- JSC::ExecState* exec_state, JSC::PropertyNameArray& property_names,
- JSC::EnumerationMode mode) {
- AnonymousIndexedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousIndexedGetterInterface>(exec_state, object);
- if (impl) {
- for (uint32 i = 0; i < impl->length(); ++i) {
- property_names.add(JSC::Identifier::from(exec_state, i));
- }
- Base::getOwnPropertyNames(object, exec_state, property_names, mode);
- }
-}
-
-// Look up property slot and put the |value|.
-void JSCAnonymousIndexedGetterInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCAnonymousIndexedGetterInterface* this_object = JSC::jsCast<JSCAnonymousIndexedGetterInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCAnonymousIndexedGetterInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-// static
-void JSCAnonymousIndexedGetterInterface::putByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::JSValue value,
- bool should_throw) {
- AnonymousIndexedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousIndexedGetterInterface>(exec_state, cell);
- if (impl) {
- bool property_handled = false;
- if (index < impl->length()) {
- IndexedPropertySetter(cell, exec_state, index, value);
- property_handled = true;
- }
- if (s_has_named_setter) {
- if (!property_handled) {
- JSC::PropertyName property_name = JSC::Identifier::from(exec_state, index);
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property) {
- NamedPropertySetter(cell, exec_state, property_name, value);
- property_handled = true;
- }
- }
- }
- if (!property_handled) {
- Base::putByIndex(cell, exec_state, index, value, should_throw);
- }
- }
-}
-
-
-bool JSCAnonymousIndexedGetterInterface::deletePropertyByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state,
- uint32_t index) {
- TRACE_EVENT0("JSCAnonymousIndexedGetterInterface", "deletePropertyByIndex");
- AnonymousIndexedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousIndexedGetterInterface>(exec_state, cell);
- if (impl) {
- // https://heycam.github.io/webidl/#delete
- // Return true if index is not a supported property index.
- return index >= impl->length();
- }
- return false;
-}
-
-bool JSCAnonymousIndexedGetterInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCAnonymousIndexedGetterInterface* this_object = JSC::jsCast<JSCAnonymousIndexedGetterInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCAnonymousIndexedGetterInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSlength(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCAnonymousIndexedGetterInterface", "get length");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- AnonymousIndexedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousIndexedGetterInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->length());
- return result;
-}
-
-JSC::JSValue IndexedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, uint32_t index) {
- TRACE_EVENT0("JSCAnonymousIndexedGetterInterface", "IndexedPropertyGetter");
- AnonymousIndexedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousIndexedGetterInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->AnonymousIndexedGetter(index));
- return result;
-}
-
-void IndexedPropertySetter(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::JSValue jsc_value) {
- TRACE_EVENT0("JSCAnonymousIndexedGetterInterface", "IndexedPropertySetter");
- AnonymousIndexedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousIndexedGetterInterface>(exec_state, cell);
- if (!impl) {
- return;
- }
-
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- uint32_t value;
- FromJSValue(exec_state, jsc_value,
- kNoConversionFlags,
- &exception_state, &value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- impl->AnonymousIndexedSetter(index, value);
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCAnonymousIndexedGetterInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCAnonymousIndexedGetterInterface.h
deleted file mode 100644
index db0c679..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCAnonymousIndexedGetterInterface.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCAnonymousIndexedGetterInterface_h
-#define JSCAnonymousIndexedGetterInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/anonymous_indexed_getter_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCAnonymousIndexedGetterInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- static bool getOwnPropertySlotByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state,
- uint32_t index,
- JSC::PropertySlot& slot);
-
- static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*,
- JSC::PropertyNameArray&,
- JSC::EnumerationMode);
-
- static void putByIndex(JSC::JSCell* cell, JSC::ExecState* exec_state,
- uint32_t index, JSC::JSValue value, bool should_throw);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- static bool deletePropertyByIndex(JSC::JSCell*, JSC::ExecState*, uint32_t);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to AnonymousIndexedGetterInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCAnonymousIndexedGetterInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<AnonymousIndexedGetterInterface>& impl);
- ~JSCAnonymousIndexedGetterInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCAnonymousIndexedGetterInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCAnonymousNamedGetterInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCAnonymousNamedGetterInterface.cc
deleted file mode 100644
index 5944536..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCAnonymousNamedGetterInterface.cc
+++ /dev/null
@@ -1,844 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCAnonymousNamedGetterInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/jsc_property_enumerator.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::AnonymousNamedGetterInterface;
-using cobalt::bindings::testing::JSCAnonymousNamedGetterInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSCPropertyEnumerator;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = true;
-const bool s_has_named_setter = true;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCAnonymousNamedGetterInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCAnonymousNamedGetterInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCAnonymousNamedGetterInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCAnonymousNamedGetterInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCAnonymousNamedGetterInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCAnonymousNamedGetterInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCAnonymousNamedGetterInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCAnonymousNamedGetterInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCAnonymousNamedGetterInterface::InterfaceObject::s_info = {
- "AnonymousNamedGetterInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCAnonymousNamedGetterInterface::InterfaceObject)
-}; // JSCAnonymousNamedGetterInterface::InterfaceObject::s_info
-
-void JSCAnonymousNamedGetterInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCAnonymousNamedGetterInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCAnonymousNamedGetterInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "AnonymousNamedGetterInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCAnonymousNamedGetterInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCAnonymousNamedGetterInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCAnonymousNamedGetterInterface::Prototype::property_table_values[] = {
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCAnonymousNamedGetterInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCAnonymousNamedGetterInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCAnonymousNamedGetterInterface::Prototype::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCAnonymousNamedGetterInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCAnonymousNamedGetterInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCAnonymousNamedGetterInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCAnonymousNamedGetterInterface::Prototype::s_info = {
- "AnonymousNamedGetterInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCAnonymousNamedGetterInterface::Prototype)
-}; // JSCAnonymousNamedGetterInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCAnonymousNamedGetterInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCAnonymousNamedGetterInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCAnonymousNamedGetterInterface::Prototype class
-
-const JSC::HashTableValue JSCAnonymousNamedGetterInterface::property_table_values[] = {
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCAnonymousNamedGetterInterface::property_table_values
-
-// static
-const JSC::HashTable JSCAnonymousNamedGetterInterface::property_table_prototype = {
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCAnonymousNamedGetterInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCAnonymousNamedGetterInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCAnonymousNamedGetterInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCAnonymousNamedGetterInterface::NonTrivialStaticFields>
- JSCAnonymousNamedGetterInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCAnonymousNamedGetterInterface::s_info = {
- "AnonymousNamedGetterInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCAnonymousNamedGetterInterface)
-}; // JSCAnonymousNamedGetterInterface::s_info
-
-// static
-JSC::JSObject* JSCAnonymousNamedGetterInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCAnonymousNamedGetterInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCAnonymousNamedGetterInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCAnonymousNamedGetterInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == AnonymousNamedGetterInterface::AnonymousNamedGetterInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match AnonymousNamedGetterInterface::AnonymousNamedGetterInterfaceWrappableType()";
- return NULL;
- }
- AnonymousNamedGetterInterface* impl_ptr =
- base::polymorphic_downcast<AnonymousNamedGetterInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCAnonymousNamedGetterInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCAnonymousNamedGetterInterface>(global_data.heap))
- JSCAnonymousNamedGetterInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCAnonymousNamedGetterInterface::JSCAnonymousNamedGetterInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<AnonymousNamedGetterInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCAnonymousNamedGetterInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCAnonymousNamedGetterInterface::~JSCAnonymousNamedGetterInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCAnonymousNamedGetterInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCAnonymousNamedGetterInterface* this_object = JSC::jsCast<JSCAnonymousNamedGetterInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCAnonymousNamedGetterInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// static
-bool JSCAnonymousNamedGetterInterface::getOwnPropertySlotByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::PropertySlot& slot) {
- AnonymousNamedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousNamedGetterInterface>(exec_state, cell);
- if (!impl) {
- return false;
- }
- if (s_has_named_getter) {
- JSCAnonymousNamedGetterInterface* this_object = JSC::jsCast<JSCAnonymousNamedGetterInterface*>(cell);
- JSC::PropertyName property_name = JSC::Identifier::from(exec_state, index);
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property) {
- if (QueryNamedProperty(this_object, exec_state, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- return true;
- }
- }
- }
- return Base::getOwnPropertySlotByIndex(cell, exec_state, index, slot);
-}
-
-void JSCAnonymousNamedGetterInterface::getOwnPropertyNames(JSC::JSObject* object,
- JSC::ExecState* exec_state, JSC::PropertyNameArray& property_names,
- JSC::EnumerationMode mode) {
- AnonymousNamedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousNamedGetterInterface>(exec_state, object);
- if (impl) {
- JSCPropertyEnumerator enumerator(exec_state, &property_names);
- impl->EnumerateNamedProperties(&enumerator);
- Base::getOwnPropertyNames(object, exec_state, property_names, mode);
- }
-}
-
-// Look up property slot and put the |value|.
-void JSCAnonymousNamedGetterInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCAnonymousNamedGetterInterface* this_object = JSC::jsCast<JSCAnonymousNamedGetterInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCAnonymousNamedGetterInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-// static
-void JSCAnonymousNamedGetterInterface::putByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::JSValue value,
- bool should_throw) {
- AnonymousNamedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousNamedGetterInterface>(exec_state, cell);
- if (impl) {
- bool property_handled = false;
- if (s_has_named_setter) {
- if (!property_handled) {
- JSC::PropertyName property_name = JSC::Identifier::from(exec_state, index);
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property) {
- NamedPropertySetter(cell, exec_state, property_name, value);
- property_handled = true;
- }
- }
- }
- if (!property_handled) {
- Base::putByIndex(cell, exec_state, index, value, should_throw);
- }
- }
-}
-
-
-bool JSCAnonymousNamedGetterInterface::deleteProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- TRACE_EVENT1("JSCAnonymousNamedGetterInterface", "deleteProperty", "property",
- TRACE_STR_COPY(WTF::String(property_name.publicName()).utf8().data()));
- AnonymousNamedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousNamedGetterInterface>(exec_state, cell);
- if (impl) {
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property &&
- QueryNamedProperty(cell, exec_state, property_name)) {
- return NamedPropertyDeleter(cell, exec_state, property_name);
- }
- return Base::deleteProperty(cell, exec_state, property_name);
- }
- return false;
-}
-
-bool JSCAnonymousNamedGetterInterface::deletePropertyByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state,
- uint32_t index) {
- TRACE_EVENT0("JSCAnonymousNamedGetterInterface", "deletePropertyByIndex");
- AnonymousNamedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousNamedGetterInterface>(exec_state, cell);
- if (impl) {
- JSC::PropertyName property_name = JSC::Identifier::from(exec_state, index);
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property &&
- QueryNamedProperty(cell, exec_state, property_name)) {
- return NamedPropertyDeleter(cell, exec_state, property_name);
- }
- return Base::deletePropertyByIndex(cell, exec_state, index);
- }
- return false;
-}
-
-bool JSCAnonymousNamedGetterInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCAnonymousNamedGetterInterface* this_object = JSC::jsCast<JSCAnonymousNamedGetterInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCAnonymousNamedGetterInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCAnonymousNamedGetterInterface", "NamedPropertyGetter");
- AnonymousNamedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousNamedGetterInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->AnonymousNamedGetter(property_name_utf8));
- return result;
-}
-
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- AnonymousNamedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousNamedGetterInterface>(exec_state, cell);
- if (!impl) {
- return false;
- }
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- return impl->CanQueryNamedProperty(property_name_utf8);
-}
-
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- TRACE_EVENT0("JSCAnonymousNamedGetterInterface", "NamedPropertySetter");
- AnonymousNamedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousNamedGetterInterface>(exec_state, cell);
- if (!impl) {
- return;
- }
-
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
-
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- std::string value;
- FromJSValue(exec_state, jsc_value,
- kNoConversionFlags,
- &exception_state, &value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- impl->AnonymousNamedSetter(property_name_utf8, value);
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCAnonymousNamedGetterInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCAnonymousNamedGetterInterface.h
deleted file mode 100644
index 53742d8..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCAnonymousNamedGetterInterface.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCAnonymousNamedGetterInterface_h
-#define JSCAnonymousNamedGetterInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/anonymous_named_getter_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCAnonymousNamedGetterInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- static bool getOwnPropertySlotByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state,
- uint32_t index,
- JSC::PropertySlot& slot);
-
- static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*,
- JSC::PropertyNameArray&,
- JSC::EnumerationMode);
-
- static void putByIndex(JSC::JSCell* cell, JSC::ExecState* exec_state,
- uint32_t index, JSC::JSValue value, bool should_throw);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- static bool deleteProperty(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName);
-
- static bool deletePropertyByIndex(JSC::JSCell*, JSC::ExecState*, uint32_t);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to AnonymousNamedGetterInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCAnonymousNamedGetterInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<AnonymousNamedGetterInterface>& impl);
- ~JSCAnonymousNamedGetterInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCAnonymousNamedGetterInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCAnonymousNamedIndexedGetterInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCAnonymousNamedIndexedGetterInterface.cc
deleted file mode 100644
index 807e02d..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCAnonymousNamedIndexedGetterInterface.cc
+++ /dev/null
@@ -1,923 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCAnonymousNamedIndexedGetterInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/jsc_property_enumerator.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::AnonymousNamedIndexedGetterInterface;
-using cobalt::bindings::testing::JSCAnonymousNamedIndexedGetterInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSCPropertyEnumerator;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSlength(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-JSC::JSValue IndexedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, uint32_t index);
-void IndexedPropertySetter(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::JSValue value);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = true;
-const bool s_has_named_setter = true;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCAnonymousNamedIndexedGetterInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCAnonymousNamedIndexedGetterInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCAnonymousNamedIndexedGetterInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCAnonymousNamedIndexedGetterInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCAnonymousNamedIndexedGetterInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCAnonymousNamedIndexedGetterInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCAnonymousNamedIndexedGetterInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCAnonymousNamedIndexedGetterInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCAnonymousNamedIndexedGetterInterface::InterfaceObject::s_info = {
- "AnonymousNamedIndexedGetterInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCAnonymousNamedIndexedGetterInterface::InterfaceObject)
-}; // JSCAnonymousNamedIndexedGetterInterface::InterfaceObject::s_info
-
-void JSCAnonymousNamedIndexedGetterInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCAnonymousNamedIndexedGetterInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCAnonymousNamedIndexedGetterInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "AnonymousNamedIndexedGetterInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCAnonymousNamedIndexedGetterInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCAnonymousNamedIndexedGetterInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCAnonymousNamedIndexedGetterInterface::Prototype::property_table_values[] = {
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCAnonymousNamedIndexedGetterInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCAnonymousNamedIndexedGetterInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCAnonymousNamedIndexedGetterInterface::Prototype::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCAnonymousNamedIndexedGetterInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCAnonymousNamedIndexedGetterInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCAnonymousNamedIndexedGetterInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCAnonymousNamedIndexedGetterInterface::Prototype::s_info = {
- "AnonymousNamedIndexedGetterInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCAnonymousNamedIndexedGetterInterface::Prototype)
-}; // JSCAnonymousNamedIndexedGetterInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCAnonymousNamedIndexedGetterInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCAnonymousNamedIndexedGetterInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCAnonymousNamedIndexedGetterInterface::Prototype class
-
-const JSC::HashTableValue JSCAnonymousNamedIndexedGetterInterface::property_table_values[] = {
- { "length",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJSlength),
- 0,
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCAnonymousNamedIndexedGetterInterface::property_table_values
-
-// static
-const JSC::HashTable JSCAnonymousNamedIndexedGetterInterface::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCAnonymousNamedIndexedGetterInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCAnonymousNamedIndexedGetterInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCAnonymousNamedIndexedGetterInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCAnonymousNamedIndexedGetterInterface::NonTrivialStaticFields>
- JSCAnonymousNamedIndexedGetterInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCAnonymousNamedIndexedGetterInterface::s_info = {
- "AnonymousNamedIndexedGetterInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCAnonymousNamedIndexedGetterInterface)
-}; // JSCAnonymousNamedIndexedGetterInterface::s_info
-
-// static
-JSC::JSObject* JSCAnonymousNamedIndexedGetterInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCAnonymousNamedIndexedGetterInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCAnonymousNamedIndexedGetterInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCAnonymousNamedIndexedGetterInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == AnonymousNamedIndexedGetterInterface::AnonymousNamedIndexedGetterInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match AnonymousNamedIndexedGetterInterface::AnonymousNamedIndexedGetterInterfaceWrappableType()";
- return NULL;
- }
- AnonymousNamedIndexedGetterInterface* impl_ptr =
- base::polymorphic_downcast<AnonymousNamedIndexedGetterInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCAnonymousNamedIndexedGetterInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCAnonymousNamedIndexedGetterInterface>(global_data.heap))
- JSCAnonymousNamedIndexedGetterInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCAnonymousNamedIndexedGetterInterface::JSCAnonymousNamedIndexedGetterInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<AnonymousNamedIndexedGetterInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCAnonymousNamedIndexedGetterInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCAnonymousNamedIndexedGetterInterface::~JSCAnonymousNamedIndexedGetterInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCAnonymousNamedIndexedGetterInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCAnonymousNamedIndexedGetterInterface* this_object = JSC::jsCast<JSCAnonymousNamedIndexedGetterInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCAnonymousNamedIndexedGetterInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// static
-bool JSCAnonymousNamedIndexedGetterInterface::getOwnPropertySlotByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::PropertySlot& slot) {
- AnonymousNamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousNamedIndexedGetterInterface>(exec_state, cell);
- if (!impl) {
- return false;
- }
- if (index < impl->length()) {
- slot.setCustomIndex(cell, index, IndexedPropertyGetter);
- return true;
- }
- if (s_has_named_getter) {
- JSCAnonymousNamedIndexedGetterInterface* this_object = JSC::jsCast<JSCAnonymousNamedIndexedGetterInterface*>(cell);
- JSC::PropertyName property_name = JSC::Identifier::from(exec_state, index);
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property) {
- if (QueryNamedProperty(this_object, exec_state, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- return true;
- }
- }
- }
- return Base::getOwnPropertySlotByIndex(cell, exec_state, index, slot);
-}
-
-void JSCAnonymousNamedIndexedGetterInterface::getOwnPropertyNames(JSC::JSObject* object,
- JSC::ExecState* exec_state, JSC::PropertyNameArray& property_names,
- JSC::EnumerationMode mode) {
- AnonymousNamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousNamedIndexedGetterInterface>(exec_state, object);
- if (impl) {
- for (uint32 i = 0; i < impl->length(); ++i) {
- property_names.add(JSC::Identifier::from(exec_state, i));
- }
- JSCPropertyEnumerator enumerator(exec_state, &property_names);
- impl->EnumerateNamedProperties(&enumerator);
- Base::getOwnPropertyNames(object, exec_state, property_names, mode);
- }
-}
-
-// Look up property slot and put the |value|.
-void JSCAnonymousNamedIndexedGetterInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCAnonymousNamedIndexedGetterInterface* this_object = JSC::jsCast<JSCAnonymousNamedIndexedGetterInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCAnonymousNamedIndexedGetterInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-// static
-void JSCAnonymousNamedIndexedGetterInterface::putByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::JSValue value,
- bool should_throw) {
- AnonymousNamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousNamedIndexedGetterInterface>(exec_state, cell);
- if (impl) {
- bool property_handled = false;
- if (index < impl->length()) {
- IndexedPropertySetter(cell, exec_state, index, value);
- property_handled = true;
- }
- if (s_has_named_setter) {
- if (!property_handled) {
- JSC::PropertyName property_name = JSC::Identifier::from(exec_state, index);
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property) {
- NamedPropertySetter(cell, exec_state, property_name, value);
- property_handled = true;
- }
- }
- }
- if (!property_handled) {
- Base::putByIndex(cell, exec_state, index, value, should_throw);
- }
- }
-}
-
-
-bool JSCAnonymousNamedIndexedGetterInterface::deleteProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- TRACE_EVENT1("JSCAnonymousNamedIndexedGetterInterface", "deleteProperty", "property",
- TRACE_STR_COPY(WTF::String(property_name.publicName()).utf8().data()));
- AnonymousNamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousNamedIndexedGetterInterface>(exec_state, cell);
- if (impl) {
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property &&
- QueryNamedProperty(cell, exec_state, property_name)) {
- return NamedPropertyDeleter(cell, exec_state, property_name);
- }
- return Base::deleteProperty(cell, exec_state, property_name);
- }
- return false;
-}
-
-bool JSCAnonymousNamedIndexedGetterInterface::deletePropertyByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state,
- uint32_t index) {
- TRACE_EVENT0("JSCAnonymousNamedIndexedGetterInterface", "deletePropertyByIndex");
- AnonymousNamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousNamedIndexedGetterInterface>(exec_state, cell);
- if (impl) {
- // https://heycam.github.io/webidl/#delete
- // Return true if index is not a supported property index.
- return index >= impl->length();
- }
- return false;
-}
-
-bool JSCAnonymousNamedIndexedGetterInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCAnonymousNamedIndexedGetterInterface* this_object = JSC::jsCast<JSCAnonymousNamedIndexedGetterInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCAnonymousNamedIndexedGetterInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSlength(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCAnonymousNamedIndexedGetterInterface", "get length");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- AnonymousNamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousNamedIndexedGetterInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->length());
- return result;
-}
-
-JSC::JSValue IndexedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, uint32_t index) {
- TRACE_EVENT0("JSCAnonymousNamedIndexedGetterInterface", "IndexedPropertyGetter");
- AnonymousNamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousNamedIndexedGetterInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->AnonymousIndexedGetter(index));
- return result;
-}
-
-void IndexedPropertySetter(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::JSValue jsc_value) {
- TRACE_EVENT0("JSCAnonymousNamedIndexedGetterInterface", "IndexedPropertySetter");
- AnonymousNamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousNamedIndexedGetterInterface>(exec_state, cell);
- if (!impl) {
- return;
- }
-
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- uint32_t value;
- FromJSValue(exec_state, jsc_value,
- kNoConversionFlags,
- &exception_state, &value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- impl->AnonymousIndexedSetter(index, value);
-}
-
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCAnonymousNamedIndexedGetterInterface", "NamedPropertyGetter");
- AnonymousNamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousNamedIndexedGetterInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->AnonymousNamedGetter(property_name_utf8));
- return result;
-}
-
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- AnonymousNamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousNamedIndexedGetterInterface>(exec_state, cell);
- if (!impl) {
- return false;
- }
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- return impl->CanQueryNamedProperty(property_name_utf8);
-}
-
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- TRACE_EVENT0("JSCAnonymousNamedIndexedGetterInterface", "NamedPropertySetter");
- AnonymousNamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<AnonymousNamedIndexedGetterInterface>(exec_state, cell);
- if (!impl) {
- return;
- }
-
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
-
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- std::string value;
- FromJSValue(exec_state, jsc_value,
- kNoConversionFlags,
- &exception_state, &value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- impl->AnonymousNamedSetter(property_name_utf8, value);
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCAnonymousNamedIndexedGetterInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCAnonymousNamedIndexedGetterInterface.h
deleted file mode 100644
index 7aff3ee..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCAnonymousNamedIndexedGetterInterface.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCAnonymousNamedIndexedGetterInterface_h
-#define JSCAnonymousNamedIndexedGetterInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/anonymous_named_indexed_getter_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCAnonymousNamedIndexedGetterInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- static bool getOwnPropertySlotByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state,
- uint32_t index,
- JSC::PropertySlot& slot);
-
- static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*,
- JSC::PropertyNameArray&,
- JSC::EnumerationMode);
-
- static void putByIndex(JSC::JSCell* cell, JSC::ExecState* exec_state,
- uint32_t index, JSC::JSValue value, bool should_throw);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- static bool deleteProperty(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName);
-
- static bool deletePropertyByIndex(JSC::JSCell*, JSC::ExecState*, uint32_t);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to AnonymousNamedIndexedGetterInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCAnonymousNamedIndexedGetterInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<AnonymousNamedIndexedGetterInterface>& impl);
- ~JSCAnonymousNamedIndexedGetterInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCAnonymousNamedIndexedGetterInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCArbitraryInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCArbitraryInterface.cc
deleted file mode 100644
index 6ad9df6..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCArbitraryInterface.cc
+++ /dev/null
@@ -1,792 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCArbitraryInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::ArbitraryInterface;
-using cobalt::bindings::testing::JSCArbitraryInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSarbitraryProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSarbitraryProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::EncodedJSValue constructorJSArbitraryInterface(JSC::ExecState*);
-JSC::EncodedJSValue functionJSarbitraryFunction(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCArbitraryInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCArbitraryInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCArbitraryInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCArbitraryInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCArbitraryInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCArbitraryInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCArbitraryInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCArbitraryInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCArbitraryInterface::InterfaceObject::s_info = {
- "ArbitraryInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCArbitraryInterface::InterfaceObject)
-}; // JSCArbitraryInterface::InterfaceObject::s_info
-
-void JSCArbitraryInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCArbitraryInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCArbitraryInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, &constructorJSArbitraryInterface);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "ArbitraryInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCArbitraryInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCArbitraryInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCArbitraryInterface::Prototype::property_table_values[] = {
- { "arbitraryFunction",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSarbitraryFunction),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCArbitraryInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCArbitraryInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCArbitraryInterface::Prototype::property_table_prototype = {
- 9, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCArbitraryInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCArbitraryInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCArbitraryInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCArbitraryInterface::Prototype::s_info = {
- "ArbitraryInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCArbitraryInterface::Prototype)
-}; // JSCArbitraryInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCArbitraryInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCArbitraryInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCArbitraryInterface::Prototype class
-
-const JSC::HashTableValue JSCArbitraryInterface::property_table_values[] = {
- { "arbitraryProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSarbitraryProperty),
- reinterpret_cast<intptr_t>(setJSarbitraryProperty),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCArbitraryInterface::property_table_values
-
-// static
-const JSC::HashTable JSCArbitraryInterface::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCArbitraryInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCArbitraryInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCArbitraryInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCArbitraryInterface::NonTrivialStaticFields>
- JSCArbitraryInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCArbitraryInterface::s_info = {
- "ArbitraryInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCArbitraryInterface)
-}; // JSCArbitraryInterface::s_info
-
-// static
-JSC::JSObject* JSCArbitraryInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCArbitraryInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCArbitraryInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCArbitraryInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == ArbitraryInterface::ArbitraryInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match ArbitraryInterface::ArbitraryInterfaceWrappableType()";
- return NULL;
- }
- ArbitraryInterface* impl_ptr =
- base::polymorphic_downcast<ArbitraryInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCArbitraryInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCArbitraryInterface>(global_data.heap))
- JSCArbitraryInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCArbitraryInterface::JSCArbitraryInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<ArbitraryInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCArbitraryInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCArbitraryInterface::~JSCArbitraryInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCArbitraryInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCArbitraryInterface* this_object = JSC::jsCast<JSCArbitraryInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCArbitraryInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCArbitraryInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCArbitraryInterface* this_object = JSC::jsCast<JSCArbitraryInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCArbitraryInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCArbitraryInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCArbitraryInterface* this_object = JSC::jsCast<JSCArbitraryInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCArbitraryInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSarbitraryProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCArbitraryInterface", "get arbitraryProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ArbitraryInterface* impl =
- GetWrappableOrSetException<ArbitraryInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->arbitrary_property());
- return result;
-}
-
-void setJSarbitraryProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCArbitraryInterface", "set arbitraryProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- ArbitraryInterface* impl =
- GetWrappableOrSetException<ArbitraryInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<std::string >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_arbitrary_property(cobalt_value);
- }
-}
-
-JSC::EncodedJSValue constructorJSArbitraryInterface(JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- scoped_refptr<ArbitraryInterface> new_object =
- new ArbitraryInterface();
- return JSC::JSValue::encode(ToJSValue(global_object, new_object));
-
-}
-
-JSC::EncodedJSValue functionJSarbitraryFunction(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCArbitraryInterface", "call arbitraryFunction");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- ArbitraryInterface* impl =
- GetWrappableOrSetException<ArbitraryInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- impl->ArbitraryFunction();
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCArbitraryInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCArbitraryInterface.h
deleted file mode 100644
index 0ea203b..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCArbitraryInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCArbitraryInterface_h
-#define JSCArbitraryInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/arbitrary_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCArbitraryInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to ArbitraryInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCArbitraryInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<ArbitraryInterface>& impl);
- ~JSCArbitraryInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCArbitraryInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCBaseInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCBaseInterface.cc
deleted file mode 100644
index 0af6ea5..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCBaseInterface.cc
+++ /dev/null
@@ -1,761 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCBaseInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::BaseInterface;
-using cobalt::bindings::testing::JSCBaseInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSbaseAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-JSC::EncodedJSValue constructorJSBaseInterface(JSC::ExecState*);
-JSC::EncodedJSValue functionJSbaseOperation(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCBaseInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCBaseInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCBaseInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCBaseInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCBaseInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCBaseInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCBaseInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCBaseInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCBaseInterface::InterfaceObject::s_info = {
- "BaseInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCBaseInterface::InterfaceObject)
-}; // JSCBaseInterface::InterfaceObject::s_info
-
-void JSCBaseInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCBaseInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCBaseInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, &constructorJSBaseInterface);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "BaseInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCBaseInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCBaseInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCBaseInterface::Prototype::property_table_values[] = {
- { "baseOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSbaseOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCBaseInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCBaseInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCBaseInterface::Prototype::property_table_prototype = {
- 9, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCBaseInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCBaseInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCBaseInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCBaseInterface::Prototype::s_info = {
- "BaseInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCBaseInterface::Prototype)
-}; // JSCBaseInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCBaseInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCBaseInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCBaseInterface::Prototype class
-
-const JSC::HashTableValue JSCBaseInterface::property_table_values[] = {
- { "baseAttribute",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJSbaseAttribute),
- 0,
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCBaseInterface::property_table_values
-
-// static
-const JSC::HashTable JSCBaseInterface::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCBaseInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCBaseInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCBaseInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCBaseInterface::NonTrivialStaticFields>
- JSCBaseInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCBaseInterface::s_info = {
- "BaseInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCBaseInterface)
-}; // JSCBaseInterface::s_info
-
-// static
-JSC::JSObject* JSCBaseInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCBaseInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCBaseInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCBaseInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == BaseInterface::BaseInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match BaseInterface::BaseInterfaceWrappableType()";
- return NULL;
- }
- BaseInterface* impl_ptr =
- base::polymorphic_downcast<BaseInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCBaseInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCBaseInterface>(global_data.heap))
- JSCBaseInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCBaseInterface::JSCBaseInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<BaseInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCBaseInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCBaseInterface::~JSCBaseInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCBaseInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCBaseInterface* this_object = JSC::jsCast<JSCBaseInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCBaseInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCBaseInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCBaseInterface* this_object = JSC::jsCast<JSCBaseInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCBaseInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCBaseInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCBaseInterface* this_object = JSC::jsCast<JSCBaseInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCBaseInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSbaseAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCBaseInterface", "get baseAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- BaseInterface* impl =
- GetWrappableOrSetException<BaseInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->base_attribute());
- return result;
-}
-
-JSC::EncodedJSValue constructorJSBaseInterface(JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- scoped_refptr<BaseInterface> new_object =
- new BaseInterface();
- return JSC::JSValue::encode(ToJSValue(global_object, new_object));
-
-}
-
-JSC::EncodedJSValue functionJSbaseOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCBaseInterface", "call baseOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- BaseInterface* impl =
- GetWrappableOrSetException<BaseInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- impl->BaseOperation();
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCBaseInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCBaseInterface.h
deleted file mode 100644
index dfdf90a..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCBaseInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCBaseInterface_h
-#define JSCBaseInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/base_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCBaseInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to BaseInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCBaseInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<BaseInterface>& impl);
- ~JSCBaseInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCBaseInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCBooleanTypeTestInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCBooleanTypeTestInterface.cc
deleted file mode 100644
index 23b1192..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCBooleanTypeTestInterface.cc
+++ /dev/null
@@ -1,830 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCBooleanTypeTestInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::BooleanTypeTestInterface;
-using cobalt::bindings::testing::JSCBooleanTypeTestInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSbooleanProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSbooleanProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::EncodedJSValue functionJSbooleanArgumentOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSbooleanReturnOperation(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCBooleanTypeTestInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCBooleanTypeTestInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCBooleanTypeTestInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCBooleanTypeTestInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCBooleanTypeTestInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCBooleanTypeTestInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCBooleanTypeTestInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCBooleanTypeTestInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCBooleanTypeTestInterface::InterfaceObject::s_info = {
- "BooleanTypeTestInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCBooleanTypeTestInterface::InterfaceObject)
-}; // JSCBooleanTypeTestInterface::InterfaceObject::s_info
-
-void JSCBooleanTypeTestInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCBooleanTypeTestInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCBooleanTypeTestInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "BooleanTypeTestInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCBooleanTypeTestInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCBooleanTypeTestInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCBooleanTypeTestInterface::Prototype::property_table_values[] = {
- { "booleanArgumentOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSbooleanArgumentOperation),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "booleanReturnOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSbooleanReturnOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCBooleanTypeTestInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCBooleanTypeTestInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCBooleanTypeTestInterface::Prototype::property_table_prototype = {
- 10, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCBooleanTypeTestInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCBooleanTypeTestInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCBooleanTypeTestInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCBooleanTypeTestInterface::Prototype::s_info = {
- "BooleanTypeTestInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCBooleanTypeTestInterface::Prototype)
-}; // JSCBooleanTypeTestInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCBooleanTypeTestInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCBooleanTypeTestInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCBooleanTypeTestInterface::Prototype class
-
-const JSC::HashTableValue JSCBooleanTypeTestInterface::property_table_values[] = {
- { "booleanProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSbooleanProperty),
- reinterpret_cast<intptr_t>(setJSbooleanProperty),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCBooleanTypeTestInterface::property_table_values
-
-// static
-const JSC::HashTable JSCBooleanTypeTestInterface::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCBooleanTypeTestInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCBooleanTypeTestInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCBooleanTypeTestInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCBooleanTypeTestInterface::NonTrivialStaticFields>
- JSCBooleanTypeTestInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCBooleanTypeTestInterface::s_info = {
- "BooleanTypeTestInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCBooleanTypeTestInterface)
-}; // JSCBooleanTypeTestInterface::s_info
-
-// static
-JSC::JSObject* JSCBooleanTypeTestInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCBooleanTypeTestInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCBooleanTypeTestInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCBooleanTypeTestInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == BooleanTypeTestInterface::BooleanTypeTestInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match BooleanTypeTestInterface::BooleanTypeTestInterfaceWrappableType()";
- return NULL;
- }
- BooleanTypeTestInterface* impl_ptr =
- base::polymorphic_downcast<BooleanTypeTestInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCBooleanTypeTestInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCBooleanTypeTestInterface>(global_data.heap))
- JSCBooleanTypeTestInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCBooleanTypeTestInterface::JSCBooleanTypeTestInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<BooleanTypeTestInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCBooleanTypeTestInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCBooleanTypeTestInterface::~JSCBooleanTypeTestInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCBooleanTypeTestInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCBooleanTypeTestInterface* this_object = JSC::jsCast<JSCBooleanTypeTestInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCBooleanTypeTestInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCBooleanTypeTestInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCBooleanTypeTestInterface* this_object = JSC::jsCast<JSCBooleanTypeTestInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCBooleanTypeTestInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCBooleanTypeTestInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCBooleanTypeTestInterface* this_object = JSC::jsCast<JSCBooleanTypeTestInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCBooleanTypeTestInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSbooleanProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCBooleanTypeTestInterface", "get booleanProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- BooleanTypeTestInterface* impl =
- GetWrappableOrSetException<BooleanTypeTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->boolean_property());
- return result;
-}
-
-void setJSbooleanProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCBooleanTypeTestInterface", "set booleanProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- BooleanTypeTestInterface* impl =
- GetWrappableOrSetException<BooleanTypeTestInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<bool >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_boolean_property(cobalt_value);
- }
-}
-
-JSC::EncodedJSValue functionJSbooleanArgumentOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCBooleanTypeTestInterface", "call booleanArgumentOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- BooleanTypeTestInterface* impl =
- GetWrappableOrSetException<BooleanTypeTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<bool >::ConversionType arg1;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg1);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->BooleanArgumentOperation(arg1);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSbooleanReturnOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCBooleanTypeTestInterface", "call booleanReturnOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- BooleanTypeTestInterface* impl =
- GetWrappableOrSetException<BooleanTypeTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<bool >::ReturnType return_value = impl->BooleanReturnOperation();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCBooleanTypeTestInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCBooleanTypeTestInterface.h
deleted file mode 100644
index 86a52fe..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCBooleanTypeTestInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCBooleanTypeTestInterface_h
-#define JSCBooleanTypeTestInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/boolean_type_test_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCBooleanTypeTestInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to BooleanTypeTestInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCBooleanTypeTestInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<BooleanTypeTestInterface>& impl);
- ~JSCBooleanTypeTestInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCBooleanTypeTestInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCCallbackFunctionInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCCallbackFunctionInterface.cc
deleted file mode 100644
index e80158a..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCCallbackFunctionInterface.cc
+++ /dev/null
@@ -1,1032 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCCallbackFunctionInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-#include "JSCArbitraryInterface.h"
-#include "cobalt/bindings/testing/arbitrary_interface.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::CallbackFunctionInterface;
-using cobalt::bindings::testing::JSCCallbackFunctionInterface;
-using cobalt::bindings::testing::ArbitraryInterface;
-using cobalt::bindings::testing::JSCArbitraryInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJScallbackAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJScallbackAttribute(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSnullableCallbackAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSnullableCallbackAttribute(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::EncodedJSValue functionJStakesFunctionThatReturnsString(JSC::ExecState*);
-JSC::EncodedJSValue functionJStakesFunctionWithNullableParameters(JSC::ExecState*);
-JSC::EncodedJSValue functionJStakesFunctionWithOneParameter(JSC::ExecState*);
-JSC::EncodedJSValue functionJStakesFunctionWithSeveralParameters(JSC::ExecState*);
-JSC::EncodedJSValue functionJStakesVoidFunction(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCCallbackFunctionInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCCallbackFunctionInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCCallbackFunctionInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCCallbackFunctionInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCCallbackFunctionInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCCallbackFunctionInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCCallbackFunctionInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCCallbackFunctionInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCCallbackFunctionInterface::InterfaceObject::s_info = {
- "CallbackFunctionInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCCallbackFunctionInterface::InterfaceObject)
-}; // JSCCallbackFunctionInterface::InterfaceObject::s_info
-
-void JSCCallbackFunctionInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCCallbackFunctionInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCCallbackFunctionInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "CallbackFunctionInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCCallbackFunctionInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCCallbackFunctionInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCCallbackFunctionInterface::Prototype::property_table_values[] = {
- { "takesFunctionThatReturnsString",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJStakesFunctionThatReturnsString),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "takesFunctionWithNullableParameters",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJStakesFunctionWithNullableParameters),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "takesFunctionWithOneParameter",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJStakesFunctionWithOneParameter),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "takesFunctionWithSeveralParameters",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJStakesFunctionWithSeveralParameters),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "takesVoidFunction",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJStakesVoidFunction),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCCallbackFunctionInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCCallbackFunctionInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCCallbackFunctionInterface::Prototype::property_table_prototype = {
- 21, // compactSize
- 15, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCCallbackFunctionInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCCallbackFunctionInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCCallbackFunctionInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCCallbackFunctionInterface::Prototype::s_info = {
- "CallbackFunctionInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCCallbackFunctionInterface::Prototype)
-}; // JSCCallbackFunctionInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCCallbackFunctionInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCCallbackFunctionInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCCallbackFunctionInterface::Prototype class
-
-const JSC::HashTableValue JSCCallbackFunctionInterface::property_table_values[] = {
- { "callbackAttribute",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJScallbackAttribute),
- reinterpret_cast<intptr_t>(setJScallbackAttribute),
- JSC::NoIntrinsic
- },
- { "nullableCallbackAttribute",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSnullableCallbackAttribute),
- reinterpret_cast<intptr_t>(setJSnullableCallbackAttribute),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCCallbackFunctionInterface::property_table_values
-
-// static
-const JSC::HashTable JSCCallbackFunctionInterface::property_table_prototype = {
- 9, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCCallbackFunctionInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCCallbackFunctionInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCCallbackFunctionInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCCallbackFunctionInterface::NonTrivialStaticFields>
- JSCCallbackFunctionInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCCallbackFunctionInterface::s_info = {
- "CallbackFunctionInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCCallbackFunctionInterface)
-}; // JSCCallbackFunctionInterface::s_info
-
-// static
-JSC::JSObject* JSCCallbackFunctionInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCCallbackFunctionInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCCallbackFunctionInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCCallbackFunctionInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == CallbackFunctionInterface::CallbackFunctionInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match CallbackFunctionInterface::CallbackFunctionInterfaceWrappableType()";
- return NULL;
- }
- CallbackFunctionInterface* impl_ptr =
- base::polymorphic_downcast<CallbackFunctionInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCCallbackFunctionInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCCallbackFunctionInterface>(global_data.heap))
- JSCCallbackFunctionInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCCallbackFunctionInterface::JSCCallbackFunctionInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<CallbackFunctionInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCCallbackFunctionInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCCallbackFunctionInterface::~JSCCallbackFunctionInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCCallbackFunctionInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCCallbackFunctionInterface* this_object = JSC::jsCast<JSCCallbackFunctionInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCCallbackFunctionInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCCallbackFunctionInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCCallbackFunctionInterface* this_object = JSC::jsCast<JSCCallbackFunctionInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCCallbackFunctionInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCCallbackFunctionInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCCallbackFunctionInterface* this_object = JSC::jsCast<JSCCallbackFunctionInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCCallbackFunctionInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJScallbackAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCCallbackFunctionInterface", "get callbackAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- CallbackFunctionInterface* impl =
- GetWrappableOrSetException<CallbackFunctionInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->callback_attribute());
- return result;
-}
-
-void setJScallbackAttribute(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCCallbackFunctionInterface", "set callbackAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- CallbackFunctionInterface* impl =
- GetWrappableOrSetException<CallbackFunctionInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<CallbackFunctionInterface::VoidFunction >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_callback_attribute(cobalt_value);
- }
-}
-
-JSC::JSValue getJSnullableCallbackAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCCallbackFunctionInterface", "get nullableCallbackAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- CallbackFunctionInterface* impl =
- GetWrappableOrSetException<CallbackFunctionInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->nullable_callback_attribute());
- return result;
-}
-
-void setJSnullableCallbackAttribute(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCCallbackFunctionInterface", "set nullableCallbackAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- CallbackFunctionInterface* impl =
- GetWrappableOrSetException<CallbackFunctionInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<CallbackFunctionInterface::VoidFunction >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- (kConversionFlagNullable), &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_nullable_callback_attribute(cobalt_value);
- }
-}
-
-JSC::EncodedJSValue functionJStakesFunctionThatReturnsString(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCCallbackFunctionInterface", "call takesFunctionThatReturnsString");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- CallbackFunctionInterface* impl =
- GetWrappableOrSetException<CallbackFunctionInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<CallbackFunctionInterface::FunctionThatReturnsString >::ConversionType cb;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &cb);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->TakesFunctionThatReturnsString(cb);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJStakesFunctionWithNullableParameters(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCCallbackFunctionInterface", "call takesFunctionWithNullableParameters");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- CallbackFunctionInterface* impl =
- GetWrappableOrSetException<CallbackFunctionInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<CallbackFunctionInterface::FunctionWithNullableParameters >::ConversionType cb;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &cb);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->TakesFunctionWithNullableParameters(cb);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJStakesFunctionWithOneParameter(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCCallbackFunctionInterface", "call takesFunctionWithOneParameter");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- CallbackFunctionInterface* impl =
- GetWrappableOrSetException<CallbackFunctionInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<CallbackFunctionInterface::FunctionWithOneParameter >::ConversionType cb;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &cb);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->TakesFunctionWithOneParameter(cb);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJStakesFunctionWithSeveralParameters(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCCallbackFunctionInterface", "call takesFunctionWithSeveralParameters");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- CallbackFunctionInterface* impl =
- GetWrappableOrSetException<CallbackFunctionInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<CallbackFunctionInterface::FunctionWithSeveralParameters >::ConversionType cb;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &cb);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->TakesFunctionWithSeveralParameters(cb);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJStakesVoidFunction(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCCallbackFunctionInterface", "call takesVoidFunction");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- CallbackFunctionInterface* impl =
- GetWrappableOrSetException<CallbackFunctionInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<CallbackFunctionInterface::VoidFunction >::ConversionType cb;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &cb);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->TakesVoidFunction(cb);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCCallbackFunctionInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCCallbackFunctionInterface.h
deleted file mode 100644
index 71f4a8d..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCCallbackFunctionInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCCallbackFunctionInterface_h
-#define JSCCallbackFunctionInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/callback_function_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCCallbackFunctionInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to CallbackFunctionInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCCallbackFunctionInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<CallbackFunctionInterface>& impl);
- ~JSCCallbackFunctionInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCCallbackFunctionInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCCallbackInterfaceInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCCallbackInterfaceInterface.cc
deleted file mode 100644
index 0654877..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCCallbackInterfaceInterface.cc
+++ /dev/null
@@ -1,834 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCCallbackInterfaceInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-#include "JSCSingleOperationInterface.h"
-#include "cobalt/bindings/testing/single_operation_interface.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::CallbackInterfaceInterface;
-using cobalt::bindings::testing::JSCCallbackInterfaceInterface;
-using cobalt::bindings::testing::JSCSingleOperationInterface;
-using cobalt::bindings::testing::SingleOperationInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJScallbackAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJScallbackAttribute(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::EncodedJSValue functionJSregisterCallback(JSC::ExecState*);
-JSC::EncodedJSValue functionJSsomeOperation(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCCallbackInterfaceInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCCallbackInterfaceInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCCallbackInterfaceInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCCallbackInterfaceInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCCallbackInterfaceInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCCallbackInterfaceInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCCallbackInterfaceInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCCallbackInterfaceInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCCallbackInterfaceInterface::InterfaceObject::s_info = {
- "CallbackInterfaceInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCCallbackInterfaceInterface::InterfaceObject)
-}; // JSCCallbackInterfaceInterface::InterfaceObject::s_info
-
-void JSCCallbackInterfaceInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCCallbackInterfaceInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCCallbackInterfaceInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "CallbackInterfaceInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCCallbackInterfaceInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCCallbackInterfaceInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCCallbackInterfaceInterface::Prototype::property_table_values[] = {
- { "registerCallback",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSregisterCallback),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "someOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSsomeOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCCallbackInterfaceInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCCallbackInterfaceInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCCallbackInterfaceInterface::Prototype::property_table_prototype = {
- 10, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCCallbackInterfaceInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCCallbackInterfaceInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCCallbackInterfaceInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCCallbackInterfaceInterface::Prototype::s_info = {
- "CallbackInterfaceInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCCallbackInterfaceInterface::Prototype)
-}; // JSCCallbackInterfaceInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCCallbackInterfaceInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCCallbackInterfaceInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCCallbackInterfaceInterface::Prototype class
-
-const JSC::HashTableValue JSCCallbackInterfaceInterface::property_table_values[] = {
- { "callbackAttribute",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJScallbackAttribute),
- reinterpret_cast<intptr_t>(setJScallbackAttribute),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCCallbackInterfaceInterface::property_table_values
-
-// static
-const JSC::HashTable JSCCallbackInterfaceInterface::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCCallbackInterfaceInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCCallbackInterfaceInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCCallbackInterfaceInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCCallbackInterfaceInterface::NonTrivialStaticFields>
- JSCCallbackInterfaceInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCCallbackInterfaceInterface::s_info = {
- "CallbackInterfaceInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCCallbackInterfaceInterface)
-}; // JSCCallbackInterfaceInterface::s_info
-
-// static
-JSC::JSObject* JSCCallbackInterfaceInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCCallbackInterfaceInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCCallbackInterfaceInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCCallbackInterfaceInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == CallbackInterfaceInterface::CallbackInterfaceInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match CallbackInterfaceInterface::CallbackInterfaceInterfaceWrappableType()";
- return NULL;
- }
- CallbackInterfaceInterface* impl_ptr =
- base::polymorphic_downcast<CallbackInterfaceInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCCallbackInterfaceInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCCallbackInterfaceInterface>(global_data.heap))
- JSCCallbackInterfaceInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCCallbackInterfaceInterface::JSCCallbackInterfaceInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<CallbackInterfaceInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCCallbackInterfaceInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCCallbackInterfaceInterface::~JSCCallbackInterfaceInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCCallbackInterfaceInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCCallbackInterfaceInterface* this_object = JSC::jsCast<JSCCallbackInterfaceInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCCallbackInterfaceInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCCallbackInterfaceInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCCallbackInterfaceInterface* this_object = JSC::jsCast<JSCCallbackInterfaceInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCCallbackInterfaceInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCCallbackInterfaceInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCCallbackInterfaceInterface* this_object = JSC::jsCast<JSCCallbackInterfaceInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCCallbackInterfaceInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJScallbackAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCCallbackInterfaceInterface", "get callbackAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- CallbackInterfaceInterface* impl =
- GetWrappableOrSetException<CallbackInterfaceInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->callback_attribute());
- return result;
-}
-
-void setJScallbackAttribute(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCCallbackInterfaceInterface", "set callbackAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- CallbackInterfaceInterface* impl =
- GetWrappableOrSetException<CallbackInterfaceInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<CallbackInterfaceTraits<SingleOperationInterface > >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- (kConversionFlagNullable), &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_callback_attribute(cobalt_value);
- }
-}
-
-JSC::EncodedJSValue functionJSregisterCallback(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCCallbackInterfaceInterface", "call registerCallback");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- CallbackInterfaceInterface* impl =
- GetWrappableOrSetException<CallbackInterfaceInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<CallbackInterfaceTraits<SingleOperationInterface > >::ConversionType callback_interface;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &callback_interface);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->RegisterCallback(callback_interface);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSsomeOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCCallbackInterfaceInterface", "call someOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- CallbackInterfaceInterface* impl =
- GetWrappableOrSetException<CallbackInterfaceInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- impl->SomeOperation();
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCCallbackInterfaceInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCCallbackInterfaceInterface.h
deleted file mode 100644
index a7feb43..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCCallbackInterfaceInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCCallbackInterfaceInterface_h
-#define JSCCallbackInterfaceInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/callback_interface_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCCallbackInterfaceInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to CallbackInterfaceInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCCallbackInterfaceInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<CallbackInterfaceInterface>& impl);
- ~JSCCallbackInterfaceInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCCallbackInterfaceInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCConditionalInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCConditionalInterface.cc
deleted file mode 100644
index c1d873b..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCConditionalInterface.cc
+++ /dev/null
@@ -1,902 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#if defined(ENABLE_CONDITIONAL_INTERFACE)
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCConditionalInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::ConditionalInterface;
-using cobalt::bindings::testing::JSCConditionalInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-#if defined(ENABLE_CONDITIONAL_PROPERTY)
-JSC::JSValue getJSenabledAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSenabledAttribute(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-#endif // defined(ENABLE_CONDITIONAL_PROPERTY)
-#if defined(NO_ENABLE_CONDITIONAL_PROPERTY)
-JSC::JSValue getJSdisabledAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSdisabledAttribute(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-#endif // defined(NO_ENABLE_CONDITIONAL_PROPERTY)
-#if defined(NO_ENABLE_CONDITIONAL_PROPERTY)
-JSC::EncodedJSValue functionJSdisabledOperation(JSC::ExecState*);
-#endif // defined(NO_ENABLE_CONDITIONAL_PROPERTY)
-#if defined(ENABLE_CONDITIONAL_PROPERTY)
-JSC::EncodedJSValue functionJSenabledOperation(JSC::ExecState*);
-#endif // defined(ENABLE_CONDITIONAL_PROPERTY)
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCConditionalInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCConditionalInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCConditionalInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCConditionalInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCConditionalInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCConditionalInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCConditionalInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCConditionalInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCConditionalInterface::InterfaceObject::s_info = {
- "ConditionalInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCConditionalInterface::InterfaceObject)
-}; // JSCConditionalInterface::InterfaceObject::s_info
-
-void JSCConditionalInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCConditionalInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCConditionalInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "ConditionalInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCConditionalInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCConditionalInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCConditionalInterface::Prototype::property_table_values[] = {
-#if defined(NO_ENABLE_CONDITIONAL_PROPERTY)
- { "disabledOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSdisabledOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
-#endif // defined(NO_ENABLE_CONDITIONAL_PROPERTY)
-#if defined(ENABLE_CONDITIONAL_PROPERTY)
- { "enabledOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSenabledOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
-#endif // defined(ENABLE_CONDITIONAL_PROPERTY)
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCConditionalInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCConditionalInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCConditionalInterface::Prototype::property_table_prototype = {
- 10, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCConditionalInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCConditionalInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCConditionalInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCConditionalInterface::Prototype::s_info = {
- "ConditionalInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCConditionalInterface::Prototype)
-}; // JSCConditionalInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCConditionalInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCConditionalInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCConditionalInterface::Prototype class
-
-const JSC::HashTableValue JSCConditionalInterface::property_table_values[] = {
-#if defined(ENABLE_CONDITIONAL_PROPERTY)
- { "enabledAttribute",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSenabledAttribute),
- reinterpret_cast<intptr_t>(setJSenabledAttribute),
- JSC::NoIntrinsic
- },
-#endif // defined(ENABLE_CONDITIONAL_PROPERTY)
-#if defined(NO_ENABLE_CONDITIONAL_PROPERTY)
- { "disabledAttribute",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSdisabledAttribute),
- reinterpret_cast<intptr_t>(setJSdisabledAttribute),
- JSC::NoIntrinsic
- },
-#endif // defined(NO_ENABLE_CONDITIONAL_PROPERTY)
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCConditionalInterface::property_table_values
-
-// static
-const JSC::HashTable JSCConditionalInterface::property_table_prototype = {
- 9, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCConditionalInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCConditionalInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCConditionalInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCConditionalInterface::NonTrivialStaticFields>
- JSCConditionalInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCConditionalInterface::s_info = {
- "ConditionalInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCConditionalInterface)
-}; // JSCConditionalInterface::s_info
-
-// static
-JSC::JSObject* JSCConditionalInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCConditionalInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCConditionalInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCConditionalInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == ConditionalInterface::ConditionalInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match ConditionalInterface::ConditionalInterfaceWrappableType()";
- return NULL;
- }
- ConditionalInterface* impl_ptr =
- base::polymorphic_downcast<ConditionalInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCConditionalInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCConditionalInterface>(global_data.heap))
- JSCConditionalInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCConditionalInterface::JSCConditionalInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<ConditionalInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCConditionalInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCConditionalInterface::~JSCConditionalInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCConditionalInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCConditionalInterface* this_object = JSC::jsCast<JSCConditionalInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCConditionalInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCConditionalInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCConditionalInterface* this_object = JSC::jsCast<JSCConditionalInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCConditionalInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCConditionalInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCConditionalInterface* this_object = JSC::jsCast<JSCConditionalInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCConditionalInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-#if defined(ENABLE_CONDITIONAL_PROPERTY)
-JSC::JSValue getJSenabledAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCConditionalInterface", "get enabledAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ConditionalInterface* impl =
- GetWrappableOrSetException<ConditionalInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->enabled_attribute());
- return result;
-}
-
-void setJSenabledAttribute(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCConditionalInterface", "set enabledAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- ConditionalInterface* impl =
- GetWrappableOrSetException<ConditionalInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<int32_t >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_enabled_attribute(cobalt_value);
- }
-}
-#endif // defined(ENABLE_CONDITIONAL_PROPERTY)
-
-#if defined(NO_ENABLE_CONDITIONAL_PROPERTY)
-JSC::JSValue getJSdisabledAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCConditionalInterface", "get disabledAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ConditionalInterface* impl =
- GetWrappableOrSetException<ConditionalInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->disabled_attribute());
- return result;
-}
-
-void setJSdisabledAttribute(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCConditionalInterface", "set disabledAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- ConditionalInterface* impl =
- GetWrappableOrSetException<ConditionalInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<int32_t >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_disabled_attribute(cobalt_value);
- }
-}
-#endif // defined(NO_ENABLE_CONDITIONAL_PROPERTY)
-#if defined(NO_ENABLE_CONDITIONAL_PROPERTY)
-
-JSC::EncodedJSValue functionJSdisabledOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCConditionalInterface", "call disabledOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- ConditionalInterface* impl =
- GetWrappableOrSetException<ConditionalInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- impl->DisabledOperation();
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-#endif // defined(NO_ENABLE_CONDITIONAL_PROPERTY)
-#if defined(ENABLE_CONDITIONAL_PROPERTY)
-
-JSC::EncodedJSValue functionJSenabledOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCConditionalInterface", "call enabledOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- ConditionalInterface* impl =
- GetWrappableOrSetException<ConditionalInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- impl->EnabledOperation();
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-#endif // defined(ENABLE_CONDITIONAL_PROPERTY)
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
-#endif // defined(ENABLE_CONDITIONAL_INTERFACE)
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCConditionalInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCConditionalInterface.h
deleted file mode 100644
index 6a67c7f..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCConditionalInterface.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCConditionalInterface_h
-#define JSCConditionalInterface_h
-
-#if defined(ENABLE_CONDITIONAL_INTERFACE)
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/conditional_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCConditionalInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to ConditionalInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCConditionalInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<ConditionalInterface>& impl);
- ~JSCConditionalInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // defined(ENABLE_CONDITIONAL_INTERFACE)
-
-#endif // JSCConditionalInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCConstantsInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCConstantsInterface.cc
deleted file mode 100644
index 7919ac5..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCConstantsInterface.cc
+++ /dev/null
@@ -1,754 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCConstantsInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::ConstantsInterface;
-using cobalt::bindings::testing::JSCConstantsInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSINTEGER_CONSTANT(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-JSC::JSValue getJSDOUBLE_CONSTANT(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCConstantsInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCConstantsInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCConstantsInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { "INTEGER_CONSTANT",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJSINTEGER_CONSTANT),
- 0,
- JSC::NoIntrinsic
- },
- { "DOUBLE_CONSTANT",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJSDOUBLE_CONSTANT),
- 0,
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCConstantsInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCConstantsInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 9, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCConstantsInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCConstantsInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCConstantsInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCConstantsInterface::InterfaceObject::s_info = {
- "ConstantsInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCConstantsInterface::InterfaceObject)
-}; // JSCConstantsInterface::InterfaceObject::s_info
-
-void JSCConstantsInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCConstantsInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCConstantsInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "ConstantsInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCConstantsInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCConstantsInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCConstantsInterface::Prototype::property_table_values[] = {
- { "INTEGER_CONSTANT",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJSINTEGER_CONSTANT),
- 0,
- JSC::NoIntrinsic
- },
- { "DOUBLE_CONSTANT",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJSDOUBLE_CONSTANT),
- 0,
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCConstantsInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCConstantsInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCConstantsInterface::Prototype::property_table_prototype = {
- 10, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCConstantsInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCConstantsInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCConstantsInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCConstantsInterface::Prototype::s_info = {
- "ConstantsInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCConstantsInterface::Prototype)
-}; // JSCConstantsInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCConstantsInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCConstantsInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCConstantsInterface::Prototype class
-
-const JSC::HashTableValue JSCConstantsInterface::property_table_values[] = {
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCConstantsInterface::property_table_values
-
-// static
-const JSC::HashTable JSCConstantsInterface::property_table_prototype = {
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCConstantsInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCConstantsInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCConstantsInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCConstantsInterface::NonTrivialStaticFields>
- JSCConstantsInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCConstantsInterface::s_info = {
- "ConstantsInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCConstantsInterface)
-}; // JSCConstantsInterface::s_info
-
-// static
-JSC::JSObject* JSCConstantsInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCConstantsInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCConstantsInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCConstantsInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == ConstantsInterface::ConstantsInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match ConstantsInterface::ConstantsInterfaceWrappableType()";
- return NULL;
- }
- ConstantsInterface* impl_ptr =
- base::polymorphic_downcast<ConstantsInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCConstantsInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCConstantsInterface>(global_data.heap))
- JSCConstantsInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCConstantsInterface::JSCConstantsInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<ConstantsInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCConstantsInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCConstantsInterface::~JSCConstantsInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCConstantsInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCConstantsInterface* this_object = JSC::jsCast<JSCConstantsInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCConstantsInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCConstantsInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCConstantsInterface* this_object = JSC::jsCast<JSCConstantsInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCConstantsInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCConstantsInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCConstantsInterface* this_object = JSC::jsCast<JSCConstantsInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCConstantsInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSINTEGER_CONSTANT(
- JSC::ExecState* exec_state, JSC::JSValue, JSC::PropertyName) {
- TRACE_EVENT0("JSCConstantsInterface", "get INTEGER_CONSTANT");
- COMPILE_ASSERT(ConstantsInterface::kIntegerConstant == 5,
- ValueForConstantsInterface_kIntegerConstantDoesNotMatchIDL);
- // JSCGlobalObject* is only needed for non-primitive types.
- return ToJSValue(NULL, 5);
-}
-
-JSC::JSValue getJSDOUBLE_CONSTANT(
- JSC::ExecState* exec_state, JSC::JSValue, JSC::PropertyName) {
- TRACE_EVENT0("JSCConstantsInterface", "get DOUBLE_CONSTANT");
- DCHECK_EQ(2.718, ConstantsInterface::kDoubleConstant) <<
- "The value for ConstantsInterface::kDoubleConstant does not match "
- "the value in the interface definition.";
- // JSCGlobalObject* is only needed for non-primitive types.
- return ToJSValue(NULL, 2.718);
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCConstantsInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCConstantsInterface.h
deleted file mode 100644
index d977ced..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCConstantsInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCConstantsInterface_h
-#define JSCConstantsInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/constants_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCConstantsInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to ConstantsInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCConstantsInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<ConstantsInterface>& impl);
- ~JSCConstantsInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCConstantsInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCConstructorInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCConstructorInterface.cc
deleted file mode 100644
index eac76c2..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCConstructorInterface.cc
+++ /dev/null
@@ -1,759 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCConstructorInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::ConstructorInterface;
-using cobalt::bindings::testing::JSCConstructorInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::EncodedJSValue constructorJSConstructorInterface(JSC::ExecState*);
-JSC::EncodedJSValue constructorJSConstructorInterface1(JSC::ExecState*);
-JSC::EncodedJSValue constructorJSConstructorInterface2(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCConstructorInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCConstructorInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCConstructorInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCConstructorInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCConstructorInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCConstructorInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCConstructorInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCConstructorInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCConstructorInterface::InterfaceObject::s_info = {
- "ConstructorInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCConstructorInterface::InterfaceObject)
-}; // JSCConstructorInterface::InterfaceObject::s_info
-
-void JSCConstructorInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCConstructorInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCConstructorInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, &constructorJSConstructorInterface);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "ConstructorInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCConstructorInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCConstructorInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCConstructorInterface::Prototype::property_table_values[] = {
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCConstructorInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCConstructorInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCConstructorInterface::Prototype::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCConstructorInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCConstructorInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCConstructorInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCConstructorInterface::Prototype::s_info = {
- "ConstructorInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCConstructorInterface::Prototype)
-}; // JSCConstructorInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCConstructorInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCConstructorInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCConstructorInterface::Prototype class
-
-const JSC::HashTableValue JSCConstructorInterface::property_table_values[] = {
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCConstructorInterface::property_table_values
-
-// static
-const JSC::HashTable JSCConstructorInterface::property_table_prototype = {
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCConstructorInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCConstructorInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCConstructorInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCConstructorInterface::NonTrivialStaticFields>
- JSCConstructorInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCConstructorInterface::s_info = {
- "ConstructorInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCConstructorInterface)
-}; // JSCConstructorInterface::s_info
-
-// static
-JSC::JSObject* JSCConstructorInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCConstructorInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCConstructorInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCConstructorInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == ConstructorInterface::ConstructorInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match ConstructorInterface::ConstructorInterfaceWrappableType()";
- return NULL;
- }
- ConstructorInterface* impl_ptr =
- base::polymorphic_downcast<ConstructorInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCConstructorInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCConstructorInterface>(global_data.heap))
- JSCConstructorInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCConstructorInterface::JSCConstructorInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<ConstructorInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCConstructorInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCConstructorInterface::~JSCConstructorInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCConstructorInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCConstructorInterface* this_object = JSC::jsCast<JSCConstructorInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCConstructorInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCConstructorInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCConstructorInterface* this_object = JSC::jsCast<JSCConstructorInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCConstructorInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCConstructorInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCConstructorInterface* this_object = JSC::jsCast<JSCConstructorInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCConstructorInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::EncodedJSValue constructorJSConstructorInterface(JSC::ExecState* exec_state) {
- const size_t num_arguments = exec_state->argumentCount();
- switch(num_arguments) {
- case(0): {
- // Overload resolution algorithm details found here:
- // http://heycam.github.io/webidl/#dfn-overload-resolution-algorithm
- if (true) {
- return constructorJSConstructorInterface1(exec_state);
- }
- break;
- }
- case(1): {
- // Overload resolution algorithm details found here:
- // http://heycam.github.io/webidl/#dfn-overload-resolution-algorithm
- if (true) {
- return constructorJSConstructorInterface2(exec_state);
- }
- break;
- }
- }
- // Invalid number of args
- // http://heycam.github.io/webidl/#dfn-overload-resolution-algorithm
- // 4. If S is empty, then throw a TypeError.
- return JSC::throwVMTypeError(exec_state);
-}
-
-JSC::EncodedJSValue constructorJSConstructorInterface1(JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- scoped_refptr<ConstructorInterface> new_object =
- new ConstructorInterface();
- return JSC::JSValue::encode(ToJSValue(global_object, new_object));
-
-}
-
-JSC::EncodedJSValue constructorJSConstructorInterface2(JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<bool >::ConversionType arg;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- scoped_refptr<ConstructorInterface> new_object =
- new ConstructorInterface(arg);
- return JSC::JSValue::encode(ToJSValue(global_object, new_object));
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCConstructorInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCConstructorInterface.h
deleted file mode 100644
index 3d0eb62..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCConstructorInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCConstructorInterface_h
-#define JSCConstructorInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/constructor_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCConstructorInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to ConstructorInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCConstructorInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<ConstructorInterface>& impl);
- ~JSCConstructorInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCConstructorInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCConstructorWithArgumentsInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCConstructorWithArgumentsInterface.cc
deleted file mode 100644
index dc8159a..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCConstructorWithArgumentsInterface.cc
+++ /dev/null
@@ -1,833 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCConstructorWithArgumentsInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::ConstructorWithArgumentsInterface;
-using cobalt::bindings::testing::JSCConstructorWithArgumentsInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSlongArg(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-JSC::JSValue getJSbooleanArg(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-JSC::JSValue getJSstringArg(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-JSC::EncodedJSValue constructorJSConstructorWithArgumentsInterface(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCConstructorWithArgumentsInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCConstructorWithArgumentsInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCConstructorWithArgumentsInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCConstructorWithArgumentsInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCConstructorWithArgumentsInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCConstructorWithArgumentsInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCConstructorWithArgumentsInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCConstructorWithArgumentsInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCConstructorWithArgumentsInterface::InterfaceObject::s_info = {
- "ConstructorWithArgumentsInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCConstructorWithArgumentsInterface::InterfaceObject)
-}; // JSCConstructorWithArgumentsInterface::InterfaceObject::s_info
-
-void JSCConstructorWithArgumentsInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCConstructorWithArgumentsInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCConstructorWithArgumentsInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 2;
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, &constructorJSConstructorWithArgumentsInterface);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "ConstructorWithArgumentsInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCConstructorWithArgumentsInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCConstructorWithArgumentsInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCConstructorWithArgumentsInterface::Prototype::property_table_values[] = {
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCConstructorWithArgumentsInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCConstructorWithArgumentsInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCConstructorWithArgumentsInterface::Prototype::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCConstructorWithArgumentsInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCConstructorWithArgumentsInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCConstructorWithArgumentsInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCConstructorWithArgumentsInterface::Prototype::s_info = {
- "ConstructorWithArgumentsInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCConstructorWithArgumentsInterface::Prototype)
-}; // JSCConstructorWithArgumentsInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCConstructorWithArgumentsInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCConstructorWithArgumentsInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCConstructorWithArgumentsInterface::Prototype class
-
-const JSC::HashTableValue JSCConstructorWithArgumentsInterface::property_table_values[] = {
- { "longArg",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJSlongArg),
- 0,
- JSC::NoIntrinsic
- },
- { "booleanArg",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJSbooleanArg),
- 0,
- JSC::NoIntrinsic
- },
- { "stringArg",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJSstringArg),
- 0,
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCConstructorWithArgumentsInterface::property_table_values
-
-// static
-const JSC::HashTable JSCConstructorWithArgumentsInterface::property_table_prototype = {
- 10, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCConstructorWithArgumentsInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCConstructorWithArgumentsInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCConstructorWithArgumentsInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCConstructorWithArgumentsInterface::NonTrivialStaticFields>
- JSCConstructorWithArgumentsInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCConstructorWithArgumentsInterface::s_info = {
- "ConstructorWithArgumentsInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCConstructorWithArgumentsInterface)
-}; // JSCConstructorWithArgumentsInterface::s_info
-
-// static
-JSC::JSObject* JSCConstructorWithArgumentsInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCConstructorWithArgumentsInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCConstructorWithArgumentsInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCConstructorWithArgumentsInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == ConstructorWithArgumentsInterface::ConstructorWithArgumentsInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match ConstructorWithArgumentsInterface::ConstructorWithArgumentsInterfaceWrappableType()";
- return NULL;
- }
- ConstructorWithArgumentsInterface* impl_ptr =
- base::polymorphic_downcast<ConstructorWithArgumentsInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCConstructorWithArgumentsInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCConstructorWithArgumentsInterface>(global_data.heap))
- JSCConstructorWithArgumentsInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCConstructorWithArgumentsInterface::JSCConstructorWithArgumentsInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<ConstructorWithArgumentsInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCConstructorWithArgumentsInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCConstructorWithArgumentsInterface::~JSCConstructorWithArgumentsInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCConstructorWithArgumentsInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCConstructorWithArgumentsInterface* this_object = JSC::jsCast<JSCConstructorWithArgumentsInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCConstructorWithArgumentsInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCConstructorWithArgumentsInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCConstructorWithArgumentsInterface* this_object = JSC::jsCast<JSCConstructorWithArgumentsInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCConstructorWithArgumentsInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCConstructorWithArgumentsInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCConstructorWithArgumentsInterface* this_object = JSC::jsCast<JSCConstructorWithArgumentsInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCConstructorWithArgumentsInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSlongArg(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCConstructorWithArgumentsInterface", "get longArg");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ConstructorWithArgumentsInterface* impl =
- GetWrappableOrSetException<ConstructorWithArgumentsInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->long_arg());
- return result;
-}
-
-JSC::JSValue getJSbooleanArg(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCConstructorWithArgumentsInterface", "get booleanArg");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ConstructorWithArgumentsInterface* impl =
- GetWrappableOrSetException<ConstructorWithArgumentsInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->boolean_arg());
- return result;
-}
-
-JSC::JSValue getJSstringArg(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCConstructorWithArgumentsInterface", "get stringArg");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ConstructorWithArgumentsInterface* impl =
- GetWrappableOrSetException<ConstructorWithArgumentsInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->string_arg());
- return result;
-}
-
-JSC::EncodedJSValue constructorJSConstructorWithArgumentsInterface(JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- const size_t kMinArguments = 2;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<int32_t >::ConversionType arg1;
- TypeTraits<bool >::ConversionType arg2;
- // Optional arguments with default values
- TypeTraits<std::string >::ConversionType default_arg =
- "default";
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg1);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
-
- DCHECK_LT(1, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(1),
- kNoConversionFlags,
- &exception_state, &arg2);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
-
- size_t num_set_arguments = 3;
- if (exec_state->argumentCount() > 2) {
- FromJSValue(exec_state,
- exec_state->argument(2),
- kNoConversionFlags,
- &exception_state,
- &default_arg);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- }
- scoped_refptr<ConstructorWithArgumentsInterface> new_object =
- new ConstructorWithArgumentsInterface(arg1, arg2, default_arg);
- return JSC::JSValue::encode(ToJSValue(global_object, new_object));
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCConstructorWithArgumentsInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCConstructorWithArgumentsInterface.h
deleted file mode 100644
index 3a69aab..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCConstructorWithArgumentsInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCConstructorWithArgumentsInterface_h
-#define JSCConstructorWithArgumentsInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/constructor_with_arguments_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCConstructorWithArgumentsInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to ConstructorWithArgumentsInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCConstructorWithArgumentsInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<ConstructorWithArgumentsInterface>& impl);
- ~JSCConstructorWithArgumentsInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCConstructorWithArgumentsInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCDOMStringTestInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCDOMStringTestInterface.cc
deleted file mode 100644
index e37be61..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCDOMStringTestInterface.cc
+++ /dev/null
@@ -1,1001 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCDOMStringTestInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::DOMStringTestInterface;
-using cobalt::bindings::testing::JSCDOMStringTestInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSproperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSproperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSreadOnlyProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-JSC::JSValue getJSreadOnlyTokenProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-JSC::JSValue getJSnullIsEmptyProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSnullIsEmptyProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSundefinedIsEmptyProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSundefinedIsEmptyProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSnullableUndefinedIsEmptyProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSnullableUndefinedIsEmptyProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCDOMStringTestInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCDOMStringTestInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCDOMStringTestInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCDOMStringTestInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCDOMStringTestInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCDOMStringTestInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCDOMStringTestInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCDOMStringTestInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCDOMStringTestInterface::InterfaceObject::s_info = {
- "DOMStringTestInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCDOMStringTestInterface::InterfaceObject)
-}; // JSCDOMStringTestInterface::InterfaceObject::s_info
-
-void JSCDOMStringTestInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCDOMStringTestInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCDOMStringTestInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "DOMStringTestInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCDOMStringTestInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCDOMStringTestInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCDOMStringTestInterface::Prototype::property_table_values[] = {
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCDOMStringTestInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCDOMStringTestInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCDOMStringTestInterface::Prototype::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCDOMStringTestInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCDOMStringTestInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCDOMStringTestInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCDOMStringTestInterface::Prototype::s_info = {
- "DOMStringTestInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCDOMStringTestInterface::Prototype)
-}; // JSCDOMStringTestInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCDOMStringTestInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCDOMStringTestInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCDOMStringTestInterface::Prototype class
-
-const JSC::HashTableValue JSCDOMStringTestInterface::property_table_values[] = {
- { "property",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSproperty),
- reinterpret_cast<intptr_t>(setJSproperty),
- JSC::NoIntrinsic
- },
- { "readOnlyProperty",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJSreadOnlyProperty),
- 0,
- JSC::NoIntrinsic
- },
- { "readOnlyTokenProperty",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJSreadOnlyTokenProperty),
- 0,
- JSC::NoIntrinsic
- },
- { "nullIsEmptyProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSnullIsEmptyProperty),
- reinterpret_cast<intptr_t>(setJSnullIsEmptyProperty),
- JSC::NoIntrinsic
- },
- { "undefinedIsEmptyProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSundefinedIsEmptyProperty),
- reinterpret_cast<intptr_t>(setJSundefinedIsEmptyProperty),
- JSC::NoIntrinsic
- },
- { "nullableUndefinedIsEmptyProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSnullableUndefinedIsEmptyProperty),
- reinterpret_cast<intptr_t>(setJSnullableUndefinedIsEmptyProperty),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCDOMStringTestInterface::property_table_values
-
-// static
-const JSC::HashTable JSCDOMStringTestInterface::property_table_prototype = {
- 21, // compactSize
- 15, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCDOMStringTestInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCDOMStringTestInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCDOMStringTestInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCDOMStringTestInterface::NonTrivialStaticFields>
- JSCDOMStringTestInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCDOMStringTestInterface::s_info = {
- "DOMStringTestInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCDOMStringTestInterface)
-}; // JSCDOMStringTestInterface::s_info
-
-// static
-JSC::JSObject* JSCDOMStringTestInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCDOMStringTestInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCDOMStringTestInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCDOMStringTestInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == DOMStringTestInterface::DOMStringTestInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match DOMStringTestInterface::DOMStringTestInterfaceWrappableType()";
- return NULL;
- }
- DOMStringTestInterface* impl_ptr =
- base::polymorphic_downcast<DOMStringTestInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCDOMStringTestInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCDOMStringTestInterface>(global_data.heap))
- JSCDOMStringTestInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCDOMStringTestInterface::JSCDOMStringTestInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<DOMStringTestInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCDOMStringTestInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCDOMStringTestInterface::~JSCDOMStringTestInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCDOMStringTestInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCDOMStringTestInterface* this_object = JSC::jsCast<JSCDOMStringTestInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCDOMStringTestInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCDOMStringTestInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCDOMStringTestInterface* this_object = JSC::jsCast<JSCDOMStringTestInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCDOMStringTestInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCDOMStringTestInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCDOMStringTestInterface* this_object = JSC::jsCast<JSCDOMStringTestInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCDOMStringTestInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSproperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCDOMStringTestInterface", "get property");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- DOMStringTestInterface* impl =
- GetWrappableOrSetException<DOMStringTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->property());
- return result;
-}
-
-void setJSproperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCDOMStringTestInterface", "set property");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- DOMStringTestInterface* impl =
- GetWrappableOrSetException<DOMStringTestInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<std::string >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_property(cobalt_value);
- }
-}
-
-JSC::JSValue getJSreadOnlyProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCDOMStringTestInterface", "get readOnlyProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- DOMStringTestInterface* impl =
- GetWrappableOrSetException<DOMStringTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->read_only_property());
- return result;
-}
-
-JSC::JSValue getJSreadOnlyTokenProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCDOMStringTestInterface", "get readOnlyTokenProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- DOMStringTestInterface* impl =
- GetWrappableOrSetException<DOMStringTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->read_only_token_property());
- return result;
-}
-
-JSC::JSValue getJSnullIsEmptyProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCDOMStringTestInterface", "get nullIsEmptyProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- DOMStringTestInterface* impl =
- GetWrappableOrSetException<DOMStringTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->null_is_empty_property());
- return result;
-}
-
-void setJSnullIsEmptyProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCDOMStringTestInterface", "set nullIsEmptyProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- DOMStringTestInterface* impl =
- GetWrappableOrSetException<DOMStringTestInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<std::string >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- (kConversionFlagTreatNullAsEmptyString), &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_null_is_empty_property(cobalt_value);
- }
-}
-
-JSC::JSValue getJSundefinedIsEmptyProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCDOMStringTestInterface", "get undefinedIsEmptyProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- DOMStringTestInterface* impl =
- GetWrappableOrSetException<DOMStringTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->undefined_is_empty_property());
- return result;
-}
-
-void setJSundefinedIsEmptyProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCDOMStringTestInterface", "set undefinedIsEmptyProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- DOMStringTestInterface* impl =
- GetWrappableOrSetException<DOMStringTestInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<std::string >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- (kConversionFlagTreatUndefinedAsEmptyString), &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_undefined_is_empty_property(cobalt_value);
- }
-}
-
-JSC::JSValue getJSnullableUndefinedIsEmptyProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCDOMStringTestInterface", "get nullableUndefinedIsEmptyProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- DOMStringTestInterface* impl =
- GetWrappableOrSetException<DOMStringTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->nullable_undefined_is_empty_property());
- return result;
-}
-
-void setJSnullableUndefinedIsEmptyProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCDOMStringTestInterface", "set nullableUndefinedIsEmptyProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- DOMStringTestInterface* impl =
- GetWrappableOrSetException<DOMStringTestInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<base::optional<std::string > >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- (kConversionFlagNullable | kConversionFlagTreatUndefinedAsEmptyString), &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_nullable_undefined_is_empty_property(cobalt_value);
- }
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCDOMStringTestInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCDOMStringTestInterface.h
deleted file mode 100644
index 32ccb2c..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCDOMStringTestInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCDOMStringTestInterface_h
-#define JSCDOMStringTestInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/dom_string_test_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCDOMStringTestInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to DOMStringTestInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCDOMStringTestInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<DOMStringTestInterface>& impl);
- ~JSCDOMStringTestInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCDOMStringTestInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCDerivedGetterSetterInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCDerivedGetterSetterInterface.cc
deleted file mode 100644
index a11005c..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCDerivedGetterSetterInterface.cc
+++ /dev/null
@@ -1,1084 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCDerivedGetterSetterInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/jsc_property_enumerator.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::DerivedGetterSetterInterface;
-using cobalt::bindings::testing::JSCDerivedGetterSetterInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSCPropertyEnumerator;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSlength(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-JSC::JSValue getJSpropertyOnDerivedClass(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSpropertyOnDerivedClass(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::EncodedJSValue functionJSderivedIndexedGetter(JSC::ExecState*);
-JSC::EncodedJSValue functionJSderivedIndexedSetter(JSC::ExecState*);
-JSC::EncodedJSValue functionJSoperationOnDerivedClass(JSC::ExecState*);
-JSC::JSValue IndexedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, uint32_t index);
-void IndexedPropertySetter(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::JSValue value);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = true;
-const bool s_has_named_setter = true;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = false;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCDerivedGetterSetterInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCDerivedGetterSetterInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCDerivedGetterSetterInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCDerivedGetterSetterInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCDerivedGetterSetterInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCDerivedGetterSetterInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCDerivedGetterSetterInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCDerivedGetterSetterInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCDerivedGetterSetterInterface::InterfaceObject::s_info = {
- "DerivedGetterSetterInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCDerivedGetterSetterInterface::InterfaceObject)
-}; // JSCDerivedGetterSetterInterface::InterfaceObject::s_info
-
-void JSCDerivedGetterSetterInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCDerivedGetterSetterInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCDerivedGetterSetterInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "DerivedGetterSetterInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCDerivedGetterSetterInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCDerivedGetterSetterInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCDerivedGetterSetterInterface::Prototype::property_table_values[] = {
- { "derivedIndexedGetter",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSderivedIndexedGetter),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "derivedIndexedSetter",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSderivedIndexedSetter),
- static_cast<intptr_t>(2),
- JSC::NoIntrinsic
- },
- { "operationOnDerivedClass",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSoperationOnDerivedClass),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCDerivedGetterSetterInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCDerivedGetterSetterInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCDerivedGetterSetterInterface::Prototype::property_table_prototype = {
- 19, // compactSize
- 15, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCDerivedGetterSetterInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCDerivedGetterSetterInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCDerivedGetterSetterInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCDerivedGetterSetterInterface::Prototype::s_info = {
- "DerivedGetterSetterInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCDerivedGetterSetterInterface::Prototype)
-}; // JSCDerivedGetterSetterInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCDerivedGetterSetterInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCDerivedGetterSetterInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype =
- bindings::testing::JSCNamedIndexedGetterInterface::GetPrototype(global_object);
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCDerivedGetterSetterInterface::Prototype class
-
-const JSC::HashTableValue JSCDerivedGetterSetterInterface::property_table_values[] = {
- { "length",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJSlength),
- 0,
- JSC::NoIntrinsic
- },
- { "propertyOnDerivedClass",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSpropertyOnDerivedClass),
- reinterpret_cast<intptr_t>(setJSpropertyOnDerivedClass),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCDerivedGetterSetterInterface::property_table_values
-
-// static
-const JSC::HashTable JSCDerivedGetterSetterInterface::property_table_prototype = {
- 9, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCDerivedGetterSetterInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCDerivedGetterSetterInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCDerivedGetterSetterInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCDerivedGetterSetterInterface::NonTrivialStaticFields>
- JSCDerivedGetterSetterInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCDerivedGetterSetterInterface::s_info = {
- "DerivedGetterSetterInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCDerivedGetterSetterInterface)
-}; // JSCDerivedGetterSetterInterface::s_info
-
-// static
-JSC::JSObject* JSCDerivedGetterSetterInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCDerivedGetterSetterInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCDerivedGetterSetterInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCDerivedGetterSetterInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == DerivedGetterSetterInterface::DerivedGetterSetterInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match DerivedGetterSetterInterface::DerivedGetterSetterInterfaceWrappableType()";
- return NULL;
- }
- DerivedGetterSetterInterface* impl_ptr =
- base::polymorphic_downcast<DerivedGetterSetterInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCDerivedGetterSetterInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCDerivedGetterSetterInterface>(global_data.heap))
- JSCDerivedGetterSetterInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCDerivedGetterSetterInterface::JSCDerivedGetterSetterInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<DerivedGetterSetterInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCDerivedGetterSetterInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCDerivedGetterSetterInterface::~JSCDerivedGetterSetterInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCDerivedGetterSetterInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCDerivedGetterSetterInterface* this_object = JSC::jsCast<JSCDerivedGetterSetterInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCDerivedGetterSetterInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// static
-bool JSCDerivedGetterSetterInterface::getOwnPropertySlotByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::PropertySlot& slot) {
- DerivedGetterSetterInterface* impl =
- GetWrappableOrSetException<DerivedGetterSetterInterface>(exec_state, cell);
- if (!impl) {
- return false;
- }
- if (index < impl->length()) {
- slot.setCustomIndex(cell, index, IndexedPropertyGetter);
- return true;
- }
- if (s_has_named_getter) {
- JSCDerivedGetterSetterInterface* this_object = JSC::jsCast<JSCDerivedGetterSetterInterface*>(cell);
- JSC::PropertyName property_name = JSC::Identifier::from(exec_state, index);
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property) {
- if (QueryNamedProperty(this_object, exec_state, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- return true;
- }
- }
- }
- return Base::getOwnPropertySlotByIndex(cell, exec_state, index, slot);
-}
-
-void JSCDerivedGetterSetterInterface::getOwnPropertyNames(JSC::JSObject* object,
- JSC::ExecState* exec_state, JSC::PropertyNameArray& property_names,
- JSC::EnumerationMode mode) {
- DerivedGetterSetterInterface* impl =
- GetWrappableOrSetException<DerivedGetterSetterInterface>(exec_state, object);
- if (impl) {
- for (uint32 i = 0; i < impl->length(); ++i) {
- property_names.add(JSC::Identifier::from(exec_state, i));
- }
- JSCPropertyEnumerator enumerator(exec_state, &property_names);
- impl->EnumerateNamedProperties(&enumerator);
- Base::getOwnPropertyNames(object, exec_state, property_names, mode);
- }
-}
-
-// Look up property slot and put the |value|.
-void JSCDerivedGetterSetterInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCDerivedGetterSetterInterface* this_object = JSC::jsCast<JSCDerivedGetterSetterInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCDerivedGetterSetterInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-// static
-void JSCDerivedGetterSetterInterface::putByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::JSValue value,
- bool should_throw) {
- DerivedGetterSetterInterface* impl =
- GetWrappableOrSetException<DerivedGetterSetterInterface>(exec_state, cell);
- if (impl) {
- bool property_handled = false;
- if (index < impl->length()) {
- IndexedPropertySetter(cell, exec_state, index, value);
- property_handled = true;
- }
- if (s_has_named_setter) {
- if (!property_handled) {
- JSC::PropertyName property_name = JSC::Identifier::from(exec_state, index);
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property) {
- NamedPropertySetter(cell, exec_state, property_name, value);
- property_handled = true;
- }
- }
- }
- if (!property_handled) {
- Base::putByIndex(cell, exec_state, index, value, should_throw);
- }
- }
-}
-
-
-bool JSCDerivedGetterSetterInterface::deleteProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- TRACE_EVENT1("JSCDerivedGetterSetterInterface", "deleteProperty", "property",
- TRACE_STR_COPY(WTF::String(property_name.publicName()).utf8().data()));
- DerivedGetterSetterInterface* impl =
- GetWrappableOrSetException<DerivedGetterSetterInterface>(exec_state, cell);
- if (impl) {
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property &&
- QueryNamedProperty(cell, exec_state, property_name)) {
- return NamedPropertyDeleter(cell, exec_state, property_name);
- }
- return Base::deleteProperty(cell, exec_state, property_name);
- }
- return false;
-}
-
-bool JSCDerivedGetterSetterInterface::deletePropertyByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state,
- uint32_t index) {
- TRACE_EVENT0("JSCDerivedGetterSetterInterface", "deletePropertyByIndex");
- DerivedGetterSetterInterface* impl =
- GetWrappableOrSetException<DerivedGetterSetterInterface>(exec_state, cell);
- if (impl) {
- // https://heycam.github.io/webidl/#delete
- // Return true if index is not a supported property index.
- return index >= impl->length();
- }
- return false;
-}
-
-bool JSCDerivedGetterSetterInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCDerivedGetterSetterInterface* this_object = JSC::jsCast<JSCDerivedGetterSetterInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCDerivedGetterSetterInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSlength(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCDerivedGetterSetterInterface", "get length");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- DerivedGetterSetterInterface* impl =
- GetWrappableOrSetException<DerivedGetterSetterInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->length());
- return result;
-}
-
-JSC::JSValue getJSpropertyOnDerivedClass(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCDerivedGetterSetterInterface", "get propertyOnDerivedClass");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- DerivedGetterSetterInterface* impl =
- GetWrappableOrSetException<DerivedGetterSetterInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->property_on_derived_class());
- return result;
-}
-
-void setJSpropertyOnDerivedClass(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCDerivedGetterSetterInterface", "set propertyOnDerivedClass");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- DerivedGetterSetterInterface* impl =
- GetWrappableOrSetException<DerivedGetterSetterInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<bool >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_property_on_derived_class(cobalt_value);
- }
-}
-
-JSC::EncodedJSValue functionJSderivedIndexedGetter(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCDerivedGetterSetterInterface", "call derivedIndexedGetter");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- DerivedGetterSetterInterface* impl =
- GetWrappableOrSetException<DerivedGetterSetterInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<uint32_t >::ConversionType index;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &index);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- TypeTraits<uint32_t >::ReturnType return_value = impl->DerivedIndexedGetter(index);
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSderivedIndexedSetter(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCDerivedGetterSetterInterface", "call derivedIndexedSetter");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- DerivedGetterSetterInterface* impl =
- GetWrappableOrSetException<DerivedGetterSetterInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 2;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<uint32_t >::ConversionType index;
- TypeTraits<uint32_t >::ConversionType value;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &index);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
-
- DCHECK_LT(1, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(1),
- kNoConversionFlags,
- &exception_state, &value);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->DerivedIndexedSetter(index, value);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSoperationOnDerivedClass(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCDerivedGetterSetterInterface", "call operationOnDerivedClass");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- DerivedGetterSetterInterface* impl =
- GetWrappableOrSetException<DerivedGetterSetterInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- impl->OperationOnDerivedClass();
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::JSValue IndexedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, uint32_t index) {
- TRACE_EVENT0("JSCDerivedGetterSetterInterface", "IndexedPropertyGetter");
- DerivedGetterSetterInterface* impl =
- GetWrappableOrSetException<DerivedGetterSetterInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->DerivedIndexedGetter(index));
- return result;
-}
-
-void IndexedPropertySetter(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::JSValue jsc_value) {
- TRACE_EVENT0("JSCDerivedGetterSetterInterface", "IndexedPropertySetter");
- DerivedGetterSetterInterface* impl =
- GetWrappableOrSetException<DerivedGetterSetterInterface>(exec_state, cell);
- if (!impl) {
- return;
- }
-
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- uint32_t value;
- FromJSValue(exec_state, jsc_value,
- kNoConversionFlags,
- &exception_state, &value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- impl->DerivedIndexedSetter(index, value);
-}
-
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCDerivedGetterSetterInterface", "NamedPropertyGetter");
- DerivedGetterSetterInterface* impl =
- GetWrappableOrSetException<DerivedGetterSetterInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->AnonymousNamedGetter(property_name_utf8));
- return result;
-}
-
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- DerivedGetterSetterInterface* impl =
- GetWrappableOrSetException<DerivedGetterSetterInterface>(exec_state, cell);
- if (!impl) {
- return false;
- }
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- return impl->CanQueryNamedProperty(property_name_utf8);
-}
-
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- TRACE_EVENT0("JSCDerivedGetterSetterInterface", "NamedPropertySetter");
- DerivedGetterSetterInterface* impl =
- GetWrappableOrSetException<DerivedGetterSetterInterface>(exec_state, cell);
- if (!impl) {
- return;
- }
-
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
-
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- std::string value;
- FromJSValue(exec_state, jsc_value,
- kNoConversionFlags,
- &exception_state, &value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- impl->AnonymousNamedSetter(property_name_utf8, value);
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCDerivedGetterSetterInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCDerivedGetterSetterInterface.h
deleted file mode 100644
index dd449eb..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCDerivedGetterSetterInterface.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCDerivedGetterSetterInterface_h
-#define JSCDerivedGetterSetterInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "JSCNamedIndexedGetterInterface.h"
-#include "cobalt/bindings/testing/derived_getter_setter_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCDerivedGetterSetterInterface
- : public bindings::testing::JSCNamedIndexedGetterInterface {
- typedef bindings::testing::JSCNamedIndexedGetterInterface BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- static bool getOwnPropertySlotByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state,
- uint32_t index,
- JSC::PropertySlot& slot);
-
- static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*,
- JSC::PropertyNameArray&,
- JSC::EnumerationMode);
-
- static void putByIndex(JSC::JSCell* cell, JSC::ExecState* exec_state,
- uint32_t index, JSC::JSValue value, bool should_throw);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- static bool deleteProperty(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName);
-
- static bool deletePropertyByIndex(JSC::JSCell*, JSC::ExecState*, uint32_t);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to DerivedGetterSetterInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCDerivedGetterSetterInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<DerivedGetterSetterInterface>& impl);
- ~JSCDerivedGetterSetterInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCDerivedGetterSetterInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCDerivedInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCDerivedInterface.cc
deleted file mode 100644
index 34a3976..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCDerivedInterface.cc
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCDerivedInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::DerivedInterface;
-using cobalt::bindings::testing::JSCDerivedInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSderivedAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-JSC::EncodedJSValue constructorJSDerivedInterface(JSC::ExecState*);
-JSC::EncodedJSValue functionJSderivedOperation(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = false;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCDerivedInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCDerivedInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCDerivedInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCDerivedInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCDerivedInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCDerivedInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCDerivedInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCDerivedInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCDerivedInterface::InterfaceObject::s_info = {
- "DerivedInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCDerivedInterface::InterfaceObject)
-}; // JSCDerivedInterface::InterfaceObject::s_info
-
-void JSCDerivedInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCDerivedInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCDerivedInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, &constructorJSDerivedInterface);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "DerivedInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCDerivedInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCDerivedInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCDerivedInterface::Prototype::property_table_values[] = {
- { "derivedOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSderivedOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCDerivedInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCDerivedInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCDerivedInterface::Prototype::property_table_prototype = {
- 9, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCDerivedInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCDerivedInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCDerivedInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCDerivedInterface::Prototype::s_info = {
- "DerivedInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCDerivedInterface::Prototype)
-}; // JSCDerivedInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCDerivedInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCDerivedInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype =
- bindings::testing::JSCBaseInterface::GetPrototype(global_object);
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCDerivedInterface::Prototype class
-
-const JSC::HashTableValue JSCDerivedInterface::property_table_values[] = {
- { "derivedAttribute",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJSderivedAttribute),
- 0,
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCDerivedInterface::property_table_values
-
-// static
-const JSC::HashTable JSCDerivedInterface::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCDerivedInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCDerivedInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCDerivedInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCDerivedInterface::NonTrivialStaticFields>
- JSCDerivedInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCDerivedInterface::s_info = {
- "DerivedInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCDerivedInterface)
-}; // JSCDerivedInterface::s_info
-
-// static
-JSC::JSObject* JSCDerivedInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCDerivedInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCDerivedInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCDerivedInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == DerivedInterface::DerivedInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match DerivedInterface::DerivedInterfaceWrappableType()";
- return NULL;
- }
- DerivedInterface* impl_ptr =
- base::polymorphic_downcast<DerivedInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCDerivedInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCDerivedInterface>(global_data.heap))
- JSCDerivedInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCDerivedInterface::JSCDerivedInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<DerivedInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCDerivedInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCDerivedInterface::~JSCDerivedInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCDerivedInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCDerivedInterface* this_object = JSC::jsCast<JSCDerivedInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCDerivedInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCDerivedInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCDerivedInterface* this_object = JSC::jsCast<JSCDerivedInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCDerivedInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCDerivedInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCDerivedInterface* this_object = JSC::jsCast<JSCDerivedInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCDerivedInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSderivedAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCDerivedInterface", "get derivedAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- DerivedInterface* impl =
- GetWrappableOrSetException<DerivedInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->derived_attribute());
- return result;
-}
-
-JSC::EncodedJSValue constructorJSDerivedInterface(JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- scoped_refptr<DerivedInterface> new_object =
- new DerivedInterface();
- return JSC::JSValue::encode(ToJSValue(global_object, new_object));
-
-}
-
-JSC::EncodedJSValue functionJSderivedOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCDerivedInterface", "call derivedOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- DerivedInterface* impl =
- GetWrappableOrSetException<DerivedInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- impl->DerivedOperation();
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCDerivedInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCDerivedInterface.h
deleted file mode 100644
index 1aa746e..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCDerivedInterface.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCDerivedInterface_h
-#define JSCDerivedInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "JSCBaseInterface.h"
-#include "cobalt/bindings/testing/derived_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCDerivedInterface
- : public bindings::testing::JSCBaseInterface {
- typedef bindings::testing::JSCBaseInterface BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to DerivedInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCDerivedInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<DerivedInterface>& impl);
- ~JSCDerivedInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCDerivedInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCDisabledInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCDisabledInterface.cc
deleted file mode 100644
index dc31ae1..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCDisabledInterface.cc
+++ /dev/null
@@ -1,792 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#if defined(NO_ENABLE_CONDITIONAL_INTERFACE)
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCDisabledInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::DisabledInterface;
-using cobalt::bindings::testing::JSCDisabledInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSdisabledProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSdisabledProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::EncodedJSValue functionJSdisabledFunction(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCDisabledInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCDisabledInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCDisabledInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCDisabledInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCDisabledInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCDisabledInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCDisabledInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCDisabledInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCDisabledInterface::InterfaceObject::s_info = {
- "DisabledInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCDisabledInterface::InterfaceObject)
-}; // JSCDisabledInterface::InterfaceObject::s_info
-
-void JSCDisabledInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCDisabledInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCDisabledInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "DisabledInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCDisabledInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCDisabledInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCDisabledInterface::Prototype::property_table_values[] = {
- { "disabledFunction",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSdisabledFunction),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCDisabledInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCDisabledInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCDisabledInterface::Prototype::property_table_prototype = {
- 9, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCDisabledInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCDisabledInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCDisabledInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCDisabledInterface::Prototype::s_info = {
- "DisabledInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCDisabledInterface::Prototype)
-}; // JSCDisabledInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCDisabledInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCDisabledInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCDisabledInterface::Prototype class
-
-const JSC::HashTableValue JSCDisabledInterface::property_table_values[] = {
- { "disabledProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSdisabledProperty),
- reinterpret_cast<intptr_t>(setJSdisabledProperty),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCDisabledInterface::property_table_values
-
-// static
-const JSC::HashTable JSCDisabledInterface::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCDisabledInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCDisabledInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCDisabledInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCDisabledInterface::NonTrivialStaticFields>
- JSCDisabledInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCDisabledInterface::s_info = {
- "DisabledInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCDisabledInterface)
-}; // JSCDisabledInterface::s_info
-
-// static
-JSC::JSObject* JSCDisabledInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCDisabledInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCDisabledInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCDisabledInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == DisabledInterface::DisabledInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match DisabledInterface::DisabledInterfaceWrappableType()";
- return NULL;
- }
- DisabledInterface* impl_ptr =
- base::polymorphic_downcast<DisabledInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCDisabledInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCDisabledInterface>(global_data.heap))
- JSCDisabledInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCDisabledInterface::JSCDisabledInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<DisabledInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCDisabledInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCDisabledInterface::~JSCDisabledInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCDisabledInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCDisabledInterface* this_object = JSC::jsCast<JSCDisabledInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCDisabledInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCDisabledInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCDisabledInterface* this_object = JSC::jsCast<JSCDisabledInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCDisabledInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCDisabledInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCDisabledInterface* this_object = JSC::jsCast<JSCDisabledInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCDisabledInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSdisabledProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCDisabledInterface", "get disabledProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- DisabledInterface* impl =
- GetWrappableOrSetException<DisabledInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->disabled_property());
- return result;
-}
-
-void setJSdisabledProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCDisabledInterface", "set disabledProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- DisabledInterface* impl =
- GetWrappableOrSetException<DisabledInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<int32_t >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_disabled_property(cobalt_value);
- }
-}
-
-JSC::EncodedJSValue functionJSdisabledFunction(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCDisabledInterface", "call disabledFunction");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- DisabledInterface* impl =
- GetWrappableOrSetException<DisabledInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- impl->DisabledFunction();
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
-#endif // defined(NO_ENABLE_CONDITIONAL_INTERFACE)
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCDisabledInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCDisabledInterface.h
deleted file mode 100644
index f03711f..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCDisabledInterface.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCDisabledInterface_h
-#define JSCDisabledInterface_h
-
-#if defined(NO_ENABLE_CONDITIONAL_INTERFACE)
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/disabled_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCDisabledInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to DisabledInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCDisabledInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<DisabledInterface>& impl);
- ~JSCDisabledInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // defined(NO_ENABLE_CONDITIONAL_INTERFACE)
-
-#endif // JSCDisabledInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCEnumerationInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCEnumerationInterface.cc
deleted file mode 100644
index 94267fc..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCEnumerationInterface.cc
+++ /dev/null
@@ -1,812 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCEnumerationInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::EnumerationInterface;
-using cobalt::bindings::testing::JSCEnumerationInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-// Declare and define these in the same namespace that the other overloads
-// were brought into with the using declaration.
-JSC::JSValue ToJSValue(JSCGlobalObject*, EnumerationInterface::TestEnum in_enum);
-void FromJSValue(JSC::ExecState* exec_state, JSC::JSValue jsvalue,
- int conversion_flags, JSCExceptionState* exception_state,
- EnumerationInterface::TestEnum* out_enum);
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSenumProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSenumProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::EncodedJSValue constructorJSEnumerationInterface(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCEnumerationInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCEnumerationInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCEnumerationInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCEnumerationInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCEnumerationInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCEnumerationInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCEnumerationInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCEnumerationInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCEnumerationInterface::InterfaceObject::s_info = {
- "EnumerationInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCEnumerationInterface::InterfaceObject)
-}; // JSCEnumerationInterface::InterfaceObject::s_info
-
-void JSCEnumerationInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCEnumerationInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCEnumerationInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, &constructorJSEnumerationInterface);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "EnumerationInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCEnumerationInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCEnumerationInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCEnumerationInterface::Prototype::property_table_values[] = {
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCEnumerationInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCEnumerationInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCEnumerationInterface::Prototype::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCEnumerationInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCEnumerationInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCEnumerationInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCEnumerationInterface::Prototype::s_info = {
- "EnumerationInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCEnumerationInterface::Prototype)
-}; // JSCEnumerationInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCEnumerationInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCEnumerationInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCEnumerationInterface::Prototype class
-
-const JSC::HashTableValue JSCEnumerationInterface::property_table_values[] = {
- { "enumProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSenumProperty),
- reinterpret_cast<intptr_t>(setJSenumProperty),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCEnumerationInterface::property_table_values
-
-// static
-const JSC::HashTable JSCEnumerationInterface::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCEnumerationInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCEnumerationInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCEnumerationInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCEnumerationInterface::NonTrivialStaticFields>
- JSCEnumerationInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCEnumerationInterface::s_info = {
- "EnumerationInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCEnumerationInterface)
-}; // JSCEnumerationInterface::s_info
-
-// static
-JSC::JSObject* JSCEnumerationInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCEnumerationInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCEnumerationInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCEnumerationInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == EnumerationInterface::EnumerationInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match EnumerationInterface::EnumerationInterfaceWrappableType()";
- return NULL;
- }
- EnumerationInterface* impl_ptr =
- base::polymorphic_downcast<EnumerationInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCEnumerationInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCEnumerationInterface>(global_data.heap))
- JSCEnumerationInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCEnumerationInterface::JSCEnumerationInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<EnumerationInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCEnumerationInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCEnumerationInterface::~JSCEnumerationInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCEnumerationInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCEnumerationInterface* this_object = JSC::jsCast<JSCEnumerationInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCEnumerationInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCEnumerationInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCEnumerationInterface* this_object = JSC::jsCast<JSCEnumerationInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCEnumerationInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCEnumerationInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCEnumerationInterface* this_object = JSC::jsCast<JSCEnumerationInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCEnumerationInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSenumProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCEnumerationInterface", "get enumProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- EnumerationInterface* impl =
- GetWrappableOrSetException<EnumerationInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->enum_property());
- return result;
-}
-
-void setJSenumProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCEnumerationInterface", "set enumProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- EnumerationInterface* impl =
- GetWrappableOrSetException<EnumerationInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<EnumerationInterface::TestEnum >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_enum_property(cobalt_value);
- }
-}
-
-JSC::EncodedJSValue constructorJSEnumerationInterface(JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- scoped_refptr<EnumerationInterface> new_object =
- new EnumerationInterface();
- return JSC::JSValue::encode(ToJSValue(global_object, new_object));
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
-
-namespace {
-JSC::JSValue ToJSValue(JSCGlobalObject* global_object, EnumerationInterface::TestEnum in_enum) {
- JSC::JSGlobalData* global_data = &(global_object->globalData());
- switch (in_enum) {
- case EnumerationInterface::kAlpha: return JSC::jsString(global_data, "alpha");
- case EnumerationInterface::kBeta: return JSC::jsString(global_data, "beta");
- case EnumerationInterface::kGamma: return JSC::jsString(global_data, "gamma");
- default:
- NOTREACHED();
- return JSC::jsUndefined();
- }
-}
-void FromJSValue(JSC::ExecState* exec_state, JSC::JSValue jsvalue,
- int conversion_flags, JSCExceptionState* exception_state,
- EnumerationInterface::TestEnum* out_enum) {
- DCHECK_EQ(0, conversion_flags) << "Unexpected conversion flags.";
- // JSValue -> IDL enum algorithm described here:
- // http://heycam.github.io/webidl/#es-enumeration
-
- // 1. Let S be the result of calling ToString(V).
- JSC::JSString* js_string = jsvalue.toString(exec_state);
- if (exec_state->hadException()) {
- DLOG(WARNING) << "Exception converting value to string";
- return;
- }
- const WTF::String& wtf_string = js_string->tryGetValue();
- // 3. Return the enumeration value of type E that is equal to S.
-if (wtf_string == "alpha") {
- *out_enum = EnumerationInterface::kAlpha;
- } else if (wtf_string == "beta") {
- *out_enum = EnumerationInterface::kBeta;
- } else if (wtf_string == "gamma") {
- *out_enum = EnumerationInterface::kGamma;
- } else {
- // 2. If S is not one of E's enumeration values, then throw a TypeError.
- JSC::throwTypeError(exec_state);
- }
-}
-} // namespace
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCEnumerationInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCEnumerationInterface.h
deleted file mode 100644
index 3f1cd55..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCEnumerationInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCEnumerationInterface_h
-#define JSCEnumerationInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/enumeration_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCEnumerationInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to EnumerationInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCEnumerationInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<EnumerationInterface>& impl);
- ~JSCEnumerationInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCEnumerationInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCExceptionObjectInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCExceptionObjectInterface.cc
deleted file mode 100644
index 8ba3dbf..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCExceptionObjectInterface.cc
+++ /dev/null
@@ -1,764 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCExceptionObjectInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ErrorPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::ExceptionObjectInterface;
-using cobalt::bindings::testing::JSCExceptionObjectInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSerror(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-JSC::JSValue getJSmessage(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCExceptionObjectInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCExceptionObjectInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCExceptionObjectInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCExceptionObjectInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCExceptionObjectInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCExceptionObjectInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCExceptionObjectInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCExceptionObjectInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCExceptionObjectInterface::InterfaceObject::s_info = {
- "ExceptionObjectInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCExceptionObjectInterface::InterfaceObject)
-}; // JSCExceptionObjectInterface::InterfaceObject::s_info
-
-void JSCExceptionObjectInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCExceptionObjectInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCExceptionObjectInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "ExceptionObjectInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCExceptionObjectInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCExceptionObjectInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCExceptionObjectInterface::Prototype::property_table_values[] = {
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCExceptionObjectInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCExceptionObjectInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCExceptionObjectInterface::Prototype::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCExceptionObjectInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCExceptionObjectInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCExceptionObjectInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCExceptionObjectInterface::Prototype::s_info = {
- "ExceptionObjectInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCExceptionObjectInterface::Prototype)
-}; // JSCExceptionObjectInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCExceptionObjectInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCExceptionObjectInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->errorPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCExceptionObjectInterface::Prototype class
-
-const JSC::HashTableValue JSCExceptionObjectInterface::property_table_values[] = {
- { "error",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJSerror),
- 0,
- JSC::NoIntrinsic
- },
- { "message",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJSmessage),
- 0,
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCExceptionObjectInterface::property_table_values
-
-// static
-const JSC::HashTable JSCExceptionObjectInterface::property_table_prototype = {
- 9, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCExceptionObjectInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCExceptionObjectInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCExceptionObjectInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCExceptionObjectInterface::NonTrivialStaticFields>
- JSCExceptionObjectInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCExceptionObjectInterface::s_info = {
- "ExceptionObjectInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCExceptionObjectInterface)
-}; // JSCExceptionObjectInterface::s_info
-
-// static
-JSC::JSObject* JSCExceptionObjectInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCExceptionObjectInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCExceptionObjectInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCExceptionObjectInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == ExceptionObjectInterface::ExceptionObjectInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match ExceptionObjectInterface::ExceptionObjectInterfaceWrappableType()";
- return NULL;
- }
- ExceptionObjectInterface* impl_ptr =
- base::polymorphic_downcast<ExceptionObjectInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ErrorInstanceType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCExceptionObjectInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCExceptionObjectInterface>(global_data.heap))
- JSCExceptionObjectInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- global_data.heap.addFinalizer(wrapper, destroy);
- return wrapper;
-}
-JSCExceptionObjectInterface::JSCExceptionObjectInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<ExceptionObjectInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCExceptionObjectInterface::finishCreation(JSC::JSGlobalData& global_data) {
- WTF::String error_message = ToWTFString(wrappable()->message());
- BaseClass::finishCreation(global_data, error_message);
- DCHECK(inherits(&s_info));
-}
-
-JSCExceptionObjectInterface::~JSCExceptionObjectInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCExceptionObjectInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCExceptionObjectInterface* this_object = JSC::jsCast<JSCExceptionObjectInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCExceptionObjectInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCExceptionObjectInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCExceptionObjectInterface* this_object = JSC::jsCast<JSCExceptionObjectInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCExceptionObjectInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCExceptionObjectInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCExceptionObjectInterface* this_object = JSC::jsCast<JSCExceptionObjectInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCExceptionObjectInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSerror(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCExceptionObjectInterface", "get error");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ExceptionObjectInterface* impl =
- GetWrappableOrSetException<ExceptionObjectInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->error());
- return result;
-}
-
-JSC::JSValue getJSmessage(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCExceptionObjectInterface", "get message");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ExceptionObjectInterface* impl =
- GetWrappableOrSetException<ExceptionObjectInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->message());
- return result;
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCExceptionObjectInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCExceptionObjectInterface.h
deleted file mode 100644
index 9e1f2bc..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCExceptionObjectInterface.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCExceptionObjectInterface_h
-#define JSCExceptionObjectInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/exception_object_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ErrorInstance.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCExceptionObjectInterface
- : public script::javascriptcore::ExceptionBase {
- typedef script::javascriptcore::ExceptionBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to ExceptionObjectInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCExceptionObjectInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<ExceptionObjectInterface>& impl);
- ~JSCExceptionObjectInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCExceptionObjectInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCExceptionsInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCExceptionsInterface.cc
deleted file mode 100644
index 2dab46e..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCExceptionsInterface.cc
+++ /dev/null
@@ -1,805 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCExceptionsInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::ExceptionsInterface;
-using cobalt::bindings::testing::JSCExceptionsInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSattributeThrowsException(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSattributeThrowsException(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::EncodedJSValue constructorJSExceptionsInterface(JSC::ExecState*);
-JSC::EncodedJSValue functionJSfunctionThrowsException(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCExceptionsInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCExceptionsInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCExceptionsInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCExceptionsInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCExceptionsInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCExceptionsInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCExceptionsInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCExceptionsInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCExceptionsInterface::InterfaceObject::s_info = {
- "ExceptionsInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCExceptionsInterface::InterfaceObject)
-}; // JSCExceptionsInterface::InterfaceObject::s_info
-
-void JSCExceptionsInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCExceptionsInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCExceptionsInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, &constructorJSExceptionsInterface);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "ExceptionsInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCExceptionsInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCExceptionsInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCExceptionsInterface::Prototype::property_table_values[] = {
- { "functionThrowsException",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSfunctionThrowsException),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCExceptionsInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCExceptionsInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCExceptionsInterface::Prototype::property_table_prototype = {
- 9, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCExceptionsInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCExceptionsInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCExceptionsInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCExceptionsInterface::Prototype::s_info = {
- "ExceptionsInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCExceptionsInterface::Prototype)
-}; // JSCExceptionsInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCExceptionsInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCExceptionsInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCExceptionsInterface::Prototype class
-
-const JSC::HashTableValue JSCExceptionsInterface::property_table_values[] = {
- { "attributeThrowsException",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSattributeThrowsException),
- reinterpret_cast<intptr_t>(setJSattributeThrowsException),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCExceptionsInterface::property_table_values
-
-// static
-const JSC::HashTable JSCExceptionsInterface::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCExceptionsInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCExceptionsInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCExceptionsInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCExceptionsInterface::NonTrivialStaticFields>
- JSCExceptionsInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCExceptionsInterface::s_info = {
- "ExceptionsInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCExceptionsInterface)
-}; // JSCExceptionsInterface::s_info
-
-// static
-JSC::JSObject* JSCExceptionsInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCExceptionsInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCExceptionsInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCExceptionsInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == ExceptionsInterface::ExceptionsInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match ExceptionsInterface::ExceptionsInterfaceWrappableType()";
- return NULL;
- }
- ExceptionsInterface* impl_ptr =
- base::polymorphic_downcast<ExceptionsInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCExceptionsInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCExceptionsInterface>(global_data.heap))
- JSCExceptionsInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCExceptionsInterface::JSCExceptionsInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<ExceptionsInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCExceptionsInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCExceptionsInterface::~JSCExceptionsInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCExceptionsInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCExceptionsInterface* this_object = JSC::jsCast<JSCExceptionsInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCExceptionsInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCExceptionsInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCExceptionsInterface* this_object = JSC::jsCast<JSCExceptionsInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCExceptionsInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCExceptionsInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCExceptionsInterface* this_object = JSC::jsCast<JSCExceptionsInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCExceptionsInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSattributeThrowsException(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCExceptionsInterface", "get attributeThrowsException");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ExceptionsInterface* impl =
- GetWrappableOrSetException<ExceptionsInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
- JSCExceptionState exception_state(global_object);
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->attribute_throws_exception(&exception_state));
- if (exception_state.is_exception_set()) {
- return JSC::throwError(exec_state, exception_state.exception_object());
- }
- return result;
-}
-
-void setJSattributeThrowsException(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCExceptionsInterface", "set attributeThrowsException");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- ExceptionsInterface* impl =
- GetWrappableOrSetException<ExceptionsInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<bool >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_attribute_throws_exception(cobalt_value, &exception_state);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- }
- }
-}
-
-JSC::EncodedJSValue constructorJSExceptionsInterface(JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- scoped_refptr<ExceptionsInterface> new_object =
- new ExceptionsInterface(&exception_state);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- return JSC::JSValue::encode(ToJSValue(global_object, new_object));
-
-}
-
-JSC::EncodedJSValue functionJSfunctionThrowsException(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCExceptionsInterface", "call functionThrowsException");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- ExceptionsInterface* impl =
- GetWrappableOrSetException<ExceptionsInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- impl->FunctionThrowsException(&exception_state);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCExceptionsInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCExceptionsInterface.h
deleted file mode 100644
index 8cf99e2..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCExceptionsInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCExceptionsInterface_h
-#define JSCExceptionsInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/exceptions_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCExceptionsInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to ExceptionsInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCExceptionsInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<ExceptionsInterface>& impl);
- ~JSCExceptionsInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCExceptionsInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCExtendedIDLAttributesInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCExtendedIDLAttributesInterface.cc
deleted file mode 100644
index 50b3d7a..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCExtendedIDLAttributesInterface.cc
+++ /dev/null
@@ -1,729 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCExtendedIDLAttributesInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::ExtendedIDLAttributesInterface;
-using cobalt::bindings::testing::JSCExtendedIDLAttributesInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::EncodedJSValue functionJScallWithSettings(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCExtendedIDLAttributesInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCExtendedIDLAttributesInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCExtendedIDLAttributesInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCExtendedIDLAttributesInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCExtendedIDLAttributesInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCExtendedIDLAttributesInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCExtendedIDLAttributesInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCExtendedIDLAttributesInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCExtendedIDLAttributesInterface::InterfaceObject::s_info = {
- "ExtendedIDLAttributesInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCExtendedIDLAttributesInterface::InterfaceObject)
-}; // JSCExtendedIDLAttributesInterface::InterfaceObject::s_info
-
-void JSCExtendedIDLAttributesInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCExtendedIDLAttributesInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCExtendedIDLAttributesInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "ExtendedIDLAttributesInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCExtendedIDLAttributesInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCExtendedIDLAttributesInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCExtendedIDLAttributesInterface::Prototype::property_table_values[] = {
- { "callWithSettings",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJScallWithSettings),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCExtendedIDLAttributesInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCExtendedIDLAttributesInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCExtendedIDLAttributesInterface::Prototype::property_table_prototype = {
- 9, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCExtendedIDLAttributesInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCExtendedIDLAttributesInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCExtendedIDLAttributesInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCExtendedIDLAttributesInterface::Prototype::s_info = {
- "ExtendedIDLAttributesInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCExtendedIDLAttributesInterface::Prototype)
-}; // JSCExtendedIDLAttributesInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCExtendedIDLAttributesInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCExtendedIDLAttributesInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCExtendedIDLAttributesInterface::Prototype class
-
-const JSC::HashTableValue JSCExtendedIDLAttributesInterface::property_table_values[] = {
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCExtendedIDLAttributesInterface::property_table_values
-
-// static
-const JSC::HashTable JSCExtendedIDLAttributesInterface::property_table_prototype = {
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCExtendedIDLAttributesInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCExtendedIDLAttributesInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCExtendedIDLAttributesInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCExtendedIDLAttributesInterface::NonTrivialStaticFields>
- JSCExtendedIDLAttributesInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCExtendedIDLAttributesInterface::s_info = {
- "ExtendedIDLAttributesInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCExtendedIDLAttributesInterface)
-}; // JSCExtendedIDLAttributesInterface::s_info
-
-// static
-JSC::JSObject* JSCExtendedIDLAttributesInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCExtendedIDLAttributesInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCExtendedIDLAttributesInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCExtendedIDLAttributesInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == ExtendedIDLAttributesInterface::ExtendedIDLAttributesInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match ExtendedIDLAttributesInterface::ExtendedIDLAttributesInterfaceWrappableType()";
- return NULL;
- }
- ExtendedIDLAttributesInterface* impl_ptr =
- base::polymorphic_downcast<ExtendedIDLAttributesInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCExtendedIDLAttributesInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCExtendedIDLAttributesInterface>(global_data.heap))
- JSCExtendedIDLAttributesInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCExtendedIDLAttributesInterface::JSCExtendedIDLAttributesInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<ExtendedIDLAttributesInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCExtendedIDLAttributesInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCExtendedIDLAttributesInterface::~JSCExtendedIDLAttributesInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCExtendedIDLAttributesInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCExtendedIDLAttributesInterface* this_object = JSC::jsCast<JSCExtendedIDLAttributesInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCExtendedIDLAttributesInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCExtendedIDLAttributesInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCExtendedIDLAttributesInterface* this_object = JSC::jsCast<JSCExtendedIDLAttributesInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCExtendedIDLAttributesInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCExtendedIDLAttributesInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCExtendedIDLAttributesInterface* this_object = JSC::jsCast<JSCExtendedIDLAttributesInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCExtendedIDLAttributesInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::EncodedJSValue functionJScallWithSettings(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCExtendedIDLAttributesInterface", "call callWithSettings");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- ExtendedIDLAttributesInterface* impl =
- GetWrappableOrSetException<ExtendedIDLAttributesInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- impl->CallWithSettings(global_object->GetEnvironmentSettings());
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCExtendedIDLAttributesInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCExtendedIDLAttributesInterface.h
deleted file mode 100644
index 42e2316..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCExtendedIDLAttributesInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCExtendedIDLAttributesInterface_h
-#define JSCExtendedIDLAttributesInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/extended_idl_attributes_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCExtendedIDLAttributesInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to ExtendedIDLAttributesInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCExtendedIDLAttributesInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<ExtendedIDLAttributesInterface>& impl);
- ~JSCExtendedIDLAttributesInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCExtendedIDLAttributesInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCGarbageCollectionTestInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCGarbageCollectionTestInterface.cc
deleted file mode 100644
index 035124a..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCGarbageCollectionTestInterface.cc
+++ /dev/null
@@ -1,838 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCGarbageCollectionTestInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-#include "JSCGarbageCollectionTestInterface.h"
-#include "cobalt/bindings/testing/garbage_collection_test_interface.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::GarbageCollectionTestInterface;
-using cobalt::bindings::testing::JSCGarbageCollectionTestInterface;
-using cobalt::bindings::testing::GarbageCollectionTestInterface;
-using cobalt::bindings::testing::JSCGarbageCollectionTestInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSprevious(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSprevious(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSnext(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSnext(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::EncodedJSValue constructorJSGarbageCollectionTestInterface(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-scoped_refptr<Wrappable> GetOpaqueRootFromWrappable(
- const scoped_refptr<Wrappable>& wrappable) {
- GarbageCollectionTestInterface* impl =
- base::polymorphic_downcast<GarbageCollectionTestInterface*>(wrappable.get());
- Wrappable* opaque_root = impl->GetHead();
- return make_scoped_refptr<Wrappable>(opaque_root);
-}
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCGarbageCollectionTestInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCGarbageCollectionTestInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCGarbageCollectionTestInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCGarbageCollectionTestInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCGarbageCollectionTestInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCGarbageCollectionTestInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCGarbageCollectionTestInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCGarbageCollectionTestInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCGarbageCollectionTestInterface::InterfaceObject::s_info = {
- "GarbageCollectionTestInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCGarbageCollectionTestInterface::InterfaceObject)
-}; // JSCGarbageCollectionTestInterface::InterfaceObject::s_info
-
-void JSCGarbageCollectionTestInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCGarbageCollectionTestInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCGarbageCollectionTestInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, &constructorJSGarbageCollectionTestInterface);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "GarbageCollectionTestInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCGarbageCollectionTestInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCGarbageCollectionTestInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCGarbageCollectionTestInterface::Prototype::property_table_values[] = {
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCGarbageCollectionTestInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCGarbageCollectionTestInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCGarbageCollectionTestInterface::Prototype::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCGarbageCollectionTestInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCGarbageCollectionTestInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCGarbageCollectionTestInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCGarbageCollectionTestInterface::Prototype::s_info = {
- "GarbageCollectionTestInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCGarbageCollectionTestInterface::Prototype)
-}; // JSCGarbageCollectionTestInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCGarbageCollectionTestInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCGarbageCollectionTestInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCGarbageCollectionTestInterface::Prototype class
-
-const JSC::HashTableValue JSCGarbageCollectionTestInterface::property_table_values[] = {
- { "previous",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSprevious),
- reinterpret_cast<intptr_t>(setJSprevious),
- JSC::NoIntrinsic
- },
- { "next",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSnext),
- reinterpret_cast<intptr_t>(setJSnext),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCGarbageCollectionTestInterface::property_table_values
-
-// static
-const JSC::HashTable JSCGarbageCollectionTestInterface::property_table_prototype = {
- 9, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCGarbageCollectionTestInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCGarbageCollectionTestInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCGarbageCollectionTestInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCGarbageCollectionTestInterface::NonTrivialStaticFields>
- JSCGarbageCollectionTestInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCGarbageCollectionTestInterface::s_info = {
- "GarbageCollectionTestInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCGarbageCollectionTestInterface)
-}; // JSCGarbageCollectionTestInterface::s_info
-
-// static
-JSC::JSObject* JSCGarbageCollectionTestInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCGarbageCollectionTestInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCGarbageCollectionTestInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCGarbageCollectionTestInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == GarbageCollectionTestInterface::GarbageCollectionTestInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match GarbageCollectionTestInterface::GarbageCollectionTestInterfaceWrappableType()";
- return NULL;
- }
- GarbageCollectionTestInterface* impl_ptr =
- base::polymorphic_downcast<GarbageCollectionTestInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCGarbageCollectionTestInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCGarbageCollectionTestInterface>(global_data.heap))
- JSCGarbageCollectionTestInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCGarbageCollectionTestInterface::JSCGarbageCollectionTestInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<GarbageCollectionTestInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
- set_get_opaque_root_function(base::Bind(&GetOpaqueRootFromWrappable));
-}
-
-void JSCGarbageCollectionTestInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCGarbageCollectionTestInterface::~JSCGarbageCollectionTestInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCGarbageCollectionTestInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCGarbageCollectionTestInterface* this_object = JSC::jsCast<JSCGarbageCollectionTestInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCGarbageCollectionTestInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCGarbageCollectionTestInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCGarbageCollectionTestInterface* this_object = JSC::jsCast<JSCGarbageCollectionTestInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCGarbageCollectionTestInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCGarbageCollectionTestInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCGarbageCollectionTestInterface* this_object = JSC::jsCast<JSCGarbageCollectionTestInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCGarbageCollectionTestInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSprevious(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCGarbageCollectionTestInterface", "get previous");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- GarbageCollectionTestInterface* impl =
- GetWrappableOrSetException<GarbageCollectionTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->previous());
- return result;
-}
-
-void setJSprevious(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCGarbageCollectionTestInterface", "set previous");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- GarbageCollectionTestInterface* impl =
- GetWrappableOrSetException<GarbageCollectionTestInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<scoped_refptr<GarbageCollectionTestInterface> >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- (kConversionFlagNullable), &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_previous(cobalt_value);
- }
-}
-
-JSC::JSValue getJSnext(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCGarbageCollectionTestInterface", "get next");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- GarbageCollectionTestInterface* impl =
- GetWrappableOrSetException<GarbageCollectionTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->next());
- return result;
-}
-
-void setJSnext(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCGarbageCollectionTestInterface", "set next");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- GarbageCollectionTestInterface* impl =
- GetWrappableOrSetException<GarbageCollectionTestInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<scoped_refptr<GarbageCollectionTestInterface> >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- (kConversionFlagNullable), &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_next(cobalt_value);
- }
-}
-
-JSC::EncodedJSValue constructorJSGarbageCollectionTestInterface(JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- scoped_refptr<GarbageCollectionTestInterface> new_object =
- new GarbageCollectionTestInterface();
- return JSC::JSValue::encode(ToJSValue(global_object, new_object));
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCGarbageCollectionTestInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCGarbageCollectionTestInterface.h
deleted file mode 100644
index 58ef5c2..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCGarbageCollectionTestInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCGarbageCollectionTestInterface_h
-#define JSCGarbageCollectionTestInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/garbage_collection_test_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCGarbageCollectionTestInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to GarbageCollectionTestInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCGarbageCollectionTestInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<GarbageCollectionTestInterface>& impl);
- ~JSCGarbageCollectionTestInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCGarbageCollectionTestInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCGetOpaqueRootInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCGetOpaqueRootInterface.cc
deleted file mode 100644
index 25312f8..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCGetOpaqueRootInterface.cc
+++ /dev/null
@@ -1,730 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCGetOpaqueRootInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::GetOpaqueRootInterface;
-using cobalt::bindings::testing::JSCGetOpaqueRootInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::EncodedJSValue constructorJSGetOpaqueRootInterface(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-scoped_refptr<Wrappable> GetOpaqueRootFromWrappable(
- const scoped_refptr<Wrappable>& wrappable) {
- GetOpaqueRootInterface* impl =
- base::polymorphic_downcast<GetOpaqueRootInterface*>(wrappable.get());
- Wrappable* opaque_root = impl->get_opaque_root_function_name();
- return make_scoped_refptr<Wrappable>(opaque_root);
-}
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCGetOpaqueRootInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCGetOpaqueRootInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCGetOpaqueRootInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCGetOpaqueRootInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCGetOpaqueRootInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCGetOpaqueRootInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCGetOpaqueRootInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCGetOpaqueRootInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCGetOpaqueRootInterface::InterfaceObject::s_info = {
- "GetOpaqueRootInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCGetOpaqueRootInterface::InterfaceObject)
-}; // JSCGetOpaqueRootInterface::InterfaceObject::s_info
-
-void JSCGetOpaqueRootInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCGetOpaqueRootInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCGetOpaqueRootInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, &constructorJSGetOpaqueRootInterface);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "GetOpaqueRootInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCGetOpaqueRootInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCGetOpaqueRootInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCGetOpaqueRootInterface::Prototype::property_table_values[] = {
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCGetOpaqueRootInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCGetOpaqueRootInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCGetOpaqueRootInterface::Prototype::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCGetOpaqueRootInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCGetOpaqueRootInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCGetOpaqueRootInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCGetOpaqueRootInterface::Prototype::s_info = {
- "GetOpaqueRootInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCGetOpaqueRootInterface::Prototype)
-}; // JSCGetOpaqueRootInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCGetOpaqueRootInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCGetOpaqueRootInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCGetOpaqueRootInterface::Prototype class
-
-const JSC::HashTableValue JSCGetOpaqueRootInterface::property_table_values[] = {
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCGetOpaqueRootInterface::property_table_values
-
-// static
-const JSC::HashTable JSCGetOpaqueRootInterface::property_table_prototype = {
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCGetOpaqueRootInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCGetOpaqueRootInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCGetOpaqueRootInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCGetOpaqueRootInterface::NonTrivialStaticFields>
- JSCGetOpaqueRootInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCGetOpaqueRootInterface::s_info = {
- "GetOpaqueRootInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCGetOpaqueRootInterface)
-}; // JSCGetOpaqueRootInterface::s_info
-
-// static
-JSC::JSObject* JSCGetOpaqueRootInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCGetOpaqueRootInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCGetOpaqueRootInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCGetOpaqueRootInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == GetOpaqueRootInterface::GetOpaqueRootInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match GetOpaqueRootInterface::GetOpaqueRootInterfaceWrappableType()";
- return NULL;
- }
- GetOpaqueRootInterface* impl_ptr =
- base::polymorphic_downcast<GetOpaqueRootInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCGetOpaqueRootInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCGetOpaqueRootInterface>(global_data.heap))
- JSCGetOpaqueRootInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCGetOpaqueRootInterface::JSCGetOpaqueRootInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<GetOpaqueRootInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
- set_get_opaque_root_function(base::Bind(&GetOpaqueRootFromWrappable));
-}
-
-void JSCGetOpaqueRootInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCGetOpaqueRootInterface::~JSCGetOpaqueRootInterface() {
- // Empty destructor
-}
-
-void JSCGetOpaqueRootInterface::visitChildren(JSC::JSCell* cell, JSC::SlotVisitor& visitor) {
- WrapperBase<JSC::JSDestructibleObject, Wrappable>::visitChildren(
- cell, visitor);
-
- JSCGlobalObject* global_object = JSC::jsCast<JSCGlobalObject*>(
- JSC::jsCast<JSObject*>(cell)->globalObject());
-
- GetOpaqueRootInterface* impl = base::polymorphic_downcast<GetOpaqueRootInterface*>(
- JSC::jsCast<WrapperBase*>(cell)->wrappable().get());
-
- Wrappable* opaque_root0 = impl->add_opaque_root_function_name();
- if (opaque_root0) {
- visitor.addOpaqueRoot(opaque_root0);
- }
-}
-
-// Look up property slot for querying property values.
-bool JSCGetOpaqueRootInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCGetOpaqueRootInterface* this_object = JSC::jsCast<JSCGetOpaqueRootInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCGetOpaqueRootInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCGetOpaqueRootInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCGetOpaqueRootInterface* this_object = JSC::jsCast<JSCGetOpaqueRootInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCGetOpaqueRootInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCGetOpaqueRootInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCGetOpaqueRootInterface* this_object = JSC::jsCast<JSCGetOpaqueRootInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCGetOpaqueRootInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::EncodedJSValue constructorJSGetOpaqueRootInterface(JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- scoped_refptr<GetOpaqueRootInterface> new_object =
- new GetOpaqueRootInterface();
- return JSC::JSValue::encode(ToJSValue(global_object, new_object));
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCGetOpaqueRootInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCGetOpaqueRootInterface.h
deleted file mode 100644
index 4e88b6c..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCGetOpaqueRootInterface.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCGetOpaqueRootInterface_h
-#define JSCGetOpaqueRootInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/get_opaque_root_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCGetOpaqueRootInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to GetOpaqueRootInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCGetOpaqueRootInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<GetOpaqueRootInterface>& impl);
- ~JSCGetOpaqueRootInterface();
-
- static void visitChildren(JSC::JSCell* cell, JSC::SlotVisitor& visitor);
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCGetOpaqueRootInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCGlobalInterfaceParent.cc b/src/cobalt/bindings/generated/jsc/testing/JSCGlobalInterfaceParent.cc
deleted file mode 100644
index fe08052..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCGlobalInterfaceParent.cc
+++ /dev/null
@@ -1,729 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCGlobalInterfaceParent.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::GlobalInterfaceParent;
-using cobalt::bindings::testing::JSCGlobalInterfaceParent;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::EncodedJSValue functionJSparentOperation(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCGlobalInterfaceParent::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCGlobalInterfaceParent";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCGlobalInterfaceParent::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCGlobalInterfaceParent::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCGlobalInterfaceParent::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCGlobalInterfaceParent::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCGlobalInterfaceParent::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCGlobalInterfaceParent::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCGlobalInterfaceParent::InterfaceObject::s_info = {
- "GlobalInterfaceParentConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCGlobalInterfaceParent::InterfaceObject)
-}; // JSCGlobalInterfaceParent::InterfaceObject::s_info
-
-void JSCGlobalInterfaceParent::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCGlobalInterfaceParent::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCGlobalInterfaceParent::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "GlobalInterfaceParent");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCGlobalInterfaceParent::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCGlobalInterfaceParent::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCGlobalInterfaceParent::Prototype::property_table_values[] = {
- { "parentOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSparentOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCGlobalInterfaceParent::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCGlobalInterfaceParent::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCGlobalInterfaceParent::Prototype::property_table_prototype = {
- 9, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCGlobalInterfaceParent::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCGlobalInterfaceParent::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCGlobalInterfaceParent::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCGlobalInterfaceParent::Prototype::s_info = {
- "GlobalInterfaceParentPrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCGlobalInterfaceParent::Prototype)
-}; // JSCGlobalInterfaceParent::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCGlobalInterfaceParent::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCGlobalInterfaceParent::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCGlobalInterfaceParent::Prototype class
-
-const JSC::HashTableValue JSCGlobalInterfaceParent::property_table_values[] = {
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCGlobalInterfaceParent::property_table_values
-
-// static
-const JSC::HashTable JSCGlobalInterfaceParent::property_table_prototype = {
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCGlobalInterfaceParent::property_table_prototype
-
-// static
-const JSC::HashTable* JSCGlobalInterfaceParent::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCGlobalInterfaceParent::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCGlobalInterfaceParent::NonTrivialStaticFields>
- JSCGlobalInterfaceParent::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCGlobalInterfaceParent::s_info = {
- "GlobalInterfaceParent", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCGlobalInterfaceParent)
-}; // JSCGlobalInterfaceParent::s_info
-
-// static
-JSC::JSObject* JSCGlobalInterfaceParent::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCGlobalInterfaceParent::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCGlobalInterfaceParent::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCGlobalInterfaceParent::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == GlobalInterfaceParent::GlobalInterfaceParentWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match GlobalInterfaceParent::GlobalInterfaceParentWrappableType()";
- return NULL;
- }
- GlobalInterfaceParent* impl_ptr =
- base::polymorphic_downcast<GlobalInterfaceParent*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCGlobalInterfaceParent* wrapper =
- new (NotNull, JSC::allocateCell<JSCGlobalInterfaceParent>(global_data.heap))
- JSCGlobalInterfaceParent(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCGlobalInterfaceParent::JSCGlobalInterfaceParent(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<GlobalInterfaceParent>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCGlobalInterfaceParent::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCGlobalInterfaceParent::~JSCGlobalInterfaceParent() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCGlobalInterfaceParent::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCGlobalInterfaceParent* this_object = JSC::jsCast<JSCGlobalInterfaceParent*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCGlobalInterfaceParent, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCGlobalInterfaceParent::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCGlobalInterfaceParent* this_object = JSC::jsCast<JSCGlobalInterfaceParent*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCGlobalInterfaceParent, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCGlobalInterfaceParent::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCGlobalInterfaceParent* this_object = JSC::jsCast<JSCGlobalInterfaceParent*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCGlobalInterfaceParent, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::EncodedJSValue functionJSparentOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCGlobalInterfaceParent", "call parentOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- GlobalInterfaceParent* impl =
- GetWrappableOrSetException<GlobalInterfaceParent>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- impl->ParentOperation();
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCGlobalInterfaceParent.h b/src/cobalt/bindings/generated/jsc/testing/JSCGlobalInterfaceParent.h
deleted file mode 100644
index ebbbfa9..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCGlobalInterfaceParent.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCGlobalInterfaceParent_h
-#define JSCGlobalInterfaceParent_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/global_interface_parent.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCGlobalInterfaceParent
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to GlobalInterfaceParent.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCGlobalInterfaceParent(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<GlobalInterfaceParent>& impl);
- ~JSCGlobalInterfaceParent();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCGlobalInterfaceParent_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCIndexedGetterInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCIndexedGetterInterface.cc
deleted file mode 100644
index 1049b03..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCIndexedGetterInterface.cc
+++ /dev/null
@@ -1,993 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCIndexedGetterInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::IndexedGetterInterface;
-using cobalt::bindings::testing::JSCIndexedGetterInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSlength(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-JSC::EncodedJSValue functionJSindexedDeleter(JSC::ExecState*);
-JSC::EncodedJSValue functionJSindexedGetter(JSC::ExecState*);
-JSC::EncodedJSValue functionJSindexedSetter(JSC::ExecState*);
-JSC::JSValue IndexedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, uint32_t index);
-void IndexedPropertySetter(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::JSValue value);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCIndexedGetterInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCIndexedGetterInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCIndexedGetterInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCIndexedGetterInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCIndexedGetterInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCIndexedGetterInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCIndexedGetterInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCIndexedGetterInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCIndexedGetterInterface::InterfaceObject::s_info = {
- "IndexedGetterInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCIndexedGetterInterface::InterfaceObject)
-}; // JSCIndexedGetterInterface::InterfaceObject::s_info
-
-void JSCIndexedGetterInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCIndexedGetterInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCIndexedGetterInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "IndexedGetterInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCIndexedGetterInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCIndexedGetterInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCIndexedGetterInterface::Prototype::property_table_values[] = {
- { "indexedDeleter",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSindexedDeleter),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "indexedGetter",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSindexedGetter),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "indexedSetter",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSindexedSetter),
- static_cast<intptr_t>(2),
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCIndexedGetterInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCIndexedGetterInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCIndexedGetterInterface::Prototype::property_table_prototype = {
- 19, // compactSize
- 15, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCIndexedGetterInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCIndexedGetterInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCIndexedGetterInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCIndexedGetterInterface::Prototype::s_info = {
- "IndexedGetterInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCIndexedGetterInterface::Prototype)
-}; // JSCIndexedGetterInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCIndexedGetterInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCIndexedGetterInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCIndexedGetterInterface::Prototype class
-
-const JSC::HashTableValue JSCIndexedGetterInterface::property_table_values[] = {
- { "length",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJSlength),
- 0,
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCIndexedGetterInterface::property_table_values
-
-// static
-const JSC::HashTable JSCIndexedGetterInterface::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCIndexedGetterInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCIndexedGetterInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCIndexedGetterInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCIndexedGetterInterface::NonTrivialStaticFields>
- JSCIndexedGetterInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCIndexedGetterInterface::s_info = {
- "IndexedGetterInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCIndexedGetterInterface)
-}; // JSCIndexedGetterInterface::s_info
-
-// static
-JSC::JSObject* JSCIndexedGetterInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCIndexedGetterInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCIndexedGetterInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCIndexedGetterInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == IndexedGetterInterface::IndexedGetterInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match IndexedGetterInterface::IndexedGetterInterfaceWrappableType()";
- return NULL;
- }
- IndexedGetterInterface* impl_ptr =
- base::polymorphic_downcast<IndexedGetterInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCIndexedGetterInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCIndexedGetterInterface>(global_data.heap))
- JSCIndexedGetterInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCIndexedGetterInterface::JSCIndexedGetterInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<IndexedGetterInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCIndexedGetterInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCIndexedGetterInterface::~JSCIndexedGetterInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCIndexedGetterInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCIndexedGetterInterface* this_object = JSC::jsCast<JSCIndexedGetterInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCIndexedGetterInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// static
-bool JSCIndexedGetterInterface::getOwnPropertySlotByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::PropertySlot& slot) {
- IndexedGetterInterface* impl =
- GetWrappableOrSetException<IndexedGetterInterface>(exec_state, cell);
- if (!impl) {
- return false;
- }
- if (index < impl->length()) {
- slot.setCustomIndex(cell, index, IndexedPropertyGetter);
- return true;
- }
- if (s_has_named_getter) {
- JSCIndexedGetterInterface* this_object = JSC::jsCast<JSCIndexedGetterInterface*>(cell);
- JSC::PropertyName property_name = JSC::Identifier::from(exec_state, index);
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property) {
- if (QueryNamedProperty(this_object, exec_state, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- return true;
- }
- }
- }
- return Base::getOwnPropertySlotByIndex(cell, exec_state, index, slot);
-}
-
-void JSCIndexedGetterInterface::getOwnPropertyNames(JSC::JSObject* object,
- JSC::ExecState* exec_state, JSC::PropertyNameArray& property_names,
- JSC::EnumerationMode mode) {
- IndexedGetterInterface* impl =
- GetWrappableOrSetException<IndexedGetterInterface>(exec_state, object);
- if (impl) {
- for (uint32 i = 0; i < impl->length(); ++i) {
- property_names.add(JSC::Identifier::from(exec_state, i));
- }
- Base::getOwnPropertyNames(object, exec_state, property_names, mode);
- }
-}
-
-// Look up property slot and put the |value|.
-void JSCIndexedGetterInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCIndexedGetterInterface* this_object = JSC::jsCast<JSCIndexedGetterInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCIndexedGetterInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-// static
-void JSCIndexedGetterInterface::putByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::JSValue value,
- bool should_throw) {
- IndexedGetterInterface* impl =
- GetWrappableOrSetException<IndexedGetterInterface>(exec_state, cell);
- if (impl) {
- bool property_handled = false;
- if (index < impl->length()) {
- IndexedPropertySetter(cell, exec_state, index, value);
- property_handled = true;
- }
- if (s_has_named_setter) {
- if (!property_handled) {
- JSC::PropertyName property_name = JSC::Identifier::from(exec_state, index);
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property) {
- NamedPropertySetter(cell, exec_state, property_name, value);
- property_handled = true;
- }
- }
- }
- if (!property_handled) {
- Base::putByIndex(cell, exec_state, index, value, should_throw);
- }
- }
-}
-
-
-bool JSCIndexedGetterInterface::deletePropertyByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state,
- uint32_t index) {
- TRACE_EVENT0("JSCIndexedGetterInterface", "deletePropertyByIndex");
- IndexedGetterInterface* impl =
- GetWrappableOrSetException<IndexedGetterInterface>(exec_state, cell);
- if (impl) {
- // https://heycam.github.io/webidl/#delete
- // Return true if index is not a supported property index.
- return index >= impl->length();
- }
- return false;
-}
-
-bool JSCIndexedGetterInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCIndexedGetterInterface* this_object = JSC::jsCast<JSCIndexedGetterInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCIndexedGetterInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSlength(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCIndexedGetterInterface", "get length");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- IndexedGetterInterface* impl =
- GetWrappableOrSetException<IndexedGetterInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->length());
- return result;
-}
-
-JSC::EncodedJSValue functionJSindexedDeleter(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCIndexedGetterInterface", "call indexedDeleter");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- IndexedGetterInterface* impl =
- GetWrappableOrSetException<IndexedGetterInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<uint32_t >::ConversionType index;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &index);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->IndexedDeleter(index);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSindexedGetter(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCIndexedGetterInterface", "call indexedGetter");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- IndexedGetterInterface* impl =
- GetWrappableOrSetException<IndexedGetterInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<uint32_t >::ConversionType index;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &index);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- TypeTraits<uint32_t >::ReturnType return_value = impl->IndexedGetter(index);
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSindexedSetter(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCIndexedGetterInterface", "call indexedSetter");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- IndexedGetterInterface* impl =
- GetWrappableOrSetException<IndexedGetterInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 2;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<uint32_t >::ConversionType index;
- TypeTraits<uint32_t >::ConversionType value;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &index);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
-
- DCHECK_LT(1, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(1),
- kNoConversionFlags,
- &exception_state, &value);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->IndexedSetter(index, value);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::JSValue IndexedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, uint32_t index) {
- TRACE_EVENT0("JSCIndexedGetterInterface", "IndexedPropertyGetter");
- IndexedGetterInterface* impl =
- GetWrappableOrSetException<IndexedGetterInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->IndexedGetter(index));
- return result;
-}
-
-void IndexedPropertySetter(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::JSValue jsc_value) {
- TRACE_EVENT0("JSCIndexedGetterInterface", "IndexedPropertySetter");
- IndexedGetterInterface* impl =
- GetWrappableOrSetException<IndexedGetterInterface>(exec_state, cell);
- if (!impl) {
- return;
- }
-
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- uint32_t value;
- FromJSValue(exec_state, jsc_value,
- kNoConversionFlags,
- &exception_state, &value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- impl->IndexedSetter(index, value);
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCIndexedGetterInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCIndexedGetterInterface.h
deleted file mode 100644
index 563e4b9..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCIndexedGetterInterface.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCIndexedGetterInterface_h
-#define JSCIndexedGetterInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/indexed_getter_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCIndexedGetterInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- static bool getOwnPropertySlotByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state,
- uint32_t index,
- JSC::PropertySlot& slot);
-
- static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*,
- JSC::PropertyNameArray&,
- JSC::EnumerationMode);
-
- static void putByIndex(JSC::JSCell* cell, JSC::ExecState* exec_state,
- uint32_t index, JSC::JSValue value, bool should_throw);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- static bool deletePropertyByIndex(JSC::JSCell*, JSC::ExecState*, uint32_t);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to IndexedGetterInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCIndexedGetterInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<IndexedGetterInterface>& impl);
- ~JSCIndexedGetterInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCIndexedGetterInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCInterfaceWithUnsupportedProperties.cc b/src/cobalt/bindings/generated/jsc/testing/JSCInterfaceWithUnsupportedProperties.cc
deleted file mode 100644
index 987a767..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCInterfaceWithUnsupportedProperties.cc
+++ /dev/null
@@ -1,732 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCInterfaceWithUnsupportedProperties.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::InterfaceWithUnsupportedProperties;
-using cobalt::bindings::testing::JSCInterfaceWithUnsupportedProperties;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSsupportedAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCInterfaceWithUnsupportedProperties::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCInterfaceWithUnsupportedProperties";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCInterfaceWithUnsupportedProperties::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCInterfaceWithUnsupportedProperties::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCInterfaceWithUnsupportedProperties::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCInterfaceWithUnsupportedProperties::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCInterfaceWithUnsupportedProperties::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCInterfaceWithUnsupportedProperties::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCInterfaceWithUnsupportedProperties::InterfaceObject::s_info = {
- "InterfaceWithUnsupportedPropertiesConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCInterfaceWithUnsupportedProperties::InterfaceObject)
-}; // JSCInterfaceWithUnsupportedProperties::InterfaceObject::s_info
-
-void JSCInterfaceWithUnsupportedProperties::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCInterfaceWithUnsupportedProperties::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCInterfaceWithUnsupportedProperties::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "InterfaceWithUnsupportedProperties");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCInterfaceWithUnsupportedProperties::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCInterfaceWithUnsupportedProperties::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCInterfaceWithUnsupportedProperties::Prototype::property_table_values[] = {
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCInterfaceWithUnsupportedProperties::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCInterfaceWithUnsupportedProperties::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCInterfaceWithUnsupportedProperties::Prototype::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCInterfaceWithUnsupportedProperties::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCInterfaceWithUnsupportedProperties::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCInterfaceWithUnsupportedProperties::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCInterfaceWithUnsupportedProperties::Prototype::s_info = {
- "InterfaceWithUnsupportedPropertiesPrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCInterfaceWithUnsupportedProperties::Prototype)
-}; // JSCInterfaceWithUnsupportedProperties::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCInterfaceWithUnsupportedProperties::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCInterfaceWithUnsupportedProperties::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCInterfaceWithUnsupportedProperties::Prototype class
-
-const JSC::HashTableValue JSCInterfaceWithUnsupportedProperties::property_table_values[] = {
- { "supportedAttribute",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJSsupportedAttribute),
- 0,
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCInterfaceWithUnsupportedProperties::property_table_values
-
-// static
-const JSC::HashTable JSCInterfaceWithUnsupportedProperties::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCInterfaceWithUnsupportedProperties::property_table_prototype
-
-// static
-const JSC::HashTable* JSCInterfaceWithUnsupportedProperties::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCInterfaceWithUnsupportedProperties::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCInterfaceWithUnsupportedProperties::NonTrivialStaticFields>
- JSCInterfaceWithUnsupportedProperties::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCInterfaceWithUnsupportedProperties::s_info = {
- "InterfaceWithUnsupportedProperties", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCInterfaceWithUnsupportedProperties)
-}; // JSCInterfaceWithUnsupportedProperties::s_info
-
-// static
-JSC::JSObject* JSCInterfaceWithUnsupportedProperties::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCInterfaceWithUnsupportedProperties::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCInterfaceWithUnsupportedProperties::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCInterfaceWithUnsupportedProperties::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == InterfaceWithUnsupportedProperties::InterfaceWithUnsupportedPropertiesWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match InterfaceWithUnsupportedProperties::InterfaceWithUnsupportedPropertiesWrappableType()";
- return NULL;
- }
- InterfaceWithUnsupportedProperties* impl_ptr =
- base::polymorphic_downcast<InterfaceWithUnsupportedProperties*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCInterfaceWithUnsupportedProperties* wrapper =
- new (NotNull, JSC::allocateCell<JSCInterfaceWithUnsupportedProperties>(global_data.heap))
- JSCInterfaceWithUnsupportedProperties(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCInterfaceWithUnsupportedProperties::JSCInterfaceWithUnsupportedProperties(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<InterfaceWithUnsupportedProperties>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCInterfaceWithUnsupportedProperties::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCInterfaceWithUnsupportedProperties::~JSCInterfaceWithUnsupportedProperties() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCInterfaceWithUnsupportedProperties::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCInterfaceWithUnsupportedProperties* this_object = JSC::jsCast<JSCInterfaceWithUnsupportedProperties*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCInterfaceWithUnsupportedProperties, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCInterfaceWithUnsupportedProperties::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCInterfaceWithUnsupportedProperties* this_object = JSC::jsCast<JSCInterfaceWithUnsupportedProperties*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCInterfaceWithUnsupportedProperties, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCInterfaceWithUnsupportedProperties::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCInterfaceWithUnsupportedProperties* this_object = JSC::jsCast<JSCInterfaceWithUnsupportedProperties*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCInterfaceWithUnsupportedProperties, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSsupportedAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCInterfaceWithUnsupportedProperties", "get supportedAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- InterfaceWithUnsupportedProperties* impl =
- GetWrappableOrSetException<InterfaceWithUnsupportedProperties>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->supported_attribute());
- return result;
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCInterfaceWithUnsupportedProperties.h b/src/cobalt/bindings/generated/jsc/testing/JSCInterfaceWithUnsupportedProperties.h
deleted file mode 100644
index 5d55bde..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCInterfaceWithUnsupportedProperties.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCInterfaceWithUnsupportedProperties_h
-#define JSCInterfaceWithUnsupportedProperties_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/interface_with_unsupported_properties.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCInterfaceWithUnsupportedProperties
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to InterfaceWithUnsupportedProperties.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCInterfaceWithUnsupportedProperties(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<InterfaceWithUnsupportedProperties>& impl);
- ~JSCInterfaceWithUnsupportedProperties();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCInterfaceWithUnsupportedProperties_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCNamedConstructorInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCNamedConstructorInterface.cc
deleted file mode 100644
index 1825c9e..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCNamedConstructorInterface.cc
+++ /dev/null
@@ -1,870 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCNamedConstructorInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::NamedConstructorInterface;
-using cobalt::bindings::testing::JSCNamedConstructorInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::EncodedJSValue constructorJSNamedConstructorInterface(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCNamedConstructorInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCNamedConstructorInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCNamedConstructorInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNamedConstructorInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCNamedConstructorInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNamedConstructorInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCNamedConstructorInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNamedConstructorInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCNamedConstructorInterface::InterfaceObject::s_info = {
- "NamedConstructorInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNamedConstructorInterface::InterfaceObject)
-}; // JSCNamedConstructorInterface::InterfaceObject::s_info
-
-void JSCNamedConstructorInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCNamedConstructorInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCNamedConstructorInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, &constructorJSNamedConstructorInterface);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "NamedConstructorInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCNamedConstructorInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCNamedConstructorInterface::NamedInterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- NamedInterfaceObject* this_object = JSC::jsCast<NamedInterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- NamedInterfaceObject* this_object = JSC::jsCast<NamedInterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<NamedInterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCNamedConstructorInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- NamedInterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCNamedConstructorInterface::NamedInterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNamedConstructorInterface::NamedInterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCNamedConstructorInterface::NamedInterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNamedConstructorInterface::NamedInterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCNamedConstructorInterface::NamedInterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNamedConstructorInterface::NamedInterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCNamedConstructorInterface::NamedInterfaceObject::s_info = {
- "NamedConstructorInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNamedConstructorInterface::NamedInterfaceObject)
-}; // JSCNamedConstructorInterface::NamedInterfaceObject::s_info
-
-void JSCNamedConstructorInterface::NamedInterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCNamedConstructorInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCNamedConstructorInterface::NamedInterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, &constructorJSNamedConstructorInterface);
-
- // Create the new interface object.
- NamedInterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<NamedInterfaceObject>(global_data.heap))
- NamedInterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "SomeNamedConstructor");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCNamedConstructorInterface::NamedInterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCNamedConstructorInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCNamedConstructorInterface::Prototype::property_table_values[] = {
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCNamedConstructorInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNamedConstructorInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCNamedConstructorInterface::Prototype::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNamedConstructorInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCNamedConstructorInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNamedConstructorInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCNamedConstructorInterface::Prototype::s_info = {
- "NamedConstructorInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNamedConstructorInterface::Prototype)
-}; // JSCNamedConstructorInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCNamedConstructorInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCNamedConstructorInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCNamedConstructorInterface::Prototype class
-
-const JSC::HashTableValue JSCNamedConstructorInterface::property_table_values[] = {
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNamedConstructorInterface::property_table_values
-
-// static
-const JSC::HashTable JSCNamedConstructorInterface::property_table_prototype = {
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNamedConstructorInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCNamedConstructorInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNamedConstructorInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCNamedConstructorInterface::NonTrivialStaticFields>
- JSCNamedConstructorInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCNamedConstructorInterface::s_info = {
- "NamedConstructorInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNamedConstructorInterface)
-}; // JSCNamedConstructorInterface::s_info
-
-// static
-JSC::JSObject* JSCNamedConstructorInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCNamedConstructorInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCNamedConstructorInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-JSC::JSObject* JSCNamedConstructorInterface::GetNamedConstructor(
- JSC::ExecState* exec_state) {
- return NamedInterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSObject* JSCNamedConstructorInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == NamedConstructorInterface::NamedConstructorInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match NamedConstructorInterface::NamedConstructorInterfaceWrappableType()";
- return NULL;
- }
- NamedConstructorInterface* impl_ptr =
- base::polymorphic_downcast<NamedConstructorInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCNamedConstructorInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCNamedConstructorInterface>(global_data.heap))
- JSCNamedConstructorInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCNamedConstructorInterface::JSCNamedConstructorInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<NamedConstructorInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCNamedConstructorInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCNamedConstructorInterface::~JSCNamedConstructorInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCNamedConstructorInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCNamedConstructorInterface* this_object = JSC::jsCast<JSCNamedConstructorInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCNamedConstructorInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCNamedConstructorInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCNamedConstructorInterface* this_object = JSC::jsCast<JSCNamedConstructorInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCNamedConstructorInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCNamedConstructorInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCNamedConstructorInterface* this_object = JSC::jsCast<JSCNamedConstructorInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCNamedConstructorInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::EncodedJSValue constructorJSNamedConstructorInterface(JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- scoped_refptr<NamedConstructorInterface> new_object =
- new NamedConstructorInterface();
- return JSC::JSValue::encode(ToJSValue(global_object, new_object));
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCNamedConstructorInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCNamedConstructorInterface.h
deleted file mode 100644
index b0af676..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCNamedConstructorInterface.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCNamedConstructorInterface_h
-#define JSCNamedConstructorInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/named_constructor_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCNamedConstructorInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // Get the named constructor for this wrapper class.
- static JSC::JSObject* GetNamedConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to NamedConstructorInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCNamedConstructorInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<NamedConstructorInterface>& impl);
- ~JSCNamedConstructorInterface();
-
- private:
- class InterfaceObject;
- class NamedInterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCNamedConstructorInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCNamedGetterInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCNamedGetterInterface.cc
deleted file mode 100644
index 27a6fa1..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCNamedGetterInterface.cc
+++ /dev/null
@@ -1,984 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCNamedGetterInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/jsc_property_enumerator.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::NamedGetterInterface;
-using cobalt::bindings::testing::JSCNamedGetterInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSCPropertyEnumerator;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::EncodedJSValue functionJSnamedDeleter(JSC::ExecState*);
-JSC::EncodedJSValue functionJSnamedGetter(JSC::ExecState*);
-JSC::EncodedJSValue functionJSnamedSetter(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = true;
-const bool s_has_named_setter = true;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCNamedGetterInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCNamedGetterInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCNamedGetterInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNamedGetterInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCNamedGetterInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNamedGetterInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCNamedGetterInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNamedGetterInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCNamedGetterInterface::InterfaceObject::s_info = {
- "NamedGetterInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNamedGetterInterface::InterfaceObject)
-}; // JSCNamedGetterInterface::InterfaceObject::s_info
-
-void JSCNamedGetterInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCNamedGetterInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCNamedGetterInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "NamedGetterInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCNamedGetterInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCNamedGetterInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCNamedGetterInterface::Prototype::property_table_values[] = {
- { "namedDeleter",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSnamedDeleter),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "namedGetter",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSnamedGetter),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "namedSetter",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSnamedSetter),
- static_cast<intptr_t>(2),
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCNamedGetterInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNamedGetterInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCNamedGetterInterface::Prototype::property_table_prototype = {
- 19, // compactSize
- 15, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNamedGetterInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCNamedGetterInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNamedGetterInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCNamedGetterInterface::Prototype::s_info = {
- "NamedGetterInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNamedGetterInterface::Prototype)
-}; // JSCNamedGetterInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCNamedGetterInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCNamedGetterInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCNamedGetterInterface::Prototype class
-
-const JSC::HashTableValue JSCNamedGetterInterface::property_table_values[] = {
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNamedGetterInterface::property_table_values
-
-// static
-const JSC::HashTable JSCNamedGetterInterface::property_table_prototype = {
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNamedGetterInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCNamedGetterInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNamedGetterInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCNamedGetterInterface::NonTrivialStaticFields>
- JSCNamedGetterInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCNamedGetterInterface::s_info = {
- "NamedGetterInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNamedGetterInterface)
-}; // JSCNamedGetterInterface::s_info
-
-// static
-JSC::JSObject* JSCNamedGetterInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCNamedGetterInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCNamedGetterInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCNamedGetterInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == NamedGetterInterface::NamedGetterInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match NamedGetterInterface::NamedGetterInterfaceWrappableType()";
- return NULL;
- }
- NamedGetterInterface* impl_ptr =
- base::polymorphic_downcast<NamedGetterInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCNamedGetterInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCNamedGetterInterface>(global_data.heap))
- JSCNamedGetterInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCNamedGetterInterface::JSCNamedGetterInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<NamedGetterInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCNamedGetterInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCNamedGetterInterface::~JSCNamedGetterInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCNamedGetterInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCNamedGetterInterface* this_object = JSC::jsCast<JSCNamedGetterInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCNamedGetterInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// static
-bool JSCNamedGetterInterface::getOwnPropertySlotByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::PropertySlot& slot) {
- NamedGetterInterface* impl =
- GetWrappableOrSetException<NamedGetterInterface>(exec_state, cell);
- if (!impl) {
- return false;
- }
- if (s_has_named_getter) {
- JSCNamedGetterInterface* this_object = JSC::jsCast<JSCNamedGetterInterface*>(cell);
- JSC::PropertyName property_name = JSC::Identifier::from(exec_state, index);
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property) {
- if (QueryNamedProperty(this_object, exec_state, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- return true;
- }
- }
- }
- return Base::getOwnPropertySlotByIndex(cell, exec_state, index, slot);
-}
-
-void JSCNamedGetterInterface::getOwnPropertyNames(JSC::JSObject* object,
- JSC::ExecState* exec_state, JSC::PropertyNameArray& property_names,
- JSC::EnumerationMode mode) {
- NamedGetterInterface* impl =
- GetWrappableOrSetException<NamedGetterInterface>(exec_state, object);
- if (impl) {
- JSCPropertyEnumerator enumerator(exec_state, &property_names);
- impl->EnumerateNamedProperties(&enumerator);
- Base::getOwnPropertyNames(object, exec_state, property_names, mode);
- }
-}
-
-// Look up property slot and put the |value|.
-void JSCNamedGetterInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCNamedGetterInterface* this_object = JSC::jsCast<JSCNamedGetterInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCNamedGetterInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-// static
-void JSCNamedGetterInterface::putByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::JSValue value,
- bool should_throw) {
- NamedGetterInterface* impl =
- GetWrappableOrSetException<NamedGetterInterface>(exec_state, cell);
- if (impl) {
- bool property_handled = false;
- if (s_has_named_setter) {
- if (!property_handled) {
- JSC::PropertyName property_name = JSC::Identifier::from(exec_state, index);
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property) {
- NamedPropertySetter(cell, exec_state, property_name, value);
- property_handled = true;
- }
- }
- }
- if (!property_handled) {
- Base::putByIndex(cell, exec_state, index, value, should_throw);
- }
- }
-}
-
-
-bool JSCNamedGetterInterface::deleteProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- TRACE_EVENT1("JSCNamedGetterInterface", "deleteProperty", "property",
- TRACE_STR_COPY(WTF::String(property_name.publicName()).utf8().data()));
- NamedGetterInterface* impl =
- GetWrappableOrSetException<NamedGetterInterface>(exec_state, cell);
- if (impl) {
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property &&
- QueryNamedProperty(cell, exec_state, property_name)) {
- return NamedPropertyDeleter(cell, exec_state, property_name);
- }
- return Base::deleteProperty(cell, exec_state, property_name);
- }
- return false;
-}
-
-bool JSCNamedGetterInterface::deletePropertyByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state,
- uint32_t index) {
- TRACE_EVENT0("JSCNamedGetterInterface", "deletePropertyByIndex");
- NamedGetterInterface* impl =
- GetWrappableOrSetException<NamedGetterInterface>(exec_state, cell);
- if (impl) {
- JSC::PropertyName property_name = JSC::Identifier::from(exec_state, index);
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property &&
- QueryNamedProperty(cell, exec_state, property_name)) {
- return NamedPropertyDeleter(cell, exec_state, property_name);
- }
- return Base::deletePropertyByIndex(cell, exec_state, index);
- }
- return false;
-}
-
-bool JSCNamedGetterInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCNamedGetterInterface* this_object = JSC::jsCast<JSCNamedGetterInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCNamedGetterInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::EncodedJSValue functionJSnamedDeleter(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNamedGetterInterface", "call namedDeleter");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NamedGetterInterface* impl =
- GetWrappableOrSetException<NamedGetterInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<std::string >::ConversionType name;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &name);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->NamedDeleter(name);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSnamedGetter(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNamedGetterInterface", "call namedGetter");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NamedGetterInterface* impl =
- GetWrappableOrSetException<NamedGetterInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<std::string >::ConversionType name;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &name);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- TypeTraits<std::string >::ReturnType return_value = impl->NamedGetter(name);
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSnamedSetter(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNamedGetterInterface", "call namedSetter");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NamedGetterInterface* impl =
- GetWrappableOrSetException<NamedGetterInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 2;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<std::string >::ConversionType name;
- TypeTraits<std::string >::ConversionType value;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &name);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
-
- DCHECK_LT(1, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(1),
- kNoConversionFlags,
- &exception_state, &value);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->NamedSetter(name, value);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCNamedGetterInterface", "NamedPropertyGetter");
- NamedGetterInterface* impl =
- GetWrappableOrSetException<NamedGetterInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->NamedGetter(property_name_utf8));
- return result;
-}
-
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NamedGetterInterface* impl =
- GetWrappableOrSetException<NamedGetterInterface>(exec_state, cell);
- if (!impl) {
- return false;
- }
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- return impl->CanQueryNamedProperty(property_name_utf8);
-}
-
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- TRACE_EVENT0("JSCNamedGetterInterface", "NamedPropertySetter");
- NamedGetterInterface* impl =
- GetWrappableOrSetException<NamedGetterInterface>(exec_state, cell);
- if (!impl) {
- return;
- }
-
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
-
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- std::string value;
- FromJSValue(exec_state, jsc_value,
- kNoConversionFlags,
- &exception_state, &value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- impl->NamedSetter(property_name_utf8, value);
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NamedGetterInterface* impl =
- GetWrappableOrSetException<NamedGetterInterface>(exec_state, cell);
- if (impl) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- impl->NamedDeleter(property_name_utf8);
- return true;
- }
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCNamedGetterInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCNamedGetterInterface.h
deleted file mode 100644
index cf9ad8d..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCNamedGetterInterface.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCNamedGetterInterface_h
-#define JSCNamedGetterInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/named_getter_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCNamedGetterInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- static bool getOwnPropertySlotByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state,
- uint32_t index,
- JSC::PropertySlot& slot);
-
- static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*,
- JSC::PropertyNameArray&,
- JSC::EnumerationMode);
-
- static void putByIndex(JSC::JSCell* cell, JSC::ExecState* exec_state,
- uint32_t index, JSC::JSValue value, bool should_throw);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- static bool deleteProperty(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName);
-
- static bool deletePropertyByIndex(JSC::JSCell*, JSC::ExecState*, uint32_t);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to NamedGetterInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCNamedGetterInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<NamedGetterInterface>& impl);
- ~JSCNamedGetterInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCNamedGetterInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCNamedIndexedGetterInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCNamedIndexedGetterInterface.cc
deleted file mode 100644
index ed0cf6e..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCNamedIndexedGetterInterface.cc
+++ /dev/null
@@ -1,1193 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCNamedIndexedGetterInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/jsc_property_enumerator.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::NamedIndexedGetterInterface;
-using cobalt::bindings::testing::JSCNamedIndexedGetterInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSCPropertyEnumerator;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSlength(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-JSC::JSValue getJSpropertyOnBaseClass(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSpropertyOnBaseClass(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::EncodedJSValue functionJSindexedGetter(JSC::ExecState*);
-JSC::EncodedJSValue functionJSindexedSetter(JSC::ExecState*);
-JSC::EncodedJSValue functionJSnamedGetter(JSC::ExecState*);
-JSC::EncodedJSValue functionJSnamedSetter(JSC::ExecState*);
-JSC::EncodedJSValue functionJSoperationOnBaseClass(JSC::ExecState*);
-JSC::JSValue IndexedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, uint32_t index);
-void IndexedPropertySetter(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::JSValue value);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = true;
-const bool s_has_named_setter = true;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCNamedIndexedGetterInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCNamedIndexedGetterInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCNamedIndexedGetterInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNamedIndexedGetterInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCNamedIndexedGetterInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNamedIndexedGetterInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCNamedIndexedGetterInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNamedIndexedGetterInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCNamedIndexedGetterInterface::InterfaceObject::s_info = {
- "NamedIndexedGetterInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNamedIndexedGetterInterface::InterfaceObject)
-}; // JSCNamedIndexedGetterInterface::InterfaceObject::s_info
-
-void JSCNamedIndexedGetterInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCNamedIndexedGetterInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCNamedIndexedGetterInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "NamedIndexedGetterInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCNamedIndexedGetterInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCNamedIndexedGetterInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCNamedIndexedGetterInterface::Prototype::property_table_values[] = {
- { "indexedGetter",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSindexedGetter),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "indexedSetter",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSindexedSetter),
- static_cast<intptr_t>(2),
- JSC::NoIntrinsic
- },
- { "namedGetter",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSnamedGetter),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "namedSetter",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSnamedSetter),
- static_cast<intptr_t>(2),
- JSC::NoIntrinsic
- },
- { "operationOnBaseClass",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSoperationOnBaseClass),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCNamedIndexedGetterInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNamedIndexedGetterInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCNamedIndexedGetterInterface::Prototype::property_table_prototype = {
- 21, // compactSize
- 15, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNamedIndexedGetterInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCNamedIndexedGetterInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNamedIndexedGetterInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCNamedIndexedGetterInterface::Prototype::s_info = {
- "NamedIndexedGetterInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNamedIndexedGetterInterface::Prototype)
-}; // JSCNamedIndexedGetterInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCNamedIndexedGetterInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCNamedIndexedGetterInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCNamedIndexedGetterInterface::Prototype class
-
-const JSC::HashTableValue JSCNamedIndexedGetterInterface::property_table_values[] = {
- { "length",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJSlength),
- 0,
- JSC::NoIntrinsic
- },
- { "propertyOnBaseClass",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSpropertyOnBaseClass),
- reinterpret_cast<intptr_t>(setJSpropertyOnBaseClass),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNamedIndexedGetterInterface::property_table_values
-
-// static
-const JSC::HashTable JSCNamedIndexedGetterInterface::property_table_prototype = {
- 9, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNamedIndexedGetterInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCNamedIndexedGetterInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNamedIndexedGetterInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCNamedIndexedGetterInterface::NonTrivialStaticFields>
- JSCNamedIndexedGetterInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCNamedIndexedGetterInterface::s_info = {
- "NamedIndexedGetterInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNamedIndexedGetterInterface)
-}; // JSCNamedIndexedGetterInterface::s_info
-
-// static
-JSC::JSObject* JSCNamedIndexedGetterInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCNamedIndexedGetterInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCNamedIndexedGetterInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCNamedIndexedGetterInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == NamedIndexedGetterInterface::NamedIndexedGetterInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match NamedIndexedGetterInterface::NamedIndexedGetterInterfaceWrappableType()";
- return NULL;
- }
- NamedIndexedGetterInterface* impl_ptr =
- base::polymorphic_downcast<NamedIndexedGetterInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCNamedIndexedGetterInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCNamedIndexedGetterInterface>(global_data.heap))
- JSCNamedIndexedGetterInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCNamedIndexedGetterInterface::JSCNamedIndexedGetterInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<NamedIndexedGetterInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCNamedIndexedGetterInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCNamedIndexedGetterInterface::~JSCNamedIndexedGetterInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCNamedIndexedGetterInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCNamedIndexedGetterInterface* this_object = JSC::jsCast<JSCNamedIndexedGetterInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCNamedIndexedGetterInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// static
-bool JSCNamedIndexedGetterInterface::getOwnPropertySlotByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::PropertySlot& slot) {
- NamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<NamedIndexedGetterInterface>(exec_state, cell);
- if (!impl) {
- return false;
- }
- if (index < impl->length()) {
- slot.setCustomIndex(cell, index, IndexedPropertyGetter);
- return true;
- }
- if (s_has_named_getter) {
- JSCNamedIndexedGetterInterface* this_object = JSC::jsCast<JSCNamedIndexedGetterInterface*>(cell);
- JSC::PropertyName property_name = JSC::Identifier::from(exec_state, index);
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property) {
- if (QueryNamedProperty(this_object, exec_state, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- return true;
- }
- }
- }
- return Base::getOwnPropertySlotByIndex(cell, exec_state, index, slot);
-}
-
-void JSCNamedIndexedGetterInterface::getOwnPropertyNames(JSC::JSObject* object,
- JSC::ExecState* exec_state, JSC::PropertyNameArray& property_names,
- JSC::EnumerationMode mode) {
- NamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<NamedIndexedGetterInterface>(exec_state, object);
- if (impl) {
- for (uint32 i = 0; i < impl->length(); ++i) {
- property_names.add(JSC::Identifier::from(exec_state, i));
- }
- JSCPropertyEnumerator enumerator(exec_state, &property_names);
- impl->EnumerateNamedProperties(&enumerator);
- Base::getOwnPropertyNames(object, exec_state, property_names, mode);
- }
-}
-
-// Look up property slot and put the |value|.
-void JSCNamedIndexedGetterInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCNamedIndexedGetterInterface* this_object = JSC::jsCast<JSCNamedIndexedGetterInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCNamedIndexedGetterInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-// static
-void JSCNamedIndexedGetterInterface::putByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::JSValue value,
- bool should_throw) {
- NamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<NamedIndexedGetterInterface>(exec_state, cell);
- if (impl) {
- bool property_handled = false;
- if (index < impl->length()) {
- IndexedPropertySetter(cell, exec_state, index, value);
- property_handled = true;
- }
- if (s_has_named_setter) {
- if (!property_handled) {
- JSC::PropertyName property_name = JSC::Identifier::from(exec_state, index);
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property) {
- NamedPropertySetter(cell, exec_state, property_name, value);
- property_handled = true;
- }
- }
- }
- if (!property_handled) {
- Base::putByIndex(cell, exec_state, index, value, should_throw);
- }
- }
-}
-
-
-bool JSCNamedIndexedGetterInterface::deleteProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- TRACE_EVENT1("JSCNamedIndexedGetterInterface", "deleteProperty", "property",
- TRACE_STR_COPY(WTF::String(property_name.publicName()).utf8().data()));
- NamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<NamedIndexedGetterInterface>(exec_state, cell);
- if (impl) {
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property &&
- QueryNamedProperty(cell, exec_state, property_name)) {
- return NamedPropertyDeleter(cell, exec_state, property_name);
- }
- return Base::deleteProperty(cell, exec_state, property_name);
- }
- return false;
-}
-
-bool JSCNamedIndexedGetterInterface::deletePropertyByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state,
- uint32_t index) {
- TRACE_EVENT0("JSCNamedIndexedGetterInterface", "deletePropertyByIndex");
- NamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<NamedIndexedGetterInterface>(exec_state, cell);
- if (impl) {
- // https://heycam.github.io/webidl/#delete
- // Return true if index is not a supported property index.
- return index >= impl->length();
- }
- return false;
-}
-
-bool JSCNamedIndexedGetterInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCNamedIndexedGetterInterface* this_object = JSC::jsCast<JSCNamedIndexedGetterInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCNamedIndexedGetterInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSlength(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCNamedIndexedGetterInterface", "get length");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- NamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<NamedIndexedGetterInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->length());
- return result;
-}
-
-JSC::JSValue getJSpropertyOnBaseClass(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCNamedIndexedGetterInterface", "get propertyOnBaseClass");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- NamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<NamedIndexedGetterInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->property_on_base_class());
- return result;
-}
-
-void setJSpropertyOnBaseClass(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCNamedIndexedGetterInterface", "set propertyOnBaseClass");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- NamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<NamedIndexedGetterInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<bool >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_property_on_base_class(cobalt_value);
- }
-}
-
-JSC::EncodedJSValue functionJSindexedGetter(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNamedIndexedGetterInterface", "call indexedGetter");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<NamedIndexedGetterInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<uint32_t >::ConversionType index;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &index);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- TypeTraits<uint32_t >::ReturnType return_value = impl->IndexedGetter(index);
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSindexedSetter(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNamedIndexedGetterInterface", "call indexedSetter");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<NamedIndexedGetterInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 2;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<uint32_t >::ConversionType index;
- TypeTraits<uint32_t >::ConversionType value;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &index);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
-
- DCHECK_LT(1, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(1),
- kNoConversionFlags,
- &exception_state, &value);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->IndexedSetter(index, value);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSnamedGetter(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNamedIndexedGetterInterface", "call namedGetter");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<NamedIndexedGetterInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<std::string >::ConversionType name;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &name);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- TypeTraits<std::string >::ReturnType return_value = impl->NamedGetter(name);
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSnamedSetter(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNamedIndexedGetterInterface", "call namedSetter");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<NamedIndexedGetterInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 2;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<std::string >::ConversionType name;
- TypeTraits<std::string >::ConversionType value;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &name);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
-
- DCHECK_LT(1, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(1),
- kNoConversionFlags,
- &exception_state, &value);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->NamedSetter(name, value);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSoperationOnBaseClass(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNamedIndexedGetterInterface", "call operationOnBaseClass");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<NamedIndexedGetterInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- impl->OperationOnBaseClass();
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::JSValue IndexedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, uint32_t index) {
- TRACE_EVENT0("JSCNamedIndexedGetterInterface", "IndexedPropertyGetter");
- NamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<NamedIndexedGetterInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->IndexedGetter(index));
- return result;
-}
-
-void IndexedPropertySetter(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::JSValue jsc_value) {
- TRACE_EVENT0("JSCNamedIndexedGetterInterface", "IndexedPropertySetter");
- NamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<NamedIndexedGetterInterface>(exec_state, cell);
- if (!impl) {
- return;
- }
-
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- uint32_t value;
- FromJSValue(exec_state, jsc_value,
- kNoConversionFlags,
- &exception_state, &value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- impl->IndexedSetter(index, value);
-}
-
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCNamedIndexedGetterInterface", "NamedPropertyGetter");
- NamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<NamedIndexedGetterInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->NamedGetter(property_name_utf8));
- return result;
-}
-
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<NamedIndexedGetterInterface>(exec_state, cell);
- if (!impl) {
- return false;
- }
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- return impl->CanQueryNamedProperty(property_name_utf8);
-}
-
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- TRACE_EVENT0("JSCNamedIndexedGetterInterface", "NamedPropertySetter");
- NamedIndexedGetterInterface* impl =
- GetWrappableOrSetException<NamedIndexedGetterInterface>(exec_state, cell);
- if (!impl) {
- return;
- }
-
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
-
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- std::string value;
- FromJSValue(exec_state, jsc_value,
- kNoConversionFlags,
- &exception_state, &value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- impl->NamedSetter(property_name_utf8, value);
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCNamedIndexedGetterInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCNamedIndexedGetterInterface.h
deleted file mode 100644
index c84aab4..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCNamedIndexedGetterInterface.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCNamedIndexedGetterInterface_h
-#define JSCNamedIndexedGetterInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/named_indexed_getter_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCNamedIndexedGetterInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- static bool getOwnPropertySlotByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state,
- uint32_t index,
- JSC::PropertySlot& slot);
-
- static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*,
- JSC::PropertyNameArray&,
- JSC::EnumerationMode);
-
- static void putByIndex(JSC::JSCell* cell, JSC::ExecState* exec_state,
- uint32_t index, JSC::JSValue value, bool should_throw);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- static bool deleteProperty(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName);
-
- static bool deletePropertyByIndex(JSC::JSCell*, JSC::ExecState*, uint32_t);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to NamedIndexedGetterInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCNamedIndexedGetterInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<NamedIndexedGetterInterface>& impl);
- ~JSCNamedIndexedGetterInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCNamedIndexedGetterInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCNestedPutForwardsInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCNestedPutForwardsInterface.cc
deleted file mode 100644
index 889d4d7..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCNestedPutForwardsInterface.cc
+++ /dev/null
@@ -1,783 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCNestedPutForwardsInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-#include "JSCPutForwardsInterface.h"
-#include "cobalt/bindings/testing/put_forwards_interface.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::NestedPutForwardsInterface;
-using cobalt::bindings::testing::JSCNestedPutForwardsInterface;
-using cobalt::bindings::testing::JSCPutForwardsInterface;
-using cobalt::bindings::testing::PutForwardsInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSnestedForwardingAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSnestedForwardingAttribute(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCNestedPutForwardsInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCNestedPutForwardsInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCNestedPutForwardsInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNestedPutForwardsInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCNestedPutForwardsInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNestedPutForwardsInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCNestedPutForwardsInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNestedPutForwardsInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCNestedPutForwardsInterface::InterfaceObject::s_info = {
- "NestedPutForwardsInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNestedPutForwardsInterface::InterfaceObject)
-}; // JSCNestedPutForwardsInterface::InterfaceObject::s_info
-
-void JSCNestedPutForwardsInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCNestedPutForwardsInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCNestedPutForwardsInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "NestedPutForwardsInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCNestedPutForwardsInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCNestedPutForwardsInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCNestedPutForwardsInterface::Prototype::property_table_values[] = {
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCNestedPutForwardsInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNestedPutForwardsInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCNestedPutForwardsInterface::Prototype::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNestedPutForwardsInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCNestedPutForwardsInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNestedPutForwardsInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCNestedPutForwardsInterface::Prototype::s_info = {
- "NestedPutForwardsInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNestedPutForwardsInterface::Prototype)
-}; // JSCNestedPutForwardsInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCNestedPutForwardsInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCNestedPutForwardsInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCNestedPutForwardsInterface::Prototype class
-
-const JSC::HashTableValue JSCNestedPutForwardsInterface::property_table_values[] = {
- { "nestedForwardingAttribute",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSnestedForwardingAttribute),
- reinterpret_cast<intptr_t>(setJSnestedForwardingAttribute),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNestedPutForwardsInterface::property_table_values
-
-// static
-const JSC::HashTable JSCNestedPutForwardsInterface::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNestedPutForwardsInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCNestedPutForwardsInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNestedPutForwardsInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCNestedPutForwardsInterface::NonTrivialStaticFields>
- JSCNestedPutForwardsInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCNestedPutForwardsInterface::s_info = {
- "NestedPutForwardsInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNestedPutForwardsInterface)
-}; // JSCNestedPutForwardsInterface::s_info
-
-// static
-JSC::JSObject* JSCNestedPutForwardsInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCNestedPutForwardsInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCNestedPutForwardsInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCNestedPutForwardsInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == NestedPutForwardsInterface::NestedPutForwardsInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match NestedPutForwardsInterface::NestedPutForwardsInterfaceWrappableType()";
- return NULL;
- }
- NestedPutForwardsInterface* impl_ptr =
- base::polymorphic_downcast<NestedPutForwardsInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCNestedPutForwardsInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCNestedPutForwardsInterface>(global_data.heap))
- JSCNestedPutForwardsInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCNestedPutForwardsInterface::JSCNestedPutForwardsInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<NestedPutForwardsInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCNestedPutForwardsInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCNestedPutForwardsInterface::~JSCNestedPutForwardsInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCNestedPutForwardsInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCNestedPutForwardsInterface* this_object = JSC::jsCast<JSCNestedPutForwardsInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCNestedPutForwardsInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCNestedPutForwardsInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCNestedPutForwardsInterface* this_object = JSC::jsCast<JSCNestedPutForwardsInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCNestedPutForwardsInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCNestedPutForwardsInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCNestedPutForwardsInterface* this_object = JSC::jsCast<JSCNestedPutForwardsInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCNestedPutForwardsInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSnestedForwardingAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCNestedPutForwardsInterface", "get nestedForwardingAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- NestedPutForwardsInterface* impl =
- GetWrappableOrSetException<NestedPutForwardsInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->nested_forwarding_attribute());
- return result;
-}
-
-void setJSnestedForwardingAttribute(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCNestedPutForwardsInterface", "set nestedForwardingAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- NestedPutForwardsInterface* impl =
- GetWrappableOrSetException<NestedPutForwardsInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- {
- scoped_refptr<PutForwardsInterface> forwarded_impl =
- impl->nested_forwarding_attribute();
- if (!forwarded_impl) {
- return;
- }
- {
- scoped_refptr<ArbitraryInterface> forwarded_forwarded_impl =
- forwarded_impl->forwarding_attribute();
- if (!forwarded_forwarded_impl) {
- return;
- }
- TypeTraits<std::string >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- forwarded_forwarded_impl->set_arbitrary_property(cobalt_value);
- }
- }
-
- }
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCNestedPutForwardsInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCNestedPutForwardsInterface.h
deleted file mode 100644
index 2a35ff4..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCNestedPutForwardsInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCNestedPutForwardsInterface_h
-#define JSCNestedPutForwardsInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/nested_put_forwards_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCNestedPutForwardsInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to NestedPutForwardsInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCNestedPutForwardsInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<NestedPutForwardsInterface>& impl);
- ~JSCNestedPutForwardsInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCNestedPutForwardsInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCNoConstructorInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCNoConstructorInterface.cc
deleted file mode 100644
index 2d96b5d..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCNoConstructorInterface.cc
+++ /dev/null
@@ -1,703 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCNoConstructorInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::NoConstructorInterface;
-using cobalt::bindings::testing::JSCNoConstructorInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCNoConstructorInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCNoConstructorInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCNoConstructorInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNoConstructorInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCNoConstructorInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNoConstructorInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCNoConstructorInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNoConstructorInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCNoConstructorInterface::InterfaceObject::s_info = {
- "NoConstructorInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNoConstructorInterface::InterfaceObject)
-}; // JSCNoConstructorInterface::InterfaceObject::s_info
-
-void JSCNoConstructorInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCNoConstructorInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCNoConstructorInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "NoConstructorInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCNoConstructorInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCNoConstructorInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCNoConstructorInterface::Prototype::property_table_values[] = {
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCNoConstructorInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNoConstructorInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCNoConstructorInterface::Prototype::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNoConstructorInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCNoConstructorInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNoConstructorInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCNoConstructorInterface::Prototype::s_info = {
- "NoConstructorInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNoConstructorInterface::Prototype)
-}; // JSCNoConstructorInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCNoConstructorInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCNoConstructorInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCNoConstructorInterface::Prototype class
-
-const JSC::HashTableValue JSCNoConstructorInterface::property_table_values[] = {
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNoConstructorInterface::property_table_values
-
-// static
-const JSC::HashTable JSCNoConstructorInterface::property_table_prototype = {
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNoConstructorInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCNoConstructorInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNoConstructorInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCNoConstructorInterface::NonTrivialStaticFields>
- JSCNoConstructorInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCNoConstructorInterface::s_info = {
- "NoConstructorInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNoConstructorInterface)
-}; // JSCNoConstructorInterface::s_info
-
-// static
-JSC::JSObject* JSCNoConstructorInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCNoConstructorInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCNoConstructorInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCNoConstructorInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == NoConstructorInterface::NoConstructorInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match NoConstructorInterface::NoConstructorInterfaceWrappableType()";
- return NULL;
- }
- NoConstructorInterface* impl_ptr =
- base::polymorphic_downcast<NoConstructorInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCNoConstructorInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCNoConstructorInterface>(global_data.heap))
- JSCNoConstructorInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCNoConstructorInterface::JSCNoConstructorInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<NoConstructorInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCNoConstructorInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCNoConstructorInterface::~JSCNoConstructorInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCNoConstructorInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCNoConstructorInterface* this_object = JSC::jsCast<JSCNoConstructorInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCNoConstructorInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCNoConstructorInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCNoConstructorInterface* this_object = JSC::jsCast<JSCNoConstructorInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCNoConstructorInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCNoConstructorInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCNoConstructorInterface* this_object = JSC::jsCast<JSCNoConstructorInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCNoConstructorInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCNoConstructorInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCNoConstructorInterface.h
deleted file mode 100644
index 8c31ac4..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCNoConstructorInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCNoConstructorInterface_h
-#define JSCNoConstructorInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/no_constructor_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCNoConstructorInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to NoConstructorInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCNoConstructorInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<NoConstructorInterface>& impl);
- ~JSCNoConstructorInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCNoConstructorInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCNoInterfaceObjectInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCNoInterfaceObjectInterface.cc
deleted file mode 100644
index dec1a8c..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCNoInterfaceObjectInterface.cc
+++ /dev/null
@@ -1,513 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCNoInterfaceObjectInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::NoInterfaceObjectInterface;
-using cobalt::bindings::testing::JSCNoInterfaceObjectInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCNoInterfaceObjectInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCNoInterfaceObjectInterface::Prototype::property_table_values[] = {
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNoInterfaceObjectInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCNoInterfaceObjectInterface::Prototype::property_table_prototype = {
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNoInterfaceObjectInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCNoInterfaceObjectInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNoInterfaceObjectInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCNoInterfaceObjectInterface::Prototype::s_info = {
- "NoInterfaceObjectInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNoInterfaceObjectInterface::Prototype)
-}; // JSCNoInterfaceObjectInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCNoInterfaceObjectInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCNoInterfaceObjectInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCNoInterfaceObjectInterface::Prototype class
-
-const JSC::HashTableValue JSCNoInterfaceObjectInterface::property_table_values[] = {
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNoInterfaceObjectInterface::property_table_values
-
-// static
-const JSC::HashTable JSCNoInterfaceObjectInterface::property_table_prototype = {
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNoInterfaceObjectInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCNoInterfaceObjectInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNoInterfaceObjectInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCNoInterfaceObjectInterface::NonTrivialStaticFields>
- JSCNoInterfaceObjectInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCNoInterfaceObjectInterface::s_info = {
- "NoInterfaceObjectInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNoInterfaceObjectInterface)
-}; // JSCNoInterfaceObjectInterface::s_info
-
-// static
-JSC::JSObject* JSCNoInterfaceObjectInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-
-// static
-JSC::JSObject* JSCNoInterfaceObjectInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == NoInterfaceObjectInterface::NoInterfaceObjectInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match NoInterfaceObjectInterface::NoInterfaceObjectInterfaceWrappableType()";
- return NULL;
- }
- NoInterfaceObjectInterface* impl_ptr =
- base::polymorphic_downcast<NoInterfaceObjectInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCNoInterfaceObjectInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCNoInterfaceObjectInterface>(global_data.heap))
- JSCNoInterfaceObjectInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCNoInterfaceObjectInterface::JSCNoInterfaceObjectInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<NoInterfaceObjectInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCNoInterfaceObjectInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCNoInterfaceObjectInterface::~JSCNoInterfaceObjectInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCNoInterfaceObjectInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCNoInterfaceObjectInterface* this_object = JSC::jsCast<JSCNoInterfaceObjectInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCNoInterfaceObjectInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCNoInterfaceObjectInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCNoInterfaceObjectInterface* this_object = JSC::jsCast<JSCNoInterfaceObjectInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCNoInterfaceObjectInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCNoInterfaceObjectInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCNoInterfaceObjectInterface* this_object = JSC::jsCast<JSCNoInterfaceObjectInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCNoInterfaceObjectInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCNoInterfaceObjectInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCNoInterfaceObjectInterface.h
deleted file mode 100644
index bbc4f66..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCNoInterfaceObjectInterface.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCNoInterfaceObjectInterface_h
-#define JSCNoInterfaceObjectInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/no_interface_object_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCNoInterfaceObjectInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to NoInterfaceObjectInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCNoInterfaceObjectInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<NoInterfaceObjectInterface>& impl);
- ~JSCNoInterfaceObjectInterface();
-
- private:
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCNoInterfaceObjectInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCNullableTypesTestInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCNullableTypesTestInterface.cc
deleted file mode 100644
index 6acb572..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCNullableTypesTestInterface.cc
+++ /dev/null
@@ -1,1215 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCNullableTypesTestInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-#include "JSCArbitraryInterface.h"
-#include "cobalt/bindings/testing/arbitrary_interface.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::NullableTypesTestInterface;
-using cobalt::bindings::testing::JSCNullableTypesTestInterface;
-using cobalt::bindings::testing::ArbitraryInterface;
-using cobalt::bindings::testing::JSCArbitraryInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSnullableBooleanProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSnullableBooleanProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSnullableNumericProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSnullableNumericProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSnullableStringProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSnullableStringProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSnullableObjectProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSnullableObjectProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::EncodedJSValue functionJSnullableBooleanArgument(JSC::ExecState*);
-JSC::EncodedJSValue functionJSnullableBooleanOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSnullableNumericArgument(JSC::ExecState*);
-JSC::EncodedJSValue functionJSnullableNumericOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSnullableObjectArgument(JSC::ExecState*);
-JSC::EncodedJSValue functionJSnullableObjectOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSnullableStringArgument(JSC::ExecState*);
-JSC::EncodedJSValue functionJSnullableStringOperation(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCNullableTypesTestInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCNullableTypesTestInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCNullableTypesTestInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNullableTypesTestInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCNullableTypesTestInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNullableTypesTestInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCNullableTypesTestInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNullableTypesTestInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCNullableTypesTestInterface::InterfaceObject::s_info = {
- "NullableTypesTestInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNullableTypesTestInterface::InterfaceObject)
-}; // JSCNullableTypesTestInterface::InterfaceObject::s_info
-
-void JSCNullableTypesTestInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCNullableTypesTestInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCNullableTypesTestInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "NullableTypesTestInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCNullableTypesTestInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCNullableTypesTestInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCNullableTypesTestInterface::Prototype::property_table_values[] = {
- { "nullableBooleanArgument",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSnullableBooleanArgument),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "nullableBooleanOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSnullableBooleanOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "nullableNumericArgument",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSnullableNumericArgument),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "nullableNumericOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSnullableNumericOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "nullableObjectArgument",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSnullableObjectArgument),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "nullableObjectOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSnullableObjectOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "nullableStringArgument",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSnullableStringArgument),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "nullableStringOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSnullableStringOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCNullableTypesTestInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNullableTypesTestInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCNullableTypesTestInterface::Prototype::property_table_prototype = {
- 40, // compactSize
- 31, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNullableTypesTestInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCNullableTypesTestInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNullableTypesTestInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCNullableTypesTestInterface::Prototype::s_info = {
- "NullableTypesTestInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNullableTypesTestInterface::Prototype)
-}; // JSCNullableTypesTestInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCNullableTypesTestInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCNullableTypesTestInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCNullableTypesTestInterface::Prototype class
-
-const JSC::HashTableValue JSCNullableTypesTestInterface::property_table_values[] = {
- { "nullableBooleanProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSnullableBooleanProperty),
- reinterpret_cast<intptr_t>(setJSnullableBooleanProperty),
- JSC::NoIntrinsic
- },
- { "nullableNumericProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSnullableNumericProperty),
- reinterpret_cast<intptr_t>(setJSnullableNumericProperty),
- JSC::NoIntrinsic
- },
- { "nullableStringProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSnullableStringProperty),
- reinterpret_cast<intptr_t>(setJSnullableStringProperty),
- JSC::NoIntrinsic
- },
- { "nullableObjectProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSnullableObjectProperty),
- reinterpret_cast<intptr_t>(setJSnullableObjectProperty),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNullableTypesTestInterface::property_table_values
-
-// static
-const JSC::HashTable JSCNullableTypesTestInterface::property_table_prototype = {
- 19, // compactSize
- 15, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNullableTypesTestInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCNullableTypesTestInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNullableTypesTestInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCNullableTypesTestInterface::NonTrivialStaticFields>
- JSCNullableTypesTestInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCNullableTypesTestInterface::s_info = {
- "NullableTypesTestInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNullableTypesTestInterface)
-}; // JSCNullableTypesTestInterface::s_info
-
-// static
-JSC::JSObject* JSCNullableTypesTestInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCNullableTypesTestInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCNullableTypesTestInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCNullableTypesTestInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == NullableTypesTestInterface::NullableTypesTestInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match NullableTypesTestInterface::NullableTypesTestInterfaceWrappableType()";
- return NULL;
- }
- NullableTypesTestInterface* impl_ptr =
- base::polymorphic_downcast<NullableTypesTestInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCNullableTypesTestInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCNullableTypesTestInterface>(global_data.heap))
- JSCNullableTypesTestInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCNullableTypesTestInterface::JSCNullableTypesTestInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<NullableTypesTestInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCNullableTypesTestInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCNullableTypesTestInterface::~JSCNullableTypesTestInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCNullableTypesTestInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCNullableTypesTestInterface* this_object = JSC::jsCast<JSCNullableTypesTestInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCNullableTypesTestInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCNullableTypesTestInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCNullableTypesTestInterface* this_object = JSC::jsCast<JSCNullableTypesTestInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCNullableTypesTestInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCNullableTypesTestInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCNullableTypesTestInterface* this_object = JSC::jsCast<JSCNullableTypesTestInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCNullableTypesTestInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSnullableBooleanProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCNullableTypesTestInterface", "get nullableBooleanProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- NullableTypesTestInterface* impl =
- GetWrappableOrSetException<NullableTypesTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->nullable_boolean_property());
- return result;
-}
-
-void setJSnullableBooleanProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCNullableTypesTestInterface", "set nullableBooleanProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- NullableTypesTestInterface* impl =
- GetWrappableOrSetException<NullableTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<base::optional<bool > >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- (kConversionFlagNullable), &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_nullable_boolean_property(cobalt_value);
- }
-}
-
-JSC::JSValue getJSnullableNumericProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCNullableTypesTestInterface", "get nullableNumericProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- NullableTypesTestInterface* impl =
- GetWrappableOrSetException<NullableTypesTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->nullable_numeric_property());
- return result;
-}
-
-void setJSnullableNumericProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCNullableTypesTestInterface", "set nullableNumericProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- NullableTypesTestInterface* impl =
- GetWrappableOrSetException<NullableTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<base::optional<int32_t > >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- (kConversionFlagNullable), &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_nullable_numeric_property(cobalt_value);
- }
-}
-
-JSC::JSValue getJSnullableStringProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCNullableTypesTestInterface", "get nullableStringProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- NullableTypesTestInterface* impl =
- GetWrappableOrSetException<NullableTypesTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->nullable_string_property());
- return result;
-}
-
-void setJSnullableStringProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCNullableTypesTestInterface", "set nullableStringProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- NullableTypesTestInterface* impl =
- GetWrappableOrSetException<NullableTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<base::optional<std::string > >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- (kConversionFlagNullable), &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_nullable_string_property(cobalt_value);
- }
-}
-
-JSC::JSValue getJSnullableObjectProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCNullableTypesTestInterface", "get nullableObjectProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- NullableTypesTestInterface* impl =
- GetWrappableOrSetException<NullableTypesTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->nullable_object_property());
- return result;
-}
-
-void setJSnullableObjectProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCNullableTypesTestInterface", "set nullableObjectProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- NullableTypesTestInterface* impl =
- GetWrappableOrSetException<NullableTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<scoped_refptr<ArbitraryInterface> >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- (kConversionFlagNullable), &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_nullable_object_property(cobalt_value);
- }
-}
-
-JSC::EncodedJSValue functionJSnullableBooleanArgument(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNullableTypesTestInterface", "call nullableBooleanArgument");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NullableTypesTestInterface* impl =
- GetWrappableOrSetException<NullableTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<base::optional<bool > >::ConversionType arg;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- (kConversionFlagNullable),
- &exception_state, &arg);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->NullableBooleanArgument(arg);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSnullableBooleanOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNullableTypesTestInterface", "call nullableBooleanOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NullableTypesTestInterface* impl =
- GetWrappableOrSetException<NullableTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<base::optional<bool > >::ReturnType return_value = impl->NullableBooleanOperation();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSnullableNumericArgument(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNullableTypesTestInterface", "call nullableNumericArgument");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NullableTypesTestInterface* impl =
- GetWrappableOrSetException<NullableTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<base::optional<int32_t > >::ConversionType arg;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- (kConversionFlagNullable),
- &exception_state, &arg);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->NullableNumericArgument(arg);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSnullableNumericOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNullableTypesTestInterface", "call nullableNumericOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NullableTypesTestInterface* impl =
- GetWrappableOrSetException<NullableTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<base::optional<int32_t > >::ReturnType return_value = impl->NullableNumericOperation();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSnullableObjectArgument(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNullableTypesTestInterface", "call nullableObjectArgument");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NullableTypesTestInterface* impl =
- GetWrappableOrSetException<NullableTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<scoped_refptr<ArbitraryInterface> >::ConversionType arg;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- (kConversionFlagNullable),
- &exception_state, &arg);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->NullableObjectArgument(arg);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSnullableObjectOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNullableTypesTestInterface", "call nullableObjectOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NullableTypesTestInterface* impl =
- GetWrappableOrSetException<NullableTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<scoped_refptr<ArbitraryInterface> >::ReturnType return_value = impl->NullableObjectOperation();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSnullableStringArgument(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNullableTypesTestInterface", "call nullableStringArgument");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NullableTypesTestInterface* impl =
- GetWrappableOrSetException<NullableTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<base::optional<std::string > >::ConversionType arg;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- (kConversionFlagNullable),
- &exception_state, &arg);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->NullableStringArgument(arg);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSnullableStringOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNullableTypesTestInterface", "call nullableStringOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NullableTypesTestInterface* impl =
- GetWrappableOrSetException<NullableTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<base::optional<std::string > >::ReturnType return_value = impl->NullableStringOperation();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCNullableTypesTestInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCNullableTypesTestInterface.h
deleted file mode 100644
index 78bc0ed..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCNullableTypesTestInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCNullableTypesTestInterface_h
-#define JSCNullableTypesTestInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/nullable_types_test_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCNullableTypesTestInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to NullableTypesTestInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCNullableTypesTestInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<NullableTypesTestInterface>& impl);
- ~JSCNullableTypesTestInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCNullableTypesTestInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCNumericTypesTestInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCNumericTypesTestInterface.cc
deleted file mode 100644
index 6db7067..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCNumericTypesTestInterface.cc
+++ /dev/null
@@ -1,1973 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCNumericTypesTestInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::NumericTypesTestInterface;
-using cobalt::bindings::testing::JSCNumericTypesTestInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSbyteProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSbyteProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSoctetProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSoctetProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSshortProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSshortProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSunsignedShortProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSunsignedShortProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSlongProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSlongProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSunsignedLongProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSunsignedLongProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSlongLongProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSlongLongProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSunsignedLongLongProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSunsignedLongLongProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSdoubleProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSdoubleProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSunrestrictedDoubleProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSunrestrictedDoubleProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::EncodedJSValue functionJSbyteArgumentOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSbyteReturnOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSdoubleArgumentOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSdoubleReturnOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSlongArgumentOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSlongLongArgumentOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSlongLongReturnOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSlongReturnOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSoctetArgumentOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSoctetReturnOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSshortArgumentOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSshortReturnOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSunrestrictedDoubleArgumentOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSunrestrictedDoubleReturnOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSunsignedLongArgumentOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSunsignedLongLongArgumentOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSunsignedLongLongReturnOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSunsignedLongReturnOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSunsignedShortArgumentOperation(JSC::ExecState*);
-JSC::EncodedJSValue functionJSunsignedShortReturnOperation(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCNumericTypesTestInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCNumericTypesTestInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCNumericTypesTestInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNumericTypesTestInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCNumericTypesTestInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNumericTypesTestInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCNumericTypesTestInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNumericTypesTestInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCNumericTypesTestInterface::InterfaceObject::s_info = {
- "NumericTypesTestInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNumericTypesTestInterface::InterfaceObject)
-}; // JSCNumericTypesTestInterface::InterfaceObject::s_info
-
-void JSCNumericTypesTestInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCNumericTypesTestInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCNumericTypesTestInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "NumericTypesTestInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCNumericTypesTestInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCNumericTypesTestInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCNumericTypesTestInterface::Prototype::property_table_values[] = {
- { "byteArgumentOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSbyteArgumentOperation),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "byteReturnOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSbyteReturnOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "doubleArgumentOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSdoubleArgumentOperation),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "doubleReturnOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSdoubleReturnOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "longArgumentOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSlongArgumentOperation),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "longLongArgumentOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSlongLongArgumentOperation),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "longLongReturnOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSlongLongReturnOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "longReturnOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSlongReturnOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "octetArgumentOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSoctetArgumentOperation),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "octetReturnOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSoctetReturnOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "shortArgumentOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSshortArgumentOperation),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "shortReturnOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSshortReturnOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "unrestrictedDoubleArgumentOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSunrestrictedDoubleArgumentOperation),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "unrestrictedDoubleReturnOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSunrestrictedDoubleReturnOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "unsignedLongArgumentOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSunsignedLongArgumentOperation),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "unsignedLongLongArgumentOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSunsignedLongLongArgumentOperation),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "unsignedLongLongReturnOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSunsignedLongLongReturnOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "unsignedLongReturnOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSunsignedLongReturnOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "unsignedShortArgumentOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSunsignedShortArgumentOperation),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "unsignedShortReturnOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSunsignedShortReturnOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCNumericTypesTestInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNumericTypesTestInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCNumericTypesTestInterface::Prototype::property_table_prototype = {
- 84, // compactSize
- 63, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNumericTypesTestInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCNumericTypesTestInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNumericTypesTestInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCNumericTypesTestInterface::Prototype::s_info = {
- "NumericTypesTestInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNumericTypesTestInterface::Prototype)
-}; // JSCNumericTypesTestInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCNumericTypesTestInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCNumericTypesTestInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCNumericTypesTestInterface::Prototype class
-
-const JSC::HashTableValue JSCNumericTypesTestInterface::property_table_values[] = {
- { "byteProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSbyteProperty),
- reinterpret_cast<intptr_t>(setJSbyteProperty),
- JSC::NoIntrinsic
- },
- { "octetProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSoctetProperty),
- reinterpret_cast<intptr_t>(setJSoctetProperty),
- JSC::NoIntrinsic
- },
- { "shortProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSshortProperty),
- reinterpret_cast<intptr_t>(setJSshortProperty),
- JSC::NoIntrinsic
- },
- { "unsignedShortProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSunsignedShortProperty),
- reinterpret_cast<intptr_t>(setJSunsignedShortProperty),
- JSC::NoIntrinsic
- },
- { "longProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSlongProperty),
- reinterpret_cast<intptr_t>(setJSlongProperty),
- JSC::NoIntrinsic
- },
- { "unsignedLongProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSunsignedLongProperty),
- reinterpret_cast<intptr_t>(setJSunsignedLongProperty),
- JSC::NoIntrinsic
- },
- { "longLongProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSlongLongProperty),
- reinterpret_cast<intptr_t>(setJSlongLongProperty),
- JSC::NoIntrinsic
- },
- { "unsignedLongLongProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSunsignedLongLongProperty),
- reinterpret_cast<intptr_t>(setJSunsignedLongLongProperty),
- JSC::NoIntrinsic
- },
- { "doubleProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSdoubleProperty),
- reinterpret_cast<intptr_t>(setJSdoubleProperty),
- JSC::NoIntrinsic
- },
- { "unrestrictedDoubleProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSunrestrictedDoubleProperty),
- reinterpret_cast<intptr_t>(setJSunrestrictedDoubleProperty),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCNumericTypesTestInterface::property_table_values
-
-// static
-const JSC::HashTable JSCNumericTypesTestInterface::property_table_prototype = {
- 41, // compactSize
- 31, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCNumericTypesTestInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCNumericTypesTestInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCNumericTypesTestInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCNumericTypesTestInterface::NonTrivialStaticFields>
- JSCNumericTypesTestInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCNumericTypesTestInterface::s_info = {
- "NumericTypesTestInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCNumericTypesTestInterface)
-}; // JSCNumericTypesTestInterface::s_info
-
-// static
-JSC::JSObject* JSCNumericTypesTestInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCNumericTypesTestInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCNumericTypesTestInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCNumericTypesTestInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == NumericTypesTestInterface::NumericTypesTestInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match NumericTypesTestInterface::NumericTypesTestInterfaceWrappableType()";
- return NULL;
- }
- NumericTypesTestInterface* impl_ptr =
- base::polymorphic_downcast<NumericTypesTestInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCNumericTypesTestInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCNumericTypesTestInterface>(global_data.heap))
- JSCNumericTypesTestInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCNumericTypesTestInterface::JSCNumericTypesTestInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<NumericTypesTestInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCNumericTypesTestInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCNumericTypesTestInterface::~JSCNumericTypesTestInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCNumericTypesTestInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCNumericTypesTestInterface* this_object = JSC::jsCast<JSCNumericTypesTestInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCNumericTypesTestInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCNumericTypesTestInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCNumericTypesTestInterface* this_object = JSC::jsCast<JSCNumericTypesTestInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCNumericTypesTestInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCNumericTypesTestInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCNumericTypesTestInterface* this_object = JSC::jsCast<JSCNumericTypesTestInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCNumericTypesTestInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSbyteProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "get byteProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->byte_property());
- return result;
-}
-
-void setJSbyteProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "set byteProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<int8_t >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_byte_property(cobalt_value);
- }
-}
-
-JSC::JSValue getJSoctetProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "get octetProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->octet_property());
- return result;
-}
-
-void setJSoctetProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "set octetProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<uint8_t >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_octet_property(cobalt_value);
- }
-}
-
-JSC::JSValue getJSshortProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "get shortProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->short_property());
- return result;
-}
-
-void setJSshortProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "set shortProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<int16_t >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_short_property(cobalt_value);
- }
-}
-
-JSC::JSValue getJSunsignedShortProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "get unsignedShortProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->unsigned_short_property());
- return result;
-}
-
-void setJSunsignedShortProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "set unsignedShortProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<uint16_t >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_unsigned_short_property(cobalt_value);
- }
-}
-
-JSC::JSValue getJSlongProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "get longProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->long_property());
- return result;
-}
-
-void setJSlongProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "set longProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<int32_t >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_long_property(cobalt_value);
- }
-}
-
-JSC::JSValue getJSunsignedLongProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "get unsignedLongProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->unsigned_long_property());
- return result;
-}
-
-void setJSunsignedLongProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "set unsignedLongProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<uint32_t >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_unsigned_long_property(cobalt_value);
- }
-}
-
-JSC::JSValue getJSlongLongProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "get longLongProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->long_long_property());
- return result;
-}
-
-void setJSlongLongProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "set longLongProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<int64_t >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_long_long_property(cobalt_value);
- }
-}
-
-JSC::JSValue getJSunsignedLongLongProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "get unsignedLongLongProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->unsigned_long_long_property());
- return result;
-}
-
-void setJSunsignedLongLongProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "set unsignedLongLongProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<uint64_t >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_unsigned_long_long_property(cobalt_value);
- }
-}
-
-JSC::JSValue getJSdoubleProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "get doubleProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->double_property());
- return result;
-}
-
-void setJSdoubleProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "set doubleProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<double >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- (kConversionFlagRestricted), &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_double_property(cobalt_value);
- }
-}
-
-JSC::JSValue getJSunrestrictedDoubleProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "get unrestrictedDoubleProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->unrestricted_double_property());
- return result;
-}
-
-void setJSunrestrictedDoubleProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "set unrestrictedDoubleProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<double >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_unrestricted_double_property(cobalt_value);
- }
-}
-
-JSC::EncodedJSValue functionJSbyteArgumentOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "call byteArgumentOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<int8_t >::ConversionType arg1;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg1);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->ByteArgumentOperation(arg1);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSbyteReturnOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "call byteReturnOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<int8_t >::ReturnType return_value = impl->ByteReturnOperation();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSdoubleArgumentOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "call doubleArgumentOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<double >::ConversionType arg1;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- (kConversionFlagRestricted),
- &exception_state, &arg1);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->DoubleArgumentOperation(arg1);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSdoubleReturnOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "call doubleReturnOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<double >::ReturnType return_value = impl->DoubleReturnOperation();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSlongArgumentOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "call longArgumentOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<int32_t >::ConversionType arg1;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg1);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->LongArgumentOperation(arg1);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSlongLongArgumentOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "call longLongArgumentOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<int64_t >::ConversionType arg1;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg1);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->LongLongArgumentOperation(arg1);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSlongLongReturnOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "call longLongReturnOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<int64_t >::ReturnType return_value = impl->LongLongReturnOperation();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSlongReturnOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "call longReturnOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<int32_t >::ReturnType return_value = impl->LongReturnOperation();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSoctetArgumentOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "call octetArgumentOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<uint8_t >::ConversionType arg1;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg1);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->OctetArgumentOperation(arg1);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSoctetReturnOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "call octetReturnOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<uint8_t >::ReturnType return_value = impl->OctetReturnOperation();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSshortArgumentOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "call shortArgumentOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<int16_t >::ConversionType arg1;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg1);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->ShortArgumentOperation(arg1);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSshortReturnOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "call shortReturnOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<int16_t >::ReturnType return_value = impl->ShortReturnOperation();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSunrestrictedDoubleArgumentOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "call unrestrictedDoubleArgumentOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<double >::ConversionType arg1;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg1);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->UnrestrictedDoubleArgumentOperation(arg1);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSunrestrictedDoubleReturnOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "call unrestrictedDoubleReturnOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<double >::ReturnType return_value = impl->UnrestrictedDoubleReturnOperation();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSunsignedLongArgumentOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "call unsignedLongArgumentOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<uint32_t >::ConversionType arg1;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg1);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->UnsignedLongArgumentOperation(arg1);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSunsignedLongLongArgumentOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "call unsignedLongLongArgumentOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<uint64_t >::ConversionType arg1;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg1);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->UnsignedLongLongArgumentOperation(arg1);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSunsignedLongLongReturnOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "call unsignedLongLongReturnOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<uint64_t >::ReturnType return_value = impl->UnsignedLongLongReturnOperation();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSunsignedLongReturnOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "call unsignedLongReturnOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<uint32_t >::ReturnType return_value = impl->UnsignedLongReturnOperation();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSunsignedShortArgumentOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "call unsignedShortArgumentOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<uint16_t >::ConversionType arg1;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg1);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->UnsignedShortArgumentOperation(arg1);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSunsignedShortReturnOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCNumericTypesTestInterface", "call unsignedShortReturnOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- NumericTypesTestInterface* impl =
- GetWrappableOrSetException<NumericTypesTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<uint16_t >::ReturnType return_value = impl->UnsignedShortReturnOperation();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCNumericTypesTestInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCNumericTypesTestInterface.h
deleted file mode 100644
index 38b8244..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCNumericTypesTestInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCNumericTypesTestInterface_h
-#define JSCNumericTypesTestInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/numeric_types_test_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCNumericTypesTestInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to NumericTypesTestInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCNumericTypesTestInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<NumericTypesTestInterface>& impl);
- ~JSCNumericTypesTestInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCNumericTypesTestInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCObjectTypeBindingsInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCObjectTypeBindingsInterface.cc
deleted file mode 100644
index 6ce03c8..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCObjectTypeBindingsInterface.cc
+++ /dev/null
@@ -1,924 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCObjectTypeBindingsInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-#include "JSCArbitraryInterface.h"
-#include "JSCBaseInterface.h"
-#include "JSCDerivedInterface.h"
-#include "cobalt/bindings/testing/arbitrary_interface.h"
-#include "cobalt/bindings/testing/base_interface.h"
-#include "cobalt/bindings/testing/derived_interface.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::ObjectTypeBindingsInterface;
-using cobalt::bindings::testing::JSCObjectTypeBindingsInterface;
-using cobalt::bindings::testing::ArbitraryInterface;
-using cobalt::bindings::testing::BaseInterface;
-using cobalt::bindings::testing::DerivedInterface;
-using cobalt::bindings::testing::JSCArbitraryInterface;
-using cobalt::bindings::testing::JSCBaseInterface;
-using cobalt::bindings::testing::JSCDerivedInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSarbitraryObject(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSarbitraryObject(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSbaseInterface(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-JSC::JSValue getJSderivedInterface(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSderivedInterface(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSobjectProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSobjectProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCObjectTypeBindingsInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCObjectTypeBindingsInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCObjectTypeBindingsInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCObjectTypeBindingsInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCObjectTypeBindingsInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCObjectTypeBindingsInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCObjectTypeBindingsInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCObjectTypeBindingsInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCObjectTypeBindingsInterface::InterfaceObject::s_info = {
- "ObjectTypeBindingsInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCObjectTypeBindingsInterface::InterfaceObject)
-}; // JSCObjectTypeBindingsInterface::InterfaceObject::s_info
-
-void JSCObjectTypeBindingsInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCObjectTypeBindingsInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCObjectTypeBindingsInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "ObjectTypeBindingsInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCObjectTypeBindingsInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCObjectTypeBindingsInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCObjectTypeBindingsInterface::Prototype::property_table_values[] = {
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCObjectTypeBindingsInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCObjectTypeBindingsInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCObjectTypeBindingsInterface::Prototype::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCObjectTypeBindingsInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCObjectTypeBindingsInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCObjectTypeBindingsInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCObjectTypeBindingsInterface::Prototype::s_info = {
- "ObjectTypeBindingsInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCObjectTypeBindingsInterface::Prototype)
-}; // JSCObjectTypeBindingsInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCObjectTypeBindingsInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCObjectTypeBindingsInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCObjectTypeBindingsInterface::Prototype class
-
-const JSC::HashTableValue JSCObjectTypeBindingsInterface::property_table_values[] = {
- { "arbitraryObject",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSarbitraryObject),
- reinterpret_cast<intptr_t>(setJSarbitraryObject),
- JSC::NoIntrinsic
- },
- { "baseInterface",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJSbaseInterface),
- 0,
- JSC::NoIntrinsic
- },
- { "derivedInterface",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSderivedInterface),
- reinterpret_cast<intptr_t>(setJSderivedInterface),
- JSC::NoIntrinsic
- },
- { "objectProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSobjectProperty),
- reinterpret_cast<intptr_t>(setJSobjectProperty),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCObjectTypeBindingsInterface::property_table_values
-
-// static
-const JSC::HashTable JSCObjectTypeBindingsInterface::property_table_prototype = {
- 19, // compactSize
- 15, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCObjectTypeBindingsInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCObjectTypeBindingsInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCObjectTypeBindingsInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCObjectTypeBindingsInterface::NonTrivialStaticFields>
- JSCObjectTypeBindingsInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCObjectTypeBindingsInterface::s_info = {
- "ObjectTypeBindingsInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCObjectTypeBindingsInterface)
-}; // JSCObjectTypeBindingsInterface::s_info
-
-// static
-JSC::JSObject* JSCObjectTypeBindingsInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCObjectTypeBindingsInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCObjectTypeBindingsInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCObjectTypeBindingsInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == ObjectTypeBindingsInterface::ObjectTypeBindingsInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match ObjectTypeBindingsInterface::ObjectTypeBindingsInterfaceWrappableType()";
- return NULL;
- }
- ObjectTypeBindingsInterface* impl_ptr =
- base::polymorphic_downcast<ObjectTypeBindingsInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCObjectTypeBindingsInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCObjectTypeBindingsInterface>(global_data.heap))
- JSCObjectTypeBindingsInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCObjectTypeBindingsInterface::JSCObjectTypeBindingsInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<ObjectTypeBindingsInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCObjectTypeBindingsInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCObjectTypeBindingsInterface::~JSCObjectTypeBindingsInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCObjectTypeBindingsInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCObjectTypeBindingsInterface* this_object = JSC::jsCast<JSCObjectTypeBindingsInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCObjectTypeBindingsInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCObjectTypeBindingsInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCObjectTypeBindingsInterface* this_object = JSC::jsCast<JSCObjectTypeBindingsInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCObjectTypeBindingsInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCObjectTypeBindingsInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCObjectTypeBindingsInterface* this_object = JSC::jsCast<JSCObjectTypeBindingsInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCObjectTypeBindingsInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSarbitraryObject(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCObjectTypeBindingsInterface", "get arbitraryObject");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ObjectTypeBindingsInterface* impl =
- GetWrappableOrSetException<ObjectTypeBindingsInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->arbitrary_object());
- return result;
-}
-
-void setJSarbitraryObject(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCObjectTypeBindingsInterface", "set arbitraryObject");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- ObjectTypeBindingsInterface* impl =
- GetWrappableOrSetException<ObjectTypeBindingsInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<scoped_refptr<ArbitraryInterface> >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_arbitrary_object(cobalt_value);
- }
-}
-
-JSC::JSValue getJSbaseInterface(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCObjectTypeBindingsInterface", "get baseInterface");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ObjectTypeBindingsInterface* impl =
- GetWrappableOrSetException<ObjectTypeBindingsInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->base_interface());
- return result;
-}
-
-JSC::JSValue getJSderivedInterface(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCObjectTypeBindingsInterface", "get derivedInterface");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ObjectTypeBindingsInterface* impl =
- GetWrappableOrSetException<ObjectTypeBindingsInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->derived_interface());
- return result;
-}
-
-void setJSderivedInterface(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCObjectTypeBindingsInterface", "set derivedInterface");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- ObjectTypeBindingsInterface* impl =
- GetWrappableOrSetException<ObjectTypeBindingsInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<scoped_refptr<DerivedInterface> >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_derived_interface(cobalt_value);
- }
-}
-
-JSC::JSValue getJSobjectProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCObjectTypeBindingsInterface", "get objectProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ObjectTypeBindingsInterface* impl =
- GetWrappableOrSetException<ObjectTypeBindingsInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->object_property());
- return result;
-}
-
-void setJSobjectProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCObjectTypeBindingsInterface", "set objectProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- ObjectTypeBindingsInterface* impl =
- GetWrappableOrSetException<ObjectTypeBindingsInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<OpaqueHandle >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- (kConversionFlagNullable), &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_object_property(cobalt_value);
- }
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCObjectTypeBindingsInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCObjectTypeBindingsInterface.h
deleted file mode 100644
index 54dea0d..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCObjectTypeBindingsInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCObjectTypeBindingsInterface_h
-#define JSCObjectTypeBindingsInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/object_type_bindings_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCObjectTypeBindingsInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to ObjectTypeBindingsInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCObjectTypeBindingsInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<ObjectTypeBindingsInterface>& impl);
- ~JSCObjectTypeBindingsInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCObjectTypeBindingsInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCOperationsTestInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCOperationsTestInterface.cc
deleted file mode 100644
index 816ea6c..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCOperationsTestInterface.cc
+++ /dev/null
@@ -1,1689 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCOperationsTestInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-#include "JSCArbitraryInterface.h"
-#include "cobalt/bindings/testing/arbitrary_interface.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::OperationsTestInterface;
-using cobalt::bindings::testing::JSCOperationsTestInterface;
-using cobalt::bindings::testing::ArbitraryInterface;
-using cobalt::bindings::testing::JSCArbitraryInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::EncodedJSValue functionJSlongFunctionNoArgs(JSC::ExecState*);
-JSC::EncodedJSValue functionJSobjectFunctionNoArgs(JSC::ExecState*);
-JSC::EncodedJSValue functionJSoptionalArgumentWithDefault(JSC::ExecState*);
-JSC::EncodedJSValue functionJSoptionalArguments(JSC::ExecState*);
-JSC::EncodedJSValue functionJSoptionalNullableArgumentsWithDefaults(JSC::ExecState*);
-JSC::EncodedJSValue functionJSoverloadedFunction(JSC::ExecState*);
-JSC::EncodedJSValue functionJSoverloadedFunction1(JSC::ExecState*);
-JSC::EncodedJSValue functionJSoverloadedFunction2(JSC::ExecState*);
-JSC::EncodedJSValue functionJSoverloadedFunction3(JSC::ExecState*);
-JSC::EncodedJSValue functionJSoverloadedFunction4(JSC::ExecState*);
-JSC::EncodedJSValue functionJSoverloadedFunction5(JSC::ExecState*);
-JSC::EncodedJSValue functionJSoverloadedNullable(JSC::ExecState*);
-JSC::EncodedJSValue functionJSoverloadedNullable1(JSC::ExecState*);
-JSC::EncodedJSValue functionJSoverloadedNullable2(JSC::ExecState*);
-JSC::EncodedJSValue functionJSstringFunctionNoArgs(JSC::ExecState*);
-JSC::EncodedJSValue functionJSvariadicPrimitiveArguments(JSC::ExecState*);
-JSC::EncodedJSValue functionJSvariadicStringArgumentsAfterOptionalArgument(JSC::ExecState*);
-JSC::EncodedJSValue functionJSvoidFunctionLongArg(JSC::ExecState*);
-JSC::EncodedJSValue functionJSvoidFunctionNoArgs(JSC::ExecState*);
-JSC::EncodedJSValue functionJSvoidFunctionObjectArg(JSC::ExecState*);
-JSC::EncodedJSValue functionJSvoidFunctionStringArg(JSC::ExecState*);
-JSC::EncodedJSValue staticFunctionJSoverloadedFunction(JSC::ExecState*);
-JSC::EncodedJSValue staticFunctionJSoverloadedFunction1(JSC::ExecState*);
-JSC::EncodedJSValue staticFunctionJSoverloadedFunction2(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCOperationsTestInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCOperationsTestInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCOperationsTestInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { "overloadedFunction",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(staticFunctionJSoverloadedFunction),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCOperationsTestInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCOperationsTestInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCOperationsTestInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCOperationsTestInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCOperationsTestInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCOperationsTestInterface::InterfaceObject::s_info = {
- "OperationsTestInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCOperationsTestInterface::InterfaceObject)
-}; // JSCOperationsTestInterface::InterfaceObject::s_info
-
-void JSCOperationsTestInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCOperationsTestInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCOperationsTestInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "OperationsTestInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCOperationsTestInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCOperationsTestInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCOperationsTestInterface::Prototype::property_table_values[] = {
- { "longFunctionNoArgs",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSlongFunctionNoArgs),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "objectFunctionNoArgs",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSobjectFunctionNoArgs),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "optionalArgumentWithDefault",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSoptionalArgumentWithDefault),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "optionalArguments",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSoptionalArguments),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "optionalNullableArgumentsWithDefaults",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSoptionalNullableArgumentsWithDefaults),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "overloadedFunction",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSoverloadedFunction),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "overloadedNullable",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSoverloadedNullable),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "stringFunctionNoArgs",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSstringFunctionNoArgs),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "variadicPrimitiveArguments",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSvariadicPrimitiveArguments),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "variadicStringArgumentsAfterOptionalArgument",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSvariadicStringArgumentsAfterOptionalArgument),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "voidFunctionLongArg",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSvoidFunctionLongArg),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "voidFunctionNoArgs",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSvoidFunctionNoArgs),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "voidFunctionObjectArg",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSvoidFunctionObjectArg),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "voidFunctionStringArg",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSvoidFunctionStringArg),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCOperationsTestInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCOperationsTestInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCOperationsTestInterface::Prototype::property_table_prototype = {
- 46, // compactSize
- 31, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCOperationsTestInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCOperationsTestInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCOperationsTestInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCOperationsTestInterface::Prototype::s_info = {
- "OperationsTestInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCOperationsTestInterface::Prototype)
-}; // JSCOperationsTestInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCOperationsTestInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCOperationsTestInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCOperationsTestInterface::Prototype class
-
-const JSC::HashTableValue JSCOperationsTestInterface::property_table_values[] = {
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCOperationsTestInterface::property_table_values
-
-// static
-const JSC::HashTable JSCOperationsTestInterface::property_table_prototype = {
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCOperationsTestInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCOperationsTestInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCOperationsTestInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCOperationsTestInterface::NonTrivialStaticFields>
- JSCOperationsTestInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCOperationsTestInterface::s_info = {
- "OperationsTestInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCOperationsTestInterface)
-}; // JSCOperationsTestInterface::s_info
-
-// static
-JSC::JSObject* JSCOperationsTestInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCOperationsTestInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCOperationsTestInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCOperationsTestInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == OperationsTestInterface::OperationsTestInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match OperationsTestInterface::OperationsTestInterfaceWrappableType()";
- return NULL;
- }
- OperationsTestInterface* impl_ptr =
- base::polymorphic_downcast<OperationsTestInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCOperationsTestInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCOperationsTestInterface>(global_data.heap))
- JSCOperationsTestInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCOperationsTestInterface::JSCOperationsTestInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<OperationsTestInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCOperationsTestInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCOperationsTestInterface::~JSCOperationsTestInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCOperationsTestInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCOperationsTestInterface* this_object = JSC::jsCast<JSCOperationsTestInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCOperationsTestInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCOperationsTestInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCOperationsTestInterface* this_object = JSC::jsCast<JSCOperationsTestInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCOperationsTestInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCOperationsTestInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCOperationsTestInterface* this_object = JSC::jsCast<JSCOperationsTestInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCOperationsTestInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::EncodedJSValue functionJSlongFunctionNoArgs(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCOperationsTestInterface", "call longFunctionNoArgs");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- OperationsTestInterface* impl =
- GetWrappableOrSetException<OperationsTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<int32_t >::ReturnType return_value = impl->LongFunctionNoArgs();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSobjectFunctionNoArgs(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCOperationsTestInterface", "call objectFunctionNoArgs");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- OperationsTestInterface* impl =
- GetWrappableOrSetException<OperationsTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<scoped_refptr<ArbitraryInterface> >::ReturnType return_value = impl->ObjectFunctionNoArgs();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSoptionalArgumentWithDefault(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCOperationsTestInterface", "call optionalArgumentWithDefault");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- OperationsTestInterface* impl =
- GetWrappableOrSetException<OperationsTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- // Optional arguments with default values
- TypeTraits<double >::ConversionType arg1 =
- 2.718;
-
- size_t num_set_arguments = 1;
- if (exec_state->argumentCount() > 0) {
- FromJSValue(exec_state,
- exec_state->argument(0),
- (kConversionFlagRestricted),
- &exception_state,
- &arg1);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- }
- impl->OptionalArgumentWithDefault(arg1);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSoptionalArguments(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCOperationsTestInterface", "call optionalArguments");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- OperationsTestInterface* impl =
- GetWrappableOrSetException<OperationsTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<int32_t >::ConversionType arg1;
- // Optional arguments
- TypeTraits<int32_t >::ConversionType arg2;
- TypeTraits<int32_t >::ConversionType arg3;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg1);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
-
- size_t num_set_arguments = 1;
- if (exec_state->argumentCount() > 1) {
- FromJSValue(exec_state,
- exec_state->argument(1),
- kNoConversionFlags,
- &exception_state,
- &arg2);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- ++num_set_arguments;
- }
- if (exec_state->argumentCount() > 2) {
- FromJSValue(exec_state,
- exec_state->argument(2),
- kNoConversionFlags,
- &exception_state,
- &arg3);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- ++num_set_arguments;
- }
- switch (num_set_arguments) {
- case 1:
- {
- impl->OptionalArguments(arg1);
- return JSC::JSValue::encode(JSC::jsUndefined());
- break;
- }
- case 2:
- {
- impl->OptionalArguments(arg1, arg2);
- return JSC::JSValue::encode(JSC::jsUndefined());
- break;
- }
- case 3:
- {
- impl->OptionalArguments(arg1, arg2, arg3);
- return JSC::JSValue::encode(JSC::jsUndefined());
- break;
- }
- default:
- NOTREACHED();
- return JSC::JSValue::encode(JSC::jsUndefined());
- }
-
-}
-
-JSC::EncodedJSValue functionJSoptionalNullableArgumentsWithDefaults(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCOperationsTestInterface", "call optionalNullableArgumentsWithDefaults");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- OperationsTestInterface* impl =
- GetWrappableOrSetException<OperationsTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- // Optional arguments with default values
- TypeTraits<base::optional<bool > >::ConversionType arg1 =
- base::nullopt;
- TypeTraits<scoped_refptr<ArbitraryInterface> >::ConversionType arg2 =
- NULL;
-
- size_t num_set_arguments = 2;
- if (exec_state->argumentCount() > 0) {
- FromJSValue(exec_state,
- exec_state->argument(0),
- (kConversionFlagNullable),
- &exception_state,
- &arg1);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- }
- if (exec_state->argumentCount() > 1) {
- FromJSValue(exec_state,
- exec_state->argument(1),
- (kConversionFlagNullable),
- &exception_state,
- &arg2);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- }
- impl->OptionalNullableArgumentsWithDefaults(arg1, arg2);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSoverloadedFunction(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCOperationsTestInterface", "call overloadedFunction");
- const size_t num_arguments = exec_state->argumentCount();
- switch(num_arguments) {
- case(0): {
- // Overload resolution algorithm details found here:
- // http://heycam.github.io/webidl/#dfn-overload-resolution-algorithm
- if (true) {
- return functionJSoverloadedFunction1(exec_state);
- }
- break;
- }
- case(1): {
- // Overload resolution algorithm details found here:
- // http://heycam.github.io/webidl/#dfn-overload-resolution-algorithm
- JSC::JSValue arg = exec_state->argument(0);
- if (arg.isNumber()) {
- return functionJSoverloadedFunction2(exec_state);
- }
- if (true) {
- return functionJSoverloadedFunction3(exec_state);
- }
- if (true) {
- return functionJSoverloadedFunction2(exec_state);
- }
- break;
- }
- case(3): {
- // Overload resolution algorithm details found here:
- // http://heycam.github.io/webidl/#dfn-overload-resolution-algorithm
- JSC::JSValue arg = exec_state->argument(2);
- if (arg.inherits(JSCArbitraryInterface::s_classinfo())) {
- return functionJSoverloadedFunction5(exec_state);
- }
- if (true) {
- return functionJSoverloadedFunction4(exec_state);
- }
- break;
- }
- }
- // Invalid number of args
- // http://heycam.github.io/webidl/#dfn-overload-resolution-algorithm
- // 4. If S is empty, then throw a TypeError.
- return JSC::throwVMTypeError(exec_state);
-}
-
-JSC::EncodedJSValue functionJSoverloadedFunction1(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- OperationsTestInterface* impl =
- GetWrappableOrSetException<OperationsTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- impl->OverloadedFunction();
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSoverloadedFunction2(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- OperationsTestInterface* impl =
- GetWrappableOrSetException<OperationsTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<int32_t >::ConversionType arg;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->OverloadedFunction(arg);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSoverloadedFunction3(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- OperationsTestInterface* impl =
- GetWrappableOrSetException<OperationsTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<std::string >::ConversionType arg;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->OverloadedFunction(arg);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSoverloadedFunction4(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- OperationsTestInterface* impl =
- GetWrappableOrSetException<OperationsTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 3;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<int32_t >::ConversionType arg1;
- TypeTraits<int32_t >::ConversionType arg2;
- TypeTraits<int32_t >::ConversionType arg3;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg1);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
-
- DCHECK_LT(1, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(1),
- kNoConversionFlags,
- &exception_state, &arg2);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
-
- DCHECK_LT(2, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(2),
- kNoConversionFlags,
- &exception_state, &arg3);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->OverloadedFunction(arg1, arg2, arg3);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSoverloadedFunction5(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- OperationsTestInterface* impl =
- GetWrappableOrSetException<OperationsTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 3;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<int32_t >::ConversionType arg1;
- TypeTraits<int32_t >::ConversionType arg2;
- TypeTraits<scoped_refptr<ArbitraryInterface> >::ConversionType arg3;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg1);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
-
- DCHECK_LT(1, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(1),
- kNoConversionFlags,
- &exception_state, &arg2);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
-
- DCHECK_LT(2, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(2),
- kNoConversionFlags,
- &exception_state, &arg3);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->OverloadedFunction(arg1, arg2, arg3);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSoverloadedNullable(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCOperationsTestInterface", "call overloadedNullable");
- const size_t num_arguments = exec_state->argumentCount();
- switch(num_arguments) {
- case(1): {
- // Overload resolution algorithm details found here:
- // http://heycam.github.io/webidl/#dfn-overload-resolution-algorithm
- JSC::JSValue arg = exec_state->argument(0);
- if (arg.isUndefinedOrNull()) {
- return functionJSoverloadedNullable2(exec_state);
- }
- if (true) {
- return functionJSoverloadedNullable1(exec_state);
- }
- break;
- }
- }
- // Invalid number of args
- // http://heycam.github.io/webidl/#dfn-overload-resolution-algorithm
- // 4. If S is empty, then throw a TypeError.
- return JSC::throwVMTypeError(exec_state);
-}
-
-JSC::EncodedJSValue functionJSoverloadedNullable1(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- OperationsTestInterface* impl =
- GetWrappableOrSetException<OperationsTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<int32_t >::ConversionType arg;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->OverloadedNullable(arg);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSoverloadedNullable2(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- OperationsTestInterface* impl =
- GetWrappableOrSetException<OperationsTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<base::optional<bool > >::ConversionType arg;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- (kConversionFlagNullable),
- &exception_state, &arg);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->OverloadedNullable(arg);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSstringFunctionNoArgs(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCOperationsTestInterface", "call stringFunctionNoArgs");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- OperationsTestInterface* impl =
- GetWrappableOrSetException<OperationsTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<std::string >::ReturnType return_value = impl->StringFunctionNoArgs();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSvariadicPrimitiveArguments(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCOperationsTestInterface", "call variadicPrimitiveArguments");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- OperationsTestInterface* impl =
- GetWrappableOrSetException<OperationsTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- // Variadic argument
- TypeTraits<std::vector<int32_t> >::ConversionType bools;
-
- // Get variadic arguments.
- const size_t kFirstVariadicArgIndex = 0;
- if (exec_state->argumentCount() > kFirstVariadicArgIndex) {
- bools.resize(exec_state->argumentCount() - kFirstVariadicArgIndex);
- for (int i = 0; i + kFirstVariadicArgIndex < exec_state->argumentCount(); ++i) {
- FromJSValue(exec_state,
- exec_state->argument(i + kFirstVariadicArgIndex),
- kNoConversionFlags,
- &exception_state,
- &bools[i]);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- }
- }
- impl->VariadicPrimitiveArguments(bools);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSvariadicStringArgumentsAfterOptionalArgument(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCOperationsTestInterface", "call variadicStringArgumentsAfterOptionalArgument");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- OperationsTestInterface* impl =
- GetWrappableOrSetException<OperationsTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- // Optional arguments
- TypeTraits<bool >::ConversionType optional_arg;
- // Variadic argument
- TypeTraits<std::vector<std::string> >::ConversionType strings;
-
- size_t num_set_arguments = 0;
- if (exec_state->argumentCount() > 0) {
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state,
- &optional_arg);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- ++num_set_arguments;
- }
-
- // Get variadic arguments.
- const size_t kLastOptionalArgIndex = 1;
- if (num_set_arguments == kLastOptionalArgIndex) {
- // If the last optional argument has been set, we will call the overload
- // that takes the variadic argument, possibly with an empty vector in the
- // case that there are no more arguments left.
- ++num_set_arguments;
- }
- const size_t kFirstVariadicArgIndex = 1;
- if (exec_state->argumentCount() > kFirstVariadicArgIndex) {
- strings.resize(exec_state->argumentCount() - kFirstVariadicArgIndex);
- for (int i = 0; i + kFirstVariadicArgIndex < exec_state->argumentCount(); ++i) {
- FromJSValue(exec_state,
- exec_state->argument(i + kFirstVariadicArgIndex),
- kNoConversionFlags,
- &exception_state,
- &strings[i]);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- }
- }
- switch (num_set_arguments) {
- case 0:
- {
- impl->VariadicStringArgumentsAfterOptionalArgument();
- return JSC::JSValue::encode(JSC::jsUndefined());
- break;
- }
- case 2:
- {
- impl->VariadicStringArgumentsAfterOptionalArgument(optional_arg, strings);
- return JSC::JSValue::encode(JSC::jsUndefined());
- break;
- }
- default:
- NOTREACHED();
- return JSC::JSValue::encode(JSC::jsUndefined());
- }
-
-}
-
-JSC::EncodedJSValue functionJSvoidFunctionLongArg(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCOperationsTestInterface", "call voidFunctionLongArg");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- OperationsTestInterface* impl =
- GetWrappableOrSetException<OperationsTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<int32_t >::ConversionType arg;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->VoidFunctionLongArg(arg);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSvoidFunctionNoArgs(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCOperationsTestInterface", "call voidFunctionNoArgs");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- OperationsTestInterface* impl =
- GetWrappableOrSetException<OperationsTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- impl->VoidFunctionNoArgs();
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSvoidFunctionObjectArg(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCOperationsTestInterface", "call voidFunctionObjectArg");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- OperationsTestInterface* impl =
- GetWrappableOrSetException<OperationsTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<scoped_refptr<ArbitraryInterface> >::ConversionType arg;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->VoidFunctionObjectArg(arg);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSvoidFunctionStringArg(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCOperationsTestInterface", "call voidFunctionStringArg");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- OperationsTestInterface* impl =
- GetWrappableOrSetException<OperationsTestInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<std::string >::ConversionType arg;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->VoidFunctionStringArg(arg);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue staticFunctionJSoverloadedFunction(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCOperationsTestInterface", "call overloadedFunction");
- const size_t num_arguments = exec_state->argumentCount();
- switch(num_arguments) {
- case(1): {
- // Overload resolution algorithm details found here:
- // http://heycam.github.io/webidl/#dfn-overload-resolution-algorithm
- if (true) {
- return staticFunctionJSoverloadedFunction1(exec_state);
- }
- break;
- }
- case(2): {
- // Overload resolution algorithm details found here:
- // http://heycam.github.io/webidl/#dfn-overload-resolution-algorithm
- if (true) {
- return staticFunctionJSoverloadedFunction2(exec_state);
- }
- break;
- }
- }
- // Invalid number of args
- // http://heycam.github.io/webidl/#dfn-overload-resolution-algorithm
- // 4. If S is empty, then throw a TypeError.
- return JSC::throwVMTypeError(exec_state);
-}
-
-JSC::EncodedJSValue staticFunctionJSoverloadedFunction1(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<double >::ConversionType arg;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- (kConversionFlagRestricted),
- &exception_state, &arg);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- OperationsTestInterface::OverloadedFunction(arg);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue staticFunctionJSoverloadedFunction2(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
-
- const size_t kMinArguments = 2;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<double >::ConversionType arg1;
- TypeTraits<double >::ConversionType arg2;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- (kConversionFlagRestricted),
- &exception_state, &arg1);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
-
- DCHECK_LT(1, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(1),
- (kConversionFlagRestricted),
- &exception_state, &arg2);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- OperationsTestInterface::OverloadedFunction(arg1, arg2);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCOperationsTestInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCOperationsTestInterface.h
deleted file mode 100644
index d1158e9..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCOperationsTestInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCOperationsTestInterface_h
-#define JSCOperationsTestInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/operations_test_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCOperationsTestInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to OperationsTestInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCOperationsTestInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<OperationsTestInterface>& impl);
- ~JSCOperationsTestInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCOperationsTestInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCPutForwardsInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCPutForwardsInterface.cc
deleted file mode 100644
index c51d3be..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCPutForwardsInterface.cc
+++ /dev/null
@@ -1,833 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCPutForwardsInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-#include "JSCArbitraryInterface.h"
-#include "cobalt/bindings/testing/arbitrary_interface.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::PutForwardsInterface;
-using cobalt::bindings::testing::JSCPutForwardsInterface;
-using cobalt::bindings::testing::ArbitraryInterface;
-using cobalt::bindings::testing::JSCArbitraryInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSforwardingAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSforwardingAttribute(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSstaticForwardingAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSstaticForwardingAttribute(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCPutForwardsInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCPutForwardsInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCPutForwardsInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { "staticForwardingAttribute",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJSstaticForwardingAttribute),
- 0,
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCPutForwardsInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCPutForwardsInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCPutForwardsInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCPutForwardsInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCPutForwardsInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCPutForwardsInterface::InterfaceObject::s_info = {
- "PutForwardsInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCPutForwardsInterface::InterfaceObject)
-}; // JSCPutForwardsInterface::InterfaceObject::s_info
-
-void JSCPutForwardsInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCPutForwardsInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCPutForwardsInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "PutForwardsInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCPutForwardsInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCPutForwardsInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCPutForwardsInterface::Prototype::property_table_values[] = {
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCPutForwardsInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCPutForwardsInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCPutForwardsInterface::Prototype::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCPutForwardsInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCPutForwardsInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCPutForwardsInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCPutForwardsInterface::Prototype::s_info = {
- "PutForwardsInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCPutForwardsInterface::Prototype)
-}; // JSCPutForwardsInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCPutForwardsInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCPutForwardsInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCPutForwardsInterface::Prototype class
-
-const JSC::HashTableValue JSCPutForwardsInterface::property_table_values[] = {
- { "forwardingAttribute",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSforwardingAttribute),
- reinterpret_cast<intptr_t>(setJSforwardingAttribute),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCPutForwardsInterface::property_table_values
-
-// static
-const JSC::HashTable JSCPutForwardsInterface::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCPutForwardsInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCPutForwardsInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCPutForwardsInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCPutForwardsInterface::NonTrivialStaticFields>
- JSCPutForwardsInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCPutForwardsInterface::s_info = {
- "PutForwardsInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCPutForwardsInterface)
-}; // JSCPutForwardsInterface::s_info
-
-// static
-JSC::JSObject* JSCPutForwardsInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCPutForwardsInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCPutForwardsInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCPutForwardsInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == PutForwardsInterface::PutForwardsInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match PutForwardsInterface::PutForwardsInterfaceWrappableType()";
- return NULL;
- }
- PutForwardsInterface* impl_ptr =
- base::polymorphic_downcast<PutForwardsInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCPutForwardsInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCPutForwardsInterface>(global_data.heap))
- JSCPutForwardsInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCPutForwardsInterface::JSCPutForwardsInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<PutForwardsInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCPutForwardsInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCPutForwardsInterface::~JSCPutForwardsInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCPutForwardsInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCPutForwardsInterface* this_object = JSC::jsCast<JSCPutForwardsInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCPutForwardsInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCPutForwardsInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCPutForwardsInterface* this_object = JSC::jsCast<JSCPutForwardsInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCPutForwardsInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCPutForwardsInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCPutForwardsInterface* this_object = JSC::jsCast<JSCPutForwardsInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCPutForwardsInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSforwardingAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCPutForwardsInterface", "get forwardingAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- PutForwardsInterface* impl =
- GetWrappableOrSetException<PutForwardsInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->forwarding_attribute());
- return result;
-}
-
-void setJSforwardingAttribute(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCPutForwardsInterface", "set forwardingAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- PutForwardsInterface* impl =
- GetWrappableOrSetException<PutForwardsInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- {
- scoped_refptr<ArbitraryInterface> forwarded_impl =
- impl->forwarding_attribute();
- if (!forwarded_impl) {
- return;
- }
- TypeTraits<std::string >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- forwarded_impl->set_arbitrary_property(cobalt_value);
- }
- }
-
-}
-
-JSC::JSValue getJSstaticForwardingAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCPutForwardsInterface", "get staticForwardingAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
-
- JSC::JSValue result = ToJSValue(
- global_object,
- PutForwardsInterface::static_forwarding_attribute());
- return result;
-}
-
-void setJSstaticForwardingAttribute(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCPutForwardsInterface", "set staticForwardingAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- {
- scoped_refptr<ArbitraryInterface> forwarded_impl =
- PutForwardsInterface::static_forwarding_attribute();
- if (!forwarded_impl) {
- return;
- }
- TypeTraits<std::string >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- forwarded_impl->set_arbitrary_property(cobalt_value);
- }
- }
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCPutForwardsInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCPutForwardsInterface.h
deleted file mode 100644
index 2fbc8e1..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCPutForwardsInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCPutForwardsInterface_h
-#define JSCPutForwardsInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/put_forwards_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCPutForwardsInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to PutForwardsInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCPutForwardsInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<PutForwardsInterface>& impl);
- ~JSCPutForwardsInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCPutForwardsInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCSequenceUser.cc b/src/cobalt/bindings/generated/jsc/testing/JSCSequenceUser.cc
deleted file mode 100644
index 0d06309..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCSequenceUser.cc
+++ /dev/null
@@ -1,1175 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCSequenceUser.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::SequenceUser;
-using cobalt::bindings::testing::JSCSequenceUser;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::EncodedJSValue constructorJSSequenceUser(JSC::ExecState*);
-JSC::EncodedJSValue functionJSgetInterfaceSequence(JSC::ExecState*);
-JSC::EncodedJSValue functionJSgetInterfaceSequenceSequenceSequence(JSC::ExecState*);
-JSC::EncodedJSValue functionJSgetLongSequence(JSC::ExecState*);
-JSC::EncodedJSValue functionJSgetStringSequence(JSC::ExecState*);
-JSC::EncodedJSValue functionJSgetStringSequenceSequence(JSC::ExecState*);
-JSC::EncodedJSValue functionJSgetUnionOfStringAndStringSequence(JSC::ExecState*);
-JSC::EncodedJSValue functionJSgetUnionSequence(JSC::ExecState*);
-JSC::EncodedJSValue functionJSsetInterfaceSequence(JSC::ExecState*);
-JSC::EncodedJSValue functionJSsetInterfaceSequenceSequenceSequence(JSC::ExecState*);
-JSC::EncodedJSValue functionJSsetLongSequence(JSC::ExecState*);
-JSC::EncodedJSValue functionJSsetStringSequence(JSC::ExecState*);
-JSC::EncodedJSValue functionJSsetStringSequenceSequence(JSC::ExecState*);
-JSC::EncodedJSValue functionJSsetUnionOfStringAndStringSequence(JSC::ExecState*);
-JSC::EncodedJSValue functionJSsetUnionSequence(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCSequenceUser::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCSequenceUser";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCSequenceUser::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCSequenceUser::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCSequenceUser::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCSequenceUser::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCSequenceUser::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCSequenceUser::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCSequenceUser::InterfaceObject::s_info = {
- "SequenceUserConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCSequenceUser::InterfaceObject)
-}; // JSCSequenceUser::InterfaceObject::s_info
-
-void JSCSequenceUser::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCSequenceUser::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCSequenceUser::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, &constructorJSSequenceUser);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "SequenceUser");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCSequenceUser::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCSequenceUser::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCSequenceUser::Prototype::property_table_values[] = {
- { "getInterfaceSequence",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSgetInterfaceSequence),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "getInterfaceSequenceSequenceSequence",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSgetInterfaceSequenceSequenceSequence),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "getLongSequence",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSgetLongSequence),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "getStringSequence",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSgetStringSequence),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "getStringSequenceSequence",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSgetStringSequenceSequence),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "getUnionOfStringAndStringSequence",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSgetUnionOfStringAndStringSequence),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "getUnionSequence",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSgetUnionSequence),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "setInterfaceSequence",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSsetInterfaceSequence),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "setInterfaceSequenceSequenceSequence",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSsetInterfaceSequenceSequenceSequence),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "setLongSequence",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSsetLongSequence),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "setStringSequence",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSsetStringSequence),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "setStringSequenceSequence",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSsetStringSequenceSequence),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "setUnionOfStringAndStringSequence",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSsetUnionOfStringAndStringSequence),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "setUnionSequence",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSsetUnionSequence),
- static_cast<intptr_t>(1),
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCSequenceUser::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCSequenceUser::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCSequenceUser::Prototype::property_table_prototype = {
- 46, // compactSize
- 31, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCSequenceUser::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCSequenceUser::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCSequenceUser::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCSequenceUser::Prototype::s_info = {
- "SequenceUserPrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCSequenceUser::Prototype)
-}; // JSCSequenceUser::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCSequenceUser::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCSequenceUser::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCSequenceUser::Prototype class
-
-const JSC::HashTableValue JSCSequenceUser::property_table_values[] = {
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCSequenceUser::property_table_values
-
-// static
-const JSC::HashTable JSCSequenceUser::property_table_prototype = {
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCSequenceUser::property_table_prototype
-
-// static
-const JSC::HashTable* JSCSequenceUser::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCSequenceUser::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCSequenceUser::NonTrivialStaticFields>
- JSCSequenceUser::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCSequenceUser::s_info = {
- "SequenceUser", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCSequenceUser)
-}; // JSCSequenceUser::s_info
-
-// static
-JSC::JSObject* JSCSequenceUser::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCSequenceUser::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCSequenceUser::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCSequenceUser::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == SequenceUser::SequenceUserWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match SequenceUser::SequenceUserWrappableType()";
- return NULL;
- }
- SequenceUser* impl_ptr =
- base::polymorphic_downcast<SequenceUser*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCSequenceUser* wrapper =
- new (NotNull, JSC::allocateCell<JSCSequenceUser>(global_data.heap))
- JSCSequenceUser(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCSequenceUser::JSCSequenceUser(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<SequenceUser>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCSequenceUser::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCSequenceUser::~JSCSequenceUser() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCSequenceUser::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCSequenceUser* this_object = JSC::jsCast<JSCSequenceUser*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCSequenceUser, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCSequenceUser::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCSequenceUser* this_object = JSC::jsCast<JSCSequenceUser*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCSequenceUser, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCSequenceUser::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCSequenceUser* this_object = JSC::jsCast<JSCSequenceUser*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCSequenceUser, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::EncodedJSValue constructorJSSequenceUser(JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- scoped_refptr<SequenceUser> new_object =
- new SequenceUser();
- return JSC::JSValue::encode(ToJSValue(global_object, new_object));
-
-}
-
-JSC::EncodedJSValue functionJSgetInterfaceSequence(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCSequenceUser", "call getInterfaceSequence");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- SequenceUser* impl =
- GetWrappableOrSetException<SequenceUser>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<script::Sequence< scoped_refptr<ArbitraryInterface> > >::ReturnType return_value = impl->GetInterfaceSequence();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSgetInterfaceSequenceSequenceSequence(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCSequenceUser", "call getInterfaceSequenceSequenceSequence");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- SequenceUser* impl =
- GetWrappableOrSetException<SequenceUser>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<script::Sequence< script::Sequence< script::Sequence< scoped_refptr<ArbitraryInterface> > > > >::ReturnType return_value = impl->GetInterfaceSequenceSequenceSequence();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSgetLongSequence(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCSequenceUser", "call getLongSequence");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- SequenceUser* impl =
- GetWrappableOrSetException<SequenceUser>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<script::Sequence< int32_t > >::ReturnType return_value = impl->GetLongSequence();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSgetStringSequence(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCSequenceUser", "call getStringSequence");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- SequenceUser* impl =
- GetWrappableOrSetException<SequenceUser>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<script::Sequence< std::string > >::ReturnType return_value = impl->GetStringSequence();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSgetStringSequenceSequence(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCSequenceUser", "call getStringSequenceSequence");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- SequenceUser* impl =
- GetWrappableOrSetException<SequenceUser>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<script::Sequence< script::Sequence< std::string > > >::ReturnType return_value = impl->GetStringSequenceSequence();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSgetUnionOfStringAndStringSequence(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCSequenceUser", "call getUnionOfStringAndStringSequence");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- SequenceUser* impl =
- GetWrappableOrSetException<SequenceUser>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<script::UnionType2<std::string, script::Sequence< std::string > > >::ReturnType return_value = impl->GetUnionOfStringAndStringSequence();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSgetUnionSequence(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCSequenceUser", "call getUnionSequence");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- SequenceUser* impl =
- GetWrappableOrSetException<SequenceUser>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<script::Sequence< script::UnionType2<std::string, scoped_refptr<ArbitraryInterface> > > >::ReturnType return_value = impl->GetUnionSequence();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSsetInterfaceSequence(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCSequenceUser", "call setInterfaceSequence");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- SequenceUser* impl =
- GetWrappableOrSetException<SequenceUser>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<script::Sequence< scoped_refptr<ArbitraryInterface> > >::ConversionType elements;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &elements);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->SetInterfaceSequence(elements);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSsetInterfaceSequenceSequenceSequence(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCSequenceUser", "call setInterfaceSequenceSequenceSequence");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- SequenceUser* impl =
- GetWrappableOrSetException<SequenceUser>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<script::Sequence< script::Sequence< script::Sequence< scoped_refptr<ArbitraryInterface> > > > >::ConversionType elements;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &elements);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->SetInterfaceSequenceSequenceSequence(elements);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSsetLongSequence(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCSequenceUser", "call setLongSequence");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- SequenceUser* impl =
- GetWrappableOrSetException<SequenceUser>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<script::Sequence< int32_t > >::ConversionType elements;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &elements);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->SetLongSequence(elements);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSsetStringSequence(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCSequenceUser", "call setStringSequence");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- SequenceUser* impl =
- GetWrappableOrSetException<SequenceUser>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<script::Sequence< std::string > >::ConversionType elements;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &elements);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->SetStringSequence(elements);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSsetStringSequenceSequence(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCSequenceUser", "call setStringSequenceSequence");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- SequenceUser* impl =
- GetWrappableOrSetException<SequenceUser>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<script::Sequence< script::Sequence< std::string > > >::ConversionType elements;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &elements);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->SetStringSequenceSequence(elements);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSsetUnionOfStringAndStringSequence(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCSequenceUser", "call setUnionOfStringAndStringSequence");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- SequenceUser* impl =
- GetWrappableOrSetException<SequenceUser>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<script::UnionType2<std::string, script::Sequence< std::string > > >::ConversionType elements;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &elements);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->SetUnionOfStringAndStringSequence(elements);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSsetUnionSequence(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCSequenceUser", "call setUnionSequence");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- SequenceUser* impl =
- GetWrappableOrSetException<SequenceUser>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<script::Sequence< script::UnionType2<std::string, scoped_refptr<ArbitraryInterface> > > >::ConversionType elements;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &elements);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- impl->SetUnionSequence(elements);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCSequenceUser.h b/src/cobalt/bindings/generated/jsc/testing/JSCSequenceUser.h
deleted file mode 100644
index 251cec3..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCSequenceUser.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCSequenceUser_h
-#define JSCSequenceUser_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/sequence_user.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCSequenceUser
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to SequenceUser.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCSequenceUser(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<SequenceUser>& impl);
- ~JSCSequenceUser();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCSequenceUser_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCSingleOperationInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCSingleOperationInterface.cc
deleted file mode 100644
index 60515f6..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCSingleOperationInterface.cc
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/callback-interface.h.template
-
-// clang-format off
-
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCSingleOperationInterface.h"
-#include "JSCArbitraryInterface.h"
-#include "cobalt/bindings/testing/arbitrary_interface.h"
-
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-
-namespace {
-using cobalt::bindings::testing::SingleOperationInterface;
-using cobalt::bindings::testing::JSCSingleOperationInterface;
-using cobalt::bindings::testing::ArbitraryInterface;
-using cobalt::bindings::testing::JSCArbitraryInterface;
-
-using cobalt::script::javascriptcore::GetCallableForCallbackInterface;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::util::GetExceptionString;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-JSCSingleOperationInterface::JSCSingleOperationInterface(
- JSC::JSObject* implementing_object)
- : implementing_object_(implementing_object) { }
-
-base::optional<int32_t > JSCSingleOperationInterface::HandleCallback(
- const scoped_refptr<script::Wrappable>& callback_this,
- const scoped_refptr<ArbitraryInterface>& value,
- bool* had_exception) const {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(implementing_object_->globalObject());
- JSC::JSGlobalData* global_data = &global_object->globalData();
- JSC::ExecState* exec_state = global_object->globalExec();
- JSC::JSLockHolder lock(*global_data);
-
- // get callable object
- JSC::JSValue callable;
- JSC::CallData call_data;
- JSC::CallType call_type = GetCallableForCallbackInterface(exec_state,
- implementing_object_, "handleCallback", &callable, &call_data);
- if (call_type == JSC::CallTypeNone) {
- // TypeError
- DLOG(INFO) << "User object was not callable.";
- *had_exception = true;
- return base::optional<int32_t >();
- }
-
- JSC::JSValue js_this = ToJSValue(global_object, callback_this);
-
- // Convert args.
- JSC::MarkedArgumentBuffer args;
- args.append(ToJSValue(global_object, value));
-
- // call
- JSC::DynamicGlobalObjectScope global_object_scope(*global_data, global_object);
- JSC::JSValue js_return_value =
- JSC::call(exec_state, callable, call_type, call_data, js_this, args);
- if (exec_state->hadException()) {
- DLOG(WARNING) << "Exception in callback: "
- << GetExceptionString(exec_state);
- exec_state->clearException();
- *had_exception = true;
- return base::optional<int32_t >();
- }
- JSCExceptionState exception_state(global_object);
- base::optional<int32_t > cobalt_return_value;
- FromJSValue(exec_state, js_return_value, 0, &exception_state, &cobalt_return_value);
-
- *had_exception = exception_state.is_exception_set();
- return cobalt_return_value;
-}
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCSingleOperationInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCSingleOperationInterface.h
deleted file mode 100644
index 6b8be4c..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCSingleOperationInterface.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/callback-interface.h.template
-
-// clang-format off
-
-#ifndef JSCSingleOperationInterface_h
-#define JSCSingleOperationInterface_h
-
-#include "cobalt/script/wrappable.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "cobalt/bindings/testing/single_operation_interface.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCSingleOperationInterface : public SingleOperationInterface {
- public:
- JSCSingleOperationInterface(JSC::JSObject* implementing_object);
- base::optional<int32_t > HandleCallback(
- const scoped_refptr<script::Wrappable>& callback_this,
- const scoped_refptr<ArbitraryInterface>& value,
- bool* had_exception) const OVERRIDE;
- JSC::JSObject* implementing_object() const { return implementing_object_; }
-
- private:
- JSC::JSObject* implementing_object_;
-};
-
-} // namespace bindings
-} // namespace testing
-namespace script {
-// Explicit instantiation of CallbackInterfaceTraits struct so we can infer
-// the type of the generated class from the type of the callback interface.
-template<>
-struct CallbackInterfaceTraits<bindings::testing::SingleOperationInterface> {
- typedef bindings::testing::JSCSingleOperationInterface JSCCallbackInterfaceClass;
-};
-
-} // namespace script
-} // namespace cobalt
-
-#endif // JSCSingleOperationInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCStaticPropertiesInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCStaticPropertiesInterface.cc
deleted file mode 100644
index d791d04..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCStaticPropertiesInterface.cc
+++ /dev/null
@@ -1,971 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCStaticPropertiesInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-#include "JSCArbitraryInterface.h"
-#include "cobalt/bindings/testing/arbitrary_interface.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::StaticPropertiesInterface;
-using cobalt::bindings::testing::JSCStaticPropertiesInterface;
-using cobalt::bindings::testing::ArbitraryInterface;
-using cobalt::bindings::testing::JSCArbitraryInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSstaticAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSstaticAttribute(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::EncodedJSValue staticFunctionJSstaticFunction(JSC::ExecState*);
-JSC::EncodedJSValue staticFunctionJSstaticFunction1(JSC::ExecState*);
-JSC::EncodedJSValue staticFunctionJSstaticFunction2(JSC::ExecState*);
-JSC::EncodedJSValue staticFunctionJSstaticFunction3(JSC::ExecState*);
-JSC::EncodedJSValue staticFunctionJSstaticFunction4(JSC::ExecState*);
-JSC::EncodedJSValue staticFunctionJSstaticFunction5(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCStaticPropertiesInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCStaticPropertiesInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCStaticPropertiesInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { "staticAttribute",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSstaticAttribute),
- reinterpret_cast<intptr_t>(setJSstaticAttribute),
- JSC::NoIntrinsic
- },
- { "staticFunction",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(staticFunctionJSstaticFunction),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCStaticPropertiesInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCStaticPropertiesInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 9, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCStaticPropertiesInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCStaticPropertiesInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCStaticPropertiesInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCStaticPropertiesInterface::InterfaceObject::s_info = {
- "StaticPropertiesInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCStaticPropertiesInterface::InterfaceObject)
-}; // JSCStaticPropertiesInterface::InterfaceObject::s_info
-
-void JSCStaticPropertiesInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCStaticPropertiesInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCStaticPropertiesInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "StaticPropertiesInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCStaticPropertiesInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCStaticPropertiesInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCStaticPropertiesInterface::Prototype::property_table_values[] = {
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCStaticPropertiesInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCStaticPropertiesInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCStaticPropertiesInterface::Prototype::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCStaticPropertiesInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCStaticPropertiesInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCStaticPropertiesInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCStaticPropertiesInterface::Prototype::s_info = {
- "StaticPropertiesInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCStaticPropertiesInterface::Prototype)
-}; // JSCStaticPropertiesInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCStaticPropertiesInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCStaticPropertiesInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCStaticPropertiesInterface::Prototype class
-
-const JSC::HashTableValue JSCStaticPropertiesInterface::property_table_values[] = {
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCStaticPropertiesInterface::property_table_values
-
-// static
-const JSC::HashTable JSCStaticPropertiesInterface::property_table_prototype = {
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCStaticPropertiesInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCStaticPropertiesInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCStaticPropertiesInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCStaticPropertiesInterface::NonTrivialStaticFields>
- JSCStaticPropertiesInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCStaticPropertiesInterface::s_info = {
- "StaticPropertiesInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCStaticPropertiesInterface)
-}; // JSCStaticPropertiesInterface::s_info
-
-// static
-JSC::JSObject* JSCStaticPropertiesInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCStaticPropertiesInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCStaticPropertiesInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCStaticPropertiesInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == StaticPropertiesInterface::StaticPropertiesInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match StaticPropertiesInterface::StaticPropertiesInterfaceWrappableType()";
- return NULL;
- }
- StaticPropertiesInterface* impl_ptr =
- base::polymorphic_downcast<StaticPropertiesInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCStaticPropertiesInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCStaticPropertiesInterface>(global_data.heap))
- JSCStaticPropertiesInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCStaticPropertiesInterface::JSCStaticPropertiesInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<StaticPropertiesInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCStaticPropertiesInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCStaticPropertiesInterface::~JSCStaticPropertiesInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCStaticPropertiesInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCStaticPropertiesInterface* this_object = JSC::jsCast<JSCStaticPropertiesInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCStaticPropertiesInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCStaticPropertiesInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCStaticPropertiesInterface* this_object = JSC::jsCast<JSCStaticPropertiesInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCStaticPropertiesInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCStaticPropertiesInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCStaticPropertiesInterface* this_object = JSC::jsCast<JSCStaticPropertiesInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCStaticPropertiesInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSstaticAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCStaticPropertiesInterface", "get staticAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
-
- JSC::JSValue result = ToJSValue(
- global_object,
- StaticPropertiesInterface::static_attribute());
- return result;
-}
-
-void setJSstaticAttribute(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCStaticPropertiesInterface", "set staticAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- TypeTraits<std::string >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- StaticPropertiesInterface::set_static_attribute(cobalt_value);
- }
-}
-
-JSC::EncodedJSValue staticFunctionJSstaticFunction(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCStaticPropertiesInterface", "call staticFunction");
- const size_t num_arguments = exec_state->argumentCount();
- switch(num_arguments) {
- case(0): {
- // Overload resolution algorithm details found here:
- // http://heycam.github.io/webidl/#dfn-overload-resolution-algorithm
- if (true) {
- return staticFunctionJSstaticFunction1(exec_state);
- }
- break;
- }
- case(1): {
- // Overload resolution algorithm details found here:
- // http://heycam.github.io/webidl/#dfn-overload-resolution-algorithm
- JSC::JSValue arg = exec_state->argument(0);
- if (arg.isNumber()) {
- return staticFunctionJSstaticFunction2(exec_state);
- }
- if (true) {
- return staticFunctionJSstaticFunction3(exec_state);
- }
- if (true) {
- return staticFunctionJSstaticFunction2(exec_state);
- }
- break;
- }
- case(3): {
- // Overload resolution algorithm details found here:
- // http://heycam.github.io/webidl/#dfn-overload-resolution-algorithm
- JSC::JSValue arg = exec_state->argument(2);
- if (arg.inherits(JSCArbitraryInterface::s_classinfo())) {
- return staticFunctionJSstaticFunction5(exec_state);
- }
- if (true) {
- return staticFunctionJSstaticFunction4(exec_state);
- }
- break;
- }
- }
- // Invalid number of args
- // http://heycam.github.io/webidl/#dfn-overload-resolution-algorithm
- // 4. If S is empty, then throw a TypeError.
- return JSC::throwVMTypeError(exec_state);
-}
-
-JSC::EncodedJSValue staticFunctionJSstaticFunction1(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
-
- StaticPropertiesInterface::StaticFunction();
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue staticFunctionJSstaticFunction2(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<int32_t >::ConversionType arg;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- StaticPropertiesInterface::StaticFunction(arg);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue staticFunctionJSstaticFunction3(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
-
- const size_t kMinArguments = 1;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<std::string >::ConversionType arg;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- StaticPropertiesInterface::StaticFunction(arg);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue staticFunctionJSstaticFunction4(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
-
- const size_t kMinArguments = 3;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<int32_t >::ConversionType arg1;
- TypeTraits<int32_t >::ConversionType arg2;
- TypeTraits<int32_t >::ConversionType arg3;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg1);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
-
- DCHECK_LT(1, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(1),
- kNoConversionFlags,
- &exception_state, &arg2);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
-
- DCHECK_LT(2, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(2),
- kNoConversionFlags,
- &exception_state, &arg3);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- StaticPropertiesInterface::StaticFunction(arg1, arg2, arg3);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue staticFunctionJSstaticFunction5(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
-
- const size_t kMinArguments = 3;
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
- // Non-optional arguments
- TypeTraits<int32_t >::ConversionType arg1;
- TypeTraits<int32_t >::ConversionType arg2;
- TypeTraits<scoped_refptr<ArbitraryInterface> >::ConversionType arg3;
-
- DCHECK_LT(0, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(0),
- kNoConversionFlags,
- &exception_state, &arg1);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
-
- DCHECK_LT(1, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(1),
- kNoConversionFlags,
- &exception_state, &arg2);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
-
- DCHECK_LT(2, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument(2),
- kNoConversionFlags,
- &exception_state, &arg3);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- StaticPropertiesInterface::StaticFunction(arg1, arg2, arg3);
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCStaticPropertiesInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCStaticPropertiesInterface.h
deleted file mode 100644
index dbb5bf8..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCStaticPropertiesInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCStaticPropertiesInterface_h
-#define JSCStaticPropertiesInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/static_properties_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCStaticPropertiesInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to StaticPropertiesInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCStaticPropertiesInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<StaticPropertiesInterface>& impl);
- ~JSCStaticPropertiesInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCStaticPropertiesInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCStringifierAnonymousOperationInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCStringifierAnonymousOperationInterface.cc
deleted file mode 100644
index 87dd022..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCStringifierAnonymousOperationInterface.cc
+++ /dev/null
@@ -1,725 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCStringifierAnonymousOperationInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::StringifierAnonymousOperationInterface;
-using cobalt::bindings::testing::JSCStringifierAnonymousOperationInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::EncodedJSValue StringifierJS(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCStringifierAnonymousOperationInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCStringifierAnonymousOperationInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCStringifierAnonymousOperationInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCStringifierAnonymousOperationInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCStringifierAnonymousOperationInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCStringifierAnonymousOperationInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCStringifierAnonymousOperationInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCStringifierAnonymousOperationInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCStringifierAnonymousOperationInterface::InterfaceObject::s_info = {
- "StringifierAnonymousOperationInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCStringifierAnonymousOperationInterface::InterfaceObject)
-}; // JSCStringifierAnonymousOperationInterface::InterfaceObject::s_info
-
-void JSCStringifierAnonymousOperationInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCStringifierAnonymousOperationInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCStringifierAnonymousOperationInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "StringifierAnonymousOperationInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCStringifierAnonymousOperationInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCStringifierAnonymousOperationInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCStringifierAnonymousOperationInterface::Prototype::property_table_values[] = {
- { "toString",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(StringifierJS),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCStringifierAnonymousOperationInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCStringifierAnonymousOperationInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCStringifierAnonymousOperationInterface::Prototype::property_table_prototype = {
- 9, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCStringifierAnonymousOperationInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCStringifierAnonymousOperationInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCStringifierAnonymousOperationInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCStringifierAnonymousOperationInterface::Prototype::s_info = {
- "StringifierAnonymousOperationInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCStringifierAnonymousOperationInterface::Prototype)
-}; // JSCStringifierAnonymousOperationInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCStringifierAnonymousOperationInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCStringifierAnonymousOperationInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCStringifierAnonymousOperationInterface::Prototype class
-
-const JSC::HashTableValue JSCStringifierAnonymousOperationInterface::property_table_values[] = {
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCStringifierAnonymousOperationInterface::property_table_values
-
-// static
-const JSC::HashTable JSCStringifierAnonymousOperationInterface::property_table_prototype = {
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCStringifierAnonymousOperationInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCStringifierAnonymousOperationInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCStringifierAnonymousOperationInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCStringifierAnonymousOperationInterface::NonTrivialStaticFields>
- JSCStringifierAnonymousOperationInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCStringifierAnonymousOperationInterface::s_info = {
- "StringifierAnonymousOperationInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCStringifierAnonymousOperationInterface)
-}; // JSCStringifierAnonymousOperationInterface::s_info
-
-// static
-JSC::JSObject* JSCStringifierAnonymousOperationInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCStringifierAnonymousOperationInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCStringifierAnonymousOperationInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCStringifierAnonymousOperationInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == StringifierAnonymousOperationInterface::StringifierAnonymousOperationInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match StringifierAnonymousOperationInterface::StringifierAnonymousOperationInterfaceWrappableType()";
- return NULL;
- }
- StringifierAnonymousOperationInterface* impl_ptr =
- base::polymorphic_downcast<StringifierAnonymousOperationInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCStringifierAnonymousOperationInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCStringifierAnonymousOperationInterface>(global_data.heap))
- JSCStringifierAnonymousOperationInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCStringifierAnonymousOperationInterface::JSCStringifierAnonymousOperationInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<StringifierAnonymousOperationInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCStringifierAnonymousOperationInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCStringifierAnonymousOperationInterface::~JSCStringifierAnonymousOperationInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCStringifierAnonymousOperationInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCStringifierAnonymousOperationInterface* this_object = JSC::jsCast<JSCStringifierAnonymousOperationInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCStringifierAnonymousOperationInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCStringifierAnonymousOperationInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCStringifierAnonymousOperationInterface* this_object = JSC::jsCast<JSCStringifierAnonymousOperationInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCStringifierAnonymousOperationInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCStringifierAnonymousOperationInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCStringifierAnonymousOperationInterface* this_object = JSC::jsCast<JSCStringifierAnonymousOperationInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCStringifierAnonymousOperationInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-JSC::EncodedJSValue StringifierJS(JSC::ExecState* exec_state) {
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- StringifierAnonymousOperationInterface* impl =
- GetWrappableOrSetException<StringifierAnonymousOperationInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
-
- JSC::JSValue result = ToJSValue(global_object, impl->AnonymousStringifier());
- return JSC::JSValue::encode(result);
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCStringifierAnonymousOperationInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCStringifierAnonymousOperationInterface.h
deleted file mode 100644
index ac79ef5..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCStringifierAnonymousOperationInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCStringifierAnonymousOperationInterface_h
-#define JSCStringifierAnonymousOperationInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/stringifier_anonymous_operation_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCStringifierAnonymousOperationInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to StringifierAnonymousOperationInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCStringifierAnonymousOperationInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<StringifierAnonymousOperationInterface>& impl);
- ~JSCStringifierAnonymousOperationInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCStringifierAnonymousOperationInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCStringifierAttributeInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCStringifierAttributeInterface.cc
deleted file mode 100644
index 3b0dfed..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCStringifierAttributeInterface.cc
+++ /dev/null
@@ -1,785 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCStringifierAttributeInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::StringifierAttributeInterface;
-using cobalt::bindings::testing::JSCStringifierAttributeInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJStheStringifierAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJStheStringifierAttribute(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::EncodedJSValue StringifierJS(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCStringifierAttributeInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCStringifierAttributeInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCStringifierAttributeInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCStringifierAttributeInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCStringifierAttributeInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCStringifierAttributeInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCStringifierAttributeInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCStringifierAttributeInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCStringifierAttributeInterface::InterfaceObject::s_info = {
- "StringifierAttributeInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCStringifierAttributeInterface::InterfaceObject)
-}; // JSCStringifierAttributeInterface::InterfaceObject::s_info
-
-void JSCStringifierAttributeInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCStringifierAttributeInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCStringifierAttributeInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "StringifierAttributeInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCStringifierAttributeInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCStringifierAttributeInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCStringifierAttributeInterface::Prototype::property_table_values[] = {
- { "toString",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(StringifierJS),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCStringifierAttributeInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCStringifierAttributeInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCStringifierAttributeInterface::Prototype::property_table_prototype = {
- 9, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCStringifierAttributeInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCStringifierAttributeInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCStringifierAttributeInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCStringifierAttributeInterface::Prototype::s_info = {
- "StringifierAttributeInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCStringifierAttributeInterface::Prototype)
-}; // JSCStringifierAttributeInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCStringifierAttributeInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCStringifierAttributeInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCStringifierAttributeInterface::Prototype class
-
-const JSC::HashTableValue JSCStringifierAttributeInterface::property_table_values[] = {
- { "theStringifierAttribute",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJStheStringifierAttribute),
- reinterpret_cast<intptr_t>(setJStheStringifierAttribute),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCStringifierAttributeInterface::property_table_values
-
-// static
-const JSC::HashTable JSCStringifierAttributeInterface::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCStringifierAttributeInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCStringifierAttributeInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCStringifierAttributeInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCStringifierAttributeInterface::NonTrivialStaticFields>
- JSCStringifierAttributeInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCStringifierAttributeInterface::s_info = {
- "StringifierAttributeInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCStringifierAttributeInterface)
-}; // JSCStringifierAttributeInterface::s_info
-
-// static
-JSC::JSObject* JSCStringifierAttributeInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCStringifierAttributeInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCStringifierAttributeInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCStringifierAttributeInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == StringifierAttributeInterface::StringifierAttributeInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match StringifierAttributeInterface::StringifierAttributeInterfaceWrappableType()";
- return NULL;
- }
- StringifierAttributeInterface* impl_ptr =
- base::polymorphic_downcast<StringifierAttributeInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCStringifierAttributeInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCStringifierAttributeInterface>(global_data.heap))
- JSCStringifierAttributeInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCStringifierAttributeInterface::JSCStringifierAttributeInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<StringifierAttributeInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCStringifierAttributeInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCStringifierAttributeInterface::~JSCStringifierAttributeInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCStringifierAttributeInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCStringifierAttributeInterface* this_object = JSC::jsCast<JSCStringifierAttributeInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCStringifierAttributeInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCStringifierAttributeInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCStringifierAttributeInterface* this_object = JSC::jsCast<JSCStringifierAttributeInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCStringifierAttributeInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCStringifierAttributeInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCStringifierAttributeInterface* this_object = JSC::jsCast<JSCStringifierAttributeInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCStringifierAttributeInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJStheStringifierAttribute(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCStringifierAttributeInterface", "get theStringifierAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- StringifierAttributeInterface* impl =
- GetWrappableOrSetException<StringifierAttributeInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->the_stringifier_attribute());
- return result;
-}
-
-void setJStheStringifierAttribute(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCStringifierAttributeInterface", "set theStringifierAttribute");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- StringifierAttributeInterface* impl =
- GetWrappableOrSetException<StringifierAttributeInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<std::string >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_the_stringifier_attribute(cobalt_value);
- }
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-JSC::EncodedJSValue StringifierJS(JSC::ExecState* exec_state) {
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- StringifierAttributeInterface* impl =
- GetWrappableOrSetException<StringifierAttributeInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
-
- JSC::JSValue result = ToJSValue(global_object, impl->the_stringifier_attribute());
- return JSC::JSValue::encode(result);
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCStringifierAttributeInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCStringifierAttributeInterface.h
deleted file mode 100644
index 3d84c36..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCStringifierAttributeInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCStringifierAttributeInterface_h
-#define JSCStringifierAttributeInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/stringifier_attribute_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCStringifierAttributeInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to StringifierAttributeInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCStringifierAttributeInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<StringifierAttributeInterface>& impl);
- ~JSCStringifierAttributeInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCStringifierAttributeInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCStringifierOperationInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCStringifierOperationInterface.cc
deleted file mode 100644
index db2d4b4..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCStringifierOperationInterface.cc
+++ /dev/null
@@ -1,751 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCStringifierOperationInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::StringifierOperationInterface;
-using cobalt::bindings::testing::JSCStringifierOperationInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::EncodedJSValue functionJStheStringifierOperation(JSC::ExecState*);
-JSC::EncodedJSValue StringifierJS(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCStringifierOperationInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCStringifierOperationInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCStringifierOperationInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCStringifierOperationInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCStringifierOperationInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCStringifierOperationInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCStringifierOperationInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCStringifierOperationInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCStringifierOperationInterface::InterfaceObject::s_info = {
- "StringifierOperationInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCStringifierOperationInterface::InterfaceObject)
-}; // JSCStringifierOperationInterface::InterfaceObject::s_info
-
-void JSCStringifierOperationInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCStringifierOperationInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCStringifierOperationInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "StringifierOperationInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCStringifierOperationInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCStringifierOperationInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCStringifierOperationInterface::Prototype::property_table_values[] = {
- { "theStringifierOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJStheStringifierOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "toString",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(StringifierJS),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCStringifierOperationInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCStringifierOperationInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCStringifierOperationInterface::Prototype::property_table_prototype = {
- 10, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCStringifierOperationInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCStringifierOperationInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCStringifierOperationInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCStringifierOperationInterface::Prototype::s_info = {
- "StringifierOperationInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCStringifierOperationInterface::Prototype)
-}; // JSCStringifierOperationInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCStringifierOperationInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCStringifierOperationInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCStringifierOperationInterface::Prototype class
-
-const JSC::HashTableValue JSCStringifierOperationInterface::property_table_values[] = {
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCStringifierOperationInterface::property_table_values
-
-// static
-const JSC::HashTable JSCStringifierOperationInterface::property_table_prototype = {
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCStringifierOperationInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCStringifierOperationInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCStringifierOperationInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCStringifierOperationInterface::NonTrivialStaticFields>
- JSCStringifierOperationInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCStringifierOperationInterface::s_info = {
- "StringifierOperationInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCStringifierOperationInterface)
-}; // JSCStringifierOperationInterface::s_info
-
-// static
-JSC::JSObject* JSCStringifierOperationInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCStringifierOperationInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCStringifierOperationInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCStringifierOperationInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == StringifierOperationInterface::StringifierOperationInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match StringifierOperationInterface::StringifierOperationInterfaceWrappableType()";
- return NULL;
- }
- StringifierOperationInterface* impl_ptr =
- base::polymorphic_downcast<StringifierOperationInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCStringifierOperationInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCStringifierOperationInterface>(global_data.heap))
- JSCStringifierOperationInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCStringifierOperationInterface::JSCStringifierOperationInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<StringifierOperationInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCStringifierOperationInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCStringifierOperationInterface::~JSCStringifierOperationInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCStringifierOperationInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCStringifierOperationInterface* this_object = JSC::jsCast<JSCStringifierOperationInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCStringifierOperationInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCStringifierOperationInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCStringifierOperationInterface* this_object = JSC::jsCast<JSCStringifierOperationInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCStringifierOperationInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCStringifierOperationInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCStringifierOperationInterface* this_object = JSC::jsCast<JSCStringifierOperationInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCStringifierOperationInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::EncodedJSValue functionJStheStringifierOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCStringifierOperationInterface", "call theStringifierOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- StringifierOperationInterface* impl =
- GetWrappableOrSetException<StringifierOperationInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<std::string >::ReturnType return_value = impl->TheStringifierOperation();
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-JSC::EncodedJSValue StringifierJS(JSC::ExecState* exec_state) {
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- StringifierOperationInterface* impl =
- GetWrappableOrSetException<StringifierOperationInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
-
- JSC::JSValue result = ToJSValue(global_object, impl->TheStringifierOperation());
- return JSC::JSValue::encode(result);
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCStringifierOperationInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCStringifierOperationInterface.h
deleted file mode 100644
index f20c26d..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCStringifierOperationInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCStringifierOperationInterface_h
-#define JSCStringifierOperationInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/stringifier_operation_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCStringifierOperationInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to StringifierOperationInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCStringifierOperationInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<StringifierOperationInterface>& impl);
- ~JSCStringifierOperationInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCStringifierOperationInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCTargetInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCTargetInterface.cc
deleted file mode 100644
index 0dbd16b..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCTargetInterface.cc
+++ /dev/null
@@ -1,755 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCTargetInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::TargetInterface;
-using cobalt::bindings::testing::JSCTargetInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::EncodedJSValue functionJSimplementedInterfaceFunction(JSC::ExecState*);
-JSC::EncodedJSValue functionJSpartialInterfaceFunction(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCTargetInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCTargetInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCTargetInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCTargetInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCTargetInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCTargetInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCTargetInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCTargetInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCTargetInterface::InterfaceObject::s_info = {
- "TargetInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCTargetInterface::InterfaceObject)
-}; // JSCTargetInterface::InterfaceObject::s_info
-
-void JSCTargetInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCTargetInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCTargetInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "TargetInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCTargetInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCTargetInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCTargetInterface::Prototype::property_table_values[] = {
- { "implementedInterfaceFunction",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSimplementedInterfaceFunction),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "partialInterfaceFunction",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSpartialInterfaceFunction),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCTargetInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCTargetInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCTargetInterface::Prototype::property_table_prototype = {
- 10, // compactSize
- 7, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCTargetInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCTargetInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCTargetInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCTargetInterface::Prototype::s_info = {
- "TargetInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCTargetInterface::Prototype)
-}; // JSCTargetInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCTargetInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCTargetInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCTargetInterface::Prototype class
-
-const JSC::HashTableValue JSCTargetInterface::property_table_values[] = {
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCTargetInterface::property_table_values
-
-// static
-const JSC::HashTable JSCTargetInterface::property_table_prototype = {
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCTargetInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCTargetInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCTargetInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCTargetInterface::NonTrivialStaticFields>
- JSCTargetInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCTargetInterface::s_info = {
- "TargetInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCTargetInterface)
-}; // JSCTargetInterface::s_info
-
-// static
-JSC::JSObject* JSCTargetInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCTargetInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCTargetInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCTargetInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == TargetInterface::TargetInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match TargetInterface::TargetInterfaceWrappableType()";
- return NULL;
- }
- TargetInterface* impl_ptr =
- base::polymorphic_downcast<TargetInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCTargetInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCTargetInterface>(global_data.heap))
- JSCTargetInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCTargetInterface::JSCTargetInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<TargetInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCTargetInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCTargetInterface::~JSCTargetInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCTargetInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCTargetInterface* this_object = JSC::jsCast<JSCTargetInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCTargetInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCTargetInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCTargetInterface* this_object = JSC::jsCast<JSCTargetInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCTargetInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCTargetInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCTargetInterface* this_object = JSC::jsCast<JSCTargetInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCTargetInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::EncodedJSValue functionJSimplementedInterfaceFunction(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCTargetInterface", "call implementedInterfaceFunction");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- TargetInterface* impl =
- GetWrappableOrSetException<TargetInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- impl->ImplementedInterfaceFunction();
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-
-JSC::EncodedJSValue functionJSpartialInterfaceFunction(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCTargetInterface", "call partialInterfaceFunction");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- TargetInterface* impl =
- GetWrappableOrSetException<TargetInterface>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- impl->PartialInterfaceFunction();
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCTargetInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCTargetInterface.h
deleted file mode 100644
index 511a979..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCTargetInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCTargetInterface_h
-#define JSCTargetInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/target_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCTargetInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to TargetInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCTargetInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<TargetInterface>& impl);
- ~JSCTargetInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCTargetInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCUnionTypesInterface.cc b/src/cobalt/bindings/generated/jsc/testing/JSCUnionTypesInterface.cc
deleted file mode 100644
index e1a3fce..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCUnionTypesInterface.cc
+++ /dev/null
@@ -1,951 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCUnionTypesInterface.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-#include "JSCArbitraryInterface.h"
-#include "JSCBaseInterface.h"
-#include "cobalt/bindings/testing/arbitrary_interface.h"
-#include "cobalt/bindings/testing/base_interface.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::UnionTypesInterface;
-using cobalt::bindings::testing::JSCUnionTypesInterface;
-using cobalt::bindings::testing::ArbitraryInterface;
-using cobalt::bindings::testing::BaseInterface;
-using cobalt::bindings::testing::JSCArbitraryInterface;
-using cobalt::bindings::testing::JSCBaseInterface;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSunionProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSunionProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSunionWithNullableMemberProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSunionWithNullableMemberProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSnullableUnionProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSnullableUnionProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSunionBaseProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSunionBaseProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = true;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCUnionTypesInterface::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCUnionTypesInterface";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCUnionTypesInterface::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCUnionTypesInterface::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCUnionTypesInterface::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCUnionTypesInterface::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCUnionTypesInterface::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCUnionTypesInterface::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCUnionTypesInterface::InterfaceObject::s_info = {
- "UnionTypesInterfaceConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCUnionTypesInterface::InterfaceObject)
-}; // JSCUnionTypesInterface::InterfaceObject::s_info
-
-void JSCUnionTypesInterface::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCUnionTypesInterface::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCUnionTypesInterface::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "UnionTypesInterface");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCUnionTypesInterface::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCUnionTypesInterface::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCUnionTypesInterface::Prototype::property_table_values[] = {
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCUnionTypesInterface::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCUnionTypesInterface::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCUnionTypesInterface::Prototype::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCUnionTypesInterface::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCUnionTypesInterface::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCUnionTypesInterface::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCUnionTypesInterface::Prototype::s_info = {
- "UnionTypesInterfacePrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCUnionTypesInterface::Prototype)
-}; // JSCUnionTypesInterface::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCUnionTypesInterface::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCUnionTypesInterface::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCUnionTypesInterface::Prototype class
-
-const JSC::HashTableValue JSCUnionTypesInterface::property_table_values[] = {
- { "unionProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSunionProperty),
- reinterpret_cast<intptr_t>(setJSunionProperty),
- JSC::NoIntrinsic
- },
- { "unionWithNullableMemberProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSunionWithNullableMemberProperty),
- reinterpret_cast<intptr_t>(setJSunionWithNullableMemberProperty),
- JSC::NoIntrinsic
- },
- { "nullableUnionProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSnullableUnionProperty),
- reinterpret_cast<intptr_t>(setJSnullableUnionProperty),
- JSC::NoIntrinsic
- },
- { "unionBaseProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSunionBaseProperty),
- reinterpret_cast<intptr_t>(setJSunionBaseProperty),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCUnionTypesInterface::property_table_values
-
-// static
-const JSC::HashTable JSCUnionTypesInterface::property_table_prototype = {
- 19, // compactSize
- 15, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCUnionTypesInterface::property_table_prototype
-
-// static
-const JSC::HashTable* JSCUnionTypesInterface::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCUnionTypesInterface::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCUnionTypesInterface::NonTrivialStaticFields>
- JSCUnionTypesInterface::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCUnionTypesInterface::s_info = {
- "UnionTypesInterface", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCUnionTypesInterface)
-}; // JSCUnionTypesInterface::s_info
-
-// static
-JSC::JSObject* JSCUnionTypesInterface::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCUnionTypesInterface::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCUnionTypesInterface::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-JSC::JSObject* JSCUnionTypesInterface::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == UnionTypesInterface::UnionTypesInterfaceWrappableType())) {
- NOTREACHED() << "Type of wrappable does not match UnionTypesInterface::UnionTypesInterfaceWrappableType()";
- return NULL;
- }
- UnionTypesInterface* impl_ptr =
- base::polymorphic_downcast<UnionTypesInterface*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- JSCUnionTypesInterface* wrapper =
- new (NotNull, JSC::allocateCell<JSCUnionTypesInterface>(global_data.heap))
- JSCUnionTypesInterface(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
- return wrapper;
-}
-JSCUnionTypesInterface::JSCUnionTypesInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<UnionTypesInterface>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl) {
-}
-
-void JSCUnionTypesInterface::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCUnionTypesInterface::~JSCUnionTypesInterface() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCUnionTypesInterface::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCUnionTypesInterface* this_object = JSC::jsCast<JSCUnionTypesInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property_slot = JSC::getStaticValueSlot<JSCUnionTypesInterface, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCUnionTypesInterface::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCUnionTypesInterface* this_object = JSC::jsCast<JSCUnionTypesInterface*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCUnionTypesInterface, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCUnionTypesInterface::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCUnionTypesInterface* this_object = JSC::jsCast<JSCUnionTypesInterface*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCUnionTypesInterface, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSunionProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCUnionTypesInterface", "get unionProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- UnionTypesInterface* impl =
- GetWrappableOrSetException<UnionTypesInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->union_property());
- return result;
-}
-
-void setJSunionProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCUnionTypesInterface", "set unionProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- UnionTypesInterface* impl =
- GetWrappableOrSetException<UnionTypesInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<script::UnionType4<std::string, bool, scoped_refptr<ArbitraryInterface>, int32_t > >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_union_property(cobalt_value);
- }
-}
-
-JSC::JSValue getJSunionWithNullableMemberProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCUnionTypesInterface", "get unionWithNullableMemberProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- UnionTypesInterface* impl =
- GetWrappableOrSetException<UnionTypesInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->union_with_nullable_member_property());
- return result;
-}
-
-void setJSunionWithNullableMemberProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCUnionTypesInterface", "set unionWithNullableMemberProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- UnionTypesInterface* impl =
- GetWrappableOrSetException<UnionTypesInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<base::optional<script::UnionType2<double, std::string > > >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_union_with_nullable_member_property(cobalt_value);
- }
-}
-
-JSC::JSValue getJSnullableUnionProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCUnionTypesInterface", "get nullableUnionProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- UnionTypesInterface* impl =
- GetWrappableOrSetException<UnionTypesInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->nullable_union_property());
- return result;
-}
-
-void setJSnullableUnionProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCUnionTypesInterface", "set nullableUnionProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- UnionTypesInterface* impl =
- GetWrappableOrSetException<UnionTypesInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<base::optional<script::UnionType2<double, std::string > > >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- (kConversionFlagNullable), &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_nullable_union_property(cobalt_value);
- }
-}
-
-JSC::JSValue getJSunionBaseProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCUnionTypesInterface", "get unionBaseProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- UnionTypesInterface* impl =
- GetWrappableOrSetException<UnionTypesInterface>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->union_base_property());
- return result;
-}
-
-void setJSunionBaseProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCUnionTypesInterface", "set unionBaseProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- UnionTypesInterface* impl =
- GetWrappableOrSetException<UnionTypesInterface>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<script::UnionType2<scoped_refptr<BaseInterface>, std::string > >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_union_base_property(cobalt_value);
- }
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCUnionTypesInterface.h b/src/cobalt/bindings/generated/jsc/testing/JSCUnionTypesInterface.h
deleted file mode 100644
index ddc64d2..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCUnionTypesInterface.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCUnionTypesInterface_h
-#define JSCUnionTypesInterface_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "cobalt/bindings/testing/union_types_interface.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCUnionTypesInterface
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to UnionTypesInterface.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCUnionTypesInterface(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<UnionTypesInterface>& impl);
- ~JSCUnionTypesInterface();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCUnionTypesInterface_h
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCWindow.cc b/src/cobalt/bindings/generated/jsc/testing/JSCWindow.cc
deleted file mode 100644
index b1720fd..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCWindow.cc
+++ /dev/null
@@ -1,1229 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
-
-// clang-format off
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-#include "JSCWindow.h"
-
-#include "base/debug/trace_event.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-#include "JSCAnonymousIndexedGetterInterface.h"
-#include "JSCAnonymousNamedGetterInterface.h"
-#include "JSCAnonymousNamedIndexedGetterInterface.h"
-#include "JSCArbitraryInterface.h"
-#include "JSCBaseInterface.h"
-#include "JSCBooleanTypeTestInterface.h"
-#include "JSCCallbackFunctionInterface.h"
-#include "JSCCallbackInterfaceInterface.h"
-#include "JSCConditionalInterface.h"
-#include "JSCConstantsInterface.h"
-#include "JSCConstructorInterface.h"
-#include "JSCConstructorWithArgumentsInterface.h"
-#include "JSCDOMStringTestInterface.h"
-#include "JSCDerivedGetterSetterInterface.h"
-#include "JSCDerivedInterface.h"
-#include "JSCDisabledInterface.h"
-#include "JSCEnumerationInterface.h"
-#include "JSCExceptionObjectInterface.h"
-#include "JSCExceptionsInterface.h"
-#include "JSCExtendedIDLAttributesInterface.h"
-#include "JSCGarbageCollectionTestInterface.h"
-#include "JSCGetOpaqueRootInterface.h"
-#include "JSCGlobalInterfaceParent.h"
-#include "JSCImplementedInterface.h"
-#include "JSCIndexedGetterInterface.h"
-#include "JSCInterfaceWithUnsupportedProperties.h"
-#include "JSCNamedConstructorInterface.h"
-#include "JSCNamedGetterInterface.h"
-#include "JSCNamedIndexedGetterInterface.h"
-#include "JSCNestedPutForwardsInterface.h"
-#include "JSCNoConstructorInterface.h"
-#include "JSCNoInterfaceObjectInterface.h"
-#include "JSCNullableTypesTestInterface.h"
-#include "JSCNumericTypesTestInterface.h"
-#include "JSCObjectTypeBindingsInterface.h"
-#include "JSCOperationsTestInterface.h"
-#include "JSCPutForwardsInterface.h"
-#include "JSCSequenceUser.h"
-#include "JSCSingleOperationInterface.h"
-#include "JSCStaticPropertiesInterface.h"
-#include "JSCStringifierAnonymousOperationInterface.h"
-#include "JSCStringifierAttributeInterface.h"
-#include "JSCStringifierOperationInterface.h"
-#include "JSCTargetInterface.h"
-#include "JSCUnionTypesInterface.h"
-#include "JSCWindow.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/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/get_opaque_root_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_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/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/window.h"
-
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-
-namespace {
-using cobalt::bindings::testing::Window;
-using cobalt::bindings::testing::JSCWindow;
-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;
-#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::GetOpaqueRootInterface;
-using cobalt::bindings::testing::GlobalInterfaceParent;
-using cobalt::bindings::testing::ImplementedInterface;
-using cobalt::bindings::testing::IndexedGetterInterface;
-using cobalt::bindings::testing::InterfaceWithUnsupportedProperties;
-using cobalt::bindings::testing::JSCAnonymousIndexedGetterInterface;
-using cobalt::bindings::testing::JSCAnonymousNamedGetterInterface;
-using cobalt::bindings::testing::JSCAnonymousNamedIndexedGetterInterface;
-using cobalt::bindings::testing::JSCArbitraryInterface;
-using cobalt::bindings::testing::JSCBaseInterface;
-using cobalt::bindings::testing::JSCBooleanTypeTestInterface;
-using cobalt::bindings::testing::JSCCallbackFunctionInterface;
-using cobalt::bindings::testing::JSCCallbackInterfaceInterface;
-#if defined(ENABLE_CONDITIONAL_INTERFACE)
-using cobalt::bindings::testing::JSCConditionalInterface;
-#endif // defined(ENABLE_CONDITIONAL_INTERFACE)
-using cobalt::bindings::testing::JSCConstantsInterface;
-using cobalt::bindings::testing::JSCConstructorInterface;
-using cobalt::bindings::testing::JSCConstructorWithArgumentsInterface;
-using cobalt::bindings::testing::JSCDOMStringTestInterface;
-using cobalt::bindings::testing::JSCDerivedGetterSetterInterface;
-using cobalt::bindings::testing::JSCDerivedInterface;
-#if defined(NO_ENABLE_CONDITIONAL_INTERFACE)
-using cobalt::bindings::testing::JSCDisabledInterface;
-#endif // defined(NO_ENABLE_CONDITIONAL_INTERFACE)
-using cobalt::bindings::testing::JSCEnumerationInterface;
-using cobalt::bindings::testing::JSCExceptionObjectInterface;
-using cobalt::bindings::testing::JSCExceptionsInterface;
-using cobalt::bindings::testing::JSCExtendedIDLAttributesInterface;
-using cobalt::bindings::testing::JSCGarbageCollectionTestInterface;
-using cobalt::bindings::testing::JSCGetOpaqueRootInterface;
-using cobalt::bindings::testing::JSCGlobalInterfaceParent;
-using cobalt::bindings::testing::JSCImplementedInterface;
-using cobalt::bindings::testing::JSCIndexedGetterInterface;
-using cobalt::bindings::testing::JSCInterfaceWithUnsupportedProperties;
-using cobalt::bindings::testing::JSCNamedConstructorInterface;
-using cobalt::bindings::testing::JSCNamedGetterInterface;
-using cobalt::bindings::testing::JSCNamedIndexedGetterInterface;
-using cobalt::bindings::testing::JSCNestedPutForwardsInterface;
-using cobalt::bindings::testing::JSCNoConstructorInterface;
-using cobalt::bindings::testing::JSCNoInterfaceObjectInterface;
-using cobalt::bindings::testing::JSCNullableTypesTestInterface;
-using cobalt::bindings::testing::JSCNumericTypesTestInterface;
-using cobalt::bindings::testing::JSCObjectTypeBindingsInterface;
-using cobalt::bindings::testing::JSCOperationsTestInterface;
-using cobalt::bindings::testing::JSCPutForwardsInterface;
-using cobalt::bindings::testing::JSCSequenceUser;
-using cobalt::bindings::testing::JSCSingleOperationInterface;
-using cobalt::bindings::testing::JSCStaticPropertiesInterface;
-using cobalt::bindings::testing::JSCStringifierAnonymousOperationInterface;
-using cobalt::bindings::testing::JSCStringifierAttributeInterface;
-using cobalt::bindings::testing::JSCStringifierOperationInterface;
-using cobalt::bindings::testing::JSCTargetInterface;
-using cobalt::bindings::testing::JSCUnionTypesInterface;
-using cobalt::bindings::testing::JSCWindow;
-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::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::Window;
-using cobalt::script::CallbackInterfaceTraits;
-using cobalt::script::GlobalEnvironment;
-using cobalt::script::OpaqueHandle;
-using cobalt::script::OpaqueHandleHolder;
-using cobalt::script::ScriptObject;
-using cobalt::script::Wrappable;
-
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-} // namespace
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-namespace {
-JSC::JSValue getJSwindowProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-void setJSwindowProperty(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-JSC::JSValue getJSwindow(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-JSC::EncodedJSValue functionJSgetStackTrace(JSC::ExecState*);
-JSC::EncodedJSValue functionJSwindowOperation(JSC::ExecState*);
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = false;
-const bool s_has_named_setter = false;
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = false;
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-} // namespace
-
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class JSCWindow::InterfaceObject : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<InterfaceObject>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for JSCWindow";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCWindow::InterfaceObject::property_table_values[] = {
- // static functions will also go here.
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCWindow::InterfaceObject::property_table_values
-
-// static
-const JSC::HashTable
-JSCWindow::InterfaceObject::property_table_prototype = {
- // Sizes will be calculated based on the number of static functions as well.
- 2, // compactSize
- 1, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCWindow::InterfaceObject::property_table_prototype
-
-// static
-const JSC::HashTable*
-JSCWindow::InterfaceObject::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCWindow::InterfaceObject::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo JSCWindow::InterfaceObject::s_info = {
- "WindowConstructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCWindow::InterfaceObject)
-}; // JSCWindow::InterfaceObject::s_info
-
-void JSCWindow::InterfaceObject::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- JSCWindow::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* JSCWindow::InterfaceObject::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-
- // Create the new interface object.
- InterfaceObject* new_interface_object =
- new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
- InterfaceObject(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "Window");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of JSCWindow::InterfaceObject class
-
-// Class that defines a JS Object representing this interface's prototype
-class JSCWindow::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue JSCWindow::Prototype::property_table_values[] = {
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>(JSCWindow::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCWindow::Prototype::property_table_values
-
-// static
-const JSC::HashTable JSCWindow::Prototype::property_table_prototype = {
- 4, // compactSize
- 3, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCWindow::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* JSCWindow::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCWindow::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo JSCWindow::Prototype::s_info = {
- "WindowPrototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCWindow::Prototype)
-}; // JSCWindow::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool JSCWindow::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* JSCWindow::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
- JSC::JSObject* parent_prototype =
- bindings::testing::JSCGlobalInterfaceParent::GetPrototype(global_object);
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of JSCWindow::Prototype class
-
-const JSC::HashTableValue JSCWindow::property_table_values[] = {
- { "windowProperty",
- JSC::DontDelete ,
- reinterpret_cast<intptr_t>(getJSwindowProperty),
- reinterpret_cast<intptr_t>(setJSwindowProperty),
- JSC::NoIntrinsic
- },
- { "window",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJSwindow),
- 0,
- JSC::NoIntrinsic
- },
- { "getStackTrace",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSgetStackTrace),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { "windowOperation",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJSwindowOperation),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // JSCWindow::property_table_values
-
-// static
-const JSC::HashTable JSCWindow::property_table_prototype = {
- 19, // compactSize
- 15, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // JSCWindow::property_table_prototype
-
-// static
-const JSC::HashTable* JSCWindow::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- JSCWindow::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<JSCWindow::NonTrivialStaticFields>
- JSCWindow::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo JSCWindow::s_info = {
- "Window", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE(JSCWindow)
-}; // JSCWindow::s_info
-
-// static
-JSC::JSObject* JSCWindow::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-// static
-JSC::JSObject* JSCWindow::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue JSCWindow::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-
-// static
-script::javascriptcore::JSCGlobalObject* JSCWindow::Create(
- const scoped_refptr<Window>& global_interface,
- script::EnvironmentSettings* environment_settings,
- JSC::JSGlobalData* global_data,
- ScriptObjectRegistry* script_object_registry) {
- scoped_ptr<script::javascriptcore::WrapperFactory> wrapper_factory =
- make_scoped_ptr(new script::javascriptcore::WrapperFactory());
- wrapper_factory->RegisterWrappableType(
- AnonymousIndexedGetterInterface::AnonymousIndexedGetterInterfaceWrappableType(),
- JSCAnonymousIndexedGetterInterface::s_classinfo(),
- JSCAnonymousIndexedGetterInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- AnonymousNamedGetterInterface::AnonymousNamedGetterInterfaceWrappableType(),
- JSCAnonymousNamedGetterInterface::s_classinfo(),
- JSCAnonymousNamedGetterInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- AnonymousNamedIndexedGetterInterface::AnonymousNamedIndexedGetterInterfaceWrappableType(),
- JSCAnonymousNamedIndexedGetterInterface::s_classinfo(),
- JSCAnonymousNamedIndexedGetterInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- ArbitraryInterface::ArbitraryInterfaceWrappableType(),
- JSCArbitraryInterface::s_classinfo(),
- JSCArbitraryInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- BaseInterface::BaseInterfaceWrappableType(),
- JSCBaseInterface::s_classinfo(),
- JSCBaseInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- BooleanTypeTestInterface::BooleanTypeTestInterfaceWrappableType(),
- JSCBooleanTypeTestInterface::s_classinfo(),
- JSCBooleanTypeTestInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- CallbackFunctionInterface::CallbackFunctionInterfaceWrappableType(),
- JSCCallbackFunctionInterface::s_classinfo(),
- JSCCallbackFunctionInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- CallbackInterfaceInterface::CallbackInterfaceInterfaceWrappableType(),
- JSCCallbackInterfaceInterface::s_classinfo(),
- JSCCallbackInterfaceInterface::GetCreateWrapperFunction());
-#if defined(ENABLE_CONDITIONAL_INTERFACE)
- wrapper_factory->RegisterWrappableType(
- ConditionalInterface::ConditionalInterfaceWrappableType(),
- JSCConditionalInterface::s_classinfo(),
- JSCConditionalInterface::GetCreateWrapperFunction());
-#endif // defined(ENABLE_CONDITIONAL_INTERFACE)
- wrapper_factory->RegisterWrappableType(
- ConstantsInterface::ConstantsInterfaceWrappableType(),
- JSCConstantsInterface::s_classinfo(),
- JSCConstantsInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- ConstructorInterface::ConstructorInterfaceWrappableType(),
- JSCConstructorInterface::s_classinfo(),
- JSCConstructorInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- ConstructorWithArgumentsInterface::ConstructorWithArgumentsInterfaceWrappableType(),
- JSCConstructorWithArgumentsInterface::s_classinfo(),
- JSCConstructorWithArgumentsInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- DOMStringTestInterface::DOMStringTestInterfaceWrappableType(),
- JSCDOMStringTestInterface::s_classinfo(),
- JSCDOMStringTestInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- DerivedGetterSetterInterface::DerivedGetterSetterInterfaceWrappableType(),
- JSCDerivedGetterSetterInterface::s_classinfo(),
- JSCDerivedGetterSetterInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- DerivedInterface::DerivedInterfaceWrappableType(),
- JSCDerivedInterface::s_classinfo(),
- JSCDerivedInterface::GetCreateWrapperFunction());
-#if defined(NO_ENABLE_CONDITIONAL_INTERFACE)
- wrapper_factory->RegisterWrappableType(
- DisabledInterface::DisabledInterfaceWrappableType(),
- JSCDisabledInterface::s_classinfo(),
- JSCDisabledInterface::GetCreateWrapperFunction());
-#endif // defined(NO_ENABLE_CONDITIONAL_INTERFACE)
- wrapper_factory->RegisterWrappableType(
- EnumerationInterface::EnumerationInterfaceWrappableType(),
- JSCEnumerationInterface::s_classinfo(),
- JSCEnumerationInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- ExceptionObjectInterface::ExceptionObjectInterfaceWrappableType(),
- JSCExceptionObjectInterface::s_classinfo(),
- JSCExceptionObjectInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- ExceptionsInterface::ExceptionsInterfaceWrappableType(),
- JSCExceptionsInterface::s_classinfo(),
- JSCExceptionsInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- ExtendedIDLAttributesInterface::ExtendedIDLAttributesInterfaceWrappableType(),
- JSCExtendedIDLAttributesInterface::s_classinfo(),
- JSCExtendedIDLAttributesInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- GarbageCollectionTestInterface::GarbageCollectionTestInterfaceWrappableType(),
- JSCGarbageCollectionTestInterface::s_classinfo(),
- JSCGarbageCollectionTestInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- GetOpaqueRootInterface::GetOpaqueRootInterfaceWrappableType(),
- JSCGetOpaqueRootInterface::s_classinfo(),
- JSCGetOpaqueRootInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- GlobalInterfaceParent::GlobalInterfaceParentWrappableType(),
- JSCGlobalInterfaceParent::s_classinfo(),
- JSCGlobalInterfaceParent::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- ImplementedInterface::ImplementedInterfaceWrappableType(),
- JSCImplementedInterface::s_classinfo(),
- JSCImplementedInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- IndexedGetterInterface::IndexedGetterInterfaceWrappableType(),
- JSCIndexedGetterInterface::s_classinfo(),
- JSCIndexedGetterInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- InterfaceWithUnsupportedProperties::InterfaceWithUnsupportedPropertiesWrappableType(),
- JSCInterfaceWithUnsupportedProperties::s_classinfo(),
- JSCInterfaceWithUnsupportedProperties::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- NamedConstructorInterface::NamedConstructorInterfaceWrappableType(),
- JSCNamedConstructorInterface::s_classinfo(),
- JSCNamedConstructorInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- NamedGetterInterface::NamedGetterInterfaceWrappableType(),
- JSCNamedGetterInterface::s_classinfo(),
- JSCNamedGetterInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- NamedIndexedGetterInterface::NamedIndexedGetterInterfaceWrappableType(),
- JSCNamedIndexedGetterInterface::s_classinfo(),
- JSCNamedIndexedGetterInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- NestedPutForwardsInterface::NestedPutForwardsInterfaceWrappableType(),
- JSCNestedPutForwardsInterface::s_classinfo(),
- JSCNestedPutForwardsInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- NoConstructorInterface::NoConstructorInterfaceWrappableType(),
- JSCNoConstructorInterface::s_classinfo(),
- JSCNoConstructorInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- NoInterfaceObjectInterface::NoInterfaceObjectInterfaceWrappableType(),
- JSCNoInterfaceObjectInterface::s_classinfo(),
- JSCNoInterfaceObjectInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- NullableTypesTestInterface::NullableTypesTestInterfaceWrappableType(),
- JSCNullableTypesTestInterface::s_classinfo(),
- JSCNullableTypesTestInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- NumericTypesTestInterface::NumericTypesTestInterfaceWrappableType(),
- JSCNumericTypesTestInterface::s_classinfo(),
- JSCNumericTypesTestInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- ObjectTypeBindingsInterface::ObjectTypeBindingsInterfaceWrappableType(),
- JSCObjectTypeBindingsInterface::s_classinfo(),
- JSCObjectTypeBindingsInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- OperationsTestInterface::OperationsTestInterfaceWrappableType(),
- JSCOperationsTestInterface::s_classinfo(),
- JSCOperationsTestInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- PutForwardsInterface::PutForwardsInterfaceWrappableType(),
- JSCPutForwardsInterface::s_classinfo(),
- JSCPutForwardsInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- SequenceUser::SequenceUserWrappableType(),
- JSCSequenceUser::s_classinfo(),
- JSCSequenceUser::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- StaticPropertiesInterface::StaticPropertiesInterfaceWrappableType(),
- JSCStaticPropertiesInterface::s_classinfo(),
- JSCStaticPropertiesInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- StringifierAnonymousOperationInterface::StringifierAnonymousOperationInterfaceWrappableType(),
- JSCStringifierAnonymousOperationInterface::s_classinfo(),
- JSCStringifierAnonymousOperationInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- StringifierAttributeInterface::StringifierAttributeInterfaceWrappableType(),
- JSCStringifierAttributeInterface::s_classinfo(),
- JSCStringifierAttributeInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- StringifierOperationInterface::StringifierOperationInterfaceWrappableType(),
- JSCStringifierOperationInterface::s_classinfo(),
- JSCStringifierOperationInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- TargetInterface::TargetInterfaceWrappableType(),
- JSCTargetInterface::s_classinfo(),
- JSCTargetInterface::GetCreateWrapperFunction());
- wrapper_factory->RegisterWrappableType(
- UnionTypesInterface::UnionTypesInterfaceWrappableType(),
- JSCUnionTypesInterface::s_classinfo(),
- JSCUnionTypesInterface::GetCreateWrapperFunction());
-
- JSC::JSLockHolder lock(global_data);
- JSC::Structure* structure = JSC::Structure::create(
- *global_data,
- NULL, // JSC::JSGlobalObject*
- JSC::jsNull(), // prototype
- JSC::TypeInfo(JSC::GlobalObjectType, StructureFlags),
- &s_info);
- JSCWindow* global_wrapper =
- new (NotNull, JSC::allocateCell<JSCWindow>(global_data->heap))
- JSCWindow(
- global_data,
- structure,
- script_object_registry,
- wrapper_factory.Pass(),
- environment_settings,
- global_interface);
- global_wrapper->finishCreation(*global_data);
- global_data->heap.addFinalizer(global_wrapper, JSCWindow::destroy);
- global_wrapper->setPrototype(
- global_wrapper->globalData(),
- JSCWindow::GetPrototype(global_wrapper));
-
- return global_wrapper;
-}
-JSCWindow::JSCWindow(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- scoped_ptr<script::javascriptcore::WrapperFactory> wrapper_factory,
- script::EnvironmentSettings* environment_settings,
- const scoped_refptr<Window>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl,
- wrapper_factory.Pass(), environment_settings) {
-}
-
-void JSCWindow::finishCreation(JSC::JSGlobalData& global_data) {
- BaseClass::finishCreation(global_data);
- DCHECK(inherits(&s_info));
-}
-
-JSCWindow::~JSCWindow() {
- // Empty destructor
-}
-
-// Look up property slot for querying property values.
-bool JSCWindow::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- JSCWindow* this_object = JSC::jsCast<JSCWindow*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- // Global interface may have both operations and properties as own properties
- // so we cannot use getStaticValueSlot.
- bool found_property_slot = JSC::getStaticPropertySlot<JSCWindow, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-
-// Look up property slot and put the |value|.
-void JSCWindow::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- JSCWindow* this_object = JSC::jsCast<JSCWindow*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
- }
-
- if (!property_handled) {
- JSC::lookupPut<JSCWindow, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-
-bool JSCWindow::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- JSCWindow* this_object = JSC::jsCast<JSCWindow*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<JSCWindow, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-
-JSC::JSValue getJSwindowProperty(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCWindow", "get windowProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- Window* impl =
- GetWrappableOrSetException<Window>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->window_property());
- return result;
-}
-
-void setJSwindowProperty(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("JSCWindow", "set windowProperty");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- Window* impl =
- GetWrappableOrSetException<Window>(exec_state, this_object);
- if (!impl) {
- return;
- }
- TypeTraits<std::string >::ConversionType cobalt_value;
- FromJSValue(exec_state, value,
- kNoConversionFlags, &exception_state,
- &cobalt_value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- impl->set_window_property(cobalt_value);
- }
-}
-
-JSC::JSValue getJSwindow(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("JSCWindow", "get window");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- Window* impl =
- GetWrappableOrSetException<Window>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-
- JSC::JSValue result = ToJSValue(
- global_object,
- impl->window());
- return result;
-}
-
-JSC::EncodedJSValue functionJSgetStackTrace(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCWindow", "call getStackTrace");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- Window* impl =
- GetWrappableOrSetException<Window>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- TypeTraits<std::string >::ReturnType return_value = impl->GetStackTrace(global_object->GetStackTrace());
- return JSC::JSValue::encode(ToJSValue(global_object, return_value));
-
-}
-
-JSC::EncodedJSValue functionJSwindowOperation(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("JSCWindow", "call windowOperation");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- Window* impl =
- GetWrappableOrSetException<Window>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-
- impl->WindowOperation();
- return JSC::JSValue::encode(JSC::jsUndefined());
-
-}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- return false;
-}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-
-} // namespace testing
-} // namespace bindings
-
-namespace script {
-
-template<>
-void GlobalEnvironment::CreateGlobalObject<Window>(
- const scoped_refptr<Window>& global_interface,
- EnvironmentSettings* environment_settings) {
- JSCGlobalEnvironment* jsc_global_environment =
- base::polymorphic_downcast<JSCGlobalEnvironment*>(this);
- JSCEngine* jsc_engine = jsc_global_environment->engine();
-
- JSCGlobalObject* global_object = JSCWindow::Create(
- global_interface, environment_settings,
- jsc_engine->global_data(), jsc_engine->script_object_registry());
- jsc_global_environment->SetGlobalObject(global_object);
-}
-
-// MSVS compiler does not need this explicit instantiation, and generates a
-// compiler error.
-#if !defined(_MSC_VER)
-// Explicitly instantiate the template function for template type Window
-// This is needed to prevent link errors when trying to resolve the template
-// instantiation.
-template
-void GlobalEnvironment::CreateGlobalObject<Window>(
- const scoped_refptr<Window>& global_interface,
- EnvironmentSettings* environment_settings);
-#endif
-
-} // namespace script
-} // namespace cobalt
diff --git a/src/cobalt/bindings/generated/jsc/testing/JSCWindow.h b/src/cobalt/bindings/generated/jsc/testing/JSCWindow.h
deleted file mode 100644
index 337e702..0000000
--- a/src/cobalt/bindings/generated/jsc/testing/JSCWindow.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright 2017 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.
- */
-
-// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
-// Auto-generated from template: bindings/javascriptcore/templates/interface.h.template
-
-// clang-format off
-
-#ifndef JSCWindow_h
-#define JSCWindow_h
-
-#include "base/hash_tables.h"
-#include "base/lazy_instance.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "JSCGlobalInterfaceParent.h"
-#include "cobalt/bindings/testing/window.h"
-
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace bindings {
-namespace testing {
-
-class JSCWindow
- : public script::javascriptcore::JSCGlobalObject {
- typedef script::javascriptcore::JSCGlobalObject BaseClass;
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-
- static script::javascriptcore::JSCGlobalObject* Create(
- const scoped_refptr<Window>& global_interface,
- script::EnvironmentSettings* environment_settings,
- JSC::JSGlobalData* global_data,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry);
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- JSCWindow(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
- scoped_ptr<script::javascriptcore::WrapperFactory> wrapper_factory,
- script::EnvironmentSettings* environment_settings,
- const scoped_refptr<Window>& impl);
- ~JSCWindow();
-
- private:
- class InterfaceObject;
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-
-} // namespace bindings
-} // namespace testing
-} // namespace cobalt
-
-#endif // JSCWindow_h
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsAnonymousIndexedGetterInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsAnonymousIndexedGetterInterface.cc
index 1431c98..99f4334 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsAnonymousIndexedGetterInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsAnonymousIndexedGetterInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsAnonymousNamedGetterInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsAnonymousNamedGetterInterface.cc
index a8d43f5..d0582d8 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsAnonymousNamedGetterInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsAnonymousNamedGetterInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsAnonymousNamedIndexedGetterInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsAnonymousNamedIndexedGetterInterface.cc
index 3c2595d..b0c6695 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsAnonymousNamedIndexedGetterInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsAnonymousNamedIndexedGetterInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsArbitraryInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsArbitraryInterface.cc
index 44c9b63..4f4784df 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsArbitraryInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsArbitraryInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsBaseInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsBaseInterface.cc
index cdc9be8..132b075 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsBaseInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsBaseInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsBooleanTypeTestInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsBooleanTypeTestInterface.cc
index 9a99f9a..e410fed 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsBooleanTypeTestInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsBooleanTypeTestInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsCallbackFunctionInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsCallbackFunctionInterface.cc
index 3be6905..1a096d0 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsCallbackFunctionInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsCallbackFunctionInterface.cc
@@ -30,11 +30,11 @@
#include "cobalt/bindings/testing/arbitrary_interface.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -63,24 +63,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsCallbackInterfaceInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsCallbackInterfaceInterface.cc
index 10ac0df..f48c900 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsCallbackInterfaceInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsCallbackInterfaceInterface.cc
@@ -30,11 +30,11 @@
#include "cobalt/bindings/testing/single_operation_interface.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -63,24 +63,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsConditionalInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsConditionalInterface.cc
index 9cdd93d..6212ba4 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsConditionalInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsConditionalInterface.cc
@@ -30,11 +30,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -61,24 +61,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsConstantsInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsConstantsInterface.cc
index bcdf5b9..03c4196 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsConstantsInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsConstantsInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsConstructorInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsConstructorInterface.cc
index 8f70977..1bc6ac8 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsConstructorInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsConstructorInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsConstructorWithArgumentsInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsConstructorWithArgumentsInterface.cc
index 133af7b..f0e18bd 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsConstructorWithArgumentsInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsConstructorWithArgumentsInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsDOMStringTestInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsDOMStringTestInterface.cc
index 9f8c0df..b3bd4dd 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsDOMStringTestInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsDOMStringTestInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsDerivedGetterSetterInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsDerivedGetterSetterInterface.cc
index bd6275e..4675e1d 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsDerivedGetterSetterInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsDerivedGetterSetterInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsDerivedInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsDerivedInterface.cc
index 91b1f0a..208da07 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsDerivedInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsDerivedInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsDisabledInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsDisabledInterface.cc
index ee423a0..0375829 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsDisabledInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsDisabledInterface.cc
@@ -30,11 +30,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -61,24 +61,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsEnumerationInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsEnumerationInterface.cc
index 8a1d44d..69d01c4 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsEnumerationInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsEnumerationInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
// Declare and define these in the same namespace that the other overloads
// were brought into with the using declaration.
void ToJSValue(
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsExceptionObjectInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsExceptionObjectInterface.cc
index bd69c56..225b3e4 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsExceptionObjectInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsExceptionObjectInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -60,24 +60,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsExceptionsInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsExceptionsInterface.cc
index 57c7eb2..99d0bd4 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsExceptionsInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsExceptionsInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsExtendedIDLAttributesInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsExtendedIDLAttributesInterface.cc
index e3fc612..637bd2d 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsExtendedIDLAttributesInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsExtendedIDLAttributesInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsGarbageCollectionTestInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsGarbageCollectionTestInterface.cc
index 898f998..af6ac31 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsGarbageCollectionTestInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsGarbageCollectionTestInterface.cc
@@ -30,11 +30,11 @@
#include "cobalt/bindings/testing/garbage_collection_test_interface.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -63,24 +63,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsGetOpaqueRootInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsGetOpaqueRootInterface.cc
index 0c5b553..000b086 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsGetOpaqueRootInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsGetOpaqueRootInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsGlobalInterfaceParent.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsGlobalInterfaceParent.cc
index 7c3b03f..008fe1d 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsGlobalInterfaceParent.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsGlobalInterfaceParent.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsIndexedGetterInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsIndexedGetterInterface.cc
index 84c8d65..9c30841 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsIndexedGetterInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsIndexedGetterInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsInterfaceWithUnsupportedProperties.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsInterfaceWithUnsupportedProperties.cc
index abefc97..e6eb894 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsInterfaceWithUnsupportedProperties.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsInterfaceWithUnsupportedProperties.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsNamedConstructorInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsNamedConstructorInterface.cc
index 24c5476..89c25ee 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsNamedConstructorInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsNamedConstructorInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsNamedGetterInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsNamedGetterInterface.cc
index 600a69b..39327ca 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsNamedGetterInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsNamedGetterInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsNamedIndexedGetterInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsNamedIndexedGetterInterface.cc
index 4bac6ac..d94c42e 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsNamedIndexedGetterInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsNamedIndexedGetterInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsNestedPutForwardsInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsNestedPutForwardsInterface.cc
index 0cd1892..cc2a0d3 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsNestedPutForwardsInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsNestedPutForwardsInterface.cc
@@ -30,11 +30,11 @@
#include "cobalt/bindings/testing/put_forwards_interface.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -63,24 +63,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsNoConstructorInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsNoConstructorInterface.cc
index 2c2c72a..fda94fd 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsNoConstructorInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsNoConstructorInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsNoInterfaceObjectInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsNoInterfaceObjectInterface.cc
index 7fcd823..5dc3462 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsNoInterfaceObjectInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsNoInterfaceObjectInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsNullableTypesTestInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsNullableTypesTestInterface.cc
index 7744590..c84d0da 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsNullableTypesTestInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsNullableTypesTestInterface.cc
@@ -30,11 +30,11 @@
#include "cobalt/bindings/testing/arbitrary_interface.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -63,24 +63,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsNumericTypesTestInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsNumericTypesTestInterface.cc
index 127a4f1..c69246b 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsNumericTypesTestInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsNumericTypesTestInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsObjectTypeBindingsInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsObjectTypeBindingsInterface.cc
index fd32f75..eee7181 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsObjectTypeBindingsInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsObjectTypeBindingsInterface.cc
@@ -34,11 +34,11 @@
#include "cobalt/bindings/testing/derived_interface.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -71,24 +71,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsOperationsTestInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsOperationsTestInterface.cc
index 884fca6..97906a1 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsOperationsTestInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsOperationsTestInterface.cc
@@ -30,11 +30,11 @@
#include "cobalt/bindings/testing/arbitrary_interface.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -63,24 +63,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsPutForwardsInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsPutForwardsInterface.cc
index 93471b0..85d028c 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsPutForwardsInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsPutForwardsInterface.cc
@@ -30,11 +30,11 @@
#include "cobalt/bindings/testing/arbitrary_interface.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -63,24 +63,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsSequenceUser.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsSequenceUser.cc
index 164ed3c..3612c6c 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsSequenceUser.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsSequenceUser.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsStaticPropertiesInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsStaticPropertiesInterface.cc
index 9c2fe11..083be93 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsStaticPropertiesInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsStaticPropertiesInterface.cc
@@ -30,11 +30,11 @@
#include "cobalt/bindings/testing/arbitrary_interface.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -63,24 +63,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsStringifierAnonymousOperationInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsStringifierAnonymousOperationInterface.cc
index bb8be7c..2f8dbd5 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsStringifierAnonymousOperationInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsStringifierAnonymousOperationInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsStringifierAttributeInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsStringifierAttributeInterface.cc
index 2313691..591fce5 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsStringifierAttributeInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsStringifierAttributeInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsStringifierOperationInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsStringifierOperationInterface.cc
index 0eae6b1..aa4ccda 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsStringifierOperationInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsStringifierOperationInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsTargetInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsTargetInterface.cc
index c680c08..afd7fcf 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsTargetInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsTargetInterface.cc
@@ -28,11 +28,11 @@
#include "cobalt/script/script_object.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -59,24 +59,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsUnionTypesInterface.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsUnionTypesInterface.cc
index 709d054..2c61789 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsUnionTypesInterface.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsUnionTypesInterface.cc
@@ -32,11 +32,11 @@
#include "cobalt/bindings/testing/base_interface.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -67,24 +67,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
} // namespace
namespace cobalt {
diff --git a/src/cobalt/bindings/generated/mozjs/testing/MozjsWindow.cc b/src/cobalt/bindings/generated/mozjs/testing/MozjsWindow.cc
index 69c6ccb..acb3053 100644
--- a/src/cobalt/bindings/generated/mozjs/testing/MozjsWindow.cc
+++ b/src/cobalt/bindings/generated/mozjs/testing/MozjsWindow.cc
@@ -120,11 +120,11 @@
#include "cobalt/bindings/testing/window.h"
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -251,24 +251,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
JSObject* DummyFunctor(
JSContext* context, const scoped_refptr<Wrappable>& wrappable) {
NOTREACHED();
@@ -788,6 +788,7 @@
MozjsWindow::CreateProxy(
context, global_interface);
mozjs_global_environment->SetEnvironmentSettings(environment_settings);
+ mozjs_global_environment->EvaluateAutomatics();
WrapperFactory* wrapper_factory =
mozjs_global_environment->wrapper_factory();
diff --git a/src/cobalt/bindings/javascriptcore/__init__.py b/src/cobalt/bindings/javascriptcore/__init__.py
deleted file mode 100644
index ef65bee..0000000
--- a/src/cobalt/bindings/javascriptcore/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-# Required for Python to search this directory for module files
diff --git a/src/cobalt/bindings/javascriptcore/code_generator.py b/src/cobalt/bindings/javascriptcore/code_generator.py
deleted file mode 100644
index 89f3e71..0000000
--- a/src/cobalt/bindings/javascriptcore/code_generator.py
+++ /dev/null
@@ -1,103 +0,0 @@
-# Copyright 2016 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.
-"""JSC-specific implementation of CodeGeneratorCobalt.
-
-Defines CodeGeneratorJsc and ExpressionGeneratorJsc classes.
-"""
-
-import os
-import sys
-
-# Add the bindings directory to the path.
-module_path, module_filename = os.path.split(os.path.realpath(__file__))
-cobalt_bindings_dir = os.path.normpath(os.path.join(module_path, os.pardir))
-sys.path.append(cobalt_bindings_dir)
-
-from code_generator_cobalt import CodeGeneratorCobalt # pylint: disable=g-import-not-at-top
-from expression_generator import ExpressionGenerator
-
-TEMPLATES_DIR = os.path.normpath(os.path.join(module_path, 'templates'))
-
-
-def calculate_jsc_lookup_size(num_properties):
- """Calculate the number of entries to allocate in JSC::Lookup hash table."""
- # JSC::Lookup uses an array internally to represent hash entries.
- # The first |size_mask + 1| entries are hash buckets, and the remaining
- # entries starting from entries[size_mask+1] are used for hash collisions.
- # In the worst case where all keys collide, we will need
- # (size_mask +1) + (num_properties - 1) entries, to account for properties[0]
- # getting assigned to a hash bucket, and the remaining N-1 properties getting
- # assigned to overflow entries.
- # TODO: WebKit's bindings generation script calculates the actual
- # required number of entries by duplicating the JSC::Lookup logic in the
- # script and determining the number of collisions. If we want to reduce the
- # number of entries allocated we can do something similar.
- size_mask = calculate_jsc_lookup_size_mask(num_properties)
- return (size_mask + 1) + max(0, (num_properties - 1))
-
-
-def calculate_jsc_lookup_size_mask(num_properties):
- """Calculate the number of hash buckets to use in JSC::Lookup hash table."""
- # 2 * num_properties is the heuristic used in WebKit's JSC bindings generation
- # script to determine the number of hash buckets for the property hash table
- num_hash_buckets = max(1, 2 * num_properties)
- # JSC::Lookup hash table implementation uses a bitmask of the Identifier's
- # hash to determine which bucket a Property goes into. This also rounds the
- # number of buckets up to the closest power of 2.
- return pow(2, num_hash_buckets.bit_length()) - 1
-
-
-class ExpressionGeneratorJsc(ExpressionGenerator):
- """Implementation of ExpressionGenerator for JavaScriptCore."""
-
- def is_undefined(self, arg):
- return '%s.isUndefined()' % arg
-
- def is_undefined_or_null(self, arg):
- return '%s.isUndefinedOrNull()' % arg
-
- def inherits_interface(self, interface_name, arg):
- return '%s.inherits(JSC%s::s_classinfo())' % (arg, interface_name)
-
- def is_number(self, arg):
- return '%s.isNumber()' % arg
-
-
-class CodeGeneratorJsc(CodeGeneratorCobalt):
- """Code generator class for JavaScriptCore bindings."""
-
- _expression_generator = ExpressionGeneratorJsc()
-
- def __init__(self, interfaces_info, cache_dir, output_dir):
- CodeGeneratorCobalt.__init__(self, interfaces_info, TEMPLATES_DIR,
- cache_dir, output_dir)
-
- @property
- def generated_file_prefix(self):
- return 'JSC'
-
- @property
- def expression_generator(self):
- return CodeGeneratorJsc._expression_generator
-
- def build_interface_context(self, interface, interface_info, definitions):
- """Overrides CodeGeneratorCobalt.build_interface_context."""
- context = super(CodeGeneratorJsc, self).build_interface_context(
- interface, interface_info, definitions)
- jsc_lookup_info = {
- 'calculate_jsc_lookup_size': calculate_jsc_lookup_size,
- 'calculate_jsc_lookup_size_mask': calculate_jsc_lookup_size_mask,
- }
- context.update(jsc_lookup_info)
- return context
diff --git a/src/cobalt/bindings/javascriptcore/idl_compiler.py b/src/cobalt/bindings/javascriptcore/idl_compiler.py
deleted file mode 100644
index 9277e29..0000000
--- a/src/cobalt/bindings/javascriptcore/idl_compiler.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2016 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.
-"""Compile an .idl file to Cobalt JSC bindings (.h and .cpp files).
-
-Calls into idl_compiler_cobalt.shared_main specifying the JavaScriptCore
-CodeGenerator class.
-"""
-
-import os
-import sys
-
-module_path, module_filename = os.path.split(os.path.realpath(__file__))
-bindings_dir = os.path.normpath(os.path.join(module_path, os.pardir))
-sys.path.append(bindings_dir)
-
-from idl_compiler_cobalt import generate_bindings # pylint: disable=g-import-not-at-top
-from javascriptcore.code_generator import CodeGeneratorJsc
-
-if __name__ == '__main__':
- sys.exit(generate_bindings(CodeGeneratorJsc))
diff --git a/src/cobalt/bindings/javascriptcore/templates/callback-interface.cc.template b/src/cobalt/bindings/javascriptcore/templates/callback-interface.cc.template
deleted file mode 100644
index 6768199..0000000
--- a/src/cobalt/bindings/javascriptcore/templates/callback-interface.cc.template
+++ /dev/null
@@ -1,118 +0,0 @@
-{#
- # Copyright 2016 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.
- #}
-{% extends "callback-interface-base.cc.template" %}
-{% block includes %}
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-{{ super() }}
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-{% endblock includes %}
-
-{% block using_directives %}
-{{ super() }}
-using cobalt::script::javascriptcore::GetCallableForCallbackInterface;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::util::GetExceptionString;
-{% endblock using_directives %}
-
-{% block implementation %}
-namespace cobalt {
-{% for component in components %}
-namespace {{component}} {
-{% endfor %}
-
-{{binding_class}}::{{binding_class}}(
- JSC::JSObject* implementing_object)
- : implementing_object_(implementing_object) { }
-
-{% for operation in operations %}
-{% for overload in operation.overloads %}
-{{overload.type}} {{binding_class}}::{{overload.name}}(
- const scoped_refptr<script::Wrappable>& callback_this,
- {% for arg in overload.arguments %}
- {{arg.arg_type}} {{arg.name}},
- {% endfor %}
- bool* had_exception) const {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(implementing_object_->globalObject());
- JSC::JSGlobalData* global_data = &global_object->globalData();
- JSC::ExecState* exec_state = global_object->globalExec();
- JSC::JSLockHolder lock(*global_data);
-
- // get callable object
- JSC::JSValue callable;
- JSC::CallData call_data;
- JSC::CallType call_type = GetCallableForCallbackInterface(exec_state,
- implementing_object_, "{{overload.idl_name}}", &callable, &call_data);
- if (call_type == JSC::CallTypeNone) {
- // TypeError
- DLOG(INFO) << "User object was not callable.";
- *had_exception = true;
-{% if overload.type == 'void' %}
- return;
-{% else %}
- return {{overload.type}}();
-{% endif %}
- }
-
- JSC::JSValue js_this = ToJSValue(global_object, callback_this);
-
- // Convert args.
- JSC::MarkedArgumentBuffer args;
- {% for arg in overload.arguments %}
- args.append(ToJSValue(global_object, {{arg.name}}));
- {% endfor %}
-
- // call
- JSC::DynamicGlobalObjectScope global_object_scope(*global_data, global_object);
- JSC::JSValue js_return_value =
- JSC::call(exec_state, callable, call_type, call_data, js_this, args);
- if (exec_state->hadException()) {
- DLOG(WARNING) << "Exception in callback: "
- << GetExceptionString(exec_state);
- exec_state->clearException();
- *had_exception = true;
-{% if overload.type == 'void' %}
- return;
-{% else %}
- return {{overload.type}}();
-{% endif %}
- }
-{% if overload.type != 'void' %}
- JSCExceptionState exception_state(global_object);
- {{overload.type}} cobalt_return_value;
- FromJSValue(exec_state, js_return_value, 0, &exception_state, &cobalt_return_value);
-
- *had_exception = exception_state.is_exception_set();
- return cobalt_return_value;
-{% else %}
- *had_exception = false;
-{% endif %}
-}
-{% endfor %}
-{% endfor %}
-
-{% for component in components %}
-} // namespace {{component}}
-{% endfor %}
-} // namespace cobalt
-{% endblock implementation %}
diff --git a/src/cobalt/bindings/javascriptcore/templates/callback-interface.h.template b/src/cobalt/bindings/javascriptcore/templates/callback-interface.h.template
deleted file mode 100644
index 3a399c6..0000000
--- a/src/cobalt/bindings/javascriptcore/templates/callback-interface.h.template
+++ /dev/null
@@ -1,65 +0,0 @@
-{#
- # Copyright 2016 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.
- #}
-{% extends "callback-interface-base.h.template" %}
-
-{% block includes %}
-#include "cobalt/script/wrappable.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-{% for include in header_includes %}
-#include "{{include}}"
-{% endfor %}
-{% endblock includes %}
-
-{% block implementation %}
-namespace cobalt {
-{% for component in components %}
-namespace {{component}} {
-{% endfor %}
-
-class {{binding_class}} : public {{impl_class}} {
- public:
- {{binding_class}}(JSC::JSObject* implementing_object);
-{% for operation in operations %}
-{% for overload in operation.overloads %}
- {{overload.type}} {{overload.name}}(
- const scoped_refptr<script::Wrappable>& callback_this,
- {% for arg in overload.arguments %}
- {{arg.arg_type}} {{arg.name}},
- {% endfor %}
- bool* had_exception) const OVERRIDE;
-{% endfor %}
-{% endfor %}
- JSC::JSObject* implementing_object() const { return implementing_object_; }
-
- private:
- JSC::JSObject* implementing_object_;
-};
-
-{% for component in components %}
-} // namespace {{component}}
-{% endfor %}
-namespace script {
-// Explicit instantiation of CallbackInterfaceTraits struct so we can infer
-// the type of the generated class from the type of the callback interface.
-template<>
-struct CallbackInterfaceTraits<{{fully_qualified_impl_class}}> {
- typedef {{fully_qualified_binding_class}} JSCCallbackInterfaceClass;
-};
-
-} // namespace script
-} // namespace cobalt
-{% endblock implementation %}
diff --git a/src/cobalt/bindings/javascriptcore/templates/interface-object.template b/src/cobalt/bindings/javascriptcore/templates/interface-object.template
deleted file mode 100644
index 325ea41..0000000
--- a/src/cobalt/bindings/javascriptcore/templates/interface-object.template
+++ /dev/null
@@ -1,233 +0,0 @@
-{#
- # Copyright 2016 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.
- #}
-
-{% macro create_interface_object(interface_object_class_name, interface_object_name) -%}
-// Class that defines a JS Object representing this interface's Interface Object
-// https://www.w3.org/TR/WebIDL/#interface-object
-class {{binding_class}}::{{interface_object_class_name}} : public ConstructorBase {
- public:
- // Get the Interface Object. Will create a new Interface Object if necessary,
- // otherwise it will return the cached one.
- static JSC::JSObject* GetInstance(JSC::ExecState* exec);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- {{interface_object_class_name}}* this_object = JSC::jsCast<{{interface_object_class_name}}*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-
- // Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
- // Since JSFunction::getOwnPropertySlot is protected, we can't call it from
- // the helper function.
- const JSC::HashEntry* entry =
- GetPropertyTable(exec)->entry(exec, property_name);
-
- if (!entry) // not found, forward to parent
- return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
-
- if (entry->attributes() & JSC::Function)
- return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
-
- slot.setCacheableCustom(this_object, entry->propertyGetter());
- return true;
- }
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- {{interface_object_class_name}}* this_object = JSC::jsCast<{{interface_object_class_name}}*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool found_property = JSC::lookupPut<{{interface_object_class_name}}>(
- exec_state, property_name, value, GetPropertyTable(exec_state),
- this_object, slot.isStrictMode());
- DLOG_IF(INFO, !found_property) << "Did not find property named " <<
- WTF::String(property_name.publicName()).utf8().data() <<
- " to set on interface object for {{binding_class}}";
- if (!found_property) {
- BaseClass::put(cell, exec_state, property_name, value, slot);
- }
- }
-
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
-{% if not constructor %}
- // static override. This prevents this object from being called as a
- // constructor, throwing a TypeError if the user attempts to do so.
- //
- // This method is defined when no constructors are defined on the IDL.
- static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
- return JSC::ConstructTypeNone;
- }
-{% endif %}
-
- private:
- typedef ConstructorBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::ImplementsHasInstance |
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- {{interface_object_class_name}}(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(exec_state, global_object, structure) { }
- void finishCreation(JSC::ExecState* exec_state,
- JSC::NativeExecutable* native_executable, int length,
- const String& name);
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue {{binding_class}}::{{interface_object_class_name}}::property_table_values[] = {
- // static functions will also go here.
-{% for attribute in static_attributes %}
-{% if attribute.conditional %}
-#if defined({{attribute.conditional}})
-{% endif %}
- { "{{attribute.idl_name}}",
- JSC::DontDelete {{'| JSC::ReadOnly' if attribute.is_read_only}},
- reinterpret_cast<intptr_t>(getJS{{attribute.idl_name}}),
- {% if attribute.is_read_only %}
- 0,
- {% else %}
- reinterpret_cast<intptr_t>(setJS{{attribute.idl_name}}),
- {% endif %}
- JSC::NoIntrinsic
- },
-{% if attribute.conditional %}
-#endif // defined({{attribute.conditional}})
-{% endif %}
-{% endfor %}
-{% for operation in static_operations %}
-{% if operation.conditional %}
-#if defined({{operation.conditional}})
-{% endif %}
- { "{{operation.idl_name}}",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(staticFunctionJS{{operation.idl_name}}),
- static_cast<intptr_t>({{operation.length}}),
- JSC::NoIntrinsic
- },
-{% if operation.conditional %}
-#endif // defined({{operation.conditional}})
-{% endif %}
-{% endfor %}
-{% for constant in constants %}
- { "{{constant.idl_name}}",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJS{{constant.idl_name}}),
- 0,
- JSC::NoIntrinsic
- },
-{% endfor %}
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // {{binding_class}}::{{interface_object_class_name}}::property_table_values
-
-// static
-const JSC::HashTable
-{{binding_class}}::{{interface_object_class_name}}::property_table_prototype = {
-{% set num_properties = constants|length + static_attributes|length + static_operations|length %}
- // Sizes will be calculated based on the number of static functions as well.
- {{ calculate_jsc_lookup_size(num_properties) }}, // compactSize
- {{ calculate_jsc_lookup_size_mask(num_properties) }}, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // {{binding_class}}::{{interface_object_class_name}}::property_table_prototype
-
-// static
-const JSC::HashTable*
-{{binding_class}}::{{interface_object_class_name}}::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- {{binding_class}}::{{interface_object_class_name}}::s_classinfo(),
- property_table_prototype);
-}
-
-const JSC::ClassInfo {{binding_class}}::{{interface_object_class_name}}::s_info = {
- "{{interface_name}}Constructor", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE({{binding_class}}::{{interface_object_class_name}})
-}; // {{binding_class}}::{{interface_object_class_name}}::s_info
-
-void {{binding_class}}::{{interface_object_class_name}}::finishCreation(
- JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
- int length, const String& name) {
- BaseClass::finishCreation(exec_state, native_executable, length, name);
- ASSERT(inherits(&s_info));
- // Add a 'prototype' property whose value is the prototype object.
- putDirect(exec_state->globalData(),
- exec_state->propertyNames().prototype,
- {{binding_class}}::GetPrototype(exec_state->lexicalGlobalObject()),
- JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
- DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
-}
-
-// static
-JSC::JSObject* {{binding_class}}::{{interface_object_class_name}}::GetInstance(
- JSC::ExecState* exec_state) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached interface object, and create a new one if needed.
- JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
- if (interface_object == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSObject* parent_prototype = global_object->functionPrototype();
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
-{% if constructor %}
- const int kNumArguments = {{constructor.length}};
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, &constructorJS{{impl_class}});
-{% else %}
- const int kNumArguments = 0;
- // NativeExecutable must be non-null even if this is not actually callable.
- JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
-{% endif %}
-
- // Create the new interface object.
- {{interface_object_class_name}}* new_interface_object =
- new (NotNull, JSC::allocateCell<{{interface_object_class_name}}>(global_data.heap))
- {{interface_object_class_name}}(exec_state, global_object, structure);
- new_interface_object->finishCreation(exec_state, executable, kNumArguments, "{{interface_object_name}}");
- // Add the interface object to the cache.
- global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
- interface_object = new_interface_object;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
- return interface_object;
-}
-
-// End of {{binding_class}}::{{interface_object_class_name}} class
-{% endmacro %}
diff --git a/src/cobalt/bindings/javascriptcore/templates/interface.cc.template b/src/cobalt/bindings/javascriptcore/templates/interface.cc.template
deleted file mode 100644
index 4958230..0000000
--- a/src/cobalt/bindings/javascriptcore/templates/interface.cc.template
+++ /dev/null
@@ -1,1126 +0,0 @@
-{#
- # Copyright 2015 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.
- #}
-{% extends "interface-base.cc.template" %}
-{% block includes %}
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-
-{{ super() }}
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-{% if named_property_getter %}
-#include "cobalt/script/javascriptcore/jsc_property_enumerator.h"
-{% endif %}
-#include "cobalt/script/javascriptcore/type_traits.h"
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-{% if is_exception_interface %}
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ErrorPrototype.h"
-{% endif %}
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
-{% endblock includes %}
-{% block using_directives %}
-{{ super() }}
-using cobalt::script::javascriptcore::kConversionFlagNullable;
-using cobalt::script::javascriptcore::kConversionFlagRestricted;
-using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
-using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
-using cobalt::script::javascriptcore::kNoConversionFlags;
-using cobalt::script::javascriptcore::ConstructorBase;
-using cobalt::script::javascriptcore::GetWrappableOrSetException;
-using cobalt::script::javascriptcore::FromJSValue;
-using cobalt::script::javascriptcore::FromWTFString;
-using cobalt::script::javascriptcore::JSCCallbackFunction;
-using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
-using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
-using cobalt::script::javascriptcore::JSCEngine;
-using cobalt::script::javascriptcore::JSCExceptionState;
-using cobalt::script::javascriptcore::JSCGlobalEnvironment;
-using cobalt::script::javascriptcore::JSCGlobalObject;
-using cobalt::script::javascriptcore::JSCObjectHandle;
-using cobalt::script::javascriptcore::JSCObjectHandleHolder;
-{% if named_property_getter %}
-using cobalt::script::javascriptcore::JSCPropertyEnumerator;
-{% endif %}
-using cobalt::script::javascriptcore::JSObjectToWrappable;
-using cobalt::script::javascriptcore::PrototypeBase;
-using cobalt::script::javascriptcore::ScriptObjectRegistry;
-using cobalt::script::javascriptcore::ThreadLocalHashTable;
-using cobalt::script::javascriptcore::ToJSValue;
-using cobalt::script::javascriptcore::ToWTFString;
-using cobalt::script::javascriptcore::TypeTraits;
-using cobalt::script::javascriptcore::WrapperBase;
-using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
-using cobalt::script::javascriptcore::util::GetStackTrace;
-{% endblock using_directives %}
-{% block enumeration_declarations %}
-{% if enumerations|length %}
-// Declare and define these in the same namespace that the other overloads
-// were brought into with the using declaration.
-{% for enumeration in enumerations %}
-JSC::JSValue ToJSValue(JSCGlobalObject*, {{impl_class}}::{{enumeration.name}} in_enum);
-void FromJSValue(JSC::ExecState* exec_state, JSC::JSValue jsvalue,
- int conversion_flags, JSCExceptionState* exception_state,
- {{impl_class}}::{{enumeration.name}}* out_enum);
-{% endfor %}
-{% endif %}
-{% endblock enumeration_declarations %}
-
-{% from 'macros.cc.template' import add_extra_arguments %}
-{% from 'macros.cc.template' import call_function %}
-{% from 'macros.cc.template' import constructor_implementation with context %}
-{% from 'macros.cc.template' import function_implementation with context %}
-{% from 'macros.cc.template' import overload_resolution_implementation with context %}
-{% from 'macros.cc.template' import set_attribute_implementation with context %}
-{% from 'interface-object.template' import create_interface_object with context %}
-
-{% block implementation %}
-namespace {
-{% for constant in constants %}
-JSC::JSValue getJS{{constant.idl_name}}(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-{% endfor %}
-{% for attribute in attributes + static_attributes %}
-{% if attribute.conditional %}
-#if defined({{attribute.conditional}})
-{% endif %}
-JSC::JSValue getJS{{attribute.idl_name}}(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-{% if attribute.has_setter %}
-void setJS{{attribute.idl_name}}(
- JSC::ExecState* exec,
- JSC::JSObject* this_object,
- JSC::JSValue value);
-{% endif %}
-{% if attribute.conditional %}
-#endif // defined({{attribute.conditional}})
-{% endif %}
-{% endfor %}
-{% if constructor %}
-JSC::EncodedJSValue constructorJS{{impl_class}}(JSC::ExecState*);
-{% for overload in constructor.overloads if constructor.overloads|length > 1 %}
-JSC::EncodedJSValue constructorJS{{impl_class}}{{overload.overload_index}}(JSC::ExecState*);
-{% endfor %}
-{% endif %}
-{% for operation in operations + static_operations %}
-{% if operation.conditional %}
-#if defined({{operation.conditional}})
-{% endif %}
-{% set boundFunctionPrefix = "staticFunctionJS" if operation.is_static else "functionJS" %}
-JSC::EncodedJSValue {{boundFunctionPrefix}}{{operation.idl_name}}(JSC::ExecState*);
-{% for overload in operation.overloads if operation.overloads|length > 1 %}
-JSC::EncodedJSValue {{boundFunctionPrefix}}{{overload.idl_name}}{{overload.overload_index}}(JSC::ExecState*);
-{% endfor %}
-{% if operation.conditional %}
-#endif // defined({{operation.conditional}})
-{% endif %}
-{% endfor %}
-{% if indexed_property_getter %}
-JSC::JSValue IndexedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, uint32_t index);
-{% endif %}
-{% if indexed_property_setter %}
-void IndexedPropertySetter(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::JSValue value);
-{% endif %}
-{% if stringifier %}
-JSC::EncodedJSValue StringifierJS(JSC::ExecState*);
-{% endif %}
-
-// These are declared unconditionally, but only defined if needed by the
-// interface.
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value);
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name);
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name);
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value);
-
-const bool s_has_named_getter = {{'true' if named_property_getter else 'false'}};
-const bool s_has_named_setter = {{'true' if named_property_setter else 'false'}};
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-const bool s_use_debug_missing_property_handler = {{'true' if not parent_interface else 'false'}};
-#else
-const bool s_use_debug_missing_property_handler = false;
-#endif
-{% if get_opaque_root %}
-scoped_refptr<Wrappable> GetOpaqueRootFromWrappable(
- const scoped_refptr<Wrappable>& wrappable) {
- {{impl_class}}* impl =
- base::polymorphic_downcast<{{impl_class}}*>(wrappable.get());
- Wrappable* opaque_root = impl->{{get_opaque_root}}();
- return make_scoped_refptr<Wrappable>(opaque_root);
-}
-{% endif %}
-} // namespace
-
-{% if has_interface_object %}
-{{create_interface_object("InterfaceObject", impl_class)}}
-{% endif %}
-{% if named_constructor %}
-{{create_interface_object("NamedInterfaceObject", named_constructor)}}
-{% endif %}
-{% include "prototype-object.template" %}
-
-const JSC::HashTableValue {{binding_class}}::property_table_values[] = {
-{% for attribute in attributes %}
-{% if attribute.conditional %}
-#if defined({{attribute.conditional}})
-{% endif %}
- { "{{attribute.idl_name}}",
- JSC::DontDelete {{'| JSC::ReadOnly' if not attribute.has_setter}},
- reinterpret_cast<intptr_t>(getJS{{attribute.idl_name}}),
- {% if attribute.has_setter %}
- reinterpret_cast<intptr_t>(setJS{{attribute.idl_name}}),
- {% else %}
- 0,
- {% endif %}
- JSC::NoIntrinsic
- },
-{% if attribute.conditional %}
-#endif // defined({{attribute.conditional}})
-{% endif %}
-{% endfor %}
-{% if is_global_interface %}
-{% for operation in operations %}
-{% if operation.conditional %}
-#if defined({{operation.conditional}})
-{% endif %}
- { "{{operation.idl_name}}",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJS{{operation.idl_name}}),
- static_cast<intptr_t>({{operation.length}}),
- JSC::NoIntrinsic
- },
-{% if operation.conditional %}
-#endif // defined({{operation.conditional}})
-{% endif %}
-{% endfor %}
-{% endif %}
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // {{binding_class}}::property_table_values
-
-// static
-const JSC::HashTable {{binding_class}}::property_table_prototype = {
-{# This doesn't take into account disabled properties, but this is okay. This
- value must be at least as large as the number of properties. #}
-{% set num_properties = attributes|length %}
-{% if is_global_interface %}
-{% set num_properties = num_properties + operations|length %}
-{% endif %}
- {{ calculate_jsc_lookup_size(num_properties) }}, // compactSize
- {{ calculate_jsc_lookup_size_mask(num_properties) }}, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // {{binding_class}}::property_table_prototype
-
-// static
-const JSC::HashTable* {{binding_class}}::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- {{binding_class}}::s_classinfo(), property_table_prototype);
-}
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
-base::LazyInstance<{{binding_class}}::NonTrivialStaticFields>
- {{binding_class}}::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
-#endif // __LB_SHELL__FORCE_LOGGING__
-
-const JSC::ClassInfo {{binding_class}}::s_info = {
- "{{interface_name}}", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE({{binding_class}})
-}; // {{binding_class}}::s_info
-
-// static
-JSC::JSObject* {{binding_class}}::GetPrototype(
- JSC::JSGlobalObject* global_object) {
- return Prototype::GetInstance(global_object);
-}
-
-{% if has_interface_object %}
-// static
-JSC::JSObject* {{binding_class}}::GetConstructor(
- JSC::ExecState* exec_state) {
- return InterfaceObject::GetInstance(exec_state);
-}
-
-// static
-JSC::JSValue {{binding_class}}::Prototype::GetConstructor(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
-}
-{% endif %}
-{% if named_constructor %}
-JSC::JSObject* {{binding_class}}::GetNamedConstructor(
- JSC::ExecState* exec_state) {
- return NamedInterfaceObject::GetInstance(exec_state);
-}
-{% endif %}
-{% if is_global_interface %}
-
-// static
-script::javascriptcore::JSCGlobalObject* {{binding_class}}::Create(
- const scoped_refptr<{{impl_class}}>& global_interface,
- script::EnvironmentSettings* environment_settings,
- JSC::JSGlobalData* global_data,
- ScriptObjectRegistry* script_object_registry) {
- scoped_ptr<script::javascriptcore::WrapperFactory> wrapper_factory =
- make_scoped_ptr(new script::javascriptcore::WrapperFactory());
-{% for interface in all_interfaces %}
-{% if interface.conditional %}
-#if defined({{interface.conditional}})
-{% endif %}
- {# Don't register a create method for the global interface, since we do not
- create a wrapper for it directly. #}
- {% if interface.name != impl_class %}
- wrapper_factory->RegisterWrappableType(
- {{interface.name}}::{{interface.name}}WrappableType(),
- JSC{{interface.name}}::s_classinfo(),
- JSC{{interface.name}}::GetCreateWrapperFunction());
- {% endif %}
-{% if interface.conditional %}
-#endif // defined({{interface.conditional}})
-{% endif %}
-{% endfor %}
-
- JSC::JSLockHolder lock(global_data);
- JSC::Structure* structure = JSC::Structure::create(
- *global_data,
- NULL, // JSC::JSGlobalObject*
- JSC::jsNull(), // prototype
- JSC::TypeInfo(JSC::GlobalObjectType, StructureFlags),
- &s_info);
- {{binding_class}}* global_wrapper =
- new (NotNull, JSC::allocateCell<{{binding_class}}>(global_data->heap))
- {{binding_class}}(
- global_data,
- structure,
- script_object_registry,
- wrapper_factory.Pass(),
- environment_settings,
- global_interface);
- global_wrapper->finishCreation(*global_data);
- global_data->heap.addFinalizer(global_wrapper, {{binding_class}}::destroy);
- global_wrapper->setPrototype(
- global_wrapper->globalData(),
- {{binding_class}}::GetPrototype(global_wrapper));
-
- return global_wrapper;
-}
-{% else %}
-
-// static
-JSC::JSObject* {{binding_class}}::Create(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) {
- if (!(wrappable->GetWrappableType() == {{impl_class}}::{{impl_class}}WrappableType())) {
- NOTREACHED() << "Type of wrappable does not match {{impl_class}}::{{impl_class}}WrappableType()";
- return NULL;
- }
- {{impl_class}}* impl_ptr =
- base::polymorphic_downcast<{{impl_class}}*>(wrappable.get());
-
- JSC::JSGlobalData& global_data = global_object->globalData();
-
- // Get or Create the prototype object for this interface.
- JSC::JSObject* prototype = Prototype::GetInstance(global_object);
- DCHECK(prototype);
-
- JSC::JSLockHolder lock(global_data);
- // Create a JSC::Structure object for this instance.
-{% if is_exception_interface %}
- JSC::TypeInfo type_info(JSC::ErrorInstanceType, StructureFlags);
-{% else %}
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
-{% endif %}
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(prototype),
- type_info,
- &s_info);
-
- // Instantiate a new garbage-collected wrapper object.
- {{binding_class}}* wrapper =
- new (NotNull, JSC::allocateCell<{{binding_class}}>(global_data.heap))
- {{binding_class}}(
- &global_data,
- structure,
- global_object->script_object_registry(),
- make_scoped_refptr(impl_ptr));
- wrapper->finishCreation(global_data);
-{% if is_exception_interface %}
- global_data.heap.addFinalizer(wrapper, destroy);
-{% endif %}
- return wrapper;
-}
-{% endif %}
-{{binding_class}}::{{binding_class}}(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
-{% if is_global_interface %}
- scoped_ptr<script::javascriptcore::WrapperFactory> wrapper_factory,
- script::EnvironmentSettings* environment_settings,
-{% endif %}
- const scoped_refptr<{{impl_class}}>& impl)
- : BaseClass(global_data, structure, script_object_registry, impl{% if is_global_interface %},
- wrapper_factory.Pass(), environment_settings{% endif %}) {
-{% if get_opaque_root %}
- set_get_opaque_root_function(base::Bind(&GetOpaqueRootFromWrappable));
-{% endif %}
-}
-
-void {{binding_class}}::finishCreation(JSC::JSGlobalData& global_data) {
-{% if is_exception_interface %}
- WTF::String error_message = ToWTFString(wrappable()->message());
- BaseClass::finishCreation(global_data, error_message);
-{% else %}
- BaseClass::finishCreation(global_data);
-{% endif %}
- DCHECK(inherits(&s_info));
-}
-
-{{binding_class}}::~{{binding_class}}() {
- // Empty destructor
-}
-{% if add_opaque_roots %}
-
-void {{binding_class}}::visitChildren(JSC::JSCell* cell, JSC::SlotVisitor& visitor) {
- WrapperBase<JSC::JSDestructibleObject, Wrappable>::visitChildren(
- cell, visitor);
-
- JSCGlobalObject* global_object = JSC::jsCast<JSCGlobalObject*>(
- JSC::jsCast<JSObject*>(cell)->globalObject());
-
- {{impl_class}}* impl = base::polymorphic_downcast<{{impl_class}}*>(
- JSC::jsCast<WrapperBase*>(cell)->wrappable().get());
-
-{% for opaque_root in add_opaque_roots %}
- Wrappable* opaque_root{{loop.index0}} = impl->{{opaque_root}}();
- if (opaque_root{{loop.index0}}) {
- visitor.addOpaqueRoot(opaque_root{{loop.index0}});
- }
-{% endfor %}
-}
-{% endif %}
-
-// Look up property slot for querying property values.
-bool {{binding_class}}::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- {{binding_class}}* this_object = JSC::jsCast<{{binding_class}}*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
-{% if is_global_interface %}
- // Global interface may have both operations and properties as own properties
- // so we cannot use getStaticValueSlot.
- bool found_property_slot = JSC::getStaticPropertySlot<{{binding_class}}, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-{% else %}
- bool found_property_slot = JSC::getStaticValueSlot<{{binding_class}}, BaseClass>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-{% endif %}
- if (s_has_named_getter || s_use_debug_missing_property_handler) {
- bool found_property_on_prototype_chain = false;
- if (!found_property_slot && cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- found_property_on_prototype_chain =
- prototype->hasProperty(exec, property_name);
- }
- }
- if (s_has_named_getter) {
- if (!found_property_slot && !found_property_on_prototype_chain) {
- if (QueryNamedProperty(this_object, exec, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- found_property_slot = true;
- }
- }
- }
- if (s_use_debug_missing_property_handler) {
- // The property was not found as an own-property, nor was it found on the
- // prototype chain, so set the missing property handler to be called
- // when getting this property value.
- if (!found_property_slot && !found_property_on_prototype_chain) {
- slot.setCustom(cell, &OnGetMissingProperty);
- found_property_slot = true;
- }
- }
- }
- return found_property_slot;
-}
-{% if indexed_property_getter or named_property_getter %}
-
-// static
-bool {{binding_class}}::getOwnPropertySlotByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::PropertySlot& slot) {
- {{impl_class}}* impl =
- GetWrappableOrSetException<{{impl_class}}>(exec_state, cell);
- if (!impl) {
- return false;
- }
-{% if indexed_property_getter %}
- if (index < impl->length()) {
- slot.setCustomIndex(cell, index, IndexedPropertyGetter);
- return true;
- }
-{% endif %}
- if (s_has_named_getter) {
- {{binding_class}}* this_object = JSC::jsCast<{{binding_class}}*>(cell);
- JSC::PropertyName property_name = JSC::Identifier::from(exec_state, index);
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property) {
- if (QueryNamedProperty(this_object, exec_state, property_name)) {
- slot.setCustom(cell, &NamedPropertyGetter);
- return true;
- }
- }
- }
- return Base::getOwnPropertySlotByIndex(cell, exec_state, index, slot);
-}
-
-void {{binding_class}}::getOwnPropertyNames(JSC::JSObject* object,
- JSC::ExecState* exec_state, JSC::PropertyNameArray& property_names,
- JSC::EnumerationMode mode) {
- {{impl_class}}* impl =
- GetWrappableOrSetException<{{impl_class}}>(exec_state, object);
- if (impl) {
-{% if indexed_property_getter %}
- for (uint32 i = 0; i < impl->length(); ++i) {
- property_names.add(JSC::Identifier::from(exec_state, i));
- }
-{% endif %}
-{% if named_property_getter %}
- JSCPropertyEnumerator enumerator(exec_state, &property_names);
- impl->EnumerateNamedProperties(&enumerator);
-{% endif %}
- Base::getOwnPropertyNames(object, exec_state, property_names, mode);
- }
-}
-{% endif %}
-
-// Look up property slot and put the |value|.
-void {{binding_class}}::put(JSC::JSCell* cell, JSC::ExecState* exec,
- JSC::PropertyName property_name, JSC::JSValue value,
- JSC::PutPropertySlot& slot) {
- {{binding_class}}* this_object = JSC::jsCast<{{binding_class}}*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- bool property_handled = false;
- if (s_has_named_setter || s_use_debug_missing_property_handler) {
- // Need to look up the property manually.
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec, property_name);
-
- if (s_has_named_setter) {
- // We didn't find the property on the object or prototype chain, so
- // set or create a new named property.
- if (!has_property) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- NamedPropertySetter(cell, exec, property_name, value);
- property_handled = true;
- }
- }
- if (s_use_debug_missing_property_handler) {
- if (!has_property && !property_handled) {
- property_handled = OnSetMissingProperty(cell, exec, property_name, value);
- }
- }
-{% if not is_global_interface and not parent_interface %}
-#ifdef __LB_SHELL__FORCE_LOGGING__
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-
- base::AutoLock lock(non_trivial_static_fields.Get().lock_);
- base::hash_set<std::string>& properties_warned_about =
- non_trivial_static_fields.Get().properties_warned_about;
-
- if (properties_warned_about.find(property_name_utf8) ==
- properties_warned_about.end()) {
- properties_warned_about.insert(property_name_utf8);
- WTF::String class_name = cell->className();
- DLOG_IF(WARNING, !has_property) << "Did not find property named " <<
- property_name_utf8 << " to set on wrapper for "
- << FromWTFString(class_name)
- << std::endl << StackTraceToString(GetStackTrace(exec, 32))
- << std::endl;
- }
-#endif // __LB_SHELL__FORCE_LOGGING__
-{% endif %}
- }
-
- if (!property_handled) {
- JSC::lookupPut<{{binding_class}}, BaseClass>(
- exec, property_name, value, GetPropertyTable(exec), this_object, slot);
- }
-}
-{% if indexed_property_setter or named_property_setter %}
-
-// static
-void {{binding_class}}::putByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::JSValue value,
- bool should_throw) {
- {{impl_class}}* impl =
- GetWrappableOrSetException<{{impl_class}}>(exec_state, cell);
- if (impl) {
- bool property_handled = false;
-{% if indexed_property_setter %}
- if (index < impl->length()) {
- IndexedPropertySetter(cell, exec_state, index, value);
- property_handled = true;
- }
-{% endif %}
- if (s_has_named_setter) {
- if (!property_handled) {
- JSC::PropertyName property_name = JSC::Identifier::from(exec_state, index);
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property) {
- NamedPropertySetter(cell, exec_state, property_name, value);
- property_handled = true;
- }
- }
- }
- if (!property_handled) {
- Base::putByIndex(cell, exec_state, index, value, should_throw);
- }
- }
-}
-
-{% endif %}
-{% if supports_named_properties %}
-
-bool {{binding_class}}::deleteProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- TRACE_EVENT1("{{binding_class}}", "deleteProperty", "property",
- TRACE_STR_COPY(WTF::String(property_name.publicName()).utf8().data()));
- {{impl_class}}* impl =
- GetWrappableOrSetException<{{impl_class}}>(exec_state, cell);
- if (impl) {
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property &&
- QueryNamedProperty(cell, exec_state, property_name)) {
- return NamedPropertyDeleter(cell, exec_state, property_name);
- }
- return Base::deleteProperty(cell, exec_state, property_name);
- }
- return false;
-}
-{% endif %}
-{% if supports_named_properties or supports_indexed_properties %}
-
-bool {{binding_class}}::deletePropertyByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state,
- uint32_t index) {
- TRACE_EVENT0("{{binding_class}}", "deletePropertyByIndex");
- {{impl_class}}* impl =
- GetWrappableOrSetException<{{impl_class}}>(exec_state, cell);
- if (impl) {
-{% if supports_indexed_properties %}
- // https://heycam.github.io/webidl/#delete
- // Return true if index is not a supported property index.
- return index >= impl->length();
-{% elif supports_named_properties %}
- JSC::PropertyName property_name = JSC::Identifier::from(exec_state, index);
- bool has_property = HasOwnPropertyOrPrototypeProperty(
- cell, exec_state, property_name);
- if (!has_property &&
- QueryNamedProperty(cell, exec_state, property_name)) {
- return NamedPropertyDeleter(cell, exec_state, property_name);
- }
- return Base::deletePropertyByIndex(cell, exec_state, index);
-{% endif %}
- }
- return false;
-}
-{% endif %}
-
-bool {{binding_class}}::HasOwnPropertyOrPrototypeProperty(
- JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- {{binding_class}}* this_object = JSC::jsCast<{{binding_class}}*>(cell);
- JSC::PropertySlot lookup_slot;
- bool has_property = JSC::getStaticPropertySlot<{{binding_class}}, BaseClass>(
- exec_state, GetPropertyTable(exec_state), this_object, property_name,
- lookup_slot);
- return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
-}
-
-namespace {
-{% for constant in constants %}
-
-JSC::JSValue getJS{{constant.idl_name}}(
- JSC::ExecState* exec_state, JSC::JSValue, JSC::PropertyName) {
- TRACE_EVENT0("{{binding_class}}", "get {{constant.idl_name}}");
-{% if constant.can_use_compile_assert %}
- COMPILE_ASSERT({{impl_class}}::{{constant.name}} == {{constant.value}},
- ValueFor{{impl_class}}_{{constant.name}}DoesNotMatchIDL);
-{% else %}
- DCHECK_EQ({{constant.value}}, {{impl_class}}::{{constant.name}}) <<
- "The value for {{impl_class}}::{{constant.name}} does not match "
- "the value in the interface definition.";
-{% endif %}
- // JSCGlobalObject* is only needed for non-primitive types.
- return ToJSValue(NULL, {{constant.value}});
-}
-{% endfor %}
-{% for attribute in attributes + static_attributes %}
-
-{% if attribute.conditional %}
-#if defined({{attribute.conditional}})
-{% endif %}
-JSC::JSValue getJS{{attribute.idl_name}}(
- JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name) {
- TRACE_EVENT0("{{binding_class}}", "get {{attribute.idl_name}}");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
-{% if not attribute.is_static %}
- {{impl_class}}* impl =
- GetWrappableOrSetException<{{impl_class}}>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
-{% endif %}
-{% if attribute.raises_exception %}
- JSCExceptionState exception_state(global_object);
-{% endif %}
-
-{% if attribute.is_named_constructor_attribute %}
- JSC::JSObject* constructor_object =
- JSC{{attribute.interface_name}}::GetNamedConstructor(
- global_object->globalExec());
- DCHECK(constructor_object)
- << "NULL constructor returned for {{attribute.interface_name}}.";
- return JSC::JSValue(constructor_object);
-{% elif attribute.is_constructor_attribute %}
- JSC::JSObject* constructor_object =
- JSC{{attribute.interface_name}}::GetConstructor(
- global_object->globalExec());
- DCHECK(constructor_object)
- << "NULL constructor returned for {{attribute.interface_name}}.";
- return JSC::JSValue(constructor_object);
-{% else %}
-{% call(arguments_list) add_extra_arguments('global_object', [], attribute) %}
- JSC::JSValue result = ToJSValue(
- global_object,
- {{ call_function("impl", impl_class, attribute.getter_function_name, arguments_list, attribute.is_static) -}});
-{% if attribute.raises_exception %}
- if (exception_state.is_exception_set()) {
- return JSC::throwError(exec_state, exception_state.exception_object());
- }
-{% endif %}
- return result;
-{% endcall %}
-{% endif %}
-}
-{% if attribute.has_setter %}
-
-void setJS{{attribute.idl_name}}(
- JSC::ExecState* exec_state,
- JSC::JSObject* this_object,
- JSC::JSValue value) {
- TRACE_EVENT0("{{binding_class}}", "set {{attribute.idl_name}}");
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
-{% if not attribute.is_static %}
- {{impl_class}}* impl =
- GetWrappableOrSetException<{{impl_class}}>(exec_state, this_object);
- if (!impl) {
- return;
- }
-{% endif %}
-{{ set_attribute_implementation(attribute, impl_class, "impl") }}
-}
-{% endif %}
-{% if attribute.conditional %}
-#endif // defined({{attribute.conditional}})
-{% endif %}
-{% endfor %}
-{% if constructor %}
-
-JSC::EncodedJSValue constructorJS{{impl_class}}(JSC::ExecState* exec_state) {
-{% if constructor.overloads|length == 1 %}
-{{constructor_implementation(constructor.overloads[0])}}
-{% else %}
-{{overload_resolution_implementation(constructor, 'constructorJS' + impl_class)}}
-{% endif %}
-}
-{% for overload in constructor.overloads if constructor.overloads|length > 1 %}
-
-JSC::EncodedJSValue constructorJS{{impl_class}}{{overload.overload_index}}(JSC::ExecState* exec_state) {
-{{constructor_implementation(overload)}}
-}
-{% endfor %}
-{% endif %}
-{% for operation in operations + static_operations %}
-{% if operation.conditional %}
-#if defined({{operation.conditional}})
-{% endif %}
-
-{% set boundFunctionPrefix = "staticFunctionJS" if operation.is_static else "functionJS" %}
-JSC::EncodedJSValue {{boundFunctionPrefix}}{{operation.idl_name}}(
- JSC::ExecState* exec_state) {
- TRACE_EVENT0("{{binding_class}}", "call {{operation.idl_name}}");
-{% if operation.overloads|length == 1 %}
-{{function_implementation(operation.overloads[0])}}
-{% else %}
-{{overload_resolution_implementation(operation, boundFunctionPrefix + operation.idl_name)}}
-{% endif %}
-}
-{% for overload in operation.overloads if operation.overloads|length > 1 %}
-
-JSC::EncodedJSValue {{boundFunctionPrefix}}{{operation.idl_name}}{{overload.overload_index}}(
- JSC::ExecState* exec_state) {
-{{function_implementation(overload)}}
-}
-{% endfor %}
-{% if operation.conditional %}
-#endif // defined({{operation.conditional}})
-{% endif %}
-{% endfor %}
-{% if indexed_property_getter %}
-
-JSC::JSValue IndexedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, uint32_t index) {
- TRACE_EVENT0("{{binding_class}}", "IndexedPropertyGetter");
- {{impl_class}}* impl =
- GetWrappableOrSetException<{{impl_class}}>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
-{% call(arguments_list)
- add_extra_arguments('global_object', ['index'], indexed_property_getter) %}
- JSC::JSValue result = ToJSValue(
- global_object,
- {{ call_function("impl", impl_class, indexed_property_getter.name,
- arguments_list, False) -}});
-{% if indexed_property_getter.raises_exception %}
- if (exception_state.is_exception_set()) {
- return JSC::throwError(exec_state, exception_state.exception_object());
- }
-{% endif %}
- return result;
-{% endcall %}
-}
-{% endif %}
-{% if indexed_property_setter %}
-
-void IndexedPropertySetter(JSC::JSCell* cell,
- JSC::ExecState* exec_state, uint32_t index, JSC::JSValue jsc_value) {
- TRACE_EVENT0("{{binding_class}}", "IndexedPropertySetter");
- {{impl_class}}* impl =
- GetWrappableOrSetException<{{impl_class}}>(exec_state, cell);
- if (!impl) {
- return;
- }
-
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- {{indexed_property_setter.type}} value;
- FromJSValue(exec_state, jsc_value,
- {{indexed_property_setter.conversion_flags}},
- &exception_state, &value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
-{% call(arguments_list) add_extra_arguments(
- 'global_object', ['index', 'value'], indexed_property_setter) %}
- {{ call_function("impl", impl_class, indexed_property_setter.name,
- arguments_list, False) -}};
-{% if indexed_property_setter.raises_exception %}
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- }
-{% endif %}
-{% endcall %}
-}
-{% endif %}
-{% if named_property_getter %}
-
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- TRACE_EVENT0("{{binding_class}}", "NamedPropertyGetter");
- {{impl_class}}* impl =
- GetWrappableOrSetException<{{impl_class}}>(exec_state, slot_base);
- if (!impl) {
- return exec_state->exception();
- }
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
-{% call(arguments_list) add_extra_arguments('global_object', ['property_name_utf8'], named_property_getter) %}
- JSC::JSValue result = ToJSValue(
- global_object,
- {{ call_function("impl", impl_class, named_property_getter.name, arguments_list, False) -}});
-{% if named_property_getter.raises_exception %}
- if (exception_state.is_exception_set()) {
- return JSC::throwError(exec_state, exception_state.exception_object());
- }
-{% endif %}
- return result;
-{% endcall %}
-}
-
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- {{impl_class}}* impl =
- GetWrappableOrSetException<{{impl_class}}>(exec_state, cell);
- if (!impl) {
- return false;
- }
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- return impl->CanQueryNamedProperty(property_name_utf8);
-}
-{% else %}
-JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
- NOTREACHED();
- return false;
-}
-{% endif %}
-{% if named_property_setter %}
-
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- TRACE_EVENT0("{{binding_class}}", "NamedPropertySetter");
- {{impl_class}}* impl =
- GetWrappableOrSetException<{{impl_class}}>(exec_state, cell);
- if (!impl) {
- return;
- }
-
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
-
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- {{named_property_setter.type}} value;
- FromJSValue(exec_state, jsc_value,
- {{named_property_setter.conversion_flags}},
- &exception_state, &value);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
-{% call(arguments_list) add_extra_arguments(
- 'global_object', ['property_name_utf8', 'value'], named_property_setter) %}
- {{ call_function(
- "impl", impl_class, named_property_setter.name, arguments_list, False) -}};
-{% if named_property_setter.raises_exception %}
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- }
-{% endif %}
-{% endcall %}
-}
-{% else %}
-void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue jsc_value) {
- NOTREACHED();
-}
-{% endif %}
-
-bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name) {
-{% if named_property_deleter %}
- {{impl_class}}* impl =
- GetWrappableOrSetException<{{impl_class}}>(exec_state, cell);
- if (impl) {
- std::string property_name_utf8 = FromWTFString(property_name.publicName());
- impl->{{named_property_deleter.name}}(property_name_utf8);
- return true;
- }
-{% endif %}
- return false;
-}
-{% if stringifier %}
-
-JSC::EncodedJSValue StringifierJS(JSC::ExecState* exec_state) {
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- {{impl_class}}* impl =
- GetWrappableOrSetException<{{impl_class}}>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
-
- JSC::JSValue result = ToJSValue(global_object, impl->{{stringifier.name}}());
- return JSC::JSValue::encode(result);
-}
-{% endif %}
-
-#if !defined(COBALT_BUILD_TYPE_GOLD)
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onGetMissingProperty exists, so call this and
- // return the result as the value for this property.
- JSC::MarkedArgumentBuffer args;
- args.append(slot_base);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval;
- }
- }
- return JSC::jsUndefined();
-}
-
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSC::JSValue callable = global_object->get(
- exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
- if (!callable.isUndefined()) {
- JSC::CallData call_data;
- JSC::CallType call_type = JSC::getCallData(callable, call_data);
- if (call_type != JSC::CallTypeNone) {
- // The function called __onSetMissingProperty exists, so call this with
- // the value to be set. The missing property handler returns true if it
- // has handled the setting of this property.
- JSC::MarkedArgumentBuffer args;
- args.append(cell);
- args.append(JSC::JSValue(
- JSC::JSString::create(
- global_object->globalData(), property_name.publicName())));
- args.append(value);
- JSC::JSValue retval = JSC::call(
- exec_state, callable, call_type, call_data, global_object, args);
- return retval.toBoolean(exec_state);
- }
- }
- return false;
-}
-#else
-JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
- JSC::JSValue slot_base, JSC::PropertyName property_name) {
- NOTREACHED();
- return JSC::jsUndefined();
-}
-bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
- JSC::PropertyName property_name, JSC::JSValue value) {
- NOTREACHED();
- return false;
-}
-#endif
-} // namespace
-{% endblock implementation %}
-
-{% block create_global_object_impl %}
- JSCGlobalEnvironment* jsc_global_environment =
- base::polymorphic_downcast<JSCGlobalEnvironment*>(this);
- JSCEngine* jsc_engine = jsc_global_environment->engine();
-
- JSCGlobalObject* global_object = {{binding_class}}::Create(
- global_interface, environment_settings,
- jsc_engine->global_data(), jsc_engine->script_object_registry());
- jsc_global_environment->SetGlobalObject(global_object);
-{% endblock create_global_object_impl %}
-
-{% block enumeration_definitions %}
-{% for enumeration in enumerations %}
-JSC::JSValue ToJSValue(JSCGlobalObject* global_object, {{impl_class}}::{{enumeration.name}} in_enum) {
- JSC::JSGlobalData* global_data = &(global_object->globalData());
- switch (in_enum) {
-{% for value, idl_value in enumeration.value_pairs %}
- case {{impl_class}}::{{value}}: return JSC::jsString(global_data, "{{idl_value}}");
-{% endfor %}
- default:
- NOTREACHED();
- return JSC::jsUndefined();
- }
-}
-void FromJSValue(JSC::ExecState* exec_state, JSC::JSValue jsvalue,
- int conversion_flags, JSCExceptionState* exception_state,
- {{impl_class}}::{{enumeration.name}}* out_enum) {
- DCHECK_EQ(0, conversion_flags) << "Unexpected conversion flags.";
- // JSValue -> IDL enum algorithm described here:
- // http://heycam.github.io/webidl/#es-enumeration
-
- // 1. Let S be the result of calling ToString(V).
- JSC::JSString* js_string = jsvalue.toString(exec_state);
- if (exec_state->hadException()) {
- DLOG(WARNING) << "Exception converting value to string";
- return;
- }
- const WTF::String& wtf_string = js_string->tryGetValue();
- // 3. Return the enumeration value of type E that is equal to S.
-{% for value, idl_value in enumeration.value_pairs %}
- {{-" else " if not loop.first}}if (wtf_string == "{{idl_value}}") {
- *out_enum = {{impl_class}}::{{value}};
- }{% endfor %} else {
- // 2. If S is not one of E's enumeration values, then throw a TypeError.
- JSC::throwTypeError(exec_state);
- }
-}
-{% endfor %}
-{% endblock enumeration_definitions %}
diff --git a/src/cobalt/bindings/javascriptcore/templates/interface.h.template b/src/cobalt/bindings/javascriptcore/templates/interface.h.template
deleted file mode 100644
index 0fb76e8..0000000
--- a/src/cobalt/bindings/javascriptcore/templates/interface.h.template
+++ /dev/null
@@ -1,176 +0,0 @@
-{#
- # Copyright 2015 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.
- #}
-{% extends "interface-base.h.template" %}
-{% block includes %}
-{{ super() }}
-#include "base/threading/thread_local_storage.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-{% if is_exception_interface %}
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ErrorInstance.h"
-{% endif %}
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-{% endblock includes%}
-
-{% block implementation %}
-class {{binding_class}}
-{% if is_global_interface %}
- : public script::javascriptcore::JSCGlobalObject {
- typedef script::javascriptcore::JSCGlobalObject BaseClass;
-{% elif is_exception_interface %}
- : public script::javascriptcore::ExceptionBase {
- typedef script::javascriptcore::ExceptionBase BaseClass;
-{% elif parent_interface %}
- : public {{parent_interface}} {
- typedef {{parent_interface}} BaseClass;
-{% else %}
- : public script::javascriptcore::InterfaceBase {
- typedef script::javascriptcore::InterfaceBase BaseClass;
-{% endif %}
- public:
-
- // Get the prototype object for this wrapper class.
- static JSC::JSObject* GetPrototype(JSC::JSGlobalObject* global_object);
-{% if has_interface_object %}
-
- // Get the interface object for this wrapper class.
- static JSC::JSObject* GetConstructor(JSC::ExecState* exec_state);
-{% endif %}
-{% if named_constructor %}
-
- // Get the named constructor for this wrapper class.
- static JSC::JSObject* GetNamedConstructor(JSC::ExecState* exec_state);
-{% endif %}
-
- // JavaScriptCore functions and members
-
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-{% if indexed_property_getter or named_property_getter %}
-
- static bool getOwnPropertySlotByIndex(JSC::JSCell* cell,
- JSC::ExecState* exec_state,
- uint32_t index,
- JSC::PropertySlot& slot);
-
- static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*,
- JSC::PropertyNameArray&,
- JSC::EnumerationMode);
-{% endif %}
-{% if indexed_property_setter or named_property_setter %}
-
- static void putByIndex(JSC::JSCell* cell, JSC::ExecState* exec_state,
- uint32_t index, JSC::JSValue value, bool should_throw);
-{% endif %}
-
- // static override. Needed to support setting a property.
- static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName,
- JSC::JSValue, JSC::PutPropertySlot&);
-{% if supports_named_properties %}
-
- static bool deleteProperty(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName);
-{% endif %}
-{% if supports_indexed_properties or supports_named_properties %}
-
- static bool deletePropertyByIndex(JSC::JSCell*, JSC::ExecState*, uint32_t);
-{% endif %}
-
- // static override. This function will be called after a new object has
- // been created.
- void finishCreation(JSC::JSGlobalData& global_data);
-{% if not is_global_interface %}
-
- static script::javascriptcore::WrapperFactory::CreateWrapperFunction
- GetCreateWrapperFunction() {
- return base::Bind(&Create);
- }
-
- private:
- // Create a new wrapper for |wrappable|, which will be cast to {{impl_class}}.
- static JSC::JSObject* Create(
- script::javascriptcore::JSCGlobalObject* global_object,
- const scoped_refptr<script::Wrappable>& wrappable);
-{% else %}
-
- static script::javascriptcore::JSCGlobalObject* Create(
- const scoped_refptr<{{impl_class}}>& global_interface,
- script::EnvironmentSettings* environment_settings,
- JSC::JSGlobalData* global_data,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry);
-{% endif %}
-
- protected:
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- {{binding_class}}(
- JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- script::javascriptcore::ScriptObjectRegistry* script_object_registry,
-{% if is_global_interface %}
- scoped_ptr<script::javascriptcore::WrapperFactory> wrapper_factory,
- script::EnvironmentSettings* environment_settings,
-{% endif %}
- const scoped_refptr<{{impl_class}}>& impl);
- ~{{binding_class}}();
- {% if add_opaque_roots %}
-
- static void visitChildren(JSC::JSCell* cell, JSC::SlotVisitor& visitor);
- {% endif %}
-
- private:
-{% if has_interface_object %}
- class InterfaceObject;
-{% endif %}
-{% if named_constructor %}
- class NamedInterfaceObject;
-{% endif %}
- class Prototype;
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
- static base::LazyInstance<
- cobalt::script::javascriptcore::ThreadLocalHashTable>
- thread_local_property_table;
-
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static bool HasOwnPropertyOrPrototypeProperty(JSC::JSCell* cell,
- JSC::ExecState* exec_state, JSC::PropertyName property_name);
-
-#ifdef __LB_SHELL__FORCE_LOGGING__
- struct NonTrivialStaticFields {
- // TODO: Only log attempts of usage of unsupported Web APIs.
- base::hash_set<std::string> properties_warned_about;
- base::Lock lock_;
- };
- static base::LazyInstance<NonTrivialStaticFields> non_trivial_static_fields;
-#endif // __LB_SHELL__FORCE_LOGGING__
-};
-{% endblock implementation %}
diff --git a/src/cobalt/bindings/javascriptcore/templates/macros.cc.template b/src/cobalt/bindings/javascriptcore/templates/macros.cc.template
deleted file mode 100644
index a3a20fe..0000000
--- a/src/cobalt/bindings/javascriptcore/templates/macros.cc.template
+++ /dev/null
@@ -1,325 +0,0 @@
-{#
- # Extract and marshal arguments that will be passed to a function-like call.
- # Parameters:
- # operation: An IdlOperation object
- # Passed to caller:
- # A string that can be used as the parameters for a function call. It will
- # be either empty, or a comma-separated list of variable names.
- #}
-{% macro extract_arguments(operation) %}
-{% set non_optional_arguments = operation.arguments|rejectattr('is_optional')|rejectattr('is_variadic')|list %}
-{% set optional_arguments = operation.arguments|selectattr('is_optional')|list %}
-{% set num_default_arguments = optional_arguments|rejectattr('default_value', 'none')|list|length %}
-{% set variadic_argument = operation.arguments|last if (operation.arguments|length > 0) and (operation.arguments|last).is_variadic %}
-{% set has_non_default_optional_arguments = optional_arguments|length > num_default_arguments %}
-
-{%- if non_optional_arguments|length > 0 %}
- const size_t kMinArguments = {{non_optional_arguments|length}};
- if (exec_state->argumentCount() < kMinArguments) {
- return JSC::throwVMNotEnoughArgumentsError(exec_state);
- }
-{% endif -%}
-
-{# Declare variables for all arguments #}
-{% for argument in non_optional_arguments %}
-{% if loop.first %}
- // Non-optional arguments
-{% endif %}
- TypeTraits<{{argument.type}} >::ConversionType {{argument.name}};
-{% endfor %}
-{% for argument in optional_arguments if argument.default_value %}
-{% if loop.first %}
- // Optional arguments with default values
-{% endif %}
- TypeTraits<{{argument.type}} >::ConversionType {{argument.name}} =
- {{argument.default_value}};
-{% endfor %}
-{% for argument in optional_arguments if not argument.default_value %}
-{% if loop.first %}
- // Optional arguments
-{% endif %}
- TypeTraits<{{argument.type}} >::ConversionType {{argument.name}};
-{% endfor %}
-{% if variadic_argument %}
- // Variadic argument
- TypeTraits<{{variadic_argument.type}} >::ConversionType {{variadic_argument.name}};
-{% endif -%}
-
-{% for argument in non_optional_arguments %}
-
- DCHECK_LT({{loop.index0}}, exec_state->argumentCount());
- FromJSValue(exec_state,
- exec_state->argument({{loop.index0}}),
- {{argument.conversion_flags}},
- &exception_state, &{{argument.name}});
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
-{% endfor -%}
-{% for argument in optional_arguments %}
-{% if loop.first %}
-
- size_t num_set_arguments = {{non_optional_arguments|length + num_default_arguments}};
-{% endif %}
- if (exec_state->argumentCount() > {{loop.index0 + non_optional_arguments|length}}) {
- FromJSValue(exec_state,
- exec_state->argument({{loop.index0 + non_optional_arguments|length}}),
- {{argument.conversion_flags}},
- &exception_state,
- &{{argument.name}});
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
-{% if not argument.default_value %}
- ++num_set_arguments;
-{% endif %}
- }
-{% endfor %}
-{% if variadic_argument %}
-
- // Get variadic arguments.
-{% if optional_arguments|length %}
- const size_t kLastOptionalArgIndex = {{non_optional_arguments|length + optional_arguments|length}};
- if (num_set_arguments == kLastOptionalArgIndex) {
- // If the last optional argument has been set, we will call the overload
- // that takes the variadic argument, possibly with an empty vector in the
- // case that there are no more arguments left.
- ++num_set_arguments;
- }
-{% endif %}
- const size_t kFirstVariadicArgIndex = {{operation.arguments|length - 1}};
- if (exec_state->argumentCount() > kFirstVariadicArgIndex) {
- {{variadic_argument.name}}.resize(exec_state->argumentCount() - kFirstVariadicArgIndex);
- for (int i = 0; i + kFirstVariadicArgIndex < exec_state->argumentCount(); ++i) {
- FromJSValue(exec_state,
- exec_state->argument(i + kFirstVariadicArgIndex),
- {{variadic_argument.conversion_flags}},
- &exception_state,
- &{{variadic_argument.name}}[i]);
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
- }
- }
-{% endif -%}
-
-{# Call the implementation function, based on the number of set arguments. #}
-{% if has_non_default_optional_arguments %}
- switch (num_set_arguments) {
-{% for num_arguments in range(non_optional_arguments|length + num_default_arguments, operation.arguments|length + 1) %}
-{# If no variadic arguments have been set, we still call the function with
- signature that has the variadic argument and pass an empty vector. There is
- no such function signature that takes the optional parameter immediately
- preceeding the variadic argument but does not take the variadic arguments. #}
-{% if loop.last or not operation.arguments[num_arguments].is_variadic %}
-{% set function_arguments = operation.arguments[0:num_arguments]|map(attribute='name')|list %}
- case {{num_arguments}}:
- {
- {# whitespace control block #}
- {{-caller(function_arguments)|indent(8, True)}}
- break;
- }
-{% endif %}
-{% endfor %}
- default:
- NOTREACHED();
- return JSC::JSValue::encode(JSC::jsUndefined());
- }
-{% else %} {#- has_non_default_optional_arguments #}
-{% set function_arguments = operation.arguments|map(attribute='name')|list %}
- {# whitespace control block #}
- {{-caller(function_arguments)|indent(2, True)}}
-{% endif %}
-{% endmacro %}
-
-{#
- # Append extra arguments that should be passed to a cobalt function.
- # Specifically, this will prepend parameters specified on IDLs using the
- # [CallWith=] extended attribute.
- # Parameters:
- # global_object: A C++ expression to retrieve a JSCGlobalObject pointer.
- # arguments_list: A list of C++ expressions that represent a sequence of
- # arguments that will be passed to a function.
- # idl_object: An IDL object that may have the extended attribute that
- # we are interested in.
- # is_constructor: True if we are extracting the extended attribute for
- # a constructor.
- # Passed to caller:
- # arguments_list, possibly with extra arguments prepended.
- #}
-{% macro add_extra_arguments(global_object, arguments_list, context) %}
-{% set prepend = [] %}
-{% set append = [] %}
-{% if context.call_with %}
-{% set prepend = ['%s->Get%s()'|format(global_object, context.call_with)] %}
-{% endif %}
-{% if context.raises_exception %}
-{% set append = ['&exception_state'] %}
-{% endif %}
-{{caller(prepend + arguments_list + append)}}
-{%- endmacro %}
-
-{#
- # Create an expression to call a member function, which might be static,
- # with the given arguments.
- # Parameters:
- # this_object: A string that is the name of a C++ variable that is a
- # pointer to an instance of the implementation class.
- # class_name: A string that is the name of the C++ implementation class.
- # function_name: A string that is the name of the function to be called.
- # arguments_list: A list of C++ expressions that represent a sequence of
- # arguments that will be passed to a function.
- # is_static: True if the method is static.
- #}
-{% macro call_function(this_object, class_name, function_name, arguments_list, is_static) %}
-{% if is_static %}
-{{class_name}}::{{function_name}}({{arguments_list|join(', ')}})
-{%- else %}
-{{this_object}}->{{function_name}}({{arguments_list|join(', ')}})
-{%- endif %}
-{%- endmacro %}
-
-{#
- # Function body for operation bindings.
- # Parameters:
- # operation: The operation context object
- #}
-{% macro function_implementation(operation) %}
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
-{% if not operation.is_static %}
- JSC::JSObject* this_object =
- exec_state->hostThisValue().toThisObject(exec_state);
- {{impl_class}}* impl =
- GetWrappableOrSetException<{{impl_class}}>(exec_state, this_object);
- if (!impl) {
- return JSC::JSValue::encode(exec_state->exception());
- }
-{% endif %}
-
-{% call(arguments_list) extract_arguments(operation) %}
-{% call(arguments_list) add_extra_arguments('global_object', arguments_list, operation) %}
-{{ 'TypeTraits<%s >::ReturnType return_value = '|format(operation.type) if operation.type != 'void'}}
-{{- call_function("impl", impl_class, operation.name, arguments_list, operation.is_static) -}};
-{% if operation.raises_exception %}
-if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
-}
-{% endif %}
-return JSC::JSValue::encode({{'ToJSValue(global_object, return_value)' if operation.type != 'void' else 'JSC::jsUndefined()'}});
-{% endcall %}
-{% endcall %}
-{%- endmacro %}
-
-{#
- # Function body for constructor bindings.
- # Parameters:
- # operation: The constructor context object
- #}
-{% macro constructor_implementation(constructor) %}
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
-{% call(arguments_list) extract_arguments(constructor) %}
-{% call(arguments_list) add_extra_arguments('global_object', arguments_list, constructor) %}
- scoped_refptr<{{impl_class}}> new_object =
- new {{impl_class}}({{arguments_list|join(', ')}});
-{% if constructor.raises_exception %}
- if (exception_state.is_exception_set()) {
- return JSC::throwVMError(exec_state, exception_state.exception_object());
- }
-{% endif %}
- return JSC::JSValue::encode(ToJSValue(global_object, new_object));
-{% endcall %}
-{% endcall %}
-{%- endmacro %}
-
-{#
- # Function body for overload resolution function.
- # Parameters:
- # overload_context: The overload context object.
- # bound_function_prefix: The prefix of the function to be called on
- # resolution. The overload index will be appended to this.
- #}
-{% macro overload_resolution_implementation(overload_context, bound_function_prefix) %}
- const size_t num_arguments = exec_state->argumentCount();
- switch(num_arguments) {
-{% for length, distinguishing_argument_index, resolution_tests in overload_context.overload_resolution_by_length %}
- case({{length}}): {
- // Overload resolution algorithm details found here:
- // http://heycam.github.io/webidl/#dfn-overload-resolution-algorithm
-{# In the case there is only one resolution condition, we don't need the arg. #}
-{% if resolution_tests|length > 1 %}
- JSC::JSValue arg = exec_state->argument({{distinguishing_argument_index}});
-{% endif %}
-{% for test, overload in resolution_tests %}
- if ({{test("arg")}}) {
- return {{bound_function_prefix}}{{overload.overload_index}}(exec_state);
- }
-{% endfor %}
- break;
- }
-{% endfor %}
- }
- // Invalid number of args
- // http://heycam.github.io/webidl/#dfn-overload-resolution-algorithm
- // 4. If S is empty, then throw a TypeError.
- return JSC::throwVMTypeError(exec_state);
-{%- endmacro %}
-
-{#
- # Function body for setting an attribute value.
- # Parameters:
- # attribute: The attribute context object.
- # impl_class: Cobalt class name of the Cobalt implementation of the
- # interface on which the attribute is a member.
- # cobalt_impl: Variable name of a pointer to a Cobalt implementation of the
- # interface on which the attribute is a member.
- #}
-{% macro set_attribute_implementation(attribute, impl_class, cobalt_impl) %}
-{% if attribute.is_constructor_attribute %}
- NOTIMPLEMENTED() << "Setting constructors not yet supported.";
-{% else %}
-{% if attribute.put_forwards %}
- {
- {{attribute.type}} forwarded_{{cobalt_impl}} =
- {{call_function(cobalt_impl, impl_class, attribute.getter_function_name,
- arguments_list, attribute.is_static)-}};
- if (!forwarded_{{cobalt_impl}}) {
- return;
- }
-{{ set_attribute_implementation(attribute.put_forwards, attribute.type,
- "forwarded_" + cobalt_impl) }}
- }
-{% else %} {#- if attribute.put_forwards #}
- TypeTraits<{{attribute.type}} >::ConversionType cobalt_value;
-{% if attribute.is_event_listener %}
- ToEventListenerAttribute(exec_state, value, {{attribute.conversion_flags}},
- &exception_state, this_object, &cobalt_value);
-{% else %}
- FromJSValue(exec_state, value,
- {{attribute.conversion_flags}}, &exception_state,
- &cobalt_value);
-{% endif %}
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return;
- }
-{% call(arguments_list) add_extra_arguments('global_object', ['cobalt_value'],
- attribute) %}
- // Check if argument conversion raised an exception.
- if (!exec_state->hadException()) {
- {{ call_function(cobalt_impl, impl_class, attribute.setter_function_name,
- arguments_list, attribute.is_static) -}};
-{% if attribute.raises_exception %}
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- }
-{% endif %}
- }
-{%- endcall %}
-{% endif %} {#- attribute.put_forwards #}
-{% endif %} {#- attribute.is_constructor_attribute #}
-{%- endmacro %}
-
diff --git a/src/cobalt/bindings/javascriptcore/templates/prototype-object.template b/src/cobalt/bindings/javascriptcore/templates/prototype-object.template
deleted file mode 100644
index 603493f..0000000
--- a/src/cobalt/bindings/javascriptcore/templates/prototype-object.template
+++ /dev/null
@@ -1,179 +0,0 @@
-{#
- # Copyright 2016 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.
- #}
-// Class that defines a JS Object representing this interface's prototype
-class {{binding_class}}::Prototype : public PrototypeBase {
- public:
- // Get the prototype. Will create a new prototype if necessary, otherwise it
- // will return a cached prototype.
- static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
- DECLARE_CLASSINFO();
-
- // Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
- // Must be public so that it can be accessible from getStaticValueSlot<>.
- static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
- JSC::PropertyName,
- JSC::PropertySlot&);
-
- private:
- typedef PrototypeBase BaseClass;
-
- static const unsigned StructureFlags =
- JSC::OverridesGetOwnPropertySlot |
- BaseClass::StructureFlags;
-
- Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : BaseClass(global_object, structure) { }
-
-{% if has_interface_object %}
- static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
- JSC::JSValue slot_base,
- JSC::PropertyName property_name);
-{% endif %}
- static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
-
- static const JSC::HashTableValue property_table_values[];
- static const JSC::HashTable property_table_prototype;
-};
-
-const JSC::HashTableValue {{binding_class}}::Prototype::property_table_values[] = {
-{% for operation in operations if not is_global_interface %}
-{% if operation.conditional %}
-#if defined({{operation.conditional}})
-{% endif %}
- { "{{operation.idl_name}}",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(functionJS{{operation.idl_name}}),
- static_cast<intptr_t>({{operation.length}}),
- JSC::NoIntrinsic
- },
-{% if operation.conditional %}
-#endif // defined({{operation.conditional}})
-{% endif %}
-{% endfor %}
-{% if stringifier %}
- { "toString",
- JSC::DontDelete | JSC::Function,
- reinterpret_cast<intptr_t>(StringifierJS),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
-{% endif %}
-{% for constant in constants %}
- { "{{constant.idl_name}}",
- JSC::DontDelete | JSC::ReadOnly,
- reinterpret_cast<intptr_t>(getJS{{constant.idl_name}}),
- 0,
- JSC::NoIntrinsic
- },
-{% endfor %}
-{% if has_interface_object %}
- { "constructor",
- JSC::DontDelete | JSC::DontEnum,
- reinterpret_cast<intptr_t>({{binding_class}}::Prototype::GetConstructor),
- static_cast<intptr_t>(0),
- JSC::NoIntrinsic
- },
-{% endif %}
- { 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
-}; // {{binding_class}}::Prototype::property_table_values
-
-// static
-const JSC::HashTable {{binding_class}}::Prototype::property_table_prototype = {
-{% set num_prototype_properties = constants|length %}
-{% if not is_global_interface %}
-{% set num_prototype_properties = num_prototype_properties + operations|length %}
-{% endif %}
-{% if has_interface_object %}
-{% set num_prototype_properties = num_prototype_properties + 1 %}
-{% endif %}
-{% if stringifier %}
-{% set num_prototype_properties = num_prototype_properties + 1 %}
-{% endif %}
- {{ calculate_jsc_lookup_size(num_prototype_properties) }}, // compactSize
- {{ calculate_jsc_lookup_size_mask(num_prototype_properties) }}, // compactSizeMask
- property_table_values,
- NULL // table allocated at runtime
-}; // {{binding_class}}::Prototype::property_table_prototype
-
-// static
-const JSC::HashTable* {{binding_class}}::Prototype::GetPropertyTable(
- JSC::ExecState* exec_state) {
- return ThreadLocalHashTable::GetInstance()->GetHashTable(
- {{binding_class}}::Prototype::s_classinfo(), property_table_prototype);
-}
-
-const JSC::ClassInfo {{binding_class}}::Prototype::s_info = {
- "{{interface_name}}Prototype", // className
- BaseClass::s_classinfo(), // parentClass
- NULL, // static hash-table of properties (not used)
- GetPropertyTable, // function pointer to get hash-table of properties
- CREATE_METHOD_TABLE({{binding_class}}::Prototype)
-}; // {{binding_class}}::Prototype::s_info
-
-// Look up property slot for querying property values.
-bool {{binding_class}}::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
- JSC::ExecState* exec, JSC::PropertyName property_name,
- JSC::PropertySlot& slot) {
- Prototype* this_object = JSC::jsCast<Prototype*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
- return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
- exec, GetPropertyTable(exec), this_object, property_name, slot);
-}
-
-// static
-JSC::JSObject* {{binding_class}}::Prototype::GetInstance(
- JSC::JSGlobalObject* base_global_object) {
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalObject*>(base_global_object);
- ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
-
- // Try to get the cached prototype, and create a new one if needed.
- JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
- if (prototype == NULL) {
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSLockHolder lock(&global_data);
-
-{% if parent_interface %}
- JSC::JSObject* parent_prototype =
- {{parent_interface}}::GetPrototype(global_object);
-{% elif is_exception_interface %}
- JSC::JSObject* parent_prototype = global_object->errorPrototype();
-{% else %}
- JSC::JSObject* parent_prototype = global_object->objectPrototype();
-{% endif %}
- JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
- JSC::Structure* structure = JSC::Structure::create(
- global_data,
- global_object,
- JSC::JSValue(parent_prototype),
- type_info,
- &s_info);
-
- // Create the new prototype object.
- Prototype* new_prototype =
- new (NotNull, JSC::allocateCell<Prototype>(
- global_data.heap))
- Prototype(global_object, structure);
- new_prototype->finishCreation(global_data);
- // Add the prototype to the cache.
- global_object->object_cache()->CachePrototype(&s_info, new_prototype);
- prototype = new_prototype;
- }
- DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
- return prototype;
-}
-
-// End of {{binding_class}}::Prototype class
diff --git a/src/cobalt/bindings/mozjs/templates/interface.cc.template b/src/cobalt/bindings/mozjs/templates/interface.cc.template
index 90ed015..06c23c3 100644
--- a/src/cobalt/bindings/mozjs/templates/interface.cc.template
+++ b/src/cobalt/bindings/mozjs/templates/interface.cc.template
@@ -27,11 +27,11 @@
{% block includes %}
{{ super() }}
#include "base/lazy_instance.h"
-#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/exception_state.h"
+#include "cobalt/script/mozjs/callback_function_conversion.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
-#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_callback_function.h"
+#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_global_environment.h"
#include "cobalt/script/mozjs/mozjs_object_handle.h"
#include "cobalt/script/mozjs/mozjs_property_enumerator.h"
@@ -53,24 +53,24 @@
using cobalt::script::CallbackFunction;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::ExceptionState;
+using cobalt::script::Wrappable;
using cobalt::script::mozjs::FromJSValue;
+using cobalt::script::mozjs::InterfaceData;
+using cobalt::script::mozjs::MozjsCallbackFunction;
+using cobalt::script::mozjs::MozjsExceptionState;
+using cobalt::script::mozjs::MozjsGlobalEnvironment;
+using cobalt::script::mozjs::MozjsPropertyEnumerator;
+using cobalt::script::mozjs::MozjsUserObjectHolder;
+using cobalt::script::mozjs::ProxyHandler;
+using cobalt::script::mozjs::ToJSValue;
+using cobalt::script::mozjs::TypeTraits;
+using cobalt::script::mozjs::WrapperFactory;
+using cobalt::script::mozjs::WrapperPrivate;
using cobalt::script::mozjs::kConversionFlagNullable;
using cobalt::script::mozjs::kConversionFlagRestricted;
using cobalt::script::mozjs::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::mozjs::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::mozjs::kNoConversionFlags;
-using cobalt::script::mozjs::InterfaceData;
-using cobalt::script::mozjs::MozjsCallbackFunction;
-using cobalt::script::mozjs::MozjsExceptionState;
-using cobalt::script::mozjs::MozjsGlobalEnvironment;
-using cobalt::script::mozjs::MozjsUserObjectHolder;
-using cobalt::script::mozjs::MozjsPropertyEnumerator;
-using cobalt::script::mozjs::ProxyHandler;
-using cobalt::script::mozjs::ToJSValue;
-using cobalt::script::mozjs::TypeTraits;
-using cobalt::script::mozjs::WrapperPrivate;
-using cobalt::script::mozjs::WrapperFactory;
-using cobalt::script::Wrappable;
{% endblock using_directives %}
{% block enumeration_declarations %}
{% if enumerations|length %}
@@ -945,6 +945,7 @@
{{binding_class}}::CreateProxy(
context, global_interface);
mozjs_global_environment->SetEnvironmentSettings(environment_settings);
+ mozjs_global_environment->EvaluateAutomatics();
WrapperFactory* wrapper_factory =
mozjs_global_environment->wrapper_factory();
diff --git a/src/cobalt/bindings/run_cobalt_bindings_tests.bat b/src/cobalt/bindings/run_cobalt_bindings_tests.bat
index e26fc8d..2df4a48 100644
--- a/src/cobalt/bindings/run_cobalt_bindings_tests.bat
+++ b/src/cobalt/bindings/run_cobalt_bindings_tests.bat
@@ -14,5 +14,4 @@
@rem limitations under the License.
@rem
-@python run_cobalt_bindings_tests.py jsc %*
@python run_cobalt_bindings_tests.py mozjs %*
diff --git a/src/cobalt/bindings/run_cobalt_bindings_tests.py b/src/cobalt/bindings/run_cobalt_bindings_tests.py
index 4aa69b8..a364191 100644
--- a/src/cobalt/bindings/run_cobalt_bindings_tests.py
+++ b/src/cobalt/bindings/run_cobalt_bindings_tests.py
@@ -37,7 +37,6 @@
# Add cobalt's bindings generation scripts to the path.
sys.path.append(cobalt_bindings_dir)
from idl_compiler_cobalt import IdlCompilerCobalt # pylint: disable=g-import-not-at-top
-from javascriptcore.code_generator import CodeGeneratorJsc
from mozjs.code_generator import CodeGeneratorMozjs
CodeGeneratorMozjs45 = __import__( # pylint: disable=invalid-name
'mozjs-45.code_generator').code_generator.CodeGeneratorMozjs
@@ -54,9 +53,7 @@
parser.add_argument('engine')
args = parser.parse_args(argv[1:])
- if args.engine.lower() == 'jsc':
- generator = CodeGeneratorJsc
- elif args.engine.lower() == 'mozjs':
+ if args.engine.lower() == 'mozjs':
generator = CodeGeneratorMozjs
elif args.engine.lower() == 'mozjs-45':
generator = CodeGeneratorMozjs45
diff --git a/src/cobalt/bindings/run_cobalt_bindings_tests.sh b/src/cobalt/bindings/run_cobalt_bindings_tests.sh
index 3cce2da..12ff255 100755
--- a/src/cobalt/bindings/run_cobalt_bindings_tests.sh
+++ b/src/cobalt/bindings/run_cobalt_bindings_tests.sh
@@ -19,6 +19,5 @@
# Ensure we are in the bindings directory.
cd "$(dirname "${BASH_SOURCE[0]}")"
-python run_cobalt_bindings_tests.py jsc "$@"
python run_cobalt_bindings_tests.py mozjs "$@"
python run_cobalt_bindings_tests.py mozjs-45 "$@"
diff --git a/src/cobalt/bindings/testing/global_constructors_idls_idl_files_list.tmp b/src/cobalt/bindings/testing/global_constructors_idls_idl_files_list.tmp
deleted file mode 100644
index bb7227e..0000000
--- a/src/cobalt/bindings/testing/global_constructors_idls_idl_files_list.tmp
+++ /dev/null
@@ -1,46 +0,0 @@
-AnonymousIndexedGetterInterface.idl
-AnonymousNamedGetterInterface.idl
-AnonymousNamedIndexedGetterInterface.idl
-ArbitraryInterface.idl
-BaseInterface.idl
-BooleanTypeTestInterface.idl
-CallbackFunctionInterface.idl
-CallbackInterfaceInterface.idl
-ConditionalInterface.idl
-ConstantsInterface.idl
-ConstructorInterface.idl
-ConstructorWithArgumentsInterface.idl
-DerivedGetterSetterInterface.idl
-DerivedInterface.idl
-DisabledInterface.idl
-DOMStringTestInterface.idl
-EnumerationInterface.idl
-ExceptionObjectInterface.idl
-ExceptionsInterface.idl
-ExtendedIDLAttributesInterface.idl
-GarbageCollectionTestInterface.idl
-GetOpaqueRootInterface.idl
-GlobalInterfaceParent.idl
-IndexedGetterInterface.idl
-InterfaceWithUnsupportedProperties.idl
-NamedConstructorInterface.idl
-NamedGetterInterface.idl
-NamedIndexedGetterInterface.idl
-NestedPutForwardsInterface.idl
-NoConstructorInterface.idl
-NoInterfaceObjectInterface.idl
-NullableTypesTestInterface.idl
-NumericTypesTestInterface.idl
-ObjectTypeBindingsInterface.idl
-OperationsTestInterface.idl
-PutForwardsInterface.idl
-SequenceUser.idl
-SingleOperationInterface.idl
-StaticPropertiesInterface.idl
-StringifierAnonymousOperationInterface.idl
-StringifierAttributeInterface.idl
-StringifierOperationInterface.idl
-TargetInterface.idl
-UnionTypesInterface.idl
-Window.idl
-UnsupportedInterface.idl
diff --git a/src/cobalt/bindings/testing/global_objects_idl_files_list.tmp b/src/cobalt/bindings/testing/global_objects_idl_files_list.tmp
deleted file mode 100644
index 3b0f3da..0000000
--- a/src/cobalt/bindings/testing/global_objects_idl_files_list.tmp
+++ /dev/null
@@ -1,45 +0,0 @@
-AnonymousIndexedGetterInterface.idl
-AnonymousNamedGetterInterface.idl
-AnonymousNamedIndexedGetterInterface.idl
-ArbitraryInterface.idl
-BaseInterface.idl
-BooleanTypeTestInterface.idl
-CallbackFunctionInterface.idl
-CallbackInterfaceInterface.idl
-ConditionalInterface.idl
-ConstantsInterface.idl
-ConstructorInterface.idl
-ConstructorWithArgumentsInterface.idl
-DerivedGetterSetterInterface.idl
-DerivedInterface.idl
-DisabledInterface.idl
-DOMStringTestInterface.idl
-EnumerationInterface.idl
-ExceptionObjectInterface.idl
-ExceptionsInterface.idl
-ExtendedIDLAttributesInterface.idl
-GarbageCollectionTestInterface.idl
-GetOpaqueRootInterface.idl
-GlobalInterfaceParent.idl
-IndexedGetterInterface.idl
-InterfaceWithUnsupportedProperties.idl
-NamedConstructorInterface.idl
-NamedGetterInterface.idl
-NamedIndexedGetterInterface.idl
-NestedPutForwardsInterface.idl
-NoConstructorInterface.idl
-NoInterfaceObjectInterface.idl
-NullableTypesTestInterface.idl
-NumericTypesTestInterface.idl
-ObjectTypeBindingsInterface.idl
-OperationsTestInterface.idl
-PutForwardsInterface.idl
-SequenceUser.idl
-SingleOperationInterface.idl
-StaticPropertiesInterface.idl
-StringifierAnonymousOperationInterface.idl
-StringifierAttributeInterface.idl
-StringifierOperationInterface.idl
-TargetInterface.idl
-UnionTypesInterface.idl
-Window.idl
diff --git a/src/cobalt/bindings/testing/interfaces_info_individual_static_idl_files_list.tmp b/src/cobalt/bindings/testing/interfaces_info_individual_static_idl_files_list.tmp
deleted file mode 100644
index ea6cdb9..0000000
--- a/src/cobalt/bindings/testing/interfaces_info_individual_static_idl_files_list.tmp
+++ /dev/null
@@ -1,49 +0,0 @@
-AnonymousIndexedGetterInterface.idl
-AnonymousNamedGetterInterface.idl
-AnonymousNamedIndexedGetterInterface.idl
-ArbitraryInterface.idl
-BaseInterface.idl
-BooleanTypeTestInterface.idl
-CallbackFunctionInterface.idl
-CallbackInterfaceInterface.idl
-ConditionalInterface.idl
-ConstantsInterface.idl
-ConstructorInterface.idl
-ConstructorWithArgumentsInterface.idl
-DerivedGetterSetterInterface.idl
-DerivedInterface.idl
-DisabledInterface.idl
-DOMStringTestInterface.idl
-EnumerationInterface.idl
-ExceptionObjectInterface.idl
-ExceptionsInterface.idl
-ExtendedIDLAttributesInterface.idl
-GarbageCollectionTestInterface.idl
-GetOpaqueRootInterface.idl
-GlobalInterfaceParent.idl
-IndexedGetterInterface.idl
-InterfaceWithUnsupportedProperties.idl
-NamedConstructorInterface.idl
-NamedGetterInterface.idl
-NamedIndexedGetterInterface.idl
-NestedPutForwardsInterface.idl
-NoConstructorInterface.idl
-NoInterfaceObjectInterface.idl
-NullableTypesTestInterface.idl
-NumericTypesTestInterface.idl
-ObjectTypeBindingsInterface.idl
-OperationsTestInterface.idl
-PutForwardsInterface.idl
-SequenceUser.idl
-SingleOperationInterface.idl
-StaticPropertiesInterface.idl
-StringifierAnonymousOperationInterface.idl
-StringifierAttributeInterface.idl
-StringifierOperationInterface.idl
-TargetInterface.idl
-UnionTypesInterface.idl
-Window.idl
-ImplementedInterface.idl
-PartialInterface.idl
-InterfaceWithUnsupportedProperties_partial.idl
-UnsupportedInterface.idl
diff --git a/src/cobalt/browser/application.cc b/src/cobalt/browser/application.cc
index 765ee14..0f6eb18 100644
--- a/src/cobalt/browser/application.cc
+++ b/src/cobalt/browser/application.cc
@@ -260,7 +260,9 @@
const char kYouTubeTvLocationPolicy[] =
"h5vcc-location-src "
"https://www.youtube.com/tv "
+ "https://www.youtube.com/tv/ "
"https://web-release-qa.youtube.com/tv "
+ "https://web-release-qa.youtube.com/tv/ "
#if defined(ENABLE_ABOUT_SCHEME)
"about: "
#endif
diff --git a/src/cobalt/browser/browser.gyp b/src/cobalt/browser/browser.gyp
index c544756..755d85f 100644
--- a/src/cobalt/browser/browser.gyp
+++ b/src/cobalt/browser/browser.gyp
@@ -58,6 +58,7 @@
'COBALT_IMAGE_CACHE_SIZE_IN_BYTES=<(image_cache_size_in_bytes)',
'COBALT_REMOTE_TYPEFACE_CACHE_SIZE_IN_BYTES=<(remote_typeface_cache_size_in_bytes)',
'COBALT_IMAGE_CACHE_CAPACITY_MULTIPLIER_WHEN_PLAYING_VIDEO=<(image_cache_capacity_multiplier_when_playing_video)',
+ 'COBALT_MESH_CACHE_SIZE_IN_BYTES=<(mesh_cache_size_in_bytes)',
],
'dependencies': [
'<(DEPTH)/cobalt/accessibility/accessibility.gyp:accessibility',
diff --git a/src/cobalt/browser/browser_bindings.gyp b/src/cobalt/browser/browser_bindings.gyp
index 5d6e627..802b803 100644
--- a/src/cobalt/browser/browser_bindings.gyp
+++ b/src/cobalt/browser/browser_bindings.gyp
@@ -163,6 +163,7 @@
'../h5vcc/H5vccSettings.idl',
'../h5vcc/H5vccStorage.idl',
'../h5vcc/H5vccSystem.idl',
+ '../h5vcc/H5vccTraceEvent.idl',
'../speech/SpeechRecognition.idl',
'../speech/SpeechRecognitionAlternative.idl',
diff --git a/src/cobalt/browser/browser_module.cc b/src/cobalt/browser/browser_module.cc
index d14f425..1bcdc3c 100644
--- a/src/cobalt/browser/browser_module.cc
+++ b/src/cobalt/browser/browser_module.cc
@@ -514,7 +514,7 @@
}
#if defined(ENABLE_DEBUG_CONSOLE)
- trace_manager.OnKeyEventProduced();
+ trace_manager_.OnKeyEventProduced();
#endif // defined(ENABLE_DEBUG_CONSOLE)
InjectKeyEventToMainWebModule(event);
@@ -642,6 +642,9 @@
FROM_HERE, base::Bind(&base::WaitableEvent::Signal,
base::Unretained(&got_window_driver)));
got_window_driver.Wait();
+ // This log is relied on by the webdriver benchmark tests, so it shouldn't be
+ // changed unless the corresponding benchmark logic is changed as well.
+ LOG(INFO) << "Created WindowDriver: ID=" << window_id.id();
DCHECK(window_driver);
return window_driver.Pass();
}
diff --git a/src/cobalt/browser/browser_module.h b/src/cobalt/browser/browser_module.h
index 82322b3..e275d55 100644
--- a/src/cobalt/browser/browser_module.h
+++ b/src/cobalt/browser/browser_module.h
@@ -299,7 +299,7 @@
// Manages a second web module to implement the debug console.
scoped_ptr<DebugConsole> debug_console_;
- TraceManager trace_manager;
+ TraceManager trace_manager_;
// Command handler object for toggling the input fuzzer on/off.
base::ConsoleCommandManager::CommandHandler fuzzer_toggle_command_handler_;
diff --git a/src/cobalt/browser/debug_console/debug_console.js b/src/cobalt/browser/debug_console/debug_console.js
index 7c2f8a5..6f56962 100644
--- a/src/cobalt/browser/debug_console/debug_console.js
+++ b/src/cobalt/browser/debug_console/debug_console.js
@@ -32,6 +32,44 @@
// Number of animation frame samples since the last update.
var animationFrameSamples = 0;
+// Map of 'Unidentified' additional Cobalt keyCodes to equivalent keys.
+var unidentifiedCobaltKeyMap = {
+ // kSbKeyGamepad1
+ 0x8000: 'Enter',
+ // kSbKeyGamepad2
+ 0x8001: 'Esc',
+ // kSbKeyGamepad3
+ 0x8002: 'Home',
+ // kSbKeyGamepad5
+ 0x8008: 'Enter',
+ // kSbKeyGamepad6
+ 0x8009: 'Enter',
+ // kSbKeyGamepadDPadUp
+ 0x800C: 'ArrowUp',
+ // kSbKeyGamepadDPadDown
+ 0x800D: 'ArrowDown',
+ // kSbKeyGamepadDPadLeft
+ 0x800E: 'ArrowLeft',
+ // kSbKeyGamepadDPadRight
+ 0x800F: 'ArrowRight',
+ // kSbKeyGamepadLeftStickUp
+ 0x8011: 'ArrowUp',
+ // kSbKeyGamepadLeftStickDown
+ 0x8012: 'ArrowDown',
+ // kSbKeyGamepadLeftStickLeft
+ 0x8013: 'ArrowLeft',
+ // kSbKeyGamepadLeftStickRight
+ 0x8014: 'ArrowRight',
+ // kSbKeyGamepadRightStickUp
+ 0x8015: 'ArrowUp',
+ // kSbKeyGamepadRightStickDown
+ 0x8016: 'ArrowDown',
+ // kSbKeyGamepadRightStickLeft
+ 0x8017: 'ArrowLeft',
+ // kSbKeyGamepadRightStickRight
+ 0x8018: 'ArrowRight'
+};
+
function createMessageLog() {
var messageContainer = document.getElementById('messageContainer');
messageLog = new MessageLog(messageContainer);
@@ -195,6 +233,10 @@
function onKeydown(event) {
var key = event.key;
+ if (key == 'Unidentified') {
+ key = unidentifiedCobaltKeyMap[event.keyCode] || 'Unidentified';
+ }
+
if (key == 'ArrowLeft') {
commandInput.moveCursor(-1);
} else if (key == 'ArrowRight') {
diff --git a/src/cobalt/browser/global_constructors_idls_idl_files_list.tmp b/src/cobalt/browser/global_constructors_idls_idl_files_list.tmp
deleted file mode 100644
index b50619f..0000000
--- a/src/cobalt/browser/global_constructors_idls_idl_files_list.tmp
+++ /dev/null
@@ -1,149 +0,0 @@
-../audio/AudioBuffer.idl
-../audio/AudioBufferSourceNode.idl
-../audio/AudioContext.idl
-../audio/AudioDestinationNode.idl
-../audio/AudioNode.idl
-../cssom/CSS.idl
-../cssom/CSSConditionRule.idl
-../cssom/CSSGroupingRule.idl
-../cssom/CSSFontFaceRule.idl
-../cssom/CSSMediaRule.idl
-../cssom/CSSKeyframeRule.idl
-../cssom/CSSKeyframesRule.idl
-../cssom/CSSRule.idl
-../cssom/CSSRuleList.idl
-../cssom/CSSStyleDeclaration.idl
-../cssom/CSSStyleRule.idl
-../cssom/CSSStyleSheet.idl
-../cssom/MediaList.idl
-../cssom/StyleSheet.idl
-../cssom/StyleSheetList.idl
-../debug/DebugHub.idl
-../debug/Debugger.idl
-../debug/DebuggerEventTarget.idl
-../debug/DebugScriptRunner.idl
-../dom/AnimationEvent.idl
-../dom/ArrayBuffer.idl
-../dom/ArrayBufferView.idl
-../dom/Attr.idl
-../dom/Blob.idl
-../dom/CDATASection.idl
-../dom/CharacterData.idl
-../dom/Comment.idl
-../dom/Console.idl
-../dom/Crypto.idl
-../dom/DataView.idl
-../dom/Document.idl
-../dom/DocumentTimeline.idl
-../dom/DocumentType.idl
-../dom/DOMException.idl
-../dom/DOMImplementation.idl
-../dom/DOMParser.idl
-../dom/DOMRect.idl
-../dom/DOMRectList.idl
-../dom/DOMRectReadOnly.idl
-../dom/DOMStringMap.idl
-../dom/DOMTokenList.idl
-../dom/Element.idl
-../dom/Event.idl
-../dom/EventListener.idl
-../dom/EventTarget.idl
-../dom/Float32Array.idl
-../dom/Float64Array.idl
-../dom/FocusEvent.idl
-../dom/History.idl
-../dom/HTMLAnchorElement.idl
-../dom/HTMLBodyElement.idl
-../dom/HTMLBRElement.idl
-../dom/HTMLCollection.idl
-../dom/HTMLDivElement.idl
-../dom/HTMLElement.idl
-../dom/HTMLHeadElement.idl
-../dom/HTMLHeadingElement.idl
-../dom/HTMLHtmlElement.idl
-../dom/HTMLImageElement.idl
-../dom/HTMLLinkElement.idl
-../dom/HTMLMediaElement.idl
-../dom/HTMLMetaElement.idl
-../dom/HTMLParagraphElement.idl
-../dom/HTMLScriptElement.idl
-../dom/HTMLSpanElement.idl
-../dom/HTMLStyleElement.idl
-../dom/HTMLTitleElement.idl
-../dom/HTMLUnknownElement.idl
-../dom/HTMLVideoElement.idl
-../dom/KeyboardEvent.idl
-../dom/Location.idl
-../dom/MediaError.idl
-../dom/MediaKeyCompleteEvent.idl
-../dom/MediaKeyError.idl
-../dom/MediaKeyErrorEvent.idl
-../dom/MediaKeyMessageEvent.idl
-../dom/MediaKeyNeededEvent.idl
-../dom/MediaQueryList.idl
-../dom/MediaSource.idl
-../dom/MemoryInfo.idl
-../dom/MimeTypeArray.idl
-../dom/NamedNodeMap.idl
-../dom/Navigator.idl
-../dom/Node.idl
-../dom/NodeList.idl
-../dom/Performance.idl
-../dom/PerformanceTiming.idl
-../dom/PluginArray.idl
-../dom/ProgressEvent.idl
-../dom/Screen.idl
-../dom/SecurityPolicyViolationEvent.idl
-../dom/SourceBuffer.idl
-../dom/SourceBufferList.idl
-../dom/Storage.idl
-../dom/StorageEvent.idl
-../dom/TestRunner.idl
-../dom/Text.idl
-../dom/TimeRanges.idl
-../dom/TransitionEvent.idl
-../dom/UIEvent.idl
-../dom/Uint16Array.idl
-../dom/Uint32Array.idl
-../dom/Uint8Array.idl
-../dom/URL.idl
-../dom/VideoPlaybackQuality.idl
-../dom/Window.idl
-../dom/XMLDocument.idl
-../dom/XMLSerializer.idl
-../h5vcc/dial/DialHttpRequest.idl
-../h5vcc/dial/DialHttpResponse.idl
-../h5vcc/dial/DialServer.idl
-../h5vcc/H5vcc.idl
-../h5vcc/H5vccAccountInfo.idl
-../h5vcc/H5vccAccountManager.idl
-../h5vcc/H5vccAudioConfig.idl
-../h5vcc/H5vccAudioConfigArray.idl
-../h5vcc/H5vccCVal.idl
-../h5vcc/H5vccCValKeyList.idl
-../h5vcc/H5vccDeepLinkEventTarget.idl
-../h5vcc/H5vccRuntime.idl
-../h5vcc/H5vccRuntimeEventTarget.idl
-../h5vcc/H5vccSettings.idl
-../h5vcc/H5vccStorage.idl
-../h5vcc/H5vccSystem.idl
-../speech/SpeechRecognition.idl
-../speech/SpeechRecognitionAlternative.idl
-../speech/SpeechRecognitionError.idl
-../speech/SpeechRecognitionEvent.idl
-../speech/SpeechRecognitionResult.idl
-../speech/SpeechRecognitionResultList.idl
-../web_animations/Animatable.idl
-../web_animations/Animation.idl
-../web_animations/AnimationEffectReadOnly.idl
-../web_animations/AnimationEffectTimingReadOnly.idl
-../web_animations/AnimationTimeline.idl
-../web_animations/Keyframe.idl
-../web_animations/KeyframeEffectReadOnly.idl
-../webdriver/ScriptExecutor.idl
-../webdriver/ScriptExecutorParams.idl
-../webdriver/ScriptExecutorResult.idl
-../websocket/WebSocket.idl
-../xhr/XMLHttpRequest.idl
-../xhr/XMLHttpRequestEventTarget.idl
-../xhr/XMLHttpRequestUpload.idl
diff --git a/src/cobalt/browser/global_objects_idl_files_list.tmp b/src/cobalt/browser/global_objects_idl_files_list.tmp
deleted file mode 100644
index b50619f..0000000
--- a/src/cobalt/browser/global_objects_idl_files_list.tmp
+++ /dev/null
@@ -1,149 +0,0 @@
-../audio/AudioBuffer.idl
-../audio/AudioBufferSourceNode.idl
-../audio/AudioContext.idl
-../audio/AudioDestinationNode.idl
-../audio/AudioNode.idl
-../cssom/CSS.idl
-../cssom/CSSConditionRule.idl
-../cssom/CSSGroupingRule.idl
-../cssom/CSSFontFaceRule.idl
-../cssom/CSSMediaRule.idl
-../cssom/CSSKeyframeRule.idl
-../cssom/CSSKeyframesRule.idl
-../cssom/CSSRule.idl
-../cssom/CSSRuleList.idl
-../cssom/CSSStyleDeclaration.idl
-../cssom/CSSStyleRule.idl
-../cssom/CSSStyleSheet.idl
-../cssom/MediaList.idl
-../cssom/StyleSheet.idl
-../cssom/StyleSheetList.idl
-../debug/DebugHub.idl
-../debug/Debugger.idl
-../debug/DebuggerEventTarget.idl
-../debug/DebugScriptRunner.idl
-../dom/AnimationEvent.idl
-../dom/ArrayBuffer.idl
-../dom/ArrayBufferView.idl
-../dom/Attr.idl
-../dom/Blob.idl
-../dom/CDATASection.idl
-../dom/CharacterData.idl
-../dom/Comment.idl
-../dom/Console.idl
-../dom/Crypto.idl
-../dom/DataView.idl
-../dom/Document.idl
-../dom/DocumentTimeline.idl
-../dom/DocumentType.idl
-../dom/DOMException.idl
-../dom/DOMImplementation.idl
-../dom/DOMParser.idl
-../dom/DOMRect.idl
-../dom/DOMRectList.idl
-../dom/DOMRectReadOnly.idl
-../dom/DOMStringMap.idl
-../dom/DOMTokenList.idl
-../dom/Element.idl
-../dom/Event.idl
-../dom/EventListener.idl
-../dom/EventTarget.idl
-../dom/Float32Array.idl
-../dom/Float64Array.idl
-../dom/FocusEvent.idl
-../dom/History.idl
-../dom/HTMLAnchorElement.idl
-../dom/HTMLBodyElement.idl
-../dom/HTMLBRElement.idl
-../dom/HTMLCollection.idl
-../dom/HTMLDivElement.idl
-../dom/HTMLElement.idl
-../dom/HTMLHeadElement.idl
-../dom/HTMLHeadingElement.idl
-../dom/HTMLHtmlElement.idl
-../dom/HTMLImageElement.idl
-../dom/HTMLLinkElement.idl
-../dom/HTMLMediaElement.idl
-../dom/HTMLMetaElement.idl
-../dom/HTMLParagraphElement.idl
-../dom/HTMLScriptElement.idl
-../dom/HTMLSpanElement.idl
-../dom/HTMLStyleElement.idl
-../dom/HTMLTitleElement.idl
-../dom/HTMLUnknownElement.idl
-../dom/HTMLVideoElement.idl
-../dom/KeyboardEvent.idl
-../dom/Location.idl
-../dom/MediaError.idl
-../dom/MediaKeyCompleteEvent.idl
-../dom/MediaKeyError.idl
-../dom/MediaKeyErrorEvent.idl
-../dom/MediaKeyMessageEvent.idl
-../dom/MediaKeyNeededEvent.idl
-../dom/MediaQueryList.idl
-../dom/MediaSource.idl
-../dom/MemoryInfo.idl
-../dom/MimeTypeArray.idl
-../dom/NamedNodeMap.idl
-../dom/Navigator.idl
-../dom/Node.idl
-../dom/NodeList.idl
-../dom/Performance.idl
-../dom/PerformanceTiming.idl
-../dom/PluginArray.idl
-../dom/ProgressEvent.idl
-../dom/Screen.idl
-../dom/SecurityPolicyViolationEvent.idl
-../dom/SourceBuffer.idl
-../dom/SourceBufferList.idl
-../dom/Storage.idl
-../dom/StorageEvent.idl
-../dom/TestRunner.idl
-../dom/Text.idl
-../dom/TimeRanges.idl
-../dom/TransitionEvent.idl
-../dom/UIEvent.idl
-../dom/Uint16Array.idl
-../dom/Uint32Array.idl
-../dom/Uint8Array.idl
-../dom/URL.idl
-../dom/VideoPlaybackQuality.idl
-../dom/Window.idl
-../dom/XMLDocument.idl
-../dom/XMLSerializer.idl
-../h5vcc/dial/DialHttpRequest.idl
-../h5vcc/dial/DialHttpResponse.idl
-../h5vcc/dial/DialServer.idl
-../h5vcc/H5vcc.idl
-../h5vcc/H5vccAccountInfo.idl
-../h5vcc/H5vccAccountManager.idl
-../h5vcc/H5vccAudioConfig.idl
-../h5vcc/H5vccAudioConfigArray.idl
-../h5vcc/H5vccCVal.idl
-../h5vcc/H5vccCValKeyList.idl
-../h5vcc/H5vccDeepLinkEventTarget.idl
-../h5vcc/H5vccRuntime.idl
-../h5vcc/H5vccRuntimeEventTarget.idl
-../h5vcc/H5vccSettings.idl
-../h5vcc/H5vccStorage.idl
-../h5vcc/H5vccSystem.idl
-../speech/SpeechRecognition.idl
-../speech/SpeechRecognitionAlternative.idl
-../speech/SpeechRecognitionError.idl
-../speech/SpeechRecognitionEvent.idl
-../speech/SpeechRecognitionResult.idl
-../speech/SpeechRecognitionResultList.idl
-../web_animations/Animatable.idl
-../web_animations/Animation.idl
-../web_animations/AnimationEffectReadOnly.idl
-../web_animations/AnimationEffectTimingReadOnly.idl
-../web_animations/AnimationTimeline.idl
-../web_animations/Keyframe.idl
-../web_animations/KeyframeEffectReadOnly.idl
-../webdriver/ScriptExecutor.idl
-../webdriver/ScriptExecutorParams.idl
-../webdriver/ScriptExecutorResult.idl
-../websocket/WebSocket.idl
-../xhr/XMLHttpRequest.idl
-../xhr/XMLHttpRequestEventTarget.idl
-../xhr/XMLHttpRequestUpload.idl
diff --git a/src/cobalt/browser/interfaces_info_individual_static_idl_files_list.tmp b/src/cobalt/browser/interfaces_info_individual_static_idl_files_list.tmp
deleted file mode 100644
index a9c6e86..0000000
--- a/src/cobalt/browser/interfaces_info_individual_static_idl_files_list.tmp
+++ /dev/null
@@ -1,176 +0,0 @@
-../audio/AudioBuffer.idl
-../audio/AudioBufferSourceNode.idl
-../audio/AudioContext.idl
-../audio/AudioDestinationNode.idl
-../audio/AudioNode.idl
-../cssom/CSS.idl
-../cssom/CSSConditionRule.idl
-../cssom/CSSGroupingRule.idl
-../cssom/CSSFontFaceRule.idl
-../cssom/CSSMediaRule.idl
-../cssom/CSSKeyframeRule.idl
-../cssom/CSSKeyframesRule.idl
-../cssom/CSSRule.idl
-../cssom/CSSRuleList.idl
-../cssom/CSSStyleDeclaration.idl
-../cssom/CSSStyleRule.idl
-../cssom/CSSStyleSheet.idl
-../cssom/MediaList.idl
-../cssom/StyleSheet.idl
-../cssom/StyleSheetList.idl
-../debug/DebugHub.idl
-../debug/Debugger.idl
-../debug/DebuggerEventTarget.idl
-../debug/DebugScriptRunner.idl
-../dom/AnimationEvent.idl
-../dom/ArrayBuffer.idl
-../dom/ArrayBufferView.idl
-../dom/Attr.idl
-../dom/Blob.idl
-../dom/CDATASection.idl
-../dom/CharacterData.idl
-../dom/Comment.idl
-../dom/Console.idl
-../dom/Crypto.idl
-../dom/DataView.idl
-../dom/Document.idl
-../dom/DocumentTimeline.idl
-../dom/DocumentType.idl
-../dom/DOMException.idl
-../dom/DOMImplementation.idl
-../dom/DOMParser.idl
-../dom/DOMRect.idl
-../dom/DOMRectList.idl
-../dom/DOMRectReadOnly.idl
-../dom/DOMStringMap.idl
-../dom/DOMTokenList.idl
-../dom/Element.idl
-../dom/Event.idl
-../dom/EventListener.idl
-../dom/EventTarget.idl
-../dom/Float32Array.idl
-../dom/Float64Array.idl
-../dom/FocusEvent.idl
-../dom/History.idl
-../dom/HTMLAnchorElement.idl
-../dom/HTMLBodyElement.idl
-../dom/HTMLBRElement.idl
-../dom/HTMLCollection.idl
-../dom/HTMLDivElement.idl
-../dom/HTMLElement.idl
-../dom/HTMLHeadElement.idl
-../dom/HTMLHeadingElement.idl
-../dom/HTMLHtmlElement.idl
-../dom/HTMLImageElement.idl
-../dom/HTMLLinkElement.idl
-../dom/HTMLMediaElement.idl
-../dom/HTMLMetaElement.idl
-../dom/HTMLParagraphElement.idl
-../dom/HTMLScriptElement.idl
-../dom/HTMLSpanElement.idl
-../dom/HTMLStyleElement.idl
-../dom/HTMLTitleElement.idl
-../dom/HTMLUnknownElement.idl
-../dom/HTMLVideoElement.idl
-../dom/KeyboardEvent.idl
-../dom/Location.idl
-../dom/MediaError.idl
-../dom/MediaKeyCompleteEvent.idl
-../dom/MediaKeyError.idl
-../dom/MediaKeyErrorEvent.idl
-../dom/MediaKeyMessageEvent.idl
-../dom/MediaKeyNeededEvent.idl
-../dom/MediaQueryList.idl
-../dom/MediaSource.idl
-../dom/MemoryInfo.idl
-../dom/MimeTypeArray.idl
-../dom/NamedNodeMap.idl
-../dom/Navigator.idl
-../dom/Node.idl
-../dom/NodeList.idl
-../dom/Performance.idl
-../dom/PerformanceTiming.idl
-../dom/PluginArray.idl
-../dom/ProgressEvent.idl
-../dom/Screen.idl
-../dom/SecurityPolicyViolationEvent.idl
-../dom/SourceBuffer.idl
-../dom/SourceBufferList.idl
-../dom/Storage.idl
-../dom/StorageEvent.idl
-../dom/TestRunner.idl
-../dom/Text.idl
-../dom/TimeRanges.idl
-../dom/TransitionEvent.idl
-../dom/UIEvent.idl
-../dom/Uint16Array.idl
-../dom/Uint32Array.idl
-../dom/Uint8Array.idl
-../dom/URL.idl
-../dom/VideoPlaybackQuality.idl
-../dom/Window.idl
-../dom/XMLDocument.idl
-../dom/XMLSerializer.idl
-../h5vcc/dial/DialHttpRequest.idl
-../h5vcc/dial/DialHttpResponse.idl
-../h5vcc/dial/DialServer.idl
-../h5vcc/H5vcc.idl
-../h5vcc/H5vccAccountInfo.idl
-../h5vcc/H5vccAccountManager.idl
-../h5vcc/H5vccAudioConfig.idl
-../h5vcc/H5vccAudioConfigArray.idl
-../h5vcc/H5vccCVal.idl
-../h5vcc/H5vccCValKeyList.idl
-../h5vcc/H5vccDeepLinkEventTarget.idl
-../h5vcc/H5vccRuntime.idl
-../h5vcc/H5vccRuntimeEventTarget.idl
-../h5vcc/H5vccSettings.idl
-../h5vcc/H5vccStorage.idl
-../h5vcc/H5vccSystem.idl
-../speech/SpeechRecognition.idl
-../speech/SpeechRecognitionAlternative.idl
-../speech/SpeechRecognitionError.idl
-../speech/SpeechRecognitionEvent.idl
-../speech/SpeechRecognitionResult.idl
-../speech/SpeechRecognitionResultList.idl
-../web_animations/Animatable.idl
-../web_animations/Animation.idl
-../web_animations/AnimationEffectReadOnly.idl
-../web_animations/AnimationEffectTimingReadOnly.idl
-../web_animations/AnimationTimeline.idl
-../web_animations/Keyframe.idl
-../web_animations/KeyframeEffectReadOnly.idl
-../webdriver/ScriptExecutor.idl
-../webdriver/ScriptExecutorParams.idl
-../webdriver/ScriptExecutorResult.idl
-../websocket/WebSocket.idl
-../xhr/XMLHttpRequest.idl
-../xhr/XMLHttpRequestEventTarget.idl
-../xhr/XMLHttpRequestUpload.idl
-../cssom/LinkStyle.idl
-../dom/Document_CSSOM.idl
-../dom/Document_HTML5.idl
-../dom/Document_WebAnimationsAPI.idl
-../dom/Element_CSSOMView.idl
-../dom/Element_DOMParsingAndSerialization.idl
-../dom/ElementCSSInlineStyle.idl
-../dom/GlobalCrypto.idl
-../dom/GlobalEventHandlers.idl
-../dom/HTMLElement_CSSOMView.idl
-../dom/NavigatorID.idl
-../dom/NavigatorLanguage.idl
-../dom/NavigatorPlugins.idl
-../dom/NavigatorStorageUtils.idl
-../dom/NonDocumentTypeChildNode.idl
-../dom/NonElementParentNode.idl
-../dom/ParentNode.idl
-../dom/Performance_HighResolutionTime.idl
-../dom/URLUtils.idl
-../dom/Window_AnimationTiming.idl
-../dom/Window_CSSOM.idl
-../dom/Window_CSSOMView.idl
-../dom/Window_Performance.idl
-../dom/WindowEventHandlers.idl
-../dom/WindowLocalStorage.idl
-../dom/WindowSessionStorage.idl
-../dom/WindowTimers.idl
diff --git a/src/cobalt/browser/memory_tracker/memory_tracker_tool_impl.cc b/src/cobalt/browser/memory_tracker/memory_tracker_tool_impl.cc
index cc317ea..91b34f3 100644
--- a/src/cobalt/browser/memory_tracker/memory_tracker_tool_impl.cc
+++ b/src/cobalt/browser/memory_tracker/memory_tracker_tool_impl.cc
@@ -126,6 +126,24 @@
return s;
}
+// Removes odd elements and resizes vector.
+template <typename VectorType>
+void RemoveOddElements(VectorType* v) {
+ typedef typename VectorType::iterator iterator;
+
+ iterator read_it = v->end();
+ iterator write_it = v->end();
+ for (size_t i = 0; i*2 < v->size(); ++i) {
+ write_it = v->begin() + i;
+ read_it = v->begin() + (i*2);
+ *write_it = *read_it;
+ }
+ if (write_it != v->end()) {
+ write_it++;
+ }
+ v->erase(write_it, v->end());
+}
+
// NoMemoryTracking will disable memory tracking while in the current scope of
// execution. When the object is destroyed it will reset the previous state
// of allocation tracking.
@@ -191,8 +209,8 @@
}
std::string TimeInMinutesString() const {
base::TimeDelta delta_t = time_since_start();
- int64 seconds = delta_t.InSeconds();
- float time_mins = static_cast<float>(seconds) / 60.f;
+ float seconds = static_cast<float>(delta_t.InMilliseconds()) / 1000.0f;
+ float time_mins = seconds / 60.f;
std::stringstream ss;
ss << time_mins;
@@ -662,7 +680,7 @@
<< "// to be used in a stacked graph." << kNewLine;
// HEADER.
- ss << "Time(mins),";
+ ss << kQuote << "Time(mins)" << kQuote << kDelimiter;
for (MapIt it = samples.begin(); it != samples.end(); ++it) {
const std::string& name = it->first;
ss << kQuote << SanitizeCSVKey(name) << kQuote << kDelimiter;
@@ -672,7 +690,8 @@
// Print out the values of each of the samples.
for (size_t i = 0; i < smallest_sample_size; ++i) {
// Output time first so that it can be used as an x-axis.
- const double time_mins = timeseries.time_stamps_[i].InSeconds()/60.f;
+ const double time_mins =
+ timeseries.time_stamps_[i].InMilliseconds() / (1000. * 60.);
ss << time_mins << ",";
for (MapIt it = samples.begin(); it != samples.end(); ++it) {
const int64 alloc_bytes = it->second.allocated_bytes_[i];
@@ -692,7 +711,7 @@
ss << kNewLine << "// CSV of COUNT of allocations per region." << kNewLine;
// HEADER
- ss << "Time(mins),";
+ ss << kQuote << "Time(mins)" << kQuote << kDelimiter;
for (MapIt it = samples.begin(); it != samples.end(); ++it) {
const std::string& name = it->first;
ss << kQuote << SanitizeCSVKey(name) << kQuote << kDelimiter;
@@ -700,7 +719,8 @@
ss << kNewLine;
for (size_t i = 0; i < smallest_sample_size; ++i) {
// Output time first so that it can be used as an x-axis.
- const double time_mins = timeseries.time_stamps_[i].InSeconds() / 60.f;
+ const double time_mins =
+ timeseries.time_stamps_[i].InMilliseconds() / (1000. * 60.);
ss << time_mins << ",";
for (MapIt it = samples.begin(); it != samples.end(); ++it) {
const int64 n_allocs = it->second.number_allocations_[i];
@@ -710,6 +730,7 @@
}
ss << "// END CSV of COUNT of allocations per region." << kNewLine;
ss << "//////////////////////////////////////////////";
+ ss << kNewLine;
std::string output = ss.str();
return output;
@@ -720,6 +741,7 @@
const base::TimeDelta& time_now) {
const size_t sample_count = timeseries->time_stamps_.size();
timeseries->time_stamps_.push_back(time_now);
+
MapAllocationSamples& map_samples = timeseries->samples_;
std::vector<const AllocationGroup*> vector_output;
@@ -780,11 +802,11 @@
void MemoryTrackerCompressedTimeSeries::Compress(TimeSeries* timeseries) {
typedef MapAllocationSamples::iterator MapIt;
MapAllocationSamples& samples = timeseries->samples_;
- DoCompression(&(timeseries->time_stamps_));
+ RemoveOddElements(&(timeseries->time_stamps_));
for (MapIt it = samples.begin(); it != samples.end(); ++it) {
AllocationSamples& data = it->second;
- DoCompression(&data.allocated_bytes_);
- DoCompression(&data.number_allocations_);
+ RemoveOddElements(&data.allocated_bytes_);
+ RemoveOddElements(&data.number_allocations_);
}
}
diff --git a/src/cobalt/browser/trace_manager.h b/src/cobalt/browser/trace_manager.h
index 2fc4dc6..8ace7b8 100644
--- a/src/cobalt/browser/trace_manager.h
+++ b/src/cobalt/browser/trace_manager.h
@@ -28,6 +28,7 @@
namespace cobalt {
namespace browser {
+// Wrapper class which wraps all trace related stuff.
class TraceManager {
public:
// Returns whether there's a trace that is active.
diff --git a/src/cobalt/browser/web_module.cc b/src/cobalt/browser/web_module.cc
index 572200d..e1ab7dc 100644
--- a/src/cobalt/browser/web_module.cc
+++ b/src/cobalt/browser/web_module.cc
@@ -229,6 +229,9 @@
// from URLs.
scoped_ptr<loader::font::RemoteTypefaceCache> remote_typeface_cache_;
+ // MeshCache that is used to manage mesh cache logic.
+ scoped_ptr<loader::mesh::MeshCache> mesh_cache_;
+
// Interface between LocalStorage and the Storage Manager.
scoped_ptr<dom::LocalStorageDatabase> local_storage_database_;
@@ -386,6 +389,13 @@
loader_factory_.get());
DCHECK(remote_typeface_cache_);
+ DCHECK_LE(0, data.options.mesh_cache_capacity);
+ mesh_cache_ = loader::mesh::CreateMeshCache(
+ base::StringPrintf("%s.MeshCache", name_.c_str()),
+ static_cast<uint32>(data.options.mesh_cache_capacity),
+ loader_factory_.get());
+ DCHECK(mesh_cache_);
+
local_storage_database_.reset(
new dom::LocalStorageDatabase(data.network_module->storage_manager()));
DCHECK(local_storage_database_);
@@ -420,8 +430,8 @@
css_parser_.get(), dom_parser_.get(), fetcher_factory_.get(),
&resource_provider_, image_cache_.get(),
reduced_image_cache_capacity_manager_.get(), remote_typeface_cache_.get(),
- local_storage_database_.get(), data.media_module, data.media_module,
- execution_state_.get(), script_runner_.get(),
+ mesh_cache_.get(), local_storage_database_.get(), data.media_module,
+ data.media_module, execution_state_.get(), script_runner_.get(),
media_source_registry_.get(),
web_module_stat_tracker_->dom_stat_tracker(), data.initial_url,
data.network_module->GetUserAgent(),
@@ -543,6 +553,7 @@
javascript_engine_.reset();
web_module_stat_tracker_.reset();
local_storage_database_.reset();
+ mesh_cache_.reset();
remote_typeface_cache_.reset();
image_cache_.reset();
fetcher_factory_.reset();
@@ -746,6 +757,7 @@
image_cache_capacity(COBALT_IMAGE_CACHE_SIZE_IN_BYTES),
remote_typeface_cache_capacity(
COBALT_REMOTE_TYPEFACE_CACHE_SIZE_IN_BYTES),
+ mesh_cache_capacity(COBALT_MESH_CACHE_SIZE_IN_BYTES),
csp_enforcement_mode(dom::kCspEnforcementEnable),
csp_insecure_allowed_token(0),
track_event_stats(false),
diff --git a/src/cobalt/browser/web_module.h b/src/cobalt/browser/web_module.h
index 2307e89..dfeb9dc 100644
--- a/src/cobalt/browser/web_module.h
+++ b/src/cobalt/browser/web_module.h
@@ -122,12 +122,15 @@
// can't be changed from the whitelisted origins.
std::string location_policy;
- // Image cache capaticy in bytes.
+ // Image cache capacity in bytes.
int image_cache_capacity;
// Typeface cache capacity in bytes.
int remote_typeface_cache_capacity;
+ // Mesh cache capacity in bytes.
+ int mesh_cache_capacity;
+
// Content Security Policy enforcement mode for this web module.
dom::CspEnforcementType csp_enforcement_mode;
diff --git a/src/cobalt/browser/web_module_stat_tracker.cc b/src/cobalt/browser/web_module_stat_tracker.cc
index 06323fa..64b999f 100644
--- a/src/cobalt/browser/web_module_stat_tracker.cc
+++ b/src/cobalt/browser/web_module_stat_tracker.cc
@@ -129,6 +129,16 @@
StringPrintf("Event.Count.%s.DOM.HtmlElement.UpdateComputedStyle",
name.c_str()),
0, "Number of update computed styles for HTML elements."),
+ count_dom_generate_html_element_computed_style(
+ StringPrintf(
+ "Event.Count.%s.DOM.HtmlElement.GenerateHtmlElementComputedStyle",
+ name.c_str()),
+ 0, "Number of generated computed styles for HTML elements."),
+ count_dom_generate_pseudo_element_computed_style(
+ StringPrintf("Event.Count.%s.DOM.HtmlElement."
+ "GeneratePseudoElementComputedStyle",
+ name.c_str()),
+ 0, "Number of generated computed styles for Pseudo elements."),
count_layout_boxes_created(
StringPrintf("Event.Count.%s.Layout.Box.Created", name.c_str()), 0,
"Number of boxes created."),
@@ -174,6 +184,7 @@
,
value_dictionary(
StringPrintf("Event.%s.ValueDictionary", name.c_str()),
+ "{}"
"All event values represented as a dictionary in a string.")
#endif // ENABLE_WEBDRIVER
{
@@ -207,6 +218,10 @@
dom_stat_tracker_->update_matching_rules_count();
event_stats->count_dom_update_computed_style =
dom_stat_tracker_->update_computed_style_count();
+ event_stats->count_dom_generate_html_element_computed_style =
+ dom_stat_tracker_->generate_html_element_computed_style_count();
+ event_stats->count_dom_generate_pseudo_element_computed_style =
+ dom_stat_tracker_->generate_pseudo_element_computed_style_count();
event_stats->count_layout_boxes_created =
layout_stat_tracker_->boxes_created_count();
event_stats->count_layout_boxes_destroyed =
@@ -249,10 +264,15 @@
<< dom_stat_tracker_->html_elements_created_count() << ", "
<< "\"CntDomHtmlElementsDestroyed\":"
<< dom_stat_tracker_->html_elements_destroyed_count() << ", "
- << "\"CntDomUpdateMatchingRuleCalls\":"
+ << "\"CntDomUpdateMatchingRules\":"
<< dom_stat_tracker_->update_matching_rules_count() << ", "
- << "\"CntDomUpdateComputedStyleCalls\":"
+ << "\"CntDomUpdateComputedStyle\":"
<< dom_stat_tracker_->update_computed_style_count() << ", "
+ << "\"CntDomGenerateHtmlComputedStyle\":"
+ << dom_stat_tracker_->generate_html_element_computed_style_count() << ", "
+ << "\"CntDomGeneratePseudoComputedStyle\":"
+ << dom_stat_tracker_->generate_pseudo_element_computed_style_count()
+ << ", "
<< "\"CntLayoutBoxes\":" << layout_stat_tracker_->total_boxes() << ", "
<< "\"CntLayoutBoxesCreated\":"
<< layout_stat_tracker_->boxes_created_count() << ", "
diff --git a/src/cobalt/browser/web_module_stat_tracker.h b/src/cobalt/browser/web_module_stat_tracker.h
index 95efb4a..b4f24e7 100644
--- a/src/cobalt/browser/web_module_stat_tracker.h
+++ b/src/cobalt/browser/web_module_stat_tracker.h
@@ -82,6 +82,10 @@
base::CVal<int, base::CValPublic> count_dom_html_elements_destroyed;
base::CVal<int, base::CValPublic> count_dom_update_matching_rules;
base::CVal<int, base::CValPublic> count_dom_update_computed_style;
+ base::CVal<int, base::CValPublic>
+ count_dom_generate_html_element_computed_style;
+ base::CVal<int, base::CValPublic>
+ count_dom_generate_pseudo_element_computed_style;
base::CVal<int, base::CValPublic> count_layout_boxes_created;
base::CVal<int, base::CValPublic> count_layout_boxes_destroyed;
diff --git a/src/cobalt/build/build.id b/src/cobalt/build/build.id
index b679c25..255f12e 100644
--- a/src/cobalt/build/build.id
+++ b/src/cobalt/build/build.id
@@ -1 +1 @@
-21796
\ No newline at end of file
+22891
\ No newline at end of file
diff --git a/src/cobalt/build/config/base.gypi b/src/cobalt/build/config/base.gypi
index 9ab623b..8174cbd 100644
--- a/src/cobalt/build/config/base.gypi
+++ b/src/cobalt/build/config/base.gypi
@@ -169,6 +169,11 @@
# typefaces downloaded from a web page.
'remote_typeface_cache_size_in_bytes%': 5 * 1024 * 1024,
+ # Determines the capacity of the mesh cache. Each mesh is held compressed
+ # in main memory, to be inflated into a GPU buffer when needed for
+ # projection. Default to 0 and set by platforms that support map-to-mesh.
+ 'mesh_cache_size_in_bytes%': 0,
+
# Only relevant if you are using the Blitter API.
# Determines the capacity of the software surface cache, which is used to
# cache all surfaces that are rendered via a software rasterizer to avoid
diff --git a/src/cobalt/build/generate_data_header.py b/src/cobalt/build/generate_data_header.py
index 1bfdff4..322b6b8 100755
--- a/src/cobalt/build/generate_data_header.py
+++ b/src/cobalt/build/generate_data_header.py
@@ -28,18 +28,14 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
-
"""Convert binary files to source arrays.
-This script takes all of the files in a given directory (and all of its
-subdirectories) and concatenates them for access at byte arrays in a c++
-header file.
+This script takes all of the given input files and directories (and all
+subdirectories) and concatenates them for access at byte arrays in a c++ header
+file.
-The directory to check is specified as the first argument, and the output
-header is specified as the second argument.
-
-The utility function GenerateMap() is also generated to populate a std::map
-that maps between filenames and the embedded file.
+The utility function GenerateMap() is also generated to populate a std::map that
+maps between filenames and the embedded file.
All generated symbols will be placed under the user-provided namespace.
"""
@@ -48,64 +44,85 @@
import sys
-def GetVariableNameFromPath(file_path):
- # Get rid of non-variable name friendly characters
- return file_path.replace('.', '_').replace('/', '_')
+class InputFile(object):
+ """A file with an absolute path and a path that it is relative to."""
+
+ def __init__(self, path, parent):
+ self.path = os.path.abspath(path)
+ self.parent = os.path.abspath(parent)
+
+ def GetRelativePath(self):
+ return os.path.relpath(self.path, self.parent)
+
+ def GetVariableName(self):
+ # Get rid of non-variable name friendly characters
+ return self.GetRelativePath().replace('.', '_').replace('/', '_')
-def WriteFileDataToHeader(input_file, output_file):
+def WriteFileDataToHeader(filename, output_file):
"""Concatenates a single file into the output file."""
- with file(input_file, 'rb') as f:
+ with file(filename, 'rb') as f:
file_contents = f.read()
- def chunks(l, n):
- """ Yield successive n-sized chunks from l."""
+
+ def Chunks(l, n):
+ """Yield successive n-sized chunks from l."""
for i in xrange(0, len(l), n):
- yield l[i:i+n]
+ yield l[i:i + n]
- output_string = ',\n'.join([', '.join(['0x%02x' % ord(y) for y in x])
- for x in chunks(file_contents, 200)])
- output_file.write('{' + output_string + '};\n\n')
+ output_string = ',\n'.join([
+ ', '.join(['0x%02x' % ord(y) for y in x])
+ for x in Chunks(file_contents, 13)
+ ])
+ output_file.write('{\n' + output_string + '\n};\n\n')
-def GetFilesToConcatenate(input_directory):
- """Get list of files to concatenate.
+def GetInputFilesToConcatenate(paths):
+ """Converts a list of paths into a flattened list of InputFiles.
+
+ If an input path is a directory, it adds an entry for each file in that
+ subtree, and keeps it relative to the specified directory.
+
+ If an input path is a regular file, it adds an entry for that file, relative
+ to its immediate parent directory.
Args:
- input_directory: Directory to search for files.
- Returns:
- A list of all files that we would like to concatenate relative
- to the input directory.
+ paths: Array of paths to search for files.
+ Returns:
+ A list of InputFiles that we would like to concatenate.
"""
file_list = []
- for dirpath, _, files in os.walk(input_directory):
- for input_file in files:
- file_list.append(
- os.path.relpath(
- os.path.join(dirpath, input_file),
- input_directory))
+ for path in paths:
+ path = os.path.abspath(path)
+ if os.path.isdir(path):
+ for directory, _, files in os.walk(path):
+ for filename in files:
+ file_list.append(InputFile(os.path.join(directory, filename), path))
+ elif os.path.isfile(path):
+ file_list.append(InputFile(path, os.path.dirname(path)))
+ else:
+ raise '%s is not a file or directory.' % path
return file_list
-def WriteAllFilesToHeader(input_directory, files, output_file):
- """Writes the content of all passed in files to the header file."""
+def WriteAllFilesToHeader(input_files, output_file):
+ """Writes the content of all passed in InputFiles to the header file."""
- for path in files:
- input_file_variable_name = GetVariableNameFromPath(path)
+ for input_file in input_files:
+ input_file_variable_name = input_file.GetVariableName()
output_file.write('const unsigned char %s[] =\n' % input_file_variable_name)
-
- WriteFileDataToHeader(os.path.join(input_directory, path), output_file)
+ WriteFileDataToHeader(input_file.path, output_file)
-def GenerateMapFunction(files, output_file):
+def GenerateMapFunction(input_files, output_file):
"""Generate C++ containing a map.
Generates a c++ function that populates a map (mapping filenames to the
embedded contents.)
Args:
- files: List of filenames in the map.
+ input_files: List of InputFiles in the map.
output_file: Name of c++ file to write out.
"""
@@ -114,17 +131,18 @@
'inline void GenerateMap(GeneratedResourceMap &out_map) {\n')
# os.walk gets dirpath, dirnames, filenames; we want just filenames, so [2]
- for path in files:
+ for input_file in input_files:
# The lookup key will be the file path relative to the input directory
- input_file_variable_name = GetVariableNameFromPath(path)
+ input_file_variable_name = input_file.GetVariableName()
output_file.write(' out_map["%s"] = FileContents(%s, sizeof(%s));\n' %
- (path, input_file_variable_name, input_file_variable_name)
- )
+ (input_file.GetRelativePath(), input_file_variable_name,
+ input_file_variable_name))
output_file.write('}\n\n')
-def main(namespace, input_directory, output_file_name):
+def WriteHeader(namespace, output_file_name, files_to_concatenate):
+ """Writes an embedded resource header to the given output filename."""
output_file = open(output_file_name, 'w')
include_guard = '_COBALT_GENERATED_' + namespace.upper() + '_H_'
output_file.write('// Copyright 2014 Google Inc. '
@@ -133,22 +151,22 @@
'#ifndef ' + include_guard + '\n'
'#define ' + include_guard + '\n\n'
'#include \"cobalt/base/generated_resources_types.h\"\n\n'
- 'namespace ' + namespace +' {\n')
+ 'namespace ' + namespace + ' {\n')
- files_to_concatenate = GetFilesToConcatenate(input_directory)
- WriteAllFilesToHeader(input_directory,
- files_to_concatenate,
- output_file)
+ WriteAllFilesToHeader(files_to_concatenate, output_file)
GenerateMapFunction(files_to_concatenate, output_file)
output_file.write('} // namespace ' + namespace + '\n\n'
'#endif // ' + include_guard + '\n')
+def main(namespace, output_file_name, paths):
+ WriteHeader(namespace, output_file_name, GetInputFilesToConcatenate(paths))
+
+
if __name__ == '__main__':
- if len(sys.argv) != 4:
- print ('usage:\n %s <namespace> <input directory> <output filepath>' %
- sys.argv[0])
+ if len(sys.argv) < 4:
+ print 'usage:\n %s <namespace> <output-file> <inputs...> \n' % sys.argv[0]
print __doc__
sys.exit(1)
- main(sys.argv[1], sys.argv[2], sys.argv[3])
+ main(sys.argv[1], sys.argv[2], sys.argv[3:])
diff --git a/src/cobalt/cssom/compound_selector.h b/src/cobalt/cssom/compound_selector.h
index b4e1121..097e2cd 100644
--- a/src/cobalt/cssom/compound_selector.h
+++ b/src/cobalt/cssom/compound_selector.h
@@ -117,8 +117,8 @@
Specificity specificity_;
bool has_pseudo_element_;
// This flag tracks whether or not during rule matching, after the initial
- // candidate gathering phase, the simple selectors additional checks during
- // the verification phase to determine a match; otherwise, the act of
+ // candidate gathering phase, the simple selectors require additional checks
+ // during the verification phase to determine a match; otherwise, the act of
// being gathered itself proves the match.
// There are two cases where the selectors require a visit:
// 1. There are multiple selectors. Gathering only tests against the first
diff --git a/src/cobalt/cssom/cssom.gyp b/src/cobalt/cssom/cssom.gyp
index 2d3723e..96cd74d 100644
--- a/src/cobalt/cssom/cssom.gyp
+++ b/src/cobalt/cssom/cssom.gyp
@@ -269,7 +269,7 @@
'outputs': [
'<(output_path)',
],
- 'action': ['python', '<(script_path)', 'CSSOMEmbeddedResources', '<(input_directory)', '<(output_path)'],
+ 'action': ['python', '<(script_path)', 'CSSOMEmbeddedResources', '<(output_path)', '<(input_directory)'],
'message': 'Embedding cssom resources in "<(input_directory)" into header file, "<(output_path)".',
'msvs_cygwin_shell': 1,
},
diff --git a/src/cobalt/dom/character_data.cc b/src/cobalt/dom/character_data.cc
index 1c031f6..6ffff25 100644
--- a/src/cobalt/dom/character_data.cc
+++ b/src/cobalt/dom/character_data.cc
@@ -16,11 +16,19 @@
#include "cobalt/dom/character_data.h"
+#include "cobalt/dom/mutation_reporter.h"
+
namespace cobalt {
namespace dom {
CharacterData::CharacterData(Document* document, const base::StringPiece& data)
: Node(document), data_(data.begin(), data.end()) {}
+void CharacterData::set_data(const std::string& data) {
+ MutationReporter mutation_reporter(this, GatherInclusiveAncestorsObservers());
+ mutation_reporter.ReportCharacterDataMutation(data_);
+ data_ = data;
+}
+
} // namespace dom
} // namespace cobalt
diff --git a/src/cobalt/dom/character_data.h b/src/cobalt/dom/character_data.h
index 08d5b00..12a8d9d 100644
--- a/src/cobalt/dom/character_data.h
+++ b/src/cobalt/dom/character_data.h
@@ -33,19 +33,29 @@
// Web API: Node
base::optional<std::string> node_value() const OVERRIDE { return data_; }
void set_node_value(const base::optional<std::string>& node_value) OVERRIDE {
- data_ = node_value.value_or("");
+ // Don't use value_or to avoid copying the string.
+ if (node_value) {
+ set_data(node_value.value());
+ } else {
+ set_data("");
+ }
}
base::optional<std::string> text_content() const OVERRIDE { return data_; }
void set_text_content(
const base::optional<std::string>& text_content) OVERRIDE {
- data_ = text_content.value_or("");
+ // Don't use value_or to avoid copying the string.
+ if (text_content) {
+ set_data(text_content.value());
+ } else {
+ set_data("");
+ }
}
// Web API: CharacterData
//
std::string data() const { return data_; }
- void set_data(const std::string& data) { data_ = data; }
+ void set_data(const std::string& data);
// Custom, not in any spec.
//
diff --git a/src/cobalt/dom/comment_test.cc b/src/cobalt/dom/comment_test.cc
index 6de330b..71c1c45 100644
--- a/src/cobalt/dom/comment_test.cc
+++ b/src/cobalt/dom/comment_test.cc
@@ -42,7 +42,7 @@
CommentTest::CommentTest()
: html_element_context_(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, "") {
+ NULL, NULL, NULL, NULL, NULL, "") {
EXPECT_TRUE(GlobalStats::GetInstance()->CheckNoLeaks());
document_ = new Document(&html_element_context_);
}
diff --git a/src/cobalt/dom/document_test.cc b/src/cobalt/dom/document_test.cc
index ee0f442..e50c06c 100644
--- a/src/cobalt/dom/document_test.cc
+++ b/src/cobalt/dom/document_test.cc
@@ -66,7 +66,7 @@
: css_parser_(css_parser::Parser::Create()),
dom_stat_tracker_(new DomStatTracker("DocumentTest")),
html_element_context_(NULL, css_parser_.get(), NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL,
dom_stat_tracker_.get(), "") {
EXPECT_TRUE(GlobalStats::GetInstance()->CheckNoLeaks());
}
diff --git a/src/cobalt/dom/document_type_test.cc b/src/cobalt/dom/document_type_test.cc
index 90f51c3..540dc53 100644
--- a/src/cobalt/dom/document_type_test.cc
+++ b/src/cobalt/dom/document_type_test.cc
@@ -27,7 +27,7 @@
protected:
DocumentTypeTest()
: html_element_context_(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, ""),
+ NULL, NULL, NULL, NULL, NULL, ""),
document_(new Document(&html_element_context_)) {}
~DocumentTypeTest() OVERRIDE {}
diff --git a/src/cobalt/dom/dom.gyp b/src/cobalt/dom/dom.gyp
index 02775e4..3d2a9e9 100644
--- a/src/cobalt/dom/dom.gyp
+++ b/src/cobalt/dom/dom.gyp
@@ -179,10 +179,15 @@
'memory_info.h',
'mime_type_array.cc',
'mime_type_array.h',
+ 'mutation_observer_task_manager.cc',
+ 'mutation_observer_task_manager.h',
'mutation_observer.cc',
'mutation_observer.h',
'mutation_observer_init.h',
+ 'mutation_record.cc',
'mutation_record.h',
+ 'mutation_reporter.cc',
+ 'mutation_reporter.h',
'named_node_map.cc',
'named_node_map.h',
'navigator.cc',
@@ -206,6 +211,9 @@
'progress_event.h',
'pseudo_element.cc',
'pseudo_element.h',
+ 'registered_observer.h',
+ 'registered_observer_list.cc',
+ 'registered_observer_list.h',
'rule_matching.cc',
'rule_matching.h',
'screen.h',
diff --git a/src/cobalt/dom/dom_implementation_test.cc b/src/cobalt/dom/dom_implementation_test.cc
index a9687aa..ff137ed 100644
--- a/src/cobalt/dom/dom_implementation_test.cc
+++ b/src/cobalt/dom/dom_implementation_test.cc
@@ -28,7 +28,7 @@
TEST(DOMImplementationTest, CreateDocumentShouldCreateXMLDocument) {
HTMLElementContext html_element_context(NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL,
- "");
+ NULL, "");
scoped_refptr<DOMImplementation> dom_implementation =
new DOMImplementation(&html_element_context);
scoped_refptr<Document> document =
diff --git a/src/cobalt/dom/dom_parser_test.cc b/src/cobalt/dom/dom_parser_test.cc
index 0e5cde6..fe037e1 100644
--- a/src/cobalt/dom/dom_parser_test.cc
+++ b/src/cobalt/dom/dom_parser_test.cc
@@ -50,8 +50,8 @@
&stub_script_runner_, NULL /* media_source_registry */,
NULL /* resource_provider */, NULL /* image_cache */,
NULL /* reduced_image_cache_capacity_manager */,
- NULL /* remote_typeface_cache */, NULL /* dom_stat_tracker */,
- "" /* language */),
+ NULL /* remote_typeface_cache */, NULL /* mesh_cache */,
+ NULL /* dom_stat_tracker */, "" /* language */),
dom_parser_(new DOMParser(&html_element_context_)) {}
TEST_F(DOMParserTest, ParsesXML) {
diff --git a/src/cobalt/dom/dom_stat_tracker.cc b/src/cobalt/dom/dom_stat_tracker.cc
index 81ad1a8..83dcd38 100644
--- a/src/cobalt/dom/dom_stat_tracker.cc
+++ b/src/cobalt/dom/dom_stat_tracker.cc
@@ -34,7 +34,9 @@
html_elements_created_count_(0),
html_elements_destroyed_count_(0),
update_matching_rules_count_(0),
- update_computed_style_count_(0) {
+ update_computed_style_count_(0),
+ generate_html_element_computed_style_count_(0),
+ generate_pseudo_element_computed_style_count_(0) {
stop_watch_durations_.resize(kNumStopWatchTypes, base::TimeDelta());
}
@@ -94,6 +96,14 @@
void DomStatTracker::OnUpdateComputedStyle() { ++update_computed_style_count_; }
+void DomStatTracker::OnGenerateHtmlElementComputedStyle() {
+ ++generate_html_element_computed_style_count_;
+}
+
+void DomStatTracker::OnGeneratePseudoElementComputedStyle() {
+ ++generate_pseudo_element_computed_style_count_;
+}
+
base::TimeDelta DomStatTracker::GetStopWatchTypeDuration(
StopWatchType type) const {
return stop_watch_durations_[type];
@@ -117,6 +127,8 @@
html_elements_destroyed_count_ = 0;
update_matching_rules_count_ = 0;
update_computed_style_count_ = 0;
+ generate_html_element_computed_style_count_ = 0;
+ generate_pseudo_element_computed_style_count_ = 0;
}
} // namespace dom
diff --git a/src/cobalt/dom/dom_stat_tracker.h b/src/cobalt/dom/dom_stat_tracker.h
index 80e1208..23d8bcd 100644
--- a/src/cobalt/dom/dom_stat_tracker.h
+++ b/src/cobalt/dom/dom_stat_tracker.h
@@ -49,6 +49,8 @@
void OnHtmlElementDestroyed();
void OnUpdateMatchingRules();
void OnUpdateComputedStyle();
+ void OnGenerateHtmlElementComputedStyle();
+ void OnGeneratePseudoElementComputedStyle();
int total_html_elements() const { return total_html_elements_; }
@@ -64,6 +66,12 @@
int update_computed_style_count() const {
return update_computed_style_count_;
}
+ int generate_html_element_computed_style_count() const {
+ return generate_html_element_computed_style_count_;
+ }
+ int generate_pseudo_element_computed_style_count() const {
+ return generate_pseudo_element_computed_style_count_;
+ }
base::TimeDelta GetStopWatchTypeDuration(StopWatchType type) const;
@@ -92,6 +100,8 @@
int html_elements_destroyed_count_;
int update_matching_rules_count_;
int update_computed_style_count_;
+ int generate_html_element_computed_style_count_;
+ int generate_pseudo_element_computed_style_count_;
// Stop watch-related.
std::vector<base::TimeDelta> stop_watch_durations_;
diff --git a/src/cobalt/dom/dom_string_map_test.cc b/src/cobalt/dom/dom_string_map_test.cc
index d9c5521..365c9a8 100644
--- a/src/cobalt/dom/dom_string_map_test.cc
+++ b/src/cobalt/dom/dom_string_map_test.cc
@@ -45,7 +45,7 @@
DOMStringMapTest::DOMStringMapTest()
: html_element_context_(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, ""),
+ NULL, NULL, NULL, NULL, NULL, ""),
document_(new Document(&html_element_context_)),
element_(new Element(document_, base::Token("element"))),
dom_string_map_(new DOMStringMap(element_)) {}
diff --git a/src/cobalt/dom/dom_test.gyp b/src/cobalt/dom/dom_test.gyp
index 9bbd53a..a80be3f 100644
--- a/src/cobalt/dom/dom_test.gyp
+++ b/src/cobalt/dom/dom_test.gyp
@@ -49,6 +49,7 @@
'local_storage_database_test.cc',
'location_test.cc',
'media_query_list_test.cc',
+ 'mutation_observer_test.cc',
'node_dispatch_event_test.cc',
'node_list_live_test.cc',
'node_list_test.cc',
diff --git a/src/cobalt/dom/dom_token_list_test.cc b/src/cobalt/dom/dom_token_list_test.cc
index 0ef5e3e..70e224c 100644
--- a/src/cobalt/dom/dom_token_list_test.cc
+++ b/src/cobalt/dom/dom_token_list_test.cc
@@ -40,7 +40,7 @@
DOMTokenListTest::DOMTokenListTest()
: html_element_context_(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, "") {
+ NULL, NULL, NULL, NULL, NULL, "") {
EXPECT_TRUE(GlobalStats::GetInstance()->CheckNoLeaks());
document_ = new Document(&html_element_context_);
}
diff --git a/src/cobalt/dom/element.cc b/src/cobalt/dom/element.cc
index 7300b67..8eddb53 100644
--- a/src/cobalt/dom/element.cc
+++ b/src/cobalt/dom/element.cc
@@ -32,6 +32,7 @@
#include "cobalt/dom/html_collection.h"
#include "cobalt/dom/html_element.h"
#include "cobalt/dom/html_element_context.h"
+#include "cobalt/dom/mutation_reporter.h"
#include "cobalt/dom/named_node_map.h"
#include "cobalt/dom/parser.h"
#include "cobalt/dom/serializer.h"
@@ -187,6 +188,11 @@
// value is value, and then append this attribute to the context object and
// terminate these steps.
// 5. Change attribute from context object to value.
+
+ base::optional<std::string> old_value = GetAttribute(attr_name);
+ MutationReporter mutation_reporter(this, GatherInclusiveAncestorsObservers());
+ mutation_reporter.ReportAttributesMutation(attr_name, old_value);
+
switch (attr_name.size()) {
case 5:
if (attr_name == kStyleAttributeName) {
@@ -252,6 +258,13 @@
StringToLowerASCII(&attr_name);
}
+ base::optional<std::string> old_value = GetAttribute(attr_name);
+ if (old_value) {
+ MutationReporter mutation_reporter(this,
+ GatherInclusiveAncestorsObservers());
+ mutation_reporter.ReportAttributesMutation(attr_name, old_value);
+ }
+
// 2. Remove the first attribute from the context object whose name is name,
// if any.
switch (attr_name.size()) {
diff --git a/src/cobalt/dom/element_test.cc b/src/cobalt/dom/element_test.cc
index c8b5ea9..d4a3724 100644
--- a/src/cobalt/dom/element_test.cc
+++ b/src/cobalt/dom/element_test.cc
@@ -61,7 +61,7 @@
dom_parser_(new dom_parser::Parser()),
dom_stat_tracker_(new DomStatTracker("ElementTest")),
html_element_context_(NULL, css_parser_.get(), dom_parser_.get(), NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
dom_stat_tracker_.get(), "") {
EXPECT_TRUE(GlobalStats::GetInstance()->CheckNoLeaks());
document_ = new Document(&html_element_context_);
diff --git a/src/cobalt/dom/html_element.cc b/src/cobalt/dom/html_element.cc
index b3ea234..9123ffb 100644
--- a/src/cobalt/dom/html_element.cc
+++ b/src/cobalt/dom/html_element.cc
@@ -956,6 +956,7 @@
UpdateComputedStyleInvalidationFlags invalidation_flags;
if (generate_computed_style) {
+ dom_stat_tracker_->OnGenerateHtmlElementComputedStyle();
bool animations_modified = false;
scoped_refptr<cssom::CSSComputedStyleData> new_computed_style =
@@ -982,7 +983,7 @@
css_computed_style_declaration_->UpdateInheritedData();
}
- // NOTE: Currently, pseudo elements computed styles are always generated. If
+ // NOTE: Currently, pseudo element's computed styles are always generated. If
// this becomes a performance bottleneck, change the logic so that it only
// occurs when needed.
@@ -990,6 +991,7 @@
for (int pseudo_element_type = 0; pseudo_element_type < kMaxPseudoElementType;
++pseudo_element_type) {
if (pseudo_elements_[pseudo_element_type]) {
+ dom_stat_tracker_->OnGeneratePseudoElementComputedStyle();
bool animations_modified = false;
scoped_refptr<cssom::CSSComputedStyleData> pseudo_element_computed_style =
diff --git a/src/cobalt/dom/html_element_context.cc b/src/cobalt/dom/html_element_context.cc
index c7a9975..e3888d3 100644
--- a/src/cobalt/dom/html_element_context.cc
+++ b/src/cobalt/dom/html_element_context.cc
@@ -32,7 +32,8 @@
loader::image::ReducedCacheCapacityManager*
reduced_image_cache_capacity_manager,
loader::font::RemoteTypefaceCache* remote_typeface_cache,
- DomStatTracker* dom_stat_tracker, const std::string& language)
+ loader::mesh::MeshCache* mesh_cache, DomStatTracker* dom_stat_tracker,
+ const std::string& language)
: fetcher_factory_(fetcher_factory),
css_parser_(css_parser),
dom_parser_(dom_parser),
@@ -45,6 +46,7 @@
reduced_image_cache_capacity_manager_(
reduced_image_cache_capacity_manager),
remote_typeface_cache_(remote_typeface_cache),
+ mesh_cache_(mesh_cache),
dom_stat_tracker_(dom_stat_tracker),
language_(language),
sync_load_thread_("Synchronous Load"),
diff --git a/src/cobalt/dom/html_element_context.h b/src/cobalt/dom/html_element_context.h
index a751b03..4c0f933 100644
--- a/src/cobalt/dom/html_element_context.h
+++ b/src/cobalt/dom/html_element_context.h
@@ -28,6 +28,7 @@
#include "cobalt/loader/fetcher_factory.h"
#include "cobalt/loader/font/remote_typeface_cache.h"
#include "cobalt/loader/image/image_cache.h"
+#include "cobalt/loader/mesh/mesh_cache.h"
#include "cobalt/media/can_play_type_handler.h"
#include "cobalt/media/web_media_player_factory.h"
#include "cobalt/script/script_runner.h"
@@ -53,6 +54,7 @@
loader::image::ReducedCacheCapacityManager*
reduced_image_cache_capacity_manager,
loader::font::RemoteTypefaceCache* remote_typeface_cache,
+ loader::mesh::MeshCache* mesh_cache,
DomStatTracker* dom_stat_tracker,
const std::string& language);
~HTMLElementContext();
@@ -85,6 +87,8 @@
return remote_typeface_cache_;
}
+ loader::mesh::MeshCache* mesh_cache() const { return mesh_cache_; }
+
DomStatTracker* dom_stat_tracker() { return dom_stat_tracker_; }
const std::string& language() const { return language_; }
@@ -113,6 +117,7 @@
loader::image::ReducedCacheCapacityManager* const
reduced_image_cache_capacity_manager_;
loader::font::RemoteTypefaceCache* const remote_typeface_cache_;
+ loader::mesh::MeshCache* const mesh_cache_;
DomStatTracker* const dom_stat_tracker_;
const std::string language_;
diff --git a/src/cobalt/dom/html_element_factory_test.cc b/src/cobalt/dom/html_element_factory_test.cc
index 2f0c00c..c1485fb 100644
--- a/src/cobalt/dom/html_element_factory_test.cc
+++ b/src/cobalt/dom/html_element_factory_test.cc
@@ -60,8 +60,8 @@
NULL /* media_source_registry */, NULL /* resource_provider */,
NULL /* image_cache */,
NULL /* reduced_image_cache_capacity_manager */,
- NULL /* remote_typeface_cache */, dom_stat_tracker_.get(),
- "" /* language */),
+ NULL /* remote_typeface_cache */, NULL /* mesh_cache */,
+ dom_stat_tracker_.get(), "" /* language */),
document_(new Document(&html_element_context_)) {}
~HTMLElementFactoryTest() OVERRIDE {}
diff --git a/src/cobalt/dom/html_element_test.cc b/src/cobalt/dom/html_element_test.cc
index e445dcb..2178549 100644
--- a/src/cobalt/dom/html_element_test.cc
+++ b/src/cobalt/dom/html_element_test.cc
@@ -110,8 +110,8 @@
HTMLElementTest()
: dom_stat_tracker_(new DomStatTracker("HTMLElementTest")),
html_element_context_(NULL, &css_parser_, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, dom_stat_tracker_.get(),
- ""),
+ NULL, NULL, NULL, NULL, NULL,
+ dom_stat_tracker_.get(), ""),
document_(new Document(&html_element_context_)) {}
~HTMLElementTest() OVERRIDE {}
diff --git a/src/cobalt/dom/location.cc b/src/cobalt/dom/location.cc
index 9886f33..7202a3fd 100644
--- a/src/cobalt/dom/location.cc
+++ b/src/cobalt/dom/location.cc
@@ -83,5 +83,12 @@
}
}
+void Location::Reload() {
+ if (!navigation_callback_.is_null()) {
+ LOG(INFO) << "Reloading URL: " << url();
+ navigation_callback_.Run(url());
+ }
+}
+
} // namespace dom
} // namespace cobalt
diff --git a/src/cobalt/dom/location.h b/src/cobalt/dom/location.h
index d9552ca..1b3aa76 100644
--- a/src/cobalt/dom/location.h
+++ b/src/cobalt/dom/location.h
@@ -49,11 +49,7 @@
void Replace(const std::string& url);
- void Reload() {
- if (!navigation_callback_.is_null()) {
- navigation_callback_.Run(url());
- }
- }
+ void Reload();
// Web API: URLUtils (implements)
//
diff --git a/src/cobalt/dom/mutation_observer.cc b/src/cobalt/dom/mutation_observer.cc
index 3cfa7a0..04057a8 100644
--- a/src/cobalt/dom/mutation_observer.cc
+++ b/src/cobalt/dom/mutation_observer.cc
@@ -16,12 +16,15 @@
#include "cobalt/dom/mutation_observer.h"
+#include "cobalt/dom/mutation_observer_task_manager.h"
+#include "cobalt/dom/node.h"
+
namespace cobalt {
namespace dom {
// Abstract base class for a MutationCallback.
class MutationObserver::CallbackInternal {
public:
- virtual void RunCallback(const MutationRecordSequence& mutations,
+ virtual bool RunCallback(const MutationRecordSequence& mutations,
const scoped_refptr<MutationObserver>& observer) = 0;
virtual ~CallbackInternal() {}
};
@@ -33,9 +36,11 @@
ScriptCallback(const MutationObserver::MutationCallbackArg& callback,
MutationObserver* owner)
: callback_(owner, callback) {}
- void RunCallback(const MutationObserver::MutationRecordSequence& mutations,
+ bool RunCallback(const MutationObserver::MutationRecordSequence& mutations,
const scoped_refptr<MutationObserver>& observer) OVERRIDE {
- callback_.value().Run(mutations, observer);
+ script::CallbackResult<void> result =
+ callback_.value().Run(mutations, observer);
+ return !result.exception;
}
private:
@@ -48,37 +53,114 @@
explicit NativeCallback(
const MutationObserver::NativeMutationCallback& callback)
: callback_(callback) {}
- void RunCallback(const MutationObserver::MutationRecordSequence& mutations,
+ bool RunCallback(const MutationObserver::MutationRecordSequence& mutations,
const scoped_refptr<MutationObserver>& observer) OVERRIDE {
callback_.Run(mutations, observer);
+ return true;
}
private:
MutationObserver::NativeMutationCallback callback_;
};
+
} // namespace
MutationObserver::MutationObserver(
- const NativeMutationCallback& native_callback) {
+ const NativeMutationCallback& native_callback,
+ MutationObserverTaskManager* task_manager)
+ : task_manager_(task_manager) {
callback_.reset(new NativeCallback(native_callback));
+ task_manager_->OnMutationObserverCreated(this);
}
-MutationObserver::MutationObserver(const MutationCallbackArg& callback) {
+MutationObserver::MutationObserver(const MutationCallbackArg& callback,
+ MutationObserverTaskManager* task_manager)
+ : task_manager_(task_manager) {
callback_.reset(new ScriptCallback(callback, this));
+ task_manager_->OnMutationObserverCreated(this);
+}
+
+MutationObserver::~MutationObserver() {
+ task_manager_->OnMutationObserverDestroyed(this);
}
void MutationObserver::Observe(const scoped_refptr<Node>& target,
const MutationObserverInit& options) {
- UNREFERENCED_PARAMETER(target);
- UNREFERENCED_PARAMETER(options);
- NOTIMPLEMENTED();
+ if (!target) {
+ // |target| is not nullable, so if this is NULL that indicates a bug in the
+ // bindings layer.
+ NOTREACHED();
+ return;
+ }
+ if (!target->RegisterMutationObserver(make_scoped_refptr(this), options)) {
+ // TODO: Throw TypeError.
+ NOTREACHED();
+ }
+ TrackObservedNode(target);
}
-void MutationObserver::Disconnect() { NOTIMPLEMENTED(); }
+void MutationObserver::Disconnect() {
+ // The disconnect() method must, for each node in the context object's
+ // list of nodes, remove any registered observer on node for which the context
+ // object is the observer, and also empty context object's record queue.
+ for (WeakNodeVector::iterator it = observed_nodes_.begin();
+ it != observed_nodes_.end(); ++it) {
+ dom::Node* node = it->get();
+ if (node != NULL) {
+ node->UnregisterMutationObserver(make_scoped_refptr(this));
+ }
+ }
+ observed_nodes_.clear();
+ record_queue_.clear();
+}
MutationObserver::MutationRecordSequence MutationObserver::TakeRecords() {
- NOTIMPLEMENTED();
- return MutationRecordSequence();
+ // The takeRecords() method must return a copy of the record queue and then
+ // empty the record queue.
+ MutationRecordSequence record_queue;
+ record_queue.swap(record_queue_);
+ return record_queue;
+}
+
+void MutationObserver::QueueMutationRecord(
+ const scoped_refptr<MutationRecord>& record) {
+ record_queue_.push_back(record);
+ task_manager_->QueueMutationObserverMicrotask();
+}
+
+bool MutationObserver::Notify() {
+ // https://www.w3.org/TR/dom/#mutationobserver
+ // Step 3 of "notify mutation observers" steps:
+ // 1. Let queue be a copy of mo's record queue.
+ // 2. Empty mo's record queue.
+ MutationRecordSequence records = TakeRecords();
+
+ // 3. Remove all transient registered observers whose observer is mo.
+ // TODO: handle transient registered observers.
+
+ // 4. If queue is non-empty, call mo's callback with queue as first
+ // argument, and mo (itself) as second argument and callback this
+ // value. If this throws an exception, report the exception.
+ if (!records.empty()) {
+ return callback_->RunCallback(records, make_scoped_refptr(this));
+ }
+ // If no records, return true to indicate no error occurred.
+ return true;
+}
+
+void MutationObserver::TrackObservedNode(const scoped_refptr<dom::Node>& node) {
+ for (WeakNodeVector::iterator it = observed_nodes_.begin();
+ it != observed_nodes_.end();) {
+ if (*it == NULL) {
+ it = observed_nodes_.erase(it);
+ continue;
+ }
+ if (*it == node) {
+ return;
+ }
+ ++it;
+ }
+ observed_nodes_.push_back(base::AsWeakPtr(node.get()));
}
} // namespace dom
diff --git a/src/cobalt/dom/mutation_observer.h b/src/cobalt/dom/mutation_observer.h
index a78030a..fa8daa9 100644
--- a/src/cobalt/dom/mutation_observer.h
+++ b/src/cobalt/dom/mutation_observer.h
@@ -24,7 +24,6 @@
#include "base/memory/scoped_ptr.h"
#include "cobalt/dom/mutation_observer_init.h"
#include "cobalt/dom/mutation_record.h"
-#include "cobalt/dom/node.h"
#include "cobalt/script/callback_function.h"
#include "cobalt/script/sequence.h"
#include "cobalt/script/wrappable.h"
@@ -32,6 +31,9 @@
namespace cobalt {
namespace dom {
+class MutationObserverTaskManager;
+class Node;
+
// A MutationObserver object can be used to observe mutations to the tree of
// nodes.
// https://www.w3.org/TR/dom/#mutationobserver
@@ -51,22 +53,44 @@
// Not part of the spec. Support creating MutationObservers from native Cobalt
// code.
- explicit MutationObserver(const NativeMutationCallback& native_callback);
+ MutationObserver(const NativeMutationCallback& native_callback,
+ MutationObserverTaskManager* task_manager);
// Web Api: MutationObserver
- explicit MutationObserver(const MutationCallbackArg& callback);
+ MutationObserver(const MutationCallbackArg& callback,
+ MutationObserverTaskManager* task_manager);
+ ~MutationObserver();
+
void Observe(const scoped_refptr<Node>& target,
const MutationObserverInit& options);
void Disconnect();
MutationRecordSequence TakeRecords();
+ // Not part of the MutationObserver interface. Implements step (4.8) of the
+ // "queue a mutation record" algorithm.
+ // https://www.w3.org/TR/dom/#queue-a-mutation-record
+ void QueueMutationRecord(const scoped_refptr<MutationRecord>& record);
+
+ // Not part of the the MutationObserver interface. Implements steps (3) of the
+ // "notify mutation observers" algorithm.
+ // https://www.w3.org/TR/dom/#notify-mutation-observers
+ bool Notify();
+
// Internal helper class to allow creation of a MutationObserver with either a
// native or script callback. Must be public so it can be inherited from in
// the .cc file.
class CallbackInternal;
+ DEFINE_WRAPPABLE_TYPE(MutationObserver);
+
private:
+ void TrackObservedNode(const scoped_refptr<dom::Node>& node);
+
scoped_ptr<CallbackInternal> callback_;
+ typedef std::vector<base::WeakPtr<dom::Node> > WeakNodeVector;
+ WeakNodeVector observed_nodes_;
+ MutationRecordSequence record_queue_;
+ MutationObserverTaskManager* task_manager_;
};
} // namespace dom
} // namespace cobalt
diff --git a/src/cobalt/dom/mutation_observer_init.h b/src/cobalt/dom/mutation_observer_init.h
index 3e3c0ea..bd39b33 100644
--- a/src/cobalt/dom/mutation_observer_init.h
+++ b/src/cobalt/dom/mutation_observer_init.h
@@ -21,6 +21,7 @@
#include <vector>
#include "base/optional.h"
+#include "cobalt/script/sequence.h"
namespace cobalt {
namespace dom {
@@ -28,20 +29,101 @@
// Represents the MutationObserverInit dictionary type that is used to
// initialize the MutationObserver interface.
// https://www.w3.org/TR/dom/#mutationobserver
-struct MutationObserverInit {
- typedef std::vector<std::string> StringSequence;
+class MutationObserverInit {
+ public:
+ typedef script::Sequence<std::string> StringSequence;
- // Default values as specified in the IDL.
- MutationObserverInit() : child_list(false), subtree(false) {}
+ MutationObserverInit()
+ : child_list_(false),
+ attributes_(false),
+ has_attributes_(false),
+ character_data_(false),
+ has_character_data_(false),
+ subtree_(false),
+ attribute_old_value_(false),
+ has_attribute_old_value_(false),
+ character_data_old_value_(false),
+ has_character_data_old_value_(false),
+ has_attribute_filter_(false) {}
+ bool child_list() const { return child_list_; }
+ void set_child_list(bool value) { child_list_ = value; }
+
+ bool attributes() const {
+ DCHECK(has_attributes_);
+ return attributes_;
+ }
+ void set_attributes(bool value) {
+ has_attributes_ = true;
+ attributes_ = value;
+ }
+ bool has_attributes() const { return has_attributes_; }
+
+ bool character_data() const {
+ DCHECK(has_character_data_);
+ return character_data_;
+ }
+ void set_character_data(bool value) {
+ has_character_data_ = true;
+ character_data_ = value;
+ }
+ bool has_character_data() const { return has_character_data_; }
+
+ bool subtree() const { return subtree_; }
+ void set_subtree(bool value) { subtree_ = value; }
+
+ bool attribute_old_value() const {
+ DCHECK(has_attribute_old_value_);
+ return attribute_old_value_;
+ }
+ void set_attribute_old_value(bool value) {
+ has_attribute_old_value_ = true;
+ attribute_old_value_ = value;
+ }
+ bool has_attribute_old_value() const { return has_attribute_old_value_; }
+
+ bool character_data_old_value() const {
+ DCHECK(has_character_data_old_value_);
+ return character_data_old_value_;
+ }
+ void set_character_data_old_value(bool value) {
+ has_character_data_old_value_ = true;
+ character_data_old_value_ = value;
+ }
+ bool has_character_data_old_value() const {
+ return has_character_data_old_value_;
+ }
+
+ const StringSequence& attribute_filter() const {
+ DCHECK(has_attribute_filter_);
+ return attribute_filter_;
+ }
+ void set_attribute_filter(StringSequence value) {
+ has_attribute_filter_ = true;
+ attribute_filter_ = value;
+ }
+ bool has_attribute_filter() const { return has_attribute_filter_; }
+
+ private:
// Dictionary members:
- bool child_list;
- base::optional<bool> attributes;
- base::optional<bool> character_data;
- bool subtree;
- base::optional<bool> attribute_old_value;
- base::optional<bool> character_data_old_value;
- base::optional<StringSequence> attribute_filter;
+ bool child_list_;
+
+ bool attributes_;
+ bool has_attributes_;
+
+ bool character_data_;
+ bool has_character_data_;
+
+ bool subtree_;
+
+ bool attribute_old_value_;
+ bool has_attribute_old_value_;
+
+ bool character_data_old_value_;
+ bool has_character_data_old_value_;
+
+ StringSequence attribute_filter_;
+ bool has_attribute_filter_;
};
} // namespace dom
} // namespace cobalt
diff --git a/src/cobalt/dom/mutation_observer_task_manager.cc b/src/cobalt/dom/mutation_observer_task_manager.cc
new file mode 100644
index 0000000..b7c7c7a
--- /dev/null
+++ b/src/cobalt/dom/mutation_observer_task_manager.cc
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2017 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.
+ */
+
+#include "cobalt/dom/mutation_observer_task_manager.h"
+
+#include "base/callback.h"
+#include "base/message_loop.h"
+
+namespace cobalt {
+namespace dom {
+
+void MutationObserverTaskManager::OnMutationObserverCreated(
+ MutationObserver* observer) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(observers_.find(observer) == observers_.end());
+ observers_.insert(observer);
+}
+void MutationObserverTaskManager::OnMutationObserverDestroyed(
+ MutationObserver* observer) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(observers_.find(observer) != observers_.end());
+ observers_.erase(observer);
+}
+
+void MutationObserverTaskManager::QueueMutationObserverMicrotask() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ // https://www.w3.org/TR/dom/#queue-a-mutation-observer-compound-microtask
+ // To queue a mutation observer compound microtask, run these steps:
+ // 1. If mutation observer compound microtask queued flag is set, terminate
+ // these steps.
+ if (task_posted_) {
+ return;
+ }
+ // 2. Set mutation observer compound microtask queued flag.
+ task_posted_ = true;
+ // 3. Queue a compound microtask to notify mutation observers.
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&MutationObserverTaskManager::NotifyMutationObservers,
+ base::Unretained(this)));
+}
+
+void MutationObserverTaskManager::NotifyMutationObservers() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(task_posted_);
+ DCHECK(MessageLoop::current());
+ // https://www.w3.org/TR/dom/#notify-mutation-observers
+ // To notify mutation observers, run these steps:
+ // 1. Unset mutation observer compound microtask queued flag.
+ task_posted_ = false;
+
+ // 2. Let notify list be a copy of unit of related similar-origin browsing
+ // contexts's list of MutationObserver objects.
+ // 3. For each MutationObserver object mo in notify list, execute a compound
+ // microtask subtask to run these steps: [HTML]
+ //
+ // Subtask steps are implemented in MutationObserver::Notify.
+ for (MutationObserverSet::iterator it = observers_.begin();
+ it != observers_.end(); ++it) {
+ MutationObserver* observer = *it;
+ if (!observer->Notify()) {
+ DLOG(ERROR) << "Exception when notifying mutation observer.";
+ }
+ }
+}
+
+} // namespace dom
+} // namespace cobalt
diff --git a/src/cobalt/dom/mutation_observer_task_manager.h b/src/cobalt/dom/mutation_observer_task_manager.h
new file mode 100644
index 0000000..c080492
--- /dev/null
+++ b/src/cobalt/dom/mutation_observer_task_manager.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2017 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.
+ */
+
+#ifndef COBALT_DOM_MUTATION_OBSERVER_TASK_MANAGER_H_
+#define COBALT_DOM_MUTATION_OBSERVER_TASK_MANAGER_H_
+
+#include <utility>
+
+#include "base/hash_tables.h"
+#include "base/threading/thread_checker.h"
+#include "cobalt/dom/mutation_observer.h"
+
+namespace cobalt {
+namespace dom {
+
+// The Mutation observer spec describes a sequence of steps to "queue a mutation
+// observer compound microtask" and "notify mutation observers". These steps
+// are implemented in this helper class, which must outlive all
+// MutationObserver instances.
+// The spec expects an EventLoop implementation, which Cobalt does not currently
+// have.
+// https://www.w3.org/TR/dom/#mutation-observers
+class MutationObserverTaskManager {
+ public:
+ MutationObserverTaskManager() : task_posted_(false) {}
+
+ // These should be called in the constructor/destructor of the
+ // MutationObserver.
+ void OnMutationObserverCreated(MutationObserver* observer);
+ void OnMutationObserverDestroyed(MutationObserver* observer);
+
+ // Post a task to notify mutation observers, if one is not already posted.
+ void QueueMutationObserverMicrotask();
+
+ private:
+ // Notify all mutation observers.
+ void NotifyMutationObservers();
+
+ typedef base::hash_set<MutationObserver*> MutationObserverSet;
+
+ base::ThreadChecker thread_checker_;
+ MutationObserverSet observers_;
+ bool task_posted_;
+};
+
+} // namespace dom
+} // namespace cobalt
+
+#endif // COBALT_DOM_MUTATION_OBSERVER_TASK_MANAGER_H_
diff --git a/src/cobalt/dom/mutation_observer_test.cc b/src/cobalt/dom/mutation_observer_test.cc
new file mode 100644
index 0000000..32a1a04
--- /dev/null
+++ b/src/cobalt/dom/mutation_observer_test.cc
@@ -0,0 +1,533 @@
+/*
+ * Copyright 2017 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.
+ */
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/message_loop.h"
+#include "cobalt/dom/element.h"
+#include "cobalt/dom/mutation_observer_init.h"
+#include "cobalt/dom/mutation_observer_task_manager.h"
+#include "cobalt/dom/mutation_record.h"
+#include "cobalt/dom/mutation_reporter.h"
+#include "cobalt/dom/node_list.h"
+#include "cobalt/dom/text.h"
+#include "cobalt/script/sequence.h"
+#include "cobalt/test/empty_document.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using ::testing::_;
+using ::testing::SaveArg;
+
+namespace cobalt {
+namespace dom {
+// Helper struct for childList mutations.
+struct ChildListMutationArguments {
+ scoped_refptr<dom::Element> previous_sibling;
+ scoped_refptr<dom::Element> next_sibling;
+ scoped_refptr<dom::NodeList> added_nodes;
+ scoped_refptr<dom::NodeList> removed_nodes;
+};
+
+class MutationCallbackMock {
+ public:
+ MOCK_METHOD2(NativeMutationCallback,
+ void(const MutationObserver::MutationRecordSequence&,
+ const scoped_refptr<MutationObserver>&));
+};
+
+class MutationObserverTest : public ::testing::Test {
+ protected:
+ dom::Document* document() { return empty_document_.document(); }
+ MutationObserverTaskManager* task_manager() { return &task_manager_; }
+ MutationCallbackMock* callback_mock() { return &callback_mock_; }
+
+ scoped_refptr<Element> CreateDiv() {
+ scoped_refptr<Element> element = document()->CreateElement("div");
+ DCHECK(element);
+ document()->AppendChild(element);
+ return element;
+ }
+
+ scoped_refptr<MutationObserver> CreateObserver() {
+ return new MutationObserver(
+ base::Bind(&MutationCallbackMock::NativeMutationCallback,
+ base::Unretained(&callback_mock_)),
+ &task_manager_);
+ }
+
+ ChildListMutationArguments CreateChildListMutationArguments() {
+ // These nodes are not actually related in the way they are named
+ // (next_sibling, previous_sibling, etc) but that is not relevant for the
+ // purpose of these tests.
+ ChildListMutationArguments args;
+ args.previous_sibling = CreateDiv();
+ args.next_sibling = CreateDiv();
+ args.added_nodes = new NodeList();
+ args.added_nodes->AppendNode(CreateDiv());
+ args.removed_nodes = new NodeList();
+ args.removed_nodes->AppendNode(CreateDiv());
+ return args;
+ }
+
+ private:
+ MutationObserverTaskManager task_manager_;
+ test::EmptyDocument empty_document_;
+ MutationCallbackMock callback_mock_;
+ MessageLoop message_loop_;
+};
+
+TEST_F(MutationObserverTest, CreateAttributeMutationRecord) {
+ scoped_refptr<dom::Element> target = CreateDiv();
+ scoped_refptr<MutationRecord> record =
+ MutationRecord::CreateAttributeMutationRecord(target, "attribute_name",
+ std::string("old_value"));
+ ASSERT_TRUE(record);
+
+ // "type" and attribute-related attributes are set as expected
+ EXPECT_STREQ("attribute", record->type().c_str());
+ EXPECT_TRUE(record->attribute_name());
+ EXPECT_STREQ("attribute_name", record->attribute_name()->c_str());
+ EXPECT_TRUE(record->old_value());
+ EXPECT_STREQ("old_value", record->old_value()->c_str());
+
+ // "target" is set as expected.
+ EXPECT_EQ(target, record->target());
+
+ // Namespaces are not supported.
+ EXPECT_FALSE(record->attribute_namespace());
+
+ // Unrelated attributes are not set.
+ EXPECT_FALSE(record->added_nodes());
+ EXPECT_FALSE(record->removed_nodes());
+ EXPECT_FALSE(record->previous_sibling());
+ EXPECT_FALSE(record->next_sibling());
+}
+
+TEST_F(MutationObserverTest, CreateCharacterDataMutationRecord) {
+ scoped_refptr<dom::Element> target = CreateDiv();
+ scoped_refptr<MutationRecord> record =
+ MutationRecord::CreateCharacterDataMutationRecord(
+ target, std::string("old_character_data"));
+ ASSERT_TRUE(record);
+
+ // "type" and attribute-related attributes are set as expected
+ EXPECT_STREQ("characterData", record->type().c_str());
+ EXPECT_TRUE(record->old_value());
+ EXPECT_STREQ("old_character_data", record->old_value()->c_str());
+
+ // "target" is set as expected.
+ EXPECT_EQ(target, record->target());
+
+ // Unrelated attributes are not set.
+ EXPECT_FALSE(record->attribute_name());
+ EXPECT_FALSE(record->attribute_namespace());
+ EXPECT_FALSE(record->added_nodes());
+ EXPECT_FALSE(record->removed_nodes());
+ EXPECT_FALSE(record->previous_sibling());
+ EXPECT_FALSE(record->next_sibling());
+}
+
+TEST_F(MutationObserverTest, CreateChildListMutationRecord) {
+ scoped_refptr<dom::Element> target = CreateDiv();
+
+ ChildListMutationArguments args = CreateChildListMutationArguments();
+ scoped_refptr<MutationRecord> record =
+ MutationRecord::CreateChildListMutationRecord(
+ target, args.added_nodes, args.removed_nodes, args.previous_sibling,
+ args.next_sibling);
+ ASSERT_TRUE(record);
+
+ // "type" and attribute-related attributes are set as expected
+ EXPECT_STREQ("childList", record->type().c_str());
+ EXPECT_EQ(args.added_nodes, record->added_nodes());
+ EXPECT_EQ(args.removed_nodes, record->removed_nodes());
+ EXPECT_EQ(args.previous_sibling, record->previous_sibling());
+ EXPECT_EQ(args.next_sibling, record->next_sibling());
+
+ // "target" is set as expected.
+ EXPECT_EQ(target, record->target());
+
+ // Unrelated attributes are not set.
+ EXPECT_FALSE(record->attribute_name());
+ EXPECT_FALSE(record->attribute_namespace());
+ EXPECT_FALSE(record->old_value());
+}
+
+TEST_F(MutationObserverTest, MutationObserverInit) {
+ MutationObserverInit init;
+ // Default values are set according to spec.
+ EXPECT_FALSE(init.child_list());
+ EXPECT_FALSE(init.subtree());
+
+ // Other values are not set.
+ EXPECT_FALSE(init.has_attributes());
+ EXPECT_FALSE(init.has_character_data());
+ EXPECT_FALSE(init.has_attribute_old_value());
+ EXPECT_FALSE(init.has_character_data_old_value());
+ EXPECT_FALSE(init.has_attribute_filter());
+
+ // Set other values.
+ init.set_attributes(true);
+ init.set_character_data(true);
+ init.set_attribute_old_value(true);
+ init.set_character_data_old_value(true);
+ script::Sequence<std::string> attribute_filter;
+ attribute_filter.push_back("a_filter");
+ init.set_attribute_filter(attribute_filter);
+
+ // Other values are now set.
+ EXPECT_TRUE(init.has_attributes());
+ EXPECT_TRUE(init.attributes());
+ EXPECT_TRUE(init.has_character_data());
+ EXPECT_TRUE(init.character_data());
+ EXPECT_TRUE(init.has_attribute_old_value());
+ EXPECT_TRUE(init.attribute_old_value());
+ EXPECT_TRUE(init.has_character_data_old_value());
+ EXPECT_TRUE(init.character_data_old_value());
+ EXPECT_TRUE(init.has_attribute_filter());
+ EXPECT_EQ(init.attribute_filter().size(), attribute_filter.size());
+ EXPECT_EQ(init.attribute_filter().at(0), attribute_filter.at(0));
+}
+
+TEST_F(MutationObserverTest, TakeRecords) {
+ scoped_refptr<dom::Element> target = CreateDiv();
+
+ // Newly created observer shouldn't have records.
+ scoped_refptr<MutationObserver> observer = CreateObserver();
+ MutationObserver::MutationRecordSequence records;
+ records = observer->TakeRecords();
+ EXPECT_TRUE(records.empty());
+
+ // Append a mutation records.
+ scoped_refptr<MutationRecord> record =
+ MutationRecord::CreateCharacterDataMutationRecord(target,
+ "old_character_data");
+ observer->QueueMutationRecord(record);
+
+ // The queued record can be taken once.
+ records = observer->TakeRecords();
+ ASSERT_EQ(1, records.size());
+ ASSERT_EQ(records.at(0), record);
+ records = observer->TakeRecords();
+ EXPECT_TRUE(records.empty());
+}
+
+TEST_F(MutationObserverTest, Notify) {
+ scoped_refptr<dom::Element> target = CreateDiv();
+
+ // Create a new observer and queue a mutation record.
+ scoped_refptr<MutationObserver> observer = CreateObserver();
+ scoped_refptr<MutationRecord> record =
+ MutationRecord::CreateCharacterDataMutationRecord(target,
+ "old_character_data");
+ observer->QueueMutationRecord(record);
+
+ // Callback should be fired with the first argument being a sequence of the
+ // queued record, and the second argument being the observer.
+ MutationObserver::MutationRecordSequence records;
+ EXPECT_CALL(*callback_mock(), NativeMutationCallback(_, observer))
+ .WillOnce(SaveArg<0>(&records));
+ observer->Notify();
+ ASSERT_EQ(1, records.size());
+ EXPECT_EQ(record, records.at(0));
+
+ // There should be no more records queued up after the callback has been
+ // fired.
+ records = observer->TakeRecords();
+ EXPECT_TRUE(records.empty());
+}
+
+TEST_F(MutationObserverTest, ReportMutation) {
+ scoped_refptr<dom::Element> target = CreateDiv();
+ // Create a registered observer that cares about attribute and character data
+ // mutations.
+ scoped_refptr<MutationObserver> observer = CreateObserver();
+ MutationObserverInit init;
+ init.set_attributes(true);
+ init.set_child_list(false);
+ init.set_character_data(true);
+
+ // Create a MutationReporter for the list of registered observers.
+ scoped_ptr<std::vector<RegisteredObserver> > registered_observers(
+ new std::vector<RegisteredObserver>());
+ registered_observers->push_back(
+ RegisteredObserver(target.get(), observer, init));
+ MutationReporter reporter(target.get(), registered_observers.Pass());
+
+ // Report a few mutations.
+ reporter.ReportAttributesMutation("attribute_name", std::string("old_value"));
+ reporter.ReportCharacterDataMutation("old_character_data");
+ ChildListMutationArguments args = CreateChildListMutationArguments();
+ reporter.ReportChildListMutation(args.added_nodes, args.removed_nodes,
+ args.previous_sibling, args.next_sibling);
+
+ // Check that mutation records for the mutation types we care about have
+ // been queued.
+ MutationObserver::MutationRecordSequence records = observer->TakeRecords();
+ ASSERT_EQ(2, records.size());
+ EXPECT_EQ(records.at(0)->type(), "attribute");
+ EXPECT_EQ(records.at(1)->type(), "characterData");
+}
+
+TEST_F(MutationObserverTest, AttributeFilter) {
+ scoped_refptr<dom::Element> target = CreateDiv();
+ // Create a registered observer that cares about attribute and character data
+ // mutations.
+ scoped_refptr<MutationObserver> observer = CreateObserver();
+ MutationObserverInit init;
+ script::Sequence<std::string> attribute_filter;
+ attribute_filter.push_back("banana");
+ attribute_filter.push_back("potato");
+ init.set_attribute_filter(attribute_filter);
+ init.set_attributes(true);
+
+ // Create a MutationReporter for the list of registered observers.
+ scoped_ptr<std::vector<RegisteredObserver> > registered_observers(
+ new std::vector<RegisteredObserver>());
+ registered_observers->push_back(
+ RegisteredObserver(target.get(), observer, init));
+ MutationReporter reporter(target.get(), registered_observers.Pass());
+
+ // Report a few attribute mutations.
+ reporter.ReportAttributesMutation("banana", std::string("rotten"));
+ reporter.ReportAttributesMutation("apple", std::string("wormy"));
+ reporter.ReportAttributesMutation("potato", std::string("mashed"));
+
+ // Check that mutation records for the filtered attrbiutes have been queued.
+ MutationObserver::MutationRecordSequence records = observer->TakeRecords();
+ ASSERT_EQ(2, records.size());
+ EXPECT_STREQ(records.at(0)->attribute_name()->c_str(), "banana");
+ EXPECT_STREQ(records.at(1)->attribute_name()->c_str(), "potato");
+}
+
+TEST_F(MutationObserverTest, RegisteredObserverList) {
+ scoped_refptr<dom::Element> target = CreateDiv();
+ scoped_refptr<MutationObserver> observer = CreateObserver();
+
+ RegisteredObserverList observer_list(target.get());
+
+ // Add an observer with options.
+ MutationObserverInit options;
+ options.set_attributes(true);
+ EXPECT_TRUE(observer_list.AddMutationObserver(observer, options));
+ EXPECT_EQ(1, observer_list.registered_observers().size());
+ EXPECT_EQ(observer, observer_list.registered_observers()[0].observer());
+ EXPECT_TRUE(observer_list.registered_observers()[0].options().attributes());
+ EXPECT_FALSE(
+ observer_list.registered_observers()[0].options().has_character_data());
+ EXPECT_FALSE(observer_list.registered_observers()[0].options().child_list());
+
+ // Adding the same observer updates the options.
+ options = MutationObserverInit();
+ options.set_child_list(true);
+ EXPECT_TRUE(observer_list.AddMutationObserver(observer, options));
+ EXPECT_EQ(1, observer_list.registered_observers().size());
+ EXPECT_EQ(observer, observer_list.registered_observers()[0].observer());
+ EXPECT_FALSE(
+ observer_list.registered_observers()[0].options().has_attributes());
+ EXPECT_FALSE(
+ observer_list.registered_observers()[0].options().has_character_data());
+ EXPECT_TRUE(observer_list.registered_observers()[0].options().child_list());
+
+ // Remove the observer.
+ observer_list.RemoveMutationObserver(observer);
+ EXPECT_EQ(0, observer_list.registered_observers().size());
+}
+
+TEST_F(MutationObserverTest, LazilySetOptions) {
+ scoped_refptr<dom::Element> target = CreateDiv();
+ scoped_refptr<MutationObserver> observer = CreateObserver();
+
+ RegisteredObserverList observer_list(target.get());
+
+ // |attributes| gets set if an attribute-related option is set.
+ MutationObserverInit options;
+ options.set_attribute_old_value(true);
+ EXPECT_TRUE(observer_list.AddMutationObserver(observer, options));
+ EXPECT_EQ(1, observer_list.registered_observers().size());
+ EXPECT_TRUE(observer_list.registered_observers()[0].options().attributes());
+
+ // |character_data| gets set if an attribute-related option is set.
+ options = MutationObserverInit();
+ options.set_character_data_old_value(true);
+ EXPECT_TRUE(observer_list.AddMutationObserver(observer, options));
+ EXPECT_EQ(1, observer_list.registered_observers().size());
+ EXPECT_TRUE(
+ observer_list.registered_observers()[0].options().character_data());
+}
+
+TEST_F(MutationObserverTest, InvalidOptions) {
+ scoped_refptr<dom::Element> target = CreateDiv();
+ scoped_refptr<MutationObserver> observer = CreateObserver();
+
+ RegisteredObserverList observer_list(target.get());
+
+ // No type of mutation is set.
+ MutationObserverInit options;
+ EXPECT_FALSE(observer_list.AddMutationObserver(observer, options));
+ EXPECT_EQ(0, observer_list.registered_observers().size());
+
+ // |attributes| is set as false, but attribute old data is set.
+ options.set_attributes(false);
+ options.set_attribute_old_value(true);
+ EXPECT_FALSE(observer_list.AddMutationObserver(observer, options));
+ EXPECT_EQ(0, observer_list.registered_observers().size());
+
+ // |character_data| is set as false, but attribute old data is set.
+ options = MutationObserverInit();
+ options.set_character_data(false);
+ options.set_character_data_old_value(true);
+ EXPECT_FALSE(observer_list.AddMutationObserver(observer, options));
+ EXPECT_EQ(0, observer_list.registered_observers().size());
+}
+
+TEST_F(MutationObserverTest, AddChildNodes) {
+ scoped_refptr<Element> root = CreateDiv();
+ scoped_refptr<MutationObserver> observer = CreateObserver();
+ MutationObserverInit options;
+ options.set_subtree(true);
+ options.set_child_list(true);
+ observer->Observe(root, options);
+
+ scoped_refptr<Element> child1 = document()->CreateElement("div");
+ scoped_refptr<Element> child2 = document()->CreateElement("div");
+ ASSERT_TRUE(child1);
+ ASSERT_TRUE(child2);
+
+ root->AppendChild(child1);
+ child1->AppendChild(child2);
+
+ MutationObserver::MutationRecordSequence records = observer->TakeRecords();
+ ASSERT_EQ(2, records.size());
+ EXPECT_EQ("childList", records.at(0)->type());
+ EXPECT_EQ(root, records.at(0)->target());
+ ASSERT_FALSE(records.at(0)->removed_nodes());
+ ASSERT_TRUE(records.at(0)->added_nodes());
+ ASSERT_EQ(1, records.at(0)->added_nodes()->length());
+ EXPECT_EQ(child1, records.at(0)->added_nodes()->Item(0));
+
+ EXPECT_EQ("childList", records.at(1)->type());
+ EXPECT_EQ(child1, records.at(1)->target());
+ ASSERT_FALSE(records.at(1)->removed_nodes());
+ ASSERT_TRUE(records.at(1)->added_nodes());
+ ASSERT_EQ(1, records.at(1)->added_nodes()->length());
+ EXPECT_EQ(child2, records.at(1)->added_nodes()->Item(0));
+}
+
+TEST_F(MutationObserverTest, RemoveChildNode) {
+ scoped_refptr<Element> root = CreateDiv();
+ scoped_refptr<Element> child1 = document()->CreateElement("div");
+ scoped_refptr<Element> child2 = document()->CreateElement("div");
+ ASSERT_TRUE(child1);
+ ASSERT_TRUE(child2);
+
+ root->AppendChild(child1);
+ child1->AppendChild(child2);
+
+ scoped_refptr<MutationObserver> observer = CreateObserver();
+ MutationObserverInit options;
+ options.set_subtree(true);
+ options.set_child_list(true);
+ observer->Observe(root, options);
+
+ child1->RemoveChild(child2);
+
+ MutationObserver::MutationRecordSequence records = observer->TakeRecords();
+ ASSERT_EQ(1, records.size());
+ EXPECT_EQ("childList", records.at(0)->type());
+ EXPECT_EQ(child1, records.at(0)->target());
+ ASSERT_TRUE(records.at(0)->removed_nodes());
+ ASSERT_EQ(1, records.at(0)->removed_nodes()->length());
+ EXPECT_EQ(child2, records.at(0)->removed_nodes()->Item(0));
+}
+
+TEST_F(MutationObserverTest, MutateCharacterData) {
+ scoped_refptr<Element> root = CreateDiv();
+ scoped_refptr<Text> text = document()->CreateTextNode("initial-data");
+ ASSERT_TRUE(text);
+ root->AppendChild(text);
+
+ scoped_refptr<MutationObserver> observer = CreateObserver();
+ MutationObserverInit options;
+ options.set_subtree(true);
+ options.set_character_data(true);
+ observer->Observe(root, options);
+
+ text->set_data("new-data");
+
+ MutationObserver::MutationRecordSequence records = observer->TakeRecords();
+ ASSERT_EQ(1, records.size());
+ EXPECT_EQ("characterData", records.at(0)->type());
+ EXPECT_EQ(text, records.at(0)->target());
+ ASSERT_TRUE(records.at(0)->old_value());
+ EXPECT_STREQ("initial-data", records.at(0)->old_value()->c_str());
+}
+
+TEST_F(MutationObserverTest, MutateAttribute) {
+ scoped_refptr<Element> root = CreateDiv();
+ root->SetAttribute("banana", "purple");
+ root->SetAttribute("apple", "green");
+
+ scoped_refptr<MutationObserver> observer = CreateObserver();
+ script::Sequence<std::string> filter;
+ filter.push_back("banana");
+ MutationObserverInit options;
+ options.set_attributes(true);
+ options.set_attribute_filter(filter);
+ observer->Observe(root, options);
+
+ root->SetAttribute("banana", "yellow");
+ root->SetAttribute("apple", "brown");
+
+ MutationObserver::MutationRecordSequence records = observer->TakeRecords();
+ ASSERT_EQ(1, records.size());
+ EXPECT_EQ("attribute", records.at(0)->type());
+ EXPECT_EQ(root, records.at(0)->target());
+ ASSERT_TRUE(records.at(0)->old_value());
+ ASSERT_TRUE(records.at(0)->attribute_name());
+ EXPECT_STREQ("banana", records.at(0)->attribute_name()->c_str());
+ EXPECT_STREQ("purple", records.at(0)->old_value()->c_str());
+}
+
+TEST_F(MutationObserverTest, Disconnect) {
+ scoped_refptr<Element> root = CreateDiv();
+ scoped_refptr<Text> text = document()->CreateTextNode("initial-data");
+ ASSERT_TRUE(text);
+ root->AppendChild(text);
+
+ scoped_refptr<MutationObserver> observer = CreateObserver();
+ MutationObserverInit options;
+ options.set_subtree(true);
+ options.set_character_data(true);
+ observer->Observe(root, options);
+
+ // This should queue up a mutation record.
+ text->set_data("new-data");
+
+ observer->Disconnect();
+ MutationObserver::MutationRecordSequence records = observer->TakeRecords();
+ // MutationObserver.disconnect() should clear any queued records.
+ EXPECT_EQ(0, records.size());
+
+ // This should not queue a mutation record.
+ text->set_data("more-new-data");
+ records = observer->TakeRecords();
+ EXPECT_EQ(0, records.size());
+}
+
+} // namespace dom
+} // namespace cobalt
diff --git a/src/cobalt/dom/mutation_record.cc b/src/cobalt/dom/mutation_record.cc
new file mode 100644
index 0000000..31d6eb2
--- /dev/null
+++ b/src/cobalt/dom/mutation_record.cc
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2017 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.
+ */
+
+#include "cobalt/dom/mutation_record.h"
+
+#include "cobalt/dom/node.h"
+#include "cobalt/dom/node_list.h"
+
+namespace cobalt {
+namespace dom {
+
+scoped_refptr<MutationRecord> MutationRecord::CreateAttributeMutationRecord(
+ const scoped_refptr<Node>& target, const std::string& attribute_name,
+ const base::optional<std::string>& old_value) {
+ scoped_refptr<MutationRecord> record =
+ new MutationRecord(base::Tokens::attribute(), target);
+ record->attribute_name_ = attribute_name;
+ record->old_value_ = old_value;
+ return record;
+}
+
+scoped_refptr<MutationRecord> MutationRecord::CreateCharacterDataMutationRecord(
+ const scoped_refptr<Node>& target, const std::string& old_character_data) {
+ scoped_refptr<MutationRecord> record =
+ new MutationRecord(base::Tokens::characterData(), target);
+ record->old_value_ = old_character_data;
+ return record;
+}
+
+scoped_refptr<MutationRecord> MutationRecord::CreateChildListMutationRecord(
+ const scoped_refptr<Node>& target,
+ const scoped_refptr<dom::NodeList>& added_nodes,
+ const scoped_refptr<dom::NodeList>& removed_nodes,
+ const scoped_refptr<dom::Node>& previous_sibling,
+ const scoped_refptr<dom::Node>& next_sibling) {
+ scoped_refptr<MutationRecord> record =
+ new MutationRecord(base::Tokens::childList(), target);
+ record->added_nodes_ = added_nodes;
+ record->removed_nodes_ = removed_nodes;
+ record->previous_sibling_ = previous_sibling;
+ record->next_sibling_ = next_sibling;
+ return record;
+}
+
+MutationRecord::MutationRecord(const base::Token& type,
+ const scoped_refptr<Node>& target)
+ : type_(type), target_(target) {}
+MutationRecord::~MutationRecord() {}
+
+} // namespace dom
+} // namespace cobalt
diff --git a/src/cobalt/dom/mutation_record.h b/src/cobalt/dom/mutation_record.h
index cd43589..9c21010 100644
--- a/src/cobalt/dom/mutation_record.h
+++ b/src/cobalt/dom/mutation_record.h
@@ -20,30 +20,70 @@
#include <string>
#include "base/optional.h"
-#include "cobalt/dom/node.h"
-#include "cobalt/dom/node_list.h"
+#include "cobalt/base/token.h"
#include "cobalt/script/wrappable.h"
namespace cobalt {
namespace dom {
+class Node;
+class NodeList;
+
// MutationRecords are used with the MutationObserver interface to describe a
// mutation on the documnet.
// https://www.w3.org/TR/dom/#mutationrecord
class MutationRecord : public script::Wrappable {
public:
// Web API: MutationRecord
- std::string type() { return ""; }
- scoped_refptr<dom::Node> target() { return NULL; }
- scoped_refptr<dom::NodeList> added_nodes() { return NULL; }
- scoped_refptr<dom::NodeList> removed_nodes() { return NULL; }
- scoped_refptr<dom::Node> previous_sibling() { return NULL; }
- scoped_refptr<dom::Node> next_sibling() { return NULL; }
- base::optional<std::string> attribute_name() { return base::nullopt; }
- base::optional<std::string> attribute_namespace() { return base::nullopt; }
- base::optional<std::string> old_value() { return base::nullopt; }
+ const base::Token& type() { return type_; }
+ const scoped_refptr<dom::Node>& target() { return target_; }
+ const scoped_refptr<dom::NodeList>& added_nodes() { return added_nodes_; }
+ const scoped_refptr<dom::NodeList>& removed_nodes() { return removed_nodes_; }
+ const scoped_refptr<dom::Node>& previous_sibling() {
+ return previous_sibling_;
+ }
+ const scoped_refptr<dom::Node>& next_sibling() { return next_sibling_; }
+ const base::optional<std::string>& attribute_name() {
+ return attribute_name_;
+ }
+ const base::optional<std::string>& attribute_namespace() {
+ return attribute_namespace_;
+ }
+ const base::optional<std::string>& old_value() { return old_value_; }
+
+ // Not part of the MutationRecord interface. These create functions implement
+ // the part of the "queueing a mutation record" algorithm pertaining to
+ // creating a new Mutation Record (step 4).
+ // https://www.w3.org/TR/dom/#queue-a-mutation-record
+ static scoped_refptr<MutationRecord> CreateAttributeMutationRecord(
+ const scoped_refptr<Node>& target, const std::string& attribute_name,
+ const base::optional<std::string>& old_value);
+
+ static scoped_refptr<MutationRecord> CreateCharacterDataMutationRecord(
+ const scoped_refptr<Node>& target, const std::string& old_character_data);
+
+ static scoped_refptr<MutationRecord> CreateChildListMutationRecord(
+ const scoped_refptr<Node>& target,
+ const scoped_refptr<dom::NodeList>& added_nodes,
+ const scoped_refptr<dom::NodeList>& removed_nodes,
+ const scoped_refptr<dom::Node>& previous_sibling,
+ const scoped_refptr<dom::Node>& next_sibling);
DEFINE_WRAPPABLE_TYPE(MutationRecord);
+
+ private:
+ MutationRecord(const base::Token& type, const scoped_refptr<Node>& target);
+ ~MutationRecord();
+
+ base::Token type_;
+ scoped_refptr<dom::Node> target_;
+ scoped_refptr<dom::NodeList> added_nodes_;
+ scoped_refptr<dom::NodeList> removed_nodes_;
+ scoped_refptr<dom::Node> previous_sibling_;
+ scoped_refptr<dom::Node> next_sibling_;
+ base::optional<std::string> attribute_name_;
+ base::optional<std::string> attribute_namespace_;
+ base::optional<std::string> old_value_;
};
} // namespace dom
} // namespace cobalt
diff --git a/src/cobalt/dom/mutation_reporter.cc b/src/cobalt/dom/mutation_reporter.cc
new file mode 100644
index 0000000..28bb037
--- /dev/null
+++ b/src/cobalt/dom/mutation_reporter.cc
@@ -0,0 +1,203 @@
+/*
+ * Copyright 2017 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.
+ */
+
+#include "cobalt/dom/mutation_reporter.h"
+
+#include "base/hash_tables.h"
+#include "cobalt/dom/mutation_observer.h"
+#include "cobalt/dom/mutation_observer_init.h"
+#include "cobalt/dom/node.h"
+#include "cobalt/dom/node_list.h"
+
+namespace cobalt {
+namespace dom {
+namespace {
+
+// Internal helper class to determine if a registered observer cares about a
+// certain type of mutation, and for creating a mutation record for different
+// types of mutations.
+class MutationRecordBuilder {
+ public:
+ virtual bool IsInterested(const MutationObserverInit& options) = 0;
+ virtual scoped_refptr<MutationRecord> CreateMutationRecord(
+ const scoped_refptr<Node>& target) = 0;
+};
+
+// MutationRecordBuild for attribute mutations.
+class AttributeMutationRecordBuilder : public MutationRecordBuilder {
+ public:
+ AttributeMutationRecordBuilder(const std::string& attribute_name,
+ const base::optional<std::string>& old_value)
+ : attribute_name_(attribute_name), old_value_(old_value) {}
+
+ bool IsInterested(const MutationObserverInit& options) OVERRIDE {
+ // https://www.w3.org/TR/dom/#queue-a-mutation-record
+ // 2. If type is "attributes" and options's attributes is not true,
+ // continue.
+ if (!options.has_attributes() || !options.attributes()) {
+ return false;
+ }
+
+ // 3. If type is "attributes", options's attributeFilter is present,
+ // and either options's attributeFilter does not contain name or
+ // namespace is non-null, continue.
+ if (options.has_attribute_filter()) {
+ // Cobalt doesn't support namespaces, so ignore that part of step (2).
+ for (size_t i = 0; i < options.attribute_filter().size(); ++i) {
+ if (options.attribute_filter().at(i) == attribute_name_) {
+ return true;
+ }
+ }
+ return false;
+ }
+ return true;
+ }
+
+ scoped_refptr<MutationRecord> CreateMutationRecord(
+ const scoped_refptr<Node>& target) OVERRIDE {
+ return MutationRecord::CreateAttributeMutationRecord(
+ target, attribute_name_, old_value_);
+ }
+
+ private:
+ std::string attribute_name_;
+ base::optional<std::string> old_value_;
+};
+
+// MutationRecordBuild for character data mutations.
+class CharacterDataMutationRecordBuilder : public MutationRecordBuilder {
+ public:
+ explicit CharacterDataMutationRecordBuilder(
+ const std::string& old_character_data)
+ : old_character_data_(old_character_data) {}
+
+ bool IsInterested(const MutationObserverInit& options) OVERRIDE {
+ // https://www.w3.org/TR/dom/#queue-a-mutation-record
+ // 4. If type is "characterData" and options's characterData is not true,
+ // continue.
+ return options.has_character_data() && options.character_data();
+ }
+ scoped_refptr<MutationRecord> CreateMutationRecord(
+ const scoped_refptr<Node>& target) OVERRIDE {
+ return MutationRecord::CreateCharacterDataMutationRecord(
+ target, old_character_data_);
+ }
+
+ private:
+ std::string old_character_data_;
+};
+
+// MutationRecordBuild for child list mutations.
+class ChildListMutationRecordBuilder : public MutationRecordBuilder {
+ public:
+ ChildListMutationRecordBuilder(
+ const scoped_refptr<dom::NodeList>& added_nodes,
+ const scoped_refptr<dom::NodeList>& removed_nodes,
+ const scoped_refptr<dom::Node>& previous_sibling,
+ const scoped_refptr<dom::Node>& next_sibling)
+ : added_nodes_(added_nodes),
+ removed_nodes_(removed_nodes),
+ previous_sibling_(previous_sibling),
+ next_sibling_(next_sibling) {}
+
+ bool IsInterested(const MutationObserverInit& options) OVERRIDE {
+ // https://www.w3.org/TR/dom/#queue-a-mutation-record
+ // 5. If type is "childList" and options's childList is false, continue.
+ return options.child_list();
+ }
+
+ scoped_refptr<MutationRecord> CreateMutationRecord(
+ const scoped_refptr<Node>& target) OVERRIDE {
+ return MutationRecord::CreateChildListMutationRecord(
+ target, added_nodes_, removed_nodes_, previous_sibling_, next_sibling_);
+ }
+
+ private:
+ scoped_refptr<dom::NodeList> added_nodes_;
+ scoped_refptr<dom::NodeList> removed_nodes_;
+ scoped_refptr<dom::Node> previous_sibling_;
+ scoped_refptr<dom::Node> next_sibling_;
+};
+
+// Iterate through |registered_observers| and create a new MutationRecord via
+// |record_builder| for interested observers.
+void ReportToInterestedObservers(
+ const scoped_refptr<Node>& target,
+ MutationReporter::RegisteredObserverVector* registered_observers,
+ MutationRecordBuilder* record_builder) {
+ typedef base::hash_set<MutationObserver*> MutationObserverSet;
+ MutationObserverSet reported_observers;
+ for (size_t i = 0; i < registered_observers->size(); ++i) {
+ const RegisteredObserver& registered_observer = registered_observers->at(i);
+ MutationObserver* observer = registered_observer.observer().get();
+ const MutationObserverInit& options = registered_observer.options();
+
+ // The mutation has already been reported to this observer, so skip it, per
+ // step 3.6 (https://www.w3.org/TR/dom/#queue-a-mutation-record)
+ if (reported_observers.find(observer) != reported_observers.end()) {
+ continue;
+ }
+
+ // https://www.w3.org/TR/dom/#queue-a-mutation-record
+ // 1. If node is not target and options's subtree is false, continue.
+ if (registered_observer.target() != target && !options.subtree()) {
+ continue;
+ }
+ // This observer doesn't care about this mutation, so skip it.
+ if (!record_builder->IsInterested(options)) {
+ continue;
+ }
+ // Queue a mutation record on the observer.
+ observer->QueueMutationRecord(record_builder->CreateMutationRecord(target));
+ reported_observers.insert(observer);
+ }
+}
+
+} // namespace
+
+MutationReporter::MutationReporter(
+ dom::Node* target,
+ scoped_ptr<RegisteredObserverVector> registered_observers)
+ : target_(target), observers_(registered_observers.Pass()) {}
+
+MutationReporter::~MutationReporter() {}
+
+// Implement the "queue a mutation record" algorithm.
+// https://www.w3.org/TR/dom/#queue-a-mutation-record
+void MutationReporter::ReportAttributesMutation(
+ const std::string& name,
+ const base::optional<std::string>& old_value) const {
+ AttributeMutationRecordBuilder record_builder(name, old_value);
+ ReportToInterestedObservers(target_, observers_.get(), &record_builder);
+}
+
+void MutationReporter::ReportCharacterDataMutation(
+ const std::string& old_value) const {
+ CharacterDataMutationRecordBuilder record_builder(old_value);
+ ReportToInterestedObservers(target_, observers_.get(), &record_builder);
+}
+
+void MutationReporter::ReportChildListMutation(
+ const scoped_refptr<dom::NodeList>& added_nodes,
+ const scoped_refptr<dom::NodeList>& removed_nodes,
+ const scoped_refptr<dom::Node>& previous_sibling,
+ const scoped_refptr<dom::Node>& next_sibling) const {
+ ChildListMutationRecordBuilder record_builder(added_nodes, removed_nodes,
+ previous_sibling, next_sibling);
+ ReportToInterestedObservers(target_, observers_.get(), &record_builder);
+}
+} // namespace dom
+} // namespace cobalt
diff --git a/src/cobalt/dom/mutation_reporter.h b/src/cobalt/dom/mutation_reporter.h
new file mode 100644
index 0000000..d8ccda3
--- /dev/null
+++ b/src/cobalt/dom/mutation_reporter.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2017 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.
+ */
+
+#ifndef COBALT_DOM_MUTATION_REPORTER_H_
+#define COBALT_DOM_MUTATION_REPORTER_H_
+
+#include <string>
+#include <vector>
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "cobalt/dom/registered_observer.h"
+
+namespace cobalt {
+namespace dom {
+
+class Node;
+class NodeList;
+
+// Helper class that reports a mutation to interested MutationObservers
+// according to the "queue a mutation record" algorithm:
+// https://www.w3.org/TR/dom/#queue-a-mutation-record
+//
+// This class is intended to be used internally in the Node class.
+class MutationReporter {
+ public:
+ typedef std::vector<RegisteredObserver> RegisteredObserverVector;
+ // Construct a MutationReporter with a list of potentially interested
+ // RegisteredObservers. In practice, this list of |registered_observers| will
+ // the RegisteredObservers registered to the node that is being mutated and
+ // its ancestors. |registered_observers| may contain duplicates.
+ MutationReporter(dom::Node* target,
+ scoped_ptr<RegisteredObserverVector> registered_observers);
+
+ ~MutationReporter();
+
+ // Implement the "queue a mutation record" algorithm for the different types
+ // of mutations.
+ void ReportAttributesMutation(
+ const std::string& name,
+ const base::optional<std::string>& old_value) const;
+ void ReportCharacterDataMutation(const std::string& old_value) const;
+ void ReportChildListMutation(
+ const scoped_refptr<dom::NodeList>& added_nodes,
+ const scoped_refptr<dom::NodeList>& removed_nodes,
+ const scoped_refptr<dom::Node>& previous_sibling,
+ const scoped_refptr<dom::Node>& next_sibling) const;
+
+ private:
+ dom::Node* target_;
+ scoped_ptr<RegisteredObserverVector> observers_;
+};
+} // namespace dom
+} // namespace cobalt
+#endif // COBALT_DOM_MUTATION_REPORTER_H_
diff --git a/src/cobalt/dom/node.cc b/src/cobalt/dom/node.cc
index b82b0c0..f6c6b69 100644
--- a/src/cobalt/dom/node.cc
+++ b/src/cobalt/dom/node.cc
@@ -32,6 +32,7 @@
#include "cobalt/dom/global_stats.h"
#include "cobalt/dom/html_collection.h"
#include "cobalt/dom/html_element_context.h"
+#include "cobalt/dom/mutation_reporter.h"
#include "cobalt/dom/node_descendants_iterator.h"
#include "cobalt/dom/node_list.h"
#include "cobalt/dom/node_list_live.h"
@@ -287,11 +288,26 @@
node->AdoptIntoDocument(node_document_);
// 10. Remove child from its parent with the suppress observers flag set.
- Remove(child);
+ Remove(child, true);
// 11. Insert node into parent before reference child with the suppress
// observers flag set.
- Insert(node, reference_child);
+ Insert(node, reference_child, true);
+
+ // 12. Let nodes be node's children if node is a DocumentFragment node, and a
+ // list containing solely node otherwise.
+ // 13. Queue a mutation record of "childList" for target parent with
+ // addedNodes nodes, removedNodes a list solely containing child, nextSibling
+ // reference child, and previousSibling child's previous sibling.
+ MutationReporter mutation_reporter(this, GatherInclusiveAncestorsObservers());
+ scoped_refptr<dom::NodeList> added_nodes = new dom::NodeList();
+ added_nodes->AppendNode(node);
+ scoped_refptr<dom::NodeList> removed_nodes = new dom::NodeList();
+ removed_nodes->AppendNode(child);
+ mutation_reporter.ReportChildListMutation(
+ added_nodes, removed_nodes,
+ child->previous_sibling_ /* previous_sibling */,
+ reference_child /* next_sibling */);
return child;
}
@@ -427,7 +443,8 @@
previous_sibling_(NULL),
last_child_(NULL),
inserted_into_document_(false),
- node_generation_(kInitialNodeGeneration) {
+ node_generation_(kInitialNodeGeneration),
+ ALLOW_THIS_IN_INITIALIZER_LIST(registered_observers_(this)) {
DCHECK(node_document_);
++(node_count_log.Get().count);
GlobalStats::GetInstance()->Add(this);
@@ -508,6 +525,21 @@
}
}
+scoped_ptr<Node::RegisteredObserverVector>
+Node::GatherInclusiveAncestorsObservers() {
+ scoped_ptr<RegisteredObserverVector> inclusive_observers(
+ new RegisteredObserverVector());
+ Node* current = this;
+ while (current) {
+ const RegisteredObserverList::RegisteredObserverVector& node_observers =
+ current->registered_observers_.registered_observers();
+ inclusive_observers->insert(inclusive_observers->end(),
+ node_observers.begin(), node_observers.end());
+ current = current->parent_;
+ }
+ return inclusive_observers.Pass();
+}
+
// Algorithm for EnsurePreInsertionValidity:
// https://www.w3.org/TR/dom/#concept-node-ensure-pre-insertion-validity
bool Node::EnsurePreInsertionValidity(const scoped_refptr<Node>& node,
@@ -577,7 +609,7 @@
// 4. Adopt node into parent's node document.
// 5. Insert node into parent before reference child.
node->AdoptIntoDocument(node_document_);
- Insert(node, child == node ? child->next_sibling_ : child);
+ Insert(node, child == node ? child->next_sibling_ : child, false);
// 6. Return node.
return node;
@@ -586,16 +618,35 @@
// Algorithm for Insert:
// https://www.w3.org/TR/dom/#concept-node-insert
void Node::Insert(const scoped_refptr<Node>& node,
- const scoped_refptr<Node>& child) {
+ const scoped_refptr<Node>& child, bool suppress_observers) {
// 1. 2. Not needed by Cobalt.
// 3. Let nodes be node's children if node is a DocumentFragment node, and a
// list containing solely node otherwise.
- // 4. ~ 6. Not needed by Cobalt.
+ // 4. 5. Not needed by Cobalt.
+ // 6. If suppress observers flag is unset, queue a mutation record of
+ // "childList" for parent with addedNodes nodes, nextSibling child, and
+ // previousSibling child's previous sibling or parent's last child if
+ // child is null.
// 7. For each newNode in nodes, in tree order, run these substeps:
// 1. Insert newNode into parent before child or at the end of parent if
// child is null.
// 2. Run the insertion steps with newNode.
+ if (!suppress_observers) {
+ scoped_ptr<RegisteredObserverVector> observers =
+ GatherInclusiveAncestorsObservers();
+ if (!observers->empty()) {
+ MutationReporter mutation_reporter(this, observers.Pass());
+ scoped_refptr<dom::NodeList> added_nodes = new dom::NodeList();
+ added_nodes->AppendNode(node);
+ mutation_reporter.ReportChildListMutation(
+ added_nodes, NULL, child && child->previous_sibling_
+ ? child->previous_sibling_
+ : this->last_child_ /* previous_sibling */,
+ child /* next_sibling */);
+ }
+ }
+
node->parent_ = this;
scoped_refptr<Node> next_sibling = child;
@@ -646,7 +697,7 @@
}
// 2. Remove child from parent.
- Remove(child);
+ Remove(child, false);
// 3. Return child.
return child;
@@ -654,7 +705,7 @@
// Algorithm for Remove:
// https://www.w3.org/TR/dom/#concept-node-remove
-void Node::Remove(const scoped_refptr<Node>& node) {
+void Node::Remove(const scoped_refptr<Node>& node, bool suppress_observers) {
DCHECK(node);
OnMutation();
@@ -674,10 +725,34 @@
node->OnRemovedFromDocument();
}
- // 1. ~ 8. Not needed by Cobalt.
+ // 1. 5. Not needed by Cobalt.
+ // 6. Let oldPreviousSibling be node's previous sibling
+ // 7. If suppress observers flag is unset, queue a mutation record of
+ // "childList" for parent with removedNodes a list solely containing node,
+ // nextSibling node's next sibling, and previousSibling oldPreviousSibling.
+ // 8. For each ancestor ancestor of node, if ancestor has any registered
+ // observers whose options's subtree is true, then for each such registered
+ // observer registered, append a transient registered observer whose observer
+ // and options are identical to those of registered and source which is
+ // registered to node's list of registered observers.
// 9. Remove node from its parent.
// 10. Run the removing steps with node, parent, and oldPreviousSibling.
+ scoped_ptr<RegisteredObserverVector> observers =
+ GatherInclusiveAncestorsObservers();
+ if (!observers->empty()) {
+ // Step 7 - Queue a mutation record.
+ if (!suppress_observers) {
+ MutationReporter mutation_reporter(this, observers.Pass());
+ scoped_refptr<dom::NodeList> removed_nodes = new dom::NodeList();
+ removed_nodes->AppendNode(node);
+ mutation_reporter.ReportChildListMutation(
+ NULL, removed_nodes, node->previous_sibling_ /* previous_sibling */,
+ node->next_sibling_ /* next_sibling */);
+ }
+ // TODO: transient registered observers.
+ }
+
if (node->previous_sibling_) {
node->previous_sibling_->next_sibling_ = node->next_sibling_;
} else {
diff --git a/src/cobalt/dom/node.h b/src/cobalt/dom/node.h
index 7e349d6..17f35e2 100644
--- a/src/cobalt/dom/node.h
+++ b/src/cobalt/dom/node.h
@@ -18,12 +18,16 @@
#define COBALT_DOM_NODE_H_
#include <string>
+#include <vector>
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "cobalt/base/token.h"
#include "cobalt/dom/event_target.h"
+#include "cobalt/dom/mutation_observer.h"
+#include "cobalt/dom/mutation_observer_init.h"
+#include "cobalt/dom/registered_observer_list.h"
namespace cobalt {
namespace dom {
@@ -222,6 +226,15 @@
// descendents.
void PurgeCachedResourceReferencesRecursively();
+ bool RegisterMutationObserver(const scoped_refptr<MutationObserver>& observer,
+ const MutationObserverInit& options) {
+ return registered_observers_.AddMutationObserver(observer, options);
+ }
+ void UnregisterMutationObserver(
+ const scoped_refptr<MutationObserver>& observer) {
+ registered_observers_.RemoveMutationObserver(observer);
+ }
+
DEFINE_WRAPPABLE_TYPE(Node);
protected:
@@ -255,6 +268,10 @@
// Triggers a generation update in this node and all its ancestor nodes.
void UpdateGenerationForNodeAndAncestors();
+ // Gather a list of RegisteredObservers on this node and its ancestors.
+ typedef std::vector<RegisteredObserver> RegisteredObserverVector;
+ scoped_ptr<RegisteredObserverVector> GatherInclusiveAncestorsObservers();
+
private:
// From EventTarget.
std::string GetDebugName() OVERRIDE { return node_name().c_str(); }
@@ -268,11 +285,11 @@
scoped_refptr<Node> PreInsert(const scoped_refptr<Node>& node,
const scoped_refptr<Node>& child);
- void Insert(const scoped_refptr<Node>& node,
- const scoped_refptr<Node>& child);
+ void Insert(const scoped_refptr<Node>& node, const scoped_refptr<Node>& child,
+ bool suppress_observers);
scoped_refptr<Node> PreRemove(const scoped_refptr<Node>& child);
- void Remove(const scoped_refptr<Node>& node);
+ void Remove(const scoped_refptr<Node>& node, bool suppress_observers);
// Called everytime mutation happens, i.e. when a child is inserted or removed
// from this node.
@@ -293,6 +310,8 @@
scoped_refptr<Node> first_child_;
scoped_refptr<Node> next_sibling_;
+ RegisteredObserverList registered_observers_;
+
DISALLOW_COPY_AND_ASSIGN(Node);
};
diff --git a/src/cobalt/dom/node_dispatch_event_test.cc b/src/cobalt/dom/node_dispatch_event_test.cc
index 2051305..95b223c 100644
--- a/src/cobalt/dom/node_dispatch_event_test.cc
+++ b/src/cobalt/dom/node_dispatch_event_test.cc
@@ -59,7 +59,7 @@
NodeDispatchEventTest::NodeDispatchEventTest()
: html_element_context_(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, "") {
+ NULL, NULL, NULL, NULL, NULL, "") {
EXPECT_TRUE(GlobalStats::GetInstance()->CheckNoLeaks());
document_ = new Document(&html_element_context_);
diff --git a/src/cobalt/dom/node_list_live_test.cc b/src/cobalt/dom/node_list_live_test.cc
index e3f757f..1ec534e 100644
--- a/src/cobalt/dom/node_list_live_test.cc
+++ b/src/cobalt/dom/node_list_live_test.cc
@@ -30,7 +30,7 @@
NodeListLiveTest()
: dom_stat_tracker_("NodeListLiveTest"),
html_element_context_(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, &dom_stat_tracker_, ""),
+ NULL, NULL, NULL, NULL, &dom_stat_tracker_, ""),
document_(new Document(&html_element_context_)) {}
~NodeListLiveTest() OVERRIDE {}
diff --git a/src/cobalt/dom/node_list_test.cc b/src/cobalt/dom/node_list_test.cc
index c2e7b9a..3b52082 100644
--- a/src/cobalt/dom/node_list_test.cc
+++ b/src/cobalt/dom/node_list_test.cc
@@ -30,7 +30,8 @@
NodeListTest()
: dom_stat_tracker_(new DomStatTracker("NodeListTest")),
html_element_context_(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, dom_stat_tracker_.get(), ""),
+ NULL, NULL, NULL, NULL, dom_stat_tracker_.get(),
+ ""),
document_(new Document(&html_element_context_)) {}
~NodeListTest() OVERRIDE {}
diff --git a/src/cobalt/dom/node_test.cc b/src/cobalt/dom/node_test.cc
index a4abe5e..d7e6eda 100644
--- a/src/cobalt/dom/node_test.cc
+++ b/src/cobalt/dom/node_test.cc
@@ -78,7 +78,7 @@
NodeTest::NodeTest()
: html_element_context_(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, "") {
+ NULL, NULL, NULL, NULL, NULL, "") {
EXPECT_TRUE(GlobalStats::GetInstance()->CheckNoLeaks());
document_ = new Document(&html_element_context_);
diff --git a/src/cobalt/dom/registered_observer.h b/src/cobalt/dom/registered_observer.h
new file mode 100644
index 0000000..ec46bf8
--- /dev/null
+++ b/src/cobalt/dom/registered_observer.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2017 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.
+ */
+
+#ifndef COBALT_DOM_REGISTERED_OBSERVER_H_
+#define COBALT_DOM_REGISTERED_OBSERVER_H_
+
+#include "base/memory/ref_counted.h"
+#include "cobalt/dom/mutation_observer.h"
+#include "cobalt/dom/mutation_observer_init.h"
+
+namespace cobalt {
+namespace dom {
+
+class Node;
+
+// Represents the concept of a "registered observer" as described in the
+// Mutation Observer spec.
+// https://www.w3.org/TR/dom/#registered-observer
+// This class is expected to be used internally in the Node class as a part of
+// mutation reporting.
+class RegisteredObserver {
+ public:
+ // A RegisteredObserver must not outlive the |target| node that is being
+ // observed.
+ RegisteredObserver(const Node* target,
+ const scoped_refptr<MutationObserver>& observer,
+ const MutationObserverInit& options)
+ : target_(target), observer_(observer), options_(options) {}
+
+ const scoped_refptr<MutationObserver>& observer() const { return observer_; }
+ const MutationObserverInit& options() const { return options_; }
+ void set_options(const MutationObserverInit& options) { options_ = options; }
+ const Node* target() const { return target_; }
+
+ private:
+ const Node* target_;
+ scoped_refptr<MutationObserver> observer_;
+ MutationObserverInit options_;
+};
+} // namespace dom
+} // namespace cobalt
+#endif // COBALT_DOM_REGISTERED_OBSERVER_H_
diff --git a/src/cobalt/dom/registered_observer_list.cc b/src/cobalt/dom/registered_observer_list.cc
new file mode 100644
index 0000000..4e86008
--- /dev/null
+++ b/src/cobalt/dom/registered_observer_list.cc
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2017 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.
+ */
+
+#include "cobalt/dom/registered_observer_list.h"
+
+namespace cobalt {
+namespace dom {
+namespace {
+// This algorithm is part of the description of the observe() method. It may
+// modify |options| and returns false if a TypeError should be thrown.
+// https://www.w3.org/TR/dom/#dom-mutationobserver-observe
+bool InitializeOptions(MutationObserverInit* options) {
+ if (options->has_attribute_old_value() || options->has_attribute_filter()) {
+ // 1. If either options' attributeOldValue or attributeFilter is present and
+ // options' attributes is omitted, set options' attributes to true.
+ if (!options->has_attributes()) {
+ options->set_attributes(true);
+ }
+ // 4. If options' attributeOldValue is true and options' attributes is
+ // false, throw a JavaScript TypeError.
+ // 5. If options' attributeFilter is present and options' attributes is
+ // false, throw a JavaScript TypeError.
+ if (!options->attributes()) {
+ return false;
+ }
+ }
+ if (options->has_character_data_old_value()) {
+ // 2. If options' characterDataOldValue is present and options'
+ // characterData is omitted, set options' characterData to true.
+ if (!options->has_character_data()) {
+ options->set_character_data(true);
+ }
+ // 6. If options' characterDataOldValue is true and options' characterData
+ // is false, throw a JavaScript TypeError.
+ if (!options->character_data()) {
+ return false;
+ }
+ }
+ // 3. If none of options' childList attributes, and characterData is true,
+ // throw a TypeError.
+ const bool child_list = options->child_list();
+ const bool attributes = options->has_attributes() && options->attributes();
+ const bool character_data =
+ options->has_character_data() && options->character_data();
+ if (!(child_list || attributes || character_data)) {
+ return false;
+ }
+ return true;
+}
+} // namespace
+
+bool RegisteredObserverList::AddMutationObserver(
+ const scoped_refptr<MutationObserver>& observer,
+ const MutationObserverInit& const_options) {
+ MutationObserverInit options(const_options);
+ if (!InitializeOptions(&options)) {
+ return false;
+ }
+ // https://www.w3.org/TR/dom/#dom-mutationobserver-observe
+ // 7. For each registered observer registered in target's list of registered
+ // observers whose observer is the context object:
+ // 1. Remove all transient registered observers whose source is
+ // registered.
+ // 2. Replace registered's options with options.
+ typedef RegisteredObserverVector::iterator RegisteredObserverIterator;
+ for (RegisteredObserverIterator it = registered_observers_.begin();
+ it != registered_observers_.end(); ++it) {
+ // TODO: Remove transient registered observers.
+ if (it->observer() == observer) {
+ it->set_options(options);
+ return true;
+ }
+ }
+ // 8. Otherwise, add a new registered observer to target's list of registered
+ // observers with the context object as the observer and options as the
+ // options, and add target to context object's list of nodes on which it is
+ // registered.
+ registered_observers_.push_back(
+ RegisteredObserver(target_, observer, options));
+ return true;
+}
+
+void RegisteredObserverList::RemoveMutationObserver(
+ const scoped_refptr<MutationObserver>& observer) {
+ typedef RegisteredObserverVector::iterator RegisteredObserverIterator;
+ for (RegisteredObserverIterator it = registered_observers_.begin();
+ it != registered_observers_.end(); ++it) {
+ if (it->observer() == observer) {
+ registered_observers_.erase(it);
+ return;
+ }
+ }
+ NOTREACHED() << "Did not find a mutation observer to unregister.";
+}
+} // namespace dom
+} // namespace cobalt
diff --git a/src/cobalt/dom/registered_observer_list.h b/src/cobalt/dom/registered_observer_list.h
new file mode 100644
index 0000000..8ab2365
--- /dev/null
+++ b/src/cobalt/dom/registered_observer_list.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2017 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.
+ */
+
+#ifndef COBALT_DOM_REGISTERED_OBSERVER_LIST_H_
+#define COBALT_DOM_REGISTERED_OBSERVER_LIST_H_
+
+#include <vector>
+
+#include "base/memory/ref_counted.h"
+#include "cobalt/dom/mutation_observer.h"
+#include "cobalt/dom/mutation_observer_init.h"
+#include "cobalt/dom/registered_observer.h"
+
+namespace cobalt {
+namespace dom {
+
+class Node;
+
+// A list of "registered observers" as described in the Mutation Observer spec.
+// https://www.w3.org/TR/dom/#registered-observer
+//
+// Implements the functionality described in the MutationObserver.observe
+// method:
+// https://www.w3.org/TR/dom/#dom-mutationobserver-observe
+class RegisteredObserverList {
+ public:
+ typedef std::vector<RegisteredObserver> RegisteredObserverVector;
+
+ // A RegisteredObserverList must not outlive the |target| node that is being
+ // observed.
+ explicit RegisteredObserverList(const Node* target) : target_(target) {}
+
+ // Implement the MutationObserver.observe method
+ // https://www.w3.org/TR/dom/#dom-mutationobserver-observe
+ bool AddMutationObserver(const scoped_refptr<MutationObserver>& observer,
+ const MutationObserverInit& options);
+ void RemoveMutationObserver(const scoped_refptr<MutationObserver>& observer);
+
+ const RegisteredObserverVector& registered_observers() {
+ return registered_observers_;
+ }
+
+ private:
+ const Node* target_;
+ RegisteredObserverVector registered_observers_;
+};
+} // namespace dom
+} // namespace cobalt
+#endif // COBALT_DOM_REGISTERED_OBSERVER_LIST_H_
diff --git a/src/cobalt/dom/rule_matching_test.cc b/src/cobalt/dom/rule_matching_test.cc
index c8b1135..faf8f73 100644
--- a/src/cobalt/dom/rule_matching_test.cc
+++ b/src/cobalt/dom/rule_matching_test.cc
@@ -45,7 +45,7 @@
dom_parser_(new dom_parser::Parser()),
dom_stat_tracker_(new DomStatTracker("RuleMatchingTest")),
html_element_context_(NULL, css_parser_.get(), dom_parser_.get(), NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
dom_stat_tracker_.get(), ""),
document_(new Document(&html_element_context_)),
root_(document_->CreateElement("html")->AsHTMLElement()) {
diff --git a/src/cobalt/dom/serializer_test.cc b/src/cobalt/dom/serializer_test.cc
index dedcbe1..e6ccd63 100644
--- a/src/cobalt/dom/serializer_test.cc
+++ b/src/cobalt/dom/serializer_test.cc
@@ -47,7 +47,8 @@
: dom_parser_(new dom_parser::Parser()),
dom_stat_tracker_(new DomStatTracker("SerializerTest")),
html_element_context_(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, dom_stat_tracker_.get(), ""),
+ NULL, NULL, NULL, NULL, dom_stat_tracker_.get(),
+ ""),
document_(new Document(&html_element_context_)),
root_(new Element(document_, base::Token("root"))),
source_location_(base::SourceLocation("[object SerializerTest]", 1, 1)) {}
diff --git a/src/cobalt/dom/text_test.cc b/src/cobalt/dom/text_test.cc
index 5b504b8..381e24c 100644
--- a/src/cobalt/dom/text_test.cc
+++ b/src/cobalt/dom/text_test.cc
@@ -41,7 +41,7 @@
TextTest::TextTest()
: html_element_context_(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, "") {
+ NULL, NULL, NULL, NULL, NULL, "") {
EXPECT_TRUE(GlobalStats::GetInstance()->CheckNoLeaks());
document_ = new Document(&html_element_context_);
}
diff --git a/src/cobalt/dom/window.cc b/src/cobalt/dom/window.cc
index 57ee8a5..25b6106 100644
--- a/src/cobalt/dom/window.cc
+++ b/src/cobalt/dom/window.cc
@@ -68,6 +68,7 @@
loader::image::ReducedCacheCapacityManager*
reduced_image_cache_capacity_manager,
loader::font::RemoteTypefaceCache* remote_typeface_cache,
+ loader::mesh::MeshCache* mesh_cache,
LocalStorageDatabase* local_storage_database,
media::CanPlayTypeHandler* can_play_type_handler,
media::WebMediaPlayerFactory* web_media_player_factory,
@@ -91,7 +92,7 @@
fetcher_factory, css_parser, dom_parser, can_play_type_handler,
web_media_player_factory, script_runner, media_source_registry,
resource_provider, image_cache, reduced_image_cache_capacity_manager,
- remote_typeface_cache, dom_stat_tracker, language)),
+ remote_typeface_cache, mesh_cache, dom_stat_tracker, language)),
performance_(new Performance(new base::SystemMonotonicClock())),
ALLOW_THIS_IN_INITIALIZER_LIST(document_(new Document(
html_element_context_.get(),
diff --git a/src/cobalt/dom/window.h b/src/cobalt/dom/window.h
index 8e48bc7..30a57d9 100644
--- a/src/cobalt/dom/window.h
+++ b/src/cobalt/dom/window.h
@@ -34,6 +34,7 @@
#include "cobalt/dom/event_target.h"
#include "cobalt/dom/media_query_list.h"
#include "cobalt/dom/media_source.h"
+#include "cobalt/dom/mutation_observer_task_manager.h"
#include "cobalt/dom/parser.h"
#include "cobalt/network_bridge/cookie_jar.h"
#include "cobalt/network_bridge/net_poster.h"
@@ -46,6 +47,7 @@
#include "cobalt/loader/font/remote_typeface_cache.h"
#include "cobalt/loader/image/image_cache.h"
#include "cobalt/loader/loader.h"
+#include "cobalt/loader/mesh/mesh_cache.h"
#include "cobalt/media/can_play_type_handler.h"
#include "cobalt/media/web_media_player_factory.h"
#include "cobalt/script/callback_function.h"
@@ -92,6 +94,7 @@
loader::image::ReducedCacheCapacityManager*
reduced_image_cache_capacity_manager,
loader::font::RemoteTypefaceCache* remote_typeface_cache,
+ loader::mesh::MeshCache* mesh_cache,
LocalStorageDatabase* local_storage_database,
media::CanPlayTypeHandler* can_play_type_handler,
media::WebMediaPlayerFactory* web_media_player_factory,
diff --git a/src/cobalt/dom/window_test.cc b/src/cobalt/dom/window_test.cc
index 8879146..fe10614 100644
--- a/src/cobalt/dom/window_test.cc
+++ b/src/cobalt/dom/window_test.cc
@@ -53,7 +53,7 @@
url_("about:blank"),
window_(new Window(
1920, 1080, css_parser_.get(), dom_parser_.get(),
- fetcher_factory_.get(), NULL, NULL, NULL, NULL,
+ fetcher_factory_.get(), NULL, NULL, NULL, NULL, NULL,
&local_storage_database_, stub_media_module_.get(),
stub_media_module_.get(), NULL, NULL, NULL, NULL, url_, "", "en-US",
base::Callback<void(const GURL &)>(),
diff --git a/src/cobalt/dom/xml_document_test.cc b/src/cobalt/dom/xml_document_test.cc
index 4603520..e2e48a4 100644
--- a/src/cobalt/dom/xml_document_test.cc
+++ b/src/cobalt/dom/xml_document_test.cc
@@ -27,7 +27,7 @@
TEST(XMLDocumentTest, IsXMLDocument) {
HTMLElementContext html_element_context(NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL,
- "");
+ NULL, "");
scoped_refptr<Document> document = new XMLDocument(&html_element_context);
EXPECT_TRUE(document->IsXMLDocument());
}
diff --git a/src/cobalt/dom_parser/html_decoder_test.cc b/src/cobalt/dom_parser/html_decoder_test.cc
index 1aed737..9770fab 100644
--- a/src/cobalt/dom_parser/html_decoder_test.cc
+++ b/src/cobalt/dom_parser/html_decoder_test.cc
@@ -70,7 +70,7 @@
dom_parser_.get(), NULL /* can_play_type_handler */,
NULL /* web_media_player_factory */,
&stub_script_runner_, NULL, NULL, NULL, NULL, NULL,
- dom_stat_tracker_.get(), ""),
+ NULL, dom_stat_tracker_.get(), ""),
document_(
new dom::Document(&html_element_context_, dom::Document::Options())),
root_(new dom::Element(document_, base::Token("element"))),
diff --git a/src/cobalt/dom_parser/xml_decoder_test.cc b/src/cobalt/dom_parser/xml_decoder_test.cc
index e7336eb..218885b 100644
--- a/src/cobalt/dom_parser/xml_decoder_test.cc
+++ b/src/cobalt/dom_parser/xml_decoder_test.cc
@@ -51,7 +51,7 @@
XMLDecoderTest::XMLDecoderTest()
: html_element_context_(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, ""),
+ NULL, NULL, NULL, NULL, NULL, ""),
document_(new dom::XMLDocument(&html_element_context_)),
source_location_(base::SourceLocation("[object XMLDecoderTest]", 1, 1)) {}
diff --git a/src/cobalt/h5vcc/H5vcc.idl b/src/cobalt/h5vcc/H5vcc.idl
index 6a24827..0e16d13 100644
--- a/src/cobalt/h5vcc/H5vcc.idl
+++ b/src/cobalt/h5vcc/H5vcc.idl
@@ -36,4 +36,5 @@
readonly attribute H5vccSettings settings;
readonly attribute H5vccStorage storage;
readonly attribute H5vccSystem system;
+ readonly attribute H5vccTraceEvent traceEvent;
};
diff --git a/src/cobalt/h5vcc/H5vccTraceEvent.idl b/src/cobalt/h5vcc/H5vccTraceEvent.idl
new file mode 100644
index 0000000..4e64778
--- /dev/null
+++ b/src/cobalt/h5vcc/H5vccTraceEvent.idl
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2017 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.
+ */
+
+interface H5vccTraceEvent {
+ void start();
+ void stop();
+
+ void traceBegin(DOMString category, DOMString name);
+ void traceEnd(DOMString category, DOMString name);
+
+ void traceIntBegin(DOMString category, DOMString name,
+ DOMString arg1_name, long arg1_value);
+ void traceIntEnd(DOMString category, DOMString name,
+ DOMString arg1_name, long arg1_value);
+
+ void traceFloatBegin(DOMString category, DOMString name,
+ DOMString arg1_name, float arg1_value);
+ void traceFloatEnd(DOMString category, DOMString name,
+ DOMString arg1_name, float arg1_value);
+
+ void traceStringBegin(DOMString category, DOMString name,
+ DOMString arg1_name, DOMString arg1_value);
+ void traceStringEnd(DOMString category, DOMString name,
+ DOMString arg1_name, DOMString arg1_value);
+};
diff --git a/src/cobalt/h5vcc/h5vcc.cc b/src/cobalt/h5vcc/h5vcc.cc
index b220382..cb4633e 100644
--- a/src/cobalt/h5vcc/h5vcc.cc
+++ b/src/cobalt/h5vcc/h5vcc.cc
@@ -28,6 +28,7 @@
settings_ = new H5vccSettings(settings.media_module);
storage_ = new H5vccStorage(settings.network_module);
system_ = new H5vccSystem(settings.media_module);
+ trace_event_ = new H5vccTraceEvent();
}
} // namespace h5vcc
diff --git a/src/cobalt/h5vcc/h5vcc.gyp b/src/cobalt/h5vcc/h5vcc.gyp
index c208fd0..d23ac7c 100644
--- a/src/cobalt/h5vcc/h5vcc.gyp
+++ b/src/cobalt/h5vcc/h5vcc.gyp
@@ -52,6 +52,8 @@
'h5vcc_storage.h',
'h5vcc_system.cc',
'h5vcc_system.h',
+ 'h5vcc_trace_event.cc',
+ 'h5vcc_trace_event.h',
],
'dependencies': [
'<(DEPTH)/cobalt/build/cobalt_build_id.gyp:cobalt_build_id',
diff --git a/src/cobalt/h5vcc/h5vcc.h b/src/cobalt/h5vcc/h5vcc.h
index 369cad3..6f09230 100644
--- a/src/cobalt/h5vcc/h5vcc.h
+++ b/src/cobalt/h5vcc/h5vcc.h
@@ -27,6 +27,7 @@
#include "cobalt/h5vcc/h5vcc_settings.h"
#include "cobalt/h5vcc/h5vcc_storage.h"
#include "cobalt/h5vcc/h5vcc_system.h"
+#include "cobalt/h5vcc/h5vcc_trace_event.h"
#include "cobalt/script/wrappable.h"
namespace cobalt {
@@ -59,6 +60,9 @@
const scoped_refptr<H5vccSettings>& settings() const { return settings_; }
const scoped_refptr<H5vccStorage>& storage() const { return storage_; }
const scoped_refptr<H5vccSystem>& system() const { return system_; }
+ const scoped_refptr<H5vccTraceEvent>& trace_event() const {
+ return trace_event_;
+ }
DEFINE_WRAPPABLE_TYPE(H5vcc);
@@ -70,6 +74,7 @@
scoped_refptr<H5vccSettings> settings_;
scoped_refptr<H5vccStorage> storage_;
scoped_refptr<H5vccSystem> system_;
+ scoped_refptr<H5vccTraceEvent> trace_event_;
DISALLOW_COPY_AND_ASSIGN(H5vcc);
};
diff --git a/src/cobalt/h5vcc/h5vcc_trace_event.cc b/src/cobalt/h5vcc/h5vcc_trace_event.cc
new file mode 100644
index 0000000..ca43293
--- /dev/null
+++ b/src/cobalt/h5vcc/h5vcc_trace_event.cc
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2017 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.
+ */
+
+#include "cobalt/h5vcc/h5vcc_trace_event.h"
+
+namespace cobalt {
+namespace h5vcc {
+
+namespace {
+const char* kOutputTraceFilename = "h5vcc_trace_event.json";
+} // namespace
+
+H5vccTraceEvent::H5vccTraceEvent() {}
+
+void H5vccTraceEvent::Start() {
+ if (trace_to_file_) {
+ DLOG(WARNING) << "H5vccTraceEvent is already started.";
+ } else {
+ trace_to_file_.reset(
+ new trace_event::ScopedTraceToFile(FilePath(kOutputTraceFilename)));
+ }
+}
+
+void H5vccTraceEvent::Stop() {
+ if (trace_to_file_) {
+ trace_to_file_.reset();
+ } else {
+ DLOG(WARNING) << "H5vccTraceEvent is already stopped.";
+ }
+}
+
+} // namespace h5vcc
+} // namespace cobalt
diff --git a/src/cobalt/h5vcc/h5vcc_trace_event.h b/src/cobalt/h5vcc/h5vcc_trace_event.h
new file mode 100644
index 0000000..f3e45f6
--- /dev/null
+++ b/src/cobalt/h5vcc/h5vcc_trace_event.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2017 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.
+ */
+
+#ifndef COBALT_H5VCC_H5VCC_TRACE_EVENT_H_
+#define COBALT_H5VCC_H5VCC_TRACE_EVENT_H_
+
+#include <string>
+
+#include "base/debug/trace_event.h"
+#include "cobalt/script/wrappable.h"
+#include "cobalt/trace_event/scoped_trace_to_file.h"
+
+namespace cobalt {
+namespace h5vcc {
+
+#define TRACE_EVENT0_FOR_EACH(MacroOp) \
+ MacroOp(Begin, BEGIN) \
+ MacroOp(End, END) \
+
+#define DEFINE_H5VCC_TRACE_EVENT0(Name, FunctionName) \
+ void Trace##Name(const std::string& category, const std::string& name) { \
+ UNREFERENCED_PARAMETER(category); \
+ UNREFERENCED_PARAMETER(name); \
+ TRACE_EVENT_COPY_##FunctionName##0(category.c_str(), name.c_str()); \
+ }
+
+#define TRACE_EVENT1_FOR_EACH(MacroOp) \
+ MacroOp(IntBegin, BEGIN, int32) \
+ MacroOp(IntEnd, END, int32) \
+ MacroOp(FloatBegin, BEGIN, float) \
+ MacroOp(FloatEnd, END, float) \
+ MacroOp(StringBegin, BEGIN, const std::string&) \
+ MacroOp(StringEnd, END, const std::string&)
+
+#define DEFINE_H5VCC_TRACE_EVENT1(TraceName, FunctionName, CppType) \
+ void Trace##TraceName(const std::string& category, const std::string& name, \
+ const std::string& arg1_name, CppType arg1_value) { \
+ UNREFERENCED_PARAMETER(category); \
+ UNREFERENCED_PARAMETER(name); \
+ UNREFERENCED_PARAMETER(arg1_name); \
+ UNREFERENCED_PARAMETER(arg1_value); \
+ TRACE_EVENT_COPY_##FunctionName##1(category.c_str(), name.c_str(), \
+ arg1_name.c_str(), arg1_value); \
+ }
+
+class H5vccTraceEvent : public script::Wrappable {
+ public:
+ H5vccTraceEvent();
+
+ void Start();
+ void Stop();
+
+ TRACE_EVENT0_FOR_EACH(DEFINE_H5VCC_TRACE_EVENT0)
+ TRACE_EVENT1_FOR_EACH(DEFINE_H5VCC_TRACE_EVENT1)
+
+ DEFINE_WRAPPABLE_TYPE(H5vccTraceEvent);
+
+ private:
+ // This object can be set to start a trace.
+ // While initialized, it means that a trace is on-going.
+ scoped_ptr<trace_event::ScopedTraceToFile> trace_to_file_;
+
+ DISALLOW_COPY_AND_ASSIGN(H5vccTraceEvent);
+};
+
+#undef DEFINE_H5VCC_TRACE_EVENT0
+#undef TRACE_EVENT0_FOR_EACH
+#undef DEFINE_H5VCC_TRACE_EVENT1
+#undef TRACE_EVENT1_FOR_EACH
+
+} // namespace h5vcc
+} // namespace cobalt
+
+#endif // COBALT_H5VCC_H5VCC_TRACE_EVENT_H_
diff --git a/src/cobalt/layout/layout_manager.cc b/src/cobalt/layout/layout_manager.cc
index 1639aa5..aa2f4d9 100644
--- a/src/cobalt/layout/layout_manager.cc
+++ b/src/cobalt/layout/layout_manager.cc
@@ -108,8 +108,10 @@
: window_(window),
locale_(icu::Locale::createCanonical(language.c_str())),
used_style_provider_(
- new UsedStyleProvider(window->html_element_context()->image_cache(),
- window->document()->font_cache())),
+ new UsedStyleProvider(window->html_element_context(),
+ window->html_element_context()->image_cache(),
+ window->document()->font_cache(),
+ window->html_element_context()->mesh_cache())),
on_render_tree_produced_callback_(on_render_tree_produced),
layout_trigger_(layout_trigger),
layout_dirty_(StringPrintf("%s.Layout.IsDirty", name.c_str()), true,
diff --git a/src/cobalt/layout/replaced_box.cc b/src/cobalt/layout/replaced_box.cc
index 7bcb96a..0163f06 100644
--- a/src/cobalt/layout/replaced_box.cc
+++ b/src/cobalt/layout/replaced_box.cc
@@ -20,6 +20,7 @@
#include "base/bind.h"
#include "base/logging.h"
+#include "cobalt/base/polymorphic_downcast.h"
#include "cobalt/cssom/filter_function_list_value.h"
#include "cobalt/cssom/keyword_value.h"
#include "cobalt/cssom/mtm_function.h"
@@ -284,13 +285,34 @@
const cssom::MTMFunction* mtm_filter_function =
cssom::MTMFunction::ExtractFromFilterList(computed_style()->filter());
- Node* content_node;
+ Node* content_node = NULL;
if (mtm_filter_function) {
+ const cssom::MTMFunction::MeshSpec& spec = mtm_filter_function->mesh_spec();
const scoped_refptr<cssom::KeywordValue>& stereo_mode_keyword_value =
mtm_filter_function->stereo_mode();
render_tree::StereoMode stereo_mode =
ReadStereoMode(stereo_mode_keyword_value);
- content_node = new FilterNode(MapToMeshFilter(stereo_mode), frame_node);
+
+ if (spec.mesh_type() == cssom::MTMFunction::kUrls) {
+ // Custom mesh URLs.
+ cssom::URLValue* url_value =
+ base::polymorphic_downcast<cssom::URLValue*>(spec.mesh_url().get());
+ GURL url(url_value->value());
+ scoped_refptr<render_tree::Mesh> mesh(
+ used_style_provider()->ResolveURLToMesh(url));
+
+ DCHECK(mesh) << "Could not load mesh specified by map-to-mesh filter.";
+
+ content_node =
+ new FilterNode(MapToMeshFilter(stereo_mode, mesh), frame_node);
+ } else if (spec.mesh_type() == cssom::MTMFunction::kEquirectangular) {
+ // Default equirectangular mesh.
+ content_node = new FilterNode(MapToMeshFilter(stereo_mode), frame_node);
+ } else {
+ NOTREACHED() << "Invalid mesh specification type. Expected"
+ "'equirectangular' keyword or list of URLs.";
+ content_node = frame_node;
+ }
} else {
content_node = frame_node;
}
diff --git a/src/cobalt/layout/used_style.cc b/src/cobalt/layout/used_style.cc
index 26cc44d..0464bf9 100644
--- a/src/cobalt/layout/used_style.cc
+++ b/src/cobalt/layout/used_style.cc
@@ -40,6 +40,7 @@
#include "cobalt/cssom/transform_function_visitor.h"
#include "cobalt/cssom/transform_matrix_function_value.h"
#include "cobalt/cssom/translate_function.h"
+#include "cobalt/loader/mesh/mesh_cache.h"
#include "cobalt/math/transform_2d.h"
#include "cobalt/render_tree/brush.h"
#include "cobalt/render_tree/composition_node.h"
@@ -406,9 +407,14 @@
} // namespace
-UsedStyleProvider::UsedStyleProvider(loader::image::ImageCache* image_cache,
- dom::FontCache* font_cache)
- : image_cache_(image_cache), font_cache_(font_cache) {}
+UsedStyleProvider::UsedStyleProvider(
+ dom::HTMLElementContext* html_element_context,
+ loader::image::ImageCache* image_cache, dom::FontCache* font_cache,
+ loader::mesh::MeshCache* mesh_cache)
+ : html_element_context_(html_element_context),
+ image_cache_(image_cache),
+ font_cache_(font_cache),
+ mesh_cache_(mesh_cache) {}
scoped_refptr<dom::FontList> UsedStyleProvider::GetUsedFontList(
const scoped_refptr<cssom::PropertyValue>& font_family_refptr,
@@ -465,6 +471,12 @@
return image_cache_->CreateCachedResource(url)->TryGetResource();
}
+scoped_refptr<render_tree::Mesh> UsedStyleProvider::ResolveURLToMesh(
+ const GURL& url) {
+ DCHECK(mesh_cache_);
+ return mesh_cache_->CreateCachedResource(url)->TryGetResource();
+}
+
void UsedStyleProvider::CleanupAfterLayout() {
// Clear out the last font properties prior to requesting that the font cache
// process inactive font lists. The reason for this is that the font cache
diff --git a/src/cobalt/layout/used_style.h b/src/cobalt/layout/used_style.h
index 8c964a1..b3212c9 100644
--- a/src/cobalt/layout/used_style.h
+++ b/src/cobalt/layout/used_style.h
@@ -27,12 +27,14 @@
#include "cobalt/cssom/transform_matrix.h"
#include "cobalt/dom/font_cache.h"
#include "cobalt/dom/font_list.h"
+#include "cobalt/dom/html_element_context.h"
#include "cobalt/layout/layout_unit.h"
#include "cobalt/layout/size_layout_unit.h"
#include "cobalt/loader/image/image_cache.h"
#include "cobalt/math/size.h"
#include "cobalt/math/size_f.h"
#include "cobalt/render_tree/color_rgba.h"
+#include "cobalt/render_tree/mesh.h"
#include "cobalt/render_tree/node.h"
#include "cobalt/render_tree/resource_provider.h"
#include "cobalt/render_tree/rounded_corners.h"
@@ -56,8 +58,10 @@
class UsedStyleProvider {
public:
- UsedStyleProvider(loader::image::ImageCache* image_cache,
- dom::FontCache* font_cache);
+ UsedStyleProvider(dom::HTMLElementContext* html_element_context,
+ loader::image::ImageCache* image_cache,
+ dom::FontCache* font_cache,
+ loader::mesh::MeshCache* mesh_cache = NULL);
scoped_refptr<dom::FontList> GetUsedFontList(
const scoped_refptr<cssom::PropertyValue>& font_family_refptr,
@@ -66,19 +70,26 @@
const scoped_refptr<cssom::PropertyValue>& font_weight_refptr);
scoped_refptr<render_tree::Image> ResolveURLToImage(const GURL& url);
+ scoped_refptr<render_tree::Mesh> ResolveURLToMesh(const GURL& url);
bool has_image_cache(const loader::image::ImageCache* image_cache) const {
return image_cache == image_cache_;
}
+ dom::HTMLElementContext* html_element_context() const {
+ return html_element_context_;
+ }
+
private:
// Called after layout is completed so that it can perform any necessary
// cleanup. Its primary current purpose is making a request to the font cache
// to remove any font lists that are no longer being referenced by boxes.
void CleanupAfterLayout();
+ dom::HTMLElementContext* html_element_context_;
loader::image::ImageCache* const image_cache_;
dom::FontCache* const font_cache_;
+ loader::mesh::MeshCache* const mesh_cache_;
// |font_list_key_| is retained in between lookups so that the font names
// vector will not need to allocate elements each time that it is populated.
diff --git a/src/cobalt/loader/blob_fetcher.cc b/src/cobalt/loader/blob_fetcher.cc
index d6a48b8..4118206 100644
--- a/src/cobalt/loader/blob_fetcher.cc
+++ b/src/cobalt/loader/blob_fetcher.cc
@@ -29,9 +29,8 @@
resolver_callback_(resolver_callback),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
DCHECK(!resolver_callback_.is_null());
- MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&BlobFetcher::Fetch, weak_ptr_factory_.GetWeakPtr()));
+
+ Fetch();
}
void BlobFetcher::Fetch() {
diff --git a/src/cobalt/loader/loader.gyp b/src/cobalt/loader/loader.gyp
index 45f5be4..3dd867c 100644
--- a/src/cobalt/loader/loader.gyp
+++ b/src/cobalt/loader/loader.gyp
@@ -58,6 +58,7 @@
'loader_factory.cc',
'loader_factory.h',
'loader_types.h',
+ 'mesh/mesh_cache.h',
'mesh/mesh_decoder.cc',
'mesh/mesh_decoder.h',
'mesh/projection_codec/constants.h',
@@ -172,6 +173,7 @@
'sources': [
'<(input_directory)/splash_screen.css',
'<(input_directory)/splash_screen.html',
+ '<(input_directory)/splash_screen.js',
'<(input_directory)/you_tube_logo.png',
],
'actions': [
@@ -184,7 +186,7 @@
'outputs': [
'<(output_path)',
],
- 'action': ['python', '<(script_path)', 'LoaderEmbeddedResources', '<(input_directory)', '<(output_path)'],
+ 'action': ['python', '<(script_path)', 'LoaderEmbeddedResources', '<(output_path)', '<(input_directory)'],
'message': 'Embedding layout resources in "<(input_directory)" into header file, "<(output_path)".',
},
],
diff --git a/src/cobalt/loader/mesh/mesh_cache.h b/src/cobalt/loader/mesh/mesh_cache.h
new file mode 100644
index 0000000..4e01047
--- /dev/null
+++ b/src/cobalt/loader/mesh/mesh_cache.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2017 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.
+ */
+
+#ifndef COBALT_LOADER_MESH_MESH_CACHE_H_
+#define COBALT_LOADER_MESH_MESH_CACHE_H_
+
+#include <string>
+
+#include "cobalt/loader/loader_factory.h"
+#include "cobalt/loader/resource_cache.h"
+#include "cobalt/render_tree/mesh.h"
+
+namespace cobalt {
+namespace loader {
+namespace mesh {
+
+// |MeshResourceCacheType| provides the types and implements the functions
+// required by |ResourceCache<MeshResourceCacheType>|
+struct MeshResourceCacheType {
+ typedef render_tree::Mesh ResourceType;
+
+ static uint32 GetEstimatedSizeInBytes(
+ const scoped_refptr<ResourceType>& resource) {
+ return resource->GetEstimatedSizeInBytes();
+ }
+};
+
+typedef CachedResource<MeshResourceCacheType> CachedMesh;
+typedef CachedResourceReferenceWithCallbacks<MeshResourceCacheType>
+ CachedMeshReferenceWithCallbacks;
+typedef CachedMeshReferenceWithCallbacks::CachedResourceReferenceVector
+ CachedMeshReferenceVector;
+
+typedef ResourceCache<MeshResourceCacheType> MeshCache;
+
+// CreateMeshCache() provides a mechanism for creating an |MeshCache|.
+inline static scoped_ptr<MeshCache> CreateMeshCache(
+ const std::string& name, uint32 cache_capacity,
+ loader::LoaderFactory* loader_factory) {
+ return make_scoped_ptr<MeshCache>(new MeshCache(
+ name, cache_capacity, base::Bind(&loader::LoaderFactory::CreateMeshLoader,
+ base::Unretained(loader_factory))));
+}
+
+} // namespace mesh
+} // namespace loader
+} // namespace cobalt
+
+#endif // COBALT_LOADER_MESH_MESH_CACHE_H_
diff --git a/src/cobalt/loader/mesh/mesh_decoder.cc b/src/cobalt/loader/mesh/mesh_decoder.cc
index 7333776..5b41f44 100644
--- a/src/cobalt/loader/mesh/mesh_decoder.cc
+++ b/src/cobalt/loader/mesh/mesh_decoder.cc
@@ -74,6 +74,7 @@
scoped_ptr<MeshCollection> mesh_collection_;
std::vector<render_tree::Mesh::Vertex> mesh_vertices_;
render_tree::Mesh::DrawMode mesh_draw_mode_;
+ uint32 crc_;
DISALLOW_COPY_AND_ASSIGN(MeshDecoderSink);
};
@@ -84,7 +85,7 @@
MeshDecoderSink::~MeshDecoderSink() {}
bool MeshDecoderSink::IsCached(uint32 crc) {
- UNREFERENCED_PARAMETER(crc);
+ crc_ = crc;
return false;
}
@@ -140,7 +141,7 @@
void MeshDecoderSink::EndMeshInstance() {
mesh_collection_->push_back(scoped_refptr<render_tree::Mesh>(
- new render_tree::Mesh(mesh_vertices_, mesh_draw_mode_)));
+ new render_tree::Mesh(mesh_vertices_, mesh_draw_mode_, crc_)));
}
void MeshDecoderSink::EndMeshCollection() {
@@ -215,9 +216,9 @@
return;
}
- if (raw_data_->size() == 0) {
- // Mesh projection boxes cannot be empty, since they are BMFF boxes and
- // carry at least a size and type 4cc.
+ if (raw_data_->size() <= 4) {
+ // Mesh projection boxes cannot be empty, since they carry at least the
+ // version and flags.
error_callback_.Run("MeshDecoder passed an empty buffer, cannot decode.");
return;
}
@@ -225,8 +226,9 @@
std::string error_string;
MeshDecoderSink::MeshCollectionList mesh_collection_list;
- if (MeshDecoderSink::Decode(&raw_data_->at(0), raw_data_->size(),
- &mesh_collection_list)) {
+ if (MeshDecoderSink::DecodeBoxContents(
+ 0, 0, &raw_data_->at(4), // Skip version and flags.
+ raw_data_->size(), &mesh_collection_list)) {
scoped_refptr<render_tree::Mesh> mesh =
MeshDecoderSink::ExtractSingleMesh(mesh_collection_list);
diff --git a/src/cobalt/loader/mesh/mesh_decoder.h b/src/cobalt/loader/mesh/mesh_decoder.h
index d11e210..1558acd 100644
--- a/src/cobalt/loader/mesh/mesh_decoder.h
+++ b/src/cobalt/loader/mesh/mesh_decoder.h
@@ -41,6 +41,15 @@
const SuccessCallback& success_callback,
const ErrorCallback& error_callback);
+ // This function is used for binding a callback to create a MeshDecoder.
+ static scoped_ptr<Decoder> Create(
+ render_tree::ResourceProvider* resource_provider,
+ const SuccessCallback& success_callback,
+ const ErrorCallback& error_callback) {
+ return scoped_ptr<Decoder>(
+ new MeshDecoder(resource_provider, success_callback, error_callback));
+ }
+
// From Decoder.
void DecodeChunk(const char* data, size_t size) OVERRIDE;
void Finish() OVERRIDE;
diff --git a/src/cobalt/loader/resource_cache.h b/src/cobalt/loader/resource_cache.h
index d829a35..335c90c 100644
--- a/src/cobalt/loader/resource_cache.h
+++ b/src/cobalt/loader/resource_cache.h
@@ -144,6 +144,8 @@
void RunCallbacks(CallbackType type);
+ void EnableCompletionCallbacks();
+
const GURL url_;
scoped_refptr<ResourceType> resource_;
@@ -154,6 +156,14 @@
base::ThreadChecker cached_resource_thread_checker_;
+ // In some cases (such as when the resource input data is stored in memory),
+ // completion callbacks (e.g. resource fetch success/failure) could be
+ // triggered from within the resource initialization callstack, and we are
+ // not prepared to handle that. These members let us ensure that we are fully
+ // initialized before we proceed with any completion callbacks.
+ bool completion_callbacks_enabled_;
+ base::Closure completion_callback_;
+
DISALLOW_COPY_AND_ASSIGN(CachedResource);
};
@@ -207,7 +217,9 @@
const GURL& url, const csp::SecurityCallback& security_callback,
const CreateLoaderFunction& create_loader_function,
ResourceCacheType* resource_cache)
- : url_(url), resource_cache_(resource_cache) {
+ : url_(url),
+ resource_cache_(resource_cache),
+ completion_callbacks_enabled_(false) {
DCHECK(cached_resource_thread_checker_.CalledOnValidThread());
loader_ = create_loader_function.Run(
@@ -220,7 +232,10 @@
CachedResource<CacheType>::CachedResource(const GURL& url,
ResourceType* resource,
ResourceCacheType* resource_cache)
- : url_(url), resource_(resource), resource_cache_(resource_cache) {
+ : url_(url),
+ resource_(resource),
+ resource_cache_(resource_cache),
+ completion_callbacks_enabled_(false) {
DCHECK(cached_resource_thread_checker_.CalledOnValidThread());
}
@@ -256,8 +271,14 @@
resource_ = resource;
loader_.reset();
- resource_cache_->NotifyResourceLoadingComplete(this,
- kOnLoadingSuccessCallbackType);
+
+ completion_callback_ =
+ base::Bind(&ResourceCacheType::NotifyResourceLoadingComplete,
+ base::Unretained(resource_cache_), base::Unretained(this),
+ kOnLoadingSuccessCallbackType);
+ if (completion_callbacks_enabled_) {
+ completion_callback_.Run();
+ }
}
template <typename CacheType>
@@ -267,8 +288,13 @@
LOG(WARNING) << "Error while loading '" << url_ << "': " << error;
loader_.reset();
- resource_cache_->NotifyResourceLoadingComplete(this,
- kOnLoadingErrorCallbackType);
+ completion_callback_ =
+ base::Bind(&ResourceCacheType::NotifyResourceLoadingComplete,
+ base::Unretained(resource_cache_), base::Unretained(this),
+ kOnLoadingErrorCallbackType);
+ if (completion_callbacks_enabled_) {
+ completion_callback_.Run();
+ }
}
template <typename CacheType>
@@ -304,6 +330,14 @@
}
}
+template <typename CacheType>
+void CachedResource<CacheType>::EnableCompletionCallbacks() {
+ completion_callbacks_enabled_ = true;
+ if (!completion_callback_.is_null()) {
+ completion_callback_.Run();
+ }
+}
+
//////////////////////////////////////////////////////////////////////////
// CachedResourceReferenceWithCallbacks
//////////////////////////////////////////////////////////////////////////
@@ -563,6 +597,12 @@
url, security_callback_, create_loader_function_, this));
cached_resource_map_.insert(
std::make_pair(url.spec(), cached_resource.get()));
+
+ // Only now that we are finished initializing |cached_resource|, allow
+ // completion callbacks to proceed. This can be an issue for resources that
+ // load and decode synchronously and immediately.
+ cached_resource->EnableCompletionCallbacks();
+
return cached_resource;
}
diff --git a/src/cobalt/loader/testdata/projection.box b/src/cobalt/loader/testdata/projection.box
index 22a3bb5..1e5cdff 100644
--- a/src/cobalt/loader/testdata/projection.box
+++ b/src/cobalt/loader/testdata/projection.box
Binary files differ
diff --git a/src/cobalt/network/starboard/user_agent_string_factory_starboard.cc b/src/cobalt/network/starboard/user_agent_string_factory_starboard.cc
index 1c18737..9c00b58 100644
--- a/src/cobalt/network/starboard/user_agent_string_factory_starboard.cc
+++ b/src/cobalt/network/starboard/user_agent_string_factory_starboard.cc
@@ -88,6 +88,11 @@
case kSbSystemDeviceTypeTV:
youtube_tv_info_->device_type = YouTubeTVInfo::kTV;
break;
+#if SB_API_VERSION >= SB_EXPERIMENTAL_API_VERSION
+ case kSbSystemDeviceTypeAndroidTV:
+ youtube_tv_info_->device_type = YouTubeTVInfo::kAndroidTV;
+ break;
+#endif // SB_API_VERSION >= SB_EXPERIMENTAL_API_VERSION
case kSbSystemDeviceTypeDesktopPC:
default:
youtube_tv_info_->device_type = YouTubeTVInfo::kInvalidDeviceType;
diff --git a/src/cobalt/network/user_agent_string_factory.cc b/src/cobalt/network/user_agent_string_factory.cc
index 77a7628..12fe0ef 100644
--- a/src/cobalt/network/user_agent_string_factory.cc
+++ b/src/cobalt/network/user_agent_string_factory.cc
@@ -109,6 +109,10 @@
return "STB";
case YouTubeTVInfo::kTV:
return "TV";
+#if SB_API_VERSION >= SB_EXPERIMENTAL_API_VERSION
+ case YouTubeTVInfo::kAndroidTV:
+ return "ATV";
+#endif // SB_API_VERSION >= SB_EXPERIMENTAL_API_VERSION
case YouTubeTVInfo::kInvalidDeviceType:
default:
NOTREACHED();
diff --git a/src/cobalt/network/user_agent_string_factory.h b/src/cobalt/network/user_agent_string_factory.h
index b391595..8d73c3b 100644
--- a/src/cobalt/network/user_agent_string_factory.h
+++ b/src/cobalt/network/user_agent_string_factory.h
@@ -48,6 +48,9 @@
struct YouTubeTVInfo {
enum DeviceType {
kInvalidDeviceType,
+#if SB_API_VERSION >= SB_EXPERIMENTAL_API_VERSION
+ kAndroidTV,
+#endif // SB_API_VERSION >= SB_EXPERIMENTAL_API_VERSION
kBlueRayDiskPlayer,
kGameConsole,
kOverTheTopBox,
diff --git a/src/cobalt/render_tree/map_to_mesh_filter.h b/src/cobalt/render_tree/map_to_mesh_filter.h
index 0f996fa..29448d5 100644
--- a/src/cobalt/render_tree/map_to_mesh_filter.h
+++ b/src/cobalt/render_tree/map_to_mesh_filter.h
@@ -19,6 +19,7 @@
#include "base/logging.h"
#include "base/memory/ref_counted.h"
+#include "cobalt/render_tree/mesh.h"
namespace cobalt {
namespace render_tree {
@@ -26,16 +27,21 @@
enum StereoMode { kMono, kLeftRight, kTopBottom };
// A MapToMeshFilter can be used to map source content onto a 3D mesh, within a
-// specified well-defined viewport.
+// specified well-defined viewport. A null mesh indicates the equirectangular
+// mesh should be used.
class MapToMeshFilter {
public:
- explicit MapToMeshFilter(const StereoMode stereo_mode)
- : stereo_mode_(stereo_mode) {}
+ explicit MapToMeshFilter(const StereoMode stereo_mode,
+ scoped_refptr<render_tree::Mesh> mesh = NULL)
+ : stereo_mode_(stereo_mode), mesh_(mesh) {}
StereoMode GetStereoMode() const { return stereo_mode_; }
+ scoped_refptr<render_tree::Mesh> mesh() const { return mesh_; }
+
private:
StereoMode stereo_mode_;
+ scoped_refptr<render_tree::Mesh> mesh_;
};
} // namespace render_tree
diff --git a/src/cobalt/render_tree/mesh.h b/src/cobalt/render_tree/mesh.h
index 334bd60..25c1def 100644
--- a/src/cobalt/render_tree/mesh.h
+++ b/src/cobalt/render_tree/mesh.h
@@ -22,6 +22,7 @@
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
+#include "base/optional.h"
#include "starboard/types.h"
#include "third_party/glm/glm/vec2.hpp"
#include "third_party/glm/glm/vec3.hpp"
@@ -52,18 +53,25 @@
kDrawModeTriangleFan = 6
};
- Mesh(const std::vector<Vertex>& vertices, const DrawMode mode)
- : vertices_(vertices), draw_mode_(CheckDrawMode(mode)) {}
+ Mesh(const std::vector<Vertex>& vertices, const DrawMode mode,
+ base::optional<uint32> crc = base::nullopt)
+ : vertices_(vertices), draw_mode_(CheckDrawMode(mode)), crc_(crc) {}
const std::vector<Vertex>& vertices() const { return vertices_; }
DrawMode draw_mode() const { return draw_mode_; }
+ const base::optional<uint32>& crc() const { return crc_; }
+
uint32 GetEstimatedSizeInBytes() const {
return static_cast<uint32>(vertices().size() * sizeof(Vertex) +
sizeof(DrawMode));
}
+ bool HasSameCrcAs(scoped_refptr<Mesh> other_mesh) const {
+ return other_mesh && other_mesh->crc() == crc_;
+ }
+
protected:
virtual ~Mesh() {}
@@ -86,6 +94,9 @@
const std::vector<Vertex> vertices_;
const DrawMode draw_mode_;
+ // Cyclic Redundancy Check code of the mesh projection box that contains this
+ // mesh.
+ const base::optional<uint32> crc_;
};
} // namespace render_tree
diff --git a/src/cobalt/renderer/backend/egl/graphics_context.cc b/src/cobalt/renderer/backend/egl/graphics_context.cc
index fabca63..c3ab6cd 100644
--- a/src/cobalt/renderer/backend/egl/graphics_context.cc
+++ b/src/cobalt/renderer/backend/egl/graphics_context.cc
@@ -64,7 +64,7 @@
// Create a dummy EGLSurface object to be assigned as the target surface
// when we need to make OpenGL calls that do not depend on a surface (e.g.
// creating a texture).
- null_surface_ = new PBufferRenderTargetEGL(display, config, math::Size(1, 1));
+ null_surface_ = new PBufferRenderTargetEGL(display, config, math::Size(0, 0));
ScopedMakeCurrent scoped_current_context(this);
diff --git a/src/cobalt/renderer/backend/egl/graphics_system.cc b/src/cobalt/renderer/backend/egl/graphics_system.cc
index a83bb00..7a73c9c 100644
--- a/src/cobalt/renderer/backend/egl/graphics_system.cc
+++ b/src/cobalt/renderer/backend/egl/graphics_system.cc
@@ -75,8 +75,10 @@
8,
EGL_ALPHA_SIZE,
8,
+#if !SB_HAS_QUIRK(NO_EGL_BIND_TO_TEXTURE)
EGL_BIND_TO_TEXTURE_RGBA,
EGL_TRUE,
+#endif
EGL_RENDERABLE_TYPE,
EGL_OPENGL_ES2_BIT,
EGL_NONE};
diff --git a/src/cobalt/renderer/backend/egl/pbuffer_render_target.cc b/src/cobalt/renderer/backend/egl/pbuffer_render_target.cc
index d7af3f7..0634c82 100644
--- a/src/cobalt/renderer/backend/egl/pbuffer_render_target.cc
+++ b/src/cobalt/renderer/backend/egl/pbuffer_render_target.cc
@@ -35,6 +35,14 @@
EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA,
EGL_NONE,
};
+ // When a dummy 0-area render target is requested, it will not be used as a
+ // drawing target and we therefore don't require for it to be a texture.
+ if (dimensions.height() == 0 && dimensions.width() == 0) {
+ // Fake 1x1 to avoid an arithmetic error (SIGFPE) in eglMakeCurrent() on
+ // some platforms.
+ surface_attrib_list[1] = surface_attrib_list[3] = 1;
+ surface_attrib_list[4] = EGL_NONE;
+ }
surface_ =
eglCreatePbufferSurface(display_, config_, surface_attrib_list);
diff --git a/src/cobalt/renderer/glimp_shaders/glsl/vertex_mesh.glsl b/src/cobalt/renderer/glimp_shaders/glsl/vertex_mesh.glsl
index b41b78f..81611c6 100644
--- a/src/cobalt/renderer/glimp_shaders/glsl/vertex_mesh.glsl
+++ b/src/cobalt/renderer/glimp_shaders/glsl/vertex_mesh.glsl
@@ -1,11 +1,10 @@
attribute vec3 a_position;
attribute vec2 a_tex_coord;
varying vec2 v_tex_coord;
-uniform vec2 u_tex_offset;
-uniform vec2 u_tex_multiplier;
+uniform mat3 u_tex_transform;
uniform mat4 u_mvp_matrix;
void main() {
gl_Position = u_mvp_matrix * vec4(a_position.xyz, 1.0);
- v_tex_coord.x = a_tex_coord.x * u_tex_multiplier.x + u_tex_offset.x;
- v_tex_coord.y = a_tex_coord.y * u_tex_multiplier.y + u_tex_offset.y;
+ vec3 tex_coord = u_tex_transform * vec3(a_tex_coord, 1.0);
+ v_tex_coord = tex_coord.xy;
}
diff --git a/src/cobalt/script/engine.gyp b/src/cobalt/script/engine.gyp
index 18af9d8..ddb6e3e 100644
--- a/src/cobalt/script/engine.gyp
+++ b/src/cobalt/script/engine.gyp
@@ -31,16 +31,8 @@
# building 'all'.
'target_name': 'all_engines',
'type': 'none',
- 'conditions': [
- ['OS == "starboard"', {
- 'dependencies': [
- 'mozjs/mozjs.gyp:*',
- ],
- }, { #else
- 'dependencies': [
- 'javascriptcore/javascriptcore.gyp:*',
- ],
- }],
+ 'dependencies': [
+ 'mozjs/mozjs.gyp:*',
],
},
],
diff --git a/src/cobalt/script/engine_variables.gypi b/src/cobalt/script/engine_variables.gypi
index 98f91e8..98f413c 100644
--- a/src/cobalt/script/engine_variables.gypi
+++ b/src/cobalt/script/engine_variables.gypi
@@ -14,7 +14,6 @@
{
'includes': [
- 'javascriptcore/javascriptcore_variables.gypi',
'mozjs/mozjs_variables.gypi',
'mozjs-45/mozjs-45_variables.gypi',
],
diff --git a/src/cobalt/script/javascriptcore/constructor_base.h b/src/cobalt/script/javascriptcore/constructor_base.h
deleted file mode 100644
index ab192f1..0000000
--- a/src/cobalt/script/javascriptcore/constructor_base.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_CONSTRUCTOR_BASE_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_CONSTRUCTOR_BASE_H_
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-// All JavaScriptCore interface object classes will inherit from this.
-class ConstructorBase : public JSC::JSFunction {
- public:
- // static override. This prevents this object from being called as a normal
- // function, throwing a TypeError if the user attempts to do so.
- static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
- return JSC::CallTypeNone;
- }
-
- protected:
- ConstructorBase(JSC::ExecState* exec_state,
- JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : JSC::JSFunction(exec_state, global_object, structure) {}
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_CONSTRUCTOR_BASE_H_
diff --git a/src/cobalt/script/javascriptcore/conversion_helpers.cc b/src/cobalt/script/javascriptcore/conversion_helpers.cc
deleted file mode 100644
index 9484c0d..0000000
--- a/src/cobalt/script/javascriptcore/conversion_helpers.cc
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-
-#include "base/logging.h"
-#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSScope.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSString.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-JSC::JSValue StringToJSValue(JSC::JSGlobalData* global_data,
- const std::string& utf8_string) {
- WTF::String wtf_string = ToWTFString(utf8_string);
- JSC::JSString* js_string = JSC::jsString(global_data, wtf_string);
- JSC::JSValue string_value(js_string);
- DCHECK(string_value.isString());
- return string_value;
-}
-
-void JSValueToString(JSC::ExecState* exec_state, JSC::JSValue value,
- std::string* out_string) {
- // By default null and undefined evaluate to the strings "null" and
- // "undefined" respectively.
- // TODO: Optimize this.
- JSC::JSString* js_string = value.toString(exec_state);
- const WTF::String& wtf_string = js_string->value(exec_state);
- *out_string = FromWTFString(wtf_string);
-}
-
-JSC::JSValue TokenToJSValue(JSC::JSGlobalData* global_data,
- base::Token utf8_string) {
- WTF::String wtf_string = ToWTFString(utf8_string.c_str());
- JSC::JSString* js_string = JSC::jsString(global_data, wtf_string);
- JSC::JSValue string_value(js_string);
- DCHECK(string_value.isString());
- return string_value;
-}
-
-WTF::String ToWTFString(const std::string& utf8_string) {
- WTF::String wtf_string;
- // If the string is all ASCII, we can convert it using half the memory of
- // the generalized conversion function. This is significant as uses
- // some huge ASCII-only source files (> 10M chars).
- if (IsStringASCII(utf8_string)) {
- wtf_string = WTF::String(utf8_string.c_str(), utf8_string.length());
- }
-
- wtf_string = WTF::String::fromUTF8(utf8_string.c_str());
- if (wtf_string.isNull()) {
- if (!IsStringUTF8(utf8_string)) {
- DLOG(ERROR) << "Non-UTF8 characters in input string";
- } else {
- DLOG(ERROR) << "Unknown error converting to WTFString";
- }
- wtf_string = WTF::String::fromUTF8("");
- }
- return wtf_string;
-}
-
-std::string FromWTFString(const WTF::String& wtf_string) {
- WTF::CString utf8_string = wtf_string.utf8();
- return std::string(utf8_string.data(), utf8_string.length());
-}
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
diff --git a/src/cobalt/script/javascriptcore/conversion_helpers.h b/src/cobalt/script/javascriptcore/conversion_helpers.h
deleted file mode 100644
index 3b30135..0000000
--- a/src/cobalt/script/javascriptcore/conversion_helpers.h
+++ /dev/null
@@ -1,577 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_CONVERSION_HELPERS_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_CONVERSION_HELPERS_H_
-
-#include <limits>
-#include <string>
-
-#include "base/logging.h"
-#include "base/optional.h"
-#include "cobalt/base/enable_if.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/base/token.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function_holder.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/union_type_conversion_forward.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalData.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSValue.h"
-#include "third_party/WebKit/Source/WTF/wtf/text/WTFString.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-// Flags that can be used as a bitmask for special conversion behaviour.
-enum ConversionFlags {
- kNoConversionFlags = 0,
- kConversionFlagRestricted = 1 << 0,
- kConversionFlagNullable = 1 << 1,
- kConversionFlagTreatNullAsEmptyString = 1 << 2,
- kConversionFlagTreatUndefinedAsEmptyString = 1 << 3,
-
- // Valid conversion flags for numeric values.
- kConversionFlagsNumeric = kConversionFlagRestricted,
-
- // Valid conversion flags for string types.
- kConversionFlagsString = kConversionFlagTreatNullAsEmptyString |
- kConversionFlagTreatUndefinedAsEmptyString,
-
- // Valid conversion flags for callback functions.
- kConversionFlagsCallbackFunction = kConversionFlagNullable,
-
- // Valid conversion flags for callback interfaces.
- kConversionFlagsCallbackInterface = kConversionFlagNullable,
-
- // Valid conversion flags for objects.
- kConversionFlagsObject = kConversionFlagNullable,
-};
-
-// Convert std::string in utf8 encoding to WTFString.
-WTF::String ToWTFString(const std::string& utf8_string);
-
-// Convert WTFString to std::string in utf8.
-std::string FromWTFString(const WTF::String& wtf_string);
-
-// Convert std::string in utf8 encoding to a JSValue representing the string.
-JSC::JSValue StringToJSValue(JSC::JSGlobalData* global_data,
- const std::string& utf8_string);
-
-// Convert a JSValue to a std::string in utf8 encoding.
-void JSValueToString(JSC::ExecState* exec_state, JSC::JSValue value,
- std::string* out_string);
-
-// Convert base::Token in utf8 encoding to a JSValue representing the string.
-JSC::JSValue TokenToJSValue(JSC::JSGlobalData* global_data,
- base::Token utf8_string);
-
-// For a given JSObject* get a pointer to the corresponding Cobalt
-// implementation.
-template <class T>
-inline T* JSObjectToWrappable(JSC::ExecState* exec_state,
- JSC::JSObject* js_object,
- ExceptionState* out_exception) {
- // Assumes we've already checked that null values are acceptable.
- if (!js_object) {
- return NULL;
- }
-
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- Wrappable* wrappable = NULL;
- const JSC::ClassInfo* class_info = NULL;
- if (js_object == global_object) {
- // This is the global object, so get the pointer to the global interface
- // from the JSCGlobalObject.
- wrappable = global_object->global_interface().get();
- class_info = JSCGlobalObject::s_classinfo();
- } else if (global_object->wrapper_factory()->IsWrapper(js_object)) {
- // This is a wrapper object, so get the Wrappable from the appropriate
- // base class.
- if (js_object->isErrorInstance()) {
- wrappable = ExceptionBase::GetWrappable(js_object).get();
- } else {
- wrappable = InterfaceBase::GetWrappable(js_object).get();
- }
- class_info =
- global_object->wrapper_factory()->GetClassInfo(base::GetTypeId<T>());
- } else {
- // This is not a platform object. Return a type error.
- out_exception->SetSimpleException(kDoesNotImplementInterface);
- return NULL;
- }
-
- // Check that the js_object is the expected class.
- if (js_object->inherits(class_info)) {
- return base::polymorphic_downcast<T*>(wrappable);
- } else {
- out_exception->SetSimpleException(kDoesNotImplementInterface);
- return NULL;
- }
-}
-
-// GetWrappableOrSetException functions will set an exception if the value is
-// not a Wrapper object that corresponds to the Wrappable type T.
-// Additionally, an exception will be set if object is NULL.
-template <class T>
-T* GetWrappableOrSetException(JSC::ExecState* exec_state,
- JSC::JSObject* object) {
- if (!object) {
- JSC::throwTypeError(exec_state);
- return NULL;
- }
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCExceptionState exception_state(global_object);
- T* impl = JSObjectToWrappable<T>(exec_state, object, &exception_state);
- if (exception_state.is_exception_set()) {
- JSC::throwError(exec_state, exception_state.exception_object());
- return NULL;
- }
- return impl;
-}
-
-template <class T>
-T* GetWrappableOrSetException(JSC::ExecState* exec_state, JSC::JSCell* cell) {
- // getObject() returns NULL if the cell is not an object.
- JSC::JSObject* object = cell ? cell->getObject() : NULL;
- return GetWrappableOrSetException<T>(exec_state, object);
-}
-
-template <class T>
-T* GetWrappableOrSetException(JSC::ExecState* exec_state, JSC::JSValue value) {
- // getObject() returns NULL if the value is not an object.
- JSC::JSObject* object = value.getObject();
- return GetWrappableOrSetException<T>(exec_state, object);
-}
-
-// Overloads of ToJSValue convert different Cobalt types to JSValue.
-//
-// bool -> JSValue
-inline JSC::JSValue ToJSValue(JSCGlobalObject*, bool in_boolean) {
- return JSC::jsBoolean(in_boolean);
-}
-
-// numeric types -> JSValue
-template <class T>
-inline JSC::JSValue ToJSValue(
- JSCGlobalObject*, T in_number,
- typename base::enable_if<std::numeric_limits<T>::is_specialized>::type* =
- NULL) {
- JSC::JSValue number_value = JSC::jsNumber(in_number);
- DCHECK(number_value.isNumber());
- return number_value;
-}
-
-// std::string -> JSValue
-inline JSC::JSValue ToJSValue(JSCGlobalObject* global_object,
- const std::string& in_string) {
- return StringToJSValue(&(global_object->globalData()), in_string);
-}
-
-// base::Token -> JSValue
-inline JSC::JSValue ToJSValue(JSCGlobalObject* global_object,
- base::Token in_token) {
- return TokenToJSValue(&(global_object->globalData()), in_token);
-}
-
-// object -> JSValue
-template <class T>
-inline JSC::JSValue ToJSValue(JSCGlobalObject* global_object,
- const scoped_refptr<T>& in_object) {
- if (!in_object) {
- return JSC::jsNull();
- }
- JSC::JSObject* wrapper =
- global_object->wrapper_factory()->GetWrapper(global_object, in_object);
- DCHECK(wrapper);
- return JSC::JSValue(wrapper);
-}
-
-// optional<T> -> JSValue
-template <class T>
-inline JSC::JSValue ToJSValue(JSCGlobalObject* global_object,
- base::optional<T> in_optional) {
- if (!in_optional) {
- return JSC::jsNull();
- }
- return ToJSValue(global_object, in_optional.value());
-}
-
-// CallbackFunction -> JSValue
-template <class T>
-inline JSC::JSValue ToJSValue(
- JSCGlobalObject* global_object,
- const ScriptObject<CallbackFunction<T> >* callback_function) {
- if (!callback_function) {
- return JSC::jsNull();
- }
-
- // Downcast to JSCCallbackFunctionHolder, which has public members that
- // we can use to dig in to get the JS object.
- const JSCCallbackFunctionHolder<CallbackFunction<T> >*
- jsc_callback_function_holder = base::polymorphic_downcast<
- const JSCCallbackFunctionHolder<CallbackFunction<T> >*>(
- callback_function);
- // Get the base CallbackFunction<T> class from the JSCCallbackFunctionHolder.
- const CallbackFunction<T>* callback =
- jsc_callback_function_holder->GetScriptObject();
- // Shouldn't be NULL. If the callback was NULL then NULL should have been
- // passed as an argument into this function.
- DCHECK(callback);
- // Downcast to the JSCCallbackFunction type, from which we can get the
- // JSFunction.
- const JSCCallbackFunction<T>* jsc_callback =
- base::polymorphic_downcast<const JSCCallbackFunction<T>*>(callback);
- return JSC::JSValue(jsc_callback->callable());
-}
-
-// CallbackInterface -> JSValue
-template <class T>
-inline JSC::JSValue ToJSValue(JSCGlobalObject* global_object,
- const ScriptObject<T>* callback_interface) {
- if (!callback_interface) {
- return JSC::jsNull();
- }
- typedef typename CallbackInterfaceTraits<T>::JSCCallbackInterfaceClass
- JSCCallbackInterfaceClass;
- // Downcast to JSCCallbackInterfaceHolder
- const JSCCallbackInterfaceHolder<T>* jsc_callback_interface_holder =
- base::polymorphic_downcast<const JSCCallbackInterfaceHolder<T>*>(
- callback_interface);
-
- // Shouldn't be NULL. If the callback was NULL then NULL should have been
- // passed as an argument into this function.
- // Downcast to the corresponding JSCCallbackInterface type, from which we can
- // get the implementing object.
- const JSCCallbackInterfaceClass* jsc_callback_interface =
- base::polymorphic_downcast<const JSCCallbackInterfaceClass*>(
- jsc_callback_interface_holder->GetScriptObject());
- DCHECK(jsc_callback_interface);
- // Return the user object implementing this interface.
- return JSC::JSValue(jsc_callback_interface->implementing_object());
-}
-
-// OpaqueHandle -> JSValue
-inline JSC::JSValue ToJSValue(JSCGlobalObject* global_object,
- const OpaqueHandleHolder* opaque_handle_holder) {
- if (!opaque_handle_holder) {
- return JSC::jsNull();
- }
-
- // Downcast to JSCObjectHandleHolder, which has public members that
- // we can use to dig in to get the JS object.
- const JSCObjectHandleHolder* jsc_object_handle_holder =
- base::polymorphic_downcast<const JSCObjectHandleHolder*>(
- opaque_handle_holder);
-
- JSC::JSObject* js_object = jsc_object_handle_holder->js_object();
- if (js_object) {
- return JSC::JSValue(js_object);
- } else {
- return JSC::jsNull();
- }
-}
-
-// Overloads of FromJSValue retrieve the Cobalt value from a JSValue.
-//
-// JSValue -> bool
-inline void FromJSValue(JSC::ExecState* exec_state, JSC::JSValue jsvalue,
- int conversion_flags, ExceptionState* out_exception,
- bool* out_bool) {
- DCHECK_EQ(conversion_flags, kNoConversionFlags)
- << "No conversion flags supported.";
- *out_bool = jsvalue.toBoolean(exec_state);
-}
-
-// JSValue -> signed integers <= 4 bytes
-template <class T>
-inline void FromJSValue(
- JSC::ExecState* exec_state, JSC::JSValue jsvalue, int conversion_flags,
- ExceptionState* out_exception, T* out_number,
- typename base::enable_if<std::numeric_limits<T>::is_specialized &&
- std::numeric_limits<T>::is_integer &&
- std::numeric_limits<T>::is_signed &&
- (sizeof(T) <= 4),
- T>::type* = NULL) {
- DCHECK_EQ(conversion_flags, kNoConversionFlags)
- << "No conversion flags supported.";
- int32_t int32_value = jsvalue.toInt32(exec_state);
- *out_number = static_cast<T>(int32_value);
-}
-
-// JSValue -> unsigned integers <= 4 bytes
-template <class T>
-inline void FromJSValue(
- JSC::ExecState* exec_state, JSC::JSValue jsvalue, int conversion_flags,
- ExceptionState* out_exception, T* out_number,
- typename base::enable_if<std::numeric_limits<T>::is_specialized &&
- std::numeric_limits<T>::is_integer &&
- !std::numeric_limits<T>::is_signed &&
- (sizeof(T) <= 4),
- T>::type* = NULL) {
- DCHECK_EQ(conversion_flags, kNoConversionFlags)
- << "No conversion flags supported.";
- uint32_t uint32_value = jsvalue.toUInt32(exec_state);
- *out_number = static_cast<T>(uint32_value);
-}
-
-// JSValue -> signed integers > 4 bytes
-template <class T>
-inline void FromJSValue(
- JSC::ExecState* exec_state, JSC::JSValue jsvalue, int conversion_flags,
- ExceptionState* out_exception, T* out_number,
- typename base::enable_if<std::numeric_limits<T>::is_specialized &&
- std::numeric_limits<T>::is_integer &&
- std::numeric_limits<T>::is_signed &&
- (sizeof(T) > 4),
- T>::type* = NULL) {
- NOTIMPLEMENTED();
-}
-
-// JSValue -> unsigned integers > 4 bytes
-template <class T>
-inline void FromJSValue(
- JSC::ExecState* exec_state, JSC::JSValue jsvalue, int conversion_flags,
- ExceptionState* out_exception, T* out_number,
- typename base::enable_if<std::numeric_limits<T>::is_specialized &&
- std::numeric_limits<T>::is_integer &&
- !std::numeric_limits<T>::is_signed &&
- (sizeof(T) > 4),
- T>::type* = NULL) {
- NOTIMPLEMENTED();
-}
-
-// JSValue -> double
-template <class T>
-inline void FromJSValue(
- JSC::ExecState* exec_state, JSC::JSValue jsvalue, int conversion_flags,
- ExceptionState* out_exception, T* out_number,
- typename base::enable_if<std::numeric_limits<T>::is_specialized &&
- !std::numeric_limits<T>::is_integer,
- T>::type* = NULL) {
- DCHECK_EQ(conversion_flags & ~kConversionFlagsNumeric, 0)
- << "Unexpected conversion flags found.";
- double double_value = jsvalue.toNumber(exec_state);
- if (!isfinite(double_value) &&
- (conversion_flags & kConversionFlagRestricted)) {
- out_exception->SetSimpleException(kNotFinite);
- return;
- }
- *out_number = double_value;
-}
-
-// JSValue -> std::string
-inline void FromJSValue(JSC::ExecState* exec_state, JSC::JSValue jsvalue,
- int conversion_flags, ExceptionState* out_exception,
- std::string* out_string) {
- DCHECK_EQ(conversion_flags & ~kConversionFlagsString, 0)
- << "Unexpected conversion flags found: ";
- if (jsvalue.isNull() &&
- conversion_flags & kConversionFlagTreatNullAsEmptyString) {
- *out_string = "";
- } else if (jsvalue.isUndefined() &&
- conversion_flags & kConversionFlagTreatUndefinedAsEmptyString) {
- *out_string = "";
- } else {
- JSValueToString(exec_state, jsvalue, out_string);
- }
-}
-
-// JSValue -> object
-template <class T>
-inline void FromJSValue(JSC::ExecState* exec_state, JSC::JSValue jsvalue,
- int conversion_flags, ExceptionState* out_exception,
- scoped_refptr<T>* out_object) {
- DCHECK_EQ(conversion_flags & ~kConversionFlagsObject, 0)
- << "Unexpected conversion flags found.";
-
- JSC::JSObject* js_object = NULL;
- if (jsvalue.isNull()) {
- if (!(conversion_flags & kConversionFlagNullable)) {
- out_exception->SetSimpleException(kNotNullableType);
- return;
- }
- } else {
- // Returns NULL if jsvalue is not an object.
- js_object = jsvalue.getObject();
- if (!js_object) {
- out_exception->SetSimpleException(kNotObjectType);
- return;
- }
- }
- *out_object = JSObjectToWrappable<T>(exec_state, js_object, out_exception);
-}
-
-// JSValue -> optional<T>
-template <class T>
-inline void FromJSValue(JSC::ExecState* exec_state, JSC::JSValue jsvalue,
- int conversion_flags, ExceptionState* out_exception,
- base::optional<T>* out_optional) {
- if (jsvalue.isNull()) {
- *out_optional = base::nullopt;
- } else if (jsvalue.isUndefined()) {
- *out_optional = base::nullopt;
- } else {
- *out_optional = T();
- FromJSValue(exec_state, jsvalue,
- conversion_flags & ~kConversionFlagNullable, out_exception,
- &(out_optional->value()));
- }
-}
-
-// JSValue -> optional<T>
-template <>
-inline void FromJSValue(JSC::ExecState* exec_state, JSC::JSValue jsvalue,
- int conversion_flags, ExceptionState* out_exception,
- base::optional<std::string>* out_optional) {
- if (jsvalue.isNull()) {
- *out_optional = base::nullopt;
- } else if (jsvalue.isUndefined() &&
- !(conversion_flags & kConversionFlagTreatUndefinedAsEmptyString)) {
- // If TreatUndefinedAs=EmptyString is set, skip the default conversion
- // of undefined to null.
- *out_optional = base::nullopt;
- } else {
- *out_optional = std::string();
- FromJSValue(exec_state, jsvalue,
- conversion_flags & ~kConversionFlagNullable, out_exception,
- &(out_optional->value()));
- }
-}
-
-// JSValue -> CallbackFunction
-template <class T>
-inline void FromJSValue(JSC::ExecState* exec_state, JSC::JSValue jsvalue,
- int conversion_flags, ExceptionState* out_exception,
- JSCCallbackFunctionHolder<T>* out_callback) {
- DCHECK_EQ(conversion_flags & ~kConversionFlagsCallbackFunction, 0)
- << "No conversion flags supported.";
- if (jsvalue.isNull()) {
- if (!(conversion_flags & kConversionFlagNullable)) {
- out_exception->SetSimpleException(kNotNullableType);
- }
- // If it is a nullable type, just return.
- return;
- }
-
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
-
- // https://www.w3.org/TR/WebIDL/#es-callback-function
- // 1. If V is not a Function object, throw a TypeError
- if (!jsvalue.isFunction()) {
- out_exception->SetSimpleException(kNotFunctionValue);
- return;
- }
-
- JSC::JSFunction* js_function =
- JSC::jsCast<JSC::JSFunction*>(jsvalue.asCell());
- DCHECK(js_function);
- JSCCallbackFunction<typename T::Signature> callback_function(js_function);
- *out_callback = JSCCallbackFunctionHolder<T>(
- callback_function, global_object->script_object_registry());
-}
-
-// JSValue -> CallbackInterface
-template <class T>
-inline void FromJSValue(JSC::ExecState* exec_state, JSC::JSValue jsvalue,
- int conversion_flags, ExceptionState* out_exception,
- JSCCallbackInterfaceHolder<T>* out_callback_interface) {
- typedef typename CallbackInterfaceTraits<T>::JSCCallbackInterfaceClass
- JSCCallbackInterfaceClass;
- DCHECK_EQ(conversion_flags & ~kConversionFlagsCallbackFunction, 0)
- << "No conversion flags supported.";
- if (jsvalue.isNull()) {
- if (!(conversion_flags & kConversionFlagNullable)) {
- out_exception->SetSimpleException(kNotNullableType);
- }
- // If it is a nullable type, just return.
- return;
- }
-
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
-
- // https://www.w3.org/TR/WebIDL/#es-user-objects
- // Any user object can be considered to implement a user interface. Actually
- // checking if the correct properties exist will happen when the operation
- // on the callback interface is run.
-
- if (!jsvalue.isFunction() && !jsvalue.isObject()) {
- out_exception->SetSimpleException(kNotObjectOrFunction);
- return;
- }
-
- JSC::JSObject* js_object = jsvalue.getObject();
- DCHECK(js_object);
- JSCCallbackInterfaceClass callback_interface(js_object);
- *out_callback_interface = JSCCallbackInterfaceHolder<T>(
- callback_interface, global_object->script_object_registry());
-}
-
-// JSValue -> OpaqueHandle
-inline void FromJSValue(JSC::ExecState* exec_state, JSC::JSValue jsvalue,
- int conversion_flags, ExceptionState* out_exception,
- JSCObjectHandleHolder* out_handle) {
- DCHECK_EQ(conversion_flags & ~kConversionFlagsObject, 0)
- << "Unexpected conversion flags found.";
- JSC::JSObject* js_object = NULL;
- if (jsvalue.isNull()) {
- if (!(conversion_flags & kConversionFlagNullable)) {
- out_exception->SetSimpleException(kNotNullableType);
- }
- // Return here whether an exception was set or not.
- return;
- } else {
- // https://www.w3.org/TR/WebIDL/#es-object
- // 1. If Type(V) is not Object, throw a TypeError
- js_object = jsvalue.getObject();
- if (!js_object) {
- out_exception->SetSimpleException(kNotObjectType);
- return;
- }
- }
-
- // Null cases should be handled above.
- DCHECK(js_object);
-
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- JSCObjectHandle jsc_object_handle(js_object);
- *out_handle = JSCObjectHandleHolder(jsc_object_handle,
- global_object->script_object_registry());
-}
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#include "cobalt/script/javascriptcore/jsc_callback_function_impl.h"
-// Union type conversion is generated by a pump script.
-#include "cobalt/script/javascriptcore/union_type_conversion_impl.h"
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_CONVERSION_HELPERS_H_
diff --git a/src/cobalt/script/javascriptcore/javascriptcore.gyp b/src/cobalt/script/javascriptcore/javascriptcore.gyp
deleted file mode 100644
index 73b048f..0000000
--- a/src/cobalt/script/javascriptcore/javascriptcore.gyp
+++ /dev/null
@@ -1,125 +0,0 @@
-# Copyright 2015 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.
-
-{
- 'targets': [
- {
- 'target_name': 'engine',
- 'type': 'static_library',
- 'sources': [
- 'conversion_helpers.cc',
- 'conversion_helpers.h',
- 'js_object_cache.cc',
- 'js_object_cache.h',
- 'jsc_call_frame.cc',
- 'jsc_call_frame.h',
- 'jsc_callback_interface.cc',
- 'jsc_debugger.cc',
- 'jsc_debugger.h',
- 'jsc_engine.cc',
- 'jsc_engine.h',
- 'jsc_exception_state.cc',
- 'jsc_exception_state.h',
- 'jsc_gc_markup_visitor.h',
- 'jsc_global_environment.cc',
- 'jsc_global_environment.h',
- 'jsc_global_object.cc',
- 'jsc_global_object.h',
- 'jsc_object_handle.h',
- 'jsc_object_owner.h',
- 'jsc_scope.cc',
- 'jsc_scope.h',
- 'jsc_source_code.cc',
- 'jsc_source_code.h',
- 'jsc_source_provider.cc',
- 'jsc_source_provider.h',
- 'script_object_registry.cc',
- 'script_object_registry.h',
- 'thread_local_hash_table.cc',
- 'thread_local_hash_table.h',
- 'util/binding_helpers.cc',
- 'util/binding_helpers.h',
- 'util/exception_helpers.cc',
- 'util/exception_helpers.h',
- 'wrapper_base.h',
- 'wrapper_factory.cc',
- 'wrapper_factory.h',
- ],
- 'defines': [
- '__DISABLE_WTF_LOGGING__',
- ],
- 'include_dirs': [
- '<(DEPTH)/third_party/WebKit/Source/JavaScriptCore',
- '<(DEPTH)/third_party/WebKit/Source/WTF',
- ],
- 'dependencies': [
- '<(DEPTH)/cobalt/script/script.gyp:script',
- '<(DEPTH)/third_party/WebKit/Source/JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:javascriptcore',
- ],
- 'all_dependent_settings': {
- 'defines': [
- 'ENGINE_DEFINES_ATTRIBUTES_ON_OBJECT',
- 'ENGINE_USES_CONSERVATIVE_ROOTING',
- ],
- },
- 'msvs_disabled_warnings': [
- # dll-interface warnings. Not easily fixed for template types.
- 4251,
- ],
- },
- {
- 'target_name': 'jsc_engine_test',
- 'type': '<(gtest_target_type)',
- 'sources': [
- 'numeric_conversion_test.cc',
- ],
- 'defines': [
- '__DISABLE_WTF_LOGGING__',
- ],
- 'include_dirs': [
- '<(DEPTH)/third_party/WebKit/Source/JavaScriptCore',
- '<(DEPTH)/third_party/WebKit/Source/WTF',
- ],
- 'dependencies': [
- '<(DEPTH)/base/base.gyp:run_all_unittests',
- '<(DEPTH)/cobalt/base/base.gyp:base',
- '<(DEPTH)/testing/gmock.gyp:gmock',
- '<(DEPTH)/testing/gtest.gyp:gtest',
- '<(DEPTH)/third_party/WebKit/Source/JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:javascriptcore',
- 'engine',
- ]
- },
- {
- # Standalone executable for JS engine
- 'target_name': 'jsc',
- 'type': '<(final_executable_type)',
- 'sources': [
- 'jsc.cc',
- ],
- 'defines': [
- '__DISABLE_WTF_LOGGING__',
- ],
- 'include_dirs': [
- '<(DEPTH)/third_party/WebKit/Source/JavaScriptCore',
- '<(DEPTH)/third_party/WebKit/Source/WTF',
- ],
- 'dependencies': [
- ':engine',
- '<(DEPTH)/cobalt/base/base.gyp:base',
- '<(DEPTH)/cobalt/script/script.gyp:standalone_javascript_runner',
- '<(DEPTH)/third_party/WebKit/Source/JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:javascriptcore',
- ],
- },
- ],
-}
diff --git a/src/cobalt/script/javascriptcore/javascriptcore_variables.gypi b/src/cobalt/script/javascriptcore/javascriptcore_variables.gypi
deleted file mode 100644
index cc0e9cd..0000000
--- a/src/cobalt/script/javascriptcore/javascriptcore_variables.gypi
+++ /dev/null
@@ -1,51 +0,0 @@
-# Copyright 2016 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.
-
-{
- 'variables': {
- 'conditions': [
- ['javascript_engine == "javascriptcore"', {
- 'generated_bindings_prefix': 'JSC',
- 'engine_include_dirs': [
- '<(DEPTH)/third_party/WebKit/Source/JavaScriptCore',
- '<(DEPTH)/third_party/WebKit/Source/WTF',
- ],
- 'engine_dependencies': [
- '<(DEPTH)/third_party/WebKit/Source/JavaScriptCore/JavaScriptCore.gyp/JavaScriptCore.gyp:javascriptcore',
- ],
- 'engine_defines': [
- # Avoid WTF LOG macro.
- '__DISABLE_WTF_LOGGING__',
- ],
- 'engine_templates_dir': [
- '<(DEPTH)/cobalt/bindings/javascriptcore/templates',
- ],
- 'engine_template_files': [
- '<(DEPTH)/cobalt/bindings/javascriptcore/templates/callback-interface.cc.template',
- '<(DEPTH)/cobalt/bindings/javascriptcore/templates/callback-interface.h.template',
- '<(DEPTH)/cobalt/bindings/javascriptcore/templates/interface.cc.template',
- '<(DEPTH)/cobalt/bindings/javascriptcore/templates/interface.h.template',
- '<(DEPTH)/cobalt/bindings/javascriptcore/templates/interface-object.template',
- '<(DEPTH)/cobalt/bindings/javascriptcore/templates/macros.cc.template',
- '<(DEPTH)/cobalt/bindings/javascriptcore/templates/prototype-object.template',
- ],
- 'engine_bindings_scripts': [
- '<(DEPTH)/cobalt/bindings/javascriptcore/code_generator.py',
- '<(DEPTH)/cobalt/bindings/javascriptcore/idl_compiler.py',
- ],
- 'engine_idl_compiler': '<(DEPTH)/cobalt/bindings/javascriptcore/idl_compiler.py',
- }],
- ],
- },
-}
diff --git a/src/cobalt/script/javascriptcore/js_object_cache.cc b/src/cobalt/script/javascriptcore/js_object_cache.cc
deleted file mode 100644
index 1a99230..0000000
--- a/src/cobalt/script/javascriptcore/js_object_cache.cc
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2015 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.
- */
-
-#include "cobalt/script/javascriptcore/js_object_cache.h"
-
-#include <utility>
-
-#include "base/hash_tables.h"
-
-#if !defined(BASE_HASH_USE_HASH_STRUCT)
-namespace BASE_HASH_NAMESPACE {
-template<>
-inline size_t hash_value(const JSC::WriteBarrier<JSC::JSObject>& value) {
- return hash_value(value.get());
-}
-} // namespace BASE_HASH_NAMESPACE
-#endif
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-PrototypeBase* JSObjectCache::GetCachedPrototype(
- const JSC::ClassInfo* class_info) {
- CachedPrototypeMap::iterator it = cached_prototypes_.find(class_info);
- if (it != cached_prototypes_.end()) {
- return it->second.get();
- }
- return NULL;
-}
-
-void JSObjectCache::CachePrototype(const JSC::ClassInfo* class_info,
- PrototypeBase* object) {
- std::pair<CachedPrototypeMap::iterator, bool> pair_ib;
- pair_ib = cached_prototypes_.insert(std::make_pair(
- class_info, JSC::WriteBarrier<PrototypeBase>(global_object_->globalData(),
- global_object_, object)));
- DCHECK(pair_ib.second)
- << "Another Prototype was already registered for this ClassInfo";
-}
-
-ConstructorBase* JSObjectCache::GetCachedConstructor(
- const JSC::ClassInfo* class_info) {
- CachedConstructorMap::iterator it = cached_constructors_.find(class_info);
- if (it != cached_constructors_.end()) {
- return it->second.get();
- }
- return NULL;
-}
-
-void JSObjectCache::CacheConstructor(const JSC::ClassInfo* class_info,
- ConstructorBase* object) {
- std::pair<CachedConstructorMap::iterator, bool> pair_ib;
- pair_ib = cached_constructors_.insert(std::make_pair(
- class_info, JSC::WriteBarrier<ConstructorBase>(
- global_object_->globalData(), global_object_, object)));
- DCHECK(pair_ib.second)
- << "Another Prototype was already registered for this ClassInfo";
-}
-
-void JSObjectCache::CacheJSObject(JSC::JSObject* js_object) {
- cached_objects_.insert(js_object);
-}
-
-void JSObjectCache::UncacheJSObject(JSC::JSObject* js_object) {
- CachedObjectMultiset::iterator it = cached_objects_.find(js_object);
- if (it != cached_objects_.end()) {
- cached_objects_.erase(it);
- } else {
- NOTREACHED() << "Trying to uncache a JSObject that was not cached.";
- }
-}
-
-void JSObjectCache::VisitChildren(JSC::SlotVisitor* visitor) {
- for (CachedPrototypeMap::iterator it = cached_prototypes_.begin();
- it != cached_prototypes_.end(); ++it) {
- visitor->append(&(it->second));
- }
- for (CachedConstructorMap::iterator it = cached_constructors_.begin();
- it != cached_constructors_.end(); ++it) {
- visitor->append(&(it->second));
- }
- for (CachedObjectMultiset::iterator it = cached_objects_.begin();
- it != cached_objects_.end(); ++it) {
- JSC::JSObject* js_object = *it;
- visitor->appendUnbarrieredPointer(&js_object);
- }
-}
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
diff --git a/src/cobalt/script/javascriptcore/js_object_cache.h b/src/cobalt/script/javascriptcore/js_object_cache.h
deleted file mode 100644
index 6e5a271..0000000
--- a/src/cobalt/script/javascriptcore/js_object_cache.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2015 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.
- */
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_JS_OBJECT_CACHE_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_JS_OBJECT_CACHE_H_
-
-#include "base/bind.h"
-#include "base/hash_tables.h"
-#include "base/memory/ref_counted.h"
-#include "cobalt/base/type_id.h"
-#include "cobalt/script/javascriptcore/constructor_base.h"
-#include "cobalt/script/javascriptcore/prototype_base.h"
-#include "cobalt/script/wrappable.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-class JSCGlobalObject;
-
-//
-class JSObjectCache {
- public:
- explicit JSObjectCache(JSC::JSGlobalObject* global_object)
- : global_object_(global_object) {}
- // Cache an interface's Prototype object by ClassInfo. Cached objects will
- // not be garbage collected.
- PrototypeBase* GetCachedPrototype(const JSC::ClassInfo* class_info);
- void CachePrototype(const JSC::ClassInfo* class_info, PrototypeBase* object);
-
- // Cache an interface's Interface Object (constructor) by ClassInfo. Cached
- // objects will not be garbage collected.
- ConstructorBase* GetCachedConstructor(const JSC::ClassInfo* class_info);
- void CacheConstructor(const JSC::ClassInfo* class_info,
- ConstructorBase* object);
-
- // Cache a reference to this JS object internally and visit it during garbage
- // collection. This will prevent it from being garbage collected.
- // Calling this multiple times for the same object results in multiple
- // references being stored.
- void CacheJSObject(JSC::JSObject* js_object);
-
- // Remove a reference to this JS object from the internal list of objects
- // that are visited during garbage collection.
- void UncacheJSObject(JSC::JSObject* js_object);
-
- // Called during garbage collection phase. Cached objects will be visited and
- // thus prevented from being garbage collected.
- void VisitChildren(JSC::SlotVisitor* visitor);
-
- private:
- typedef base::hash_map<const JSC::ClassInfo*,
- JSC::WriteBarrier<PrototypeBase> > CachedPrototypeMap;
- typedef base::hash_map<const JSC::ClassInfo*,
- JSC::WriteBarrier<ConstructorBase> >
- CachedConstructorMap;
- typedef base::hash_multiset<JSC::JSObject*> CachedObjectMultiset;
-
- JSC::JSGlobalObject* global_object_;
- CachedPrototypeMap cached_prototypes_;
- CachedConstructorMap cached_constructors_;
- CachedObjectMultiset cached_objects_;
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_JS_OBJECT_CACHE_H_
diff --git a/src/cobalt/script/javascriptcore/jsc.cc b/src/cobalt/script/javascriptcore/jsc.cc
deleted file mode 100644
index 45ab380..0000000
--- a/src/cobalt/script/javascriptcore/jsc.cc
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2016 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.
- */
-
-#include <iostream>
-
-#include "base/command_line.h"
-#include "base/file_path.h"
-#include "base/string_util.h"
-#include "cobalt/base/wrap_main.h"
-#include "cobalt/script/javascriptcore/jsc_engine.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/standalone_javascript_runner.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-// Error.h needs to be included before JSCTypedArrayStubs.h
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/JSCTypedArrayStubs.h" // NOLINT(build/include_alpha)
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-namespace {
-
-JSC::EncodedJSValue JSC_HOST_CALL PrintFunction(JSC::ExecState* exec) {
- std::vector<std::string> string_args;
- for (uint32 i = 0; i < exec->argumentCount(); ++i) {
- string_args.push_back(
- exec->argument(i).toString(exec)->value(exec).utf8().data());
- }
- std::string joined = JoinString(string_args, ' ');
- std::cout << joined << std::endl;
- return JSC::JSValue::encode(JSC::jsUndefined());
-}
-
-void AddFunction(JSCGlobalObject* global_object, const char* name,
- JSC::NativeFunction function, uint32 arguments) {
- JSC::Identifier identifier(global_object->globalExec(), name);
- global_object->putDirect(
- global_object->globalData(), identifier,
- JSC::JSFunction::create(global_object->globalExec(), global_object,
- arguments, identifier.string(), function));
-}
-
-#if !USE(EXPORT_MACROS)
-void AddConstructableFunction(JSCGlobalObject* global_object, const char* name,
- JSC::NativeFunction function, uint32 arguments) {
- JSC::Identifier identifier(global_object->globalExec(), name);
- global_object->putDirect(
- global_object->globalData(), identifier,
- JSC::JSFunction::create(global_object->globalExec(), global_object,
- arguments, identifier.string(), function,
- JSC::NoIntrinsic, function));
-}
-#endif
-
-void SetupBindings(JSCGlobalObject* global_object) {
- JSC::JSLockHolder lock(&global_object->globalData());
- AddFunction(global_object, "print", &PrintFunction, 1);
-
- // Getting these exported properly will take a bit of work, and it's likely
- // not worth it.
-#if !USE(EXPORT_MACROS)
- AddConstructableFunction(global_object, "Uint8Array",
- JSC::constructJSUint8Array, 1);
- AddConstructableFunction(global_object, "Uint8ClampedArray",
- JSC::constructJSUint8ClampedArray, 1);
- AddConstructableFunction(global_object, "Uint16Array",
- JSC::constructJSUint16Array, 1);
- AddConstructableFunction(global_object, "Uint32Array",
- JSC::constructJSUint32Array, 1);
- AddConstructableFunction(global_object, "Int8Array",
- JSC::constructJSInt8Array, 1);
- AddConstructableFunction(global_object, "Int16Array",
- JSC::constructJSInt16Array, 1);
- AddConstructableFunction(global_object, "Int32Array",
- JSC::constructJSInt32Array, 1);
- AddConstructableFunction(global_object, "Float32Array",
- JSC::constructJSFloat32Array, 1);
- AddConstructableFunction(global_object, "Float64Array",
- JSC::constructJSFloat64Array, 1);
-#endif
-}
-
-int JSCMain(int argc, char** argv) {
- cobalt::script::StandaloneJavascriptRunner standalone_runner;
- standalone_runner.global_environment()->EnableEval();
-
- JSCGlobalObject* global_object =
- static_cast<JSCGlobalEnvironment*>(
- standalone_runner.global_environment().get())
- ->global_object();
- SetupBindings(global_object);
-
- CommandLine command_line(argc, argv);
- CommandLine::StringVector args = command_line.GetArgs();
- if (!args.empty()) {
- FilePath source_file(args[0]);
- standalone_runner.ExecuteFile(source_file);
- } else {
- standalone_runner.RunInteractive();
- }
- return 0;
-}
-
-} // namespace
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-COBALT_WRAP_SIMPLE_MAIN(cobalt::script::javascriptcore::JSCMain);
diff --git a/src/cobalt/script/javascriptcore/jsc_call_frame.cc b/src/cobalt/script/javascriptcore/jsc_call_frame.cc
deleted file mode 100644
index 864e8d0..0000000
--- a/src/cobalt/script/javascriptcore/jsc_call_frame.cc
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2016 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.
- */
-
-#include "cobalt/script/javascriptcore/jsc_call_frame.h"
-
-#include "base/logging.h"
-#include "base/string_number_conversions.h"
-#include "cobalt/script/javascriptcore/jsc_scope.h"
-
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/CallFrame.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/WTF/wtf/text/CString.h"
-#include "third_party/WebKit/Source/WTF/wtf/text/WTFString.h"
-
-namespace cobalt {
-namespace script {
-
-namespace javascriptcore {
-
-namespace {
-// Conversion from intptr_t to std::string.
-// Used to generate a unique string ID by converting the object pointer.
-std::string IntptrToString(intptr_t input) {
- COMPILE_ASSERT(sizeof(int64) >= sizeof(intptr_t),
- int64_not_big_enough_to_store_intptr_t);
- int64 input_as_int64 = static_cast<int64>(input);
- return base::Int64ToString(input_as_int64);
-}
-} // namespace
-
-JSCCallFrame::JSCCallFrame(const JSC::DebuggerCallFrame& call_frame,
- intptr_t script_id, int line_number)
- : call_frame_(call_frame),
- script_id_(IntptrToString(script_id)),
- line_number_(line_number) {
- Initialize();
-}
-
-JSCCallFrame::JSCCallFrame(const JSC::DebuggerCallFrame& call_frame,
- intptr_t script_id, int line_number,
- int column_number)
- : call_frame_(call_frame),
- script_id_(IntptrToString(script_id)),
- line_number_(line_number),
- column_number_(column_number) {
- Initialize();
-}
-
-JSCCallFrame::~JSCCallFrame() {}
-
-void JSCCallFrame::Initialize() {
- DCHECK(call_frame_.callFrame());
- DCHECK_GT(script_id_.length(), 0);
- global_object_ = JSC::jsCast<JSCGlobalObject*>(
- call_frame_.callFrame()->dynamicGlobalObject());
- DCHECK(global_object_);
-
- JSC::JSValue this_value = call_frame_.callFrame()->thisValue();
- JSC::JSObject* this_object = this_value.getObject();
- if (this_object) {
- this_holder_.reset(
- new JSCObjectHandleHolder(JSCObjectHandle(this_object),
- global_object_->script_object_registry()));
- } else {
- DLOG(WARNING) << "JavaScript 'this' value is not an object.";
- }
-}
-
-std::string JSCCallFrame::GetCallFrameId() {
- return IntptrToString(reinterpret_cast<intptr_t>(call_frame_.callFrame()));
-}
-
-scoped_ptr<CallFrame> JSCCallFrame::GetCaller() {
- JSC::CallFrame* call_frame = call_frame_.callFrame();
- DCHECK(call_frame);
- DCHECK(!call_frame->hasHostCallFrameFlag());
-
- // Get the caller.
- intptr_t source_id;
- int line_number;
- String url;
- JSC::JSValue function;
- call_frame->interpreter()->retrieveLastCaller(call_frame, line_number,
- source_id, url, function);
- call_frame = call_frame->callerFrame();
-
- if (!call_frame || call_frame->hasHostCallFrameFlag()) {
- // No valid JavaScript caller, return NULL;
- return scoped_ptr<CallFrame>();
- }
-
- return scoped_ptr<CallFrame>(new JSCCallFrame(
- JSC::DebuggerCallFrame(call_frame), source_id, line_number));
-}
-
-std::string JSCCallFrame::GetFunctionName() {
- return call_frame_.functionName().utf8().data();
-}
-
-int JSCCallFrame::GetLineNumber() {
- // Line number is absolute - will need to be adjusted for the start line in
- // inline scripts.
- DCHECK_GT(line_number_, 0);
- return line_number_;
-}
-
-base::optional<int> JSCCallFrame::GetColumnNumber() { return column_number_; }
-
-std::string JSCCallFrame::GetScriptId() { return script_id_; }
-
-scoped_ptr<Scope> JSCCallFrame::GetScopeChain() {
- DCHECK(call_frame_.callFrame());
- DCHECK(call_frame_.callFrame()->scope());
- return scoped_ptr<Scope>(new JSCScope(call_frame_.callFrame()->scope()));
-}
-
-const OpaqueHandleHolder* JSCCallFrame::GetThis() { return this_holder_.get(); }
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
diff --git a/src/cobalt/script/javascriptcore/jsc_call_frame.h b/src/cobalt/script/javascriptcore/jsc_call_frame.h
deleted file mode 100644
index dbaebf5..0000000
--- a/src/cobalt/script/javascriptcore/jsc_call_frame.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2016 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.
- */
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_JSC_CALL_FRAME_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_JSC_CALL_FRAME_H_
-
-#include <string>
-
-#include "base/optional.h"
-#include "cobalt/script/call_frame.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/scope.h"
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/debugger/DebuggerCallFrame.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-// JavaScriptCore-specific implementation of a JavaScript call frame.
-class JSCCallFrame : public CallFrame {
- public:
- JSCCallFrame(const JSC::DebuggerCallFrame& call_frame, intptr_t script_id,
- int line_number);
- JSCCallFrame(const JSC::DebuggerCallFrame& call_frame, intptr_t script_id,
- int line_number, int column_number);
- ~JSCCallFrame() OVERRIDE;
-
- std::string GetCallFrameId() OVERRIDE;
- scoped_ptr<CallFrame> GetCaller() OVERRIDE;
- std::string GetFunctionName() OVERRIDE;
- int GetLineNumber() OVERRIDE;
- base::optional<int> GetColumnNumber() OVERRIDE;
- std::string GetScriptId() OVERRIDE;
- scoped_ptr<Scope> GetScopeChain() OVERRIDE;
- const OpaqueHandleHolder* GetThis() OVERRIDE;
-
- private:
- // Called by both constructors to perform common initialization.
- void Initialize();
-
- JSC::DebuggerCallFrame call_frame_;
- std::string script_id_;
- int line_number_;
- base::optional<int> column_number_;
- JSCGlobalObject* global_object_;
- scoped_ptr<JSCObjectHandleHolder> this_holder_;
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_JSC_CALL_FRAME_H_
diff --git a/src/cobalt/script/javascriptcore/jsc_callback_function.h b/src/cobalt/script/javascriptcore/jsc_callback_function.h
deleted file mode 100644
index 818acec..0000000
--- a/src/cobalt/script/javascriptcore/jsc_callback_function.h
+++ /dev/null
@@ -1,503 +0,0 @@
-// This file was GENERATED by command:
-// pump.py jsc_callback_function.h.pump
-// DO NOT EDIT BY HAND!!!
-
-/*
- * Copyright 2015 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.
- */
-
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_JSC_CALLBACK_FUNCTION_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_JSC_CALLBACK_FUNCTION_H_
-
-#include "base/debug/trace_event.h"
-#include "base/logging.h"
-#include "cobalt/script/callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "cobalt/script/logging_exception_state.h"
-#include "cobalt/script/script_object.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-
-// The JSCCallbackFunction type is used to represent IDL callback functions.
-// Create a new JSCCallbackFunction by specifying the base CallbackFunction
-// as a template parameter to the constructor.
-//
-// Constructor parameters:
-// callable: A handle that keeps keeps alive the JSC::JSFunction that
-// will be called when the callback is fired.
-// callback: A base::Callback that will be executed when the Run(...)
-// function is executed. It will take as parameters a JSC::JSFunction
-// followed by any arguments that are defined on the callback type.
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-namespace internal {
-// Helper template functions for Callback functions' return values before being
-// returned to Cobalt.
-// Converts the return value from JavaScript into the correct Cobalt type, or
-// sets the exception bit if conversion fails.
-template <typename R>
-inline CallbackResult<R> ConvertReturnValue(JSC::ExecState* exec_state,
- JSC::JSValue jsvalue);
-}
-// First, we forward declare the Callback class template. This informs the
-// compiler that the template only has 1 type parameter which is the base
-// CallbackFunction template class with parameters.
-//
-// See base/callback.h.pump for further discussion on this pattern.
-template <typename Sig>
-class JSCCallbackFunction;
-
-template <typename R>
-class JSCCallbackFunction<R(void)>
- : public CallbackFunction<R(void)> {
- public:
- explicit JSCCallbackFunction(JSC::JSFunction* callable)
- : callable_(callable) { DCHECK(callable_); }
-
- CallbackResult<R> Run()
- const OVERRIDE {
- TRACE_EVENT0("cobalt::script::javascriptcore", "JSCCallbackFunction::Run");
- DCHECK(callable_);
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(callable_->globalObject());
- JSC::JSLockHolder lock(global_object->globalData());
-
- // https://www.w3.org/TR/WebIDL/#es-invoking-callback-functions
- // Callback 'this' is set to null, unless overridden by other specifications
- JSC::JSValue this_value = JSC::jsNull();
- JSC::MarkedArgumentBuffer args;
-
- JSC::CallData call_data;
- JSC::CallType call_type =
- JSC::JSFunction::getCallData(callable_, call_data);
- JSC::ExecState* exec_state = global_object->globalExec();
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSValue retval =
- JSC::call(exec_state, callable_, call_type, call_data, this_value,
- args);
- CallbackResult<R> callback_result;
- if (exec_state->hadException()) {
- DLOG(WARNING) << "Exception in callback: "
- << util::GetExceptionString(exec_state);
-
- exec_state->clearException();
- callback_result.exception = true;
- } else {
- callback_result = internal::ConvertReturnValue<R>(exec_state, retval);
- }
- return callback_result;
- }
-
- JSC::JSFunction* callable() const { return callable_; }
-
- private:
- JSC::JSFunction* callable_;
-};
-
-template <typename R, typename A1>
-class JSCCallbackFunction<R(A1)>
- : public CallbackFunction<R(A1)> {
- public:
- explicit JSCCallbackFunction(JSC::JSFunction* callable)
- : callable_(callable) { DCHECK(callable_); }
-
- CallbackResult<R> Run(
- typename base::internal::CallbackParamTraits<A1>::ForwardType a1)
- const OVERRIDE {
- TRACE_EVENT0("cobalt::script::javascriptcore", "JSCCallbackFunction::Run");
- DCHECK(callable_);
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(callable_->globalObject());
- JSC::JSLockHolder lock(global_object->globalData());
-
- // https://www.w3.org/TR/WebIDL/#es-invoking-callback-functions
- // Callback 'this' is set to null, unless overridden by other specifications
- JSC::JSValue this_value = JSC::jsNull();
- JSC::MarkedArgumentBuffer args;
- args.append(ToJSValue(global_object, a1));
-
- JSC::CallData call_data;
- JSC::CallType call_type =
- JSC::JSFunction::getCallData(callable_, call_data);
- JSC::ExecState* exec_state = global_object->globalExec();
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSValue retval =
- JSC::call(exec_state, callable_, call_type, call_data, this_value,
- args);
- CallbackResult<R> callback_result;
- if (exec_state->hadException()) {
- DLOG(WARNING) << "Exception in callback: "
- << util::GetExceptionString(exec_state);
-
- exec_state->clearException();
- callback_result.exception = true;
- } else {
- callback_result = internal::ConvertReturnValue<R>(exec_state, retval);
- }
- return callback_result;
- }
-
- JSC::JSFunction* callable() const { return callable_; }
-
- private:
- JSC::JSFunction* callable_;
-};
-
-template <typename R, typename A1, typename A2>
-class JSCCallbackFunction<R(A1, A2)>
- : public CallbackFunction<R(A1, A2)> {
- public:
- explicit JSCCallbackFunction(JSC::JSFunction* callable)
- : callable_(callable) { DCHECK(callable_); }
-
- CallbackResult<R> Run(
- typename base::internal::CallbackParamTraits<A1>::ForwardType a1,
- typename base::internal::CallbackParamTraits<A2>::ForwardType a2)
- const OVERRIDE {
- TRACE_EVENT0("cobalt::script::javascriptcore", "JSCCallbackFunction::Run");
- DCHECK(callable_);
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(callable_->globalObject());
- JSC::JSLockHolder lock(global_object->globalData());
-
- // https://www.w3.org/TR/WebIDL/#es-invoking-callback-functions
- // Callback 'this' is set to null, unless overridden by other specifications
- JSC::JSValue this_value = JSC::jsNull();
- JSC::MarkedArgumentBuffer args;
- args.append(ToJSValue(global_object, a1));
- args.append(ToJSValue(global_object, a2));
-
- JSC::CallData call_data;
- JSC::CallType call_type =
- JSC::JSFunction::getCallData(callable_, call_data);
- JSC::ExecState* exec_state = global_object->globalExec();
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSValue retval =
- JSC::call(exec_state, callable_, call_type, call_data, this_value,
- args);
- CallbackResult<R> callback_result;
- if (exec_state->hadException()) {
- DLOG(WARNING) << "Exception in callback: "
- << util::GetExceptionString(exec_state);
-
- exec_state->clearException();
- callback_result.exception = true;
- } else {
- callback_result = internal::ConvertReturnValue<R>(exec_state, retval);
- }
- return callback_result;
- }
-
- JSC::JSFunction* callable() const { return callable_; }
-
- private:
- JSC::JSFunction* callable_;
-};
-
-template <typename R, typename A1, typename A2, typename A3>
-class JSCCallbackFunction<R(A1, A2, A3)>
- : public CallbackFunction<R(A1, A2, A3)> {
- public:
- explicit JSCCallbackFunction(JSC::JSFunction* callable)
- : callable_(callable) { DCHECK(callable_); }
-
- CallbackResult<R> Run(
- typename base::internal::CallbackParamTraits<A1>::ForwardType a1,
- typename base::internal::CallbackParamTraits<A2>::ForwardType a2,
- typename base::internal::CallbackParamTraits<A3>::ForwardType a3)
- const OVERRIDE {
- TRACE_EVENT0("cobalt::script::javascriptcore", "JSCCallbackFunction::Run");
- DCHECK(callable_);
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(callable_->globalObject());
- JSC::JSLockHolder lock(global_object->globalData());
-
- // https://www.w3.org/TR/WebIDL/#es-invoking-callback-functions
- // Callback 'this' is set to null, unless overridden by other specifications
- JSC::JSValue this_value = JSC::jsNull();
- JSC::MarkedArgumentBuffer args;
- args.append(ToJSValue(global_object, a1));
- args.append(ToJSValue(global_object, a2));
- args.append(ToJSValue(global_object, a3));
-
- JSC::CallData call_data;
- JSC::CallType call_type =
- JSC::JSFunction::getCallData(callable_, call_data);
- JSC::ExecState* exec_state = global_object->globalExec();
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSValue retval =
- JSC::call(exec_state, callable_, call_type, call_data, this_value,
- args);
- CallbackResult<R> callback_result;
- if (exec_state->hadException()) {
- DLOG(WARNING) << "Exception in callback: "
- << util::GetExceptionString(exec_state);
-
- exec_state->clearException();
- callback_result.exception = true;
- } else {
- callback_result = internal::ConvertReturnValue<R>(exec_state, retval);
- }
- return callback_result;
- }
-
- JSC::JSFunction* callable() const { return callable_; }
-
- private:
- JSC::JSFunction* callable_;
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4>
-class JSCCallbackFunction<R(A1, A2, A3, A4)>
- : public CallbackFunction<R(A1, A2, A3, A4)> {
- public:
- explicit JSCCallbackFunction(JSC::JSFunction* callable)
- : callable_(callable) { DCHECK(callable_); }
-
- CallbackResult<R> Run(
- typename base::internal::CallbackParamTraits<A1>::ForwardType a1,
- typename base::internal::CallbackParamTraits<A2>::ForwardType a2,
- typename base::internal::CallbackParamTraits<A3>::ForwardType a3,
- typename base::internal::CallbackParamTraits<A4>::ForwardType a4)
- const OVERRIDE {
- TRACE_EVENT0("cobalt::script::javascriptcore", "JSCCallbackFunction::Run");
- DCHECK(callable_);
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(callable_->globalObject());
- JSC::JSLockHolder lock(global_object->globalData());
-
- // https://www.w3.org/TR/WebIDL/#es-invoking-callback-functions
- // Callback 'this' is set to null, unless overridden by other specifications
- JSC::JSValue this_value = JSC::jsNull();
- JSC::MarkedArgumentBuffer args;
- args.append(ToJSValue(global_object, a1));
- args.append(ToJSValue(global_object, a2));
- args.append(ToJSValue(global_object, a3));
- args.append(ToJSValue(global_object, a4));
-
- JSC::CallData call_data;
- JSC::CallType call_type =
- JSC::JSFunction::getCallData(callable_, call_data);
- JSC::ExecState* exec_state = global_object->globalExec();
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSValue retval =
- JSC::call(exec_state, callable_, call_type, call_data, this_value,
- args);
- CallbackResult<R> callback_result;
- if (exec_state->hadException()) {
- DLOG(WARNING) << "Exception in callback: "
- << util::GetExceptionString(exec_state);
-
- exec_state->clearException();
- callback_result.exception = true;
- } else {
- callback_result = internal::ConvertReturnValue<R>(exec_state, retval);
- }
- return callback_result;
- }
-
- JSC::JSFunction* callable() const { return callable_; }
-
- private:
- JSC::JSFunction* callable_;
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
- typename A5>
-class JSCCallbackFunction<R(A1, A2, A3, A4, A5)>
- : public CallbackFunction<R(A1, A2, A3, A4, A5)> {
- public:
- explicit JSCCallbackFunction(JSC::JSFunction* callable)
- : callable_(callable) { DCHECK(callable_); }
-
- CallbackResult<R> Run(
- typename base::internal::CallbackParamTraits<A1>::ForwardType a1,
- typename base::internal::CallbackParamTraits<A2>::ForwardType a2,
- typename base::internal::CallbackParamTraits<A3>::ForwardType a3,
- typename base::internal::CallbackParamTraits<A4>::ForwardType a4,
- typename base::internal::CallbackParamTraits<A5>::ForwardType a5)
- const OVERRIDE {
- TRACE_EVENT0("cobalt::script::javascriptcore", "JSCCallbackFunction::Run");
- DCHECK(callable_);
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(callable_->globalObject());
- JSC::JSLockHolder lock(global_object->globalData());
-
- // https://www.w3.org/TR/WebIDL/#es-invoking-callback-functions
- // Callback 'this' is set to null, unless overridden by other specifications
- JSC::JSValue this_value = JSC::jsNull();
- JSC::MarkedArgumentBuffer args;
- args.append(ToJSValue(global_object, a1));
- args.append(ToJSValue(global_object, a2));
- args.append(ToJSValue(global_object, a3));
- args.append(ToJSValue(global_object, a4));
- args.append(ToJSValue(global_object, a5));
-
- JSC::CallData call_data;
- JSC::CallType call_type =
- JSC::JSFunction::getCallData(callable_, call_data);
- JSC::ExecState* exec_state = global_object->globalExec();
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSValue retval =
- JSC::call(exec_state, callable_, call_type, call_data, this_value,
- args);
- CallbackResult<R> callback_result;
- if (exec_state->hadException()) {
- DLOG(WARNING) << "Exception in callback: "
- << util::GetExceptionString(exec_state);
-
- exec_state->clearException();
- callback_result.exception = true;
- } else {
- callback_result = internal::ConvertReturnValue<R>(exec_state, retval);
- }
- return callback_result;
- }
-
- JSC::JSFunction* callable() const { return callable_; }
-
- private:
- JSC::JSFunction* callable_;
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
- typename A5, typename A6>
-class JSCCallbackFunction<R(A1, A2, A3, A4, A5, A6)>
- : public CallbackFunction<R(A1, A2, A3, A4, A5, A6)> {
- public:
- explicit JSCCallbackFunction(JSC::JSFunction* callable)
- : callable_(callable) { DCHECK(callable_); }
-
- CallbackResult<R> Run(
- typename base::internal::CallbackParamTraits<A1>::ForwardType a1,
- typename base::internal::CallbackParamTraits<A2>::ForwardType a2,
- typename base::internal::CallbackParamTraits<A3>::ForwardType a3,
- typename base::internal::CallbackParamTraits<A4>::ForwardType a4,
- typename base::internal::CallbackParamTraits<A5>::ForwardType a5,
- typename base::internal::CallbackParamTraits<A6>::ForwardType a6)
- const OVERRIDE {
- TRACE_EVENT0("cobalt::script::javascriptcore", "JSCCallbackFunction::Run");
- DCHECK(callable_);
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(callable_->globalObject());
- JSC::JSLockHolder lock(global_object->globalData());
-
- // https://www.w3.org/TR/WebIDL/#es-invoking-callback-functions
- // Callback 'this' is set to null, unless overridden by other specifications
- JSC::JSValue this_value = JSC::jsNull();
- JSC::MarkedArgumentBuffer args;
- args.append(ToJSValue(global_object, a1));
- args.append(ToJSValue(global_object, a2));
- args.append(ToJSValue(global_object, a3));
- args.append(ToJSValue(global_object, a4));
- args.append(ToJSValue(global_object, a5));
- args.append(ToJSValue(global_object, a6));
-
- JSC::CallData call_data;
- JSC::CallType call_type =
- JSC::JSFunction::getCallData(callable_, call_data);
- JSC::ExecState* exec_state = global_object->globalExec();
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSValue retval =
- JSC::call(exec_state, callable_, call_type, call_data, this_value,
- args);
- CallbackResult<R> callback_result;
- if (exec_state->hadException()) {
- DLOG(WARNING) << "Exception in callback: "
- << util::GetExceptionString(exec_state);
-
- exec_state->clearException();
- callback_result.exception = true;
- } else {
- callback_result = internal::ConvertReturnValue<R>(exec_state, retval);
- }
- return callback_result;
- }
-
- JSC::JSFunction* callable() const { return callable_; }
-
- private:
- JSC::JSFunction* callable_;
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
- typename A5, typename A6, typename A7>
-class JSCCallbackFunction<R(A1, A2, A3, A4, A5, A6, A7)>
- : public CallbackFunction<R(A1, A2, A3, A4, A5, A6, A7)> {
- public:
- explicit JSCCallbackFunction(JSC::JSFunction* callable)
- : callable_(callable) { DCHECK(callable_); }
-
- CallbackResult<R> Run(
- typename base::internal::CallbackParamTraits<A1>::ForwardType a1,
- typename base::internal::CallbackParamTraits<A2>::ForwardType a2,
- typename base::internal::CallbackParamTraits<A3>::ForwardType a3,
- typename base::internal::CallbackParamTraits<A4>::ForwardType a4,
- typename base::internal::CallbackParamTraits<A5>::ForwardType a5,
- typename base::internal::CallbackParamTraits<A6>::ForwardType a6,
- typename base::internal::CallbackParamTraits<A7>::ForwardType a7)
- const OVERRIDE {
- TRACE_EVENT0("cobalt::script::javascriptcore", "JSCCallbackFunction::Run");
- DCHECK(callable_);
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(callable_->globalObject());
- JSC::JSLockHolder lock(global_object->globalData());
-
- // https://www.w3.org/TR/WebIDL/#es-invoking-callback-functions
- // Callback 'this' is set to null, unless overridden by other specifications
- JSC::JSValue this_value = JSC::jsNull();
- JSC::MarkedArgumentBuffer args;
- args.append(ToJSValue(global_object, a1));
- args.append(ToJSValue(global_object, a2));
- args.append(ToJSValue(global_object, a3));
- args.append(ToJSValue(global_object, a4));
- args.append(ToJSValue(global_object, a5));
- args.append(ToJSValue(global_object, a6));
- args.append(ToJSValue(global_object, a7));
-
- JSC::CallData call_data;
- JSC::CallType call_type =
- JSC::JSFunction::getCallData(callable_, call_data);
- JSC::ExecState* exec_state = global_object->globalExec();
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSValue retval =
- JSC::call(exec_state, callable_, call_type, call_data, this_value,
- args);
- CallbackResult<R> callback_result;
- if (exec_state->hadException()) {
- DLOG(WARNING) << "Exception in callback: "
- << util::GetExceptionString(exec_state);
-
- exec_state->clearException();
- callback_result.exception = true;
- } else {
- callback_result = internal::ConvertReturnValue<R>(exec_state, retval);
- }
- return callback_result;
- }
-
- JSC::JSFunction* callable() const { return callable_; }
-
- private:
- JSC::JSFunction* callable_;
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_JSC_CALLBACK_FUNCTION_H_
diff --git a/src/cobalt/script/javascriptcore/jsc_callback_function.h.pump b/src/cobalt/script/javascriptcore/jsc_callback_function.h.pump
deleted file mode 100644
index abba9da..0000000
--- a/src/cobalt/script/javascriptcore/jsc_callback_function.h.pump
+++ /dev/null
@@ -1,137 +0,0 @@
-$$ This is a pump file for generating file templates. Pump is a python
-$$ script that is part of the Google Test suite of utilities. Description
-$$ can be found here:
-$$
-$$ http://code.google.com/p/googletest/wiki/PumpManual
-$$
-
-$$ This should be no larger than MAX_ARITY in base/bind.h.pump.
-$var MAX_ARITY = 7
-/*
- * Copyright 2015 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.
- */
-
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_JSC_CALLBACK_FUNCTION_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_JSC_CALLBACK_FUNCTION_H_
-
-#include "base/debug/trace_event.h"
-#include "base/logging.h"
-#include "cobalt/script/callback_function.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-#include "cobalt/script/logging_exception_state.h"
-#include "cobalt/script/script_object.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-
-// The JSCCallbackFunction type is used to represent IDL callback functions.
-// Create a new JSCCallbackFunction by specifying the base CallbackFunction
-// as a template parameter to the constructor.
-//
-// Constructor parameters:
-// callable: A handle that keeps keeps alive the JSC::JSFunction that
-// will be called when the callback is fired.
-// callback: A base::Callback that will be executed when the Run(...)
-// function is executed. It will take as parameters a JSC::JSFunction
-// followed by any arguments that are defined on the callback type.
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-namespace internal {
-// Helper template functions for Callback functions' return values before being
-// returned to Cobalt.
-// Converts the return value from JavaScript into the correct Cobalt type, or
-// sets the exception bit if conversion fails.
-template <typename R>
-inline CallbackResult<R> ConvertReturnValue(JSC::ExecState* exec_state,
- JSC::JSValue jsvalue);
-}
-// First, we forward declare the Callback class template. This informs the
-// compiler that the template only has 1 type parameter which is the base
-// CallbackFunction template class with parameters.
-//
-// See base/callback.h.pump for further discussion on this pattern.
-template <typename Sig>
-class JSCCallbackFunction;
-
-$range ARITY 0..MAX_ARITY
-$for ARITY [[
-$range ARG 1..ARITY
-
-
-$if ARITY == 0 [[
-template <typename R>
-class JSCCallbackFunction<R(void)>
- : public CallbackFunction<R(void)> {
-]] $else [[
-template <typename R, $for ARG , [[typename A$(ARG)]]>
-class JSCCallbackFunction<R($for ARG , [[A$(ARG)]])>
- : public CallbackFunction<R($for ARG , [[A$(ARG)]])> {
-]]
-
- public:
- explicit JSCCallbackFunction(JSC::JSFunction* callable)
- : callable_(callable) { DCHECK(callable_); }
-
- CallbackResult<R> Run($for ARG , [[
-
- typename base::internal::CallbackParamTraits<A$(ARG)>::ForwardType a$(ARG)]])
- const OVERRIDE {
- TRACE_EVENT0("cobalt::script::javascriptcore", "JSCCallbackFunction::Run");
- DCHECK(callable_);
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(callable_->globalObject());
- JSC::JSLockHolder lock(global_object->globalData());
-
- // https://www.w3.org/TR/WebIDL/#es-invoking-callback-functions
- // Callback 'this' is set to null, unless overridden by other specifications
- JSC::JSValue this_value = JSC::jsNull();
- JSC::MarkedArgumentBuffer args;
- $for ARG [[args.append(ToJSValue(global_object, a$(ARG)));
- ]]
-
- JSC::CallData call_data;
- JSC::CallType call_type =
- JSC::JSFunction::getCallData(callable_, call_data);
- JSC::ExecState* exec_state = global_object->globalExec();
- JSC::JSGlobalData& global_data = global_object->globalData();
- JSC::JSValue retval =
- JSC::call(exec_state, callable_, call_type, call_data, this_value, args);
- CallbackResult<R> callback_result;
- if (exec_state->hadException()) {
- DLOG(WARNING) << "Exception in callback: "
- << util::GetExceptionString(exec_state);
-
- exec_state->clearException();
- callback_result.exception = true;
- } else {
- callback_result = internal::ConvertReturnValue<R>(exec_state, retval);
- }
- return callback_result;
- }
-
- JSC::JSFunction* callable() const { return callable_; }
-
- private:
- JSC::JSFunction* callable_;
-};
-
-]]
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_JSC_CALLBACK_FUNCTION_H_
diff --git a/src/cobalt/script/javascriptcore/jsc_callback_function_holder.h b/src/cobalt/script/javascriptcore/jsc_callback_function_holder.h
deleted file mode 100644
index eeb641f..0000000
--- a/src/cobalt/script/javascriptcore/jsc_callback_function_holder.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2015 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.
- */
-
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_JSC_CALLBACK_FUNCTION_HOLDER_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_JSC_CALLBACK_FUNCTION_HOLDER_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/script_object.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-// Implementation of the ScriptObject interface for JSCCallbackFunctions.
-template <typename CallbackFunction>
-class JSCCallbackFunctionHolder : public ScriptObject<CallbackFunction> {
- public:
- typedef JSCCallbackFunction<typename CallbackFunction::Signature>
- JSCCallbackFunctionClass;
- typedef ScriptObject<CallbackFunction> BaseClass;
-
- JSCCallbackFunctionHolder() : script_object_registry_(NULL) {}
-
- explicit JSCCallbackFunctionHolder(
- const JSCCallbackFunctionClass& cb,
- ScriptObjectRegistry* script_object_registry)
- : jsc_callable_(cb), script_object_registry_(script_object_registry) {
- JSC::validateCell(jsc_callable_.value().callable());
- }
-
- void RegisterOwner(Wrappable* owner) OVERRIDE {
- JSC::validateCell(jsc_callable_.value().callable());
- script_object_registry_->RegisterObjectOwner(
- owner, jsc_callable_.value().callable());
- }
-
- void DeregisterOwner(Wrappable* owner) OVERRIDE {
- // callable_ may be in the process of being garbage collected.
- script_object_registry_->DeregisterObjectOwner(
- owner, jsc_callable_.value().callable());
- }
-
- const CallbackFunction* GetScriptObject() const OVERRIDE {
- return jsc_callable_ ? &jsc_callable_.value() : NULL;
- }
-
- scoped_ptr<BaseClass> MakeCopy() const OVERRIDE {
- DCHECK(jsc_callable_);
- return make_scoped_ptr<BaseClass>(new JSCCallbackFunctionHolder(
- jsc_callable_.value(), script_object_registry_));
- }
-
- bool EqualTo(const BaseClass& other) const OVERRIDE {
- const JSCCallbackFunctionHolder* jsc_other =
- base::polymorphic_downcast<const JSCCallbackFunctionHolder*>(&other);
- if (!jsc_callable_) {
- return !jsc_other->jsc_callable_;
- }
- DCHECK(jsc_callable_);
- DCHECK(jsc_other->jsc_callable_);
- return jsc_callable_->callable() == jsc_other->jsc_callable_->callable();
- }
-
- private:
- base::optional<JSCCallbackFunctionClass> jsc_callable_;
- ScriptObjectRegistry* script_object_registry_;
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_JSC_CALLBACK_FUNCTION_HOLDER_H_
diff --git a/src/cobalt/script/javascriptcore/jsc_callback_function_impl.h b/src/cobalt/script/javascriptcore/jsc_callback_function_impl.h
deleted file mode 100644
index c95a14a..0000000
--- a/src/cobalt/script/javascriptcore/jsc_callback_function_impl.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2015 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.
- */
-
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_JSC_CALLBACK_FUNCTION_IMPL_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_JSC_CALLBACK_FUNCTION_IMPL_H_
-
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-namespace internal {
-// Helper template functions for Callback functions' return values before being
-// returned to Cobalt.
-// Converts the return value from JavaScript into the correct Cobalt type, or
-// sets the exception bit if conversion fails.
-template <typename R>
-inline CallbackResult<R> ConvertReturnValue(JSC::ExecState* exec_state,
- JSC::JSValue jsvalue) {
- // TODO: Pass conversion flags to callback function return value.
- const int kConversionFlags = 0;
- CallbackResult<R> callback_result;
- LoggingExceptionState exception_state;
- FromJSValue(exec_state, jsvalue, kConversionFlags, &exception_state,
- &callback_result.result);
- callback_result.exception = exception_state.is_exception_set();
- return callback_result;
-}
-template <>
-inline CallbackResult<void> ConvertReturnValue(JSC::ExecState* exec_state,
- JSC::JSValue jsvalue) {
- // No conversion necessary.
- return CallbackResult<void>();
-}
-} // namespace internal
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_JSC_CALLBACK_FUNCTION_IMPL_H_
diff --git a/src/cobalt/script/javascriptcore/jsc_callback_interface.cc b/src/cobalt/script/javascriptcore/jsc_callback_interface.cc
deleted file mode 100644
index 967d24e..0000000
--- a/src/cobalt/script/javascriptcore/jsc_callback_interface.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2016 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.
- */
-
-#include "cobalt/script/javascriptcore/jsc_callback_interface.h"
-
-#include "base/logging.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSScope.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-// Helper class to get the actual callable object from a JSObject.
-JSC::CallType GetCallableForCallbackInterface(
- JSC::ExecState* exec_state, JSC::JSObject* implementing_object,
- const char* property_name, JSC::JSValue* out_callable,
- JSC::CallData* out_call_data) {
- DCHECK(implementing_object);
- DCHECK(out_callable);
- DCHECK(out_call_data);
-
- JSC::JSValue callable = implementing_object;
- JSC::CallType call_type = JSC::getCallData(callable, *out_call_data);
- if (call_type == JSC::CallTypeNone) {
- JSC::Identifier identifier(exec_state, property_name);
- callable = implementing_object->get(exec_state, identifier);
- call_type = JSC::getCallData(callable, *out_call_data);
- }
- if (call_type != JSC::CallTypeNone) {
- *out_callable = callable;
- }
- return call_type;
-}
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
diff --git a/src/cobalt/script/javascriptcore/jsc_callback_interface.h b/src/cobalt/script/javascriptcore/jsc_callback_interface.h
deleted file mode 100644
index 2c62925..0000000
--- a/src/cobalt/script/javascriptcore/jsc_callback_interface.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2016 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.
- */
-
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_JSC_CALLBACK_INTERFACE_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_JSC_CALLBACK_INTERFACE_H_
-
-#include "cobalt/script/callback_interface_traits.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/CallFrame.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/CallData.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSValue.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-// Helper class to get the actual callable object from a JSObject.
-JSC::CallType GetCallableForCallbackInterface(
- JSC::ExecState* exec_state, JSC::JSObject* implementing_object,
- const char* property_name, JSC::JSValue* out_callable,
- JSC::CallData* out_call_data);
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_JSC_CALLBACK_INTERFACE_H_
diff --git a/src/cobalt/script/javascriptcore/jsc_callback_interface_holder.h b/src/cobalt/script/javascriptcore/jsc_callback_interface_holder.h
deleted file mode 100644
index 686e442..0000000
--- a/src/cobalt/script/javascriptcore/jsc_callback_interface_holder.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2016 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.
- */
-
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_JSC_CALLBACK_INTERFACE_HOLDER_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_JSC_CALLBACK_INTERFACE_HOLDER_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface.h"
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/script_object.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-template <typename CallbackInterface>
-class JSCCallbackInterfaceHolder : public ScriptObject<CallbackInterface> {
- public:
- typedef typename CallbackInterfaceTraits<
- CallbackInterface>::JSCCallbackInterfaceClass JSCCallbackInterface;
- typedef ScriptObject<CallbackInterface> BaseClass;
-
- JSCCallbackInterfaceHolder() : script_object_registry_(NULL) {}
- JSCCallbackInterfaceHolder(const JSCCallbackInterface& callback_interface,
- ScriptObjectRegistry* script_object_registry)
- : callback_interface_(callback_interface),
- script_object_registry_(script_object_registry) {}
-
- void RegisterOwner(Wrappable* owner) OVERRIDE {
- DCHECK(callback_interface_);
- JSC::JSObject* implementing_object =
- callback_interface_->implementing_object();
- JSC::validateCell(implementing_object);
- script_object_registry_->RegisterObjectOwner(owner, implementing_object);
- }
-
- void DeregisterOwner(Wrappable* owner) OVERRIDE {
- // The implementing object may be NULL if it's been garbage collected. Still
- // call Deregister in this case.
- DCHECK(callback_interface_);
- JSC::JSObject* implementing_object =
- callback_interface_->implementing_object();
- script_object_registry_->DeregisterObjectOwner(owner, implementing_object);
- }
-
- const CallbackInterface* GetScriptObject() const OVERRIDE {
- return callback_interface_ ? &callback_interface_.value() : NULL;
- }
-
- scoped_ptr<ScriptObject<CallbackInterface> > MakeCopy() const OVERRIDE {
- DCHECK(callback_interface_);
- return make_scoped_ptr<BaseClass>(new JSCCallbackInterfaceHolder(
- callback_interface_.value(), script_object_registry_));
- }
-
- bool EqualTo(const BaseClass& other) const OVERRIDE {
- const JSCCallbackInterfaceHolder* jsc_other =
- base::polymorphic_downcast<const JSCCallbackInterfaceHolder*>(&other);
- if (!callback_interface_) {
- return !jsc_other->callback_interface_;
- }
- DCHECK(callback_interface_);
- DCHECK(jsc_other->callback_interface_);
- return callback_interface_->implementing_object() ==
- jsc_other->callback_interface_->implementing_object();
- }
-
- private:
- base::optional<JSCCallbackInterface> callback_interface_;
- ScriptObjectRegistry* script_object_registry_;
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_JSC_CALLBACK_INTERFACE_HOLDER_H_
diff --git a/src/cobalt/script/javascriptcore/jsc_debugger.cc b/src/cobalt/script/javascriptcore/jsc_debugger.cc
deleted file mode 100644
index 78c3a63..0000000
--- a/src/cobalt/script/javascriptcore/jsc_debugger.cc
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * Copyright 2015 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.
- */
-
-#include "cobalt/script/javascriptcore/jsc_debugger.h"
-
-#include <cstdlib>
-#include <string>
-
-#include "base/logging.h"
-#include "base/string_number_conversions.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/javascriptcore/jsc_call_frame.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/jsc_source_provider.h"
-
-#include "third_party/WebKit/Source/JavaScriptCore/debugger/DebuggerCallFrame.h"
-#include "third_party/WebKit/Source/JavaScriptCore/heap/MarkedBlock.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/CallFrame.h"
-#include "third_party/WebKit/Source/JavaScriptCore/parser/SourceProvider.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Executable.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSCell.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalData.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSScope.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSValue.h"
-
-namespace cobalt {
-namespace script {
-
-// Static factory method declared in public interface.
-scoped_ptr<ScriptDebugger> ScriptDebugger::CreateDebugger(
- GlobalEnvironment* global_environment, Delegate* delegate) {
- return scoped_ptr<ScriptDebugger>(
- new javascriptcore::JSCDebugger(global_environment, delegate));
-}
-
-namespace javascriptcore {
-
-namespace {
-// Type used to store a set of source providers.
-typedef WTF::HashSet<JSC::SourceProvider*> SourceProviderSet;
-
-// Functor to iterate over the JS cells and gather source providers.
-class GathererFunctor : public JSC::MarkedBlock::VoidFunctor {
- public:
- GathererFunctor(JSC::JSGlobalObject* global_object,
- SourceProviderSet* source_providers)
- : global_object_(global_object), source_providers_(source_providers) {}
-
- void operator()(JSC::JSCell* cell) {
- JSC::JSFunction* function = JSC::jsDynamicCast<JSC::JSFunction*>(cell);
- if (function && !function->isHostFunction() &&
- function->scope()->globalObject() == global_object_ &&
- function->executable()->isFunctionExecutable()) {
- source_providers_->add(
- JSC::jsCast<JSC::FunctionExecutable*>(function->executable())
- ->source()
- .provider());
- }
- }
-
- private:
- SourceProviderSet* source_providers_;
- JSC::JSGlobalObject* global_object_;
-};
-
-// Uses the GatherorFunctor defined above to gather all the currently parsed
-// source providers defined in |global_object| and populate |source_providers|.
-// This is called once by the |attach| method; the script debugger is
-// automatically notified of subsequently parsed scripts via the |source_parsed|
-// method.
-void GatherSourceProviders(JSC::JSGlobalObject* global_object,
- SourceProviderSet* source_providers) {
- DCHECK(global_object);
- DCHECK(source_providers);
- source_providers->clear();
- GathererFunctor gatherer_functor(global_object, source_providers);
- JSC::JSGlobalData& global_data = global_object->globalData();
- global_data.heap.objectSpace().forEachLiveCell(gatherer_functor);
-}
-
-intptr_t StringToIntptr(const std::string& input) {
- COMPILE_ASSERT(sizeof(int64) >= sizeof(intptr_t),
- int64_not_big_enough_to_store_intptr_t);
- int64 as_int64 = 0;
- bool did_convert = base::StringToInt64(input, &as_int64);
- DCHECK(did_convert);
- return static_cast<intptr_t>(as_int64);
-}
-} // namespace
-
-JSCDebugger::JSCDebugger(GlobalEnvironment* global_environment,
- Delegate* delegate)
- : global_environment_(global_environment),
- delegate_(delegate),
- pause_on_exceptions_(kNone),
- pause_on_next_statement_(false),
- pause_on_call_frame_(NULL),
- current_call_frame_(NULL),
- current_source_id_(0),
- current_line_number_(0),
- current_column_number_(0),
- is_paused_(false) {}
-
-JSCDebugger::~JSCDebugger() {
- if (GetGlobalObject()->debugger() == this) {
- detach(GetGlobalObject());
- }
-}
-
-void JSCDebugger::Attach() {
- if (GetGlobalObject()->debugger() == NULL) {
- attach(GetGlobalObject());
- } else {
- DLOG(WARNING) << "Debugger is already attached.";
- }
-}
-
-void JSCDebugger::Detach() {
- if (GetGlobalObject()->debugger() == this) {
- detach(GetGlobalObject());
- } else {
- DLOG(WARNING) << "Debugger is not attached.";
- }
-}
-
-void JSCDebugger::Pause() {
- pause_on_next_statement_ = true;
- pause_on_call_frame_ = NULL;
-}
-
-void JSCDebugger::Resume() {
- pause_on_next_statement_ = false;
- pause_on_call_frame_ = NULL;
-}
-
-void JSCDebugger::SetBreakpoint(const std::string& script_id, int line_number,
- int column_number) {
- // Convert the string script_id used by devtools into the intptr_t source_id
- // used internally.
- intptr_t source_id = StringToIntptr(script_id);
-
- breakpoints_.push_back(Breakpoint(source_id, line_number, column_number));
-}
-
-script::ScriptDebugger::PauseOnExceptionsState
-JSCDebugger::SetPauseOnExceptions(PauseOnExceptionsState state) {
- const PauseOnExceptionsState previous_state = pause_on_exceptions_;
- pause_on_exceptions_ = state;
- return previous_state;
-}
-
-void JSCDebugger::StepInto() {
- pause_on_next_statement_ = true;
- pause_on_call_frame_ = NULL;
-}
-
-void JSCDebugger::StepOut() {
- pause_on_next_statement_ = false;
- const JSC::CallFrame* call_frame = current_call_frame_.callFrame();
- pause_on_call_frame_ = call_frame ? call_frame->callerFrame() : NULL;
-}
-
-void JSCDebugger::StepOver() {
- pause_on_next_statement_ = false;
- pause_on_call_frame_ = current_call_frame_.callFrame();
- DCHECK(pause_on_call_frame_);
-}
-
-JSCGlobalObject* JSCDebugger::GetGlobalObject() const {
- return base::polymorphic_downcast<JSCGlobalEnvironment*>(global_environment_)
- ->global_object();
-}
-
-void JSCDebugger::attach(JSC::JSGlobalObject* global_object) {
- DCHECK(global_object);
- JSC::Debugger::attach(global_object);
-
- // Gather the source providers and call |sourceParsed| on each one.
- // Any scripts parsed after this point will automatically invoke a call
- // to |sourceParsed|.
- SourceProviderSet source_providers;
- GatherSourceProviders(global_object, &source_providers);
-
- for (SourceProviderSet::iterator iter = source_providers.begin();
- iter != source_providers.end(); ++iter) {
- sourceParsed(global_object->globalExec(), *iter, -1, String());
- }
-}
-
-void JSCDebugger::detach(JSC::JSGlobalObject* global_object) {
- DCHECK(global_object);
- JSC::Debugger::detach(global_object);
- delegate_->OnScriptDebuggerDetach("canceled_by_user");
-}
-
-void JSCDebugger::sourceParsed(JSC::ExecState* exec_state,
- JSC::SourceProvider* source_provider,
- int error_line,
- const WTF::String& error_message) {
- UNREFERENCED_PARAMETER(exec_state);
- DCHECK(source_provider);
-
- if (error_line < 0) {
- // Script was parsed successfully.
- delegate_->OnScriptParsed(
- scoped_ptr<SourceProvider>(new JSCSourceProvider(source_provider)));
- } else {
- // Script failed to parse.
- delegate_->OnScriptFailedToParse(
- scoped_ptr<SourceProvider>(new JSCSourceProvider(
- source_provider, error_line, error_message.utf8().data())));
- }
-}
-
-void JSCDebugger::exception(const JSC::DebuggerCallFrame& call_frame,
- intptr_t source_id, int line_number,
- int column_number, bool has_handler) {
- if (pause_on_exceptions_ == kAll ||
- (pause_on_exceptions_ == kUncaught && !has_handler)) {
- pause_on_next_statement_ = true;
- pause_on_call_frame_ = NULL;
- }
-
- UpdateAndPauseIfNeeded(call_frame, source_id, line_number, column_number);
-}
-
-void JSCDebugger::atStatement(const JSC::DebuggerCallFrame& call_frame,
- intptr_t source_id, int line_number,
- int column_number) {
- UpdateAndPauseIfNeeded(call_frame, source_id, line_number, column_number);
-}
-
-void JSCDebugger::callEvent(const JSC::DebuggerCallFrame& call_frame,
- intptr_t source_id, int line_number,
- int column_number) {
- UpdateAndPauseIfNeeded(call_frame, source_id, line_number, column_number);
-}
-
-void JSCDebugger::returnEvent(const JSC::DebuggerCallFrame& call_frame,
- intptr_t source_id, int line_number,
- int column_number) {
- UpdateAndPauseIfNeeded(call_frame, source_id, line_number, column_number);
-}
-
-void JSCDebugger::willExecuteProgram(const JSC::DebuggerCallFrame& call_frame,
- intptr_t source_id, int line_number,
- int column_number) {
- UpdateAndPauseIfNeeded(call_frame, source_id, line_number, column_number);
-}
-
-void JSCDebugger::didExecuteProgram(const JSC::DebuggerCallFrame& call_frame,
- intptr_t source_id, int line_number,
- int column_number) {
- UpdateAndPauseIfNeeded(call_frame, source_id, line_number, column_number);
-}
-
-void JSCDebugger::didReachBreakpoint(const JSC::DebuggerCallFrame& call_frame,
- intptr_t source_id, int line_number,
- int column_number) {
- pause_on_next_statement_ = true;
- pause_on_call_frame_ = NULL;
- UpdateAndPauseIfNeeded(call_frame, source_id, line_number, column_number);
-}
-
-void JSCDebugger::UpdateAndPauseIfNeeded(
- const JSC::DebuggerCallFrame& call_frame, intptr_t source_id,
- int line_number, int column_number) {
- // Don't do anything if we're currently paused. We want to remember the call
- // frame and source location at the point we paused, not override them with
- // any debugging scripts that get evaluated while paused.
- if (is_paused_) {
- return;
- }
-
- UpdateSourceLocation(source_id, line_number, column_number);
- UpdateCallFrame(call_frame);
- PauseIfNeeded(call_frame);
-}
-
-void JSCDebugger::UpdateSourceLocation(intptr_t source_id, int line_number,
- int column_number) {
- current_source_id_ = source_id;
- current_line_number_ = line_number;
- current_column_number_ = column_number;
-}
-
-void JSCDebugger::UpdateCallFrame(const JSC::DebuggerCallFrame& call_frame) {
- current_call_frame_ = call_frame;
-}
-
-void JSCDebugger::PauseIfNeeded(const JSC::DebuggerCallFrame& call_frame) {
- // Determine whether we should pause.
- bool will_pause = pause_on_next_statement_;
- will_pause |=
- pause_on_call_frame_ && pause_on_call_frame_ == call_frame.callFrame();
- will_pause |= IsBreakpointAtCurrentLocation();
-
- if (!will_pause) {
- return;
- }
-
- // Set the |is_paused_| state for the remainder of this function.
- ScopedPausedState paused(this);
-
- // Delegate handles the actual blocking of the thread to implement Pause.
- delegate_->OnScriptDebuggerPause(scoped_ptr<CallFrame>(
- new JSCCallFrame(call_frame, current_source_id_, current_line_number_,
- current_column_number_)));
-}
-
-bool JSCDebugger::IsBreakpointAtCurrentLocation() const {
- for (BreakpointVector::const_iterator it = breakpoints_.begin();
- it != breakpoints_.end(); ++it) {
- if (it->source_id == current_source_id_ &&
- it->line_number == current_line_number_ &&
- (it->column_number == 0 ||
- it->column_number == current_column_number_)) {
- return true;
- }
- }
- return false;
-}
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
diff --git a/src/cobalt/script/javascriptcore/jsc_debugger.h b/src/cobalt/script/javascriptcore/jsc_debugger.h
deleted file mode 100644
index 7c0b03b..0000000
--- a/src/cobalt/script/javascriptcore/jsc_debugger.h
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright 2015 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.
- */
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_JSC_DEBUGGER_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_JSC_DEBUGGER_H_
-
-#include <string>
-#include <vector>
-
-#include "base/compiler_specific.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/script_debugger.h"
-#include "cobalt/script/source_provider.h"
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/debugger/Debugger.h"
-#include "third_party/WebKit/Source/JavaScriptCore/debugger/DebuggerCallFrame.h"
-#include "third_party/WebKit/Source/WTF/wtf/HashSet.h"
-#include "third_party/WebKit/Source/WTF/wtf/text/WTFString.h"
-
-namespace JSC {
-class ExecState;
-class JSGlobalData;
-class JSGlobalObject;
-class JSScope;
-class JSValue;
-class SourceProvider;
-}
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-// JavaScriptCore-specific implementation of a JavaScript debugger.
-// Uses multiple inheritance in accordance with the C++ style guide to extend
-// JSC::Debugger and implement ScriptDebugger.
-//
-// Only the ScriptDebugger is publicly exposed.
-// This class is not designed to be thread-safe - it is assumed that all
-// public methods will be run on the same message loop as the JavaScript
-// global object to which this debugger connects.
-class JSCDebugger : protected JSC::Debugger, public ScriptDebugger {
- public:
- JSCDebugger(GlobalEnvironment* global_environment, Delegate* delegate);
- ~JSCDebugger() OVERRIDE;
-
- // Implementation of ScriptDebugger.
- void Attach() OVERRIDE;
- void Detach() OVERRIDE;
- void Pause() OVERRIDE;
- void Resume() OVERRIDE;
- void SetBreakpoint(const std::string& script_id, int line_number,
- int column_number) OVERRIDE;
- PauseOnExceptionsState SetPauseOnExceptions(
- PauseOnExceptionsState state) OVERRIDE;
- void StepInto() OVERRIDE;
- void StepOut() OVERRIDE;
- void StepOver() OVERRIDE;
-
- protected:
- // Hides a non-virtual JSC::Debugger method with the same name.
- void attach(JSC::JSGlobalObject* global_object);
-
- // The following methods are overrides of pure virtual methods in
- // JSC::Debugger, hence the non-standard names.
- void detach(JSC::JSGlobalObject* global_object) OVERRIDE;
-
- void sourceParsed(JSC::ExecState* exec_state,
- JSC::SourceProvider* source_provider, int error_line,
- const WTF::String& error_message) OVERRIDE;
-
- void exception(const JSC::DebuggerCallFrame& call_frame, intptr_t source_id,
- int line_number, int column_number, bool has_handler) OVERRIDE;
-
- void atStatement(const JSC::DebuggerCallFrame& call_frame, intptr_t source_id,
- int line_number, int column_number) OVERRIDE;
-
- void callEvent(const JSC::DebuggerCallFrame& call_frame, intptr_t source_id,
- int line_number, int column_number) OVERRIDE;
-
- void returnEvent(const JSC::DebuggerCallFrame& call_frame, intptr_t source_id,
- int line_number, int column_number) OVERRIDE;
-
- void willExecuteProgram(const JSC::DebuggerCallFrame& call_frame,
- intptr_t source_id, int line_number,
- int column_number) OVERRIDE;
-
- void didExecuteProgram(const JSC::DebuggerCallFrame& call_frame,
- intptr_t source_id, int line_number,
- int column_number) OVERRIDE;
-
- void didReachBreakpoint(const JSC::DebuggerCallFrame& call_frame,
- intptr_t source_id, int line_number,
- int column_number) OVERRIDE;
-
- private:
- // Physical breakpoint corresponding to a specific source location.
- // TODO: Include other attributes, e.g. condition.
- struct Breakpoint {
- Breakpoint(intptr_t source_id, int line_number, int column_number)
- : source_id(source_id),
- line_number(line_number),
- column_number(column_number) {}
- intptr_t source_id;
- int line_number;
- int column_number;
- };
-
- typedef std::vector<Breakpoint> BreakpointVector;
-
- // Sets the |is_paused_| member of the debugger while in scope, unsets it
- // on destruction.
- class ScopedPausedState {
- public:
- explicit ScopedPausedState(JSCDebugger* debugger) : debugger(debugger) {
- debugger->is_paused_ = true;
- }
- ~ScopedPausedState() { debugger->is_paused_ = false; }
-
- private:
- JSCDebugger* debugger;
- };
-
- // Convenience function to get the global object pointer from the proxy.
- JSCGlobalObject* GetGlobalObject() const;
-
- // Update functions called by the overridden methods from JSC:Debugger above
- // (e.g. |atStatement|) as script is executed.
- void UpdateAndPauseIfNeeded(const JSC::DebuggerCallFrame& call_frame,
- intptr_t source_id, int line_number,
- int column_number);
- void UpdateSourceLocation(intptr_t source_id, int line_number,
- int column_number);
- void UpdateCallFrame(const JSC::DebuggerCallFrame& call_frame);
- void PauseIfNeeded(const JSC::DebuggerCallFrame& call_frame);
-
- // Sends event notifications via |delegate_|.
- void SendPausedEvent(const JSC::DebuggerCallFrame& call_frame);
- void SendResumedEvent();
-
- // Whether any of the currently active breakpoints matches the current
- // source location.
- bool IsBreakpointAtCurrentLocation() const;
-
- base::ThreadChecker thread_checker_;
- GlobalEnvironment* global_environment_;
-
- // Lifetime managed by the caller of this object's constructor.
- Delegate* delegate_;
-
- // Whether script execution pauses on exceptions.
- PauseOnExceptionsState pause_on_exceptions_;
-
- // Code execution control flags. Script execution can pause on the next
- // statement, or on a specific call frame.
- bool pause_on_next_statement_;
- JSC::CallFrame* pause_on_call_frame_;
-
- // Current call frame.
- JSC::DebuggerCallFrame current_call_frame_;
-
- // Current source location.
- intptr_t current_source_id_;
- int current_line_number_;
- int current_column_number_;
-
- // Whether script execution is currently paused.
- bool is_paused_;
-
- // Currently active breakpoints.
- BreakpointVector breakpoints_;
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_JSC_DEBUGGER_H_
diff --git a/src/cobalt/script/javascriptcore/jsc_engine.cc b/src/cobalt/script/javascriptcore/jsc_engine.cc
deleted file mode 100644
index 178f66b..0000000
--- a/src/cobalt/script/javascriptcore/jsc_engine.cc
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-#include "cobalt/script/javascriptcore/jsc_engine.h"
-
-#include "base/logging.h"
-#include "base/memory/singleton.h"
-#include "base/message_loop.h"
-#include "base/synchronization/lock.h"
-#include "base/time.h"
-#include "cobalt/base/c_val.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/InitializeThreading.h"
-#include "third_party/WebKit/Source/WTF/wtf/OSAllocator.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-namespace {
-
-class JSCEngineStats {
- public:
- JSCEngineStats();
-
- static JSCEngineStats* GetInstance() {
- return Singleton<JSCEngineStats,
- StaticMemorySingletonTraits<JSCEngineStats> >::get();
- }
-
- void JSCEngineCreated() {
- base::AutoLock auto_lock(lock_);
- ++js_engine_count_;
- }
-
- void JSCEngineDestroyed() {
- base::AutoLock auto_lock(lock_);
- --js_engine_count_;
- }
-
- size_t UpdateMemoryStatsAndReturnReserved() {
- base::AutoLock auto_lock(lock_);
- if (js_engine_count_.value() == 0) {
- return 0;
- }
- return OSAllocator::getCurrentBytesAllocated();
- }
-
- private:
- friend struct StaticMemorySingletonTraits<JSCEngineStats>;
-
- base::Lock lock_;
- base::CVal<size_t> js_engine_count_;
-};
-
-JSCEngineStats::JSCEngineStats()
- : js_engine_count_("Count.JS.Engine", 0,
- "Total JavaScript engine registered.") {}
-
-} // namespace
-
-JSCEngine::JSCEngine() {
- global_data_ = JSC::JSGlobalData::create(JSC::LargeHeap);
- JSCEngineStats::GetInstance()->JSCEngineCreated();
-}
-
-JSCEngine::~JSCEngine() {
- DCHECK(thread_checker_.CalledOnValidThread());
- JSCEngineStats::GetInstance()->JSCEngineDestroyed();
- script_object_registry_.ClearEntries();
-}
-
-scoped_refptr<GlobalEnvironment> JSCEngine::CreateGlobalEnvironment() {
- DCHECK(thread_checker_.CalledOnValidThread());
- return new JSCGlobalEnvironment(this);
-}
-
-void JSCEngine::CollectGarbage() {
- DCHECK(thread_checker_.CalledOnValidThread());
- JSC::JSLockHolder lock(global_data_.get());
- DCHECK(global_data_->heap.isSafeToCollect());
- global_data_->heap.collectAllGarbage();
-}
-
-void JSCEngine::ReportExtraMemoryCost(size_t bytes) {
- DCHECK(thread_checker_.CalledOnValidThread());
- JSC::JSLockHolder lock(global_data_.get());
- global_data_->heap.reportExtraMemoryCost(bytes);
-}
-
-size_t JSCEngine::UpdateMemoryStatsAndReturnReserved() {
- return JSCEngineStats::GetInstance()->UpdateMemoryStatsAndReturnReserved();
-}
-
-} // namespace javascriptcore
-
-scoped_ptr<JavaScriptEngine> JavaScriptEngine::CreateEngine() {
- // Documentation in InitializeThreading.h states this function should be
- // called from the main thread. However, calling it here from the thread each
- // engine is created on appears to show no difference in practice.
- JSC::initializeThreading();
-
- // There must be at most one JSGlobalData instance created per thread.
- scoped_ptr<javascriptcore::JSCEngine> engine(new javascriptcore::JSCEngine());
-
- // Global data should be of Default type - one per thread.
- DCHECK(!engine->global_data()->usingAPI());
-
- return engine.PassAs<JavaScriptEngine>();
-}
-
-} // namespace script
-} // namespace cobalt
diff --git a/src/cobalt/script/javascriptcore/jsc_engine.h b/src/cobalt/script/javascriptcore/jsc_engine.h
deleted file mode 100644
index 7ee06e0..0000000
--- a/src/cobalt/script/javascriptcore/jsc_engine.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_JSC_ENGINE_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_JSC_ENGINE_H_
-
-#include "base/threading/thread_checker.h"
-#include "cobalt/script/javascript_engine.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalData.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-class JSCEngine : public JavaScriptEngine {
- public:
- JSCEngine();
- ~JSCEngine() OVERRIDE;
-
- scoped_refptr<GlobalEnvironment> CreateGlobalEnvironment() OVERRIDE;
- void CollectGarbage() OVERRIDE;
- void ReportExtraMemoryCost(size_t bytes) OVERRIDE;
- size_t UpdateMemoryStatsAndReturnReserved() OVERRIDE;
-
- JSC::JSGlobalData* global_data() { return global_data_.get(); }
- ScriptObjectRegistry* script_object_registry() {
- return &script_object_registry_;
- }
-
- private:
- base::ThreadChecker thread_checker_;
- ScriptObjectRegistry script_object_registry_;
- RefPtr<JSC::JSGlobalData> global_data_;
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_JSC_ENGINE_H_
diff --git a/src/cobalt/script/javascriptcore/jsc_exception_state.cc b/src/cobalt/script/javascriptcore/jsc_exception_state.cc
deleted file mode 100644
index b1c63d2..0000000
--- a/src/cobalt/script/javascriptcore/jsc_exception_state.cc
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2015 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.
- */
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-
-#include <string>
-
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ErrorInstance.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-void JSCExceptionState::SetException(
- const scoped_refptr<ScriptException>& exception) {
- DCHECK(thread_checker_.CalledOnValidThread());
- JSC::JSLockHolder lock(&global_object_->globalData());
- exception_ =
- global_object_->wrapper_factory()->GetWrapper(global_object_, exception);
- DCHECK(exception_->isErrorInstance());
-}
-
-void JSCExceptionState::SetSimpleException(MessageType message_type, ...) {
- DCHECK(thread_checker_.CalledOnValidThread());
- JSC::JSLockHolder lock(&global_object_->globalData());
-
- va_list arguments;
- va_start(arguments, message_type);
- WTF::String error_string = ToWTFString(
- base::StringPrintV(GetExceptionMessageFormat(message_type), arguments));
- va_end(arguments);
-
- switch (GetSimpleExceptionType(message_type)) {
- case kError:
- exception_ = JSC::createError(global_object_, error_string);
- break;
- case kTypeError:
- exception_ = JSC::createTypeError(global_object_, error_string);
- break;
- case kRangeError:
- exception_ = JSC::createRangeError(global_object_, error_string);
- break;
- case kReferenceError:
- exception_ = JSC::createReferenceError(global_object_, error_string);
- break;
- case kSyntaxError:
- exception_ = JSC::createSyntaxError(global_object_, error_string);
- break;
- case kURIError:
- exception_ = JSC::createURIError(global_object_, error_string);
- break;
- }
-}
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
diff --git a/src/cobalt/script/javascriptcore/jsc_exception_state.h b/src/cobalt/script/javascriptcore/jsc_exception_state.h
deleted file mode 100644
index 1dfd273..0000000
--- a/src/cobalt/script/javascriptcore/jsc_exception_state.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2015 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.
- */
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_JSC_EXCEPTION_STATE_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_JSC_EXCEPTION_STATE_H_
-
-#include "base/threading/thread_checker.h"
-#include "cobalt/script/exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-class JSCExceptionState : public ExceptionState {
- public:
- explicit JSCExceptionState(JSCGlobalObject* global_object)
- : global_object_(global_object), exception_(NULL) {}
- // ExceptionState interface
- void SetException(const scoped_refptr<ScriptException>& exception) OVERRIDE;
- void SetSimpleException(MessageType message_type, ...) OVERRIDE;
-
- bool is_exception_set() const { return (exception_ != NULL); }
- JSC::JSObject* exception_object() { return exception_; }
-
- private:
- JSCGlobalObject* global_object_;
- JSC::JSObject* exception_;
- base::ThreadChecker thread_checker_;
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_JSC_EXCEPTION_STATE_H_
diff --git a/src/cobalt/script/javascriptcore/jsc_global_environment.cc b/src/cobalt/script/javascriptcore/jsc_global_environment.cc
deleted file mode 100644
index 98e6d01..0000000
--- a/src/cobalt/script/javascriptcore/jsc_global_environment.cc
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-
-#include <algorithm>
-#include <string>
-
-#include "base/debug/trace_event.h"
-#include "base/string_util.h"
-#include "base/stringprintf.h"
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/javascriptcore/jsc_engine.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/javascriptcore/jsc_source_code.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/heap/StrongInlines.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Completion.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-void JSCGlobalEnvironment::PreventGarbageCollection(
- const scoped_refptr<Wrappable>& wrappable) {
- DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(global_object_);
-
- JSC::JSLockHolder lock(global_object_->globalData());
-
- JSC::JSObject* wrapper = global_object_->wrapper_factory()->GetWrapper(
- global_object_.get(), wrappable);
- global_object_->object_cache()->CacheJSObject(wrapper);
-}
-
-JSCGlobalEnvironment::~JSCGlobalEnvironment() {
- if (global_object_.get()) {
- global_object_->setReportEvalCallback(NULL);
- }
-}
-
-void JSCGlobalEnvironment::CreateGlobalObject() {
- DCHECK(thread_checker_.CalledOnValidThread());
- JSC::JSLockHolder lock(engine_->global_data());
-
- JSCGlobalObject* global_object = JSCGlobalObject::Create(
- engine_->global_data(), engine_->script_object_registry());
- SetGlobalObject(global_object);
-}
-
-void JSCGlobalEnvironment::AllowGarbageCollection(
- const scoped_refptr<Wrappable>& wrappable) {
- DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(global_object_);
-
- JSC::JSLockHolder lock(global_object_->globalData());
-
- JSC::JSObject* wrapper = global_object_->wrapper_factory()->GetWrapper(
- global_object_.get(), wrappable);
- global_object_->object_cache()->UncacheJSObject(wrapper);
-}
-
-void JSCGlobalEnvironment::DisableEval(const std::string& message) {
- DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(global_object_);
- global_object_->setEvalEnabled(false, message.c_str());
-}
-
-void JSCGlobalEnvironment::EnableEval() {
- DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(global_object_);
- global_object_->setEvalEnabled(true);
-}
-
-void JSCGlobalEnvironment::DisableJit() {}
-
-void JSCGlobalEnvironment::Bind(const std::string& identifier,
- const scoped_refptr<Wrappable>& impl) {
- DCHECK(thread_checker_.CalledOnValidThread());
- javascriptcore::JSCGlobalObject* jsc_global_object =
- base::polymorphic_downcast<javascriptcore::JSCGlobalEnvironment*>(this)
- ->global_object();
-
- JSC::JSLockHolder lock(&jsc_global_object->globalData());
-
- JSC::JSObject* wrapper =
- jsc_global_object->wrapper_factory()->GetWrapper(jsc_global_object, impl);
-
- JSC::Identifier jsc_identifier =
- JSC::Identifier(jsc_global_object->globalExec(), identifier.c_str());
-
- // Make sure the property we are binding doesn't already exist.
- DCHECK(!jsc_global_object->hasOwnProperty(jsc_global_object->globalExec(),
- jsc_identifier));
-
- // Add the property to the global object.
- jsc_global_object->putDirect(jsc_global_object->globalData(), jsc_identifier,
- wrapper);
-}
-
-bool JSCGlobalEnvironment::EvaluateScript(
- const scoped_refptr<SourceCode>& source_code, std::string* out_result) {
- DCHECK(thread_checker_.CalledOnValidThread());
- JSC::JSLockHolder lock(global_object_->globalData());
-
- JSC::JSValue result;
- bool success = EvaluateScriptInternal(source_code, &result);
- if (out_result) {
- if (!success) {
- *out_result =
- util::GetExceptionString(global_object_->globalExec(), result);
- } else {
- WTF::String return_string =
- result.toWTFString(global_object_->globalExec());
- *out_result = return_string.utf8().data();
- }
- }
-
- return success;
-}
-
-bool JSCGlobalEnvironment::EvaluateScript(
- const scoped_refptr<SourceCode>& source_code,
- const scoped_refptr<Wrappable>& owning_object,
- base::optional<OpaqueHandleHolder::Reference>* out_opaque_handle) {
- DCHECK(thread_checker_.CalledOnValidThread());
- JSC::JSLockHolder lock(global_object_->globalData());
-
- JSC::JSValue result;
- if (!EvaluateScriptInternal(source_code, &result)) {
- std::string exception =
- util::GetExceptionString(global_object_->globalExec(), result);
- DLOG(ERROR) << exception;
- return false;
- }
- JSCObjectHandle jsc_object_handle(JSC::asObject(result));
- JSCObjectHandleHolder jsc_object_holder(
- JSCObjectHandle(JSC::asObject(result)),
- global_object_->script_object_registry());
- out_opaque_handle->emplace(owning_object.get(), jsc_object_holder);
- return true;
-}
-
-std::vector<StackFrame> JSCGlobalEnvironment::GetStackTrace(int max_frames) {
- DCHECK(thread_checker_.CalledOnValidThread());
- return util::GetStackTrace(global_object_->globalExec(), max_frames);
-}
-
-void JSCGlobalEnvironment::reportEval() {
- if (!report_eval_cb_.is_null()) {
- report_eval_cb_.Run();
- }
-}
-
-void JSCGlobalEnvironment::SetGlobalObject(JSCGlobalObject* jsc_global_object) {
- DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK_EQ(reinterpret_cast<uintptr_t>(global_object_.get()), NULL);
- global_object_ =
- JSC::Strong<JSCGlobalObject>(*engine_->global_data(), jsc_global_object);
- global_object_->setReportEvalCallback(this);
- // Disable eval() unless it's explicitly enabled (by CSP, for example).
- DisableEval("eval() is disabled by default.");
-}
-
-bool JSCGlobalEnvironment::EvaluateScriptInternal(
- const scoped_refptr<SourceCode>& source_code, JSC::JSValue* out_result) {
- TRACE_EVENT0("cobalt::script::javascriptcore",
- "JSCGlobalEnvironment::EvaluateScriptInternal");
- DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(global_object_);
-
- JSC::ExecState* exec = global_object_->globalExec();
- // Downcast to the JSC implementation of the SourceCode interface.
- JSCSourceCode* jsc_source_code =
- base::polymorphic_downcast<JSCSourceCode*>(source_code.get());
-
- // Evaluate the source code and gather the return value and exception if
- // one occurred.
- JSC::JSValue exception;
- JSC::JSValue return_value = JSC::evaluate(exec, jsc_source_code->source(),
- JSC::JSValue(), // thisValue
- &exception);
- if (exception) {
- *out_result = exception;
- exec->clearException();
- return false;
- } else {
- *out_result = return_value;
- return true;
- }
-}
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
diff --git a/src/cobalt/script/javascriptcore/jsc_global_environment.h b/src/cobalt/script/javascriptcore/jsc_global_environment.h
deleted file mode 100644
index dcb530d..0000000
--- a/src/cobalt/script/javascriptcore/jsc_global_environment.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_JSC_GLOBAL_ENVIRONMENT_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_JSC_GLOBAL_ENVIRONMENT_H_
-
-#include <string>
-#include <vector>
-
-#include "base/callback.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/script/global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_engine.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-class ScriptObjectRegistry;
-
-// GlobalEnvironment is a ref-counted object that is managed by the browser, and
-// JavaScriptCore's JSGlobalObject is a garbage-collected object.
-// It should only be accessed from the thread that created it.
-class JSCGlobalEnvironment : public GlobalEnvironment,
- public JSC::ReportEvalCallback {
- public:
- explicit JSCGlobalEnvironment(JSCEngine* engine) : engine_(engine) {}
- ~JSCGlobalEnvironment() OVERRIDE;
-
- void CreateGlobalObject() OVERRIDE;
-
- // out_result holds the string value of the last statement executed, or
- // an exception message in the case of an exception.
- bool EvaluateScript(const scoped_refptr<SourceCode>& source_code,
- std::string* out_result) OVERRIDE;
-
- bool EvaluateScript(const scoped_refptr<SourceCode>& script_utf8,
- const scoped_refptr<Wrappable>& owning_object,
- base::optional<OpaqueHandleHolder::Reference>*
- out_opaque_handle) OVERRIDE;
-
- std::vector<StackFrame> GetStackTrace(int max_frames = 0) OVERRIDE;
-
- // Create the wrapper object if it has not been created, and add it to
- // the JSObjectCache.
- void PreventGarbageCollection(
- const scoped_refptr<Wrappable>& wrappable) OVERRIDE;
-
- // Remove a reference to the wrapper object from the JSObjectCache.
- void AllowGarbageCollection(
- const scoped_refptr<Wrappable>& wrappable) OVERRIDE;
-
- void DisableEval(const std::string& message) OVERRIDE;
-
- void EnableEval() OVERRIDE;
-
- void DisableJit() OVERRIDE;
-
- void SetReportEvalCallback(const base::Closure& report_eval) OVERRIDE {
- DCHECK(thread_checker_.CalledOnValidThread());
- report_eval_cb_ = report_eval;
- }
-
- // Dynamically bind an object to the global object.
- void Bind(const std::string& identifier,
- const scoped_refptr<Wrappable>& impl) OVERRIDE;
-
- JSCGlobalObject* global_object() { return global_object_.get(); }
-
- JSCEngine* engine() { return engine_; }
-
- private:
- // JSC::ReportEvalCallback
- void reportEval() OVERRIDE;
-
- void SetGlobalObject(JSCGlobalObject* jsc_global_object);
-
- bool EvaluateScriptInternal(const scoped_refptr<SourceCode>& source_code,
- JSC::JSValue* out_result);
-
- base::ThreadChecker thread_checker_;
- // Strong references prevent the object from getting garbage collected. It
- // is used as a root for object graph traversal.
- JSC::Strong<JSCGlobalObject> global_object_;
- JSCEngine* engine_;
- base::Closure report_eval_cb_;
- friend class GlobalEnvironment;
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_JSC_GLOBAL_ENVIRONMENT_H_
diff --git a/src/cobalt/script/javascriptcore/jsc_global_object.cc b/src/cobalt/script/javascriptcore/jsc_global_object.cc
deleted file mode 100644
index 9122348..0000000
--- a/src/cobalt/script/javascriptcore/jsc_global_object.cc
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-
-#include "base/logging.h"
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-const JSC::ClassInfo JSCGlobalObject::s_info = {
- "JSCGlobalObject", JSC::JSGlobalObject::s_classinfo(), 0, 0,
- CREATE_METHOD_TABLE(JSCGlobalObject)};
-
-JSCGlobalObject* JSCGlobalObject::Create(
- JSC::JSGlobalData* global_data,
- ScriptObjectRegistry* script_object_registry) {
- JSC::Structure* structure = JSC::Structure::create(
- *global_data,
- NULL, // JSC::JSGlobalObject*
- JSC::jsNull(), // prototype
- JSC::TypeInfo(JSC::GlobalObjectType, JSC::JSGlobalObject::StructureFlags),
- &s_info);
- JSCGlobalObject* global_object =
- new (NotNull, JSC::allocateCell<JSCGlobalObject>(global_data->heap))
- JSCGlobalObject(global_data, structure, script_object_registry, NULL,
- scoped_ptr<WrapperFactory>(), NULL);
- global_object->finishCreation(*global_data);
- global_data->heap.addFinalizer(global_object, destroy);
- return global_object;
-}
-
-JSCGlobalObject::JSCGlobalObject(JSC::JSGlobalData* global_data,
- JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<Wrappable>& wrappable,
- scoped_ptr<WrapperFactory> wrapper_factory,
- EnvironmentSettings* environment_settings)
- : JSC::JSGlobalObject(*global_data, structure),
- global_interface_(wrappable),
- wrapper_factory_(wrapper_factory.Pass()),
- object_cache_(new JSObjectCache(this)),
- script_object_registry_(script_object_registry),
- environment_settings_(environment_settings) {}
-
-std::vector<script::StackFrame> JSCGlobalObject::GetStackTrace(int max_frames) {
- return util::GetStackTrace(globalExec(), max_frames);
-}
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
diff --git a/src/cobalt/script/javascriptcore/jsc_global_object.h b/src/cobalt/script/javascriptcore/jsc_global_object.h
deleted file mode 100644
index 89f0dc6..0000000
--- a/src/cobalt/script/javascriptcore/jsc_global_object.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_JSC_GLOBAL_OBJECT_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_JSC_GLOBAL_OBJECT_H_
-
-#include <vector>
-
-#include "base/bind.h"
-#include "base/hash_tables.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/weak_ptr.h"
-#include "cobalt/script/environment_settings.h"
-#include "cobalt/script/javascriptcore/js_object_cache.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-#include "cobalt/script/stack_frame.h"
-#include "cobalt/script/wrappable.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalData.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-// JSCGlobalObject is JavaScriptCore's Global Object in Cobalt. It inherits from
-// JSC::GlobalObject so we can use this wherever a JSC::GlobalObject would be
-// used, allowing us to downcast to JSCGlobalObject.
-// JSCGlobalObject is a garbage-collected object.
-class JSCGlobalObject : public JSC::JSGlobalObject {
- public:
- // Create a new garbage-collected JSCGlobalObject instance.
- static JSCGlobalObject* Create(JSC::JSGlobalData* global_data,
- ScriptObjectRegistry* script_object_registry);
-
- scoped_refptr<Wrappable> global_interface() { return global_interface_; }
-
- const WrapperFactory* wrapper_factory() { return wrapper_factory_.get(); }
-
- JSObjectCache* object_cache() { return object_cache_.get(); }
-
- ScriptObjectRegistry* script_object_registry() {
- return script_object_registry_;
- }
-
- // Getters for CallWith= arguments
- EnvironmentSettings* GetEnvironmentSettings() {
- return environment_settings_;
- }
- std::vector<StackFrame> GetStackTrace(int max_frames = 0);
-
- // JavaScriptCore stuff
- DECLARE_CLASSINFO();
-
- // Classes that inherit from JSC::GlobalObject set this flag, and set a
- // finalizer method on creation.
- static const bool needsDestruction = false;
-
- // Statically override this to ensure that we visit objects that are cached
- // or otherwise should not be garbage collected.
- static void visitChildren(JSC::JSCell* cell,
- JSC::SlotVisitor& visitor) { // NOLINT
- JSC::JSGlobalObject::visitChildren(cell, visitor);
- // Cast the JSC::JSCell* to a JSCGlobalObject, and call the non-static
- // visit_children function.
- ASSERT_GC_OBJECT_INHERITS(cell, &s_info);
- JSCGlobalObject* this_object = JSC::jsCast<JSCGlobalObject*>(cell);
- this_object->object_cache_->VisitChildren(&visitor);
- this_object->script_object_registry_->VisitOwnedObjects(
- this_object->global_interface_.get(), &visitor);
- }
-
- // static override. This will be called when this object is garbage collected.
- static void destroy(JSC::JSCell* cell) {
- // This is necessary when a garbage-collected object has a non-trivial
- // destructor.
- static_cast<JSCGlobalObject*>(cell)->~JSCGlobalObject();
- }
-
- protected:
- JSCGlobalObject(JSC::JSGlobalData* global_data, JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<Wrappable>& global_interface,
- scoped_ptr<WrapperFactory> wrapper_factory,
- EnvironmentSettings* environment_settings);
-
- private:
- scoped_refptr<Wrappable> global_interface_;
- scoped_ptr<WrapperFactory> wrapper_factory_;
- scoped_ptr<JSObjectCache> object_cache_;
- ScriptObjectRegistry* script_object_registry_;
- EnvironmentSettings* environment_settings_;
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_JSC_GLOBAL_OBJECT_H_
diff --git a/src/cobalt/script/javascriptcore/jsc_object_handle.h b/src/cobalt/script/javascriptcore/jsc_object_handle.h
deleted file mode 100644
index 3b79a93..0000000
--- a/src/cobalt/script/javascriptcore/jsc_object_handle.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_JSC_OBJECT_HANDLE_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_JSC_OBJECT_HANDLE_H_
-
-#include "cobalt/script/opaque_handle.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-// A wrapper around a JSC::JSObject that can be passed into Cobalt as an
-// opaque script object.
-class JSCObjectHandle : public OpaqueHandle {
- public:
- explicit JSCObjectHandle(JSC::JSObject* wrapper) : handle_(wrapper) {}
- JSC::JSObject* handle() const { return handle_; }
-
- private:
- JSC::JSObject* handle_;
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_JSC_OBJECT_HANDLE_H_
diff --git a/src/cobalt/script/javascriptcore/jsc_object_handle_holder.h b/src/cobalt/script/javascriptcore/jsc_object_handle_holder.h
deleted file mode 100644
index 6c1c172..0000000
--- a/src/cobalt/script/javascriptcore/jsc_object_handle_holder.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2015 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.
- */
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_JSC_OBJECT_HANDLE_HOLDER_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_JSC_OBJECT_HANDLE_HOLDER_H_
-
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle.h"
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-// Implementation of OpaqueHandleHolder class which is used to pass opaque
-// script handles into Cobalt.
-class JSCObjectHandleHolder : public OpaqueHandleHolder {
- public:
- JSCObjectHandleHolder() : script_object_registry_(NULL) {}
-
- explicit JSCObjectHandleHolder(const JSCObjectHandle& handle,
- ScriptObjectRegistry* script_object_registry)
- : object_handle_(handle),
- script_object_registry_(script_object_registry) {}
-
- void RegisterOwner(Wrappable* owner) OVERRIDE {
- JSC::JSObject* object = js_object();
- JSC::validateCell(object);
- script_object_registry_->RegisterObjectOwner(owner, object);
- }
-
- void DeregisterOwner(Wrappable* owner) OVERRIDE {
- JSC::JSObject* object = js_object();
- // object may be in the process of being garbage collected, so do not
- // dereference it.
- script_object_registry_->DeregisterObjectOwner(owner, object);
- }
-
- const OpaqueHandle* GetScriptObject() const OVERRIDE {
- return object_handle_ ? &object_handle_.value() : NULL;
- }
-
- scoped_ptr<OpaqueHandleHolder> MakeCopy() const OVERRIDE {
- DCHECK(object_handle_);
- return make_scoped_ptr<OpaqueHandleHolder>(new JSCObjectHandleHolder(
- object_handle_.value(), script_object_registry_));
- }
-
- bool EqualTo(const OpaqueHandleHolder& other) const OVERRIDE {
- const JSCObjectHandleHolder* jsc_other =
- base::polymorphic_downcast<const JSCObjectHandleHolder*>(&other);
- if (!object_handle_) {
- return !jsc_other->object_handle_;
- }
- DCHECK(object_handle_);
- DCHECK(jsc_other->object_handle_);
- return object_handle_->handle() == jsc_other->object_handle_->handle();
- }
-
- JSC::JSObject* js_object() const {
- DCHECK(object_handle_);
- return object_handle_->handle();
- }
-
- private:
- base::optional<JSCObjectHandle> object_handle_;
- ScriptObjectRegistry* script_object_registry_;
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_JSC_OBJECT_HANDLE_HOLDER_H_
diff --git a/src/cobalt/script/javascriptcore/jsc_property_enumerator.h b/src/cobalt/script/javascriptcore/jsc_property_enumerator.h
deleted file mode 100644
index 709cf08..0000000
--- a/src/cobalt/script/javascriptcore/jsc_property_enumerator.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2015 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.
- */
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_JSC_PROPERTY_ENUMERATOR_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_JSC_PROPERTY_ENUMERATOR_H_
-
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/property_enumerator.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-// Implements the PropertyEnumerator interface. Enumerated properties will
-// be added to the JSC::PropertyNameArray that is passed in at construction.
-class JSCPropertyEnumerator : public PropertyEnumerator {
- public:
- JSCPropertyEnumerator(JSC::ExecState* exec_state,
- JSC::PropertyNameArray* property_names)
- : exec_state_(exec_state), property_names_(property_names) {}
- void AddProperty(const std::string& property_name) OVERRIDE {
- WTF::String wtf_string = ToWTFString(property_name);
- JSC::Identifier identifier(exec_state_, wtf_string.impl());
- property_names_->add(identifier);
- }
-
- private:
- JSC::ExecState* exec_state_;
- JSC::PropertyNameArray* property_names_;
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_JSC_PROPERTY_ENUMERATOR_H_
diff --git a/src/cobalt/script/javascriptcore/jsc_scope.cc b/src/cobalt/script/javascriptcore/jsc_scope.cc
deleted file mode 100644
index c503aa6..0000000
--- a/src/cobalt/script/javascriptcore/jsc_scope.cc
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2016 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.
- */
-
-#include "cobalt/script/javascriptcore/jsc_scope.h"
-
-#include "base/logging.h"
-#include "base/string_number_conversions.h"
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalData.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSScope.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSValue.h"
-
-namespace cobalt {
-namespace script {
-
-namespace javascriptcore {
-
-JSCScope::JSCScope(JSC::JSScope* scope) : scope_(scope), global_object_(NULL) {
- DCHECK(scope_);
- global_object_ = JSC::jsCast<JSCGlobalObject*>(scope->globalObject());
- DCHECK(global_object_);
-
- scope_holder_.reset(new JSCObjectHandleHolder(
- JSCObjectHandle(scope_), global_object_->script_object_registry()));
- DCHECK(scope_holder_);
-}
-
-JSCScope::~JSCScope() {}
-
-const OpaqueHandleHolder* JSCScope::GetObject() { return scope_holder_.get(); }
-
-Scope::Type JSCScope::GetType() {
- DCHECK(scope_);
- int type = scope_->structure()->typeInfo().type();
- std::string type_string;
- switch (type) {
- case JSC::GlobalObjectType:
- return kGlobal;
- case JSC::ActivationObjectType:
- return kLocal;
- default: {
- DLOG(WARNING) << "Unexpected scope type: " << type;
- return kLocal;
- }
- }
-}
-
-scoped_ptr<Scope> JSCScope::GetNext() {
- DCHECK(scope_);
- if (scope_->next()) {
- return scoped_ptr<Scope>(new JSCScope(scope_->next()));
- } else {
- return scoped_ptr<Scope>();
- }
-}
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
diff --git a/src/cobalt/script/javascriptcore/jsc_scope.h b/src/cobalt/script/javascriptcore/jsc_scope.h
deleted file mode 100644
index 1e11e96..0000000
--- a/src/cobalt/script/javascriptcore/jsc_scope.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2016 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.
- */
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_JSC_SCOPE_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_JSC_SCOPE_H_
-
-#include <string>
-
-#include "base/optional.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/scope.h"
-
-namespace JSC {
-class JSScope;
-}
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-// JavaScriptCore-specific implementation of a JavaScript call frame.
-class JSCScope : public Scope {
- public:
- explicit JSCScope(JSC::JSScope* scope);
- ~JSCScope() OVERRIDE;
-
- const OpaqueHandleHolder* GetObject() OVERRIDE;
- Type GetType() OVERRIDE;
- scoped_ptr<Scope> GetNext() OVERRIDE;
-
- private:
- JSC::JSScope* scope_;
- JSCGlobalObject* global_object_;
- scoped_ptr<JSCObjectHandleHolder> scope_holder_;
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_JSC_SCOPE_H_
diff --git a/src/cobalt/script/javascriptcore/jsc_source_code.cc b/src/cobalt/script/javascriptcore/jsc_source_code.cc
deleted file mode 100644
index 7ff4be5..0000000
--- a/src/cobalt/script/javascriptcore/jsc_source_code.cc
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-
-#include "cobalt/script/javascriptcore/jsc_source_code.h"
-
-#include <string>
-
-#include "base/string_util.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/source_code.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/parser/SourceCode.h"
-#include "third_party/WebKit/Source/JavaScriptCore/parser/SourceProvider.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-namespace {
-
-// Similar to JSC::StringSourceProvider, but takes in a UTF-8 string and
-// converts to a UTF-16 WTF string.
-class UTF8StringSourceProvider : public JSC::SourceProvider {
- public:
- static WTF::PassRefPtr<UTF8StringSourceProvider> Create(
- const std::string& source_utf8, const std::string& source_url,
- int line_number, int column_number) {
- return WTF::adoptRef(new UTF8StringSourceProvider(
- source_utf8, source_url, line_number, column_number));
- }
- const WTF::String& source() const OVERRIDE { return source_; }
-
- private:
- explicit UTF8StringSourceProvider(const std::string& source_utf8,
- const std::string& source_url,
- int line_number, int column_number)
- : SourceProvider(
- ToWTFString(source_url),
- WTF::TextPosition(
- WTF::OrdinalNumber::fromOneBasedInt(line_number),
- WTF::OrdinalNumber::fromOneBasedInt(column_number))) {
- source_ = ToWTFString(source_utf8);
- }
- WTF::String source_;
-};
-
-} // namespace
-
-JSCSourceCode::JSCSourceCode(const std::string& source_utf8,
- const base::SourceLocation& source_location) {
- RefPtr<UTF8StringSourceProvider> source_provider =
- UTF8StringSourceProvider::Create(source_utf8, source_location.file_path,
- source_location.line_number,
- source_location.column_number);
- source_ = JSC::SourceCode(source_provider, source_location.line_number);
-}
-
-} // namespace javascriptcore
-
-// static method declared in public interface
-scoped_refptr<SourceCode> SourceCode::CreateSourceCode(
- const std::string& source_utf8,
- const base::SourceLocation& source_location) {
- return new javascriptcore::JSCSourceCode(source_utf8, source_location);
-}
-
-} // namespace script
-} // namespace cobalt
diff --git a/src/cobalt/script/javascriptcore/jsc_source_code.h b/src/cobalt/script/javascriptcore/jsc_source_code.h
deleted file mode 100644
index 2e7e76d..0000000
--- a/src/cobalt/script/javascriptcore/jsc_source_code.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_JSC_SOURCE_CODE_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_JSC_SOURCE_CODE_H_
-
-#include <string>
-
-#include "cobalt/script/source_code.h"
-
-#include "config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/parser/SourceCode.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-class JSCSourceCode : public SourceCode {
- public:
- explicit JSCSourceCode(const std::string& source_utf8,
- const base::SourceLocation& source_location);
- JSC::SourceCode& source() { return source_; }
-
- private:
- JSC::SourceCode source_;
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_JSC_SOURCE_CODE_H_
diff --git a/src/cobalt/script/javascriptcore/jsc_source_provider.cc b/src/cobalt/script/javascriptcore/jsc_source_provider.cc
deleted file mode 100644
index 836b044..0000000
--- a/src/cobalt/script/javascriptcore/jsc_source_provider.cc
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2016 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.
- */
-
-#include "cobalt/script/javascriptcore/jsc_source_provider.h"
-
-#include "base/logging.h"
-#include "base/string_number_conversions.h"
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/parser/SourceProvider.h"
-#include "third_party/WebKit/Source/WTF/wtf/text/CString.h"
-#include "third_party/WebKit/Source/WTF/wtf/text/WTFString.h"
-
-namespace cobalt {
-namespace script {
-
-namespace javascriptcore {
-
-namespace {
-// Conversion from intptr_t to std::string.
-// Used to convert the ID used by JSC::SourceProvider (which is cast from the
-// object pointer) to a string.
-std::string IntptrToString(intptr_t input) {
- COMPILE_ASSERT(sizeof(int64) >= sizeof(intptr_t),
- int64_not_big_enough_to_store_intptr_t);
- int64 input_as_int64 = static_cast<int64>(input);
- return base::Int64ToString(input_as_int64);
-}
-} // namespace
-
-JSCSourceProvider::JSCSourceProvider(JSC::SourceProvider* source_provider)
- : source_provider_(source_provider) {
- DCHECK(source_provider_);
-}
-
-JSCSourceProvider::JSCSourceProvider(JSC::SourceProvider* source_provider,
- int error_line,
- const std::string& error_message)
- : source_provider_(source_provider),
- error_line_(error_line),
- error_message_(error_message) {
- DCHECK(source_provider_);
- DCHECK_GE(error_line, 0);
-}
-
-JSCSourceProvider::~JSCSourceProvider() {}
-
-base::optional<int> JSCSourceProvider::GetEndColumn() {
- // TODO: Work out how to get this from a JSC::SourceProvider.
- // Should be provided for inline scripts.
- return base::nullopt;
-}
-
-base::optional<int> JSCSourceProvider::GetEndLine() {
- // TODO: Work out how to get this from a JSC::SourceProvider.
- // Should be provided for inline scripts.
- return base::nullopt;
-}
-
-base::optional<int> JSCSourceProvider::GetErrorLine() { return error_line_; }
-
-base::optional<std::string> JSCSourceProvider::GetErrorMessage() {
- return error_message_;
-}
-
-std::string JSCSourceProvider::GetScriptId() {
- return IntptrToString(source_provider_->asID());
-}
-
-std::string JSCSourceProvider::GetScriptSource() {
- return source_provider_->source().utf8().data();
-}
-
-base::optional<std::string> JSCSourceProvider::GetSourceMapUrl() {
- // TODO: Determine if we need to support this, and if so, how.
- return base::nullopt;
-}
-
-base::optional<int> JSCSourceProvider::GetStartColumn() {
- return source_provider_->startPosition().m_column.oneBasedInt();
-}
-
-base::optional<int> JSCSourceProvider::GetStartLine() {
- return source_provider_->startPosition().m_line.oneBasedInt();
-}
-
-std::string JSCSourceProvider::GetUrl() {
- return source_provider_->url().utf8().data();
-}
-
-base::optional<bool> JSCSourceProvider::IsContentScript() {
- return base::nullopt;
-}
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
diff --git a/src/cobalt/script/javascriptcore/jsc_source_provider.h b/src/cobalt/script/javascriptcore/jsc_source_provider.h
deleted file mode 100644
index 92bb359..0000000
--- a/src/cobalt/script/javascriptcore/jsc_source_provider.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2016 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.
- */
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_JSC_SOURCE_PROVIDER_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_JSC_SOURCE_PROVIDER_H_
-
-#include <base/optional.h>
-#include <cobalt/script/source_provider.h>
-
-#include <string>
-
-namespace JSC {
-class SourceProvider;
-}
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-// JavaScriptCore-specific implementation of a JavaScript source provider.
-class JSCSourceProvider : public SourceProvider {
- public:
- explicit JSCSourceProvider(JSC::SourceProvider* source_provider);
- JSCSourceProvider(JSC::SourceProvider* source_provider, int error_line,
- const std::string& error_message);
- ~JSCSourceProvider() OVERRIDE;
-
- base::optional<int> GetEndColumn() OVERRIDE;
- base::optional<int> GetEndLine() OVERRIDE;
- base::optional<int> GetErrorLine() OVERRIDE;
- base::optional<std::string> GetErrorMessage() OVERRIDE;
- std::string GetScriptId() OVERRIDE;
- std::string GetScriptSource() OVERRIDE;
- base::optional<std::string> GetSourceMapUrl() OVERRIDE;
- base::optional<int> GetStartColumn() OVERRIDE;
- base::optional<int> GetStartLine() OVERRIDE;
- std::string GetUrl() OVERRIDE;
- base::optional<bool> IsContentScript() OVERRIDE;
-
- private:
- JSC::SourceProvider* source_provider_;
- base::optional<int> error_line_;
- base::optional<std::string> error_message_;
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_JSC_SOURCE_PROVIDER_H_
diff --git a/src/cobalt/script/javascriptcore/jsc_wrapper_handle.h b/src/cobalt/script/javascriptcore/jsc_wrapper_handle.h
deleted file mode 100644
index 53d98b0..0000000
--- a/src/cobalt/script/javascriptcore/jsc_wrapper_handle.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_JSC_WRAPPER_HANDLE_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_JSC_WRAPPER_HANDLE_H_
-
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/wrappable.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-// A wrapper around a JSC::Weak handle to a garbage-collected JSC::JSObject
-// object. It's expected that this is a WrapperBase<T> object.
-class JSCWrapperHandle : public Wrappable::WeakWrapperHandle {
- public:
- explicit JSCWrapperHandle(JSC::PassWeak<JSC::JSObject> wrapper) {
- handle_ = wrapper;
- }
- static JSC::JSObject* GetJSObject(
- const Wrappable::WeakWrapperHandle* handle) {
- if (handle) {
- return base::polymorphic_downcast<const JSCWrapperHandle*>(handle)
- ->handle_.get();
- }
- return NULL;
- }
-
- private:
- JSC::Weak<JSC::JSObject> handle_;
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_JSC_WRAPPER_HANDLE_H_
diff --git a/src/cobalt/script/javascriptcore/numeric_conversion_test.cc b/src/cobalt/script/javascriptcore/numeric_conversion_test.cc
deleted file mode 100644
index ed07bb4..0000000
--- a/src/cobalt/script/javascriptcore/numeric_conversion_test.cc
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Copyright 2015 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.
- */
-
-#include <limits>
-
-#include "cobalt/base/polymorphic_downcast.h"
-#include "cobalt/script/javascript_engine.h"
-#include "cobalt/script/javascriptcore/conversion_helpers.h"
-#include "cobalt/script/javascriptcore/jsc_global_environment.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/testing/mock_exception_state.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSString.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSValue.h"
-#include "third_party/WebKit/Source/WTF/wtf/text/WTFString.h"
-
-using testing::_;
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-namespace {
-
-template <int kNumber>
-JSC::EncodedJSValue JSC_HOST_CALL returnNumberFunction(JSC::ExecState* exec) {
- return JSC::JSValue::encode(JSC::jsNumber(kNumber));
-}
-
-template <typename T>
-class NumericConversionTest : public ::testing::Test {
- public:
- NumericConversionTest()
- : engine_(JavaScriptEngine::CreateEngine()),
- global_environment_(engine_->CreateGlobalEnvironment()),
- jsc_global_object_(NULL),
- exec_state_(NULL) {
- global_environment_->CreateGlobalObject();
- jsc_global_object_ = base::polymorphic_downcast<JSCGlobalEnvironment*>(
- global_environment_.get())
- ->global_object();
- exec_state_ = jsc_global_object_->globalExec();
- }
-
- void AddFunction(JSC::JSObject* object, const char* name,
- JSC::NativeFunction function) {
- int num_arguments = 0;
- JSC::Identifier identifier(jsc_global_object_->globalExec(), name);
- object->putDirect(jsc_global_object_->globalData(), identifier,
- JSC::JSFunction::create(jsc_global_object_->globalExec(),
- jsc_global_object_, num_arguments,
- identifier.string(), function));
- }
-
- const scoped_ptr<JavaScriptEngine> engine_;
- const scoped_refptr<GlobalEnvironment> global_environment_;
- JSCGlobalObject* jsc_global_object_;
- JSC::ExecState* exec_state_;
- testing::MockExceptionState exception_state_;
-};
-
-template <typename T>
-class IntegerConversionTest : public NumericConversionTest<T> {};
-
-template <typename T>
-class FloatingPointConversionTest : public NumericConversionTest<T> {};
-
-typedef ::testing::Types<int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t,
- double> NumericTypes;
-typedef ::testing::Types<int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t>
- IntegerTypes;
-typedef ::testing::Types<double> FloatingPointTypes;
-TYPED_TEST_CASE(NumericConversionTest, NumericTypes);
-TYPED_TEST_CASE(IntegerConversionTest, IntegerTypes);
-TYPED_TEST_CASE(FloatingPointConversionTest, FloatingPointTypes);
-
-template <class T>
-T JSValueToNumber(JSC::ExecState* exec_state, JSC::JSValue js_value,
- int conversion_flags, ExceptionState* exception_state) {
- T value;
- FromJSValue(exec_state, js_value, conversion_flags, exception_state, &value);
- return value;
-}
-
-} // namespace
-
-// Conversion between a JavaScript value and an IDL integer type is described
-// here:
-// https://www.w3.org/TR/WebIDL/#es-byte
-// https://www.w3.org/TR/WebIDL/#es-octet
-// https://www.w3.org/TR/WebIDL/#es-short
-// https://www.w3.org/TR/WebIDL/#es-unsigned-short
-// https://www.w3.org/TR/WebIDL/#es-long
-// https://www.w3.org/TR/WebIDL/#es-unsigned-long
-// https://www.w3.org/TR/WebIDL/#es-double
-// The first step in each of these algorithms is the ToNumber operation:
-// http://es5.github.io/#x9.3
-// ToNumber describes how various non-numeric types should convert to a
-// number.
-
-// ToNumber: http://es5.github.io/#x9.3
-TYPED_TEST(NumericConversionTest, BooleanConversion) {
- EXPECT_EQ(1, JSValueToNumber<TypeParam>(
- this->exec_state_, JSC::jsBoolean(true), kNoConversionFlags,
- &this->exception_state_));
- EXPECT_EQ(0, JSValueToNumber<TypeParam>(
- this->exec_state_, JSC::jsBoolean(false), kNoConversionFlags,
- &this->exception_state_));
-}
-
-// ToNumber applied to the String Type: http://es5.github.io/#x9.3.1
-TYPED_TEST(NumericConversionTest, StringConversion) {
- JSC::ExecState* exec = this->jsc_global_object_->globalExec();
- EXPECT_EQ(0, JSValueToNumber<TypeParam>(
- this->exec_state_, JSC::jsString(this->exec_state_, ""),
- kNoConversionFlags, &this->exception_state_));
- EXPECT_EQ(0, JSValueToNumber<TypeParam>(
- this->exec_state_, JSC::jsString(this->exec_state_, " "),
- kNoConversionFlags, &this->exception_state_));
-
- // Integer types convert NaN to 0, and float types throw a TypeError.
- if (std::numeric_limits<TypeParam>::is_integer) {
- EXPECT_EQ(0, JSValueToNumber<TypeParam>(
- this->exec_state_,
- JSC::jsString(this->exec_state_, "not_a_number"),
- kNoConversionFlags, &this->exception_state_));
- }
-
- EXPECT_EQ(32, JSValueToNumber<TypeParam>(
- this->exec_state_, JSC::jsString(this->exec_state_, "32"),
- kNoConversionFlags, &this->exception_state_));
- EXPECT_EQ(32, JSValueToNumber<TypeParam>(
- this->exec_state_, JSC::jsString(this->exec_state_, "0x20"),
- kNoConversionFlags, &this->exception_state_));
-
- if (!std::numeric_limits<TypeParam>::is_integer) {
- EXPECT_EQ(54.34,
- JSValueToNumber<TypeParam>(
- this->exec_state_, JSC::jsString(this->exec_state_, "54.34"),
- kNoConversionFlags, &this->exception_state_));
- }
-}
-
-// Described in the integer type conversion algorithms:
-// Set x to sign(x)*floor(abs(x))
-// Also in ToUint16, ToInt32, and ToUInt64:
-// 3. Let posInt be sign(number) * floor(abs(number))
-TYPED_TEST(IntegerConversionTest, FloatingPointToIntegerConversion) {
- EXPECT_EQ(5, JSValueToNumber<TypeParam>(this->exec_state_, JSC::jsNumber(5.1),
- kNoConversionFlags,
- &this->exception_state_));
- if (std::numeric_limits<TypeParam>::is_signed) {
- EXPECT_EQ(-5, JSValueToNumber<TypeParam>(
- this->exec_state_, JSC::jsNumber(-5.1),
- kNoConversionFlags, &this->exception_state_));
- }
-}
-
-// http://es5.github.io/#x9.3
-TYPED_TEST(IntegerConversionTest, OtherConversions) {
- EXPECT_EQ(0, JSValueToNumber<TypeParam>(this->exec_state_, JSC::jsNull(),
- kNoConversionFlags,
- &this->exception_state_));
-
- const double kInfinity = std::numeric_limits<double>::infinity();
- const double kNegativeInfinity = -std::numeric_limits<double>::infinity();
- EXPECT_EQ(0, JSValueToNumber<TypeParam>(this->exec_state_, JSC::jsUndefined(),
- kNoConversionFlags,
- &this->exception_state_));
- EXPECT_EQ(0, JSValueToNumber<TypeParam>(
- this->exec_state_, JSC::jsNumber(kInfinity),
- kNoConversionFlags, &this->exception_state_));
- EXPECT_EQ(0, JSValueToNumber<TypeParam>(
- this->exec_state_, JSC::jsNumber(kNegativeInfinity),
- kNoConversionFlags, &this->exception_state_));
- EXPECT_EQ(0, JSValueToNumber<TypeParam>(this->exec_state_, JSC::jsNaN(),
- kNoConversionFlags,
- &this->exception_state_));
-}
-
-// http://es5.github.io/#x9.3
-TYPED_TEST(FloatingPointConversionTest, OtherConversions) {
- EXPECT_EQ(0, JSValueToNumber<TypeParam>(this->exec_state_, JSC::jsNull(),
- kNoConversionFlags,
- &this->exception_state_));
-
- // Check that unrestricted types convert back as expected
- const double kInfinity = std::numeric_limits<double>::infinity();
- const double kNegativeInfinity = -std::numeric_limits<double>::infinity();
-
- // Unrestricted non-finite floating point conversions
- EXPECT_EQ(kInfinity, JSValueToNumber<TypeParam>(
- this->exec_state_, JSC::jsNumber(kInfinity),
- kNoConversionFlags, &this->exception_state_));
- EXPECT_EQ(kNegativeInfinity,
- JSValueToNumber<TypeParam>(
- this->exec_state_, JSC::jsNumber(kNegativeInfinity),
- kNoConversionFlags, &this->exception_state_));
- EXPECT_TRUE(isnan(JSValueToNumber<TypeParam>(this->exec_state_, JSC::jsNaN(),
- kNoConversionFlags,
- &this->exception_state_)));
-
- // Restricted non-finite floating point conversions. These should throw a
- // TypeError.
- EXPECT_CALL(this->exception_state_, SetSimpleExceptionVA(kNotFinite, _))
- .Times(3);
- JSValueToNumber<TypeParam>(this->exec_state_, JSC::jsNumber(kInfinity),
- kConversionFlagRestricted,
- &this->exception_state_);
- JSValueToNumber<TypeParam>(
- this->exec_state_, JSC::jsNumber(kNegativeInfinity),
- kConversionFlagRestricted, &this->exception_state_);
- JSValueToNumber<TypeParam>(this->exec_state_, JSC::jsNaN(),
- kConversionFlagRestricted,
- &this->exception_state_);
-}
-
-// ToNumber (http://es5.github.io/#x9.3) calls the ToPrimitive operation:
-// http://es5.github.io/#x9.1
-// ToPrimitive calls the [[DefaultValue]] method of the object:
-// http://es5.github.io/#x8.12.8
-TYPED_TEST(NumericConversionTest, ObjectConversion) {
- JSC::JSLockHolder lock(this->jsc_global_object_->globalData());
- JSC::Structure* structure =
- JSC::createEmptyObjectStructure(this->jsc_global_object_->globalData(),
- this->jsc_global_object_, JSC::jsNull());
- {
- JSC::JSObject* object =
- JSC::constructEmptyObject(this->exec_state_, structure);
- this->AddFunction(object, "valueOf", &(returnNumberFunction<5>));
- EXPECT_EQ(
- 5, JSValueToNumber<TypeParam>(this->jsc_global_object_->globalExec(),
- JSC::JSValue(object), kNoConversionFlags,
- &this->exception_state_));
- }
- {
- JSC::JSObject* object =
- JSC::constructEmptyObject(this->exec_state_, structure);
- // The conversion algorithm uses the value of toString() if it is
- // a primitive value, which is not necessarily a string.
- this->AddFunction(object, "toString", &(returnNumberFunction<5>));
- EXPECT_EQ(5, JSValueToNumber<TypeParam>(
- this->exec_state_, JSC::JSValue(object),
- kNoConversionFlags, &this->exception_state_));
- }
- {
- JSC::JSObject* object =
- JSC::constructEmptyObject(this->exec_state_, structure);
- EXPECT_EQ(0, JSValueToNumber<TypeParam>(
- this->exec_state_, JSC::JSValue(object),
- kNoConversionFlags, &this->exception_state_));
- }
-}
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
diff --git a/src/cobalt/script/javascriptcore/prototype_base.h b/src/cobalt/script/javascriptcore/prototype_base.h
deleted file mode 100644
index 592b8ce..0000000
--- a/src/cobalt/script/javascriptcore/prototype_base.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_PROTOTYPE_BASE_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_PROTOTYPE_BASE_H_
-
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-// All JavaScriptCore interface object classes will inherit from this.
-class PrototypeBase : public JSC::JSNonFinalObject {
- // This class doesn't have any implementation, and is just used as a common
- // base class.
- protected:
- PrototypeBase(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
- : JSC::JSNonFinalObject(global_object->globalData(), structure) {}
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_PROTOTYPE_BASE_H_
diff --git a/src/cobalt/script/javascriptcore/script_object_registry.cc b/src/cobalt/script/javascriptcore/script_object_registry.cc
deleted file mode 100644
index 2d3b09f..0000000
--- a/src/cobalt/script/javascriptcore/script_object_registry.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2015 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.
- */
-
-#include "cobalt/script/javascriptcore/script_object_registry.h"
-
-#include <utility>
-
-#include "base/stl_util.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-void ScriptObjectRegistry::RegisterObjectOwner(const Wrappable* owner,
- JSC::JSObject* js_object) {
- DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(owner);
- DCHECK(js_object);
- owned_object_multimap_.insert(
- std::make_pair(owner, new JSC::Weak<JSC::JSObject>(js_object)));
-}
-
-void ScriptObjectRegistry::DeregisterObjectOwner(const Wrappable* owner,
- JSC::JSObject* js_object) {
- DCHECK(thread_checker_.CalledOnValidThread());
- std::pair<OwnedObjectMultiMap::iterator, OwnedObjectMultiMap::iterator>
- pair_range;
- pair_range = owned_object_multimap_.equal_range(owner);
- for (OwnedObjectMultiMap::iterator it = pair_range.first;
- it != pair_range.second; ++it) {
- if (it->second->get() == js_object) {
- // There may be multiple mappings between a specific owner and
- // js_object. Only remove the first mapping.
- delete it->second;
- owned_object_multimap_.erase(it);
- return;
- }
- }
-}
-
-void ScriptObjectRegistry::VisitOwnedObjects(Wrappable* owner,
- JSC::SlotVisitor* visitor) {
- DCHECK(thread_checker_.CalledOnValidThread());
- std::pair<OwnedObjectMultiMap::iterator, OwnedObjectMultiMap::iterator>
- pair_range;
- pair_range = owned_object_multimap_.equal_range(owner);
- for (OwnedObjectMultiMap::iterator it = pair_range.first;
- it != pair_range.second; ++it) {
- visitor->appendUnbarrieredWeak(it->second);
- }
-}
-
-void ScriptObjectRegistry::ClearEntries() {
- STLDeleteValues(&owned_object_multimap_);
-}
-
-ScriptObjectRegistry::~ScriptObjectRegistry() {
- // Since the ScriptObjectRegistry is destroyed after JSGlobalData, we can't
- // free any remaining JSC::Weak objects in here since they will try to access
- // structures that have already been destroyed.
- DCHECK_EQ(owned_object_multimap_.size(), 0);
-}
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
diff --git a/src/cobalt/script/javascriptcore/script_object_registry.h b/src/cobalt/script/javascriptcore/script_object_registry.h
deleted file mode 100644
index e503581..0000000
--- a/src/cobalt/script/javascriptcore/script_object_registry.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2015 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.
- */
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_SCRIPT_OBJECT_REGISTRY_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_SCRIPT_OBJECT_REGISTRY_H_
-
-#include "base/hash_tables.h"
-#include "base/threading/thread_checker.h"
-#include "cobalt/script/wrappable.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-// ScriptObjectRegistry maintains the mapping between Wrappable
-// objects and the JSObjects that they reference.
-class ScriptObjectRegistry {
- public:
- // Register an ownership relationship between |owner| and |js_object|.
- // After registering this relationship, VisitOwnedObjects() can be called
- // to visit all objects registered to the owner. DeregisterObjectOwner
- // must be called before |owner| is destroyed.
- void RegisterObjectOwner(const Wrappable* owner, JSC::JSObject* js_object);
-
- // Deregister the mapping of all objects owned by |owner|. js_object may
- // be getting garbage collected so should not be referenced.
- void DeregisterObjectOwner(const Wrappable* owner, JSC::JSObject* js_object);
-
- // Visit objects that are owned by the specified JSObject.
- void VisitOwnedObjects(Wrappable* owner, JSC::SlotVisitor* visitor);
-
- // Clear all entries and free allocated memory. This should be called before
- // the JSGlobalData is destroyed.
- void ClearEntries();
-
- ~ScriptObjectRegistry();
-
- private:
- typedef base::hash_multimap<const Wrappable*, JSC::Weak<JSC::JSObject>*>
- OwnedObjectMultiMap;
- base::ThreadChecker thread_checker_;
- OwnedObjectMultiMap owned_object_multimap_;
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_SCRIPT_OBJECT_REGISTRY_H_
diff --git a/src/cobalt/script/javascriptcore/thread_local_hash_table.cc b/src/cobalt/script/javascriptcore/thread_local_hash_table.cc
deleted file mode 100644
index ecd089f..0000000
--- a/src/cobalt/script/javascriptcore/thread_local_hash_table.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2016 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.
- */
-#include "cobalt/script/javascriptcore/thread_local_hash_table.h"
-
-#include <map>
-
-#include "base/logging.h"
-#include "base/memory/singleton.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-namespace {
-typedef std::map<const JSC::ClassInfo*, JSC::HashTable> HashTableMap;
-}
-
-// static
-ThreadLocalHashTable* ThreadLocalHashTable::GetInstance() {
- return Singleton<ThreadLocalHashTable>::get();
-}
-
-ThreadLocalHashTable::ThreadLocalHashTable() : slot_(SlotDestructor) {}
-
-ThreadLocalHashTable::~ThreadLocalHashTable() {
- // If there is any data stored in our slot on this thread, destroy it now
- // before freeing the slot itself, otherwise that data will be leaked.
- SlotDestructor(slot_.Get());
- slot_.Free();
-}
-
-JSC::HashTable* ThreadLocalHashTable::GetHashTable(
- const JSC::ClassInfo* class_info, const JSC::HashTable& prototype) {
- if (!slot_.Get()) {
- slot_.Set(new HashTableMap);
- }
- DCHECK(slot_.Get());
- HashTableMap* hash_table_map = static_cast<HashTableMap*>(slot_.Get());
- if (hash_table_map->find(class_info) == hash_table_map->end()) {
- (*hash_table_map)[class_info] = prototype;
- }
- return &(*hash_table_map)[class_info];
-}
-
-// static
-void ThreadLocalHashTable::SlotDestructor(void* value) {
- HashTableMap* hash_table_map = static_cast<HashTableMap*>(value);
- if (hash_table_map) {
- for (HashTableMap::iterator it = hash_table_map->begin();
- it != hash_table_map->end(); ++it) {
- it->second.deleteTable();
- }
- delete hash_table_map;
- }
-}
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
diff --git a/src/cobalt/script/javascriptcore/thread_local_hash_table.h b/src/cobalt/script/javascriptcore/thread_local_hash_table.h
deleted file mode 100644
index 2801d77..0000000
--- a/src/cobalt/script/javascriptcore/thread_local_hash_table.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2016 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.
- */
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_THREAD_LOCAL_HASH_TABLE_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_THREAD_LOCAL_HASH_TABLE_H_
-
-#include "base/memory/singleton.h"
-#include "base/threading/thread_local_storage.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/Lookup.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-class ThreadLocalHashTable {
- public:
- static ThreadLocalHashTable* GetInstance();
-
- JSC::HashTable* GetHashTable(const JSC::ClassInfo* class_info,
- const JSC::HashTable& prototype);
-
- private:
- ThreadLocalHashTable();
- ~ThreadLocalHashTable();
- static void SlotDestructor(void* value);
-
- base::ThreadLocalStorage::Slot slot_;
-
- friend struct DefaultSingletonTraits<ThreadLocalHashTable>;
- DISALLOW_COPY_AND_ASSIGN(ThreadLocalHashTable);
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_THREAD_LOCAL_HASH_TABLE_H_
diff --git a/src/cobalt/script/javascriptcore/type_traits.h b/src/cobalt/script/javascriptcore/type_traits.h
deleted file mode 100644
index f7bba62..0000000
--- a/src/cobalt/script/javascriptcore/type_traits.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2016 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.
- */
-
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_TYPE_TRAITS_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_TYPE_TRAITS_H_
-
-#include "cobalt/script/callback_interface_traits.h"
-#include "cobalt/script/javascriptcore/jsc_callback_function_holder.h"
-#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
-#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
-#include "cobalt/script/opaque_handle.h"
-#include "cobalt/script/script_object.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-template <typename T>
-struct TypeTraits {
- // The type to convert into from a JS Value in the bindings implementation.
- typedef T ConversionType;
- // Type type returned from a Cobalt implementation of a bound function.
- typedef T ReturnType;
-};
-
-template <>
-struct TypeTraits<OpaqueHandle> {
- typedef JSCObjectHandleHolder ConversionType;
- typedef const ScriptObject<OpaqueHandle>* ReturnType;
-};
-
-template <typename Sig>
-struct TypeTraits<CallbackFunction<Sig> > {
- typedef JSCCallbackFunctionHolder<CallbackFunction<Sig> > ConversionType;
- typedef const ScriptObject<CallbackFunction<Sig> >* ReturnType;
-};
-
-template <typename CallbackInterface>
-struct TypeTraits<CallbackInterfaceTraits<CallbackInterface> > {
- typedef JSCCallbackInterfaceHolder<CallbackInterface> ConversionType;
- typedef const ScriptObject<CallbackInterface>* ReturnType;
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_TYPE_TRAITS_H_
diff --git a/src/cobalt/script/javascriptcore/union_type_conversion_forward.h b/src/cobalt/script/javascriptcore/union_type_conversion_forward.h
deleted file mode 100644
index 04f0d97..0000000
--- a/src/cobalt/script/javascriptcore/union_type_conversion_forward.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// This file was GENERATED by command:
-// pump.py union_type_conversion_forward.h.pump
-// DO NOT EDIT BY HAND!!!
-
-
-/*
- * Copyright 2015 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.
- */
-
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_UNION_TYPE_CONVERSION_FORWARD_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_UNION_TYPE_CONVERSION_FORWARD_H_
-
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/union_type.h"
-
-// Forward declaration for ToJSValue and FromJSValue for IDL union types.
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-template <typename T1, typename T2>
-JSC::JSValue ToJSValue(JSCGlobalObject* global_object,
- const script::UnionType2<T1, T2>& in_union);
-
-template <typename T1, typename T2>
-void FromJSValue(JSC::ExecState* exec_state, JSC::JSValue jsvalue,
- int conversion_flags, ExceptionState* exception_state,
- script::UnionType2<T1, T2>* out_union);
-
-template <typename T1, typename T2, typename T3>
-JSC::JSValue ToJSValue(JSCGlobalObject* global_object,
- const script::UnionType3<T1, T2, T3>& in_union);
-
-template <typename T1, typename T2, typename T3>
-void FromJSValue(JSC::ExecState* exec_state, JSC::JSValue jsvalue,
- int conversion_flags, ExceptionState* exception_state,
- script::UnionType3<T1, T2, T3>* out_union);
-
-template <typename T1, typename T2, typename T3, typename T4>
-JSC::JSValue ToJSValue(JSCGlobalObject* global_object,
- const script::UnionType4<T1, T2, T3, T4>& in_union);
-
-template <typename T1, typename T2, typename T3, typename T4>
-void FromJSValue(JSC::ExecState* exec_state, JSC::JSValue jsvalue,
- int conversion_flags, ExceptionState* exception_state,
- script::UnionType4<T1, T2, T3, T4>* out_union);
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_UNION_TYPE_CONVERSION_FORWARD_H_
diff --git a/src/cobalt/script/javascriptcore/union_type_conversion_forward.h.pump b/src/cobalt/script/javascriptcore/union_type_conversion_forward.h.pump
deleted file mode 100644
index d6268cd..0000000
--- a/src/cobalt/script/javascriptcore/union_type_conversion_forward.h.pump
+++ /dev/null
@@ -1,58 +0,0 @@
-$$ This is a pump file for generating file templates. Pump is a python
-$$ script that is part of the Google Test suite of utilities. Description
-$$ can be found here:
-$$
-$$ http://code.google.com/p/googletest/wiki/PumpManual
-$$
-
-$$ Maximum number of different member types in a union.
-$var MAX_MEMBERS = 4
-
-/*
- * Copyright 2015 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.
- */
-
-#ifndef SCRIPT_JAVASCRIPTCORE_UNION_TYPE_CONVERSION_FORWARD_H_
-#define SCRIPT_JAVASCRIPTCORE_UNION_TYPE_CONVERSION_FORWARD_H_
-
-#include "cobalt/script/javascriptcore/jsc_exception_state.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/union_type.h"
-
-// Forward declaration for ToJSValue and FromJSValue for IDL union types.
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-$range NUM_MEMBERS 2..MAX_MEMBERS
-$for NUM_MEMBERS [[
-$range TYPE 1..NUM_MEMBERS
-
-template <$for TYPE , [[typename T$(TYPE)]]>
-JSC::JSValue ToJSValue(JSCGlobalObject* global_object, const script::UnionType$(NUM_MEMBERS)<$for TYPE , [[T$(TYPE)]]>& in_union);
-
-template <$for TYPE , [[typename T$(TYPE)]]>
-void FromJSValue(JSC::ExecState* exec_state, JSC::JSValue jsvalue,
- int conversion_flags, ExceptionState* exception_state,
- script::UnionType$(NUM_MEMBERS)<$for TYPE , [[T$(TYPE)]]>* out_union);
-
-]] $$ for NUM_MEMBERS
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // SCRIPT_JAVASCRIPTCORE_UNION_TYPE_CONVERSION_FORWARD_H_
diff --git a/src/cobalt/script/javascriptcore/union_type_conversion_impl.h b/src/cobalt/script/javascriptcore/union_type_conversion_impl.h
deleted file mode 100644
index 9122056..0000000
--- a/src/cobalt/script/javascriptcore/union_type_conversion_impl.h
+++ /dev/null
@@ -1,625 +0,0 @@
-// This file was GENERATED by command:
-// pump.py union_type_conversion_impl.h.pump
-// DO NOT EDIT BY HAND!!!
-
-/*
- * Copyright 2015 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.
- */
-
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_UNION_TYPE_CONVERSION_IMPL_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_UNION_TYPE_CONVERSION_IMPL_H_
-
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/union_type.h"
-
-// Conversion to/from JSC::JSValue for IDL union types.
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-template <typename T1, typename T2>
-JSC::JSValue ToJSValue(JSCGlobalObject* global_object,
- const script::UnionType2<T1, T2>& in_union) {
- if (in_union.template IsType<T1>()) {
- return ToJSValue(global_object, in_union.template AsType<T1>());
- }
- if (in_union.template IsType<T2>()) {
- return ToJSValue(global_object, in_union.template AsType<T2>());
- }
- NOTREACHED();
- return JSC::jsUndefined();
-}
-
-template <typename T1, typename T2>
-void FromJSValue(JSC::ExecState* exec_state, JSC::JSValue jsvalue,
- int conversion_flags, ExceptionState* exception_state,
- script::UnionType2<T1, T2>* out_union) {
- DCHECK_EQ(0, conversion_flags);
- // JS -> IDL type conversion procedure described here:
- // http://heycam.github.io/webidl/#es-union
-
- // 1. If the union type includes a nullable type and V is null or undefined,
- // then return the IDL value null.
- if (jsvalue.isNull() || jsvalue.isUndefined()) {
- // If the type was nullable or undefined, we should have caught that as a
- // part of the base::optional<T> conversion.
- NOTREACHED();
- return;
- }
- // Typedef for readability.
- typedef ::cobalt::script::internal::UnionTypeTraits<T1> UnionTypeTraitsT1;
- typedef ::cobalt::script::internal::UnionTypeTraits<T2> UnionTypeTraitsT2;
-
- // Forward declare all potential types
- T1 t1;
- T2 t2;
-
- // 3.1 If types includes an interface type that V implements, then return the
- // IDL value that is a reference to the object V.
- // 3.2 If types includes object, then return the IDL value that is a reference
- // to the object V.
- //
- // The specification doesn't dictate what should happen if V implements more
- // than one of the interfaces. For example, if V implements interface B and
- // interface B inherits from interface A, what happens if both A and B are
- // union members? Blink doesn't seem to do anything special for this case.
- // Just choose the first interface in the flattened members that matches.
- if (jsvalue.isObject()) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- const WrapperFactory* wrapper_factory = global_object->wrapper_factory();
- JSC::JSCell* js_cell = jsvalue.asCell();
-
- if (UnionTypeTraitsT1::is_interface_type &&
- js_cell->inherits(
- wrapper_factory->GetClassInfo(
- UnionTypeTraitsT1::GetTypeID()))) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t1);
- *out_union = script::UnionType2<T1, T2>(t1);
- return;
- }
- if (UnionTypeTraitsT2::is_interface_type &&
- js_cell->inherits(
- wrapper_factory->GetClassInfo(
- UnionTypeTraitsT2::GetTypeID()))) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t2);
- *out_union = script::UnionType2<T1, T2>(t2);
- return;
- }
- }
-
- // TODO: Support Date, RegExp, DOMException, Error, ArrayBuffer, DataView,
- // TypedArrayName, callback functions, dictionary, array type.
- // And sequences if necessary.
-
- // 14. If V is a Boolean value, then:
- // 1. If types includes a boolean, then return the result of converting V
- // to boolean.
- if (jsvalue.isBoolean()) {
- if (UnionTypeTraitsT1::is_boolean_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t1);
- *out_union = script::UnionType2<T1, T2>(t1);
- return;
- }
-
- if (UnionTypeTraitsT2::is_boolean_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t2);
- *out_union = script::UnionType2<T1, T2>(t2);
- return;
- }
- }
-
- // 15. If V is a Number value, then:
- // 1. If types includes a numeric type, then return the result of converting
- // V to that numeric type.
- if (jsvalue.isNumber()) {
- if (UnionTypeTraitsT1::is_numeric_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t1);
- *out_union = script::UnionType2<T1, T2>(t1);
- return;
- }
-
- if (UnionTypeTraitsT2::is_numeric_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t2);
- *out_union = script::UnionType2<T1, T2>(t2);
- return;
- }
- }
-
- // 16. If types includes a string type, then return the result of converting V
- // to that type.
- if (jsvalue.isString()) {
- if (UnionTypeTraitsT1::is_string_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t1);
- *out_union = script::UnionType2<T1, T2>(t1);
- return;
- }
-
- if (UnionTypeTraitsT2::is_string_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t2);
- *out_union = script::UnionType2<T1, T2>(t2);
- return;
- }
- }
-
- // 17. If types includes a numeric type, then return the result of converting
- // V to that numeric type.
- if (UnionTypeTraitsT1::is_numeric_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t1);
- *out_union = script::UnionType2<T1, T2>(t1);
- return;
- }
- if (UnionTypeTraitsT2::is_numeric_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t2);
- *out_union = script::UnionType2<T1, T2>(t2);
- return;
- }
-
- // 18. If types includes a boolean, then return the result of converting V to
- // boolean.
- if (UnionTypeTraitsT1::is_boolean_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t1);
- *out_union = script::UnionType2<T1, T2>(t1);
- return;
- }
- if (UnionTypeTraitsT2::is_boolean_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t2);
- *out_union = script::UnionType2<T1, T2>(t2);
- return;
- }
-
- // 19. Throw a TypeError.
- exception_state->SetSimpleException(kNotUnionType);
-}
-
-template <typename T1, typename T2, typename T3>
-JSC::JSValue ToJSValue(JSCGlobalObject* global_object,
- const script::UnionType3<T1, T2, T3>& in_union) {
- if (in_union.template IsType<T1>()) {
- return ToJSValue(global_object, in_union.template AsType<T1>());
- }
- if (in_union.template IsType<T2>()) {
- return ToJSValue(global_object, in_union.template AsType<T2>());
- }
- if (in_union.template IsType<T3>()) {
- return ToJSValue(global_object, in_union.template AsType<T3>());
- }
- NOTREACHED();
- return JSC::jsUndefined();
-}
-
-template <typename T1, typename T2, typename T3>
-void FromJSValue(JSC::ExecState* exec_state, JSC::JSValue jsvalue,
- int conversion_flags, ExceptionState* exception_state,
- script::UnionType3<T1, T2, T3>* out_union) {
- DCHECK_EQ(0, conversion_flags);
- // JS -> IDL type conversion procedure described here:
- // http://heycam.github.io/webidl/#es-union
-
- // 1. If the union type includes a nullable type and V is null or undefined,
- // then return the IDL value null.
- if (jsvalue.isNull() || jsvalue.isUndefined()) {
- // If the type was nullable or undefined, we should have caught that as a
- // part of the base::optional<T> conversion.
- NOTREACHED();
- return;
- }
- // Typedef for readability.
- typedef ::cobalt::script::internal::UnionTypeTraits<T1> UnionTypeTraitsT1;
- typedef ::cobalt::script::internal::UnionTypeTraits<T2> UnionTypeTraitsT2;
- typedef ::cobalt::script::internal::UnionTypeTraits<T3> UnionTypeTraitsT3;
-
- // Forward declare all potential types
- T1 t1;
- T2 t2;
- T3 t3;
-
- // 3.1 If types includes an interface type that V implements, then return the
- // IDL value that is a reference to the object V.
- // 3.2 If types includes object, then return the IDL value that is a reference
- // to the object V.
- //
- // The specification doesn't dictate what should happen if V implements more
- // than one of the interfaces. For example, if V implements interface B and
- // interface B inherits from interface A, what happens if both A and B are
- // union members? Blink doesn't seem to do anything special for this case.
- // Just choose the first interface in the flattened members that matches.
- if (jsvalue.isObject()) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- const WrapperFactory* wrapper_factory = global_object->wrapper_factory();
- JSC::JSCell* js_cell = jsvalue.asCell();
-
- if (UnionTypeTraitsT1::is_interface_type &&
- js_cell->inherits(
- wrapper_factory->GetClassInfo(
- UnionTypeTraitsT1::GetTypeID()))) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t1);
- *out_union = script::UnionType3<T1, T2, T3>(t1);
- return;
- }
- if (UnionTypeTraitsT2::is_interface_type &&
- js_cell->inherits(
- wrapper_factory->GetClassInfo(
- UnionTypeTraitsT2::GetTypeID()))) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t2);
- *out_union = script::UnionType3<T1, T2, T3>(t2);
- return;
- }
- if (UnionTypeTraitsT3::is_interface_type &&
- js_cell->inherits(
- wrapper_factory->GetClassInfo(
- UnionTypeTraitsT3::GetTypeID()))) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t3);
- *out_union = script::UnionType3<T1, T2, T3>(t3);
- return;
- }
- }
-
- // TODO: Support Date, RegExp, DOMException, Error, ArrayBuffer, DataView,
- // TypedArrayName, callback functions, dictionary, array type.
- // And sequences if necessary.
-
- // 14. If V is a Boolean value, then:
- // 1. If types includes a boolean, then return the result of converting V
- // to boolean.
- if (jsvalue.isBoolean()) {
- if (UnionTypeTraitsT1::is_boolean_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t1);
- *out_union = script::UnionType3<T1, T2, T3>(t1);
- return;
- }
-
- if (UnionTypeTraitsT2::is_boolean_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t2);
- *out_union = script::UnionType3<T1, T2, T3>(t2);
- return;
- }
-
- if (UnionTypeTraitsT3::is_boolean_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t3);
- *out_union = script::UnionType3<T1, T2, T3>(t3);
- return;
- }
- }
-
- // 15. If V is a Number value, then:
- // 1. If types includes a numeric type, then return the result of converting
- // V to that numeric type.
- if (jsvalue.isNumber()) {
- if (UnionTypeTraitsT1::is_numeric_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t1);
- *out_union = script::UnionType3<T1, T2, T3>(t1);
- return;
- }
-
- if (UnionTypeTraitsT2::is_numeric_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t2);
- *out_union = script::UnionType3<T1, T2, T3>(t2);
- return;
- }
-
- if (UnionTypeTraitsT3::is_numeric_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t3);
- *out_union = script::UnionType3<T1, T2, T3>(t3);
- return;
- }
- }
-
- // 16. If types includes a string type, then return the result of converting V
- // to that type.
- if (jsvalue.isString()) {
- if (UnionTypeTraitsT1::is_string_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t1);
- *out_union = script::UnionType3<T1, T2, T3>(t1);
- return;
- }
-
- if (UnionTypeTraitsT2::is_string_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t2);
- *out_union = script::UnionType3<T1, T2, T3>(t2);
- return;
- }
-
- if (UnionTypeTraitsT3::is_string_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t3);
- *out_union = script::UnionType3<T1, T2, T3>(t3);
- return;
- }
- }
-
- // 17. If types includes a numeric type, then return the result of converting
- // V to that numeric type.
- if (UnionTypeTraitsT1::is_numeric_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t1);
- *out_union = script::UnionType3<T1, T2, T3>(t1);
- return;
- }
- if (UnionTypeTraitsT2::is_numeric_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t2);
- *out_union = script::UnionType3<T1, T2, T3>(t2);
- return;
- }
- if (UnionTypeTraitsT3::is_numeric_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t3);
- *out_union = script::UnionType3<T1, T2, T3>(t3);
- return;
- }
-
- // 18. If types includes a boolean, then return the result of converting V to
- // boolean.
- if (UnionTypeTraitsT1::is_boolean_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t1);
- *out_union = script::UnionType3<T1, T2, T3>(t1);
- return;
- }
- if (UnionTypeTraitsT2::is_boolean_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t2);
- *out_union = script::UnionType3<T1, T2, T3>(t2);
- return;
- }
- if (UnionTypeTraitsT3::is_boolean_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t3);
- *out_union = script::UnionType3<T1, T2, T3>(t3);
- return;
- }
-
- // 19. Throw a TypeError.
- exception_state->SetSimpleException(kNotUnionType);
-}
-
-template <typename T1, typename T2, typename T3, typename T4>
-JSC::JSValue ToJSValue(JSCGlobalObject* global_object,
- const script::UnionType4<T1, T2, T3, T4>& in_union) {
- if (in_union.template IsType<T1>()) {
- return ToJSValue(global_object, in_union.template AsType<T1>());
- }
- if (in_union.template IsType<T2>()) {
- return ToJSValue(global_object, in_union.template AsType<T2>());
- }
- if (in_union.template IsType<T3>()) {
- return ToJSValue(global_object, in_union.template AsType<T3>());
- }
- if (in_union.template IsType<T4>()) {
- return ToJSValue(global_object, in_union.template AsType<T4>());
- }
- NOTREACHED();
- return JSC::jsUndefined();
-}
-
-template <typename T1, typename T2, typename T3, typename T4>
-void FromJSValue(JSC::ExecState* exec_state, JSC::JSValue jsvalue,
- int conversion_flags, ExceptionState* exception_state,
- script::UnionType4<T1, T2, T3, T4>* out_union) {
- DCHECK_EQ(0, conversion_flags);
- // JS -> IDL type conversion procedure described here:
- // http://heycam.github.io/webidl/#es-union
-
- // 1. If the union type includes a nullable type and V is null or undefined,
- // then return the IDL value null.
- if (jsvalue.isNull() || jsvalue.isUndefined()) {
- // If the type was nullable or undefined, we should have caught that as a
- // part of the base::optional<T> conversion.
- NOTREACHED();
- return;
- }
- // Typedef for readability.
- typedef ::cobalt::script::internal::UnionTypeTraits<T1> UnionTypeTraitsT1;
- typedef ::cobalt::script::internal::UnionTypeTraits<T2> UnionTypeTraitsT2;
- typedef ::cobalt::script::internal::UnionTypeTraits<T3> UnionTypeTraitsT3;
- typedef ::cobalt::script::internal::UnionTypeTraits<T4> UnionTypeTraitsT4;
-
- // Forward declare all potential types
- T1 t1;
- T2 t2;
- T3 t3;
- T4 t4;
-
- // 3.1 If types includes an interface type that V implements, then return the
- // IDL value that is a reference to the object V.
- // 3.2 If types includes object, then return the IDL value that is a reference
- // to the object V.
- //
- // The specification doesn't dictate what should happen if V implements more
- // than one of the interfaces. For example, if V implements interface B and
- // interface B inherits from interface A, what happens if both A and B are
- // union members? Blink doesn't seem to do anything special for this case.
- // Just choose the first interface in the flattened members that matches.
- if (jsvalue.isObject()) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- const WrapperFactory* wrapper_factory = global_object->wrapper_factory();
- JSC::JSCell* js_cell = jsvalue.asCell();
-
- if (UnionTypeTraitsT1::is_interface_type &&
- js_cell->inherits(
- wrapper_factory->GetClassInfo(
- UnionTypeTraitsT1::GetTypeID()))) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t1);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t1);
- return;
- }
- if (UnionTypeTraitsT2::is_interface_type &&
- js_cell->inherits(
- wrapper_factory->GetClassInfo(
- UnionTypeTraitsT2::GetTypeID()))) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t2);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t2);
- return;
- }
- if (UnionTypeTraitsT3::is_interface_type &&
- js_cell->inherits(
- wrapper_factory->GetClassInfo(
- UnionTypeTraitsT3::GetTypeID()))) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t3);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t3);
- return;
- }
- if (UnionTypeTraitsT4::is_interface_type &&
- js_cell->inherits(
- wrapper_factory->GetClassInfo(
- UnionTypeTraitsT4::GetTypeID()))) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t4);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t4);
- return;
- }
- }
-
- // TODO: Support Date, RegExp, DOMException, Error, ArrayBuffer, DataView,
- // TypedArrayName, callback functions, dictionary, array type.
- // And sequences if necessary.
-
- // 14. If V is a Boolean value, then:
- // 1. If types includes a boolean, then return the result of converting V
- // to boolean.
- if (jsvalue.isBoolean()) {
- if (UnionTypeTraitsT1::is_boolean_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t1);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t1);
- return;
- }
-
- if (UnionTypeTraitsT2::is_boolean_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t2);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t2);
- return;
- }
-
- if (UnionTypeTraitsT3::is_boolean_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t3);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t3);
- return;
- }
-
- if (UnionTypeTraitsT4::is_boolean_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t4);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t4);
- return;
- }
- }
-
- // 15. If V is a Number value, then:
- // 1. If types includes a numeric type, then return the result of converting
- // V to that numeric type.
- if (jsvalue.isNumber()) {
- if (UnionTypeTraitsT1::is_numeric_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t1);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t1);
- return;
- }
-
- if (UnionTypeTraitsT2::is_numeric_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t2);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t2);
- return;
- }
-
- if (UnionTypeTraitsT3::is_numeric_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t3);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t3);
- return;
- }
-
- if (UnionTypeTraitsT4::is_numeric_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t4);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t4);
- return;
- }
- }
-
- // 16. If types includes a string type, then return the result of converting V
- // to that type.
- if (jsvalue.isString()) {
- if (UnionTypeTraitsT1::is_string_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t1);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t1);
- return;
- }
-
- if (UnionTypeTraitsT2::is_string_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t2);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t2);
- return;
- }
-
- if (UnionTypeTraitsT3::is_string_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t3);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t3);
- return;
- }
-
- if (UnionTypeTraitsT4::is_string_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t4);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t4);
- return;
- }
- }
-
- // 17. If types includes a numeric type, then return the result of converting
- // V to that numeric type.
- if (UnionTypeTraitsT1::is_numeric_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t1);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t1);
- return;
- }
- if (UnionTypeTraitsT2::is_numeric_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t2);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t2);
- return;
- }
- if (UnionTypeTraitsT3::is_numeric_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t3);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t3);
- return;
- }
- if (UnionTypeTraitsT4::is_numeric_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t4);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t4);
- return;
- }
-
- // 18. If types includes a boolean, then return the result of converting V to
- // boolean.
- if (UnionTypeTraitsT1::is_boolean_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t1);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t1);
- return;
- }
- if (UnionTypeTraitsT2::is_boolean_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t2);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t2);
- return;
- }
- if (UnionTypeTraitsT3::is_boolean_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t3);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t3);
- return;
- }
- if (UnionTypeTraitsT4::is_boolean_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t4);
- *out_union = script::UnionType4<T1, T2, T3, T4>(t4);
- return;
- }
-
- // 19. Throw a TypeError.
- exception_state->SetSimpleException(kNotUnionType);
-}
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_UNION_TYPE_CONVERSION_IMPL_H_
diff --git a/src/cobalt/script/javascriptcore/union_type_conversion_impl.h.pump b/src/cobalt/script/javascriptcore/union_type_conversion_impl.h.pump
deleted file mode 100644
index 54eae9a..0000000
--- a/src/cobalt/script/javascriptcore/union_type_conversion_impl.h.pump
+++ /dev/null
@@ -1,199 +0,0 @@
-$$ This is a pump file for generating file templates. Pump is a python
-$$ script that is part of the Google Test suite of utilities. Description
-$$ can be found here:
-$$
-$$ http://code.google.com/p/googletest/wiki/PumpManual
-$$
-
-$$ Maximum number of different member types in a union.
-$var MAX_MEMBERS = 4
-/*
- * Copyright 2015 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.
- */
-
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_UNION_TYPE_CONVERSION_IMPL_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_UNION_TYPE_CONVERSION_IMPL_H_
-
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/union_type.h"
-
-// Conversion to/from JSC::JSValue for IDL union types.
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-$range NUM_MEMBERS 2..MAX_MEMBERS
-$for NUM_MEMBERS [[
-
-$range TYPE 1..NUM_MEMBERS
-
-template <$for TYPE , [[typename T$(TYPE)]]>
-JSC::JSValue ToJSValue(JSCGlobalObject* global_object,
- const script::UnionType$(NUM_MEMBERS)<$for TYPE , [[T$(TYPE)]]>& in_union) {
-$for TYPE [[
-
- if (in_union.template IsType<T$(TYPE)>()) {
- return ToJSValue(global_object, in_union.template AsType<T$(TYPE)>());
- }
-]]
-
- NOTREACHED();
- return JSC::jsUndefined();
-}
-
-template <$for TYPE , [[typename T$(TYPE)]]>
-void FromJSValue(JSC::ExecState* exec_state, JSC::JSValue jsvalue,
- int conversion_flags, ExceptionState* exception_state,
- script::UnionType$(NUM_MEMBERS)<$for TYPE , [[T$(TYPE)]]>* out_union) {
- DCHECK_EQ(0, conversion_flags);
- // JS -> IDL type conversion procedure described here:
- // http://heycam.github.io/webidl/#es-union
-
- // 1. If the union type includes a nullable type and V is null or undefined,
- // then return the IDL value null.
- if (jsvalue.isNull() || jsvalue.isUndefined()) {
- // If the type was nullable or undefined, we should have caught that as a
- // part of the base::optional<T> conversion.
- NOTREACHED();
- return;
- }
- // Typedef for readability.
-
-$for TYPE [[
- typedef ::cobalt::script::internal::UnionTypeTraits<T$(TYPE)> UnionTypeTraitsT$(TYPE);
-
-]]
-
- // Forward declare all potential types
-
-$for TYPE [[
- T$(TYPE) t$(TYPE);
-
-]]
-
- // 3.1 If types includes an interface type that V implements, then return the
- // IDL value that is a reference to the object V.
- // 3.2 If types includes object, then return the IDL value that is a reference
- // to the object V.
- //
- // The specification doesn't dictate what should happen if V implements more
- // than one of the interfaces. For example, if V implements interface B and
- // interface B inherits from interface A, what happens if both A and B are
- // union members? Blink doesn't seem to do anything special for this case.
- // Just choose the first interface in the flattened members that matches.
- if (jsvalue.isObject()) {
- JSCGlobalObject* global_object =
- JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
- const WrapperFactory* wrapper_factory = global_object->wrapper_factory();
- JSC::JSCell* js_cell = jsvalue.asCell();
-
-
-$for TYPE [[
- if (UnionTypeTraitsT$(TYPE)::is_interface_type &&
- js_cell->inherits(
- wrapper_factory->GetClassInfo(
- UnionTypeTraitsT$(TYPE)::GetTypeID()))) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t$(TYPE));
- *out_union = script::UnionType$(NUM_MEMBERS)<$for TYPE , [[T$(TYPE)]]>(t$(TYPE));
- return;
- }
-
-]]
- }
-
- // TODO: Support Date, RegExp, DOMException, Error, ArrayBuffer, DataView,
- // TypedArrayName, callback functions, dictionary, array type.
- // And sequences if necessary.
-
- // 14. If V is a Boolean value, then:
- // 1. If types includes a boolean, then return the result of converting V
- // to boolean.
- if (jsvalue.isBoolean()) {
-$for TYPE [[
-
- if (UnionTypeTraitsT$(TYPE)::is_boolean_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t$(TYPE));
- *out_union = script::UnionType$(NUM_MEMBERS)<$for TYPE , [[T$(TYPE)]]>(t$(TYPE));
- return;
- }
-
-]]
- }
-
- // 15. If V is a Number value, then:
- // 1. If types includes a numeric type, then return the result of converting
- // V to that numeric type.
- if (jsvalue.isNumber()) {
-$for TYPE [[
-
- if (UnionTypeTraitsT$(TYPE)::is_numeric_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t$(TYPE));
- *out_union = script::UnionType$(NUM_MEMBERS)<$for TYPE , [[T$(TYPE)]]>(t$(TYPE));
- return;
- }
-
-]]
- }
-
- // 16. If types includes a string type, then return the result of converting V
- // to that type.
- if (jsvalue.isString()) {
-$for TYPE [[
-
- if (UnionTypeTraitsT$(TYPE)::is_string_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t$(TYPE));
- *out_union = script::UnionType$(NUM_MEMBERS)<$for TYPE , [[T$(TYPE)]]>(t$(TYPE));
- return;
- }
-
-]]
- }
-
- // 17. If types includes a numeric type, then return the result of converting
- // V to that numeric type.
-$for TYPE [[
-
- if (UnionTypeTraitsT$(TYPE)::is_numeric_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t$(TYPE));
- *out_union = script::UnionType$(NUM_MEMBERS)<$for TYPE , [[T$(TYPE)]]>(t$(TYPE));
- return;
- }
-]]
-
-
- // 18. If types includes a boolean, then return the result of converting V to
- // boolean.
-$for TYPE [[
-
- if (UnionTypeTraitsT$(TYPE)::is_boolean_type) {
- FromJSValue(exec_state, jsvalue, conversion_flags, exception_state, &t$(TYPE));
- *out_union = script::UnionType$(NUM_MEMBERS)<$for TYPE , [[T$(TYPE)]]>(t$(TYPE));
- return;
- }
-]]
-
-
- // 19. Throw a TypeError.
- exception_state->SetSimpleException(kNotUnionType);
-}
-
-]] $$ for NUM_MEMBERS
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_UNION_TYPE_CONVERSION_IMPL_H_
diff --git a/src/cobalt/script/javascriptcore/util/binding_helpers.cc b/src/cobalt/script/javascriptcore/util/binding_helpers.cc
deleted file mode 100644
index 872aa1f..0000000
--- a/src/cobalt/script/javascriptcore/util/binding_helpers.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-
-#include "cobalt/script/javascriptcore/util/binding_helpers.h"
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-namespace util {
-
-bool HasPropertyOnPrototype(JSC::ExecState* exec_state, JSC::JSCell* cell,
- JSC::PropertyName property_name) {
- if (cell->isObject()) {
- JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
- if (prototype_value.isObject()) {
- JSC::JSObject* prototype = JSC::asObject(prototype_value);
- if (prototype->hasProperty(exec_state, property_name)) {
- return true;
- }
- }
- }
- return false;
-}
-
-} // namespace util
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
diff --git a/src/cobalt/script/javascriptcore/util/binding_helpers.h b/src/cobalt/script/javascriptcore/util/binding_helpers.h
deleted file mode 100644
index 3f51716..0000000
--- a/src/cobalt/script/javascriptcore/util/binding_helpers.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_UTIL_BINDING_HELPERS_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_UTIL_BINDING_HELPERS_H_
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/CallFrame.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSCell.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/PropertyName.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-namespace util {
-
-bool HasPropertyOnPrototype(JSC::ExecState* exec_state, JSC::JSCell* cell,
- JSC::PropertyName property_name);
-
-} // namespace util
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_UTIL_BINDING_HELPERS_H_
diff --git a/src/cobalt/script/javascriptcore/util/exception_helpers.cc b/src/cobalt/script/javascriptcore/util/exception_helpers.cc
deleted file mode 100644
index 4e44e6c..0000000
--- a/src/cobalt/script/javascriptcore/util/exception_helpers.cc
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-
-#include "cobalt/script/javascriptcore/util/exception_helpers.h"
-
-#include <algorithm>
-
-#include "base/logging.h"
-#include "base/stringprintf.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSDestructibleObject.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSScope.h"
-#include "third_party/WebKit/Source/WTF/wtf/text/WTFString.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-namespace util {
-
-std::string GetExceptionString(JSC::ExecState* exec_state) {
- return GetExceptionString(exec_state, exec_state->exception());
-}
-
-std::string GetExceptionString(JSC::ExecState* exec_state,
- JSC::JSValue exception) {
- JSC::JSGlobalData* global_data = &exec_state->globalData();
-
- WTF::String wtf_exception_string = exception.toWTFString(exec_state);
- std::string exception_string =
- exception.toWTFString(exec_state).utf8().data();
- exception_string += "\n";
-
- JSC::JSObject* exception_object = exception.toObject(exec_state);
- JSC::JSValue stack_value = exception_object->getDirect(
- *global_data, global_data->propertyNames->stack);
- if (!stack_value.isEmpty() && stack_value.isString()) {
- exception_string += stack_value.toWTFString(exec_state).utf8().data();
- } else {
- int line_number =
- exception_object->get(exec_state, JSC::Identifier(exec_state, "line"))
- .toInt32(exec_state);
- std::string source_url =
- exception_object->get(exec_state,
- JSC::Identifier(exec_state, "sourceURL"))
- .toWTFString(exec_state)
- .utf8()
- .data();
- exception_string +=
- base::StringPrintf("%s:%d", source_url.c_str(), line_number);
- }
- return exception_string;
-}
-
-std::vector<StackFrame> GetStackTrace(JSC::ExecState* exec, int max_frames) {
- std::vector<StackFrame> stack_frames;
- JSC::JSLockHolder lock(exec);
-
- WTF::Vector<JSC::StackFrame> stack_trace;
- exec->interpreter()->getStackTrace(&exec->globalData(), stack_trace);
- if (max_frames == 0) {
- max_frames = static_cast<int>(stack_trace.size());
- } else {
- max_frames = std::min(max_frames, static_cast<int>(stack_trace.size()));
- }
- for (int i = 0; i < max_frames; ++i) {
- WTF::String function_name = stack_trace[i].friendlyFunctionName(exec);
- WTF::String source_url = stack_trace[i].friendlySourceURL();
- uint32 line_number = stack_trace[i].friendlyLineNumber();
-
- StackFrame sf;
- sf.function_name = function_name.utf8().data();
- if (!source_url.isEmpty()) {
- sf.source_url = source_url.utf8().data();
- }
- sf.line_number = line_number;
- sf.column_number = 0;
- stack_frames.push_back(sf);
- }
- return stack_frames;
-}
-
-} // namespace util
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
diff --git a/src/cobalt/script/javascriptcore/util/exception_helpers.h b/src/cobalt/script/javascriptcore/util/exception_helpers.h
deleted file mode 100644
index 07918fd..0000000
--- a/src/cobalt/script/javascriptcore/util/exception_helpers.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_UTIL_EXCEPTION_HELPERS_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_UTIL_EXCEPTION_HELPERS_H_
-
-#include <string>
-#include <vector>
-
-#include "cobalt/script/stack_frame.h"
-
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/interpreter/CallFrame.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSValue.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-namespace util {
-
-std::string GetExceptionString(JSC::ExecState* exec_state);
-
-std::string GetExceptionString(JSC::ExecState* exec_state,
- JSC::JSValue exception);
-
-// Retrieve stack frame information. Set max_frames to 0 to get all
-// available, or non-0 to limit the number of frames returned.
-std::vector<StackFrame> GetStackTrace(JSC::ExecState* exec_state,
- int max_frames);
-
-} // namespace util
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_UTIL_EXCEPTION_HELPERS_H_
diff --git a/src/cobalt/script/javascriptcore/wrapper_base.h b/src/cobalt/script/javascriptcore/wrapper_base.h
deleted file mode 100644
index cdcf27b..0000000
--- a/src/cobalt/script/javascriptcore/wrapper_base.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_WRAPPER_BASE_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_WRAPPER_BASE_H_
-
-#include "base/callback.h"
-#include "base/memory/ref_counted.h"
-#include "cobalt/script/javascriptcore/jsc_global_object.h"
-#include "cobalt/script/script_exception.h"
-#include "cobalt/script/wrappable.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ErrorInstance.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSDestructibleObject.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-// All JavaScriptCore wrapper classes will inherit from this. This provides a
-// common base class for all wrapper objects. It holds a reference-counted
-// handle to a Wrappable object, which is the base class of all objects that
-// can be referenced from JavaScript.
-// The WrappableBase template class must be derived from script::Wrappable.
-template <typename JSCBaseClass, typename WrappableBase>
-class WrapperBase : public JSCBaseClass {
- public:
- const scoped_refptr<WrappableBase>& wrappable() { return wrappable_; }
-
- scoped_refptr<WrappableBase> GetOpaqueRoot() {
- if (!get_opaque_root_function_.is_null()) {
- return get_opaque_root_function_.Run(wrappable_);
- }
- return NULL;
- }
-
- static scoped_refptr<WrappableBase>& GetWrappable(JSC::JSObject* js_object) {
- ASSERT_GC_OBJECT_INHERITS(js_object, WrapperBase::s_classinfo());
- WrapperBase* wrapper_base = JSC::jsCast<WrapperBase*>(js_object);
- return wrapper_base->wrappable_;
- }
-
- protected:
- typedef base::Callback<scoped_refptr<WrappableBase>(
- const scoped_refptr<WrappableBase>&)> GetOpaqueRootFunction;
-
- WrapperBase(JSC::JSGlobalData* global_data, JSC::Structure* structure,
- ScriptObjectRegistry* script_object_registry,
- const scoped_refptr<WrappableBase>& impl)
- : JSCBaseClass(*global_data, structure),
- wrappable_(impl),
- script_object_registry_(script_object_registry) {}
-
- void set_get_opaque_root_function(
- const GetOpaqueRootFunction& get_opaque_root_function) {
- DCHECK(get_opaque_root_function_.is_null());
- get_opaque_root_function_ = get_opaque_root_function;
- }
-
- // static override. This function will be called during garbage collection
- // to mark any garbage-collected objects that are referencable from this
- // object.
- static void visitChildren(JSC::JSCell* cell,
- JSC::SlotVisitor& visitor) { // NOLINT(runtime/references)
- JSCBaseClass::visitChildren(cell, visitor);
- WrapperBase* this_object = JSC::jsCast<WrapperBase*>(cell);
- ASSERT_GC_OBJECT_INHERITS(this_object, WrapperBase::s_classinfo());
- // In general most wrappers won't have any such owned objects, but
- // this shouldn't be too expensive.
- this_object->script_object_registry_->VisitOwnedObjects(
- this_object->wrappable_.get(), &visitor);
- }
-
- // static override. This will be called when this object is garbage collected.
- static void destroy(JSC::JSCell* cell) {
- // Note that the WrapperBase destructor is non-virtual.
- // JSC's garbage-collected heap seems to not support classes with virtual
- // functions, as suggested by the lack of a virtual destructor in JSCell,
- // the base class for all GC objects, and the lack of any virtual functions
- // in WebKit's bindings implementation.
- // Garbage-collected classes with a non-trivial destructor and/or
- // member variables that need to be destructed must override destroy() to
- // ensure that the class is destructed properly.
- static_cast<WrapperBase*>(cell)->~WrapperBase();
- }
-
- private:
- scoped_refptr<WrappableBase> wrappable_;
- ScriptObjectRegistry* script_object_registry_;
- GetOpaqueRootFunction get_opaque_root_function_;
-};
-
-// Base for regular interfaces.
-typedef WrapperBase<JSC::JSDestructibleObject, Wrappable> InterfaceBase;
-// Base for exception interfaces.
-typedef WrapperBase<JSC::ErrorInstance, ScriptException> ExceptionBase;
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_WRAPPER_BASE_H_
diff --git a/src/cobalt/script/javascriptcore/wrapper_factory.cc b/src/cobalt/script/javascriptcore/wrapper_factory.cc
deleted file mode 100644
index 57fa196..0000000
--- a/src/cobalt/script/javascriptcore/wrapper_factory.cc
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-#include "cobalt/script/javascriptcore/wrapper_factory.h"
-
-#include <utility>
-
-#include "base/lazy_instance.h"
-#include "cobalt/script/javascriptcore/jsc_wrapper_handle.h"
-#include "cobalt/script/javascriptcore/wrapper_base.h"
-#include "third_party/WebKit/Source/JavaScriptCore/heap/WeakHandleOwner.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-namespace {
-
-class CachedHandleOwner : public JSC::WeakHandleOwner {
- public:
- // Return true if handle can be reached from some root unknown to JSC.
- // This can be used to keep a cached wrapper from being garbage collected
- // even though there are no strong references to it.
- bool isReachableFromOpaqueRoots(
- JSC::Handle<JSC::Unknown> handle,
- void* context,
- JSC::SlotVisitor& visitor) OVERRIDE { // NOLINT(runtime/references)
- JSC::JSObject* js_object = JSC::asObject(handle.get().asCell());
- if (js_object->isGlobalObject()) {
- NOTREACHED() << "CachedHandleOwner shouldn't refer to a global object";
- return false;
- }
-
- if (js_object->isErrorInstance()) {
- return IsReachableFromOpaqueRoots(JSC::jsCast<ExceptionBase*>(js_object),
- &visitor);
- } else {
- return IsReachableFromOpaqueRoots(JSC::jsCast<InterfaceBase*>(js_object),
- &visitor);
- }
- }
-
- private:
- template <class T>
- bool IsReachableFromOpaqueRoots(T* wrapper_base,
- JSC::SlotVisitor* slot_visitor) {
- scoped_refptr<Wrappable> opaque_root = wrapper_base->GetOpaqueRoot();
-
- // Check if we might want to keep this cached wrapper alive despite it not
- // being referenced anywhere
- if (!ShouldKeepWrapperAlive(wrapper_base, opaque_root)) {
- return false;
- }
-
- // If this wrapper has an opaque root, check if that root has been marked.
- // If the root is not alive, we do not want to keep this wrapper alive.
- if (opaque_root && slot_visitor->containsOpaqueRoot(opaque_root.get())) {
- return true;
- }
-
- // If this wrapper's wrappable has been marked as an opaque root, keep it
- // alive.
- if (slot_visitor->containsOpaqueRoot(wrapper_base->wrappable().get())) {
- return true;
- }
-
- return false;
- }
-
- template <class T>
- bool ShouldKeepWrapperAlive(T* wrapper_base,
- const scoped_refptr<Wrappable>& opaque_root) {
- if (opaque_root && opaque_root == wrapper_base->wrappable()) {
- // This is the root, so keep this wrapper alive. This will in turn keep
- // the entire tree alive.
- return true;
- }
-
- // If a custom property has been set on the wrapper object, we should keep
- // it alive so that the property persists next time the object is
- // referenced from JS.
- if (wrapper_base->hasCustomProperties()) {
- return true;
- }
-
- // Check if the wrapper should be kept alive based on the impl's state.
- return wrapper_base->wrappable()->ShouldKeepWrapperAlive();
- }
-};
-
-base::LazyInstance<CachedHandleOwner> cached_handle_owner =
- LAZY_INSTANCE_INITIALIZER;
-} // namespace
-
-void WrapperFactory::RegisterWrappableType(
- base::TypeId wrappable_type, const JSC::ClassInfo* class_info,
- const CreateWrapperFunction& create_function) {
- std::pair<WrappableTypeInfoMap::iterator, bool> pib =
- wrappable_type_infos_.insert(std::make_pair(
- wrappable_type, WrappableTypeInfo(class_info, create_function)));
- DCHECK(pib.second)
- << "RegisterWrappableType registered for type more than once.";
- wrapper_class_infos_.insert(class_info);
-}
-
-JSC::JSObject* WrapperFactory::GetWrapper(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) const {
- if (!wrappable) {
- return NULL;
- }
-
- JSC::JSObject* wrapper =
- JSCWrapperHandle::GetJSObject(GetCachedWrapper(wrappable.get()));
- if (!wrapper) {
- if (global_object->global_interface() == wrappable) {
- // Wrapper for the global object is a special case.
- wrapper = global_object;
- } else {
- scoped_ptr<Wrappable::WeakWrapperHandle> object_handle =
- WrapperFactory::CreateWrapper(global_object, wrappable);
- SetCachedWrapper(wrappable.get(), object_handle.Pass());
- wrapper = JSCWrapperHandle::GetJSObject(
- GetCachedWrapper(wrappable.get()));
- }
- }
- DCHECK(wrapper);
- return wrapper;
-}
-
-bool WrapperFactory::IsWrapper(JSC::JSObject* js_object) const {
- WrapperClassInfoSet::const_iterator it =
- wrapper_class_infos_.find(js_object->classInfo());
- return it != wrapper_class_infos_.end();
-}
-
-const JSC::ClassInfo* WrapperFactory::GetClassInfo(
- base::TypeId wrappable_type) const {
- WrappableTypeInfoMap::const_iterator it =
- wrappable_type_infos_.find(wrappable_type);
- if (it == wrappable_type_infos_.end()) {
- NOTREACHED();
- return NULL;
- }
- return it->second.class_info;
-}
-
-scoped_ptr<Wrappable::WeakWrapperHandle> WrapperFactory::CreateWrapper(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) const {
- WrappableTypeInfoMap::const_iterator it =
- wrappable_type_infos_.find(wrappable->GetWrappableType());
- if (it == wrappable_type_infos_.end()) {
- NOTREACHED();
- return scoped_ptr<Wrappable::WeakWrapperHandle>();
- }
- return make_scoped_ptr<Wrappable::WeakWrapperHandle>(
- new JSCWrapperHandle(JSC::PassWeak<JSC::JSObject>(
- it->second.create_function.Run(global_object, wrappable),
- cached_handle_owner.Pointer())));
-}
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
diff --git a/src/cobalt/script/javascriptcore/wrapper_factory.h b/src/cobalt/script/javascriptcore/wrapper_factory.h
deleted file mode 100644
index dbe2c1f..0000000
--- a/src/cobalt/script/javascriptcore/wrapper_factory.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-#ifndef COBALT_SCRIPT_JAVASCRIPTCORE_WRAPPER_FACTORY_H_
-#define COBALT_SCRIPT_JAVASCRIPTCORE_WRAPPER_FACTORY_H_
-
-#include "base/bind.h"
-#include "base/hash_tables.h"
-#include "base/memory/ref_counted.h"
-#include "cobalt/base/type_id.h"
-#include "cobalt/script/wrappable.h"
-#include "third_party/WebKit/Source/JavaScriptCore/config.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/ClassInfo.h"
-#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSObject.h"
-
-namespace cobalt {
-namespace script {
-namespace javascriptcore {
-
-class JSCGlobalObject;
-
-class WrapperFactory : public Wrappable::CachedWrapperAccessor {
- public:
- typedef base::Callback<JSC::JSObject*(
- JSCGlobalObject*, const scoped_refptr<Wrappable>&)> CreateWrapperFunction;
- void RegisterWrappableType(base::TypeId wrappable_type,
- const JSC::ClassInfo* class_info,
- const CreateWrapperFunction& create_function);
-
- // Gets a Wrapper object for this Wrappable. It may create a new Wrapper.
- JSC::JSObject* GetWrapper(JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) const;
-
- // Returns true if this JSObject is a Wrapper object.
- bool IsWrapper(JSC::JSObject* js_object) const;
-
- // Gets the JSC::ClassInfo that corresponds to this Wrappable type.
- const JSC::ClassInfo* GetClassInfo(base::TypeId wrappable_type) const;
-
- private:
- scoped_ptr<Wrappable::WeakWrapperHandle> CreateWrapper(
- JSCGlobalObject* global_object,
- const scoped_refptr<Wrappable>& wrappable) const;
-
- struct WrappableTypeInfo {
- WrappableTypeInfo(const JSC::ClassInfo* info,
- const CreateWrapperFunction& function)
- : class_info(info), create_function(function) {}
- const JSC::ClassInfo* class_info;
- CreateWrapperFunction create_function;
- };
- typedef base::hash_map<base::TypeId, WrappableTypeInfo> WrappableTypeInfoMap;
- typedef base::hash_set<const JSC::ClassInfo*> WrapperClassInfoSet;
-
- WrappableTypeInfoMap wrappable_type_infos_;
- WrapperClassInfoSet wrapper_class_infos_;
-};
-
-} // namespace javascriptcore
-} // namespace script
-} // namespace cobalt
-
-#endif // COBALT_SCRIPT_JAVASCRIPTCORE_WRAPPER_FACTORY_H_
diff --git a/src/cobalt/script/mozjs/mozjs.gyp b/src/cobalt/script/mozjs/mozjs.gyp
index 00b5356..7262cdc 100644
--- a/src/cobalt/script/mozjs/mozjs.gyp
+++ b/src/cobalt/script/mozjs/mozjs.gyp
@@ -42,6 +42,7 @@
'dependencies': [
'<(DEPTH)/cobalt/script/script.gyp:script',
'<(DEPTH)/third_party/mozjs/mozjs.gyp:mozjs_lib',
+ 'embed_mozjs_resources_as_header_files',
],
'defines': [
'MOZJS_GARBAGE_COLLECTION_THRESHOLD_IN_BYTES=<(mozjs_garbage_collection_threshold_in_bytes)',
@@ -104,5 +105,41 @@
},
'includes': [ '../../../starboard/build/deploy.gypi' ],
},
+
+ {
+ # This target takes specified files and embeds them as header files for
+ # inclusion into the binary. The script currently requires all resources
+ # to be embedded to live in the same directory.
+ 'target_name': 'embed_mozjs_resources_as_header_files',
+ 'type': 'none',
+ # Because we generate a header, we must set the hard_dependency flag.
+ 'hard_dependency': 1,
+ 'variables': {
+ 'script_path': '<(DEPTH)/cobalt/build/generate_data_header.py',
+ 'output_path': '<(SHARED_INTERMEDIATE_DIR)/cobalt/script/mozjs/embedded_resources.h',
+ },
+ 'sources': [
+ '<(DEPTH)/third_party/promise-polyfill/promise.min.js',
+ ],
+ 'actions': [
+ {
+ 'action_name': 'embed_mozjs_resources_as_header_files',
+ 'inputs': [
+ '<(script_path)',
+ '<@(_sources)',
+ ],
+ 'outputs': [
+ '<(output_path)',
+ ],
+ 'action': ['python', '<(script_path)', 'MozjsEmbeddedResources', '<(output_path)', '<@(_sources)' ],
+ 'message': 'Embedding MozJS resources in into header file, "<(output_path)".',
+ },
+ ],
+ 'direct_dependent_settings': {
+ 'include_dirs': [
+ '<(SHARED_INTERMEDIATE_DIR)',
+ ],
+ },
+ },
],
}
diff --git a/src/cobalt/script/mozjs/mozjs_global_environment.cc b/src/cobalt/script/mozjs/mozjs_global_environment.cc
index ee1237f..337db82 100644
--- a/src/cobalt/script/mozjs/mozjs_global_environment.cc
+++ b/src/cobalt/script/mozjs/mozjs_global_environment.cc
@@ -22,6 +22,7 @@
#include "base/stringprintf.h"
#include "cobalt/base/polymorphic_downcast.h"
#include "cobalt/script/mozjs/conversion_helpers.h"
+#include "cobalt/script/mozjs/embedded_resources.h"
#include "cobalt/script/mozjs/mozjs_exception_state.h"
#include "cobalt/script/mozjs/mozjs_source_code.h"
#include "cobalt/script/mozjs/mozjs_wrapper_handle.h"
@@ -193,6 +194,8 @@
context_, ProxyHandler::NewProxy(context_, global_object, NULL, NULL,
proxy_handler.Pointer()));
global_object_proxy_ = proxy;
+
+ EvaluateAutomatics();
}
bool MozjsGlobalEnvironment::EvaluateScript(
@@ -350,6 +353,20 @@
DCHECK(success);
}
+void MozjsGlobalEnvironment::EvaluateAutomatics() {
+ TRACK_MEMORY_SCOPE("Javascript");
+ std::string source(
+ reinterpret_cast<const char*>(MozjsEmbeddedResources::promise_min_js),
+ sizeof(MozjsEmbeddedResources::promise_min_js));
+ scoped_refptr<SourceCode> source_code =
+ new MozjsSourceCode(source, base::SourceLocation("promise.min.js", 1, 1));
+ std::string result;
+ bool success = EvaluateScript(source_code, &result);
+ if (!success) {
+ DLOG(FATAL) << result;
+ }
+}
+
InterfaceData* MozjsGlobalEnvironment::GetInterfaceData(intptr_t key) {
CachedInterfaceData::iterator it = cached_interface_data_.find(key);
if (it != cached_interface_data_.end()) {
diff --git a/src/cobalt/script/mozjs/mozjs_global_environment.h b/src/cobalt/script/mozjs/mozjs_global_environment.h
index 8f719e3..ff6e83d 100644
--- a/src/cobalt/script/mozjs/mozjs_global_environment.h
+++ b/src/cobalt/script/mozjs/mozjs_global_environment.h
@@ -77,6 +77,9 @@
void Bind(const std::string& identifier,
const scoped_refptr<Wrappable>& impl) OVERRIDE;
+ // Evaluates any automatically included Javascript for the environment.
+ void EvaluateAutomatics();
+
JSContext* context() const { return context_; }
JSObject* global_object_proxy() const { return global_object_proxy_; }
diff --git a/src/cobalt/script/sequence.h b/src/cobalt/script/sequence.h
index 683f6e0..71fd46b 100644
--- a/src/cobalt/script/sequence.h
+++ b/src/cobalt/script/sequence.h
@@ -17,6 +17,7 @@
#ifndef COBALT_SCRIPT_SEQUENCE_H_
#define COBALT_SCRIPT_SEQUENCE_H_
+#include <algorithm>
#include <iosfwd>
#include <vector>
@@ -58,7 +59,9 @@
typedef typename SequenceType::const_reference const_reference;
void push_back(const_reference value) { sequence_.push_back(value); }
size_type size() const { return sequence_.size(); }
+ bool empty() const { return sequence_.empty(); }
const_reference at(size_type index) const { return sequence_.at(index); }
+ void swap(Sequence<T>& other) { sequence_.swap(other.sequence_); }
private:
SequenceType sequence_;
diff --git a/src/cobalt/test/document_loader.h b/src/cobalt/test/document_loader.h
index bffc7a8..f905a29 100644
--- a/src/cobalt/test/document_loader.h
+++ b/src/cobalt/test/document_loader.h
@@ -65,8 +65,8 @@
NULL /* web_media_player_factory */, &script_runner_,
NULL /* media_source_registry */, &resource_provider_,
image_cache_.get(), NULL /* reduced_image_cache_capacity_manager */,
- NULL /* remote_font_cache */, dom_stat_tracker_.get(),
- "" /* language */) {}
+ NULL /* remote_font_cache */, NULL /* mesh_cache */,
+ dom_stat_tracker_.get(), "" /* language */) {}
void Load(const GURL& url) {
// Load the document in a nested message loop.
dom::Document::Options options(url);
diff --git a/src/cobalt/test/empty_document.h b/src/cobalt/test/empty_document.h
index 9fae1b9..c65159f 100644
--- a/src/cobalt/test/empty_document.h
+++ b/src/cobalt/test/empty_document.h
@@ -33,7 +33,7 @@
: css_parser_(css_parser::Parser::Create()),
dom_stat_tracker_(new dom::DomStatTracker("EmptyDocument")),
html_element_context_(NULL, css_parser_.get(), NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL,
dom_stat_tracker_.get(), ""),
document_(new dom::Document(&html_element_context_)) {}
diff --git a/src/cobalt/webdriver/dispatcher.cc b/src/cobalt/webdriver/dispatcher.cc
index a035bc8..0eb1bce 100644
--- a/src/cobalt/webdriver/dispatcher.cc
+++ b/src/cobalt/webdriver/dispatcher.cc
@@ -164,9 +164,8 @@
// Use reverse iterators for the match so we can early-out of a mismatch
// more quickly. Most requests start with '/session/:sessionId/', for
// example.
- typedef std::pair<std::vector<std::string>::const_reverse_iterator,
- std::vector<std::string>::const_reverse_iterator>
- MismatchResultPair;
+ typedef std::vector<std::string>::const_reverse_iterator MismatchResult;
+ typedef std::pair<MismatchResult, MismatchResult> MismatchResultPair;
typedef std::pair<CommandMappingLookup::iterator,
CommandMappingLookup::iterator> EqualRangeResultPair;
@@ -189,7 +188,7 @@
if (result_pair.first == components.rend()) {
DCHECK(
result_pair.second ==
- static_cast<const CommandMapping>(it->second).path_components.rend());
+ static_cast<MismatchResult>(it->second.path_components.rend()));
return &it->second;
}
}
diff --git a/src/cobalt/webdriver/get_element_text_test.cc b/src/cobalt/webdriver/get_element_text_test.cc
index b9a87e9..a42b3a2 100644
--- a/src/cobalt/webdriver/get_element_text_test.cc
+++ b/src/cobalt/webdriver/get_element_text_test.cc
@@ -43,7 +43,7 @@
: css_parser_(css_parser::Parser::Create()),
dom_stat_tracker_(new dom::DomStatTracker("GetElementTextTest")),
html_element_context_(NULL, css_parser_.get(), NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL,
dom_stat_tracker_.get(), "") {}
void SetUp() OVERRIDE {
diff --git a/src/cobalt/webdriver/testing/stub_window.h b/src/cobalt/webdriver/testing/stub_window.h
index aa6c912..fdd4cad 100644
--- a/src/cobalt/webdriver/testing/stub_window.h
+++ b/src/cobalt/webdriver/testing/stub_window.h
@@ -52,7 +52,7 @@
global_environment_ = engine_->CreateGlobalEnvironment();
window_ = new dom::Window(
1920, 1080, css_parser_.get(), dom_parser_.get(),
- fetcher_factory_.get(), NULL, NULL, NULL, NULL,
+ fetcher_factory_.get(), NULL, NULL, NULL, NULL, NULL,
&local_storage_database_, stub_media_module_.get(),
stub_media_module_.get(), NULL, NULL, NULL, dom_stat_tracker_.get(),
url_, "", "en-US", base::Callback<void(const GURL&)>(),
diff --git a/src/cobalt/webdriver_benchmarks/tests/README.md b/src/cobalt/webdriver_benchmarks/tests/README.md
index 1274513..032c41c 100644
--- a/src/cobalt/webdriver_benchmarks/tests/README.md
+++ b/src/cobalt/webdriver_benchmarks/tests/README.md
@@ -6,8 +6,8 @@
Each file should contain a set of tests in Python "unittest" format.
-All tests in all of the files in this directory will be run on the build system.
-Results can be recorded in the build results database.
+All tests in all of the files included within "all.py" will be run on the
+build system. Results can be recorded in the build results database.
To run an individual test, simply execute a script directly (or run
all of them via "all.py"). Platform configuration will be inferred from
@@ -17,12 +17,16 @@
To make a new test:
1. If appropriate, create a new file borrowing the boilerplate from
- an existing simple file, such as "shelf.py"
+ an existing simple file, such as "browse_horizontal.py".
- 2. If this file contains internal names or details, consider adding it
+ 2. Add the file name to the tests added within "all.py", causing it run
+ when "all.py" is run.
+
+ 3. If this file contains internal names or details, consider adding it
to the "EXCLUDE.FILES" list.
- 3. Use the `record_test_result*` methods in `tv_testcase_util` where appropriate.
+ 4. Use the `record_test_result*` methods in `tv_testcase_util` where
+ appropriate.
- 4. Results must be added to the build results database schema. See
+ 5. Results must be added to the build results database schema. See
the internal "README-Updating-Result-Schema.md" file
diff --git a/src/cobalt/webdriver_benchmarks/tests/all.py b/src/cobalt/webdriver_benchmarks/tests/all.py
index 78924c0..3cd8266 100755
--- a/src/cobalt/webdriver_benchmarks/tests/all.py
+++ b/src/cobalt/webdriver_benchmarks/tests/all.py
@@ -17,22 +17,29 @@
# pylint: disable=C6204,C6203
import tv_testcase
+def _add_test(test_suite, dir_path, test_name):
+ if os.path.isfile(os.path.join(dir_path, test_name + ".py")):
+ print("Adding test: {}".format(test_name))
+ test_suite.addTest(unittest.TestLoader().loadTestsFromModule(
+ importlib.import_module("tests." + test_name)))
# pylint: disable=unused-argument
def load_tests(loader, tests, pattern):
"""This is a Python unittest "load_tests protocol method."""
- s = unittest.TestSuite()
+ test_suite = unittest.TestSuite()
+ dir_path = os.path.dirname(__file__)
- for f in os.listdir(os.path.dirname(__file__)):
- if not f.endswith(".py"):
- continue
- if f.startswith("_"):
- continue
- if f == "all.py":
- continue
- s.addTest(unittest.TestLoader().loadTestsFromModule(
- importlib.import_module("tests." + f[:-3])))
- return s
+ # "time_to_shelf" must be the first test added. The timings that it
+ # records require it to run first.
+ _add_test(test_suite, dir_path, "time_to_shelf")
+ _add_test(test_suite, dir_path, "browse_horizontal")
+ _add_test(test_suite, dir_path, "browse_vertical")
+ _add_test(test_suite, dir_path, "browse_to_guide")
+ _add_test(test_suite, dir_path, "browse_to_search")
+ _add_test(test_suite, dir_path, "browse_to_watch")
+ _add_test(test_suite, dir_path, "csi")
+
+ return test_suite
if __name__ == "__main__":
tv_testcase.main()
diff --git a/src/cobalt/webdriver_benchmarks/tests/browse_horizontal.py b/src/cobalt/webdriver_benchmarks/tests/browse_horizontal.py
index 5751cd2..d55cb5a 100755
--- a/src/cobalt/webdriver_benchmarks/tests/browse_horizontal.py
+++ b/src/cobalt/webdriver_benchmarks/tests/browse_horizontal.py
@@ -36,8 +36,6 @@
for _ in xrange(NUM_LOAD_TV_CALLS):
self.load_tv()
- self.wait_for_processing_complete_after_focused_shelf()
-
self.send_keys(tv.FOCUSED_TILE, keys.Keys.ARROW_RIGHT)
self.wait_for_processing_complete_after_focused_shelf()
diff --git a/src/cobalt/webdriver_benchmarks/tests/browse_to_guide.py b/src/cobalt/webdriver_benchmarks/tests/browse_to_guide.py
index 750addd..20e13e5 100755
--- a/src/cobalt/webdriver_benchmarks/tests/browse_to_guide.py
+++ b/src/cobalt/webdriver_benchmarks/tests/browse_to_guide.py
@@ -45,7 +45,6 @@
for _ in xrange(NUM_LOAD_TV_CALLS):
self.load_tv()
- self.assert_displayed(tv.FOCUSED_SHELF)
for _ in xrange(NUM_ITERATIONS_PER_LOAD_TV_CALL):
browse_to_guide_recorder.on_start_event()
diff --git a/src/cobalt/webdriver_benchmarks/tests/browse_to_search.py b/src/cobalt/webdriver_benchmarks/tests/browse_to_search.py
index 8b0e0a8..3c4728e 100755
--- a/src/cobalt/webdriver_benchmarks/tests/browse_to_search.py
+++ b/src/cobalt/webdriver_benchmarks/tests/browse_to_search.py
@@ -47,7 +47,6 @@
for _ in xrange(NUM_LOAD_TV_CALLS):
self.load_tv()
- self.assert_displayed(tv.FOCUSED_SHELF)
for _ in xrange(NUM_ITERATIONS_PER_LOAD_TV_CALL):
browse_to_search_recorder.on_start_event()
diff --git a/src/cobalt/webdriver_benchmarks/tests/browse_to_watch.py b/src/cobalt/webdriver_benchmarks/tests/browse_to_watch.py
index 3733dd8..956d44b 100755
--- a/src/cobalt/webdriver_benchmarks/tests/browse_to_watch.py
+++ b/src/cobalt/webdriver_benchmarks/tests/browse_to_watch.py
@@ -48,7 +48,6 @@
for _ in xrange(NUM_LOAD_TV_CALLS):
self.load_tv()
- self.wait_for_processing_complete_after_focused_shelf()
for _ in xrange(NUM_ITERATIONS_PER_LOAD_TV_CALL):
self.send_keys(tv.FOCUSED_SHELF, keys.Keys.ARROW_DOWN)
@@ -59,6 +58,10 @@
self.wait_for_media_element_playing()
browse_to_watch_recorder.on_end_event()
+ # Wait for the title card hidden before sending the escape. Otherwise,
+ # two escapes are required to exit the video.
+ self.wait_for_title_card_hidden()
+
watch_to_browse_recorder.on_start_event()
self.send_keys(tv.FOCUSED_WATCH, keys.Keys.ESCAPE)
self.wait_for_processing_complete_after_focused_shelf()
diff --git a/src/cobalt/webdriver_benchmarks/tests/browse_vertical.py b/src/cobalt/webdriver_benchmarks/tests/browse_vertical.py
index ac44823..76a3ff8 100755
--- a/src/cobalt/webdriver_benchmarks/tests/browse_vertical.py
+++ b/src/cobalt/webdriver_benchmarks/tests/browse_vertical.py
@@ -36,8 +36,6 @@
for _ in xrange(NUM_LOAD_TV_CALLS):
self.load_tv()
- self.wait_for_processing_complete_after_focused_shelf()
-
self.send_keys(tv.FOCUSED_SHELF, keys.Keys.ARROW_DOWN)
self.wait_for_processing_complete_after_focused_shelf()
diff --git a/src/cobalt/webdriver_benchmarks/tests/time_to_shelf.py b/src/cobalt/webdriver_benchmarks/tests/time_to_shelf.py
index 9551d9d..4a1c6fa 100755
--- a/src/cobalt/webdriver_benchmarks/tests/time_to_shelf.py
+++ b/src/cobalt/webdriver_benchmarks/tests/time_to_shelf.py
@@ -19,7 +19,6 @@
from __future__ import division
from __future__ import print_function
-import datetime
import os
import sys
@@ -27,39 +26,43 @@
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
# pylint: disable=C6204,C6203
+import timer
import tv_testcase
import tv_testcase_util
class TimeToShelf(tv_testcase.TvTestCase):
+ def setUp(self):
+ # Override TvTestCase's setUp() so that blank startup can first be measured.
+ pass
+
def test_simple(self):
"""This test tries to measure the startup time for the YouTube TV page.
Specifically, this test uses the Cobalt CVal Cobalt.Lifetime, which gets
updated ~60Hz on a best effort basis and is in microseconds, to determine
- "timeToShelfBlankStartupTimeUs" and uses Python's datetime module to
- determine "timeToShelfTestTimeShelfDisplayMedianUs".
-
- Note: t0 is defined after Cobalt starts up, but has not navigated to a page.
- If that true startup time metric is desired, perhaps a separate should be
- used.
+ "timeToShelfBlankStartupTimeUs" and uses Timer to determine
+ "timeToShelfTestTimeShelfDisplayMedianUs".
"""
- metrics_array = []
+
blank_startup_time_microseconds = self.get_cval('Cobalt.Lifetime')
+
+ # Call TvTestCase's setUp() now that the blank startup time has been
+ # measured.
+ super(TimeToShelf, self).setUp()
+
+ metrics_array = []
for _ in range(10):
- t0 = datetime.datetime.now()
- self.load_tv()
- self.wait_for_processing_complete_after_focused_shelf()
- t1 = datetime.datetime.now()
- delta = t1 - t0
- startup_time_microseconds = delta.seconds * 1000000 + delta.microseconds
+ with timer.Timer('TimeShelfDisplay') as t:
+ self.load_tv()
+ startup_time_microseconds = int(t.seconds_elapsed * 1000000)
metrics_array.append(startup_time_microseconds)
- tv_testcase_util.record_test_result_median(
- 'timeToShelfTestTimeShelfDisplayMedianUs', metrics_array)
tv_testcase_util.record_test_result('timeToShelfBlankStartupTimeUs',
blank_startup_time_microseconds)
+ tv_testcase_util.record_test_result_median(
+ 'timeToShelfTestTimeShelfDisplayMedianUs', metrics_array)
if __name__ == '__main__':
diff --git a/src/cobalt/webdriver_benchmarks/tv.py b/src/cobalt/webdriver_benchmarks/tv.py
index 6bd0a70..5382a8d 100644
--- a/src/cobalt/webdriver_benchmarks/tv.py
+++ b/src/cobalt/webdriver_benchmarks/tv.py
@@ -11,6 +11,7 @@
FOCUSED_TILE = '.focused.tile'
FOCUSED_WATCH = '.focused.watch'
SEARCH_LEGEND = '.search.no-model.legend-item'
+TITLE_CARD_HIDDEN = '.title-card.hidden'
SEARCH = '#search'
WATCH = '#watch'
diff --git a/src/cobalt/webdriver_benchmarks/tv_testcase.py b/src/cobalt/webdriver_benchmarks/tv_testcase.py
index 796c860..b3781b4 100644
--- a/src/cobalt/webdriver_benchmarks/tv_testcase.py
+++ b/src/cobalt/webdriver_benchmarks/tv_testcase.py
@@ -11,21 +11,10 @@
import time
import unittest
-# pylint: disable=C6204
-try:
- # This code works for Python 2.
- import urlparse
- from urllib import urlencode
-except ImportError:
- # This code works for Python 3.
- import urllib.parse as urlparse
- from urllib.parse import urlencode
-
# This directory is a package
sys.path.insert(0, os.path.abspath("."))
# pylint: disable=C6204,C6203
import c_val_names
-import container_util
import tv
import tv_testcase_runner
import tv_testcase_util
@@ -38,18 +27,18 @@
ElementNotVisibleException = tv_testcase_util.import_selenium_module(
submodule="common.exceptions").ElementNotVisibleException
-BASE_URL = "https://www.youtube.com/"
-TV_APP_PATH = "/tv"
-BASE_PARAMS = {"env_forcedOffAllExperiments": True}
+WINDOWDRIVER_CREATED_TIMEOUT_SECONDS = 30
PAGE_LOAD_WAIT_SECONDS = 30
PROCESSING_TIMEOUT_SECONDS = 15
MEDIA_TIMEOUT_SECONDS = 30
-# Today, Cobalt's WebDriver has a race that
-# can leave the former page's DOM visible after a navigate.
-# As a workaround, sleep for a bit
-# b/33275371
+TITLE_CARD_HIDDEN_TIMEOUT_SECONDS = 30
+# Currently, after loading a new URL with cookies enabled, Kabuki randomizes
+# the shelf entries when the page finishes loading. Sleep for a bit to allow
+# this to occur before starting any additional logic.
COBALT_POST_NAVIGATE_SLEEP_SECONDS = 5
+_is_initialized = False
+
class TvTestCase(unittest.TestCase):
"""Base class for WebDriver tests.
@@ -58,12 +47,18 @@
with an internal class with the same name.
"""
+ class WindowDriverCreatedTimeoutException(BaseException):
+ """Exception thrown when WindowDriver was not created in time."""
+
class ProcessingTimeoutException(BaseException):
"""Exception thrown when processing did not complete in time."""
class MediaTimeoutException(BaseException):
"""Exception thrown when media did not complete in time."""
+ class TitleCardHiddenTimeoutException(BaseException):
+ """Exception thrown when title card did not disappear in time."""
+
@classmethod
def setUpClass(cls):
print("Running " + cls.__name__)
@@ -72,9 +67,23 @@
def tearDownClass(cls):
print("Done " + cls.__name__)
+ def setUp(self):
+ global _is_initialized
+ if not _is_initialized:
+ # Initialize the tests. This involves loading a URL which applies the
+ # forcedOffAllExperiments cookies, ensuring that no subsequent loads
+ # include experiments. Additionally, loading this URL triggers a reload.
+ query_params = {"env_forcedOffAllExperiments": True}
+ triggers_reload = True
+ self.load_tv(None, query_params, triggers_reload)
+ _is_initialized = True
+
def get_webdriver(self):
return tv_testcase_runner.GetWebDriver()
+ def get_windowdriver_created(self):
+ return tv_testcase_runner.GetWindowDriverCreated()
+
def get_cval(self, cval_name):
"""Returns the Python object represented by a JSON cval string.
@@ -90,32 +99,14 @@
else:
return json.loads(json_result)
- def goto(self, path, query_params=None):
- """Goes to a path off of BASE_URL.
-
- Args:
- path: URL path without the hostname.
- query_params: Dictionary of parameter names and values.
- Raises:
- Underlying WebDriver exceptions
- """
- parsed_url = list(urlparse.urlparse(BASE_URL))
- parsed_url[2] = path
- query_dict = BASE_PARAMS.copy()
- if query_params:
- query_dict.update(urlparse.parse_qsl(parsed_url[4]))
- container_util.merge_dict(query_dict, query_params)
- parsed_url[4] = urlencode(query_dict, doseq=True)
- final_url = urlparse.urlunparse(parsed_url)
- self.get_webdriver().get(final_url)
- time.sleep(COBALT_POST_NAVIGATE_SLEEP_SECONDS)
-
- def load_tv(self, label=None, additional_query_params=None):
+ def load_tv(self, label=None, additional_query_params=None,
+ triggers_reload=False):
"""Loads the main TV page and waits for it to display.
Args:
label: A value for the label query parameter.
additional_query_params: A dict containing additional query parameters.
+ triggers_reload: Whether or not the navigation will trigger a reload.
Raises:
Underlying WebDriver exceptions
"""
@@ -124,13 +115,19 @@
query_params = {"label": label}
if additional_query_params is not None:
query_params.update(additional_query_params)
- self.goto(TV_APP_PATH, query_params)
+ self.get_windowdriver_created().clear()
+ self.get_webdriver().get(tv_testcase_util.get_tv_url(query_params))
+ self.wait_for_windowdriver_created()
+ if triggers_reload:
+ self.get_windowdriver_created().clear()
+ self.wait_for_windowdriver_created()
+ time.sleep(COBALT_POST_NAVIGATE_SLEEP_SECONDS)
# Note that the internal tests use "expect_transition" which is
# a mechanism that sets a maximum timeout for a "@with_retries"
# decorator-driven success retry loop for subsequent webdriver requests.
#
# We'll skip that sophistication here.
- self.poll_until_found(tv.FOCUSED_SHELF)
+ self.wait_for_processing_complete_after_focused_shelf()
def poll_until_found(self, css_selector):
"""Polls until an element is found.
@@ -217,6 +214,12 @@
raise
time.sleep(1)
+ def wait_for_windowdriver_created(self):
+ """Waits for Cobalt to create a WindowDriver."""
+ windowdriver_created = self.get_windowdriver_created()
+ if not windowdriver_created.wait(WINDOWDRIVER_CREATED_TIMEOUT_SECONDS):
+ raise TvTestCase.WindowDriverCreatedTimeoutException()
+
def wait_for_processing_complete_after_focused_shelf(self):
"""Waits for Cobalt to focus on a shelf and complete pending layouts."""
self.poll_until_found(tv.FOCUSED_SHELF)
@@ -272,9 +275,21 @@
c_val_names.event_duration_dom_video_start_delay()) == 0:
if time.time() - start_time > MEDIA_TIMEOUT_SECONDS:
raise TvTestCase.MediaTimeoutException()
-
time.sleep(0.1)
+ def wait_for_title_card_hidden(self):
+ """Waits for the title to disappear while a video is playing.
+
+ Raises:
+ TitleCardHiddenTimeoutException: The title card did not become hidden in
+ the required time.
+ """
+ start_time = time.time()
+ while not self.find_elements(tv.TITLE_CARD_HIDDEN):
+ if time.time() - start_time > TITLE_CARD_HIDDEN_TIMEOUT_SECONDS:
+ raise TvTestCase.TitleCardHiddenTimeoutException()
+ time.sleep(1)
+
def main():
logging.basicConfig(level=logging.DEBUG)
diff --git a/src/cobalt/webdriver_benchmarks/tv_testcase_event_recorder.py b/src/cobalt/webdriver_benchmarks/tv_testcase_event_recorder.py
index 50acc3c..d8aec07 100644
--- a/src/cobalt/webdriver_benchmarks/tv_testcase_event_recorder.py
+++ b/src/cobalt/webdriver_benchmarks/tv_testcase_event_recorder.py
@@ -59,9 +59,7 @@
self.event_type = options.event_type
self.skip_font_file_load_events = options.skip_font_file_load_events
- if self.skip_font_file_load_events:
- self.font_files_loaded_count = self.test.get_cval(
- c_val_names.count_font_files_loaded())
+ self.font_files_loaded_count = None
self.render_tree_failure_count = 0
self.font_file_load_skip_count = 0
@@ -78,8 +76,10 @@
self._add_value_dictionary_recorder("CntDomHtmlElements")
self._add_value_dictionary_recorder("CntDomHtmlElementsCreated")
self._add_value_dictionary_recorder("CntDomHtmlElementsDestroyed")
- self._add_value_dictionary_recorder("CntDomUpdateMatchingRuleCalls")
- self._add_value_dictionary_recorder("CntDomUpdateComputedStyleCalls")
+ self._add_value_dictionary_recorder("CntDomUpdateMatchingRules")
+ self._add_value_dictionary_recorder("CntDomUpdateComputedStyle")
+ self._add_value_dictionary_recorder("CntDomGenerateHtmlComputedStyle")
+ self._add_value_dictionary_recorder("CntDomGeneratePseudoComputedStyle")
self._add_value_dictionary_recorder("CntLayoutBoxes")
self._add_value_dictionary_recorder("CntLayoutBoxesCreated")
self._add_value_dictionary_recorder("CntLayoutBoxesDestroyed")
@@ -109,12 +109,17 @@
def on_start_event(self):
"""Handles logic related to the start of the event instance."""
- pass
+
+ # If the recorder is set to skip events with font file loads and the font
+ # file loaded count hasn't been initialized yet, then do that now.
+ if self.skip_font_file_load_events and self.font_files_loaded_count is None:
+ self.font_files_loaded_count = self.test.get_cval(
+ c_val_names.count_font_files_loaded())
def on_end_event(self):
"""Handles logic related to the end of the event instance."""
- # If the event is set to skip events with font file loads and a font file
+ # If the recorder is set to skip events with font file loads and a font file
# loaded during the event, then its data is not collected. Log that it was
# skipped and return.
if self.skip_font_file_load_events:
@@ -133,7 +138,7 @@
# If the event failed to produce a render tree, then its data is not
# collected. Log the failure and return.
- if not value_dictionary.get("ProducedRenderTree"):
+ if not value_dictionary or not value_dictionary.get("ProducedRenderTree"):
self.render_tree_failure_count += 1
print("{} event failed to produce render tree! {} events failed.".format(
self.event_name, self.render_tree_failure_count))
diff --git a/src/cobalt/webdriver_benchmarks/tv_testcase_runner.py b/src/cobalt/webdriver_benchmarks/tv_testcase_runner.py
index ab69ff6..d543c4a 100755
--- a/src/cobalt/webdriver_benchmarks/tv_testcase_runner.py
+++ b/src/cobalt/webdriver_benchmarks/tv_testcase_runner.py
@@ -47,6 +47,8 @@
# Pattern to match Cobalt log line for when the WebDriver port has been
# opened.
RE_WEBDRIVER_LISTEN = re.compile(r"Starting WebDriver server on port (\d+)")
+# Pattern to match Cobalt log line for when a WindowDriver has been created.
+RE_WINDOWDRIVER_CREATED = re.compile(r"Created WindowDriver: ID=\S+")
STARTUP_TIMEOUT_SECONDS = 2 * 60
@@ -61,6 +63,7 @@
}
_webdriver = None
+_windowdriver_created = threading.Event()
def GetWebDriver():
@@ -68,6 +71,11 @@
return _webdriver
+def GetWindowDriverCreated():
+ """Returns the WindowDriver created instance."""
+ return _windowdriver_created
+
+
class TimeoutException(Exception):
pass
@@ -96,7 +104,13 @@
self.launcher = app_launcher.CreateLauncher(
platform, executable, devkit_name=devkit_name, close_output_file=False)
- self.launcher.SetArgs(["--enable_webdriver"])
+ args = []
+ args.append("--enable_webdriver")
+ args.append("--null_savegame")
+ args.append("--debug_console=off")
+ args.append("--url=about:blank")
+
+ self.launcher.SetArgs(args)
self.launcher.SetOutputCallback(self._HandleLine)
self.log_file_path = log_file_path
self.log_file = None
@@ -123,6 +137,11 @@
def _HandleLine(self, line):
"""Internal log line callback."""
+ # Check for a WindowDriver being created.
+ if RE_WINDOWDRIVER_CREATED.search(line):
+ _windowdriver_created.set()
+ return
+
# Wait for WebDriver port here then connect
if self.test_script_started.is_set():
return
diff --git a/src/cobalt/webdriver_benchmarks/tv_testcase_util.py b/src/cobalt/webdriver_benchmarks/tv_testcase_util.py
index 51840c3..4542e90 100644
--- a/src/cobalt/webdriver_benchmarks/tv_testcase_util.py
+++ b/src/cobalt/webdriver_benchmarks/tv_testcase_util.py
@@ -8,6 +8,10 @@
import json
import sys
+# pylint: disable=C6204
+import urlparse
+from urllib import urlencode
+
import container_util
# These are watched for in webdriver_benchmark_test.py
@@ -18,6 +22,11 @@
EVENT_TYPE_KEY_DOWN = "KeyDown"
EVENT_TYPE_KEY_UP = "KeyUp"
+# URL-related constants
+BASE_URL = "https://www.youtube.com/"
+TV_APP_PATH = "/tv"
+BASE_PARAMS = {}
+
def import_selenium_module(submodule=None):
"""Dynamically imports a selenium.webdriver submodule.
@@ -52,6 +61,23 @@
return module
+def get_url(path, query_params=None):
+ """Returns the URL indicated by the path and query parameters."""
+ parsed_url = list(urlparse.urlparse(BASE_URL))
+ parsed_url[2] = path
+ query_dict = BASE_PARAMS.copy()
+ if query_params:
+ query_dict.update(urlparse.parse_qsl(parsed_url[4]))
+ container_util.merge_dict(query_dict, query_params)
+ parsed_url[4] = urlencode(query_dict, doseq=True)
+ return urlparse.urlunparse(parsed_url)
+
+
+def get_tv_url(query_params=None):
+ """Returns the tv URL indicated by the query parameters."""
+ return get_url(TV_APP_PATH, query_params)
+
+
def record_test_result(name, result):
"""Records an individual scalar result of a benchmark test.
diff --git a/src/media/filters/chunk_demuxer.cc b/src/media/filters/chunk_demuxer.cc
index 76cc2c8..64760b8 100644
--- a/src/media/filters/chunk_demuxer.cc
+++ b/src/media/filters/chunk_demuxer.cc
@@ -73,7 +73,7 @@
#if defined(OS_STARBOARD)
#if SB_HAS(MEDIA_WEBM_VP9_SUPPORT)
-static const CodecInfo kVP9CodecInfo = { "vp9", DemuxerStream::VIDEO };
+static const CodecInfo kVP9CodecInfo = {"vp9*", DemuxerStream::VIDEO};
static const CodecInfo* kVideoWebMCodecs[] = {
&kVP9CodecInfo,
diff --git a/src/nb/string_interner.cc b/src/nb/string_interner.cc
index 482ea95..b4da03a 100644
--- a/src/nb/string_interner.cc
+++ b/src/nb/string_interner.cc
@@ -14,7 +14,10 @@
* limitations under the License.
*/
+#include "nb/hash.h"
#include "nb/string_interner.h"
+#include "starboard/client_porting/poem/string_poem.h"
+#include "starboard/string.h"
namespace nb {
@@ -69,4 +72,64 @@
return out;
}
-} // namespace nb
+ConcurrentStringInterner::ConcurrentStringInterner(size_t table_size) {
+ Construct(table_size);
+}
+
+void ConcurrentStringInterner::Construct(size_t table_size) {
+ if (table_size == 0) {
+ table_size = 1;
+ }
+ string_interner_table_.reserve(table_size);
+ for (size_t i = 0; i < table_size; ++i) {
+ string_interner_table_.push_back(new StringInterner);
+ }
+}
+
+ConcurrentStringInterner::~ConcurrentStringInterner() {
+ for (size_t i = 0; i < string_interner_table_.size(); ++i) {
+ delete string_interner_table_[i];
+ }
+}
+
+const std::string& ConcurrentStringInterner::Intern(const std::string& str) {
+ return GetBucket(str.c_str(), str.size()).Intern(str);
+}
+
+const std::string& ConcurrentStringInterner::Intern(const char* c_string) {
+ return GetBucket(c_string, SbStringGetLength(c_string)).Intern(c_string);
+}
+
+const std::string* ConcurrentStringInterner::Get(const std::string& str) const {
+ return GetBucket(str.c_str(), str.size()).Get(str);
+}
+
+const std::string* ConcurrentStringInterner::Get(const char* c_string) const {
+ return GetBucket(c_string, SbStringGetLength(c_string)).Get(c_string);
+}
+
+size_t ConcurrentStringInterner::Size() const {
+ size_t sum = 0;
+ for (size_t i = 0; i < string_interner_table_.size(); ++i) {
+ sum += string_interner_table_[i]->Size();
+ }
+ return sum;
+}
+
+nb::StringInterner&
+ConcurrentStringInterner::GetBucket(const char* string, size_t n) {
+ uint32_t hash_value = nb::RuntimeHash32(string, n);
+ size_t index =
+ static_cast<size_t>(hash_value % string_interner_table_.size());
+ return *string_interner_table_[index];
+}
+
+const nb::StringInterner&
+ConcurrentStringInterner::GetBucket(const char* string, size_t n) const {
+ uint32_t hash_value = nb::RuntimeHash32(string, n);
+ size_t index =
+ static_cast<size_t>(hash_value % string_interner_table_.size());
+ return *string_interner_table_[index];
+}
+
+ } // namespace nb
diff --git a/src/nb/string_interner.h b/src/nb/string_interner.h
index 2ae07ba..87840bf 100644
--- a/src/nb/string_interner.h
+++ b/src/nb/string_interner.h
@@ -19,6 +19,7 @@
#include <set>
#include <string>
+#include <vector>
#include "starboard/configuration.h"
#include "starboard/mutex.h"
@@ -67,6 +68,31 @@
SB_DISALLOW_COPY_AND_ASSIGN(StringInterner);
};
+class ConcurrentStringInterner {
+ public:
+ explicit ConcurrentStringInterner(size_t table_size = 32);
+ ~ConcurrentStringInterner(); // All outstanding const std::string* are invalidated.
+
+ // Returns an equivalent string to the input. If the input is missing from
+ // the data store then a copy-by-value is made.
+ const std::string& Intern(const std::string& str);
+ const std::string& Intern(const char* c_string);
+
+ // Returns the string object if it exists, otherwise NULL.
+ const std::string* Get(const std::string& str) const;
+ const std::string* Get(const char* c_string) const;
+
+ size_t Size() const;
+
+ private:
+ void Construct(size_t table_size);
+ StringInterner& GetBucket(const char* string, size_t n);
+ const StringInterner& GetBucket(const char* string, size_t n) const;
+ std::vector<StringInterner*> string_interner_table_;
+
+ SB_DISALLOW_COPY_AND_ASSIGN(ConcurrentStringInterner);
+};
+
} // namespace nb
#endif // NB_STRING_INTERNER_H_
diff --git a/src/nb/string_interner_test.cc b/src/nb/string_interner_test.cc
index dc4df8c..cb296a8 100644
--- a/src/nb/string_interner_test.cc
+++ b/src/nb/string_interner_test.cc
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include <cstring>
#include <string>
#include "nb/string_interner.h"
@@ -22,8 +23,31 @@
namespace nb {
namespace {
-TEST(StringInterner, Intern) {
- StringInterner string_interner;
+typedef ::testing::Types<StringInterner, ConcurrentStringInterner>
+ StringInternerTypes;
+
+// Defines test type that will be instantiated using each type in
+// AllAtomicTypes type list.
+template <typename T>
+class StringInternerTest : public ::testing::Test {};
+TYPED_TEST_CASE(StringInternerTest, StringInternerTypes); // Registration.
+
+std::string GenerateRandomString(size_t size) {
+ static const char valid_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz";
+ static const size_t n = strlen(valid_chars);
+
+ std::stringstream ss;
+ for (size_t i = 0; i < size; ++i) {
+ size_t random_char_index = std::rand() % n;
+ ss << valid_chars[random_char_index];
+ }
+ return ss.str();
+}
+
+TYPED_TEST(StringInternerTest, Intern) {
+ typedef TypeParam StringInternerT;
+ StringInternerT string_interner;
EXPECT_FALSE(string_interner.Get("A"));
EXPECT_EQ(&string_interner.Intern("A"), &string_interner.Intern("A"));
EXPECT_TRUE(string_interner.Get("A"));
@@ -32,8 +56,9 @@
EXPECT_EQ(2, string_interner.Size());
}
-TEST(StringInterner, InternStdString) {
- StringInterner string_interner;
+TYPED_TEST(StringInternerTest, InternStdString) {
+ typedef TypeParam StringInternerT;
+ StringInternerT string_interner;
std::string a = "A";
std::string a_copy = "A";
std::string b = "B";
@@ -46,5 +71,47 @@
EXPECT_EQ(2, string_interner.Size());
}
+TYPED_TEST(StringInternerTest, InternBothStrings) {
+ typedef TypeParam StringInternerT;
+ StringInternerT string_interner;
+
+ std::string a_stdstring = "A";
+ const char* c_string = "A";
+
+ const std::string* a_pointer = &string_interner.Intern("A");
+ EXPECT_EQ(a_pointer, &string_interner.Intern(c_string));
+ EXPECT_EQ(a_pointer, &string_interner.Intern(a_stdstring));
+}
+
+// Tests the expectation that a set of unique strings can all be inserted
+// into the (Concurrent)StringInterner.
+TYPED_TEST(StringInternerTest, LoadLotsOfUniqueStrings) {
+ typedef TypeParam StringInternerT;
+ StringInternerT string_interner;
+
+ static const size_t kNumStringsToLoad = 1000;
+
+ std::set<std::string> all_unique_strings;
+
+ // Keep generating random strings until we have a full set of unique strings.
+ while (all_unique_strings.size() < kNumStringsToLoad) {
+ all_unique_strings.insert(GenerateRandomString(25));
+ }
+
+ for (std::set<std::string>::const_iterator it = all_unique_strings.begin();
+ it != all_unique_strings.end(); ++it) {
+ const std::string& str = *it;
+ ASSERT_FALSE(string_interner.Get(str));
+ ASSERT_FALSE(string_interner.Get(str.c_str())); // c-string version.
+
+ string_interner.Intern(str);
+
+ ASSERT_TRUE(string_interner.Get(str));
+ ASSERT_TRUE(string_interner.Get(str.c_str())); // c-string version.
+ }
+
+ ASSERT_EQ(string_interner.Size(), all_unique_strings.size());
+}
+
} // namespace
} // namespace nb
diff --git a/src/net/http/http_util.cc b/src/net/http/http_util.cc
index 033b00d..c406586 100644
--- a/src/net/http/http_util.cc
+++ b/src/net/http/http_util.cc
@@ -426,6 +426,13 @@
return c == '"' || c == '\'';
}
+bool HttpUtil::IsTokenChar(char c) {
+ return !(c >= 0x7F || c <= 0x20 || c == '(' || c == ')' || c == '<' ||
+ c == '>' || c == '@' || c == ',' || c == ';' || c == ':' ||
+ c == '\\' || c == '"' || c == '/' || c == '[' || c == ']' ||
+ c == '?' || c == '=' || c == '{' || c == '}');
+}
+
// See RFC 2616 Sec 2.2 for the definition of |token|.
bool HttpUtil::IsToken(string::const_iterator begin,
string::const_iterator end) {
diff --git a/src/net/http/http_util.h b/src/net/http/http_util.h
index 7560b92..1846664 100644
--- a/src/net/http/http_util.h
+++ b/src/net/http/http_util.h
@@ -104,6 +104,8 @@
// Whether the character is the start of a quotation mark.
static bool IsQuote(char c);
+ // Whether the character is a valid |tchar| as defined in RFC 7230 Sec 3.2.6.
+ static bool IsTokenChar(char c);
// Whether the string is a valid |token| as defined in RFC 2616 Sec 2.2.
static bool IsToken(std::string::const_iterator begin,
std::string::const_iterator end);
diff --git a/src/net/net.gyp b/src/net/net.gyp
index 36d3e12..4a0a740 100644
--- a/src/net/net.gyp
+++ b/src/net/net.gyp
@@ -10,7 +10,7 @@
# this flag is set, we hackily avoid using mmap() in the disk cache.
'posix_avoid_mmap%': 0,
- 'enable_websockets%' : 0,
+ 'enable_websockets%' : 1,
'use_native_http_stack%': 0,
},
'targets': [
@@ -676,10 +676,18 @@
'url_request/url_request_throttler_manager.h',
'url_request/view_cache_helper.cc',
'url_request/view_cache_helper.h',
+ 'websockets/websocket_extension.cc',
+ 'websockets/websocket_extension.h',
+ 'websockets/websocket_extension_parser.cc',
+ 'websockets/websocket_extension_parser.h',
'websockets/websocket_frame.cc',
'websockets/websocket_frame.h',
'websockets/websocket_frame_parser.cc',
'websockets/websocket_frame_parser.h',
+ 'websockets/websocket_handshake_challenge.cc',
+ 'websockets/websocket_handshake_challenge.h',
+ 'websockets/websocket_handshake_constants.cc',
+ 'websockets/websocket_handshake_constants.h',
'websockets/websocket_handshake_handler.cc',
'websockets/websocket_handshake_handler.h',
'websockets/websocket_job.cc',
@@ -1037,6 +1045,7 @@
'url_request/view_cache_helper_unittest.cc',
'websockets/websocket_frame_parser_unittest.cc',
'websockets/websocket_frame_unittest.cc',
+ 'websockets/websocket_handshake_challenge_test.cc',
'websockets/websocket_handshake_handler_unittest.cc',
'websockets/websocket_handshake_handler_spdy2_unittest.cc',
'websockets/websocket_handshake_handler_spdy3_unittest.cc',
diff --git a/src/net/socket_stream/socket_stream.cc b/src/net/socket_stream/socket_stream.cc
index 73d5a2b..95f56a7 100644
--- a/src/net/socket_stream/socket_stream.cc
+++ b/src/net/socket_stream/socket_stream.cc
@@ -40,6 +40,7 @@
#include "net/socket/tcp_client_socket.h"
#include "net/socket_stream/socket_stream_metrics.h"
#include "net/url_request/url_request.h"
+#include "starboard/memory.h"
static const int kMaxPendingSendAllowed = 32768; // 32 kilobytes.
static const int kReadBufferSize = 4096;
@@ -79,7 +80,8 @@
SocketStream::ResponseHeaders::ResponseHeaders() : IOBuffer() {}
void SocketStream::ResponseHeaders::Realloc(size_t new_size) {
- headers_.reset(static_cast<char*>(realloc(headers_.release(), new_size)));
+ headers_.reset(
+ static_cast<char*>(SbMemoryReallocate(headers_.release(), new_size)));
}
SocketStream::ResponseHeaders::~ResponseHeaders() { data_ = NULL; }
diff --git a/src/net/socket_stream/socket_stream.h b/src/net/socket_stream/socket_stream.h
index a86aee8..3fa1f13 100644
--- a/src/net/socket_stream/socket_stream.h
+++ b/src/net/socket_stream/socket_stream.h
@@ -93,7 +93,10 @@
// Called when an error occured.
// This is only for error reporting to the delegate.
// |error| is net::Error.
- virtual void OnError(const SocketStream* socket, int error) {}
+ virtual void OnError(const SocketStream* socket, int error) {
+ UNREFERENCED_PARAMETER(socket);
+ UNREFERENCED_PARAMETER(error);
+ }
// Called when reading cookies to allow the delegate to block access to the
// cookie.
diff --git a/src/net/spdy/spdy_session.h b/src/net/spdy/spdy_session.h
index abb5e92..6c18212 100644
--- a/src/net/spdy/spdy_session.h
+++ b/src/net/spdy/spdy_session.h
@@ -292,6 +292,10 @@
}
void set_spdy_session_pool(SpdySessionPool* pool) {
+ // Not sure why pool is not referenced, so I added UNREFERENCED_PARAMETER
+ // here. It is likely a bug, but not worth investigating as Cobalt does
+ // not support SPDY, and it is unlikely if it ever will.
+ UNREFERENCED_PARAMETER(pool);
spdy_session_pool_ = NULL;
}
diff --git a/src/net/websockets/websocket_extension.cc b/src/net/websockets/websocket_extension.cc
new file mode 100644
index 0000000..6e558ad
--- /dev/null
+++ b/src/net/websockets/websocket_extension.cc
@@ -0,0 +1,82 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/websockets/websocket_extension.h"
+
+#include <map>
+#include <string>
+
+#include "base/logging.h"
+#include "net/http/http_util.h"
+
+namespace net {
+
+WebSocketExtension::Parameter::Parameter(const std::string& name)
+ : name_(name) {}
+
+WebSocketExtension::Parameter::Parameter(const std::string& name,
+ const std::string& value)
+ : name_(name), value_(value) {
+ DCHECK(!value.empty());
+ // |extension-param| must be a token.
+ DCHECK(HttpUtil::IsToken(value));
+}
+
+bool WebSocketExtension::Parameter::Equals(const Parameter& other) const {
+ return name_ == other.name_ && value_ == other.value_;
+}
+
+WebSocketExtension::WebSocketExtension() {}
+
+WebSocketExtension::WebSocketExtension(const std::string& name) : name_(name) {}
+
+WebSocketExtension::WebSocketExtension(const WebSocketExtension& other) {
+ name_ = other.name_;
+ parameters_ = other.parameters_;
+}
+
+WebSocketExtension::~WebSocketExtension() {}
+
+bool WebSocketExtension::Equals(const WebSocketExtension& other) const {
+ if (name_ != other.name_)
+ return false;
+ if (parameters_.size() != other.parameters_.size())
+ return false;
+
+ std::multimap<std::string, std::string> this_parameters, other_parameters;
+ for (std::vector<Parameter>::const_iterator iterator = parameters_.begin();
+ iterator != parameters_.end(); ++iterator) {
+ const Parameter& p(*iterator);
+ this_parameters.insert(std::make_pair(p.name(), p.value()));
+ }
+ for (std::vector<Parameter>::const_iterator iterator =
+ other.parameters_.begin();
+ iterator != other.parameters_.end(); ++iterator) {
+ const Parameter& p(*iterator);
+ other_parameters.insert(std::make_pair(p.name(), p.value()));
+ }
+ return this_parameters == other_parameters;
+}
+
+std::string WebSocketExtension::ToString() const {
+ if (name_.empty())
+ return std::string();
+
+ std::string result = name_;
+
+ for (std::vector<Parameter>::const_iterator iterator = parameters_.begin();
+ iterator != parameters_.end(); ++iterator) {
+ const Parameter& param(*iterator);
+ result += "; " + param.name();
+ if (!param.HasValue())
+ continue;
+
+ // |extension-param| must be a token and we don't need to quote it.
+ DCHECK(HttpUtil::IsToken(param.value()));
+ result += "=" + param.value();
+ }
+ return result;
+}
+
+} // namespace net
diff --git a/src/net/websockets/websocket_extension.h b/src/net/websockets/websocket_extension.h
new file mode 100644
index 0000000..4c42a76
--- /dev/null
+++ b/src/net/websockets/websocket_extension.h
@@ -0,0 +1,59 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_WEBSOCKETS_WEBSOCKET_EXTENSION_H_
+#define NET_WEBSOCKETS_WEBSOCKET_EXTENSION_H_
+
+#include <string>
+#include <vector>
+
+#include "net/base/net_export.h"
+
+namespace net {
+
+// A WebSocketExtension instance represents a WebSocket extension specified
+// in RFC6455.
+class NET_EXPORT_PRIVATE WebSocketExtension {
+ public:
+ // Note that RFC6455 does not allow a parameter with an empty value.
+ class NET_EXPORT_PRIVATE Parameter {
+ public:
+ // Construct a parameter which does not have a value.
+ explicit Parameter(const std::string& name);
+ // Construct a parameter with a non-empty value.
+ Parameter(const std::string& name, const std::string& value);
+
+ bool HasValue() const { return !value_.empty(); }
+ const std::string& name() const { return name_; }
+ const std::string& value() const { return value_; }
+ bool Equals(const Parameter& other) const;
+
+ // The default copy constructor and the assignment operator are defined:
+ // we need them.
+ private:
+ std::string name_;
+ std::string value_;
+ };
+
+ WebSocketExtension();
+ explicit WebSocketExtension(const std::string& name);
+ WebSocketExtension(const WebSocketExtension& other);
+ ~WebSocketExtension();
+
+ void Add(const Parameter& parameter) { parameters_.push_back(parameter); }
+ const std::string& name() const { return name_; }
+ const std::vector<Parameter>& parameters() const { return parameters_; }
+ bool Equals(const WebSocketExtension& other) const;
+ std::string ToString() const;
+
+ // The default copy constructor and the assignment operator are defined:
+ // we need them.
+ private:
+ std::string name_;
+ std::vector<Parameter> parameters_;
+};
+
+} // namespace net
+
+#endif // NET_WEBSOCKETS_WEBSOCKET_EXTENSION_H_
diff --git a/src/net/websockets/websocket_extension_parser.cc b/src/net/websockets/websocket_extension_parser.cc
new file mode 100644
index 0000000..6e52fbf
--- /dev/null
+++ b/src/net/websockets/websocket_extension_parser.cc
@@ -0,0 +1,149 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/websockets/websocket_extension_parser.h"
+
+#include "base/logging.h"
+#include "net/http/http_util.h"
+
+namespace net {
+
+WebSocketExtensionParser::WebSocketExtensionParser() {}
+
+WebSocketExtensionParser::~WebSocketExtensionParser() {}
+
+bool WebSocketExtensionParser::Parse(const char* data, size_t size) {
+ current_ = data;
+ end_ = data + size;
+ extensions_.clear();
+
+ bool failed = false;
+
+ do {
+ WebSocketExtension extension;
+ if (!ConsumeExtension(&extension)) {
+ failed = true;
+ break;
+ }
+ extensions_.push_back(extension);
+
+ ConsumeSpaces();
+ } while (ConsumeIfMatch(','));
+
+ if (!failed && current_ == end_)
+ return true;
+
+ extensions_.clear();
+ return false;
+}
+
+bool WebSocketExtensionParser::Consume(char c) {
+ ConsumeSpaces();
+ if (current_ == end_ || c != *current_)
+ return false;
+ ++current_;
+ return true;
+}
+
+bool WebSocketExtensionParser::ConsumeExtension(WebSocketExtension* extension) {
+ base::StringPiece name;
+ if (!ConsumeToken(&name))
+ return false;
+ *extension = WebSocketExtension(name.as_string());
+
+ while (ConsumeIfMatch(';')) {
+ WebSocketExtension::Parameter parameter((std::string()));
+ if (!ConsumeExtensionParameter(¶meter))
+ return false;
+ extension->Add(parameter);
+ }
+
+ return true;
+}
+
+bool WebSocketExtensionParser::ConsumeExtensionParameter(
+ WebSocketExtension::Parameter* parameter) {
+ base::StringPiece name, value;
+ std::string value_string;
+
+ if (!ConsumeToken(&name))
+ return false;
+
+ if (!ConsumeIfMatch('=')) {
+ *parameter = WebSocketExtension::Parameter(name.as_string());
+ return true;
+ }
+
+ if (Lookahead('\"')) {
+ if (!ConsumeQuotedToken(&value_string))
+ return false;
+ } else {
+ if (!ConsumeToken(&value))
+ return false;
+ value_string = value.as_string();
+ }
+ *parameter = WebSocketExtension::Parameter(name.as_string(), value_string);
+ return true;
+}
+
+bool WebSocketExtensionParser::ConsumeToken(base::StringPiece* token) {
+ ConsumeSpaces();
+ const char* head = current_;
+ while (current_ < end_ && HttpUtil::IsTokenChar(*current_))
+ ++current_;
+ if (current_ == head)
+ return false;
+ *token = base::StringPiece(head, current_ - head);
+ return true;
+}
+
+bool WebSocketExtensionParser::ConsumeQuotedToken(std::string* token) {
+ if (!Consume('"'))
+ return false;
+
+ *token = "";
+ while (current_ < end_ && *current_ != '"') {
+ if (*current_ == '\\') {
+ ++current_;
+ if (current_ == end_)
+ return false;
+ }
+ if (!HttpUtil::IsTokenChar(*current_))
+ return false;
+ *token += *current_;
+ ++current_;
+ }
+ if (current_ == end_)
+ return false;
+ DCHECK_EQ(*current_, '"');
+
+ ++current_;
+
+ return !token->empty();
+}
+
+void WebSocketExtensionParser::ConsumeSpaces() {
+ while (current_ < end_ && (*current_ == ' ' || *current_ == '\t'))
+ ++current_;
+ return;
+}
+
+bool WebSocketExtensionParser::Lookahead(char c) {
+ const char* head = current_;
+ bool result = Consume(c);
+ current_ = head;
+ return result;
+}
+
+bool WebSocketExtensionParser::ConsumeIfMatch(char c) {
+ const char* head = current_;
+ if (!Consume(c)) {
+ current_ = head;
+ return false;
+ }
+
+ return true;
+}
+
+} // namespace net
diff --git a/src/net/websockets/websocket_extension_parser.h b/src/net/websockets/websocket_extension_parser.h
new file mode 100644
index 0000000..66fe804
--- /dev/null
+++ b/src/net/websockets/websocket_extension_parser.h
@@ -0,0 +1,63 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_WEBSOCKETS_WEBSOCKET_EXTENSION_PARSER_H_
+#define NET_WEBSOCKETS_WEBSOCKET_EXTENSION_PARSER_H_
+
+#include <stddef.h>
+
+#include <string>
+#include <vector>
+
+#include "base/compiler_specific.h"
+#include "base/string_piece.h"
+#include "net/base/net_export.h"
+#include "net/websockets/websocket_extension.h"
+
+namespace net {
+
+class NET_EXPORT_PRIVATE WebSocketExtensionParser {
+ public:
+ WebSocketExtensionParser();
+ ~WebSocketExtensionParser();
+
+ // Parses the given string as a Sec-WebSocket-Extensions header value.
+ //
+ // There must be no newline characters in the input. LWS-concatenation must
+ // have already been done before calling this method.
+ //
+ // Returns true if the method was successful (no syntax error was found).
+ bool Parse(const char* data, size_t size);
+ bool Parse(const std::string& data) {
+ return Parse(data.data(), data.size());
+ }
+
+ // Returns the result of the last Parse() method call.
+ const std::vector<WebSocketExtension>& extensions() const {
+ return extensions_;
+ }
+
+ private:
+ WARN_UNUSED_RESULT bool Consume(char c);
+ WARN_UNUSED_RESULT bool ConsumeExtension(WebSocketExtension* extension);
+ WARN_UNUSED_RESULT bool ConsumeExtensionParameter(
+ WebSocketExtension::Parameter* parameter);
+ WARN_UNUSED_RESULT bool ConsumeToken(base::StringPiece* token);
+ WARN_UNUSED_RESULT bool ConsumeQuotedToken(std::string* token);
+ void ConsumeSpaces();
+ WARN_UNUSED_RESULT bool Lookahead(char c);
+ WARN_UNUSED_RESULT bool ConsumeIfMatch(char c);
+
+ // The current position in the input string.
+ const char* current_;
+ // The pointer of the end of the input string.
+ const char* end_;
+ std::vector<WebSocketExtension> extensions_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebSocketExtensionParser);
+};
+
+} // namespace net
+
+#endif // NET_WEBSOCKETS_WEBSOCKET_EXTENSION_PARSER_H_
diff --git a/src/net/websockets/websocket_handshake_challenge.cc b/src/net/websockets/websocket_handshake_challenge.cc
new file mode 100644
index 0000000..3a1c3e8
--- /dev/null
+++ b/src/net/websockets/websocket_handshake_challenge.cc
@@ -0,0 +1,20 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/websockets/websocket_handshake_challenge.h"
+
+#include "base/base64.h"
+#include "base/sha1.h"
+#include "net/websockets/websocket_handshake_constants.h"
+
+namespace net {
+
+std::string ComputeSecWebSocketAccept(const std::string& key) {
+ std::string accept;
+ std::string hash = base::SHA1HashString(key + websockets::kWebSocketGuid);
+ base::Base64Encode(hash, &accept);
+ return accept;
+}
+
+} // namespace net
diff --git a/src/net/websockets/websocket_handshake_challenge.h b/src/net/websockets/websocket_handshake_challenge.h
new file mode 100644
index 0000000..e21f2b0
--- /dev/null
+++ b/src/net/websockets/websocket_handshake_challenge.h
@@ -0,0 +1,21 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_CHALLENGE_H_
+#define NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_CHALLENGE_H_
+
+#include <string>
+
+#include "net/base/net_export.h"
+
+namespace net {
+
+// Given a WebSocket handshake challenge, compute the value that the server
+// should return in the Sec-WebSocket-Accept header.
+NET_EXPORT_PRIVATE std::string ComputeSecWebSocketAccept(
+ const std::string& key);
+
+} // namespace net
+
+#endif // NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_CHALLENGE_H_
diff --git a/src/net/websockets/websocket_handshake_challenge_test.cc b/src/net/websockets/websocket_handshake_challenge_test.cc
new file mode 100644
index 0000000..d7e45ca
--- /dev/null
+++ b/src/net/websockets/websocket_handshake_challenge_test.cc
@@ -0,0 +1,24 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/websockets/websocket_handshake_challenge.h"
+
+#include <string>
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+
+namespace {
+
+// Test the example challenge from the RFC6455.
+TEST(WebSocketHandshakeChallengeTest, RFC6455) {
+ const std::string key = "dGhlIHNhbXBsZSBub25jZQ==";
+ std::string accept = ComputeSecWebSocketAccept(key);
+ EXPECT_EQ("s3pPLMBiTxaQ9kYGzzhZRbK+xOo=", accept);
+}
+
+} // namespace
+
+} // namespace net
diff --git a/src/net/websockets/websocket_handshake_constants.cc b/src/net/websockets/websocket_handshake_constants.cc
new file mode 100644
index 0000000..bb031e2
--- /dev/null
+++ b/src/net/websockets/websocket_handshake_constants.cc
@@ -0,0 +1,38 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/websockets/websocket_handshake_constants.h"
+
+namespace net {
+namespace websockets {
+
+const char kHttpProtocolVersion[] = "HTTP/1.1";
+
+const size_t kRawChallengeLength = 16;
+
+const char kSecWebSocketProtocol[] = "Sec-WebSocket-Protocol";
+const char kSecWebSocketExtensions[] = "Sec-WebSocket-Extensions";
+const char kSecWebSocketKey[] = "Sec-WebSocket-Key";
+const char kSecWebSocketAccept[] = "Sec-WebSocket-Accept";
+const char kSecWebSocketVersion[] = "Sec-WebSocket-Version";
+
+const char kSupportedVersion[] = "13";
+
+const char kUpgrade[] = "Upgrade";
+const char kWebSocketGuid[] = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
+
+const char kSecWebSocketProtocolSpdy3[] = ":sec-websocket-protocol";
+const char kSecWebSocketExtensionsSpdy3[] = ":sec-websocket-extensions";
+
+const char* const kSecWebSocketProtocolLowercase =
+ kSecWebSocketProtocolSpdy3 + 1;
+const char* const kSecWebSocketExtensionsLowercase =
+ kSecWebSocketExtensionsSpdy3 + 1;
+const char kSecWebSocketKeyLowercase[] = "sec-websocket-key";
+const char kSecWebSocketVersionLowercase[] = "sec-websocket-version";
+const char kUpgradeLowercase[] = "upgrade";
+const char kWebSocketLowercase[] = "websocket";
+
+} // namespace websockets
+} // namespace net
diff --git a/src/net/websockets/websocket_handshake_constants.h b/src/net/websockets/websocket_handshake_constants.h
new file mode 100644
index 0000000..6b17be0
--- /dev/null
+++ b/src/net/websockets/websocket_handshake_constants.h
@@ -0,0 +1,91 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// A set of common constants that are needed for the WebSocket handshake.
+// In general, you should prefer using these constants to literal strings,
+// except in tests.
+//
+// These constants cannot be used in files that are compiled on iOS, because
+// this file is not compiled on iOS.
+
+#ifndef NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_CONSTANTS_H_
+#define NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_CONSTANTS_H_
+
+#include <stddef.h>
+
+#include "net/base/net_export.h"
+
+// This file plases constants inside the ::net::websockets namespace to avoid
+// risk of collisions with other symbols in libnet.
+namespace net {
+namespace websockets {
+
+// "HTTP/1.1"
+// RFC6455 only requires HTTP/1.1 "or better" but in practice an HTTP version
+// other than 1.1 should not occur in a WebSocket handshake.
+extern const char kHttpProtocolVersion[];
+
+// The Sec-WebSockey-Key challenge is 16 random bytes, base64 encoded.
+extern const size_t kRawChallengeLength;
+
+// "Sec-WebSocket-Protocol"
+extern const char kSecWebSocketProtocol[];
+
+// "Sec-WebSocket-Extensions"
+extern const char kSecWebSocketExtensions[];
+
+// "Sec-WebSocket-Key"
+extern const char kSecWebSocketKey[];
+
+// "Sec-WebSocket-Accept"
+extern const char kSecWebSocketAccept[];
+
+// "Sec-WebSocket-Version"
+extern const char kSecWebSocketVersion[];
+
+// This implementation only supports one version of the WebSocket protocol,
+// "13", as specified in RFC6455. If support for multiple versions is added in
+// future, it will probably no longer be worth having a constant for this.
+extern const char kSupportedVersion[];
+
+// "Upgrade"
+extern const char kUpgrade[];
+
+// "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" as defined in section 4.1 of
+// RFC6455.
+extern const char NET_EXPORT kWebSocketGuid[];
+
+// Colon-prefixed lowercase headers for SPDY3.
+
+// ":sec-websocket-protocol"
+extern const char kSecWebSocketProtocolSpdy3[];
+
+// ":sec-websocket-extensions"
+extern const char kSecWebSocketExtensionsSpdy3[];
+
+// Some parts of the code require lowercase versions of the header names in
+// order to do case-insensitive comparisons, or because of SPDY.
+// "sec-websocket-protocol"
+extern const char* const kSecWebSocketProtocolLowercase;
+
+// "sec-websocket-extensions"
+extern const char* const kSecWebSocketExtensionsLowercase;
+
+// "sec-webSocket-key"
+extern const char kSecWebSocketKeyLowercase[];
+
+// "sec-websocket-version"
+extern const char kSecWebSocketVersionLowercase[];
+
+// "upgrade"
+extern const char kUpgradeLowercase[];
+
+// "websocket", as used in the "Upgrade:" header. This is always lowercase
+// (except in obsolete versions of the protocol).
+extern const char kWebSocketLowercase[];
+
+} // namespace websockets
+} // namespace net
+
+#endif // NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_CONSTANTS_H_
diff --git a/src/net/websockets/websocket_handshake_handler.cc b/src/net/websockets/websocket_handshake_handler.cc
index 991ea31..657f2c6 100644
--- a/src/net/websockets/websocket_handshake_handler.cc
+++ b/src/net/websockets/websocket_handshake_handler.cc
@@ -541,10 +541,13 @@
headers_ = FilterHeaders(headers_, headers_to_remove, headers_to_remove_len);
}
+std::size_t WebSocketHandshakeResponseHandler::GetRawResponseLength() const {
+ return original_header_length_ + GetResponseKeySize();
+}
+
std::string WebSocketHandshakeResponseHandler::GetRawResponse() const {
DCHECK(HasResponse());
- return std::string(original_.data(),
- original_header_length_ + GetResponseKeySize());
+ return std::string(original_.data(), GetRawResponseLength());
}
std::string WebSocketHandshakeResponseHandler::GetResponse() {
diff --git a/src/net/websockets/websocket_handshake_handler.h b/src/net/websockets/websocket_handshake_handler.h
index b4a0dd5..a39403c 100644
--- a/src/net/websockets/websocket_handshake_handler.h
+++ b/src/net/websockets/websocket_handshake_handler.h
@@ -132,6 +132,7 @@
// Gets raw WebSocket handshake response received from WebSocket server.
std::string GetRawResponse() const;
+ std::size_t GetRawResponseLength() const;
// Gets WebSocket handshake response message sent to renderer process.
std::string GetResponse();
diff --git a/src/net/websockets/websocket_job.cc b/src/net/websockets/websocket_job.cc
index ff60ebe..e04cecd 100644
--- a/src/net/websockets/websocket_job.cc
+++ b/src/net/websockets/websocket_job.cc
@@ -17,8 +17,6 @@
#include "net/http/http_network_session.h"
#include "net/http/http_transaction_factory.h"
#include "net/http/http_util.h"
-#include "net/spdy/spdy_session.h"
-#include "net/spdy/spdy_session_pool.h"
#include "net/url_request/url_request_context.h"
#include "net/websockets/websocket_handshake_handler.h"
#include "net/websockets/websocket_net_log_params.h"
@@ -59,18 +57,11 @@
namespace net {
-bool WebSocketJob::websocket_over_spdy_enabled_ = false;
-
// static
void WebSocketJob::EnsureInit() {
g_websocket_job_init.Get();
}
-// static
-void WebSocketJob::set_websocket_over_spdy_enabled(bool enabled) {
- websocket_over_spdy_enabled_ = enabled;
-}
-
WebSocketJob::WebSocketJob(SocketStream::Delegate* delegate)
: delegate_(delegate),
state_(INITIALIZED),
@@ -80,7 +71,6 @@
started_to_send_handshake_request_(false),
handshake_request_sent_(0),
response_cookies_save_index_(0),
- spdy_protocol_version_(0),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_send_pending_(this)) {
}
@@ -181,7 +171,7 @@
AddRef(); // Balanced when callback_ is cleared.
return ERR_IO_PENDING;
}
- return TrySpdyStream();
+ return OK;
}
void WebSocketJob::OnConnected(
@@ -279,73 +269,6 @@
delegate_->OnError(socket, error);
}
-void WebSocketJob::OnCreatedSpdyStream(int result) {
- DCHECK(spdy_websocket_stream_.get());
- DCHECK(socket_.get());
- DCHECK_NE(ERR_IO_PENDING, result);
-
- if (state_ == CLOSED) {
- result = ERR_ABORTED;
- } else if (result == OK) {
- state_ = CONNECTING;
- result = ERR_PROTOCOL_SWITCHED;
- } else {
- spdy_websocket_stream_.reset();
- }
-
- CompleteIO(result);
-}
-
-void WebSocketJob::OnSentSpdyHeaders(int result) {
- DCHECK_NE(INITIALIZED, state_);
- if (state_ != CONNECTING)
- return;
- if (delegate_)
- delegate_->OnSentData(socket_, handshake_request_->original_length());
- handshake_request_.reset();
-}
-
-int WebSocketJob::OnReceivedSpdyResponseHeader(
- const SpdyHeaderBlock& headers, int status) {
- DCHECK_NE(INITIALIZED, state_);
- if (state_ != CONNECTING)
- return status;
- if (status != OK)
- return status;
- // TODO(toyoshim): Fallback to non-spdy connection?
- handshake_response_->ParseResponseHeaderBlock(headers,
- challenge_,
- spdy_protocol_version_);
-
- SaveCookiesAndNotifyHeaderComplete();
- return OK;
-}
-
-void WebSocketJob::OnSentSpdyData(int amount_sent) {
- DCHECK_NE(INITIALIZED, state_);
- DCHECK_NE(CONNECTING, state_);
- if (state_ == CLOSED)
- return;
- if (!spdy_websocket_stream_.get())
- return;
- OnSentData(socket_, amount_sent);
-}
-
-void WebSocketJob::OnReceivedSpdyData(const char* data, int length) {
- DCHECK_NE(INITIALIZED, state_);
- DCHECK_NE(CONNECTING, state_);
- if (state_ == CLOSED)
- return;
- if (!spdy_websocket_stream_.get())
- return;
- OnReceivedData(socket_, data, length);
-}
-
-void WebSocketJob::OnCloseSpdyStream() {
- spdy_websocket_stream_.reset();
- OnClose(socket_);
-}
-
bool WebSocketJob::SendHandshakeRequest(const char* data, int len) {
DCHECK_EQ(state_, CONNECTING);
if (started_to_send_handshake_request_)
@@ -389,13 +312,7 @@
}
void WebSocketJob::DoSendData() {
- if (spdy_websocket_stream_.get()) {
- scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock);
- handshake_request_->GetRequestHeaderBlock(
- socket_->url(), headers.get(), &challenge_, spdy_protocol_version_);
- spdy_websocket_stream_->SendRequest(headers.Pass());
- } else {
- const std::string& handshake_request =
+ const std::string& handshake_request =
handshake_request_->GetRawRequest();
handshake_request_sent_ = 0;
socket_->net_log()->AddEvent(
@@ -403,7 +320,6 @@
base::Bind(&NetLogWebSocketHandshakeCallback, &handshake_request));
socket_->SendData(handshake_request.data(),
handshake_request.size());
- }
// Just buffered in |handshake_request_|.
started_to_send_handshake_request_ = true;
}
@@ -441,10 +357,7 @@
return;
}
// handshake message is completed.
- std::string raw_response = handshake_response_->GetRawResponse();
- socket_->net_log()->AddEvent(
- NetLog::TYPE_WEB_SOCKET_READ_RESPONSE_HEADERS,
- base::Bind(&NetLogWebSocketHandshakeCallback, &raw_response));
+
if (len - response_length > 0) {
// If we received extra data, it should be frame data.
DCHECK(received_data_after_handshake_.empty());
@@ -536,57 +449,6 @@
return addresses_;
}
-int WebSocketJob::TrySpdyStream() {
- if (!socket_.get())
- return ERR_FAILED;
-
- if (!websocket_over_spdy_enabled_)
- return OK;
-
- // Check if we have a SPDY session available.
- HttpTransactionFactory* factory =
- socket_->context()->http_transaction_factory();
- if (!factory)
- return OK;
- scoped_refptr<HttpNetworkSession> session = factory->GetSession();
- if (!session.get())
- return OK;
- SpdySessionPool* spdy_pool = session->spdy_session_pool();
- const HostPortProxyPair pair(HostPortPair::FromURL(socket_->url()),
- socket_->proxy_server());
- if (!spdy_pool->HasSession(pair))
- return OK;
-
- // Forbid wss downgrade to SPDY without SSL.
- // TODO(toyoshim): Does it realize the same policy with HTTP?
- scoped_refptr<SpdySession> spdy_session =
- spdy_pool->Get(pair, *socket_->net_log());
- SSLInfo ssl_info;
- bool was_npn_negotiated;
- NextProto protocol_negotiated = kProtoUnknown;
- bool use_ssl = spdy_session->GetSSLInfo(
- &ssl_info, &was_npn_negotiated, &protocol_negotiated);
- if (socket_->is_secure() && !use_ssl)
- return OK;
-
- // Create SpdyWebSocketStream.
- spdy_protocol_version_ = spdy_session->GetProtocolVersion();
- spdy_websocket_stream_.reset(new SpdyWebSocketStream(spdy_session, this));
-
- int result = spdy_websocket_stream_->InitializeStream(
- socket_->url(), MEDIUM, *socket_->net_log());
- if (result == OK) {
- OnConnected(socket_, kMaxPendingSendAllowed);
- return ERR_PROTOCOL_SWITCHED;
- }
- if (result != ERR_IO_PENDING) {
- spdy_websocket_stream_.reset();
- return OK;
- }
-
- return ERR_IO_PENDING;
-}
-
void WebSocketJob::SetWaiting() {
waiting_ = true;
}
@@ -607,12 +469,7 @@
}
void WebSocketJob::RetryPendingIO() {
- int result = TrySpdyStream();
-
- // In the case of ERR_IO_PENDING, CompleteIO() will be called from
- // OnCreatedSpdyStream().
- if (result != ERR_IO_PENDING)
- CompleteIO(result);
+ CompleteIO(OK);
}
void WebSocketJob::CompleteIO(int result) {
@@ -626,16 +483,12 @@
}
bool WebSocketJob::SendDataInternal(const char* data, int length) {
- if (spdy_websocket_stream_.get())
- return ERR_IO_PENDING == spdy_websocket_stream_->SendData(data, length);
if (socket_.get())
return socket_->SendData(data, length);
return false;
}
void WebSocketJob::CloseInternal() {
- if (spdy_websocket_stream_.get())
- spdy_websocket_stream_->Close();
if (socket_.get())
socket_->Close();
}
diff --git a/src/net/websockets/websocket_job.h b/src/net/websockets/websocket_job.h
index e01085b..99a9c93 100644
--- a/src/net/websockets/websocket_job.h
+++ b/src/net/websockets/websocket_job.h
@@ -13,8 +13,6 @@
#include "net/base/address_list.h"
#include "net/base/completion_callback.h"
#include "net/socket_stream/socket_stream_job.h"
-#include "net/spdy/spdy_header_block.h"
-#include "net/spdy/spdy_websocket_stream.h"
class GURL;
@@ -33,8 +31,7 @@
// TODO(ukai): refactor websocket.cc to use this.
class NET_EXPORT WebSocketJob
: public SocketStreamJob,
- public SocketStream::Delegate,
- public SpdyWebSocketStream::Delegate {
+ public SocketStream::Delegate {
public:
// This is state of WebSocket, not SocketStream.
enum State {
@@ -49,10 +46,6 @@
static void EnsureInit();
- // Enable or Disable WebSocket over SPDY feature.
- // This function is intended to be called before I/O thread starts.
- static void set_websocket_over_spdy_enabled(bool enabled);
-
State state() const { return state_; }
virtual void Connect() OVERRIDE;
virtual bool SendData(const char* data, int len) OVERRIDE;
@@ -77,19 +70,12 @@
bool fatal) OVERRIDE;
virtual void OnError(const SocketStream* socket, int error) OVERRIDE;
- // SpdyWebSocketStream::Delegate methods.
- virtual void OnCreatedSpdyStream(int status) OVERRIDE;
- virtual void OnSentSpdyHeaders(int status) OVERRIDE;
- virtual int OnReceivedSpdyResponseHeader(
- const SpdyHeaderBlock& headers, int status) OVERRIDE;
- virtual void OnSentSpdyData(int amount_sent) OVERRIDE;
- virtual void OnReceivedSpdyData(const char* data, int length) OVERRIDE;
- virtual void OnCloseSpdyStream() OVERRIDE;
+ WebSocketHandshakeResponseHandler* GetHandshakeResponse() {
+ return handshake_response_.get();
+ }
private:
friend class WebSocketThrottle;
- friend class WebSocketJobSpdy2Test;
- friend class WebSocketJobSpdy3Test;
virtual ~WebSocketJob();
bool SendHandshakeRequest(const char* data, int len);
@@ -107,7 +93,6 @@
GURL GetURLForCookies() const;
const AddressList& address_list() const;
- int TrySpdyStream();
void SetWaiting();
bool IsWaiting() const;
void Wakeup();
@@ -118,8 +103,6 @@
void CloseInternal();
void SendPending();
- static bool websocket_over_spdy_enabled_;
-
SocketStream::Delegate* delegate_;
State state_;
bool waiting_;
@@ -139,8 +122,6 @@
scoped_refptr<DrainableIOBuffer> current_send_buffer_;
std::vector<char> received_data_after_handshake_;
- int spdy_protocol_version_;
- scoped_ptr<SpdyWebSocketStream> spdy_websocket_stream_;
std::string challenge_;
base::WeakPtrFactory<WebSocketJob> weak_ptr_factory_;
diff --git a/src/net/websockets/websocket_throttle_unittest.cc b/src/net/websockets/websocket_throttle_unittest.cc
index ef05c4c..7577574 100644
--- a/src/net/websockets/websocket_throttle_unittest.cc
+++ b/src/net/websockets/websocket_throttle_unittest.cc
@@ -63,7 +63,6 @@
DummySocketStreamDelegate delegate;
// TODO(toyoshim): We need to consider both spdy-enabled and spdy-disabled
// configuration.
- WebSocketJob::set_websocket_over_spdy_enabled(true);
// For host1: 1.2.3.4, 1.2.3.5, 1.2.3.6
AddressList addr;
@@ -280,7 +279,6 @@
TEST_F(WebSocketThrottleTest, NoThrottleForDuplicateAddress) {
TestURLRequestContext context;
DummySocketStreamDelegate delegate;
- WebSocketJob::set_websocket_over_spdy_enabled(true);
// For localhost: 127.0.0.1, 127.0.0.1
AddressList addr;
diff --git a/src/starboard/accessibility.h b/src/starboard/accessibility.h
new file mode 100644
index 0000000..fbe4c97
--- /dev/null
+++ b/src/starboard/accessibility.h
@@ -0,0 +1,57 @@
+// Copyright 2017 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.
+
+// Module Overview: Starboard Accessibility module
+//
+// Provides access to the system options and settings related to accessibility.
+
+#ifndef STARBOARD_ACCESSIBILITY_H_
+#define STARBOARD_ACCESSIBILITY_H_
+
+#include "starboard/export.h"
+#include "starboard/types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if SB_API_VERSION >= SB_EXPERIMENTAL_API_VERSION
+
+// A group of settings related to text-to-speech functionality, for platforms
+// that expose system settings for text-to-speech.
+typedef struct SbAccessibilityTextToSpeechSettings {
+ // Whether this platform has a system setting for text-to-speech or not.
+ bool has_text_to_speech_setting;
+
+ // Whether the text-to-speech setting is enabled or not. This setting is only
+ // valid if |has_text_to_speech_setting| is set to true.
+ bool is_text_to_speech_enabled;
+} SbAccessibilityTextToSpeechSettings;
+
+// Get the platform settings related to the text-to-speech accessibility
+// feature. This function returns false if |out_settings| is NULL or if it is
+// not zero-initialized.
+//
+// |out_settings|: A pointer to a zero-initialized
+// SbAccessibilityTextToSpeechSettings struct.
+SB_EXPORT bool SbAccessibilityGetTextToSpeechSettings(
+ SbAccessibilityTextToSpeechSettings* out_settings);
+
+#endif // SB_API_VERSION >= SB_EXPERIMENTAL_API_VERSION
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // STARBOARD_ACCESSIBILITY_H_
diff --git a/src/starboard/common/flat_map.h b/src/starboard/common/flat_map.h
index 4f4d39c..2e04d60 100644
--- a/src/starboard/common/flat_map.h
+++ b/src/starboard/common/flat_map.h
@@ -53,7 +53,7 @@
// where n is the number of items in flatmap
// and m is the input size for the operation.
//
-// bulk insert | O(n+m + m*log(m))
+// bulk insert | O(m*log(m) + m*log(n) + n+m) (sort input, check dups, merge)
// insert | O(n)
// erase | O(n)
// bulk erase | O(n*m) TODO: Make faster - O(n+m + log(m))
diff --git a/src/starboard/doc/api_process.md b/src/starboard/doc/api_process.md
new file mode 100644
index 0000000..5e6e6e2
--- /dev/null
+++ b/src/starboard/doc/api_process.md
@@ -0,0 +1,68 @@
+# Starboard API Review Process
+
+## Why do we need a process?
+The Starboard API is the contract between Starboard applications and
+implementors of the Starboard API. Changing existing APIs and adding new
+required APIs breaks that contract and increases the cost of implementors
+keeping their Starboard port up-to-date. Pushing a release to the Open Source
+repository signals to Starboard implementors that any non-experimental APIs in
+that version will not change for as long as that version of Starboard is
+supported by the Starboard applications. We cannot change those newly frozen
+APIs without causing a potentially significant disruption to any partners who
+have already implemented them, or are in the process of implementing them.
+
+While having a process may make it harder to add new things to Starboard, it is
+much harder to remove or change things that are already there.
+
+Thus we need to give special focus to changes to the Starboard API to ensure its
+consistency with existing APIs design principles. Unnecessary churn on the
+Starboard API creates more work for Starboard application developers and may
+discourage porters from keeping Starboard applications up-to-date on their
+platforms. This process is intended to save time and effort for both Starboard
+application developers and Starboard implementors in the long run, and
+illustrates the complexity of dealing with a wide variety of platforms
+simultaneously.
+
+## So you want to add a new API?
+Historically, we have done API review as a part of the Code Review process using
+Gerrit. This works well for small-ish changes. For larger changes, consider
+writing a design document up front before defining the new API.
+
+### Who does the review?
+Send a message to the public cobalt-dev group to request a review.
+
+### What is the process?
+Developers are strongly encouraged to create the interface and upload that to
+Gerrit for review before spending time on stubs and tests. Iteration on the
+interface will necessarily result in changes to the stubs and tests, which can
+result in more work for the implementer of a new API.
+
+1. Upload a .h file with Module Overview and (optionally) initial function
+ prototypes
+ * New APIs should be declared in the experimental version, as described in the
+ starboard versioning doc.
+2. Discuss the new API with whoever is performing the review, and address
+ comments.
+3. Iterate.
+ * As a part of the review process, the reviewer will work with you to ensure
+ that the new API adheres to the starboard principles.
+4. Finalize function declarations.
+5. Implement tests and stubs.
+ * Existing platforms on trunk should not break as a result of this change.
+ * At this point, you may submit the interface, tests, and stubs with your
+ reviewer’s +2.
+6. Implement the interface for at least one platform.
+7. Iterate
+8. It may be that implementation of the API reveals things that were overlooked
+ during the earlier stages of the review.
+
+Ideally most major points of feedback will be caught early in the review process
+before much time has been spent on implementation.
+In the case that the platform in (6) is an internal platform, provide a
+reference implementation for at least one external reference platform. This can
+be in a follow-up CL, but must be implemented before the new API is frozen
+(see [versioning.md](versioning.md)).
+
+## How to design a new API
+See [principles.md](principles.md) for a guide on how to design a good Starboard
+API.
diff --git a/src/starboard/doc/versioning.md b/src/starboard/doc/versioning.md
new file mode 100644
index 0000000..3e18903
--- /dev/null
+++ b/src/starboard/doc/versioning.md
@@ -0,0 +1,135 @@
+# Starboard Versioning
+
+## Motivation
+When a porter implements Starboard for a platform, it is more precise to say
+that they have implemented support for a certain version of Starboard.
+Changes to the Starboard API are associated with Starboard versions. Any usage
+of new Starboard APIs must also be protected by a compile-time check for the
+Starboard version it belongs to. This decoupling of Cobalt and Starboard
+versions ensures that a porter can update to a newer version of Cobalt, but not
+be required to implement new Starboard APIs, if the version of Starboard they
+have implemented is still supported.
+
+## Starboard API version vs. Starboard application version
+The Starboard version describes the set of Starboard APIs available to Starboard
+applications. It will be incremented with every open-source release that
+includes changes to the Starboard API. Reasons to increment the Starboard API
+version include:
+
+* New Starboard APIs
+* Removed Starboard APIs
+* Modified semantics to existing APIs
+
+Some notable cases that do not justify incrementing the Starboard version
+include:
+
+* More descriptive or clearer comments for existing APIs that do not change the
+ semantics
+* New utility classes that are built on top of Starboard APIs, such as
+ `starboard::ScopedFile`
+* Changes that affect the upward API to Starboard applications, but not the
+ downward API to porters. For example, defining new upward APIs in terms of
+ existing Starboard APIs.
+
+A particular Starboard application may be versioned independently of the
+Starboard API. A given version of a Starboard application may support a range of
+Starboard versions. It may be the case that some new functionality in a
+Starboard application requires Starboard APIs that were added to a particular
+API version. If a porter wants to use such a feature, they must therefore also
+implement the required version of the Starboard API. For example, Voice Search
+was added to Cobalt version 5 and requires the SbMicrophone APIs which were
+added to Starboard version 2. Platforms that implemented Starboard version 1
+continued to build and run Cobalt 5 correctly, but the Voice Search feature
+would be unavailable.
+
+## Range of supported Starboard versions
+The minimum supported API version is defined by the `SB_MINIMUM_API_VERSION`
+macro, which is defined in starboard/configuration.h. Likewise, the
+`SB_MAXIMUM_API_VERSION` macro defines the maximum supported API version. All
+platforms must declare a `SB_API_VERSION` macro in the platform’s
+configuration.h to declare the starboard version the platform has implemented.
+Declaring implementation for an API version outside this range will result in an
+error at compilation time.
+Generally Starboard applications will not support all versions of the Starboard
+API indefinitely. Starboard application owners may increment the minimum
+required Starboard version at their discretion.
+TBD: Timelines and communication around when an upcoming Cobalt release will
+require porters to implement a newer version of Starboard.
+
+## Using new Starboard APIs from Starboard Applications
+Usage of a Starboard API that is not available in all supported Starboard API
+versions must be guarded with a check for `SB_API_VERSION`. Starboard
+applications must continue to function correctly and must not disable existing
+functionality if this check evaluates to false, but it’s acceptable to disable
+new functionality in Starboard applications if this evaluates to false.
+
+## Adding and using new Starboard APIs
+### “experimental” Starboard version
+At any given time, exactly one version of Starboard will be denoted as the
+“experimental” version, as defined by the `SB_EXPERIMENTAL_API_VERSION` macro in
+starboard/configuration.h. It is generally not recommended to declare support
+for this version. Any Starboard APIs defined in the experimental version are
+subject to change and API requirements could be added, removed, or changed at
+any time.
+### “frozen” Starboard versions
+All Starboard versions that are less than the experimental version are
+considered frozen. Any Starboard APIs in a frozen version shall not change as
+long as that version is supported by Cobalt.
+### Life of a Starboard API
+New Starboard APIs should be defined in the experimental version. In practice,
+they should be declared as follows:
+
+```
+// starboard/new_functionality.h
+#if SB_API_VERSION >= SB_EXPERIMENTAL_API_VERSION
+void SbNewFunctionality();
+#endif
+```
+
+Starboard application features that use a new API must have a similar check:
+
+```
+// cobalt/new_feature.cc
+#if SB_API_VERSION >= SB_EXPERIMENTAL_API_VERSION
+void DoSomethingCool() {
+ SbNewFunctionality();
+}
+#endif
+```
+
+When a new version of a Starboard Application that requires new Starboard APIs
+is to be released, these new Starboard APIs will be frozen to the value of the
+current experimental version, and the experimental version will be incremented
+by one.
+
+```
+// starboard/new_functionality.h
+#if SB_API_VERSION >= 7
+void SbNewFunctionality();
+#endif
+
+// starboard/other_new_functionality.h
+#if SB_API_VERSION >= SB_EXPERIMENTAL_API_VERSION
+void SbStillInDevelopment();
+#endif
+
+// starboard/configuration.h
+#define SB_EXPERIMENTAL_API_VERSION 8
+
+// cobalt/new_feature.cc
+#if SB_API_VERSION >= 7
+void DoSomethingCool() {
+ SbNewFunctionality();
+}
+#endif
+```
+
+A developer who increments the experimental version must ensure that stubs and
+reference platforms declare support for the new experimental version through
+their respective `SB_API_VERSION` macros.
+
+## Open questions
+### Communicating Starboard API changes to porters
+When a new version of Starboard is released, there should be a process to
+describe the changes to the API, which Cobalt features depend on these, and a
+timeline for when porters will be required to move to the new version.
diff --git a/src/starboard/event.h b/src/starboard/event.h
index 44cdd79..f7d9a68 100644
--- a/src/starboard/event.h
+++ b/src/starboard/event.h
@@ -151,6 +151,13 @@
// callback directly, so SbEventHandle should never receive this event
// directly. The data type is an internally-defined structure.
kSbEventTypeScheduled,
+
+#if SB_API_VERSION >= SB_EXPERIMENTAL_API_VERSION
+ // The platform's accessibility settings have changed. The application should
+ // query the accessibility settings using the appropriate APIs to get the
+ // new settings.
+ kSbEventTypeAccessiblitySettingsChanged,
+#endif
} SbEventType;
// Structure representing a Starboard event and its data.
diff --git a/src/starboard/linux/x64directfb/future/starboard_platform.gyp b/src/starboard/linux/x64directfb/future/starboard_platform.gyp
index 189aaf1..dd6f502 100644
--- a/src/starboard/linux/x64directfb/future/starboard_platform.gyp
+++ b/src/starboard/linux/x64directfb/future/starboard_platform.gyp
@@ -18,6 +18,7 @@
'product_name': 'starboard_platform_future',
'type': 'static_library',
'sources': [
+ '<(DEPTH)/starboard/shared/stub/accessibility_get_text_to_speech_settings.cc',
'<(DEPTH)/starboard/shared/stub/decode_target_create_blitter.cc',
'<(DEPTH)/starboard/shared/stub/decode_target_destroy.cc',
'<(DEPTH)/starboard/shared/stub/decode_target_get_format.cc',
diff --git a/src/starboard/linux/x64x11/atomic_public.h b/src/starboard/linux/x64x11/atomic_public.h
index 169cb89..7845b02 100644
--- a/src/starboard/linux/x64x11/atomic_public.h
+++ b/src/starboard/linux/x64x11/atomic_public.h
@@ -14,4 +14,9 @@
* limitations under the License.
*/
+#ifndef STARBOARD_LINUX_X64X11_ATOMIC_PUBLIC_H_
+#define STARBOARD_LINUX_X64X11_ATOMIC_PUBLIC_H_
+
#include "starboard/linux/shared/atomic_public.h"
+
+#endif // STARBOARD_LINUX_X64X11_ATOMIC_PUBLIC_H_
diff --git a/src/starboard/linux/x64x11/future/starboard_platform.gyp b/src/starboard/linux/x64x11/future/starboard_platform.gyp
index 6435941..3c1ac11 100644
--- a/src/starboard/linux/x64x11/future/starboard_platform.gyp
+++ b/src/starboard/linux/x64x11/future/starboard_platform.gyp
@@ -22,6 +22,7 @@
'type': 'static_library',
'sources': [
'<@(starboard_platform_sources)',
+ '<(DEPTH)/starboard/shared/stub/accessibility_get_text_to_speech_settings.cc',
'<(DEPTH)/starboard/shared/stub/decode_target_create_egl.cc',
'<(DEPTH)/starboard/shared/stub/decode_target_destroy.cc',
'<(DEPTH)/starboard/shared/stub/decode_target_get_format.cc',
diff --git a/src/starboard/linux/x64x11/thread_types_public.h b/src/starboard/linux/x64x11/thread_types_public.h
index 6548e00..716c697 100644
--- a/src/starboard/linux/x64x11/thread_types_public.h
+++ b/src/starboard/linux/x64x11/thread_types_public.h
@@ -14,4 +14,9 @@
* limitations under the License.
*/
+#ifndef STARBOARD_LINUX_X64X11_THREAD_TYPES_PUBLIC_H_
+#define STARBOARD_LINUX_X64X11_THREAD_TYPES_PUBLIC_H_
+
#include "starboard/linux/shared/thread_types_public.h"
+
+#endif // STARBOARD_LINUX_X64X11_THREAD_TYPES_PUBLIC_H_
diff --git a/src/starboard/memory.h b/src/starboard/memory.h
index 7181541..1a7d3e9 100644
--- a/src/starboard/memory.h
+++ b/src/starboard/memory.h
@@ -292,6 +292,16 @@
return result;
}
+// Returns true if the first |count| bytes of |buffer| are set to zero.
+static SB_C_INLINE bool SbMemoryIsZero(const void* buffer, size_t count) {
+ if (count == 0) {
+ return true;
+ }
+ const char* char_buffer = (const char*)(buffer);
+ return char_buffer[0] == 0 &&
+ SbMemoryCompare(char_buffer, char_buffer + 1, count - 1) == 0;
+}
+
/////////////////////////////////////////////////////////////////
// Deprecated. Do not use.
/////////////////////////////////////////////////////////////////
diff --git a/src/starboard/nplb/accessibility_get_setting_test.cc b/src/starboard/nplb/accessibility_get_setting_test.cc
new file mode 100644
index 0000000..ab182f7
--- /dev/null
+++ b/src/starboard/nplb/accessibility_get_setting_test.cc
@@ -0,0 +1,42 @@
+// Copyright 2017 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.
+
+#include "starboard/accessibility.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace starboard {
+namespace nplb {
+namespace {
+
+#if SB_API_VERSION >= SB_EXPERIMENTAL_API_VERSION
+
+TEST(SbAccessibilityGetSettingTest, CanCallGetTextToSpeechSettings) {
+ SbAccessibilityTextToSpeechSettings settings = {0};
+ EXPECT_TRUE(SbAccessibilityGetTextToSpeechSettings(&settings));
+}
+
+TEST(SbAccessibilityGetSettingTest, CallTextToSpeechWithInvalidArgument) {
+ // |settings| should be zero-initialized.
+ SbAccessibilityTextToSpeechSettings settings = {1};
+ EXPECT_FALSE(SbAccessibilityGetTextToSpeechSettings(&settings));
+
+ // Argument should not be NULL.
+ EXPECT_FALSE(SbAccessibilityGetTextToSpeechSettings(NULL));
+}
+
+#endif
+
+} // namespace
+} // namespace nplb
+} // namespace starboard
diff --git a/src/starboard/nplb/include_all.c b/src/starboard/nplb/include_all.c
index e55a271..69ce553 100644
--- a/src/starboard/nplb/include_all.c
+++ b/src/starboard/nplb/include_all.c
@@ -14,6 +14,7 @@
// Includes all headers in a C context to make sure they compile as C files.
+#include "starboard/accessibility.h"
#include "starboard/atomic.h"
#include "starboard/audio_sink.h"
#include "starboard/blitter.h"
diff --git a/src/starboard/nplb/memory_is_zero_test.cc b/src/starboard/nplb/memory_is_zero_test.cc
new file mode 100644
index 0000000..5529071
--- /dev/null
+++ b/src/starboard/nplb/memory_is_zero_test.cc
@@ -0,0 +1,52 @@
+// Copyright 2017 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.
+
+#include "starboard/memory.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace starboard {
+namespace nplb {
+namespace {
+
+const size_t kSize = 128;
+
+TEST(SbMemoryIsZeroTest, MemoryIsZero) {
+ int8_t buffer[kSize] = {0};
+
+ EXPECT_TRUE(SbMemoryIsZero(&buffer, sizeof(buffer)));
+}
+
+TEST(SbMemoryIsZeroTest, MemoryIsNonZero) {
+ int8_t buffer[kSize] = {0};
+ buffer[kSize - 1] = 1;
+
+ EXPECT_FALSE(SbMemoryIsZero(&buffer, sizeof(buffer)));
+ EXPECT_TRUE(SbMemoryIsZero(&buffer, sizeof(buffer) - 1));
+}
+
+TEST(SbMemoryIsZeroTest, EmptyBufferIsZero) {
+ EXPECT_TRUE(SbMemoryIsZero(NULL, 0));
+}
+
+TEST(SbMemoryIsZeroTest, SingleByte) {
+ int8_t zero = 0;
+ int8_t non_zero = 1;
+
+ EXPECT_TRUE(SbMemoryIsZero(&zero, 1));
+ EXPECT_FALSE(SbMemoryIsZero(&non_zero, 1));
+}
+
+} // namespace
+} // namespace nplb
+} // namespace starboard
diff --git a/src/starboard/nplb/nplb.gyp b/src/starboard/nplb/nplb.gyp
index 2bf9cb6..fd578f0 100644
--- a/src/starboard/nplb/nplb.gyp
+++ b/src/starboard/nplb/nplb.gyp
@@ -22,6 +22,7 @@
'type': '<(gtest_target_type)',
'sources': [
'<(DEPTH)/starboard/common/test_main.cc',
+ 'accessibility_get_setting_test.cc',
'atomic_test.cc',
'audio_sink_create_test.cc',
'audio_sink_destroy_test.cc',
@@ -117,10 +118,11 @@
'memory_allocate_test.cc',
'memory_compare_test.cc',
'memory_copy_test.cc',
- 'memory_find_byte_test.cc',
'memory_deallocate_aligned_test.cc',
'memory_deallocate_test.cc',
'memory_get_stack_bounds_test.cc',
+ 'memory_is_zero_test.cc',
+ 'memory_find_byte_test.cc',
'memory_map_test.cc',
'memory_move_test.cc',
'memory_reallocate_test.cc',
diff --git a/src/starboard/raspi/shared/starboard_platform.gypi b/src/starboard/raspi/shared/starboard_platform.gypi
index a096687..9fcbc9f 100644
--- a/src/starboard/raspi/shared/starboard_platform.gypi
+++ b/src/starboard/raspi/shared/starboard_platform.gypi
@@ -302,6 +302,7 @@
'<(DEPTH)/starboard/shared/starboard/system_get_random_uint64.cc',
'<(DEPTH)/starboard/shared/starboard/system_request_stop.cc',
'<(DEPTH)/starboard/shared/starboard/window_set_default_options.cc',
+ '<(DEPTH)/starboard/shared/stub/accessibility_get_text_to_speech_settings.cc',
'<(DEPTH)/starboard/shared/stub/drm_close_session.cc',
'<(DEPTH)/starboard/shared/stub/drm_create_system.cc',
'<(DEPTH)/starboard/shared/stub/drm_destroy_system.cc',
diff --git a/src/starboard/shared/starboard/player/player_worker.cc b/src/starboard/shared/starboard/player/player_worker.cc
index 61155d6..63fb43d 100644
--- a/src/starboard/shared/starboard/player/player_worker.cc
+++ b/src/starboard/shared/starboard/player/player_worker.cc
@@ -96,12 +96,13 @@
void* PlayerWorker::ThreadEntryPoint(void* context) {
ThreadParam* param = static_cast<ThreadParam*>(context);
SB_DCHECK(param != NULL);
+ PlayerWorker* player_worker = param->player_worker;
{
ScopedLock scoped_lock(param->mutex);
- param->player_worker->job_queue_.reset(new JobQueue);
+ player_worker->job_queue_.reset(new JobQueue);
param->condition_variable.Signal();
}
- param->player_worker->RunLoop();
+ player_worker->RunLoop();
return NULL;
}
diff --git a/src/starboard/shared/stub/accessibility_get_text_to_speech_settings.cc b/src/starboard/shared/stub/accessibility_get_text_to_speech_settings.cc
new file mode 100644
index 0000000..6a2d326
--- /dev/null
+++ b/src/starboard/shared/stub/accessibility_get_text_to_speech_settings.cc
@@ -0,0 +1,27 @@
+// Copyright 2017 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.
+
+#include "starboard/accessibility.h"
+
+#include "starboard/memory.h"
+
+bool SbAccessibilityGetTextToSpeechSettings(
+ SbAccessibilityTextToSpeechSettings* out_setting) {
+ if (!out_setting ||
+ !SbMemoryIsZero(out_setting,
+ sizeof(SbAccessibilityTextToSpeechSettings))) {
+ return false;
+ }
+ return true;
+}
diff --git a/src/starboard/stub/starboard_platform.gyp b/src/starboard/stub/starboard_platform.gyp
index ff61a20..b228978 100644
--- a/src/starboard/stub/starboard_platform.gyp
+++ b/src/starboard/stub/starboard_platform.gyp
@@ -25,6 +25,7 @@
'<(DEPTH)/starboard/shared/starboard/file_mode_string_to_flags.cc',
'<(DEPTH)/starboard/shared/starboard/log_message.cc',
'<(DEPTH)/starboard/shared/starboard/queue_application.cc',
+ '<(DEPTH)/starboard/shared/stub/accessibility_get_text_to_speech_settings.cc',
'<(DEPTH)/starboard/shared/stub/atomic_public.h',
'<(DEPTH)/starboard/shared/stub/audio_sink_create.cc',
'<(DEPTH)/starboard/shared/stub/audio_sink_destroy.cc',
diff --git a/src/starboard/system.h b/src/starboard/system.h
index 2d5a1a2..8532ad8 100644
--- a/src/starboard/system.h
+++ b/src/starboard/system.h
@@ -129,6 +129,11 @@
// Desktop PC.
kSbSystemDeviceTypeDesktopPC,
+#if SB_API_VERSION >= SB_EXPERIMENTAL_API_VERSION
+ // An Android TV Device.
+ kSbSystemDeviceTypeAndroidTV,
+#endif // SB_API_VERSION >= SB_EXPERIMENTAL_API_VERSION
+
// Unknown device.
kSbSystemDeviceTypeUnknown,
} SbSystemDeviceType;
diff --git a/src/third_party/libwebp/libwebp.gyp b/src/third_party/libwebp/libwebp.gyp
index 947ed92..59deb74 100644
--- a/src/third_party/libwebp/libwebp.gyp
+++ b/src/third_party/libwebp/libwebp.gyp
@@ -80,6 +80,10 @@
},{ # "target_arch != "arm" or arm_version < 7"
'type': 'none',
}],
+ ['target_arch == "arm" and arm_version >= 8 and clang == 1', {
+ # NEON is implicit on ARMv8, and clang doesn't like the redundant flag
+ 'cflags!': [ '-mfpu=neon' ],
+ }],
['order_profiling != 0', {
'target_conditions' : [
['_toolset=="target"', {
diff --git a/src/third_party/mozjs/js/src/vm/NumericConversions.h b/src/third_party/mozjs/js/src/vm/NumericConversions.h
index 61511a0..94cddae 100644
--- a/src/third_party/mozjs/js/src/vm/NumericConversions.h
+++ b/src/third_party/mozjs/js/src/vm/NumericConversions.h
@@ -132,7 +132,11 @@
inline int32_t
ToInt32(double d)
{
-#if defined (__arm__) && defined (__GNUC__)
+#if defined(__ANDROID__) && defined(__clang__) && \
+ __clang_major__ == 3 && __clang_minor__ == 8
+#define ANDROID_CLANG38 1
+#endif
+#if defined (__arm__) && defined (__GNUC__) && !defined(ANDROID_CLANG38)
int32_t i;
uint32_t tmp0;
uint32_t tmp1;
@@ -256,6 +260,7 @@
#else
return detail::ToIntWidth<int32_t>(d);
#endif
+#undef ANDROID_CLANG38
}
/* ES5 9.6 (specialized for doubles). */
diff --git a/src/third_party/mozjs/mfbt/double-conversion/utils.h b/src/third_party/mozjs/mfbt/double-conversion/utils.h
index 0eec2d9..52fe028 100644
--- a/src/third_party/mozjs/mfbt/double-conversion/utils.h
+++ b/src/third_party/mozjs/mfbt/double-conversion/utils.h
@@ -53,7 +53,7 @@
// disabled.)
// On Linux,x86 89255e-22 != Div_double(89255.0/1e22)
#if defined(_M_X64) || defined(__x86_64__) || \
- defined(__ARMEL__) || defined(__avr32__) || \
+ defined(__ARMEL__) || defined(__avr32__) || defined(__aarch64__) || \
defined(__hppa__) || defined(__ia64__) || \
defined(__mips__) || defined(__powerpc__) || \
defined(__sparc__) || defined(__sparc) || defined(__s390__) || \
diff --git a/src/third_party/openssl/openssl.gyp b/src/third_party/openssl/openssl.gyp
index 484a49e..27a29c3 100644
--- a/src/third_party/openssl/openssl.gyp
+++ b/src/third_party/openssl/openssl.gyp
@@ -593,61 +593,71 @@
'openssl_config_path': 'config/android',
},
}],
- ['target_arch == "arm"', {
- 'sources!': [
- # Use assembly version of this source file for ARM.
- 'openssl/crypto/aes/aes_core.c',
+ ['OS=="lb_shell" or OS=="starboard"', {
+ # Don't use assembly in steel or starboard.
+ # TODO: Investigate whether assembly helps low-profile devices.
+ 'defines': [
+ 'OPENSSL_NO_ASM',
],
- 'sources': [
- 'openssl/crypto/aes/asm/aes-armv4.S',
- 'openssl/crypto/bn/asm/armv4-gf2m.S',
- 'openssl/crypto/bn/asm/armv4-mont.S',
- 'openssl/crypto/modes/asm/ghash-armv4.S',
- 'openssl/crypto/sha/asm/sha1-armv4-large.S',
- 'openssl/crypto/sha/asm/sha256-armv4.S',
- 'openssl/crypto/sha/asm/sha512-armv4.S',
- ],
- }],
- ['target_arch == "ia32"', {
- 'sources!': [
- # Use assembly version of this source file for ARM.
- 'openssl/crypto/aes/aes_core.c',
- 'openssl/crypto/aes/aes_cbc.c',
- 'openssl/crypto/des/des_enc.c',
- 'openssl/crypto/des/fcrypt_b.c',
- 'openssl/crypto/bf/bf_enc.c',
- 'openssl/crypto/bn/bn_asm.c',
- ],
- 'sources': [
- 'openssl/crypto/aes/asm/aes-586.S',
- 'openssl/crypto/aes/asm/aesni-x86.S',
- 'openssl/crypto/aes/asm/vpaes-x86.S',
- 'openssl/crypto/bf/asm/bf-586.S',
- 'openssl/crypto/bn/asm/bn-586.S',
- 'openssl/crypto/bn/asm/co-586.S',
- 'openssl/crypto/bn/asm/x86-gf2m.S',
- 'openssl/crypto/bn/asm/x86-mont.S',
- 'openssl/crypto/des/asm/crypt586.S',
- 'openssl/crypto/des/asm/des-586.S',
- 'openssl/crypto/md5/asm/md5-586.S',
- 'openssl/crypto/modes/asm/ghash-x86.S',
- 'openssl/crypto/sha/asm/sha1-586.S',
- 'openssl/crypto/sha/asm/sha256-586.S',
- 'openssl/crypto/sha/asm/sha512-586.S',
- ],
- }],
- ['target_arch=="mips"', {
- 'sources!': [
- # Use assembly version of these source files for MIPS.
- 'openssl/crypto/bn/bn_asm.c',
- 'openssl/crypto/aes/aes_core.c',
- ],
- 'sources': [
- 'openssl/crypto/aes/asm/aes-mips.S',
- 'openssl/crypto/bn/asm/bn-mips.S',
- 'openssl/crypto/bn/asm/mips-mont.S',
- 'openssl/crypto/sha/asm/sha1-mips.S',
- 'openssl/crypto/sha/asm/sha256-mips.S',
+ }, { # Not steel or starboard, use assembly
+ 'conditions': [
+ ['target_arch == "arm"', {
+ 'sources!': [
+ # Use assembly version of this source file for ARM.
+ 'openssl/crypto/aes/aes_core.c',
+ ],
+ 'sources': [
+ 'openssl/crypto/aes/asm/aes-armv4.S',
+ 'openssl/crypto/bn/asm/armv4-gf2m.S',
+ 'openssl/crypto/bn/asm/armv4-mont.S',
+ 'openssl/crypto/modes/asm/ghash-armv4.S',
+ 'openssl/crypto/sha/asm/sha1-armv4-large.S',
+ 'openssl/crypto/sha/asm/sha256-armv4.S',
+ 'openssl/crypto/sha/asm/sha512-armv4.S',
+ ],
+ }],
+ ['target_arch == "ia32"', {
+ 'sources!': [
+ # Use assembly version of these source files for IA32.
+ 'openssl/crypto/aes/aes_core.c',
+ 'openssl/crypto/aes/aes_cbc.c',
+ 'openssl/crypto/des/des_enc.c',
+ 'openssl/crypto/des/fcrypt_b.c',
+ 'openssl/crypto/bf/bf_enc.c',
+ 'openssl/crypto/bn/bn_asm.c',
+ ],
+ 'sources': [
+ 'openssl/crypto/aes/asm/aes-586.S',
+ 'openssl/crypto/aes/asm/aesni-x86.S',
+ 'openssl/crypto/aes/asm/vpaes-x86.S',
+ 'openssl/crypto/bf/asm/bf-586.S',
+ 'openssl/crypto/bn/asm/bn-586.S',
+ 'openssl/crypto/bn/asm/co-586.S',
+ 'openssl/crypto/bn/asm/x86-gf2m.S',
+ 'openssl/crypto/bn/asm/x86-mont.S',
+ 'openssl/crypto/des/asm/crypt586.S',
+ 'openssl/crypto/des/asm/des-586.S',
+ 'openssl/crypto/md5/asm/md5-586.S',
+ 'openssl/crypto/modes/asm/ghash-x86.S',
+ 'openssl/crypto/sha/asm/sha1-586.S',
+ 'openssl/crypto/sha/asm/sha256-586.S',
+ 'openssl/crypto/sha/asm/sha512-586.S',
+ ],
+ }],
+ ['target_arch=="mips"', {
+ 'sources!': [
+ # Use assembly version of these source files for MIPS.
+ 'openssl/crypto/bn/bn_asm.c',
+ 'openssl/crypto/aes/aes_core.c',
+ ],
+ 'sources': [
+ 'openssl/crypto/aes/asm/aes-mips.S',
+ 'openssl/crypto/bn/asm/bn-mips.S',
+ 'openssl/crypto/bn/asm/mips-mont.S',
+ 'openssl/crypto/sha/asm/sha1-mips.S',
+ 'openssl/crypto/sha/asm/sha256-mips.S',
+ ],
+ }],
],
}],
['clang==1', {
@@ -683,7 +693,6 @@
'NO_SYS_UN_H',
'NO_SYSLOG',
'NO_WINDOWS_BRAINDEATH',
- 'OPENSSL_NO_ASM',
'OPENSSL_NO_BF',
'OPENSSL_NO_BUF_FREELISTS',
'OPENSSL_NO_CAMELLIA',
diff --git a/src/third_party/openssl/openssl/crypto/bn/asm/armv4-gf2m.S b/src/third_party/openssl/openssl/crypto/bn/asm/armv4-gf2m.S
index 038f086..4cb7b99 100644
--- a/src/third_party/openssl/openssl/crypto/bn/asm/armv4-gf2m.S
+++ b/src/third_party/openssl/openssl/crypto/bn/asm/armv4-gf2m.S
@@ -121,7 +121,7 @@
beq .Lialu
veor d18,d18
- vmov.32 d19,r3,r3 @ two copies of b1
+ vmov d19,r3,r3 @ two copies of b1
vmov.32 d18[0],r1 @ a1
veor d20,d20
diff --git a/src/third_party/openssl/openssl/crypto/modes/asm/ghash-armv4.S b/src/third_party/openssl/openssl/crypto/modes/asm/ghash-armv4.S
index d66c4cb..a32a2e8 100644
--- a/src/third_party/openssl/openssl/crypto/modes/asm/ghash-armv4.S
+++ b/src/third_party/openssl/openssl/crypto/modes/asm/ghash-armv4.S
@@ -3,6 +3,11 @@
.text
.code 32
+#ifdef __clang__
+#define ldrplb ldrbpl
+#define ldrneb ldrbne
+#endif
+
.type rem_4bit,%object
.align 5
rem_4bit:
diff --git a/src/third_party/promise-polyfill/CHANGELOG.md b/src/third_party/promise-polyfill/CHANGELOG.md
new file mode 100644
index 0000000..f9bf5b5
--- /dev/null
+++ b/src/third_party/promise-polyfill/CHANGELOG.md
@@ -0,0 +1,94 @@
+# Changelog
+
+## 6.0.0 Deprecated `Promise._setImmediateFn` and `Promise._setUnhandledRejectionFn`
+This allows subclassing Promise without rewriting functions
+- `Promise._setImmediateFn(<immediateFn>)` has been deprecated. Use `Promise._immediateFn = <immediateFn>` instead.
+- `Promise._setUnhandledRejectionFn(<rejectionFn>)` has been deprecated. Use `Promise._unhandledRejectionFn = <rejectionFn>` instead.
+These functions will be removed in the next major version.
+
+### 5.2.1 setTimeout to 0
+Fixed bug where setTimeout was set to 1 instead of 0 for async execution
+
+### 5.2.0 Subclassing
+Allowed Subclassing. [#27](https://github.com/taylorhakes/promise-polyfill/pull/27)
+
+### 5.1.0 Fixed reliance on setTimeout
+Changed possibly unhanded warnings to use asap function instead of setTimeout
+
+## 5.0.0 Removed multiple params from Promise.all
+Removed non standard functionality of passing multiple params to Promise.all. You must pass an array now. You must change this code
+```js
+Promise.all(prom1, prom2, prom3);
+```
+to this
+```js
+Promise.all([prom1, prom2, prom3]);
+```
+
+### 4.0.4 IE8 console.warn fix
+IE8 does not have console, unless you open the developer tools. This fix checks to makes sure console.warn is defined before calling it.
+
+### 4.0.3 Fix case in bower.json
+bower.json had Promise.js instead of promise.js
+
+### 4.0.2 promise.js case fix in package.json
+Fixed promise.js in package.json. It was accidently published as Promise.js
+
+## 4.0.1 Unhandled Rejections and Other Fixes
+- Added unhandled rejection warnings to the console
+- Removed Grunt, jasmine and other unused code
+- Renamed Promise.js to lowercase promise.js in multiple places
+
+### 3.0.1 Fixed shadowing issue on setTimeout
+New version fixing this major bug https://github.com/taylorhakes/promise-polyfill/pull/17
+
+## 3.0.0 Updated setTimeout to not be affected by test mocks
+This is considered a breaking change because people may have been using this functionality. If you would like to keep version 2 functionality, set Promise._setImmediateFn on `promise-polyfill` like the code below.
+
+```js
+var Promise = require('promise-polyfill');
+Promise._setImmedateFn(function(fn) {
+ setTimeout(fn, 1);
+});
+```
+
+### 2.1.0 Promise._setImmedateFn
+Removed dead code Promise.immedateFn and added Promise._setImmediateFn(fn);
+
+### 2.0.2 Simplified Global detection
+Simplified attaching to global object
+
+### 2.0.1 Webworker bugfixes
+Fixed Webworkers missing window object
+
+## 2.0.0
+**Changed the following line**
+```
+module.exports = root.Promise ? root.Promise : Promise;
+```
+to
+```
+module.exports = Promise;
+```
+
+This means the library will not use built-in Promise by default. This allows for more consistency.
+
+You can easily add the functionality back.
+```
+var Promise = window.Promise || require('promise-polyfill');
+```
+
+**Added Promise.immediateFn to allow changing the setImmedate function**
+```
+Promise.immediateFn = window.setAsap;
+```
+
+### 1.1.4 Updated Promise to use correct global object in Browser and Node
+
+### 1.1.3 Fixed browserify issue with `this`
+
+### 1.1.2 Updated Promise.resolve to resolve with original Promise
+
+### 1.1.0 Performance Improvements for Modern Browsers
+
+## 1.0.1 Update README.md
diff --git a/src/third_party/promise-polyfill/LICENSE b/src/third_party/promise-polyfill/LICENSE
new file mode 100644
index 0000000..94b9dac
--- /dev/null
+++ b/src/third_party/promise-polyfill/LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2014 Taylor Hakes
+Copyright (c) 2014 Forbes Lindesay
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
\ No newline at end of file
diff --git a/src/third_party/promise-polyfill/README.cobalt b/src/third_party/promise-polyfill/README.cobalt
new file mode 100644
index 0000000..2048a76
--- /dev/null
+++ b/src/third_party/promise-polyfill/README.cobalt
@@ -0,0 +1,15 @@
+Name: promise-polyfill
+Short Name: promise-polyfill
+URL: https://github.com/taylorhakes/promise-polyfill
+Version: 6.0.2
+Date: Nov 24, 2016
+License: MIT
+License File: LICENSE
+Security Critical: yes
+
+Description:
+A pure-ES5 implementation of ES6 Promises.
+
+Local Modifications:
+Deleted unnecessary files.
+Modified to be slightly more tolerant of setTimeout missing.
\ No newline at end of file
diff --git a/src/third_party/promise-polyfill/README.md b/src/third_party/promise-polyfill/README.md
new file mode 100644
index 0000000..a60d646
--- /dev/null
+++ b/src/third_party/promise-polyfill/README.md
@@ -0,0 +1,96 @@
+<a href="http://promises-aplus.github.com/promises-spec">
+ <img src="http://promises-aplus.github.com/promises-spec/assets/logo-small.png"
+ align="right" alt="Promises/A+ logo" />
+</a>
+# Promise Polyfill
+[![travis][travis-image]][travis-url]
+
+[travis-image]: https://img.shields.io/travis/taylorhakes/promise-polyfill.svg?style=flat
+[travis-url]: https://travis-ci.org/taylorhakes/promise-polyfill
+
+
+Lightweight ES6 Promise polyfill for the browser and node. Adheres closely to the spec. It is a perfect polyfill IE, Firefox or any other browser that does not support native promises.
+
+For API information about Promises, please check out this article [HTML5Rocks article](http://www.html5rocks.com/en/tutorials/es6/promises/).
+
+It is extremely lightweight. ***< 1kb Gzipped***
+
+## Browser Support
+IE8+, Chrome, Firefox, IOS 4+, Safari 5+, Opera
+
+### NPM Use
+```
+npm install promise-polyfill --save-exact
+```
+### Bower Use
+```
+bower install promise-polyfill
+```
+
+## Downloads
+
+- [Promise](https://raw.github.com/taylorhakes/promise-polyfill/master/promise.js)
+- [Promise-min](https://raw.github.com/taylorhakes/promise-polyfill/master/promise.min.js)
+
+## Simple use
+```js
+import Promise from 'promise-polyfill';
+
+// To add to window
+if (!window.Promise) {
+ window.Promise = Promise;
+}
+```
+
+then you can use like normal Promises
+```js
+var prom = new Promise(function(resolve, reject) {
+ // do a thing, possibly async, then…
+
+ if (/* everything turned out fine */) {
+ resolve("Stuff worked!");
+ } else {
+ reject(new Error("It broke"));
+ }
+});
+
+prom.then(function(result) {
+ // Do something when async done
+});
+```
+
+## Deprecations
+- `Promise._setImmediateFn(<immediateFn>)` has been deprecated. Use `Promise._immediateFn = <immediateFn>;` instead.
+- `Promise._setUnhandledRejectionFn(<rejectionFn>)` has been deprecated. Use `Promise._unhandledRejectionFn = <rejectionFn>` instead.
+These functions will be removed in the next major version.
+
+## Performance
+By default promise-polyfill uses `setImmediate`, but falls back to `setTimeout` for executing asynchronously. If a browser does not support `setImmediate` (IE/Edge are the only browsers with setImmediate), you may see performance issues.
+Use a `setImmediate` polyfill to fix this issue. [setAsap](https://github.com/taylorhakes/setAsap) or [setImmediate](https://github.com/YuzuJS/setImmediate) work well.
+
+If you polyfill `window.setImmediate` or use `Promise._immediateFn = yourImmediateFn` it will be used instead of `window.setTimeout`
+```
+npm install setasap --save
+```
+```js
+var Promise = require('promise-polyfill');
+var setAsap = require('setasap');
+Promise._immediateFn = setAsap;
+```
+
+## Unhandled Rejections
+promise-polyfill will warn you about possibly unhandled rejections. It will show a console warning if a Promise is rejected, but no `.catch` is used. You can turn off this behavior by setting `Promise._setUnhandledRejectionFn(<rejectError>)`.
+If you would like to disable unhandled rejections. Use a noop like below.
+```js
+Promise._unhandledRejectionFn = function(rejectError) {};
+```
+
+
+## Testing
+```
+npm install
+npm test
+```
+
+## License
+MIT
diff --git a/src/third_party/promise-polyfill/promise.js b/src/third_party/promise-polyfill/promise.js
new file mode 100644
index 0000000..63aaa54
--- /dev/null
+++ b/src/third_party/promise-polyfill/promise.js
@@ -0,0 +1,233 @@
+(function (root) {
+
+ // Store setTimeout reference so promise-polyfill will be unaffected by
+ // other code modifying setTimeout (like sinon.useFakeTimers())
+ var setTimeoutFunc = root.setTimeout;
+
+ function noop() {}
+
+ // Polyfill for Function.prototype.bind
+ function bind(fn, thisArg) {
+ return function () {
+ fn.apply(thisArg, arguments);
+ };
+ }
+
+ function Promise(fn) {
+ if (typeof this !== 'object') throw new TypeError('Promises must be constructed via new');
+ if (typeof fn !== 'function') throw new TypeError('not a function');
+ this._state = 0;
+ this._handled = false;
+ this._value = undefined;
+ this._deferreds = [];
+
+ doResolve(fn, this);
+ }
+
+ function handle(self, deferred) {
+ while (self._state === 3) {
+ self = self._value;
+ }
+ if (self._state === 0) {
+ self._deferreds.push(deferred);
+ return;
+ }
+ self._handled = true;
+ Promise._immediateFn(function () {
+ var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;
+ if (cb === null) {
+ (self._state === 1 ? resolve : reject)(deferred.promise, self._value);
+ return;
+ }
+ var ret;
+ try {
+ ret = cb(self._value);
+ } catch (e) {
+ reject(deferred.promise, e);
+ return;
+ }
+ resolve(deferred.promise, ret);
+ });
+ }
+
+ function resolve(self, newValue) {
+ try {
+ // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure
+ if (newValue === self) throw new TypeError('A promise cannot be resolved with itself.');
+ if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) {
+ var then = newValue.then;
+ if (newValue instanceof Promise) {
+ self._state = 3;
+ self._value = newValue;
+ finale(self);
+ return;
+ } else if (typeof then === 'function') {
+ doResolve(bind(then, newValue), self);
+ return;
+ }
+ }
+ self._state = 1;
+ self._value = newValue;
+ finale(self);
+ } catch (e) {
+ reject(self, e);
+ }
+ }
+
+ function reject(self, newValue) {
+ self._state = 2;
+ self._value = newValue;
+ finale(self);
+ }
+
+ function finale(self) {
+ if (self._state === 2 && self._deferreds.length === 0) {
+ Promise._immediateFn(function() {
+ if (!self._handled) {
+ Promise._unhandledRejectionFn(self._value);
+ }
+ });
+ }
+
+ for (var i = 0, len = self._deferreds.length; i < len; i++) {
+ handle(self, self._deferreds[i]);
+ }
+ self._deferreds = null;
+ }
+
+ function Handler(onFulfilled, onRejected, promise) {
+ this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;
+ this.onRejected = typeof onRejected === 'function' ? onRejected : null;
+ this.promise = promise;
+ }
+
+ /**
+ * Take a potentially misbehaving resolver function and make sure
+ * onFulfilled and onRejected are only called once.
+ *
+ * Makes no guarantees about asynchrony.
+ */
+ function doResolve(fn, self) {
+ var done = false;
+ try {
+ fn(function (value) {
+ if (done) return;
+ done = true;
+ resolve(self, value);
+ }, function (reason) {
+ if (done) return;
+ done = true;
+ reject(self, reason);
+ });
+ } catch (ex) {
+ if (done) return;
+ done = true;
+ reject(self, ex);
+ }
+ }
+
+ Promise.prototype['catch'] = function (onRejected) {
+ return this.then(null, onRejected);
+ };
+
+ Promise.prototype.then = function (onFulfilled, onRejected) {
+ var prom = new (this.constructor)(noop);
+
+ handle(this, new Handler(onFulfilled, onRejected, prom));
+ return prom;
+ };
+
+ Promise.all = function (arr) {
+ var args = Array.prototype.slice.call(arr);
+
+ return new Promise(function (resolve, reject) {
+ if (args.length === 0) return resolve([]);
+ var remaining = args.length;
+
+ function res(i, val) {
+ try {
+ if (val && (typeof val === 'object' || typeof val === 'function')) {
+ var then = val.then;
+ if (typeof then === 'function') {
+ then.call(val, function (val) {
+ res(i, val);
+ }, reject);
+ return;
+ }
+ }
+ args[i] = val;
+ if (--remaining === 0) {
+ resolve(args);
+ }
+ } catch (ex) {
+ reject(ex);
+ }
+ }
+
+ for (var i = 0; i < args.length; i++) {
+ res(i, args[i]);
+ }
+ });
+ };
+
+ Promise.resolve = function (value) {
+ if (value && typeof value === 'object' && value.constructor === Promise) {
+ return value;
+ }
+
+ return new Promise(function (resolve) {
+ resolve(value);
+ });
+ };
+
+ Promise.reject = function (value) {
+ return new Promise(function (resolve, reject) {
+ reject(value);
+ });
+ };
+
+ Promise.race = function (values) {
+ return new Promise(function (resolve, reject) {
+ for (var i = 0, len = values.length; i < len; i++) {
+ values[i].then(resolve, reject);
+ }
+ });
+ };
+
+ // Use polyfill for setImmediate for performance gains
+ Promise._immediateFn = (typeof setImmediate === 'function' && function (fn) { setImmediate(fn); }) ||
+ function (fn) {
+ setTimeoutFunc(fn, 0);
+ };
+
+ Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) {
+ if (typeof console !== 'undefined' && console) {
+ console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console
+ }
+ };
+
+ /**
+ * Set the immediate function to execute callbacks
+ * @param fn {function} Function to execute
+ * @deprecated
+ */
+ Promise._setImmediateFn = function _setImmediateFn(fn) {
+ Promise._immediateFn = fn;
+ };
+
+ /**
+ * Change the function to execute on unhandled rejection
+ * @param {function} fn Function to execute on unhandled rejection
+ * @deprecated
+ */
+ Promise._setUnhandledRejectionFn = function _setUnhandledRejectionFn(fn) {
+ Promise._unhandledRejectionFn = fn;
+ };
+
+ if (typeof module !== 'undefined' && module.exports) {
+ module.exports = Promise;
+ } else if (!root.Promise) {
+ root.Promise = Promise;
+ }
+
+})(this);
diff --git a/src/third_party/promise-polyfill/promise.min.js b/src/third_party/promise-polyfill/promise.min.js
new file mode 100644
index 0000000..1ae225e
--- /dev/null
+++ b/src/third_party/promise-polyfill/promise.min.js
@@ -0,0 +1 @@
+!function(e){function n(){}function t(e,n){return function(){e.apply(n,arguments)}}function o(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],s(e,this)}function i(e,n){for(;3===e._state;)e=e._value;return 0===e._state?void e._deferreds.push(n):(e._handled=!0,void o._immediateFn(function(){var t=1===e._state?n.onFulfilled:n.onRejected;if(null===t)return void(1===e._state?r:u)(n.promise,e._value);var o;try{o=t(e._value)}catch(i){return void u(n.promise,i)}r(n.promise,o)}))}function r(e,n){try{if(n===e)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var i=n.then;if(n instanceof o)return e._state=3,e._value=n,void f(e);if("function"==typeof i)return void s(t(i,n),e)}e._state=1,e._value=n,f(e)}catch(r){u(e,r)}}function u(e,n){e._state=2,e._value=n,f(e)}function f(e){2===e._state&&0===e._deferreds.length&&o._immediateFn(function(){e._handled||o._unhandledRejectionFn(e._value)});for(var n=0,t=e._deferreds.length;n<t;n++)i(e,e._deferreds[n]);e._deferreds=null}function c(e,n,t){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.promise=t}function s(e,n){var t=!1;try{e(function(e){t||(t=!0,r(n,e))},function(e){t||(t=!0,u(n,e))})}catch(o){if(t)return;t=!0,u(n,o)}}var a=e.setTimeout;o.prototype["catch"]=function(e){return this.then(null,e)},o.prototype.then=function(e,t){var o=new this.constructor(n);return i(this,new c(e,t,o)),o},o.all=function(e){var n=Array.prototype.slice.call(e);return new o(function(e,t){function o(r,u){try{if(u&&("object"==typeof u||"function"==typeof u)){var f=u.then;if("function"==typeof f)return void f.call(u,function(e){o(r,e)},t)}n[r]=u,0===--i&&e(n)}catch(c){t(c)}}if(0===n.length)return e([]);for(var i=n.length,r=0;r<n.length;r++)o(r,n[r])})},o.resolve=function(e){return e&&"object"==typeof e&&e.constructor===o?e:new o(function(n){n(e)})},o.reject=function(e){return new o(function(n,t){t(e)})},o.race=function(e){return new o(function(n,t){for(var o=0,i=e.length;o<i;o++)e[o].then(n,t)})},o._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){a(e,0)},o._unhandledRejectionFn=function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)},o._setImmediateFn=function(e){o._immediateFn=e},o._setUnhandledRejectionFn=function(e){o._unhandledRejectionFn=e},"undefined"!=typeof module&&module.exports?module.exports=o:e.Promise||(e.Promise=o)}(this);
\ No newline at end of file
diff --git a/src/third_party/promise-polyfill/test/adapter.js b/src/third_party/promise-polyfill/test/adapter.js
new file mode 100644
index 0000000..ca85741
--- /dev/null
+++ b/src/third_party/promise-polyfill/test/adapter.js
@@ -0,0 +1,14 @@
+var Promise = require('../promise');
+module.exports = {
+ resolved: Promise.resolve,
+ rejected: Promise.rejected,
+ deferred: function() {
+ var obj = {};
+ var prom = new Promise(function(resolve, reject) {
+ obj.resolve = resolve;
+ obj.reject = reject;
+ });
+ obj.promise = prom;
+ return obj;
+ }
+};
diff --git a/src/third_party/promise-polyfill/test/promise.js b/src/third_party/promise-polyfill/test/promise.js
new file mode 100644
index 0000000..6d9fedc
--- /dev/null
+++ b/src/third_party/promise-polyfill/test/promise.js
@@ -0,0 +1,190 @@
+var Promise = require('../promise');
+var sinon = require('sinon');
+var assert = require('assert');
+var adapter = require('./adapter');
+describe("Promises/A+ Tests", function () {
+ require("promises-aplus-tests").mocha(adapter);
+});
+describe('Promise', function () {
+ describe('Promise._setImmediateFn', function () {
+ afterEach(function() {
+ Promise._setImmediateFn((typeof setImmediate === 'function' && function (fn) {
+ setImmediate(fn);
+ }) ||
+ function (fn) {
+ setTimeout(fn, 1);
+ });
+ });
+ it('changes immediate fn', function () {
+ var spy = sinon.spy();
+
+ function immediateFn(fn) {
+ spy();
+ fn();
+ }
+ Promise._setImmediateFn(immediateFn);
+ var done = false;
+ new Promise(function (resolve) {
+ resolve();
+ }).then(function () {
+ done = true;
+ });
+ assert(spy.calledOnce);
+ assert(done);
+ });
+ it('changes immediate fn multiple', function () {
+ var spy1 = sinon.spy();
+
+ function immediateFn1(fn) {
+ spy1();
+ fn();
+ }
+
+ var spy2 = sinon.spy();
+
+ function immediateFn2(fn) {
+ spy2();
+ fn();
+ }
+
+ Promise._setImmediateFn(immediateFn1);
+ var done = false;
+ new Promise(function (resolve) {
+ resolve();
+ }).then(function () {
+ });
+ Promise._setImmediateFn(immediateFn2);
+ new Promise(function (resolve) {
+ resolve();
+ }).then(function () {
+ done = true;
+ });
+ assert(spy2.called);
+ assert(spy1.calledOnce);
+ assert(done);
+ });
+ });
+ describe('Promise._onUnhandledRejection', function () {
+ var stub, sandbox;
+ beforeEach(function() {
+ sandbox = sinon.sandbox.create();
+ stub = sandbox.stub(console, 'warn');
+ });
+ afterEach(function() {
+ sandbox.restore();
+ });
+ it('no error on resolve', function (done) {
+ Promise.resolve(true).then(function(result) {
+ return result;
+ }).then(function(result) {
+ return result;
+ });
+
+ setTimeout(function() {
+ assert(!stub.called);
+ done();
+ }, 50);
+ });
+ it('error single Promise', function (done) {
+ new Promise(function(resolve, reject) {
+ abc.abc = 1;
+ });
+ setTimeout(function() {
+ assert(stub.calledOnce);
+ done();
+ }, 50);
+ });
+ it('multi promise error', function (done) {
+ new Promise(function(resolve, reject) {
+ abc.abc = 1;
+ }).then(function(result) {
+ return result;
+ });
+ setTimeout(function() {
+ assert(stub.calledOnce);
+ done();
+ }, 50);
+ });
+ it('promise catch no error', function (done) {
+ new Promise(function(resolve, reject) {
+ abc.abc = 1;
+ }).catch(function(result) {
+ return result;
+ });
+ setTimeout(function() {
+ assert(!stub.called);
+ done();
+ }, 50);
+ });
+ it('promise catch no error', function (done) {
+ new Promise(function(resolve, reject) {
+ abc.abc = 1;
+ }).then(function(result) {
+ return result;
+ }).catch(function(result) {
+ return result;
+ });
+ setTimeout(function() {
+ assert(!stub.called);
+ done();
+ }, 50);
+ });
+ it('promise reject error', function (done) {
+ Promise.reject('hello');
+ setTimeout(function() {
+ assert(stub.calledOnce);
+ done();
+ }, 50);
+ });
+ it('promise reject error late', function (done) {
+ var prom = Promise.reject('hello');
+ prom.catch(function() {
+
+ });
+ setTimeout(function() {
+ assert(!stub.called);
+ done();
+ }, 50);
+ });
+ it('promise reject error late', function (done) {
+ Promise.reject('hello');
+ setTimeout(function() {
+ assert.equal(stub.args[0][1], 'hello');
+ done();
+ }, 50);
+ });
+ });
+ describe('Promise.prototype.then', function() {
+ var spy,
+ SubClass;
+ beforeEach(function() {
+ spy = sinon.spy();
+ SubClass = function() {
+ spy();
+ Promise.apply(this, arguments);
+ };
+
+ function __() { this.constructor = SubClass; }
+ __.prototype = Promise.prototype;
+ SubClass.prototype = new __();
+
+ SubClass.prototype.then = function() {
+ return Promise.prototype.then.apply(this, arguments);
+ };
+ });
+ it('subclassed Promise resolves to subclass', function() {
+ var prom = new SubClass(function(resolve) {
+ resolve();
+ }).then(function() {}, function() {});
+ assert(spy.calledTwice);
+ assert(prom instanceof SubClass);
+ });
+ it('subclassed Promise rejects to subclass', function() {
+ var prom = new SubClass(function(_, reject) {
+ reject();
+ }).then(function() {}, function() {});
+ assert(spy.calledTwice);
+ assert(prom instanceof SubClass);
+ });
+ });
+});

\ No newline at end of file
diff --git a/src/third_party/protobuf-3/BUILD b/src/third_party/protobuf-3/BUILD
new file mode 100644
index 0000000..8b1046b
--- /dev/null
+++ b/src/third_party/protobuf-3/BUILD
@@ -0,0 +1,709 @@
+# Bazel (http://bazel.io/) BUILD file for Protobuf.
+
+licenses(["notice"])
+
+################################################################################
+# Protobuf Runtime Library
+################################################################################
+
+COPTS = [
+ "-DHAVE_PTHREAD",
+ "-Wall",
+ "-Wwrite-strings",
+ "-Woverloaded-virtual",
+ "-Wno-sign-compare",
+ "-Wno-error=unused-function",
+]
+
+config_setting(
+ name = "android",
+ values = {
+ "crosstool_top": "//external:android/crosstool",
+ },
+)
+
+# Android builds do not need to link in a separate pthread library.
+LINK_OPTS = select({
+ ":android": [],
+ "//conditions:default": ["-lpthread"],
+})
+
+load(
+ "protobuf",
+ "cc_proto_library",
+ "py_proto_library",
+ "internal_gen_well_known_protos_java",
+ "internal_protobuf_py_tests",
+)
+
+config_setting(
+ name = "ios_armv7",
+ values = {
+ "ios_cpu": "armv7",
+ },
+)
+
+config_setting(
+ name = "ios_armv7s",
+ values = {
+ "ios_cpu": "armv7s",
+ },
+)
+
+config_setting(
+ name = "ios_arm64",
+ values = {
+ "ios_cpu": "arm64",
+ },
+)
+
+IOS_ARM_COPTS = COPTS + [
+ "-DOS_IOS",
+ "-miphoneos-version-min=7.0",
+ "-arch armv7",
+ "-arch armv7s",
+ "-arch arm64",
+ "-D__thread=",
+ "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/",
+]
+
+cc_library(
+ name = "protobuf_lite",
+ srcs = [
+ # AUTOGEN(protobuf_lite_srcs)
+ "src/google/protobuf/arena.cc",
+ "src/google/protobuf/arenastring.cc",
+ "src/google/protobuf/extension_set.cc",
+ "src/google/protobuf/generated_message_util.cc",
+ "src/google/protobuf/io/coded_stream.cc",
+ "src/google/protobuf/io/zero_copy_stream.cc",
+ "src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
+ "src/google/protobuf/message_lite.cc",
+ "src/google/protobuf/repeated_field.cc",
+ "src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc",
+ "src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc",
+ "src/google/protobuf/stubs/bytestream.cc",
+ "src/google/protobuf/stubs/common.cc",
+ "src/google/protobuf/stubs/int128.cc",
+ "src/google/protobuf/stubs/once.cc",
+ "src/google/protobuf/stubs/status.cc",
+ "src/google/protobuf/stubs/statusor.cc",
+ "src/google/protobuf/stubs/stringpiece.cc",
+ "src/google/protobuf/stubs/stringprintf.cc",
+ "src/google/protobuf/stubs/structurally_valid.cc",
+ "src/google/protobuf/stubs/strutil.cc",
+ "src/google/protobuf/stubs/time.cc",
+ "src/google/protobuf/wire_format_lite.cc",
+ ],
+ hdrs = glob(["src/google/protobuf/**/*.h"]),
+ copts = select({
+ ":ios_armv7": IOS_ARM_COPTS,
+ ":ios_armv7s": IOS_ARM_COPTS,
+ ":ios_arm64": IOS_ARM_COPTS,
+ "//conditions:default": COPTS,
+ }),
+ includes = ["src/"],
+ linkopts = LINK_OPTS,
+ visibility = ["//visibility:public"],
+)
+
+cc_library(
+ name = "protobuf",
+ srcs = [
+ # AUTOGEN(protobuf_srcs)
+ "src/google/protobuf/any.cc",
+ "src/google/protobuf/any.pb.cc",
+ "src/google/protobuf/api.pb.cc",
+ "src/google/protobuf/compiler/importer.cc",
+ "src/google/protobuf/compiler/parser.cc",
+ "src/google/protobuf/descriptor.cc",
+ "src/google/protobuf/descriptor.pb.cc",
+ "src/google/protobuf/descriptor_database.cc",
+ "src/google/protobuf/duration.pb.cc",
+ "src/google/protobuf/dynamic_message.cc",
+ "src/google/protobuf/empty.pb.cc",
+ "src/google/protobuf/extension_set_heavy.cc",
+ "src/google/protobuf/field_mask.pb.cc",
+ "src/google/protobuf/generated_message_reflection.cc",
+ "src/google/protobuf/io/gzip_stream.cc",
+ "src/google/protobuf/io/printer.cc",
+ "src/google/protobuf/io/strtod.cc",
+ "src/google/protobuf/io/tokenizer.cc",
+ "src/google/protobuf/io/zero_copy_stream_impl.cc",
+ "src/google/protobuf/map_field.cc",
+ "src/google/protobuf/message.cc",
+ "src/google/protobuf/reflection_ops.cc",
+ "src/google/protobuf/service.cc",
+ "src/google/protobuf/source_context.pb.cc",
+ "src/google/protobuf/struct.pb.cc",
+ "src/google/protobuf/stubs/mathlimits.cc",
+ "src/google/protobuf/stubs/substitute.cc",
+ "src/google/protobuf/text_format.cc",
+ "src/google/protobuf/timestamp.pb.cc",
+ "src/google/protobuf/type.pb.cc",
+ "src/google/protobuf/unknown_field_set.cc",
+ "src/google/protobuf/util/field_comparator.cc",
+ "src/google/protobuf/util/field_mask_util.cc",
+ "src/google/protobuf/util/internal/datapiece.cc",
+ "src/google/protobuf/util/internal/default_value_objectwriter.cc",
+ "src/google/protobuf/util/internal/error_listener.cc",
+ "src/google/protobuf/util/internal/field_mask_utility.cc",
+ "src/google/protobuf/util/internal/json_escaping.cc",
+ "src/google/protobuf/util/internal/json_objectwriter.cc",
+ "src/google/protobuf/util/internal/json_stream_parser.cc",
+ "src/google/protobuf/util/internal/object_writer.cc",
+ "src/google/protobuf/util/internal/proto_writer.cc",
+ "src/google/protobuf/util/internal/protostream_objectsource.cc",
+ "src/google/protobuf/util/internal/protostream_objectwriter.cc",
+ "src/google/protobuf/util/internal/type_info.cc",
+ "src/google/protobuf/util/internal/type_info_test_helper.cc",
+ "src/google/protobuf/util/internal/utility.cc",
+ "src/google/protobuf/util/json_util.cc",
+ "src/google/protobuf/util/message_differencer.cc",
+ "src/google/protobuf/util/time_util.cc",
+ "src/google/protobuf/util/type_resolver_util.cc",
+ "src/google/protobuf/wire_format.cc",
+ "src/google/protobuf/wrappers.pb.cc",
+ ],
+ hdrs = glob(["src/**/*.h"]),
+ copts = select({
+ ":ios_armv7": IOS_ARM_COPTS,
+ ":ios_armv7s": IOS_ARM_COPTS,
+ ":ios_arm64": IOS_ARM_COPTS,
+ "//conditions:default": COPTS,
+ }),
+ includes = ["src/"],
+ linkopts = LINK_OPTS,
+ visibility = ["//visibility:public"],
+ deps = [":protobuf_lite"],
+)
+
+objc_library(
+ name = "protobuf_objc",
+ hdrs = ["objectivec/GPBProtocolBuffers.h"],
+ includes = ["objectivec"],
+ non_arc_srcs = ["objectivec/GPBProtocolBuffers.m"],
+ visibility = ["//visibility:public"],
+)
+
+RELATIVE_WELL_KNOWN_PROTOS = [
+ # AUTOGEN(well_known_protos)
+ "google/protobuf/any.proto",
+ "google/protobuf/api.proto",
+ "google/protobuf/compiler/plugin.proto",
+ "google/protobuf/descriptor.proto",
+ "google/protobuf/duration.proto",
+ "google/protobuf/empty.proto",
+ "google/protobuf/field_mask.proto",
+ "google/protobuf/source_context.proto",
+ "google/protobuf/struct.proto",
+ "google/protobuf/timestamp.proto",
+ "google/protobuf/type.proto",
+ "google/protobuf/wrappers.proto",
+]
+
+WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
+
+filegroup(
+ name = "well_known_protos",
+ srcs = WELL_KNOWN_PROTOS,
+ visibility = ["//visibility:public"],
+)
+
+cc_proto_library(
+ name = "cc_wkt_protos",
+ srcs = WELL_KNOWN_PROTOS,
+ include = "src",
+ default_runtime = ":protobuf",
+ internal_bootstrap_hack = 1,
+ protoc = ":protoc",
+ visibility = ["//visibility:public"],
+)
+
+################################################################################
+# Protocol Buffers Compiler
+################################################################################
+
+cc_library(
+ name = "protoc_lib",
+ srcs = [
+ # AUTOGEN(protoc_lib_srcs)
+ "src/google/protobuf/compiler/code_generator.cc",
+ "src/google/protobuf/compiler/command_line_interface.cc",
+ "src/google/protobuf/compiler/cpp/cpp_enum.cc",
+ "src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
+ "src/google/protobuf/compiler/cpp/cpp_extension.cc",
+ "src/google/protobuf/compiler/cpp/cpp_field.cc",
+ "src/google/protobuf/compiler/cpp/cpp_file.cc",
+ "src/google/protobuf/compiler/cpp/cpp_generator.cc",
+ "src/google/protobuf/compiler/cpp/cpp_helpers.cc",
+ "src/google/protobuf/compiler/cpp/cpp_map_field.cc",
+ "src/google/protobuf/compiler/cpp/cpp_message.cc",
+ "src/google/protobuf/compiler/cpp/cpp_message_field.cc",
+ "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
+ "src/google/protobuf/compiler/cpp/cpp_service.cc",
+ "src/google/protobuf/compiler/cpp/cpp_string_field.cc",
+ "src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
+ "src/google/protobuf/compiler/csharp/csharp_enum.cc",
+ "src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
+ "src/google/protobuf/compiler/csharp/csharp_field_base.cc",
+ "src/google/protobuf/compiler/csharp/csharp_generator.cc",
+ "src/google/protobuf/compiler/csharp/csharp_helpers.cc",
+ "src/google/protobuf/compiler/csharp/csharp_map_field.cc",
+ "src/google/protobuf/compiler/csharp/csharp_message.cc",
+ "src/google/protobuf/compiler/csharp/csharp_message_field.cc",
+ "src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
+ "src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
+ "src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
+ "src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
+ "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
+ "src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
+ "src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
+ "src/google/protobuf/compiler/java/java_context.cc",
+ "src/google/protobuf/compiler/java/java_doc_comment.cc",
+ "src/google/protobuf/compiler/java/java_enum.cc",
+ "src/google/protobuf/compiler/java/java_enum_field.cc",
+ "src/google/protobuf/compiler/java/java_enum_field_lite.cc",
+ "src/google/protobuf/compiler/java/java_enum_lite.cc",
+ "src/google/protobuf/compiler/java/java_extension.cc",
+ "src/google/protobuf/compiler/java/java_extension_lite.cc",
+ "src/google/protobuf/compiler/java/java_field.cc",
+ "src/google/protobuf/compiler/java/java_file.cc",
+ "src/google/protobuf/compiler/java/java_generator.cc",
+ "src/google/protobuf/compiler/java/java_generator_factory.cc",
+ "src/google/protobuf/compiler/java/java_helpers.cc",
+ "src/google/protobuf/compiler/java/java_lazy_message_field.cc",
+ "src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc",
+ "src/google/protobuf/compiler/java/java_map_field.cc",
+ "src/google/protobuf/compiler/java/java_map_field_lite.cc",
+ "src/google/protobuf/compiler/java/java_message.cc",
+ "src/google/protobuf/compiler/java/java_message_builder.cc",
+ "src/google/protobuf/compiler/java/java_message_builder_lite.cc",
+ "src/google/protobuf/compiler/java/java_message_field.cc",
+ "src/google/protobuf/compiler/java/java_message_field_lite.cc",
+ "src/google/protobuf/compiler/java/java_message_lite.cc",
+ "src/google/protobuf/compiler/java/java_name_resolver.cc",
+ "src/google/protobuf/compiler/java/java_primitive_field.cc",
+ "src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
+ "src/google/protobuf/compiler/java/java_service.cc",
+ "src/google/protobuf/compiler/java/java_shared_code_generator.cc",
+ "src/google/protobuf/compiler/java/java_string_field.cc",
+ "src/google/protobuf/compiler/java/java_string_field_lite.cc",
+ "src/google/protobuf/compiler/javanano/javanano_enum.cc",
+ "src/google/protobuf/compiler/javanano/javanano_enum_field.cc",
+ "src/google/protobuf/compiler/javanano/javanano_extension.cc",
+ "src/google/protobuf/compiler/javanano/javanano_field.cc",
+ "src/google/protobuf/compiler/javanano/javanano_file.cc",
+ "src/google/protobuf/compiler/javanano/javanano_generator.cc",
+ "src/google/protobuf/compiler/javanano/javanano_helpers.cc",
+ "src/google/protobuf/compiler/javanano/javanano_map_field.cc",
+ "src/google/protobuf/compiler/javanano/javanano_message.cc",
+ "src/google/protobuf/compiler/javanano/javanano_message_field.cc",
+ "src/google/protobuf/compiler/javanano/javanano_primitive_field.cc",
+ "src/google/protobuf/compiler/js/js_generator.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_field.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_file.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_message.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
+ "src/google/protobuf/compiler/plugin.cc",
+ "src/google/protobuf/compiler/plugin.pb.cc",
+ "src/google/protobuf/compiler/python/python_generator.cc",
+ "src/google/protobuf/compiler/ruby/ruby_generator.cc",
+ "src/google/protobuf/compiler/subprocess.cc",
+ "src/google/protobuf/compiler/zip_writer.cc",
+ ],
+ copts = COPTS,
+ includes = ["src/"],
+ linkopts = LINK_OPTS,
+ visibility = ["//visibility:public"],
+ deps = [":protobuf"],
+)
+
+cc_binary(
+ name = "protoc",
+ srcs = ["src/google/protobuf/compiler/main.cc"],
+ linkopts = LINK_OPTS,
+ visibility = ["//visibility:public"],
+ deps = [":protoc_lib"],
+)
+
+################################################################################
+# Tests
+################################################################################
+
+RELATIVE_LITE_TEST_PROTOS = [
+ # AUTOGEN(lite_test_protos)
+ "google/protobuf/map_lite_unittest.proto",
+ "google/protobuf/unittest_import_lite.proto",
+ "google/protobuf/unittest_import_public_lite.proto",
+ "google/protobuf/unittest_lite.proto",
+ "google/protobuf/unittest_no_arena_lite.proto",
+]
+
+LITE_TEST_PROTOS = ["src/" + s for s in RELATIVE_LITE_TEST_PROTOS]
+
+RELATIVE_TEST_PROTOS = [
+ # AUTOGEN(test_protos)
+ "google/protobuf/any_test.proto",
+ "google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto",
+ "google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto",
+ "google/protobuf/map_proto2_unittest.proto",
+ "google/protobuf/map_unittest.proto",
+ "google/protobuf/unittest.proto",
+ "google/protobuf/unittest_arena.proto",
+ "google/protobuf/unittest_custom_options.proto",
+ "google/protobuf/unittest_drop_unknown_fields.proto",
+ "google/protobuf/unittest_embed_optimize_for.proto",
+ "google/protobuf/unittest_empty.proto",
+ "google/protobuf/unittest_enormous_descriptor.proto",
+ "google/protobuf/unittest_import.proto",
+ "google/protobuf/unittest_import_public.proto",
+ "google/protobuf/unittest_lite_imports_nonlite.proto",
+ "google/protobuf/unittest_mset.proto",
+ "google/protobuf/unittest_mset_wire_format.proto",
+ "google/protobuf/unittest_no_arena.proto",
+ "google/protobuf/unittest_no_arena_import.proto",
+ "google/protobuf/unittest_no_field_presence.proto",
+ "google/protobuf/unittest_no_generic_services.proto",
+ "google/protobuf/unittest_optimize_for.proto",
+ "google/protobuf/unittest_preserve_unknown_enum.proto",
+ "google/protobuf/unittest_preserve_unknown_enum2.proto",
+ "google/protobuf/unittest_proto3_arena.proto",
+ "google/protobuf/unittest_proto3_arena_lite.proto",
+ "google/protobuf/unittest_proto3_lite.proto",
+ "google/protobuf/unittest_well_known_types.proto",
+ "google/protobuf/util/internal/testdata/anys.proto",
+ "google/protobuf/util/internal/testdata/books.proto",
+ "google/protobuf/util/internal/testdata/default_value.proto",
+ "google/protobuf/util/internal/testdata/default_value_test.proto",
+ "google/protobuf/util/internal/testdata/field_mask.proto",
+ "google/protobuf/util/internal/testdata/maps.proto",
+ "google/protobuf/util/internal/testdata/oneofs.proto",
+ "google/protobuf/util/internal/testdata/struct.proto",
+ "google/protobuf/util/internal/testdata/timestamp_duration.proto",
+ "google/protobuf/util/json_format_proto3.proto",
+ "google/protobuf/util/message_differencer_unittest.proto",
+]
+
+TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS]
+
+cc_proto_library(
+ name = "cc_test_protos",
+ srcs = LITE_TEST_PROTOS + TEST_PROTOS,
+ include = "src",
+ default_runtime = ":protobuf",
+ protoc = ":protoc",
+ deps = [":cc_wkt_protos"],
+)
+
+COMMON_TEST_SRCS = [
+ # AUTOGEN(common_test_srcs)
+ "src/google/protobuf/arena_test_util.cc",
+ "src/google/protobuf/map_test_util.cc",
+ "src/google/protobuf/test_util.cc",
+ "src/google/protobuf/testing/file.cc",
+ "src/google/protobuf/testing/googletest.cc",
+]
+
+cc_binary(
+ name = "test_plugin",
+ srcs = [
+ # AUTOGEN(test_plugin_srcs)
+ "src/google/protobuf/compiler/mock_code_generator.cc",
+ "src/google/protobuf/compiler/test_plugin.cc",
+ "src/google/protobuf/testing/file.cc",
+ ],
+ deps = [
+ ":protobuf",
+ ":protoc_lib",
+ "//external:gtest",
+ ],
+)
+
+cc_test(
+ name = "protobuf_test",
+ srcs = COMMON_TEST_SRCS + [
+ # AUTOGEN(test_srcs)
+ "src/google/protobuf/any_test.cc",
+ "src/google/protobuf/arena_unittest.cc",
+ "src/google/protobuf/arenastring_unittest.cc",
+ "src/google/protobuf/compiler/command_line_interface_unittest.cc",
+ "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc",
+ "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc",
+ "src/google/protobuf/compiler/cpp/cpp_unittest.cc",
+ "src/google/protobuf/compiler/cpp/metadata_test.cc",
+ "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
+ "src/google/protobuf/compiler/importer_unittest.cc",
+ "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc",
+ "src/google/protobuf/compiler/java/java_plugin_unittest.cc",
+ "src/google/protobuf/compiler/mock_code_generator.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc",
+ "src/google/protobuf/compiler/parser_unittest.cc",
+ "src/google/protobuf/compiler/python/python_plugin_unittest.cc",
+ "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc",
+ "src/google/protobuf/descriptor_database_unittest.cc",
+ "src/google/protobuf/descriptor_unittest.cc",
+ "src/google/protobuf/drop_unknown_fields_test.cc",
+ "src/google/protobuf/dynamic_message_unittest.cc",
+ "src/google/protobuf/extension_set_unittest.cc",
+ "src/google/protobuf/generated_message_reflection_unittest.cc",
+ "src/google/protobuf/io/coded_stream_unittest.cc",
+ "src/google/protobuf/io/printer_unittest.cc",
+ "src/google/protobuf/io/tokenizer_unittest.cc",
+ "src/google/protobuf/io/zero_copy_stream_unittest.cc",
+ "src/google/protobuf/map_field_test.cc",
+ "src/google/protobuf/map_test.cc",
+ "src/google/protobuf/message_unittest.cc",
+ "src/google/protobuf/no_field_presence_test.cc",
+ "src/google/protobuf/preserve_unknown_enum_test.cc",
+ "src/google/protobuf/proto3_arena_lite_unittest.cc",
+ "src/google/protobuf/proto3_arena_unittest.cc",
+ "src/google/protobuf/proto3_lite_unittest.cc",
+ "src/google/protobuf/reflection_ops_unittest.cc",
+ "src/google/protobuf/repeated_field_reflection_unittest.cc",
+ "src/google/protobuf/repeated_field_unittest.cc",
+ "src/google/protobuf/stubs/bytestream_unittest.cc",
+ "src/google/protobuf/stubs/common_unittest.cc",
+ "src/google/protobuf/stubs/int128_unittest.cc",
+ "src/google/protobuf/stubs/once_unittest.cc",
+ "src/google/protobuf/stubs/status_test.cc",
+ "src/google/protobuf/stubs/statusor_test.cc",
+ "src/google/protobuf/stubs/stringpiece_unittest.cc",
+ "src/google/protobuf/stubs/stringprintf_unittest.cc",
+ "src/google/protobuf/stubs/structurally_valid_unittest.cc",
+ "src/google/protobuf/stubs/strutil_unittest.cc",
+ "src/google/protobuf/stubs/template_util_unittest.cc",
+ "src/google/protobuf/stubs/time_test.cc",
+ "src/google/protobuf/stubs/type_traits_unittest.cc",
+ "src/google/protobuf/text_format_unittest.cc",
+ "src/google/protobuf/unknown_field_set_unittest.cc",
+ "src/google/protobuf/util/field_comparator_test.cc",
+ "src/google/protobuf/util/field_mask_util_test.cc",
+ "src/google/protobuf/util/internal/default_value_objectwriter_test.cc",
+ "src/google/protobuf/util/internal/json_objectwriter_test.cc",
+ "src/google/protobuf/util/internal/json_stream_parser_test.cc",
+ "src/google/protobuf/util/internal/protostream_objectsource_test.cc",
+ "src/google/protobuf/util/internal/protostream_objectwriter_test.cc",
+ "src/google/protobuf/util/internal/type_info_test_helper.cc",
+ "src/google/protobuf/util/json_util_test.cc",
+ "src/google/protobuf/util/message_differencer_unittest.cc",
+ "src/google/protobuf/util/time_util_test.cc",
+ "src/google/protobuf/util/type_resolver_util_test.cc",
+ "src/google/protobuf/well_known_types_unittest.cc",
+ "src/google/protobuf/wire_format_unittest.cc",
+ ],
+ copts = COPTS,
+ data = [
+ ":test_plugin",
+ ] + glob([
+ "src/google/protobuf/**/*",
+ ]),
+ includes = [
+ "src/",
+ ],
+ linkopts = LINK_OPTS,
+ deps = [
+ ":cc_test_protos",
+ ":protobuf",
+ ":protoc_lib",
+ "//external:gtest_main",
+ ],
+)
+
+################################################################################
+# Java support
+################################################################################
+internal_gen_well_known_protos_java(
+ srcs = WELL_KNOWN_PROTOS,
+)
+
+java_library(
+ name = "protobuf_java",
+ srcs = glob([
+ "java/core/src/main/java/com/google/protobuf/*.java",
+ ]) + [
+ ":gen_well_known_protos_java",
+ ],
+ visibility = ["//visibility:public"],
+)
+
+java_library(
+ name = "protobuf_java_util",
+ srcs = glob([
+ "java/util/src/main/java/com/google/protobuf/util/*.java",
+ ]),
+ deps = [
+ "protobuf_java",
+ "//external:gson",
+ "//external:guava",
+ ],
+ visibility = ["//visibility:public"],
+)
+
+################################################################################
+# Python support
+################################################################################
+
+py_library(
+ name = "python_srcs",
+ srcs = glob(
+ [
+ "python/google/protobuf/*.py",
+ "python/google/protobuf/**/*.py",
+ ],
+ exclude = [
+ "python/google/protobuf/internal/*_test.py",
+ "python/google/protobuf/internal/test_util.py",
+ ],
+ ),
+ srcs_version = "PY2AND3",
+ imports = ["python"],
+)
+
+cc_binary(
+ name = "internal/_api_implementation.so",
+ srcs = ["python/google/protobuf/internal/api_implementation.cc"],
+ copts = COPTS + [
+ "-DPYTHON_PROTO2_CPP_IMPL_V2",
+ ],
+ linkshared = 1,
+ linkstatic = 1,
+ deps = select({
+ "//conditions:default": [],
+ ":use_fast_cpp_protos": ["//external:python_headers"],
+ }),
+)
+
+cc_binary(
+ name = "pyext/_message.so",
+ srcs = glob([
+ "python/google/protobuf/pyext/*.cc",
+ "python/google/protobuf/pyext/*.h",
+ ]),
+ copts = COPTS + [
+ "-DGOOGLE_PROTOBUF_HAS_ONEOF=1",
+ ] + select({
+ "//conditions:default": [],
+ ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"],
+ }),
+ includes = [
+ "python/",
+ "src/",
+ ],
+ linkshared = 1,
+ linkstatic = 1,
+ deps = [
+ ":protobuf",
+ ] + select({
+ "//conditions:default": [],
+ ":use_fast_cpp_protos": ["//external:python_headers"],
+ }),
+)
+
+config_setting(
+ name = "use_fast_cpp_protos",
+ values = {
+ "define": "use_fast_cpp_protos=true",
+ },
+)
+
+config_setting(
+ name = "allow_oversize_protos",
+ values = {
+ "define": "allow_oversize_protos=true",
+ },
+)
+
+py_proto_library(
+ name = "protobuf_python",
+ srcs = WELL_KNOWN_PROTOS,
+ include = "src",
+ data = select({
+ "//conditions:default": [],
+ ":use_fast_cpp_protos": [
+ ":internal/_api_implementation.so",
+ ":pyext/_message.so",
+ ],
+ }),
+ default_runtime = "",
+ protoc = ":protoc",
+ py_libs = [
+ ":python_srcs",
+ "//external:six"
+ ],
+ srcs_version = "PY2AND3",
+ visibility = ["//visibility:public"],
+)
+
+py_proto_library(
+ name = "python_common_test_protos",
+ srcs = LITE_TEST_PROTOS + TEST_PROTOS,
+ include = "src",
+ default_runtime = "",
+ protoc = ":protoc",
+ srcs_version = "PY2AND3",
+ deps = [":protobuf_python"],
+)
+
+py_proto_library(
+ name = "python_specific_test_protos",
+ srcs = glob([
+ "python/google/protobuf/internal/*.proto",
+ "python/google/protobuf/internal/import_test_package/*.proto",
+ ]),
+ include = "python",
+ default_runtime = ":protobuf_python",
+ protoc = ":protoc",
+ srcs_version = "PY2AND3",
+ deps = [":python_common_test_protos"],
+)
+
+py_library(
+ name = "python_tests",
+ srcs = glob(
+ [
+ "python/google/protobuf/internal/*_test.py",
+ "python/google/protobuf/internal/test_util.py",
+ ],
+ ),
+ imports = ["python"],
+ srcs_version = "PY2AND3",
+ deps = [
+ ":protobuf_python",
+ ":python_common_test_protos",
+ ":python_specific_test_protos",
+ ],
+)
+
+internal_protobuf_py_tests(
+ name = "python_tests_batch",
+ data = glob([
+ "src/google/protobuf/**/*",
+ ]),
+ modules = [
+ "descriptor_database_test",
+ "descriptor_pool_test",
+ "descriptor_test",
+ "generator_test",
+ "json_format_test",
+ "message_factory_test",
+ "message_test",
+ "proto_builder_test",
+ "reflection_test",
+ "service_reflection_test",
+ "symbol_database_test",
+ "text_encoding_test",
+ "text_format_test",
+ "unknown_fields_test",
+ "wire_format_test",
+ ],
+ deps = [":python_tests"],
+)
diff --git a/src/third_party/protobuf-3/BUILD.gn b/src/third_party/protobuf-3/BUILD.gn
new file mode 100644
index 0000000..84c916a
--- /dev/null
+++ b/src/third_party/protobuf-3/BUILD.gn
@@ -0,0 +1,652 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+config("protobuf_config") {
+ include_dirs = [ "src" ]
+ defines = [
+ "GOOGLE_PROTOBUF_NO_RTTI",
+ "GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
+ ]
+ if (!is_win) {
+ defines += [ "HAVE_PTHREAD" ]
+ }
+}
+
+config("protobuf_warnings") {
+ cflags = []
+ if (is_clang) {
+ # protobuf-3 contains a few functions that are unused.
+ cflags += [ "-Wno-unused-function" ]
+ }
+}
+
+if (is_component_build) {
+ config("protobuf_use_dlls") {
+ defines = [ "PROTOBUF_USE_DLLS" ]
+ }
+}
+
+# This config should be applied to targets using generated code from the proto
+# compiler. It sets up the include directories properly.
+config("using_proto") {
+ include_dirs = [
+ "src",
+ "$root_gen_dir/protoc_out",
+ ]
+}
+
+protobuf_lite_sources = [
+ "src/google/protobuf/arena.cc",
+ "src/google/protobuf/arena.h",
+ "src/google/protobuf/arenastring.cc",
+ "src/google/protobuf/arenastring.h",
+ "src/google/protobuf/extension_set.cc",
+ "src/google/protobuf/extension_set.h",
+ "src/google/protobuf/generated_message_util.cc",
+ "src/google/protobuf/generated_message_util.h",
+ "src/google/protobuf/io/coded_stream.cc",
+ "src/google/protobuf/io/coded_stream.h",
+ "src/google/protobuf/io/coded_stream_inl.h",
+ "src/google/protobuf/io/zero_copy_stream.cc",
+ "src/google/protobuf/io/zero_copy_stream.h",
+ "src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
+ "src/google/protobuf/io/zero_copy_stream_impl_lite.h",
+ "src/google/protobuf/map.h",
+ "src/google/protobuf/map_entry_lite.h",
+ "src/google/protobuf/map_field_lite.h",
+ "src/google/protobuf/map_type_handler.h",
+ "src/google/protobuf/message_lite.cc",
+ "src/google/protobuf/message_lite.h",
+ "src/google/protobuf/repeated_field.cc",
+ "src/google/protobuf/repeated_field.h",
+ "src/google/protobuf/stubs/atomicops.h",
+ "src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h",
+ "src/google/protobuf/stubs/atomicops_internals_arm_gcc.h",
+ "src/google/protobuf/stubs/atomicops_internals_arm_qnx.h",
+ "src/google/protobuf/stubs/atomicops_internals_atomicword_compat.h",
+ "src/google/protobuf/stubs/atomicops_internals_generic_gcc.h",
+ "src/google/protobuf/stubs/atomicops_internals_macosx.h",
+ "src/google/protobuf/stubs/atomicops_internals_mips_gcc.h",
+ "src/google/protobuf/stubs/atomicops_internals_pnacl.h",
+ "src/google/protobuf/stubs/atomicops_internals_power.h",
+ "src/google/protobuf/stubs/atomicops_internals_ppc_gcc.h",
+ "src/google/protobuf/stubs/atomicops_internals_solaris.h",
+ "src/google/protobuf/stubs/atomicops_internals_tsan.h",
+ "src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc",
+ "src/google/protobuf/stubs/atomicops_internals_x86_gcc.h",
+ "src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc",
+ "src/google/protobuf/stubs/atomicops_internals_x86_msvc.h",
+ "src/google/protobuf/stubs/atomic_sequence_num.h",
+ "src/google/protobuf/stubs/bytestream.cc",
+ "src/google/protobuf/stubs/bytestream.h",
+ "src/google/protobuf/stubs/callback.h",
+ "src/google/protobuf/stubs/casts.h",
+ "src/google/protobuf/stubs/common.cc",
+ "src/google/protobuf/stubs/common.h",
+ "src/google/protobuf/stubs/fastmem.h",
+ "src/google/protobuf/stubs/hash.h",
+ "src/google/protobuf/stubs/int128.cc",
+ "src/google/protobuf/stubs/int128.h",
+ "src/google/protobuf/stubs/logging.h",
+ "src/google/protobuf/stubs/macros.h",
+ "src/google/protobuf/stubs/map_util.h",
+ "src/google/protobuf/stubs/mutex.h",
+ "src/google/protobuf/stubs/once.cc",
+ "src/google/protobuf/stubs/once.h",
+ "src/google/protobuf/stubs/platform_macros.h",
+ "src/google/protobuf/stubs/port.h",
+ "src/google/protobuf/stubs/scoped_ptr.h",
+ "src/google/protobuf/stubs/shared_ptr.h",
+ "src/google/protobuf/stubs/status.cc",
+ "src/google/protobuf/stubs/status.h",
+ "src/google/protobuf/stubs/status_macros.h",
+ "src/google/protobuf/stubs/statusor.cc",
+ "src/google/protobuf/stubs/statusor.h",
+ "src/google/protobuf/stubs/stl_util.h",
+ "src/google/protobuf/stubs/stringpiece.cc",
+ "src/google/protobuf/stubs/stringpiece.h",
+ "src/google/protobuf/stubs/stringprintf.cc",
+ "src/google/protobuf/stubs/stringprintf.h",
+ "src/google/protobuf/stubs/structurally_valid.cc",
+ "src/google/protobuf/stubs/strutil.cc",
+ "src/google/protobuf/stubs/strutil.h",
+ "src/google/protobuf/stubs/template_util.h",
+ "src/google/protobuf/stubs/type_traits.h",
+ "src/google/protobuf/stubs/time.cc",
+ "src/google/protobuf/stubs/time.h",
+ "src/google/protobuf/wire_format_lite.cc",
+ "src/google/protobuf/wire_format_lite.h",
+ "src/google/protobuf/wire_format_lite_inl.h",
+]
+
+protobuf_lite_cflags = []
+if (is_win) {
+ protobuf_lite_cflags = [
+ "/wd4018", # signed/unsigned mismatch in comparison
+ "/wd4065", # switch statement contains 'default' but no 'case' labels
+ "/wd4146", # unary minus operator applied to unsigned type
+ "/wd4244", # implicit conversion, possible loss of data
+ "/wd4267", # size_t to int truncation
+ "/wd4291", # no matching operator delete for a placement new.
+ "/wd4305", # double to float truncation
+ "/wd4355", # 'this' used in base member initializer list
+ "/wd4506", # no definition for inline function (protobuf issue #240)
+ "/wd4715", # not all control paths return a value (fixed in trunk)
+ ]
+}
+
+component("protobuf_lite") {
+ sources = protobuf_lite_sources
+
+ configs -= [ "//build/config/compiler:chromium_code" ]
+ configs += [
+ "//build/config/compiler:no_chromium_code",
+
+ # Must be after no_chromium_code for warning flags to be ordered
+ # correctly.
+ ":protobuf_warnings",
+ ]
+
+ if (is_win) {
+ configs -= [ "//build/config/win:lean_and_mean" ]
+ }
+
+ public_configs = [
+ ":protobuf_config",
+
+ # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
+ "//build/config/compiler:no_size_t_to_int_warning",
+ ]
+
+ deps = [
+ "//build/config/sanitizers:deps",
+ ]
+
+ cflags = protobuf_lite_cflags
+
+ # Required for component builds. See http://crbug.com/172800.
+ if (is_component_build) {
+ public_configs += [ ":protobuf_use_dlls" ]
+ defines = [ "LIBPROTOBUF_EXPORTS" ]
+ }
+}
+
+# This is the full, heavy protobuf lib that's needed for c++ .protos that don't
+# specify the LITE_RUNTIME option. The protocol compiler itself (protoc) falls
+# into that category. Do not use in Chrome code.
+static_library("protobuf_full") {
+ # Prevent people from depending on this outside our file.
+ visibility = [ ":*" ]
+
+ sources = protobuf_lite_sources
+ sources += [
+ "src/google/protobuf/any.cc",
+ "src/google/protobuf/any.h",
+ "src/google/protobuf/any.pb.cc",
+ "src/google/protobuf/any.pb.h",
+ "src/google/protobuf/api.pb.cc",
+ "src/google/protobuf/api.pb.h",
+ "src/google/protobuf/compiler/importer.cc",
+ "src/google/protobuf/compiler/importer.h",
+ "src/google/protobuf/compiler/parser.cc",
+ "src/google/protobuf/compiler/parser.h",
+ "src/google/protobuf/descriptor.cc",
+ "src/google/protobuf/descriptor.h",
+ "src/google/protobuf/descriptor.pb.cc",
+ "src/google/protobuf/descriptor.pb.h",
+ "src/google/protobuf/descriptor_database.cc",
+ "src/google/protobuf/descriptor_database.h",
+ "src/google/protobuf/duration.pb.cc",
+ "src/google/protobuf/duration.pb.h",
+ "src/google/protobuf/dynamic_message.cc",
+ "src/google/protobuf/dynamic_message.h",
+ "src/google/protobuf/empty.pb.cc",
+ "src/google/protobuf/empty.pb.h",
+ "src/google/protobuf/extension_set_heavy.cc",
+ "src/google/protobuf/field_mask.pb.cc",
+ "src/google/protobuf/field_mask.pb.h",
+ "src/google/protobuf/generated_enum_reflection.h",
+ "src/google/protobuf/generated_enum_util.h",
+ "src/google/protobuf/generated_message_reflection.cc",
+ "src/google/protobuf/generated_message_reflection.h",
+
+ # gzip_stream.cc pulls in zlib, but it's not actually used by protoc, just
+ # by test code, so instead of compiling zlib for the host, let's just
+ # exclude this.
+ # "src/google/protobuf/io/gzip_stream.cc",
+ # "src/google/protobuf/io/gzip_stream.h",
+
+ "src/google/protobuf/io/printer.cc",
+ "src/google/protobuf/io/printer.h",
+ "src/google/protobuf/io/strtod.cc",
+ "src/google/protobuf/io/strtod.h",
+ "src/google/protobuf/io/tokenizer.cc",
+ "src/google/protobuf/io/tokenizer.h",
+ "src/google/protobuf/io/zero_copy_stream_impl.cc",
+ "src/google/protobuf/io/zero_copy_stream_impl.h",
+ "src/google/protobuf/map_entry.h",
+ "src/google/protobuf/map_field.cc",
+ "src/google/protobuf/map_field.h",
+ "src/google/protobuf/map_field_inl.h",
+ "src/google/protobuf/message.cc",
+ "src/google/protobuf/message.h",
+ "src/google/protobuf/metadata.h",
+ "src/google/protobuf/reflection.h",
+ "src/google/protobuf/reflection_internal.h",
+ "src/google/protobuf/reflection_ops.cc",
+ "src/google/protobuf/reflection_ops.h",
+ "src/google/protobuf/service.cc",
+ "src/google/protobuf/service.h",
+ "src/google/protobuf/source_context.pb.cc",
+ "src/google/protobuf/source_context.pb.h",
+ "src/google/protobuf/struct.pb.cc",
+ "src/google/protobuf/struct.pb.h",
+ "src/google/protobuf/stubs/mathlimits.cc",
+ "src/google/protobuf/stubs/mathlimits.h",
+ "src/google/protobuf/stubs/mathutil.h",
+ "src/google/protobuf/stubs/singleton.h",
+ "src/google/protobuf/stubs/substitute.cc",
+ "src/google/protobuf/stubs/substitute.h",
+ "src/google/protobuf/text_format.cc",
+ "src/google/protobuf/text_format.h",
+ "src/google/protobuf/timestamp.pb.cc",
+ "src/google/protobuf/timestamp.pb.h",
+ "src/google/protobuf/type.pb.cc",
+ "src/google/protobuf/type.pb.h",
+ "src/google/protobuf/unknown_field_set.cc",
+ "src/google/protobuf/unknown_field_set.h",
+ "src/google/protobuf/util/field_comparator.cc",
+ "src/google/protobuf/util/field_comparator.h",
+ "src/google/protobuf/util/field_mask_util.cc",
+ "src/google/protobuf/util/field_mask_util.h",
+ "src/google/protobuf/util/internal/constants.h",
+ "src/google/protobuf/util/internal/datapiece.cc",
+ "src/google/protobuf/util/internal/datapiece.h",
+ "src/google/protobuf/util/internal/default_value_objectwriter.cc",
+ "src/google/protobuf/util/internal/default_value_objectwriter.h",
+ "src/google/protobuf/util/internal/error_listener.cc",
+ "src/google/protobuf/util/internal/error_listener.h",
+ "src/google/protobuf/util/internal/field_mask_utility.cc",
+ "src/google/protobuf/util/internal/field_mask_utility.h",
+ "src/google/protobuf/util/internal/json_escaping.cc",
+ "src/google/protobuf/util/internal/json_escaping.h",
+ "src/google/protobuf/util/internal/json_objectwriter.cc",
+ "src/google/protobuf/util/internal/json_objectwriter.h",
+ "src/google/protobuf/util/internal/json_stream_parser.cc",
+ "src/google/protobuf/util/internal/json_stream_parser.h",
+ "src/google/protobuf/util/internal/location_tracker.h",
+ "src/google/protobuf/util/internal/object_location_tracker.h",
+ "src/google/protobuf/util/internal/object_source.h",
+ "src/google/protobuf/util/internal/object_writer.cc",
+ "src/google/protobuf/util/internal/object_writer.h",
+ "src/google/protobuf/util/internal/proto_writer.cc",
+ "src/google/protobuf/util/internal/proto_writer.h",
+ "src/google/protobuf/util/internal/protostream_objectsource.cc",
+ "src/google/protobuf/util/internal/protostream_objectsource.h",
+ "src/google/protobuf/util/internal/protostream_objectwriter.cc",
+ "src/google/protobuf/util/internal/protostream_objectwriter.h",
+ "src/google/protobuf/util/internal/structured_objectwriter.h",
+ "src/google/protobuf/util/internal/type_info.cc",
+ "src/google/protobuf/util/internal/type_info.h",
+ "src/google/protobuf/util/internal/type_info_test_helper.cc",
+ "src/google/protobuf/util/internal/type_info_test_helper.h",
+ "src/google/protobuf/util/internal/utility.cc",
+ "src/google/protobuf/util/internal/utility.h",
+ "src/google/protobuf/util/json_util.cc",
+ "src/google/protobuf/util/json_util.h",
+ "src/google/protobuf/util/message_differencer.cc",
+ "src/google/protobuf/util/message_differencer.h",
+ "src/google/protobuf/util/time_util.cc",
+ "src/google/protobuf/util/time_util.h",
+ "src/google/protobuf/util/type_resolver.h",
+ "src/google/protobuf/util/type_resolver_util.cc",
+ "src/google/protobuf/util/type_resolver_util.h",
+ "src/google/protobuf/wire_format.cc",
+ "src/google/protobuf/wire_format.h",
+ "src/google/protobuf/wrappers.pb.cc",
+ "src/google/protobuf/wrappers.pb.h",
+ ]
+
+ deps = [
+ "//build/config/sanitizers:deps",
+ ]
+
+ configs -= [ "//build/config/compiler:chromium_code" ]
+ configs += [
+ "//build/config/compiler:no_chromium_code",
+
+ # Must be after no_chromium_code for warning flags to be ordered
+ # correctly.
+ ":protobuf_warnings",
+ ]
+ if (is_win) {
+ configs -= [ "//build/config/win:lean_and_mean" ]
+ }
+ public_configs = [
+ ":protobuf_config",
+
+ # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
+ "//build/config/compiler:no_size_t_to_int_warning",
+ ]
+
+ cflags = protobuf_lite_cflags
+}
+
+# Only compile the compiler for the host architecture.
+if (current_toolchain == host_toolchain) {
+ # protoc compiler is separated into protoc library and executable targets to
+ # support protoc plugins that need to link libprotoc, but not the main()
+ # itself. See src/google/protobuf/compiler/plugin.h
+ static_library("protoc_lib") {
+ sources = [
+ "src/google/protobuf/compiler/code_generator.cc",
+ "src/google/protobuf/compiler/code_generator.h",
+ "src/google/protobuf/compiler/command_line_interface.cc",
+ "src/google/protobuf/compiler/command_line_interface.h",
+ "src/google/protobuf/compiler/cpp/cpp_enum.cc",
+ "src/google/protobuf/compiler/cpp/cpp_enum.h",
+ "src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
+ "src/google/protobuf/compiler/cpp/cpp_enum_field.h",
+ "src/google/protobuf/compiler/cpp/cpp_extension.cc",
+ "src/google/protobuf/compiler/cpp/cpp_extension.h",
+ "src/google/protobuf/compiler/cpp/cpp_field.cc",
+ "src/google/protobuf/compiler/cpp/cpp_field.h",
+ "src/google/protobuf/compiler/cpp/cpp_file.cc",
+ "src/google/protobuf/compiler/cpp/cpp_file.h",
+ "src/google/protobuf/compiler/cpp/cpp_generator.cc",
+ "src/google/protobuf/compiler/cpp/cpp_generator.h",
+ "src/google/protobuf/compiler/cpp/cpp_helpers.cc",
+ "src/google/protobuf/compiler/cpp/cpp_helpers.h",
+ "src/google/protobuf/compiler/cpp/cpp_map_field.cc",
+ "src/google/protobuf/compiler/cpp/cpp_map_field.h",
+ "src/google/protobuf/compiler/cpp/cpp_message.cc",
+ "src/google/protobuf/compiler/cpp/cpp_message.h",
+ "src/google/protobuf/compiler/cpp/cpp_message_field.cc",
+ "src/google/protobuf/compiler/cpp/cpp_message_field.h",
+ "src/google/protobuf/compiler/cpp/cpp_options.h",
+ "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
+ "src/google/protobuf/compiler/cpp/cpp_primitive_field.h",
+ "src/google/protobuf/compiler/cpp/cpp_service.cc",
+ "src/google/protobuf/compiler/cpp/cpp_service.h",
+ "src/google/protobuf/compiler/cpp/cpp_string_field.cc",
+ "src/google/protobuf/compiler/cpp/cpp_string_field.h",
+ "src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
+ "src/google/protobuf/compiler/csharp/csharp_doc_comment.h",
+ "src/google/protobuf/compiler/csharp/csharp_enum.cc",
+ "src/google/protobuf/compiler/csharp/csharp_enum.h",
+ "src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
+ "src/google/protobuf/compiler/csharp/csharp_enum_field.h",
+ "src/google/protobuf/compiler/csharp/csharp_field_base.cc",
+ "src/google/protobuf/compiler/csharp/csharp_field_base.h",
+ "src/google/protobuf/compiler/csharp/csharp_generator.cc",
+ "src/google/protobuf/compiler/csharp/csharp_generator.h",
+ "src/google/protobuf/compiler/csharp/csharp_helpers.cc",
+ "src/google/protobuf/compiler/csharp/csharp_helpers.h",
+ "src/google/protobuf/compiler/csharp/csharp_map_field.cc",
+ "src/google/protobuf/compiler/csharp/csharp_map_field.h",
+ "src/google/protobuf/compiler/csharp/csharp_message.cc",
+ "src/google/protobuf/compiler/csharp/csharp_message.h",
+ "src/google/protobuf/compiler/csharp/csharp_message_field.cc",
+ "src/google/protobuf/compiler/csharp/csharp_message_field.h",
+ "src/google/protobuf/compiler/csharp/csharp_options.h",
+ "src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
+ "src/google/protobuf/compiler/csharp/csharp_primitive_field.h",
+ "src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
+ "src/google/protobuf/compiler/csharp/csharp_reflection_class.h",
+ "src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
+ "src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h",
+ "src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
+ "src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h",
+ "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
+ "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h",
+ "src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
+ "src/google/protobuf/compiler/csharp/csharp_source_generator_base.h",
+ "src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
+ "src/google/protobuf/compiler/csharp/csharp_wrapper_field.h",
+ "src/google/protobuf/compiler/java/java_context.cc",
+ "src/google/protobuf/compiler/java/java_context.h",
+ "src/google/protobuf/compiler/java/java_doc_comment.cc",
+ "src/google/protobuf/compiler/java/java_doc_comment.h",
+ "src/google/protobuf/compiler/java/java_enum.cc",
+ "src/google/protobuf/compiler/java/java_enum.h",
+ "src/google/protobuf/compiler/java/java_enum_field.cc",
+ "src/google/protobuf/compiler/java/java_enum_field.h",
+ "src/google/protobuf/compiler/java/java_enum_field_lite.cc",
+ "src/google/protobuf/compiler/java/java_enum_field_lite.h",
+ "src/google/protobuf/compiler/java/java_enum_lite.cc",
+ "src/google/protobuf/compiler/java/java_enum_lite.h",
+ "src/google/protobuf/compiler/java/java_extension.cc",
+ "src/google/protobuf/compiler/java/java_extension.h",
+ "src/google/protobuf/compiler/java/java_extension_lite.cc",
+ "src/google/protobuf/compiler/java/java_extension_lite.h",
+ "src/google/protobuf/compiler/java/java_field.cc",
+ "src/google/protobuf/compiler/java/java_field.h",
+ "src/google/protobuf/compiler/java/java_file.cc",
+ "src/google/protobuf/compiler/java/java_file.h",
+ "src/google/protobuf/compiler/java/java_generator.cc",
+ "src/google/protobuf/compiler/java/java_generator.h",
+ "src/google/protobuf/compiler/java/java_generator_factory.cc",
+ "src/google/protobuf/compiler/java/java_generator_factory.h",
+ "src/google/protobuf/compiler/java/java_helpers.cc",
+ "src/google/protobuf/compiler/java/java_helpers.h",
+ "src/google/protobuf/compiler/java/java_lazy_message_field.cc",
+ "src/google/protobuf/compiler/java/java_lazy_message_field.h",
+ "src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc",
+ "src/google/protobuf/compiler/java/java_lazy_message_field_lite.h",
+ "src/google/protobuf/compiler/java/java_map_field.cc",
+ "src/google/protobuf/compiler/java/java_map_field.h",
+ "src/google/protobuf/compiler/java/java_map_field_lite.cc",
+ "src/google/protobuf/compiler/java/java_map_field_lite.h",
+ "src/google/protobuf/compiler/java/java_message.cc",
+ "src/google/protobuf/compiler/java/java_message.h",
+ "src/google/protobuf/compiler/java/java_message_builder.cc",
+ "src/google/protobuf/compiler/java/java_message_builder.h",
+ "src/google/protobuf/compiler/java/java_message_builder_lite.cc",
+ "src/google/protobuf/compiler/java/java_message_builder_lite.h",
+ "src/google/protobuf/compiler/java/java_message_field.cc",
+ "src/google/protobuf/compiler/java/java_message_field.h",
+ "src/google/protobuf/compiler/java/java_message_field_lite.cc",
+ "src/google/protobuf/compiler/java/java_message_field_lite.h",
+ "src/google/protobuf/compiler/java/java_message_lite.cc",
+ "src/google/protobuf/compiler/java/java_message_lite.h",
+ "src/google/protobuf/compiler/java/java_name_resolver.cc",
+ "src/google/protobuf/compiler/java/java_name_resolver.h",
+ "src/google/protobuf/compiler/java/java_primitive_field.cc",
+ "src/google/protobuf/compiler/java/java_primitive_field.h",
+ "src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
+ "src/google/protobuf/compiler/java/java_primitive_field_lite.h",
+ "src/google/protobuf/compiler/java/java_service.cc",
+ "src/google/protobuf/compiler/java/java_service.h",
+ "src/google/protobuf/compiler/java/java_shared_code_generator.cc",
+ "src/google/protobuf/compiler/java/java_shared_code_generator.h",
+ "src/google/protobuf/compiler/java/java_string_field.cc",
+ "src/google/protobuf/compiler/java/java_string_field.h",
+ "src/google/protobuf/compiler/java/java_string_field_lite.cc",
+ "src/google/protobuf/compiler/java/java_string_field_lite.h",
+ "src/google/protobuf/compiler/javanano/javanano_enum.cc",
+ "src/google/protobuf/compiler/javanano/javanano_enum.h",
+ "src/google/protobuf/compiler/javanano/javanano_enum_field.cc",
+ "src/google/protobuf/compiler/javanano/javanano_enum_field.h",
+ "src/google/protobuf/compiler/javanano/javanano_extension.cc",
+ "src/google/protobuf/compiler/javanano/javanano_extension.h",
+ "src/google/protobuf/compiler/javanano/javanano_field.cc",
+ "src/google/protobuf/compiler/javanano/javanano_field.h",
+ "src/google/protobuf/compiler/javanano/javanano_file.cc",
+ "src/google/protobuf/compiler/javanano/javanano_file.h",
+ "src/google/protobuf/compiler/javanano/javanano_generator.cc",
+ "src/google/protobuf/compiler/javanano/javanano_generator.h",
+ "src/google/protobuf/compiler/javanano/javanano_helpers.cc",
+ "src/google/protobuf/compiler/javanano/javanano_helpers.h",
+ "src/google/protobuf/compiler/javanano/javanano_map_field.cc",
+ "src/google/protobuf/compiler/javanano/javanano_map_field.h",
+ "src/google/protobuf/compiler/javanano/javanano_message.cc",
+ "src/google/protobuf/compiler/javanano/javanano_message.h",
+ "src/google/protobuf/compiler/javanano/javanano_message_field.cc",
+ "src/google/protobuf/compiler/javanano/javanano_message_field.h",
+ "src/google/protobuf/compiler/javanano/javanano_primitive_field.cc",
+ "src/google/protobuf/compiler/javanano/javanano_primitive_field.h",
+ "src/google/protobuf/compiler/js/js_generator.cc",
+ "src/google/protobuf/compiler/js/js_generator.h",
+ "src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_enum.h",
+ "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_enum_field.h",
+ "src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_extension.h",
+ "src/google/protobuf/compiler/objectivec/objectivec_field.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_field.h",
+ "src/google/protobuf/compiler/objectivec/objectivec_file.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_file.h",
+ "src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_generator.h",
+ "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_helpers.h",
+ "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_map_field.h",
+ "src/google/protobuf/compiler/objectivec/objectivec_message.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_message.h",
+ "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_message_field.h",
+ "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_oneof.h",
+ "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
+ "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h",
+ "src/google/protobuf/compiler/plugin.cc",
+ "src/google/protobuf/compiler/plugin.h",
+ "src/google/protobuf/compiler/plugin.pb.cc",
+ "src/google/protobuf/compiler/plugin.pb.h",
+ "src/google/protobuf/compiler/python/python_generator.cc",
+ "src/google/protobuf/compiler/python/python_generator.h",
+ "src/google/protobuf/compiler/ruby/ruby_generator.cc",
+ "src/google/protobuf/compiler/ruby/ruby_generator.h",
+ "src/google/protobuf/compiler/subprocess.cc",
+ "src/google/protobuf/compiler/subprocess.h",
+ "src/google/protobuf/compiler/zip_writer.cc",
+ "src/google/protobuf/compiler/zip_writer.h",
+ ]
+
+ configs -= [ "//build/config/compiler:chromium_code" ]
+ configs += [
+ "//build/config/compiler:no_chromium_code",
+
+ # Must be after no_chromium_code for warning flags to be ordered
+ # correctly.
+ ":protobuf_warnings",
+ ]
+ if (is_win) {
+ # This is defined internally, don't warn on duplicate.
+ configs -= [ "//build/config/win:lean_and_mean" ]
+ }
+
+ public_configs = [ ":protobuf_config" ]
+
+ cflags = protobuf_lite_cflags
+
+ public_deps = [
+ ":protobuf_full",
+ ]
+ }
+
+ executable("protoc") {
+ sources = [
+ "src/google/protobuf/compiler/main.cc",
+ ]
+
+ configs -= [ "//build/config/compiler:chromium_code" ]
+ configs += [ "//build/config/compiler:no_chromium_code" ]
+
+ cflags = protobuf_lite_cflags
+
+ deps = [
+ ":protoc_lib",
+
+ # Default manifest on Windows (a no-op elsewhere).
+ "//build/win:default_exe_manifest",
+ ]
+ }
+}
+
+google_python_dir = "$root_out_dir/pyproto/google"
+
+copy("copy_google") {
+ sources = [
+ "__init__.py",
+ ]
+ outputs = [
+ "$google_python_dir/{{source_file_part}}",
+ ]
+}
+
+copy("copy_six") {
+ sources = [
+ "third_party/six/six.py",
+ ]
+ outputs = [
+ "$google_python_dir/third_party/six/{{source_file_part}}",
+ ]
+}
+
+copy("copy_google_protobuf") {
+ sources = [
+ "python/google/protobuf/__init__.py",
+ "python/google/protobuf/descriptor.py",
+ "python/google/protobuf/descriptor_database.py",
+ "python/google/protobuf/descriptor_pool.py",
+ "python/google/protobuf/json_format.py",
+ "python/google/protobuf/message.py",
+ "python/google/protobuf/message_factory.py",
+ "python/google/protobuf/proto_builder.py",
+ "python/google/protobuf/reflection.py",
+ "python/google/protobuf/service.py",
+ "python/google/protobuf/service_reflection.py",
+ "python/google/protobuf/symbol_database.py",
+ "python/google/protobuf/text_encoding.py",
+ "python/google/protobuf/text_format.py",
+
+ # TODO(ncarter): protoc's python generator treats descriptor.proto
+ # specially, but only when the input path is exactly
+ # "google/protobuf/descriptor.proto". I'm not sure how to execute a rule
+ # from a different directory. For now, use a manually-generated copy of
+ # descriptor_pb2.py.
+ "python/google/protobuf/descriptor_pb2.py",
+ ]
+ outputs = [
+ "$google_python_dir/protobuf/{{source_file_part}}",
+ ]
+}
+
+copy("copy_google_protobuf_internal") {
+ sources = [
+ "python/google/protobuf/internal/__init__.py",
+ "python/google/protobuf/internal/_parameterized.py",
+ "python/google/protobuf/internal/api_implementation.py",
+ "python/google/protobuf/internal/containers.py",
+ "python/google/protobuf/internal/decoder.py",
+ "python/google/protobuf/internal/encoder.py",
+ "python/google/protobuf/internal/enum_type_wrapper.py",
+ "python/google/protobuf/internal/message_listener.py",
+ "python/google/protobuf/internal/python_message.py",
+ "python/google/protobuf/internal/type_checkers.py",
+ "python/google/protobuf/internal/well_known_types.py",
+ "python/google/protobuf/internal/wire_format.py",
+ ]
+ outputs = [
+ "$google_python_dir/protobuf/internal/{{source_file_part}}",
+ ]
+}
+
+group("py_proto") {
+ public_deps = [
+ ":copy_google",
+ ":copy_google_protobuf",
+ ":copy_google_protobuf_internal",
+ ":copy_six",
+ ]
+
+ # Targets that depend on this should depend on the copied data files.
+ data = get_target_outputs(":copy_google")
+ data += get_target_outputs(":copy_six")
+ data += get_target_outputs(":copy_google_protobuf")
+ data += get_target_outputs(":copy_google_protobuf_internal")
+}
diff --git a/src/third_party/protobuf-3/CHANGES.txt b/src/third_party/protobuf-3/CHANGES.txt
new file mode 100644
index 0000000..3459ccc
--- /dev/null
+++ b/src/third_party/protobuf-3/CHANGES.txt
@@ -0,0 +1,1182 @@
+2016-05-16 version 3.0.0-beta-3 (C++/Java/Python/Ruby/Nano/Objective-C/C#/JavaScript)
+ General
+ * Supported Proto3 lite-runtime in C++/Java for mobile platforms.
+ * Any type now supports APIs to specify prefixes other than
+ type.googleapis.com
+ * Removed javanano_use_deprecated_package option; Nano will always has its own
+ ".nano" package.
+
+ C++ (Beta)
+ * Improved hash maps.
+ - Improved hash maps comments. In particular, please note that equal hash
+ maps will not necessarily have the same iteration order and
+ serialization.
+ - Added a new hash maps implementation that will become the default in a
+ later release.
+ * Arenas
+ - Several inlined methods in Arena were moved to out-of-line to improve
+ build performance and code size.
+ - Added SpaceAllocatedAndUsed() to report both space used and allocated
+ - Added convenient class UnsafeArenaAllocatedRepeatedPtrFieldBackInserter
+ * Any
+ - Allow custom type URL prefixes in Any packing.
+ - TextFormat now expand the Any type rather than printing bytes.
+ * Performance optimizations and various bug fixes.
+
+ Java (Beta)
+ * Introduced an ExperimentalApi annotation. Annotated APIs are experimental
+ and are subject to change in a backward incompatible way in future releases.
+ * Introduced zero-copy serialization as an ExperimentalApi
+ - Introduction of the `ByteOutput` interface. This is similar to
+ `OutputStream` but provides semantics for lazy writing (i.e. no
+ immediate copy required) of fields that are considered to be immutable.
+ - `ByteString` now supports writing to a `ByteOutput`, which will directly
+ expose the internals of the `ByteString` (i.e. `byte[]` or `ByteBuffer`)
+ to the `ByteOutput` without copying.
+ - `CodedOutputStream` now supports writing to a `ByteOutput`. `ByteString`
+ instances that are too large to fit in the internal buffer will be
+ (lazily) written to the `ByteOutput` directly.
+ - This allows applications using large `ByteString` fields to avoid
+ duplication of these fields entirely. Such an application can supply a
+ `ByteOutput` that chains together the chunks received from
+ `CodedOutputStream` before forwarding them onto the IO system.
+ * Other related changes to `CodedOutputStream`
+ - Additional use of `sun.misc.Unsafe` where possible to perform fast
+ access to `byte[]` and `ByteBuffer` values and avoiding unnecessary
+ range checking.
+ - `ByteBuffer`-backed `CodedOutputStream` now writes directly to the
+ `ByteBuffer` rather than to an intermediate array.
+ * Improved lite-runtime.
+ - Lite protos now implement deep equals/hashCode/toString
+ - Significantly improved the performance of Builder#mergeFrom() and
+ Builder#mergeDelimitedFrom()
+ * Various bug fixes and small feature enhancement.
+ - Fixed stack overflow when in hashCode() for infinite recursive oneofs.
+ - Fixed the lazy field parsing in lite to merge rather than overwrite.
+ - TextFormat now supports reporting line/column numbers on errors.
+ - Updated to add appropriate @Override for better compiler errors.
+
+ Python (Beta)
+ * Added JSON format for Any, Struct, Value and ListValue
+ * [ ] is now accepted for both repeated scalar fields and repeated message
+ fields in text format parser.
+ * Numerical field name is now supported in text format.
+ * Added DiscardUnknownFields API for python protobuf message.
+
+ Objective-C (Beta)
+ * Proto comments now come over as HeaderDoc comments in the generated sources
+ so Xcode can pick them up and display them.
+ * The library headers have been updated to use HeaderDoc comments so Xcode can
+ pick them up and display them.
+ * The per message and per field overhead in both generated code and runtime
+ object sizes was reduced.
+ * Generated code now include deprecated annotations when the proto file
+ included them.
+
+ C# (Beta)
+ In general: some changes are breaking, which require regenerating messages.
+ Most user-written code will not be impacted *except* for the renaming of enum
+ values.
+
+ * Allow custom type URL prefixes in `Any` packing, and ignore them when
+ unpacking
+ * `protoc` is now in a separate NuGet package (Google.Protobuf.Tools)
+ * New option: `internal_access` to generate internal classes
+ * Enum values are now PascalCased, and if there's a prefix which matches the
+ name of the enum, that is removed (so an enum `COLOR` with a value
+ `COLOR_BLUE` would generate a value of just `Blue`). An option
+ (`legacy_enum_values`) is temporarily available to disable this, but the
+ option will be removed for GA.
+ * `json_name` option is now honored
+ * If group tags are encountered when parsing, they are validated more
+ thoroughly (although we don't support actual groups)
+ * NuGet dependencies are better specified
+ * Breaking: `Preconditions` is renamed to `ProtoPreconditions`
+ * Breaking: `GeneratedCodeInfo` is renamed to `GeneratedClrTypeInfo`
+ * `JsonFormatter` now allows writing to a `TextWriter`
+ * New interface, `ICustomDiagnosticMessage` to allow more compact
+ representations from `ToString`
+ * `CodedInputStream` and `CodedOutputStream` now implement `IDisposable`,
+ which simply disposes of the streams they were constructed with
+ * Map fields no longer support null values (in line with other languages)
+ * Improvements in JSON formatting and parsing
+
+ Javascript (Alpha)
+ * Better support for "bytes" fields: bytes fields can be read as either a
+ base64 string or UInt8Array (in environments where TypedArray is supported).
+ * New support for CommonJS imports. This should make it easier to use the
+ JavaScript support in Node.js and tools like WebPack. See js/README.md for
+ more information.
+ * Some significant internal refactoring to simplify and modularize the code.
+
+ Ruby (Alpha)
+ * JSON serialization now properly uses camelCased names, with a runtime option
+ that will preserve original names from .proto files instead.
+ * Well-known types are now included in the distribution.
+ * Release now includes binary gems for Windows, Mac, and Linux instead of just
+ source gems.
+ * Bugfix for serializing oneofs.
+
+ C++/Java Lite (Alpha)
+ A new "lite" generator parameter was introduced in the protoc for C++ and
+ Java for Proto3 syntax messages. Example usage:
+
+ ./protoc --cpp_out=lite:$OUTPUT_PATH foo.proto
+
+ The protoc will treat the current input and all the transitive dependencies
+ as LITE. The same generator parameter must be used to generate the
+ dependencies.
+
+ In Proto3 syntax files, "optimized_for=LITE_RUNTIME" is no longer supported.
+
+
+2015-12-30 version 3.0.0-beta-2 (C++/Java/Python/Ruby/Nano/Objective-C/C#/JavaScript)
+ General
+ * Introduced a new language implementation: JavaScript.
+ * Added a new field option "json_name". By default proto field names are
+ converted to "lowerCamelCase" in proto3 JSON format. This option can be
+ used to override this behavior and specify a different JSON name for the
+ field.
+ * Added conformance tests to ensure implementations are following proto3 JSON
+ specification.
+
+ C++ (Beta)
+ * Various bug fixes and improvements to the JSON support utility:
+ - Duplicate map keys in JSON are now rejected (i.e., translation will
+ fail).
+ - Fixed wire-format for google.protobuf.Value/ListValue.
+ - Fixed precision loss when converting google.protobuf.Timestamp.
+ - Fixed a bug when parsing invalid UTF-8 code points.
+ - Fixed a memory leak.
+ - Reduced call stack usage.
+
+ Java (Beta)
+ * Cleaned up some unused methods on CodedOutputStream.
+ * Presized lists for packed fields during parsing in the lite runtime to
+ reduce allocations and improve performance.
+ * Improved the performance of unknown fields in the lite runtime.
+ * Introduced UnsafeByteStrings to support zero-copy ByteString creation.
+ * Various bug fixes and improvements to the JSON support utility:
+ - Fixed a thread-safety bug.
+ - Added a new option “preservingProtoFieldNames” to JsonFormat.
+ - Added a new option “includingDefaultValueFields” to JsonFormat.
+ - Updated the JSON utility to comply with proto3 JSON specification.
+
+ Python (Beta)
+ * Added proto3 JSON format utility. It includes support for all field types
+ and a few well-known types except for Any and Struct.
+ * Added runtime support for Any, Timestamp, Duration and FieldMask.
+ * [ ] is now accepted for repeated scalar fields in text format parser.
+ * Map fields now have proper O(1) performance for lookup/insert/delete
+ when using the Python/C++ implementation. They were previously using O(n)
+ search-based algorithms because the C++ reflection interface didn't
+ support true map operations.
+
+ Objective-C (Beta)
+ * Various bug-fixes and code tweaks to pass more strict compiler warnings.
+ * Now has conformance test coverage and is passing all tests.
+
+ C# (Beta)
+ * Various bug-fixes.
+ * Code generation: Files generated in directories based on namespace.
+ * Code generation: Include comments from .proto files in XML doc
+ comments (naively)
+ * Code generation: Change organization/naming of "reflection class" (access
+ to file descriptor)
+ * Code generation and library: Add Parser property to MessageDescriptor,
+ and introduce a non-generic parser type.
+ * Library: Added TypeRegistry to support JSON parsing/formatting of Any.
+ * Library: Added Any.Pack/Unpack support.
+ * Library: Implemented JSON parsing.
+
+ Javascript (Alpha)
+ * Added proto3 support for JavaScript. The runtime is written in pure
+ JavaScript and works in browsers and in Node.js. To generate JavaScript
+ code for your proto, invoke protoc with "--js_out". See js/README.md
+ for more build instructions.
+
+2015-08-26 version 3.0.0-beta-1 (C++/Java/Python/Ruby/Nano/Objective-C/C#)
+ About Beta
+ * This is the first beta release of protobuf v3.0.0. Not all languages
+ have reached beta stage. Languages not marked as beta are still in
+ alpha (i.e., be prepared for API breaking changes).
+
+ General
+ * Proto3 JSON is supported in several languages (fully supported in C++
+ and Java, partially supported in Ruby/C#). The JSON spec is defined in
+ the proto3 language guide:
+
+ https://developers.google.com/protocol-buffers/docs/proto3#json
+
+ We will publish a more detailed spec to define the exact behavior of
+ proto3-conformant JSON serializers and parsers. Until then, do not rely
+ on specific behaviors of the implementation if it’s not documented in
+ the above spec. More specifically, the behavior is not yet finalized for
+ the following:
+ - Parsing invalid JSON input (e.g., input with trailing commas).
+ - Non-camelCase names in JSON input.
+ - The same field appears multiple times in JSON input.
+ - JSON arrays contain “null” values.
+ - The message has unknown fields.
+
+ * Proto3 now enforces strict UTF-8 checking. Parsing will fail if a string
+ field contains non UTF-8 data.
+
+ C++ (Beta)
+ * Introduced new utility functions/classes in the google/protobuf/util
+ directory:
+ - MessageDifferencer: compare two proto messages and report their
+ difference