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.
25 #include "JSFileReaderSync.h"
27 #include "ExceptionCode.h"
28 #include "FileReaderSync.h"
29 #include "JSArrayBuffer.h"
31 #include "JSDOMBinding.h"
33 #include <runtime/Error.h>
34 #include <wtf/ArrayBuffer.h>
35 #include <wtf/GetPtr.h>
41 ASSERT_CLASS_FITS_IN_CELL(JSFileReaderSync);
45 #define THUNK_GENERATOR(generator) , generator
47 #define THUNK_GENERATOR(generator)
50 #define INTRINSIC(intrinsic) , intrinsic
52 #define INTRINSIC(intrinsic)
55 static const HashTableValue JSFileReaderSyncTableValues[] =
57 { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileReaderSyncConstructor), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
58 { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
61 #undef THUNK_GENERATOR
62 static const HashTable JSFileReaderSyncTable = { 2, 1, JSFileReaderSyncTableValues, 0 };
63 /* Hash table for constructor */
65 #define THUNK_GENERATOR(generator) , generator
67 #define THUNK_GENERATOR(generator)
70 #define INTRINSIC(intrinsic) , intrinsic
72 #define INTRINSIC(intrinsic)
75 static const HashTableValue JSFileReaderSyncConstructorTableValues[] =
77 { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
80 #undef THUNK_GENERATOR
81 static const HashTable JSFileReaderSyncConstructorTable = { 1, 0, JSFileReaderSyncConstructorTableValues, 0 };
82 const ClassInfo JSFileReaderSyncConstructor::s_info = { "FileReaderSyncConstructor", &DOMConstructorObject::s_info, &JSFileReaderSyncConstructorTable, 0, CREATE_METHOD_TABLE(JSFileReaderSyncConstructor) };
84 JSFileReaderSyncConstructor::JSFileReaderSyncConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
85 : DOMConstructorObject(structure, globalObject)
89 void JSFileReaderSyncConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
91 Base::finishCreation(exec->globalData());
92 ASSERT(inherits(&s_info));
93 putDirect(exec->globalData(), exec->propertyNames().prototype, JSFileReaderSyncPrototype::self(exec, globalObject), DontDelete | ReadOnly);
96 bool JSFileReaderSyncConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
98 return getStaticValueSlot<JSFileReaderSyncConstructor, JSDOMWrapper>(exec, &JSFileReaderSyncConstructorTable, static_cast<JSFileReaderSyncConstructor*>(cell), propertyName, slot);
101 bool JSFileReaderSyncConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
103 return getStaticValueDescriptor<JSFileReaderSyncConstructor, JSDOMWrapper>(exec, &JSFileReaderSyncConstructorTable, static_cast<JSFileReaderSyncConstructor*>(object), propertyName, descriptor);
106 EncodedJSValue JSC_HOST_CALL JSFileReaderSyncConstructor::constructJSFileReaderSync(ExecState* exec)
108 JSFileReaderSyncConstructor* jsConstructor = static_cast<JSFileReaderSyncConstructor*>(exec->callee());
109 RefPtr<FileReaderSync> object = FileReaderSync::create();
110 return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), object.get())));
113 ConstructType JSFileReaderSyncConstructor::getConstructData(JSCell*, ConstructData& constructData)
115 constructData.native.function = constructJSFileReaderSync;
116 return ConstructTypeHost;
119 /* Hash table for prototype */
121 #define THUNK_GENERATOR(generator) , generator
123 #define THUNK_GENERATOR(generator)
126 #define INTRINSIC(intrinsic) , intrinsic
128 #define INTRINSIC(intrinsic)
131 static const HashTableValue JSFileReaderSyncPrototypeTableValues[] =
133 { "readAsArrayBuffer", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsFileReaderSyncPrototypeFunctionReadAsArrayBuffer), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
134 { "readAsBinaryString", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsFileReaderSyncPrototypeFunctionReadAsBinaryString), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
135 { "readAsText", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsFileReaderSyncPrototypeFunctionReadAsText), (intptr_t)2 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
136 { "readAsDataURL", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsFileReaderSyncPrototypeFunctionReadAsDataURL), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
137 { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
140 #undef THUNK_GENERATOR
141 static const HashTable JSFileReaderSyncPrototypeTable = { 9, 7, JSFileReaderSyncPrototypeTableValues, 0 };
142 static const HashTable* getJSFileReaderSyncPrototypeTable(ExecState* exec)
144 return getHashTableForGlobalData(exec->globalData(), &JSFileReaderSyncPrototypeTable);
147 const ClassInfo JSFileReaderSyncPrototype::s_info = { "FileReaderSyncPrototype", &JSC::JSNonFinalObject::s_info, 0, getJSFileReaderSyncPrototypeTable, CREATE_METHOD_TABLE(JSFileReaderSyncPrototype) };
149 JSObject* JSFileReaderSyncPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
151 return getDOMPrototype<JSFileReaderSync>(exec, globalObject);
154 bool JSFileReaderSyncPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
156 JSFileReaderSyncPrototype* thisObject = jsCast<JSFileReaderSyncPrototype*>(cell);
157 return getStaticFunctionSlot<JSObject>(exec, getJSFileReaderSyncPrototypeTable(exec), thisObject, propertyName, slot);
160 bool JSFileReaderSyncPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
162 JSFileReaderSyncPrototype* thisObject = jsCast<JSFileReaderSyncPrototype*>(object);
163 return getStaticFunctionDescriptor<JSObject>(exec, getJSFileReaderSyncPrototypeTable(exec), thisObject, propertyName, descriptor);
166 static const HashTable* getJSFileReaderSyncTable(ExecState* exec)
168 return getHashTableForGlobalData(exec->globalData(), &JSFileReaderSyncTable);
171 const ClassInfo JSFileReaderSync::s_info = { "FileReaderSync", &JSDOMWrapper::s_info, 0, getJSFileReaderSyncTable , CREATE_METHOD_TABLE(JSFileReaderSync) };
173 JSFileReaderSync::JSFileReaderSync(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<FileReaderSync> impl)
174 : JSDOMWrapper(structure, globalObject)
175 , m_impl(impl.leakRef())
179 void JSFileReaderSync::finishCreation(JSGlobalData& globalData)
181 Base::finishCreation(globalData);
182 ASSERT(inherits(&s_info));
185 JSObject* JSFileReaderSync::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
187 return JSFileReaderSyncPrototype::create(exec->globalData(), globalObject, JSFileReaderSyncPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
190 bool JSFileReaderSync::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
192 JSFileReaderSync* thisObject = jsCast<JSFileReaderSync*>(cell);
193 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
194 return getStaticValueSlot<JSFileReaderSync, Base>(exec, getJSFileReaderSyncTable(exec), thisObject, propertyName, slot);
197 bool JSFileReaderSync::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
199 JSFileReaderSync* thisObject = jsCast<JSFileReaderSync*>(object);
200 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
201 return getStaticValueDescriptor<JSFileReaderSync, Base>(exec, getJSFileReaderSyncTable(exec), thisObject, propertyName, descriptor);
204 JSValue jsFileReaderSyncConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
206 JSFileReaderSync* domObject = static_cast<JSFileReaderSync*>(asObject(slotBase));
207 return JSFileReaderSync::getConstructor(exec, domObject->globalObject());
210 JSValue JSFileReaderSync::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
212 return getDOMConstructor<JSFileReaderSyncConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
215 EncodedJSValue JSC_HOST_CALL jsFileReaderSyncPrototypeFunctionReadAsArrayBuffer(ExecState* exec)
217 JSValue thisValue = exec->hostThisValue();
218 if (!thisValue.inherits(&JSFileReaderSync::s_info))
219 return throwVMTypeError(exec);
220 JSFileReaderSync* castedThis = static_cast<JSFileReaderSync*>(asObject(thisValue));
221 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSFileReaderSync::s_info);
222 FileReaderSync* imp = static_cast<FileReaderSync*>(castedThis->impl());
223 if (exec->argumentCount() < 1)
224 return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
225 ExceptionCode ec = 0;
226 ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();
228 return JSValue::encode(jsUndefined());
229 Blob* blob(toBlob(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined)));
230 if (exec->hadException())
231 return JSValue::encode(jsUndefined());
233 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->readAsArrayBuffer(scriptContext, blob, ec)));
234 setDOMException(exec, ec);
235 return JSValue::encode(result);
238 EncodedJSValue JSC_HOST_CALL jsFileReaderSyncPrototypeFunctionReadAsBinaryString(ExecState* exec)
240 JSValue thisValue = exec->hostThisValue();
241 if (!thisValue.inherits(&JSFileReaderSync::s_info))
242 return throwVMTypeError(exec);
243 JSFileReaderSync* castedThis = static_cast<JSFileReaderSync*>(asObject(thisValue));
244 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSFileReaderSync::s_info);
245 FileReaderSync* imp = static_cast<FileReaderSync*>(castedThis->impl());
246 if (exec->argumentCount() < 1)
247 return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
248 ExceptionCode ec = 0;
249 ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();
251 return JSValue::encode(jsUndefined());
252 Blob* blob(toBlob(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined)));
253 if (exec->hadException())
254 return JSValue::encode(jsUndefined());
256 JSC::JSValue result = jsOwnedStringOrNull(exec, imp->readAsBinaryString(scriptContext, blob, ec));
257 setDOMException(exec, ec);
258 return JSValue::encode(result);
261 EncodedJSValue JSC_HOST_CALL jsFileReaderSyncPrototypeFunctionReadAsText(ExecState* exec)
263 JSValue thisValue = exec->hostThisValue();
264 if (!thisValue.inherits(&JSFileReaderSync::s_info))
265 return throwVMTypeError(exec);
266 JSFileReaderSync* castedThis = static_cast<JSFileReaderSync*>(asObject(thisValue));
267 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSFileReaderSync::s_info);
268 FileReaderSync* imp = static_cast<FileReaderSync*>(castedThis->impl());
269 if (exec->argumentCount() < 1)
270 return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
271 ExceptionCode ec = 0;
272 ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();
274 return JSValue::encode(jsUndefined());
275 Blob* blob(toBlob(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined)));
276 if (exec->hadException())
277 return JSValue::encode(jsUndefined());
279 size_t argsCount = exec->argumentCount();
280 if (argsCount <= 1) {
282 JSC::JSValue result = jsOwnedStringOrNull(exec, imp->readAsText(scriptContext, blob, ec));
283 setDOMException(exec, ec);
284 return JSValue::encode(result);
287 const String& encoding(ustringToString(MAYBE_MISSING_PARAMETER(exec, 1, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 1, MissingIsUndefined).toString(exec)));
288 if (exec->hadException())
289 return JSValue::encode(jsUndefined());
291 JSC::JSValue result = jsOwnedStringOrNull(exec, imp->readAsText(scriptContext, blob, encoding, ec));
292 setDOMException(exec, ec);
293 return JSValue::encode(result);
296 EncodedJSValue JSC_HOST_CALL jsFileReaderSyncPrototypeFunctionReadAsDataURL(ExecState* exec)
298 JSValue thisValue = exec->hostThisValue();
299 if (!thisValue.inherits(&JSFileReaderSync::s_info))
300 return throwVMTypeError(exec);
301 JSFileReaderSync* castedThis = static_cast<JSFileReaderSync*>(asObject(thisValue));
302 ASSERT_GC_OBJECT_INHERITS(castedThis, &JSFileReaderSync::s_info);
303 FileReaderSync* imp = static_cast<FileReaderSync*>(castedThis->impl());
304 if (exec->argumentCount() < 1)
305 return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
306 ExceptionCode ec = 0;
307 ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();
309 return JSValue::encode(jsUndefined());
310 Blob* blob(toBlob(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined)));
311 if (exec->hadException())
312 return JSValue::encode(jsUndefined());
314 JSC::JSValue result = jsOwnedStringOrNull(exec, imp->readAsDataURL(scriptContext, blob, ec));
315 setDOMException(exec, ec);
316 return JSValue::encode(result);
319 static inline bool isObservable(JSFileReaderSync* jsFileReaderSync)
321 if (jsFileReaderSync->hasCustomProperties())
326 bool JSFileReaderSyncOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
328 JSFileReaderSync* jsFileReaderSync = static_cast<JSFileReaderSync*>(handle.get().asCell());
329 if (!isObservable(jsFileReaderSync))
331 UNUSED_PARAM(visitor);
335 void JSFileReaderSyncOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
337 JSFileReaderSync* jsFileReaderSync = static_cast<JSFileReaderSync*>(handle.get().asCell());
338 DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
339 uncacheWrapper(world, jsFileReaderSync->impl(), jsFileReaderSync);
340 jsFileReaderSync->releaseImpl();
343 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, FileReaderSync* impl)
345 return wrap<JSFileReaderSync>(exec, globalObject, impl);
348 FileReaderSync* toFileReaderSync(JSC::JSValue value)
350 return value.inherits(&JSFileReaderSync::s_info) ? static_cast<JSFileReaderSync*>(asObject(value))->impl() : 0;
355 #endif // ENABLE(BLOB)