tizen beta release
[profile/ivi/webkit-efl.git] / DerivedSources / WebCore / JSClipboard.cpp
1 /*
2     This file is part of the WebKit open source project.
3     This file has been generated by generate-bindings.pl. DO NOT MODIFY!
4
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.
9
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.
14
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.
19 */
20
21 #include "config.h"
22 #include "JSClipboard.h"
23
24 #include "Clipboard.h"
25 #include "ExceptionCode.h"
26 #include "FileList.h"
27 #include "JSDOMBinding.h"
28 #include "JSFileList.h"
29 #include "KURL.h"
30 #include <runtime/Error.h>
31 #include <wtf/GetPtr.h>
32
33 #if ENABLE(DATA_TRANSFER_ITEMS)
34 #include "DataTransferItemList.h"
35 #include "JSDataTransferItemList.h"
36 #endif
37
38 using namespace JSC;
39
40 namespace WebCore {
41
42 ASSERT_CLASS_FITS_IN_CELL(JSClipboard);
43
44 /* Hash table */
45 #if ENABLE(JIT)
46 #define THUNK_GENERATOR(generator) , generator
47 #else
48 #define THUNK_GENERATOR(generator)
49 #endif
50 #if ENABLE(DFG_JIT)
51 #define INTRINSIC(intrinsic) , intrinsic
52 #else
53 #define INTRINSIC(intrinsic)
54 #endif
55
56 static const HashTableValue JSClipboardTableValues[] =
57 {
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) },
64 #endif
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) }
67 };
68
69 #undef THUNK_GENERATOR
70 static const HashTable JSClipboardTable = { 17, 15, JSClipboardTableValues, 0 };
71 /* Hash table for constructor */
72 #if ENABLE(JIT)
73 #define THUNK_GENERATOR(generator) , generator
74 #else
75 #define THUNK_GENERATOR(generator)
76 #endif
77 #if ENABLE(DFG_JIT)
78 #define INTRINSIC(intrinsic) , intrinsic
79 #else
80 #define INTRINSIC(intrinsic)
81 #endif
82
83 static const HashTableValue JSClipboardConstructorTableValues[] =
84 {
85     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
86 };
87
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) };
91
92 JSClipboardConstructor::JSClipboardConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
93     : DOMConstructorObject(structure, globalObject)
94 {
95 }
96
97 void JSClipboardConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
98 {
99     Base::finishCreation(exec->globalData());
100     ASSERT(inherits(&s_info));
101     putDirect(exec->globalData(), exec->propertyNames().prototype, JSClipboardPrototype::self(exec, globalObject), DontDelete | ReadOnly);
102 }
103
104 bool JSClipboardConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
105 {
106     return getStaticValueSlot<JSClipboardConstructor, JSDOMWrapper>(exec, &JSClipboardConstructorTable, static_cast<JSClipboardConstructor*>(cell), propertyName, slot);
107 }
108
109 bool JSClipboardConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
110 {
111     return getStaticValueDescriptor<JSClipboardConstructor, JSDOMWrapper>(exec, &JSClipboardConstructorTable, static_cast<JSClipboardConstructor*>(object), propertyName, descriptor);
112 }
113
114 /* Hash table for prototype */
115 #if ENABLE(JIT)
116 #define THUNK_GENERATOR(generator) , generator
117 #else
118 #define THUNK_GENERATOR(generator)
119 #endif
120 #if ENABLE(DFG_JIT)
121 #define INTRINSIC(intrinsic) , intrinsic
122 #else
123 #define INTRINSIC(intrinsic)
124 #endif
125
126 static const HashTableValue JSClipboardPrototypeTableValues[] =
127 {
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) }
133 };
134
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) };
138
139 JSObject* JSClipboardPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
140 {
141     return getDOMPrototype<JSClipboard>(exec, globalObject);
142 }
143
144 bool JSClipboardPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
145 {
146     JSClipboardPrototype* thisObject = jsCast<JSClipboardPrototype*>(cell);
147     return getStaticFunctionSlot<JSObject>(exec, &JSClipboardPrototypeTable, thisObject, propertyName, slot);
148 }
149
150 bool JSClipboardPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
151 {
152     JSClipboardPrototype* thisObject = jsCast<JSClipboardPrototype*>(object);
153     return getStaticFunctionDescriptor<JSObject>(exec, &JSClipboardPrototypeTable, thisObject, propertyName, descriptor);
154 }
155
156 const ClassInfo JSClipboard::s_info = { "Clipboard", &JSDOMWrapper::s_info, &JSClipboardTable, 0 , CREATE_METHOD_TABLE(JSClipboard) };
157
158 JSClipboard::JSClipboard(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<Clipboard> impl)
159     : JSDOMWrapper(structure, globalObject)
160     , m_impl(impl.leakRef())
161 {
162 }
163
164 void JSClipboard::finishCreation(JSGlobalData& globalData)
165 {
166     Base::finishCreation(globalData);
167     ASSERT(inherits(&s_info));
168 }
169
170 JSObject* JSClipboard::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
171 {
172     return JSClipboardPrototype::create(exec->globalData(), globalObject, JSClipboardPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
173 }
174
175 bool JSClipboard::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
176 {
177     JSClipboard* thisObject = jsCast<JSClipboard*>(cell);
178     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
179     return getStaticValueSlot<JSClipboard, Base>(exec, &JSClipboardTable, thisObject, propertyName, slot);
180 }
181
182 bool JSClipboard::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
183 {
184     JSClipboard* thisObject = jsCast<JSClipboard*>(object);
185     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
186     return getStaticValueDescriptor<JSClipboard, Base>(exec, &JSClipboardTable, thisObject, propertyName, descriptor);
187 }
188
189 JSValue jsClipboardDropEffect(ExecState* exec, JSValue slotBase, const Identifier&)
190 {
191     JSClipboard* castedThis = static_cast<JSClipboard*>(asObject(slotBase));
192     UNUSED_PARAM(exec);
193     Clipboard* imp = static_cast<Clipboard*>(castedThis->impl());
194     JSValue result = jsStringOrUndefined(exec, imp->dropEffect());
195     return result;
196 }
197
198
199 JSValue jsClipboardEffectAllowed(ExecState* exec, JSValue slotBase, const Identifier&)
200 {
201     JSClipboard* castedThis = static_cast<JSClipboard*>(asObject(slotBase));
202     UNUSED_PARAM(exec);
203     Clipboard* imp = static_cast<Clipboard*>(castedThis->impl());
204     JSValue result = jsStringOrUndefined(exec, imp->effectAllowed());
205     return result;
206 }
207
208
209 JSValue jsClipboardTypes(ExecState* exec, JSValue slotBase, const Identifier&)
210 {
211     JSClipboard* castedThis = static_cast<JSClipboard*>(asObject(slotBase));
212     return castedThis->types(exec);
213 }
214
215
216 JSValue jsClipboardFiles(ExecState* exec, JSValue slotBase, const Identifier&)
217 {
218     JSClipboard* castedThis = static_cast<JSClipboard*>(asObject(slotBase));
219     UNUSED_PARAM(exec);
220     Clipboard* imp = static_cast<Clipboard*>(castedThis->impl());
221     JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->files()));
222     return result;
223 }
224
225
226 #if ENABLE(DATA_TRANSFER_ITEMS)
227 JSValue jsClipboardItems(ExecState* exec, JSValue slotBase, const Identifier&)
228 {
229     JSClipboard* castedThis = static_cast<JSClipboard*>(asObject(slotBase));
230     UNUSED_PARAM(exec);
231     Clipboard* imp = static_cast<Clipboard*>(castedThis->impl());
232     JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->items()));
233     return result;
234 }
235
236 #endif
237
238 JSValue jsClipboardConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
239 {
240     JSClipboard* domObject = static_cast<JSClipboard*>(asObject(slotBase));
241     return JSClipboard::getConstructor(exec, domObject->globalObject());
242 }
243
244 void JSClipboard::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
245 {
246     JSClipboard* thisObject = jsCast<JSClipboard*>(cell);
247     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
248     lookupPut<JSClipboard, Base>(exec, propertyName, value, &JSClipboardTable, thisObject, slot);
249 }
250
251 void setJSClipboardDropEffect(ExecState* exec, JSObject* thisObject, JSValue value)
252 {
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)));
256 }
257
258
259 void setJSClipboardEffectAllowed(ExecState* exec, JSObject* thisObject, JSValue value)
260 {
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)));
264 }
265
266
267 JSValue JSClipboard::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
268 {
269     return getDOMConstructor<JSClipboardConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
270 }
271
272 EncodedJSValue JSC_HOST_CALL jsClipboardPrototypeFunctionClearData(ExecState* exec)
273 {
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));
280 }
281
282 EncodedJSValue JSC_HOST_CALL jsClipboardPrototypeFunctionGetData(ExecState* exec)
283 {
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));
290 }
291
292 EncodedJSValue JSC_HOST_CALL jsClipboardPrototypeFunctionSetData(ExecState* exec)
293 {
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());
308
309     JSC::JSValue result = jsBoolean(imp->setData(type, data));
310     return JSValue::encode(result);
311 }
312
313 EncodedJSValue JSC_HOST_CALL jsClipboardPrototypeFunctionSetDragImage(ExecState* exec)
314 {
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));
321 }
322
323 static inline bool isObservable(JSClipboard* jsClipboard)
324 {
325     if (jsClipboard->hasCustomProperties())
326         return true;
327     return false;
328 }
329
330 bool JSClipboardOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
331 {
332     JSClipboard* jsClipboard = static_cast<JSClipboard*>(handle.get().asCell());
333     if (!isObservable(jsClipboard))
334         return false;
335     UNUSED_PARAM(visitor);
336     return false;
337 }
338
339 void JSClipboardOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
340 {
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();
345 }
346
347 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Clipboard* impl)
348 {
349     return wrap<JSClipboard>(exec, globalObject, impl);
350 }
351
352 Clipboard* toClipboard(JSC::JSValue value)
353 {
354     return value.inherits(&JSClipboard::s_info) ? static_cast<JSClipboard*>(asObject(value))->impl() : 0;
355 }
356
357 }