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) {
- JSCDerivedG