blob: 967933d63c2f25605cfb2dcc6f7d7cfb9bf59276 [file] [log] [blame]
/*
* Copyright 2016 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// This file has been auto-generated by bindings/code_generator_cobalt.py. DO NOT MODIFY!
// Auto-generated from template: bindings/javascriptcore/templates/interface.cc.template
// clang-format off
#include "third_party/WebKit/Source/JavaScriptCore/config.h"
#include "JSCWindow.h"
#include "base/debug/trace_event.h"
#include "cobalt/base/polymorphic_downcast.h"
#include "cobalt/script/global_environment.h"
#include "cobalt/script/opaque_handle.h"
#include "cobalt/script/script_object.h"
#include "JSCAnonymousIndexedGetterInterface.h"
#include "JSCAnonymousNamedGetterInterface.h"
#include "JSCAnonymousNamedIndexedGetterInterface.h"
#include "JSCArbitraryInterface.h"
#include "JSCBaseInterface.h"
#include "JSCBooleanTypeTestInterface.h"
#include "JSCCallbackFunctionInterface.h"
#include "JSCCallbackInterfaceInterface.h"
#include "JSCConditionalInterface.h"
#include "JSCConstantsInterface.h"
#include "JSCConstructorInterface.h"
#include "JSCConstructorWithArgumentsInterface.h"
#include "JSCDOMStringTestInterface.h"
#include "JSCDerivedGetterSetterInterface.h"
#include "JSCDerivedInterface.h"
#include "JSCDisabledInterface.h"
#include "JSCEnumerationInterface.h"
#include "JSCExceptionObjectInterface.h"
#include "JSCExceptionsInterface.h"
#include "JSCExtendedIDLAttributesInterface.h"
#include "JSCGarbageCollectionTestInterface.h"
#include "JSCGetOpaqueRootInterface.h"
#include "JSCGlobalInterfaceParent.h"
#include "JSCImplementedInterface.h"
#include "JSCIndexedGetterInterface.h"
#include "JSCInterfaceWithUnsupportedProperties.h"
#include "JSCNamedConstructorInterface.h"
#include "JSCNamedGetterInterface.h"
#include "JSCNamedIndexedGetterInterface.h"
#include "JSCNestedPutForwardsInterface.h"
#include "JSCNoConstructorInterface.h"
#include "JSCNoInterfaceObjectInterface.h"
#include "JSCNullableTypesTestInterface.h"
#include "JSCNumericTypesTestInterface.h"
#include "JSCObjectTypeBindingsInterface.h"
#include "JSCOperationsTestInterface.h"
#include "JSCPutForwardsInterface.h"
#include "JSCSingleOperationInterface.h"
#include "JSCStaticPropertiesInterface.h"
#include "JSCStringifierAnonymousOperationInterface.h"
#include "JSCStringifierAttributeInterface.h"
#include "JSCStringifierOperationInterface.h"
#include "JSCTargetInterface.h"
#include "JSCUnionTypesInterface.h"
#include "JSCWindow.h"
#include "cobalt/bindings/testing/anonymous_indexed_getter_interface.h"
#include "cobalt/bindings/testing/anonymous_named_getter_interface.h"
#include "cobalt/bindings/testing/anonymous_named_indexed_getter_interface.h"
#include "cobalt/bindings/testing/arbitrary_interface.h"
#include "cobalt/bindings/testing/base_interface.h"
#include "cobalt/bindings/testing/boolean_type_test_interface.h"
#include "cobalt/bindings/testing/callback_function_interface.h"
#include "cobalt/bindings/testing/callback_interface_interface.h"
#include "cobalt/bindings/testing/conditional_interface.h"
#include "cobalt/bindings/testing/constants_interface.h"
#include "cobalt/bindings/testing/constructor_interface.h"
#include "cobalt/bindings/testing/constructor_with_arguments_interface.h"
#include "cobalt/bindings/testing/derived_getter_setter_interface.h"
#include "cobalt/bindings/testing/derived_interface.h"
#include "cobalt/bindings/testing/disabled_interface.h"
#include "cobalt/bindings/testing/dom_string_test_interface.h"
#include "cobalt/bindings/testing/enumeration_interface.h"
#include "cobalt/bindings/testing/exception_object_interface.h"
#include "cobalt/bindings/testing/exceptions_interface.h"
#include "cobalt/bindings/testing/extended_idl_attributes_interface.h"
#include "cobalt/bindings/testing/garbage_collection_test_interface.h"
#include "cobalt/bindings/testing/get_opaque_root_interface.h"
#include "cobalt/bindings/testing/global_interface_parent.h"
#include "cobalt/bindings/testing/implemented_interface.h"
#include "cobalt/bindings/testing/indexed_getter_interface.h"
#include "cobalt/bindings/testing/interface_with_unsupported_properties.h"
#include "cobalt/bindings/testing/named_constructor_interface.h"
#include "cobalt/bindings/testing/named_getter_interface.h"
#include "cobalt/bindings/testing/named_indexed_getter_interface.h"
#include "cobalt/bindings/testing/nested_put_forwards_interface.h"
#include "cobalt/bindings/testing/no_constructor_interface.h"
#include "cobalt/bindings/testing/no_interface_object_interface.h"
#include "cobalt/bindings/testing/nullable_types_test_interface.h"
#include "cobalt/bindings/testing/numeric_types_test_interface.h"
#include "cobalt/bindings/testing/object_type_bindings_interface.h"
#include "cobalt/bindings/testing/operations_test_interface.h"
#include "cobalt/bindings/testing/put_forwards_interface.h"
#include "cobalt/bindings/testing/single_operation_interface.h"
#include "cobalt/bindings/testing/static_properties_interface.h"
#include "cobalt/bindings/testing/stringifier_anonymous_operation_interface.h"
#include "cobalt/bindings/testing/stringifier_attribute_interface.h"
#include "cobalt/bindings/testing/stringifier_operation_interface.h"
#include "cobalt/bindings/testing/target_interface.h"
#include "cobalt/bindings/testing/union_types_interface.h"
#include "cobalt/bindings/testing/window.h"
#include "cobalt/script/javascriptcore/constructor_base.h"
#include "cobalt/script/javascriptcore/conversion_helpers.h"
#include "cobalt/script/javascriptcore/prototype_base.h"
#include "cobalt/script/javascriptcore/jsc_callback_function.h"
#include "cobalt/script/javascriptcore/jsc_callback_interface_holder.h"
#include "cobalt/script/javascriptcore/jsc_exception_state.h"
#include "cobalt/script/javascriptcore/jsc_global_environment.h"
#include "cobalt/script/javascriptcore/jsc_global_object.h"
#include "cobalt/script/javascriptcore/jsc_object_handle.h"
#include "cobalt/script/javascriptcore/jsc_object_handle_holder.h"
#include "cobalt/script/javascriptcore/type_traits.h"
#include "cobalt/script/javascriptcore/util/binding_helpers.h"
#include "cobalt/script/javascriptcore/util/exception_helpers.h"
#include "third_party/WebKit/Source/JavaScriptCore/interpreter/Interpreter.h"
#include "third_party/WebKit/Source/JavaScriptCore/runtime/Error.h"
#include "third_party/WebKit/Source/JavaScriptCore/runtime/FunctionPrototype.h"
#include "third_party/WebKit/Source/JavaScriptCore/runtime/Identifier.h"
#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSFunction.h"
#include "third_party/WebKit/Source/JavaScriptCore/runtime/JSGlobalObject.h"
#include "third_party/WebKit/Source/JavaScriptCore/runtime/ObjectPrototype.h"
namespace {
using cobalt::bindings::testing::Window;
using cobalt::bindings::testing::JSCWindow;
using cobalt::bindings::testing::AnonymousIndexedGetterInterface;
using cobalt::bindings::testing::AnonymousNamedGetterInterface;
using cobalt::bindings::testing::AnonymousNamedIndexedGetterInterface;
using cobalt::bindings::testing::ArbitraryInterface;
using cobalt::bindings::testing::BaseInterface;
using cobalt::bindings::testing::BooleanTypeTestInterface;
using cobalt::bindings::testing::CallbackFunctionInterface;
using cobalt::bindings::testing::CallbackInterfaceInterface;
#if defined(ENABLE_CONDITIONAL_INTERFACE)
using cobalt::bindings::testing::ConditionalInterface;
#endif // defined(ENABLE_CONDITIONAL_INTERFACE)
using cobalt::bindings::testing::ConstantsInterface;
using cobalt::bindings::testing::ConstructorInterface;
using cobalt::bindings::testing::ConstructorWithArgumentsInterface;
using cobalt::bindings::testing::DOMStringTestInterface;
using cobalt::bindings::testing::DerivedGetterSetterInterface;
using cobalt::bindings::testing::DerivedInterface;
#if defined(NO_ENABLE_CONDITIONAL_INTERFACE)
using cobalt::bindings::testing::DisabledInterface;
#endif // defined(NO_ENABLE_CONDITIONAL_INTERFACE)
using cobalt::bindings::testing::EnumerationInterface;
using cobalt::bindings::testing::ExceptionObjectInterface;
using cobalt::bindings::testing::ExceptionsInterface;
using cobalt::bindings::testing::ExtendedIDLAttributesInterface;
using cobalt::bindings::testing::GarbageCollectionTestInterface;
using cobalt::bindings::testing::GetOpaqueRootInterface;
using cobalt::bindings::testing::GlobalInterfaceParent;
using cobalt::bindings::testing::ImplementedInterface;
using cobalt::bindings::testing::IndexedGetterInterface;
using cobalt::bindings::testing::InterfaceWithUnsupportedProperties;
using cobalt::bindings::testing::JSCAnonymousIndexedGetterInterface;
using cobalt::bindings::testing::JSCAnonymousNamedGetterInterface;
using cobalt::bindings::testing::JSCAnonymousNamedIndexedGetterInterface;
using cobalt::bindings::testing::JSCArbitraryInterface;
using cobalt::bindings::testing::JSCBaseInterface;
using cobalt::bindings::testing::JSCBooleanTypeTestInterface;
using cobalt::bindings::testing::JSCCallbackFunctionInterface;
using cobalt::bindings::testing::JSCCallbackInterfaceInterface;
#if defined(ENABLE_CONDITIONAL_INTERFACE)
using cobalt::bindings::testing::JSCConditionalInterface;
#endif // defined(ENABLE_CONDITIONAL_INTERFACE)
using cobalt::bindings::testing::JSCConstantsInterface;
using cobalt::bindings::testing::JSCConstructorInterface;
using cobalt::bindings::testing::JSCConstructorWithArgumentsInterface;
using cobalt::bindings::testing::JSCDOMStringTestInterface;
using cobalt::bindings::testing::JSCDerivedGetterSetterInterface;
using cobalt::bindings::testing::JSCDerivedInterface;
#if defined(NO_ENABLE_CONDITIONAL_INTERFACE)
using cobalt::bindings::testing::JSCDisabledInterface;
#endif // defined(NO_ENABLE_CONDITIONAL_INTERFACE)
using cobalt::bindings::testing::JSCEnumerationInterface;
using cobalt::bindings::testing::JSCExceptionObjectInterface;
using cobalt::bindings::testing::JSCExceptionsInterface;
using cobalt::bindings::testing::JSCExtendedIDLAttributesInterface;
using cobalt::bindings::testing::JSCGarbageCollectionTestInterface;
using cobalt::bindings::testing::JSCGetOpaqueRootInterface;
using cobalt::bindings::testing::JSCGlobalInterfaceParent;
using cobalt::bindings::testing::JSCImplementedInterface;
using cobalt::bindings::testing::JSCIndexedGetterInterface;
using cobalt::bindings::testing::JSCInterfaceWithUnsupportedProperties;
using cobalt::bindings::testing::JSCNamedConstructorInterface;
using cobalt::bindings::testing::JSCNamedGetterInterface;
using cobalt::bindings::testing::JSCNamedIndexedGetterInterface;
using cobalt::bindings::testing::JSCNestedPutForwardsInterface;
using cobalt::bindings::testing::JSCNoConstructorInterface;
using cobalt::bindings::testing::JSCNoInterfaceObjectInterface;
using cobalt::bindings::testing::JSCNullableTypesTestInterface;
using cobalt::bindings::testing::JSCNumericTypesTestInterface;
using cobalt::bindings::testing::JSCObjectTypeBindingsInterface;
using cobalt::bindings::testing::JSCOperationsTestInterface;
using cobalt::bindings::testing::JSCPutForwardsInterface;
using cobalt::bindings::testing::JSCSingleOperationInterface;
using cobalt::bindings::testing::JSCStaticPropertiesInterface;
using cobalt::bindings::testing::JSCStringifierAnonymousOperationInterface;
using cobalt::bindings::testing::JSCStringifierAttributeInterface;
using cobalt::bindings::testing::JSCStringifierOperationInterface;
using cobalt::bindings::testing::JSCTargetInterface;
using cobalt::bindings::testing::JSCUnionTypesInterface;
using cobalt::bindings::testing::JSCWindow;
using cobalt::bindings::testing::NamedConstructorInterface;
using cobalt::bindings::testing::NamedGetterInterface;
using cobalt::bindings::testing::NamedIndexedGetterInterface;
using cobalt::bindings::testing::NestedPutForwardsInterface;
using cobalt::bindings::testing::NoConstructorInterface;
using cobalt::bindings::testing::NoInterfaceObjectInterface;
using cobalt::bindings::testing::NullableTypesTestInterface;
using cobalt::bindings::testing::NumericTypesTestInterface;
using cobalt::bindings::testing::ObjectTypeBindingsInterface;
using cobalt::bindings::testing::OperationsTestInterface;
using cobalt::bindings::testing::PutForwardsInterface;
using cobalt::bindings::testing::SingleOperationInterface;
using cobalt::bindings::testing::StaticPropertiesInterface;
using cobalt::bindings::testing::StringifierAnonymousOperationInterface;
using cobalt::bindings::testing::StringifierAttributeInterface;
using cobalt::bindings::testing::StringifierOperationInterface;
using cobalt::bindings::testing::TargetInterface;
using cobalt::bindings::testing::UnionTypesInterface;
using cobalt::bindings::testing::Window;
using cobalt::script::CallbackInterfaceTraits;
using cobalt::script::GlobalEnvironment;
using cobalt::script::OpaqueHandle;
using cobalt::script::OpaqueHandleHolder;
using cobalt::script::ScriptObject;
using cobalt::script::Wrappable;
using cobalt::script::javascriptcore::kConversionFlagNullable;
using cobalt::script::javascriptcore::kConversionFlagRestricted;
using cobalt::script::javascriptcore::kConversionFlagTreatNullAsEmptyString;
using cobalt::script::javascriptcore::kConversionFlagTreatUndefinedAsEmptyString;
using cobalt::script::javascriptcore::kNoConversionFlags;
using cobalt::script::javascriptcore::ConstructorBase;
using cobalt::script::javascriptcore::GetWrappableOrSetException;
using cobalt::script::javascriptcore::FromJSValue;
using cobalt::script::javascriptcore::FromWTFString;
using cobalt::script::javascriptcore::JSCCallbackFunction;
using cobalt::script::javascriptcore::JSCCallbackFunctionHolder;
using cobalt::script::javascriptcore::JSCCallbackInterfaceHolder;
using cobalt::script::javascriptcore::JSCEngine;
using cobalt::script::javascriptcore::JSCExceptionState;
using cobalt::script::javascriptcore::JSCGlobalEnvironment;
using cobalt::script::javascriptcore::JSCGlobalObject;
using cobalt::script::javascriptcore::JSCObjectHandle;
using cobalt::script::javascriptcore::JSCObjectHandleHolder;
using cobalt::script::javascriptcore::JSObjectToWrappable;
using cobalt::script::javascriptcore::PrototypeBase;
using cobalt::script::javascriptcore::ScriptObjectRegistry;
using cobalt::script::javascriptcore::ThreadLocalHashTable;
using cobalt::script::javascriptcore::ToJSValue;
using cobalt::script::javascriptcore::ToWTFString;
using cobalt::script::javascriptcore::TypeTraits;
using cobalt::script::javascriptcore::WrapperBase;
using cobalt::script::javascriptcore::util::HasPropertyOnPrototype;
using cobalt::script::javascriptcore::util::GetStackTrace;
} // namespace
namespace cobalt {
namespace bindings {
namespace testing {
namespace {
JSC::JSValue getJSwindowProperty(
JSC::ExecState* exec_state,
JSC::JSValue slot_base,
JSC::PropertyName property_name);
void setJSwindowProperty(
JSC::ExecState* exec,
JSC::JSObject* this_object,
JSC::JSValue value);
JSC::JSValue getJSwindow(
JSC::ExecState* exec_state,
JSC::JSValue slot_base,
JSC::PropertyName property_name);
JSC::EncodedJSValue functionJSgetStackTrace(JSC::ExecState*);
JSC::EncodedJSValue functionJSwindowOperation(JSC::ExecState*);
// These are declared unconditionally, but only defined if needed by the
// interface.
JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
JSC::JSValue slot_base, JSC::PropertyName property_name);
void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
JSC::PropertyName property_name, JSC::JSValue jsc_value);
bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
JSC::PropertyName property_name);
bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
JSC::PropertyName property_name);
JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
JSC::JSValue slot_base, JSC::PropertyName property_name);
bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
JSC::PropertyName property_name, JSC::JSValue value);
const bool s_has_named_getter = false;
const bool s_has_named_setter = false;
#if !defined(COBALT_BUILD_TYPE_GOLD)
const bool s_use_debug_missing_property_handler = false;
#else
const bool s_use_debug_missing_property_handler = false;
#endif
} // namespace
// Class that defines a JS Object representing this interface's Interface Object
// https://www.w3.org/TR/WebIDL/#interface-object
class JSCWindow::InterfaceObject : public ConstructorBase {
public:
// Get the Interface Object. Will create a new Interface Object if necessary,
// otherwise it will return the cached one.
static JSC::JSObject* GetInstance(JSC::ExecState* exec);
DECLARE_CLASSINFO();
// Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
// Must be public so that it can be accessible from getStaticValueSlot<>.
static bool getOwnPropertySlot(JSC::JSCell* cell, JSC::ExecState* exec,
JSC::PropertyName property_name,
JSC::PropertySlot& slot) {
InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
// Same process as JSC::getStaticPropertySlot<>, which is defined in Lookup.h
// Since JSFunction::getOwnPropertySlot is protected, we can't call it from
// the helper function.
const JSC::HashEntry* entry =
GetPropertyTable(exec)->entry(exec, property_name);
if (!entry) // not found, forward to parent
return Base::getOwnPropertySlot(this_object, exec, property_name, slot);
if (entry->attributes() & JSC::Function)
return setUpStaticFunctionSlot(exec, entry, this_object, property_name, slot);
slot.setCacheableCustom(this_object, entry->propertyGetter());
return true;
}
// static override. Needed to support setting a property.
static void put(JSC::JSCell* cell, JSC::ExecState* exec_state,
JSC::PropertyName property_name, JSC::JSValue value,
JSC::PutPropertySlot& slot) {
InterfaceObject* this_object = JSC::jsCast<InterfaceObject*>(cell);
ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
bool found_property = JSC::lookupPut<InterfaceObject>(
exec_state, property_name, value, GetPropertyTable(exec_state),
this_object, slot.isStrictMode());
DLOG_IF(INFO, !found_property) << "Did not find property named " <<
WTF::String(property_name.publicName()).utf8().data() <<
" to set on interface object for JSCWindow";
if (!found_property) {
BaseClass::put(cell, exec_state, property_name, value, slot);
}
}
// static override. This prevents this object from being called as a normal
// function, throwing a TypeError if the user attempts to do so.
static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&) {
return JSC::CallTypeNone;
}
// static override. This prevents this object from being called as a
// constructor, throwing a TypeError if the user attempts to do so.
//
// This method is defined when no constructors are defined on the IDL.
static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&) {
return JSC::ConstructTypeNone;
}
private:
typedef ConstructorBase BaseClass;
static const unsigned StructureFlags =
JSC::ImplementsHasInstance |
JSC::OverridesGetOwnPropertySlot |
BaseClass::StructureFlags;
InterfaceObject(JSC::ExecState* exec_state, JSC::JSGlobalObject* global_object, JSC::Structure* structure)
: BaseClass(exec_state, global_object, structure) { }
void finishCreation(JSC::ExecState* exec_state,
JSC::NativeExecutable* native_executable, int length,
const String& name);
static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
static const JSC::HashTableValue property_table_values[];
static const JSC::HashTable property_table_prototype;
};
const JSC::HashTableValue JSCWindow::InterfaceObject::property_table_values[] = {
// static functions will also go here.
{ 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
}; // JSCWindow::InterfaceObject::property_table_values
// static
const JSC::HashTable
JSCWindow::InterfaceObject::property_table_prototype = {
// Sizes will be calculated based on the number of static functions as well.
2, // compactSize
1, // compactSizeMask
property_table_values,
NULL // table allocated at runtime
}; // JSCWindow::InterfaceObject::property_table_prototype
// static
const JSC::HashTable*
JSCWindow::InterfaceObject::GetPropertyTable(
JSC::ExecState* exec_state) {
return ThreadLocalHashTable::GetInstance()->GetHashTable(
JSCWindow::InterfaceObject::s_classinfo(),
property_table_prototype);
}
const JSC::ClassInfo JSCWindow::InterfaceObject::s_info = {
"WindowConstructor", // className
BaseClass::s_classinfo(), // parentClass
NULL, // static hash-table of properties (not used)
GetPropertyTable, // function pointer to get hash-table of properties
CREATE_METHOD_TABLE(JSCWindow::InterfaceObject)
}; // JSCWindow::InterfaceObject::s_info
void JSCWindow::InterfaceObject::finishCreation(
JSC::ExecState* exec_state, JSC::NativeExecutable* native_executable,
int length, const String& name) {
BaseClass::finishCreation(exec_state, native_executable, length, name);
ASSERT(inherits(&s_info));
// Add a 'prototype' property whose value is the prototype object.
putDirect(exec_state->globalData(),
exec_state->propertyNames().prototype,
JSCWindow::GetPrototype(exec_state->lexicalGlobalObject()),
JSC::DontDelete | JSC::ReadOnly | JSC::DontEnum);
DCHECK(hasOwnProperty(exec_state, JSC::Identifier(exec_state, "prototype")));
}
// static
JSC::JSObject* JSCWindow::InterfaceObject::GetInstance(
JSC::ExecState* exec_state) {
JSCGlobalObject* global_object =
static_cast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
// Try to get the cached interface object, and create a new one if needed.
JSC::JSObject* interface_object = global_object->object_cache()->GetCachedConstructor(&s_info);
if (interface_object == NULL) {
JSC::JSGlobalData& global_data = global_object->globalData();
JSC::JSObject* parent_prototype = global_object->functionPrototype();
JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
JSC::Structure* structure = JSC::Structure::create(
global_data,
global_object,
JSC::JSValue(parent_prototype),
type_info,
&s_info);
const int kNumArguments = 0;
// NativeExecutable must be non-null even if this is not actually callable.
JSC::NativeExecutable* executable = global_data.getHostFunction(NULL, NULL);
// Create the new interface object.
InterfaceObject* new_interface_object =
new (NotNull, JSC::allocateCell<InterfaceObject>(global_data.heap))
InterfaceObject(exec_state, global_object, structure);
new_interface_object->finishCreation(exec_state, executable, kNumArguments, "Window");
// Add the interface object to the cache.
global_object->object_cache()->CacheConstructor(&s_info, new_interface_object);
interface_object = new_interface_object;
}
DCHECK_EQ(global_object->object_cache()->GetCachedConstructor(&s_info), interface_object);
return interface_object;
}
// End of JSCWindow::InterfaceObject class
// Class that defines a JS Object representing this interface's prototype
class JSCWindow::Prototype : public PrototypeBase {
public:
// Get the prototype. Will create a new prototype if necessary, otherwise it
// will return a cached prototype.
static JSC::JSObject* GetInstance(JSC::JSGlobalObject* global_object);
DECLARE_CLASSINFO();
// Needed when JSC::OverridesGetOwnPropertySlot StructureFlag is set
// Must be public so that it can be accessible from getStaticValueSlot<>.
static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*,
JSC::PropertyName,
JSC::PropertySlot&);
private:
typedef PrototypeBase BaseClass;
static const unsigned StructureFlags =
JSC::OverridesGetOwnPropertySlot |
BaseClass::StructureFlags;
Prototype(JSC::JSGlobalObject* global_object, JSC::Structure* structure)
: BaseClass(global_object, structure) { }
static JSC::JSValue GetConstructor(JSC::ExecState* exec_state,
JSC::JSValue slot_base,
JSC::PropertyName property_name);
static const JSC::HashTable* GetPropertyTable(JSC::ExecState* exec_state);
static const JSC::HashTableValue property_table_values[];
static const JSC::HashTable property_table_prototype;
};
const JSC::HashTableValue JSCWindow::Prototype::property_table_values[] = {
{ "constructor",
JSC::DontDelete | JSC::DontEnum,
reinterpret_cast<intptr_t>(JSCWindow::Prototype::GetConstructor),
static_cast<intptr_t>(0),
JSC::NoIntrinsic
},
{ 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
}; // JSCWindow::Prototype::property_table_values
// static
const JSC::HashTable JSCWindow::Prototype::property_table_prototype = {
4, // compactSize
3, // compactSizeMask
property_table_values,
NULL // table allocated at runtime
}; // JSCWindow::Prototype::property_table_prototype
// static
const JSC::HashTable* JSCWindow::Prototype::GetPropertyTable(
JSC::ExecState* exec_state) {
return ThreadLocalHashTable::GetInstance()->GetHashTable(
JSCWindow::Prototype::s_classinfo(), property_table_prototype);
}
const JSC::ClassInfo JSCWindow::Prototype::s_info = {
"WindowPrototype", // className
BaseClass::s_classinfo(), // parentClass
NULL, // static hash-table of properties (not used)
GetPropertyTable, // function pointer to get hash-table of properties
CREATE_METHOD_TABLE(JSCWindow::Prototype)
}; // JSCWindow::Prototype::s_info
// Look up property slot for querying property values.
bool JSCWindow::Prototype::getOwnPropertySlot(JSC::JSCell* cell,
JSC::ExecState* exec, JSC::PropertyName property_name,
JSC::PropertySlot& slot) {
Prototype* this_object = JSC::jsCast<Prototype*>(cell);
ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
return JSC::getStaticPropertySlot<Prototype, JSC::JSObject>(
exec, GetPropertyTable(exec), this_object, property_name, slot);
}
// static
JSC::JSObject* JSCWindow::Prototype::GetInstance(
JSC::JSGlobalObject* base_global_object) {
JSCGlobalObject* global_object =
static_cast<JSCGlobalObject*>(base_global_object);
ASSERT_GC_OBJECT_INHERITS(global_object, JSCGlobalObject::s_classinfo());
// Try to get the cached prototype, and create a new one if needed.
JSC::JSObject* prototype = global_object->object_cache()->GetCachedPrototype(&s_info);
if (prototype == NULL) {
JSC::JSGlobalData& global_data = global_object->globalData();
JSC::JSLockHolder lock(&global_data);
JSC::JSObject* parent_prototype =
bindings::testing::JSCGlobalInterfaceParent::GetPrototype(global_object);
JSC::TypeInfo type_info(JSC::ObjectType, StructureFlags);
JSC::Structure* structure = JSC::Structure::create(
global_data,
global_object,
JSC::JSValue(parent_prototype),
type_info,
&s_info);
// Create the new prototype object.
Prototype* new_prototype =
new (NotNull, JSC::allocateCell<Prototype>(
global_data.heap))
Prototype(global_object, structure);
new_prototype->finishCreation(global_data);
// Add the prototype to the cache.
global_object->object_cache()->CachePrototype(&s_info, new_prototype);
prototype = new_prototype;
}
DCHECK_EQ(global_object->object_cache()->GetCachedPrototype(&s_info), prototype);
return prototype;
}
// End of JSCWindow::Prototype class
const JSC::HashTableValue JSCWindow::property_table_values[] = {
{ "windowProperty",
JSC::DontDelete ,
reinterpret_cast<intptr_t>(getJSwindowProperty),
reinterpret_cast<intptr_t>(setJSwindowProperty),
JSC::NoIntrinsic
},
{ "window",
JSC::DontDelete | JSC::ReadOnly,
reinterpret_cast<intptr_t>(getJSwindow),
0,
JSC::NoIntrinsic
},
{ "getStackTrace",
JSC::DontDelete | JSC::Function,
reinterpret_cast<intptr_t>(functionJSgetStackTrace),
static_cast<intptr_t>(0),
JSC::NoIntrinsic
},
{ "windowOperation",
JSC::DontDelete | JSC::Function,
reinterpret_cast<intptr_t>(functionJSwindowOperation),
static_cast<intptr_t>(0),
JSC::NoIntrinsic
},
{ 0, 0, 0, 0, static_cast<JSC::Intrinsic>(0) }
}; // JSCWindow::property_table_values
// static
const JSC::HashTable JSCWindow::property_table_prototype = {
19, // compactSize
15, // compactSizeMask
property_table_values,
NULL // table allocated at runtime
}; // JSCWindow::property_table_prototype
// static
const JSC::HashTable* JSCWindow::GetPropertyTable(
JSC::ExecState* exec_state) {
return ThreadLocalHashTable::GetInstance()->GetHashTable(
JSCWindow::s_classinfo(), property_table_prototype);
}
#ifdef __LB_SHELL__FORCE_LOGGING__
base::LazyInstance<JSCWindow::NonTrivialStaticFields>
JSCWindow::non_trivial_static_fields = LAZY_INSTANCE_INITIALIZER;
#endif // __LB_SHELL__FORCE_LOGGING__
const JSC::ClassInfo JSCWindow::s_info = {
"Window", // className
BaseClass::s_classinfo(), // parentClass
NULL, // static hash-table of properties (not used)
GetPropertyTable, // function pointer to get hash-table of properties
CREATE_METHOD_TABLE(JSCWindow)
}; // JSCWindow::s_info
// static
JSC::JSObject* JSCWindow::GetPrototype(
JSC::JSGlobalObject* global_object) {
return Prototype::GetInstance(global_object);
}
// static
JSC::JSObject* JSCWindow::GetConstructor(
JSC::ExecState* exec_state) {
return InterfaceObject::GetInstance(exec_state);
}
// static
JSC::JSValue JSCWindow::Prototype::GetConstructor(
JSC::ExecState* exec_state,
JSC::JSValue slot_base,
JSC::PropertyName property_name) {
return JSC::JSValue(InterfaceObject::GetInstance(exec_state));
}
// static
script::javascriptcore::JSCGlobalObject* JSCWindow::Create(
const scoped_refptr<Window>& global_interface,
script::EnvironmentSettings* environment_settings,
JSC::JSGlobalData* global_data,
ScriptObjectRegistry* script_object_registry) {
scoped_ptr<script::javascriptcore::WrapperFactory> wrapper_factory =
make_scoped_ptr(new script::javascriptcore::WrapperFactory());
wrapper_factory->RegisterWrappableType(
AnonymousIndexedGetterInterface::AnonymousIndexedGetterInterfaceWrappableType(),
JSCAnonymousIndexedGetterInterface::s_classinfo(),
JSCAnonymousIndexedGetterInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
AnonymousNamedGetterInterface::AnonymousNamedGetterInterfaceWrappableType(),
JSCAnonymousNamedGetterInterface::s_classinfo(),
JSCAnonymousNamedGetterInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
AnonymousNamedIndexedGetterInterface::AnonymousNamedIndexedGetterInterfaceWrappableType(),
JSCAnonymousNamedIndexedGetterInterface::s_classinfo(),
JSCAnonymousNamedIndexedGetterInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
ArbitraryInterface::ArbitraryInterfaceWrappableType(),
JSCArbitraryInterface::s_classinfo(),
JSCArbitraryInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
BaseInterface::BaseInterfaceWrappableType(),
JSCBaseInterface::s_classinfo(),
JSCBaseInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
BooleanTypeTestInterface::BooleanTypeTestInterfaceWrappableType(),
JSCBooleanTypeTestInterface::s_classinfo(),
JSCBooleanTypeTestInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
CallbackFunctionInterface::CallbackFunctionInterfaceWrappableType(),
JSCCallbackFunctionInterface::s_classinfo(),
JSCCallbackFunctionInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
CallbackInterfaceInterface::CallbackInterfaceInterfaceWrappableType(),
JSCCallbackInterfaceInterface::s_classinfo(),
JSCCallbackInterfaceInterface::GetCreateWrapperFunction());
#if defined(ENABLE_CONDITIONAL_INTERFACE)
wrapper_factory->RegisterWrappableType(
ConditionalInterface::ConditionalInterfaceWrappableType(),
JSCConditionalInterface::s_classinfo(),
JSCConditionalInterface::GetCreateWrapperFunction());
#endif // defined(ENABLE_CONDITIONAL_INTERFACE)
wrapper_factory->RegisterWrappableType(
ConstantsInterface::ConstantsInterfaceWrappableType(),
JSCConstantsInterface::s_classinfo(),
JSCConstantsInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
ConstructorInterface::ConstructorInterfaceWrappableType(),
JSCConstructorInterface::s_classinfo(),
JSCConstructorInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
ConstructorWithArgumentsInterface::ConstructorWithArgumentsInterfaceWrappableType(),
JSCConstructorWithArgumentsInterface::s_classinfo(),
JSCConstructorWithArgumentsInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
DOMStringTestInterface::DOMStringTestInterfaceWrappableType(),
JSCDOMStringTestInterface::s_classinfo(),
JSCDOMStringTestInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
DerivedGetterSetterInterface::DerivedGetterSetterInterfaceWrappableType(),
JSCDerivedGetterSetterInterface::s_classinfo(),
JSCDerivedGetterSetterInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
DerivedInterface::DerivedInterfaceWrappableType(),
JSCDerivedInterface::s_classinfo(),
JSCDerivedInterface::GetCreateWrapperFunction());
#if defined(NO_ENABLE_CONDITIONAL_INTERFACE)
wrapper_factory->RegisterWrappableType(
DisabledInterface::DisabledInterfaceWrappableType(),
JSCDisabledInterface::s_classinfo(),
JSCDisabledInterface::GetCreateWrapperFunction());
#endif // defined(NO_ENABLE_CONDITIONAL_INTERFACE)
wrapper_factory->RegisterWrappableType(
EnumerationInterface::EnumerationInterfaceWrappableType(),
JSCEnumerationInterface::s_classinfo(),
JSCEnumerationInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
ExceptionObjectInterface::ExceptionObjectInterfaceWrappableType(),
JSCExceptionObjectInterface::s_classinfo(),
JSCExceptionObjectInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
ExceptionsInterface::ExceptionsInterfaceWrappableType(),
JSCExceptionsInterface::s_classinfo(),
JSCExceptionsInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
ExtendedIDLAttributesInterface::ExtendedIDLAttributesInterfaceWrappableType(),
JSCExtendedIDLAttributesInterface::s_classinfo(),
JSCExtendedIDLAttributesInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
GarbageCollectionTestInterface::GarbageCollectionTestInterfaceWrappableType(),
JSCGarbageCollectionTestInterface::s_classinfo(),
JSCGarbageCollectionTestInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
GetOpaqueRootInterface::GetOpaqueRootInterfaceWrappableType(),
JSCGetOpaqueRootInterface::s_classinfo(),
JSCGetOpaqueRootInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
GlobalInterfaceParent::GlobalInterfaceParentWrappableType(),
JSCGlobalInterfaceParent::s_classinfo(),
JSCGlobalInterfaceParent::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
ImplementedInterface::ImplementedInterfaceWrappableType(),
JSCImplementedInterface::s_classinfo(),
JSCImplementedInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
IndexedGetterInterface::IndexedGetterInterfaceWrappableType(),
JSCIndexedGetterInterface::s_classinfo(),
JSCIndexedGetterInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
InterfaceWithUnsupportedProperties::InterfaceWithUnsupportedPropertiesWrappableType(),
JSCInterfaceWithUnsupportedProperties::s_classinfo(),
JSCInterfaceWithUnsupportedProperties::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
NamedConstructorInterface::NamedConstructorInterfaceWrappableType(),
JSCNamedConstructorInterface::s_classinfo(),
JSCNamedConstructorInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
NamedGetterInterface::NamedGetterInterfaceWrappableType(),
JSCNamedGetterInterface::s_classinfo(),
JSCNamedGetterInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
NamedIndexedGetterInterface::NamedIndexedGetterInterfaceWrappableType(),
JSCNamedIndexedGetterInterface::s_classinfo(),
JSCNamedIndexedGetterInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
NestedPutForwardsInterface::NestedPutForwardsInterfaceWrappableType(),
JSCNestedPutForwardsInterface::s_classinfo(),
JSCNestedPutForwardsInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
NoConstructorInterface::NoConstructorInterfaceWrappableType(),
JSCNoConstructorInterface::s_classinfo(),
JSCNoConstructorInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
NoInterfaceObjectInterface::NoInterfaceObjectInterfaceWrappableType(),
JSCNoInterfaceObjectInterface::s_classinfo(),
JSCNoInterfaceObjectInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
NullableTypesTestInterface::NullableTypesTestInterfaceWrappableType(),
JSCNullableTypesTestInterface::s_classinfo(),
JSCNullableTypesTestInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
NumericTypesTestInterface::NumericTypesTestInterfaceWrappableType(),
JSCNumericTypesTestInterface::s_classinfo(),
JSCNumericTypesTestInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
ObjectTypeBindingsInterface::ObjectTypeBindingsInterfaceWrappableType(),
JSCObjectTypeBindingsInterface::s_classinfo(),
JSCObjectTypeBindingsInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
OperationsTestInterface::OperationsTestInterfaceWrappableType(),
JSCOperationsTestInterface::s_classinfo(),
JSCOperationsTestInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
PutForwardsInterface::PutForwardsInterfaceWrappableType(),
JSCPutForwardsInterface::s_classinfo(),
JSCPutForwardsInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
StaticPropertiesInterface::StaticPropertiesInterfaceWrappableType(),
JSCStaticPropertiesInterface::s_classinfo(),
JSCStaticPropertiesInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
StringifierAnonymousOperationInterface::StringifierAnonymousOperationInterfaceWrappableType(),
JSCStringifierAnonymousOperationInterface::s_classinfo(),
JSCStringifierAnonymousOperationInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
StringifierAttributeInterface::StringifierAttributeInterfaceWrappableType(),
JSCStringifierAttributeInterface::s_classinfo(),
JSCStringifierAttributeInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
StringifierOperationInterface::StringifierOperationInterfaceWrappableType(),
JSCStringifierOperationInterface::s_classinfo(),
JSCStringifierOperationInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
TargetInterface::TargetInterfaceWrappableType(),
JSCTargetInterface::s_classinfo(),
JSCTargetInterface::GetCreateWrapperFunction());
wrapper_factory->RegisterWrappableType(
UnionTypesInterface::UnionTypesInterfaceWrappableType(),
JSCUnionTypesInterface::s_classinfo(),
JSCUnionTypesInterface::GetCreateWrapperFunction());
JSC::JSLockHolder lock(global_data);
JSC::Structure* structure = JSC::Structure::create(
*global_data,
NULL, // JSC::JSGlobalObject*
JSC::jsNull(), // prototype
JSC::TypeInfo(JSC::GlobalObjectType, StructureFlags),
&s_info);
JSCWindow* global_wrapper =
new (NotNull, JSC::allocateCell<JSCWindow>(global_data->heap))
JSCWindow(
global_data,
structure,
script_object_registry,
wrapper_factory.Pass(),
environment_settings,
global_interface);
global_wrapper->finishCreation(*global_data);
global_data->heap.addFinalizer(global_wrapper, JSCWindow::destroy);
global_wrapper->setPrototype(
global_wrapper->globalData(),
JSCWindow::GetPrototype(global_wrapper));
return global_wrapper;
}
JSCWindow::JSCWindow(
JSC::JSGlobalData* global_data,
JSC::Structure* structure,
ScriptObjectRegistry* script_object_registry,
scoped_ptr<script::javascriptcore::WrapperFactory> wrapper_factory,
script::EnvironmentSettings* environment_settings,
const scoped_refptr<Window>& impl)
: BaseClass(global_data, structure, script_object_registry, impl,
wrapper_factory.Pass(), environment_settings) {
}
void JSCWindow::finishCreation(JSC::JSGlobalData& global_data) {
BaseClass::finishCreation(global_data);
DCHECK(inherits(&s_info));
}
JSCWindow::~JSCWindow() {
// Empty destructor
}
// Look up property slot for querying property values.
bool JSCWindow::getOwnPropertySlot(JSC::JSCell* cell,
JSC::ExecState* exec, JSC::PropertyName property_name,
JSC::PropertySlot& slot) {
JSCWindow* this_object = JSC::jsCast<JSCWindow*>(cell);
ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
// Global interface may have both operations and properties as own properties
// so we cannot use getStaticValueSlot.
bool found_property_slot = JSC::getStaticPropertySlot<JSCWindow, BaseClass>(
exec, GetPropertyTable(exec), this_object, property_name, slot);
if (s_has_named_getter || s_use_debug_missing_property_handler) {
bool found_property_on_prototype_chain = false;
if (!found_property_slot && cell->isObject()) {
JSC::JSValue prototype_value = JSC::asObject(cell)->prototype();
if (prototype_value.isObject()) {
JSC::JSObject* prototype = JSC::asObject(prototype_value);
found_property_on_prototype_chain =
prototype->hasProperty(exec, property_name);
}
}
if (s_has_named_getter) {
if (!found_property_slot && !found_property_on_prototype_chain) {
if (QueryNamedProperty(this_object, exec, property_name)) {
slot.setCustom(cell, &NamedPropertyGetter);
found_property_slot = true;
}
}
}
if (s_use_debug_missing_property_handler) {
// The property was not found as an own-property, nor was it found on the
// prototype chain, so set the missing property handler to be called
// when getting this property value.
if (!found_property_slot && !found_property_on_prototype_chain) {
slot.setCustom(cell, &OnGetMissingProperty);
found_property_slot = true;
}
}
}
return found_property_slot;
}
// Look up property slot and put the |value|.
void JSCWindow::put(JSC::JSCell* cell, JSC::ExecState* exec,
JSC::PropertyName property_name, JSC::JSValue value,
JSC::PutPropertySlot& slot) {
JSCWindow* this_object = JSC::jsCast<JSCWindow*>(cell);
ASSERT_GC_OBJECT_INHERITS(this_object, &s_info);
bool property_handled = false;
if (s_has_named_setter || s_use_debug_missing_property_handler) {
// Need to look up the property manually.
bool has_property = HasOwnPropertyOrPrototypeProperty(
cell, exec, property_name);
if (s_has_named_setter) {
// We didn't find the property on the object or prototype chain, so
// set or create a new named property.
if (!has_property) {
std::string property_name_utf8 = FromWTFString(property_name.publicName());
NamedPropertySetter(cell, exec, property_name, value);
property_handled = true;
}
}
if (s_use_debug_missing_property_handler) {
if (!has_property && !property_handled) {
property_handled = OnSetMissingProperty(cell, exec, property_name, value);
}
}
}
if (!property_handled) {
JSC::lookupPut<JSCWindow, BaseClass>(
exec, property_name, value, GetPropertyTable(exec), this_object, slot);
}
}
bool JSCWindow::HasOwnPropertyOrPrototypeProperty(
JSC::JSCell* cell, JSC::ExecState* exec_state,
JSC::PropertyName property_name) {
JSCWindow* this_object = JSC::jsCast<JSCWindow*>(cell);
JSC::PropertySlot lookup_slot;
bool has_property = JSC::getStaticPropertySlot<JSCWindow, BaseClass>(
exec_state, GetPropertyTable(exec_state), this_object, property_name,
lookup_slot);
return has_property || HasPropertyOnPrototype(exec_state, cell, property_name);
}
namespace {
JSC::JSValue getJSwindowProperty(
JSC::ExecState* exec_state,
JSC::JSValue slot_base,
JSC::PropertyName property_name) {
TRACE_EVENT0("JSCWindow", "get windowProperty");
JSCGlobalObject* global_object =
JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
Window* impl =
GetWrappableOrSetException<Window>(exec_state, slot_base);
if (!impl) {
return exec_state->exception();
}
JSC::JSValue result = ToJSValue(
global_object,
impl->window_property());
return result;
}
void setJSwindowProperty(
JSC::ExecState* exec_state,
JSC::JSObject* this_object,
JSC::JSValue value) {
TRACE_EVENT0("JSCWindow", "set windowProperty");
JSCGlobalObject* global_object =
JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
JSCExceptionState exception_state(global_object);
Window* impl =
GetWrappableOrSetException<Window>(exec_state, this_object);
if (!impl) {
return;
}
TypeTraits<std::string >::ConversionType cobalt_value;
FromJSValue(exec_state, value,
kNoConversionFlags, &exception_state,
&cobalt_value);
if (exception_state.is_exception_set()) {
JSC::throwError(exec_state, exception_state.exception_object());
return;
}
// Check if argument conversion raised an exception.
if (!exec_state->hadException()) {
impl->set_window_property(cobalt_value);
}
}
JSC::JSValue getJSwindow(
JSC::ExecState* exec_state,
JSC::JSValue slot_base,
JSC::PropertyName property_name) {
TRACE_EVENT0("JSCWindow", "get window");
JSCGlobalObject* global_object =
JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
Window* impl =
GetWrappableOrSetException<Window>(exec_state, slot_base);
if (!impl) {
return exec_state->exception();
}
JSC::JSValue result = ToJSValue(
global_object,
impl->window());
return result;
}
JSC::EncodedJSValue functionJSgetStackTrace(
JSC::ExecState* exec_state) {
TRACE_EVENT0("JSCWindow", "call getStackTrace");
JSCGlobalObject* global_object =
JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
JSCExceptionState exception_state(global_object);
JSC::JSObject* this_object =
exec_state->hostThisValue().toThisObject(exec_state);
Window* impl =
GetWrappableOrSetException<Window>(exec_state, this_object);
if (!impl) {
return JSC::JSValue::encode(exec_state->exception());
}
TypeTraits<std::string >::ReturnType return_value = impl->GetStackTrace(global_object->GetStackTrace());
return JSC::JSValue::encode(ToJSValue(global_object, return_value));
}
JSC::EncodedJSValue functionJSwindowOperation(
JSC::ExecState* exec_state) {
TRACE_EVENT0("JSCWindow", "call windowOperation");
JSCGlobalObject* global_object =
JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
JSCExceptionState exception_state(global_object);
JSC::JSObject* this_object =
exec_state->hostThisValue().toThisObject(exec_state);
Window* impl =
GetWrappableOrSetException<Window>(exec_state, this_object);
if (!impl) {
return JSC::JSValue::encode(exec_state->exception());
}
impl->WindowOperation();
return JSC::JSValue::encode(JSC::jsUndefined());
}
JSC::JSValue NamedPropertyGetter(JSC::ExecState* exec_state,
JSC::JSValue slot_base, JSC::PropertyName property_name) {
NOTREACHED();
return JSC::jsUndefined();
}
bool QueryNamedProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
JSC::PropertyName property_name) {
NOTREACHED();
return false;
}
void NamedPropertySetter(JSC::JSCell* cell, JSC::ExecState* exec_state,
JSC::PropertyName property_name, JSC::JSValue jsc_value) {
NOTREACHED();
}
bool NamedPropertyDeleter(JSC::JSCell* cell, JSC::ExecState* exec_state,
JSC::PropertyName property_name) {
return false;
}
#if !defined(COBALT_BUILD_TYPE_GOLD)
JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
JSC::JSValue slot_base, JSC::PropertyName property_name) {
JSCGlobalObject* global_object =
JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
JSC::JSValue callable = global_object->get(
exec_state, JSC::Identifier(exec_state, "__onGetMissingProperty"));
if (!callable.isUndefined()) {
JSC::CallData call_data;
JSC::CallType call_type = JSC::getCallData(callable, call_data);
if (call_type != JSC::CallTypeNone) {
// The function called __onGetMissingProperty exists, so call this and
// return the result as the value for this property.
JSC::MarkedArgumentBuffer args;
args.append(slot_base);
args.append(JSC::JSValue(
JSC::JSString::create(
global_object->globalData(), property_name.publicName())));
JSC::JSValue retval = JSC::call(
exec_state, callable, call_type, call_data, global_object, args);
return retval;
}
}
return JSC::jsUndefined();
}
bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
JSC::PropertyName property_name, JSC::JSValue value) {
JSCGlobalObject* global_object =
JSC::jsCast<JSCGlobalObject*>(exec_state->lexicalGlobalObject());
JSC::JSValue callable = global_object->get(
exec_state, JSC::Identifier(exec_state, "__onSetMissingProperty"));
if (!callable.isUndefined()) {
JSC::CallData call_data;
JSC::CallType call_type = JSC::getCallData(callable, call_data);
if (call_type != JSC::CallTypeNone) {
// The function called __onSetMissingProperty exists, so call this with
// the value to be set. The missing property handler returns true if it
// has handled the setting of this property.
JSC::MarkedArgumentBuffer args;
args.append(cell);
args.append(JSC::JSValue(
JSC::JSString::create(
global_object->globalData(), property_name.publicName())));
args.append(value);
JSC::JSValue retval = JSC::call(
exec_state, callable, call_type, call_data, global_object, args);
return retval.toBoolean(exec_state);
}
}
return false;
}
#else
JSC::JSValue OnGetMissingProperty(JSC::ExecState* exec_state,
JSC::JSValue slot_base, JSC::PropertyName property_name) {
NOTREACHED();
return JSC::jsUndefined();
}
bool OnSetMissingProperty(JSC::JSCell* cell, JSC::ExecState* exec_state,
JSC::PropertyName property_name, JSC::JSValue value) {
NOTREACHED();
return false;
}
#endif
} // namespace
} // namespace testing
} // namespace bindings
namespace script {
template<>
void GlobalEnvironment::CreateGlobalObject<Window>(
const scoped_refptr<Window>& global_interface,
EnvironmentSettings* environment_settings) {
JSCGlobalEnvironment* jsc_global_environment =
base::polymorphic_downcast<JSCGlobalEnvironment*>(this);
JSCEngine* jsc_engine = jsc_global_environment->engine();
JSCGlobalObject* global_object = JSCWindow::Create(
global_interface, environment_settings,
jsc_engine->global_data(), jsc_engine->script_object_registry());
jsc_global_environment->SetGlobalObject(global_object);
}
// MSVS compiler does not need this explicit instantiation, and generates a
// compiler error.
#if !defined(_MSC_VER)
// Explicitly instantiate the template function for template type Window
// This is needed to prevent link errors when trying to resolve the template
// instantiation.
template
void GlobalEnvironment::CreateGlobalObject<Window>(
const scoped_refptr<Window>& global_interface,
EnvironmentSettings* environment_settings);
#endif
} // namespace script
} // namespace cobalt