| /* |
| This file is part of the WebKit open source project. |
| This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
| |
| This library is free software; you can redistribute it and/or |
| modify it under the terms of the GNU Library General Public |
| License as published by the Free Software Foundation; either |
| version 2 of the License, or (at your option) any later version. |
| |
| This library is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| Library General Public License for more details. |
| |
| You should have received a copy of the GNU Library General Public License |
| along with this library; see the file COPYING.LIB. If not, write to |
| the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| Boston, MA 02110-1301, USA. |
| */ |
| |
| #include "config.h" |
| #include "JSFile.h" |
| |
| #include "JSDOMBinding.h" |
| #include "JSDOMConstructor.h" |
| #include "URL.h" |
| #include <runtime/JSString.h> |
| #include <wtf/GetPtr.h> |
| |
| using namespace JSC; |
| |
| namespace WebCore { |
| |
| // Attributes |
| |
| JSC::EncodedJSValue jsFileName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsFileLastModified(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsFileConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSFileConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| |
| class JSFilePrototype : public JSC::JSNonFinalObject { |
| public: |
| typedef JSC::JSNonFinalObject Base; |
| static JSFilePrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) |
| { |
| JSFilePrototype* ptr = new (NotNull, JSC::allocateCell<JSFilePrototype>(vm.heap)) JSFilePrototype(vm, globalObject, structure); |
| ptr->finishCreation(vm); |
| return ptr; |
| } |
| |
| DECLARE_INFO; |
| static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| { |
| return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| } |
| |
| private: |
| JSFilePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| : JSC::JSNonFinalObject(vm, structure) |
| { |
| } |
| |
| void finishCreation(JSC::VM&); |
| }; |
| |
| typedef JSDOMConstructor<JSFile> JSFileConstructor; |
| |
| template<> JSC::EncodedJSValue JSC_HOST_CALL JSFileConstructor::construct(JSC::ExecState* exec) |
| { |
| ASSERT(exec); |
| return constructJSFile(*exec); |
| } |
| |
| template<> JSValue JSFileConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| { |
| return JSBlob::getConstructor(vm, &globalObject); |
| } |
| |
| template<> void JSFileConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| { |
| putDirect(vm, vm.propertyNames->prototype, JSFile::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("File"))), ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->length, jsNumber(2), ReadOnly | DontEnum); |
| } |
| |
| template<> const ClassInfo JSFileConstructor::s_info = { "File", &Base::s_info, 0, CREATE_METHOD_TABLE(JSFileConstructor) }; |
| |
| /* Hash table for prototype */ |
| |
| static const HashTableValue JSFilePrototypeTableValues[] = |
| { |
| { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSFileConstructor) } }, |
| { "name", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "lastModified", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileLastModified), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| }; |
| |
| const ClassInfo JSFilePrototype::s_info = { "FilePrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSFilePrototype) }; |
| |
| void JSFilePrototype::finishCreation(VM& vm) |
| { |
| Base::finishCreation(vm); |
| reifyStaticProperties(vm, JSFilePrototypeTableValues, *this); |
| } |
| |
| const ClassInfo JSFile::s_info = { "File", &Base::s_info, 0, CREATE_METHOD_TABLE(JSFile) }; |
| |
| JSFile::JSFile(Structure* structure, JSDOMGlobalObject& globalObject, Ref<File>&& impl) |
| : JSBlob(structure, globalObject, WTFMove(impl)) |
| { |
| } |
| |
| JSObject* JSFile::createPrototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return JSFilePrototype::create(vm, globalObject, JSFilePrototype::createStructure(vm, globalObject, JSBlob::prototype(vm, globalObject))); |
| } |
| |
| JSObject* JSFile::prototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return getDOMPrototype<JSFile>(vm, globalObject); |
| } |
| |
| EncodedJSValue jsFileName(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSFile*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "File", "name"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.name()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsFileLastModified(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSFile*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "File", "lastModified"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsNumber(impl.lastModified()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsFileConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSFilePrototype* domObject = jsDynamicCast<JSFilePrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) |
| return throwVMTypeError(state, throwScope); |
| return JSValue::encode(JSFile::getConstructor(state->vm(), domObject->globalObject())); |
| } |
| |
| bool setJSFileConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSValue value = JSValue::decode(encodedValue); |
| JSFilePrototype* domObject = jsDynamicCast<JSFilePrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) { |
| throwVMTypeError(state, throwScope); |
| return false; |
| } |
| // Shadowing a built-in constructor |
| return domObject->putDirect(state->vm(), state->propertyNames().constructor, value); |
| } |
| |
| JSValue JSFile::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| { |
| return getDOMConstructor<JSFileConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| } |
| |
| #if ENABLE(BINDING_INTEGRITY) |
| #if PLATFORM(WIN) |
| #pragma warning(disable: 4483) |
| extern "C" { extern void (*const __identifier("??_7File@WebCore@@6B@")[])(); } |
| #else |
| extern "C" { extern void* _ZTVN7WebCore4FileE[]; } |
| #endif |
| #endif |
| |
| JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<File>&& impl) |
| { |
| |
| #if ENABLE(BINDING_INTEGRITY) |
| void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| #if PLATFORM(WIN) |
| void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7File@WebCore@@6B@")); |
| #else |
| void* expectedVTablePointer = &_ZTVN7WebCore4FileE[2]; |
| #if COMPILER(CLANG) |
| // If this fails File does not have a vtable, so you need to add the |
| // ImplementationLacksVTable attribute to the interface definition |
| static_assert(__is_polymorphic(File), "File is not polymorphic"); |
| #endif |
| #endif |
| // If you hit this assertion you either have a use after free bug, or |
| // File has subclasses. If File has subclasses that get passed |
| // to toJS() we currently require File you to opt out of binding hardening |
| // by adding the SkipVTableValidation attribute to the interface IDL definition |
| RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| #endif |
| return createWrapper<File>(globalObject, WTFMove(impl)); |
| } |
| |
| JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, File& impl) |
| { |
| return wrap(state, globalObject, impl); |
| } |
| |
| File* JSFile::toWrapped(JSC::JSValue value) |
| { |
| if (auto* wrapper = jsDynamicCast<JSFile*>(value)) |
| return &wrapper->wrapped(); |
| return nullptr; |
| } |
| |
| } |