2 This file is part of the WebKit open source project.
3 This file has been generated by generate-bindings.pl. DO NOT MODIFY!
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 #include "JSClipboard.h"
24 #include "Clipboard.h"
25 #include "ExceptionCode.h"
27 #include "JSDOMBinding.h"
28 #include "JSFileList.h"
30 #include <runtime/Error.h>
31 #include <wtf/GetPtr.h>
33 #if ENABLE(DATA_TRANSFER_ITEMS)
34 #include "DataTransferItemList.h"
35 #include "JSDataTransferItemList.h"
42 ASSERT_CLASS_FITS_IN_CELL(JSClipboard);
46 #define THUNK_GENERATOR(generator) , generator
48 #define THUNK_GENERATOR(generator)
51 #define INTRINSIC(intrinsic) , intrinsic
53 #define INTRINSIC(intrinsic)
56 static const HashTableValue JSClipboardTableValues[] =
58 { "dropEffect", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsClipboardDropEffect), (intptr_t)setJSClipboardDropEffect THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
59 { "effectAllowed", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsClipboardEffectAllowed), (intptr_t)setJSClipboardEffectAllowed THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
60 { "types", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsClipboardTypes), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
61 { "files", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsClipboardFiles), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
62 #if ENABLE(DATA_TRANSFER_ITEMS)
63 { "items", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsClipboardItems), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
65 { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsClipboardConstructor), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
66 { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
69 #undef THUNK_GENERATOR
70 static const HashTable JSClipboardTable = { 17, 15, JSClipboardTableValues, 0 };
71 /* Hash table for constructor */
73 #define THUNK_GENERATOR(generator) , generator
75 #define THUNK_GENERATOR(generator)
78 #define INTRINSIC(intrinsic) , intrinsic
80 #define INTRINSIC(intrinsic)
83 static const HashTableValue JSClipboardConstructorTableValues[] =
85 { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
88 #undef THUNK_GENERATOR
89 static const HashTable JSClipboardConstructorTable = { 1, 0, JSClipboardConstructorTableValues, 0 };
90 const ClassInfo JSClipboardConstructor::s_info = { "ClipboardConstructor", &DOMConstructorObject::s_info, &JSClipboardConstructorTable, 0, CREATE_METHOD_TABLE(JSClipboardConstructor) };
92 JSClipboardConstructor::JSClipboardConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
93 : DOMConstructorObject(structure, globalObject)
97 void JSClipboardConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
99 Base::finishCreation(exec->globalData());
100 ASSERT(inherits(&s_info));
101 putDirect(exec->globalData(), exec->propertyNames().prototype, JSClipboardPrototype::self(exec, globalObject), DontDelete | ReadOnly);
104 bool JSClipboardConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
106 return getStaticValueSlot<JSClipboardConstructor, JSDOMWrapper>(exec, &JSClipboardConstructorTable, static_cast<JSClipboardConstructor*>(cell), propertyName, slot);
109 bool JSClipboardConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
111 return getStaticValueDescriptor<JSClipboardConstructor, JSDOMWrapper>(exec, &JSClipboardConstructorTable, static_cast<JSClipboardConstructor*>(object), propertyName, descriptor);
114 /* Hash table for prototype */
116 #define THUNK_GENERATOR(generator) , generator
118 #define THUNK_GENERATOR(generator)
121 #define INTRINSIC(intrinsic) , intrinsic
123 #define INTRINSIC(intrinsic)
126 static const HashTableValue JSClipboardPrototypeTableValues[] =
128 { "clearData", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsClipboardPrototypeFunctionClearData), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
129 { "getData", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsClipboardPrototypeFunctionGetData), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
130 { "setData", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsClipboardPrototypeFunctionSetData), (intptr_t)2 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
131 { "setDragImage", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsClipboardPrototypeFunctionSetDragImage), (intptr_t)3 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
132 { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
135 #undef THUNK_GENERATOR
136 static const HashTable JSClipboardPrototypeTable = { 8, 7, JSClipboardPrototypeTableValues, 0 };
137 const ClassInfo JSClipboardPrototype::s_info = { "ClipboardPrototype", &JSC::JSNonFinalObject::s_info, &JSClipboardPrototypeTable, 0, CREATE_METHOD_TABLE(JSClipboardPrototype) };
139 JSObject* JSClipboardPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
141 return getDOMPrototype<JSClipboard>(exec, globalObject);
144 bool JSClipboardPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
146 JSClipboardPrototype* thisObject = jsCast<JSClipboardPrototype*>(cell);
147 return getStaticFunctionSlot<JSObject>(exec, &JSClipboardPrototypeTable, thisObject, propertyName, slot);
150 bool JSClipboardPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
152 JSClipboardPrototype* thisObject = jsCast<JSClipboardPrototype*>(object);
153 return getStaticFunctionDescriptor<JSObject>(exec, &JSClipboardPrototypeTable, thisObject, propertyName, descriptor);
156 const ClassInfo JSClipboard::s_info = { "Clipboard", &JSDOMWrapper::s_info, &JSClipboardTable, 0 , CREATE_METHOD_TABLE(JSClipboard) };
158 JSClipboard::JSClipboard(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<Clipboard> impl)
159 : JSDOMWrapper(structure, globalObject)
160 , m_impl(impl.leakRef())
164 void JSClipboard::finishCreation(JSGlobalData& globalData)
166 Base::finishCreation(globalData);
167 ASSERT(inherits(&s_info));
170 JSObject* JSClipboard::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
172 return JSClipboardPrototype::create(exec->globalData(), globalObject, JSClipboardPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
175 bool JSClipboard::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
177 JSClipboard* thisObject = jsCast<JSClipboard*>(cell);
178 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
179 return getStaticValueSlot<JSClipboard, Base>(exec, &JSClipboardTable, thisObject, propertyName, slot);
182 bool JSClipboard::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
184 JSClipboard* thisObject = jsCast<JSClipboard*>(object);
185 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
186 return getStaticValueDescriptor<JSClipboard, Base>(exec, &JSClipboardTable, thisObject, propertyName, descriptor);
189 JSValue jsClipboardDropEffect(ExecState* exec, JSValue slotBase, const Identifier&)
191 JSClipboard* castedThis = static_cast<JSClipboard*>(asObject(slotBase));
193 Clipboard* imp = static_cast<Clipboard*>(castedThis->impl());
194 JSValue result = jsStringOrUndefined(exec, imp->dropEffect());
199 JSValue jsClipboardEffectAllowed(ExecState* exec, JSValue slotBase, const Identifier&)
201 JSClipboard* castedThis = static_cast<JSClipboard*>(asObject(slotBase));
203 Clipboard* imp = static_cast<Clipboard*>(castedThis->impl());
204 JSValue result = jsStringOrUndefined(exec, imp->effectAllowed());
209 JSValue jsClipboardTypes(ExecState* exec, JSValue slotBase, const Identifier&)
211 JSClipboard* castedThis = static_cast<JSClipboard*>(asObject(slotBase));
212 return castedThis->types(exec);
216 JSValue jsClipboardFiles(ExecState* exec, JSValue slotBase, const Identifier&)
218 JSClipboard* castedThis = static_cast<JSClipboard*>(asObject(slotBase));
220 Clipboard* imp = static_cast<Clipboard*>(castedThis->impl());
221 JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->files()));
226 #if ENABLE(DATA_TRANSFER_ITEMS)
227 JSValue jsClipboardItems(ExecState* exec, JSValue slotBase, const Identifier&)
229 JSClipboard* castedThis = static_cast<JSClipboard*>(asObject(slotBase));
231 Clipboard* imp = static_cast<Clipboard*>(castedThis->impl());
232 JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->items()));
238 JSValue jsClipboardConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
240 JSClipboard* domObject = static_cast<JSClipboard*>(asObject(slotBase));
241 return JSClipboard::getConstructor(exec, domObject->globalObject());
244 void JSClipboard::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
246 JSClipboard* thisObject = jsCast<JSClipboard*>(cell);
247 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
248 lookupPut<JSClipboard, Base>(exec, propertyName, value, &JSClipboardTable, thisObject, slot);
251 void setJSClipboardDropEffect(ExecState* exec, JSObject* thisObject, JSValue value)
253 JSClipboard* castedThis = static_cast<JSClipboard*>(thisObject);
254 Clipboard* imp = static_cast<Clipboard*>(castedThis->impl());
255 imp->setDropEffect(ustringToString(value.isEmpty() ? UString() : value.toString(exec)));
259 void setJSClipboardEffectAllowed(ExecState* exec, JSObject* thisObject, JSValue value)
261 JSClipboard* castedThis = static_cast<JSClipboard*>(thisObject);
262 Clipboard* imp = static_cast<Clipboard*>(castedThis->impl());
263 imp->setEffectAllowed(ustringToString(value.isEmpty() ? UString() : value.toString(exec)));
267 JSValue JSClipboard::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
269 return getDOMConstructor<JSClipboardConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
272 EncodedJSValue JSC_HOST_CALL jsClipboardPrototypeFunctionClearData(ExecState* exec)
274 JSValue thisValue = exec->hostThisValue();
275 if (!thisValue.inherits(&JSClipboard::s_info))
276 return throwVMTypeError(exec);
277 JSClipboard* castedThis = static_cast<JSClipboard*>(asObject(thisValue));
278 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSClipboard::s_info);
279 return JSValue::encode(castedThis->clearData(exec));
282 EncodedJSValue JSC_HOST_CALL jsClipboardPrototypeFunctionGetData(ExecState* exec)
284 JSValue thisValue = exec->hostThisValue();
285 if (!thisValue.inherits(&JSClipboard::s_info))
286 return throwVMTypeError(exec);
287 JSClipboard* castedThis = static_cast<JSClipboard*>(asObject(thisValue));
288 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSClipboard::s_info);
289 return JSValue::encode(castedThis->getData(exec));
292 EncodedJSValue JSC_HOST_CALL jsClipboardPrototypeFunctionSetData(ExecState* exec)
294 JSValue thisValue = exec->hostThisValue();
295 if (!thisValue.inherits(&JSClipboard::s_info))
296 return throwVMTypeError(exec);
297 JSClipboard* castedThis = static_cast<JSClipboard*>(asObject(thisValue));
298 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSClipboard::s_info);
299 Clipboard* imp = static_cast<Clipboard*>(castedThis->impl());
300 if (exec->argumentCount() < 2)
301 return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
302 const String& type(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toString(exec)));
303 if (exec->hadException())
304 return JSValue::encode(jsUndefined());
305 const String& data(ustringToString(MAYBE_MISSING_PARAMETER(exec, 1, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 1, MissingIsUndefined).toString(exec)));
306 if (exec->hadException())
307 return JSValue::encode(jsUndefined());
309 JSC::JSValue result = jsBoolean(imp->setData(type, data));
310 return JSValue::encode(result);
313 EncodedJSValue JSC_HOST_CALL jsClipboardPrototypeFunctionSetDragImage(ExecState* exec)
315 JSValue thisValue = exec->hostThisValue();
316 if (!thisValue.inherits(&JSClipboard::s_info))
317 return throwVMTypeError(exec);
318 JSClipboard* castedThis = static_cast<JSClipboard*>(asObject(thisValue));
319 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSClipboard::s_info);
320 return JSValue::encode(castedThis->setDragImage(exec));
323 static inline bool isObservable(JSClipboard* jsClipboard)
325 if (jsClipboard->hasCustomProperties())
330 bool JSClipboardOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
332 JSClipboard* jsClipboard = static_cast<JSClipboard*>(handle.get().asCell());
333 if (!isObservable(jsClipboard))
335 UNUSED_PARAM(visitor);
339 void JSClipboardOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
341 JSClipboard* jsClipboard = static_cast<JSClipboard*>(handle.get().asCell());
342 DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
343 uncacheWrapper(world, jsClipboard->impl(), jsClipboard);
344 jsClipboard->releaseImpl();
347 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Clipboard* impl)
349 return wrap<JSClipboard>(exec, globalObject, impl);
352 Clipboard* toClipboard(JSC::JSValue value)
354 return value.inherits(&JSClipboard::s_info) ? static_cast<JSClipboard*>(asObject(value))->impl() : 0;