WebCore/generated/JSFileReader.cpp
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     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 
       
    23 #if ENABLE(FILE_READER)
       
    24 
       
    25 #include "JSFileReader.h"
       
    26 
       
    27 #include "EventListener.h"
       
    28 #include "FileError.h"
       
    29 #include "FileReader.h"
       
    30 #include "JSBlob.h"
       
    31 #include "JSEventListener.h"
       
    32 #include "JSFile.h"
       
    33 #include "JSFileError.h"
       
    34 #include "KURL.h"
       
    35 #include "RegisteredEventListener.h"
       
    36 #include <runtime/Error.h>
       
    37 #include <runtime/JSNumberCell.h>
       
    38 #include <wtf/GetPtr.h>
       
    39 
       
    40 using namespace JSC;
       
    41 
       
    42 namespace WebCore {
       
    43 
       
    44 ASSERT_CLASS_FITS_IN_CELL(JSFileReader);
       
    45 
       
    46 /* Hash table */
       
    47 #if ENABLE(JIT)
       
    48 #define THUNK_GENERATOR(generator) , generator
       
    49 #else
       
    50 #define THUNK_GENERATOR(generator)
       
    51 #endif
       
    52 
       
    53 static const HashTableValue JSFileReaderTableValues[11] =
       
    54 {
       
    55     { "readyState", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileReaderReadyState), (intptr_t)0 THUNK_GENERATOR(0) },
       
    56     { "result", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileReaderResult), (intptr_t)0 THUNK_GENERATOR(0) },
       
    57     { "error", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileReaderError), (intptr_t)0 THUNK_GENERATOR(0) },
       
    58     { "onloadstart", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileReaderOnloadstart), (intptr_t)setJSFileReaderOnloadstart THUNK_GENERATOR(0) },
       
    59     { "onprogress", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileReaderOnprogress), (intptr_t)setJSFileReaderOnprogress THUNK_GENERATOR(0) },
       
    60     { "onload", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileReaderOnload), (intptr_t)setJSFileReaderOnload THUNK_GENERATOR(0) },
       
    61     { "onabort", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileReaderOnabort), (intptr_t)setJSFileReaderOnabort THUNK_GENERATOR(0) },
       
    62     { "onerror", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileReaderOnerror), (intptr_t)setJSFileReaderOnerror THUNK_GENERATOR(0) },
       
    63     { "onloadend", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileReaderOnloadend), (intptr_t)setJSFileReaderOnloadend THUNK_GENERATOR(0) },
       
    64     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileReaderConstructor), (intptr_t)0 THUNK_GENERATOR(0) },
       
    65     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
    66 };
       
    67 
       
    68 #undef THUNK_GENERATOR
       
    69 static JSC_CONST_HASHTABLE HashTable JSFileReaderTable = { 34, 31, JSFileReaderTableValues, 0 };
       
    70 /* Hash table for constructor */
       
    71 #if ENABLE(JIT)
       
    72 #define THUNK_GENERATOR(generator) , generator
       
    73 #else
       
    74 #define THUNK_GENERATOR(generator)
       
    75 #endif
       
    76 
       
    77 static const HashTableValue JSFileReaderConstructorTableValues[4] =
       
    78 {
       
    79     { "EMPTY", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileReaderEMPTY), (intptr_t)0 THUNK_GENERATOR(0) },
       
    80     { "LOADING", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileReaderLOADING), (intptr_t)0 THUNK_GENERATOR(0) },
       
    81     { "DONE", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileReaderDONE), (intptr_t)0 THUNK_GENERATOR(0) },
       
    82     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
    83 };
       
    84 
       
    85 #undef THUNK_GENERATOR
       
    86 static JSC_CONST_HASHTABLE HashTable JSFileReaderConstructorTable = { 9, 7, JSFileReaderConstructorTableValues, 0 };
       
    87 class JSFileReaderConstructor : public DOMConstructorObject {
       
    88 public:
       
    89     JSFileReaderConstructor(JSC::ExecState*, JSDOMGlobalObject*);
       
    90 
       
    91     virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);
       
    92     virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&);
       
    93     virtual const JSC::ClassInfo* classInfo() const { return &s_info; }
       
    94     static const JSC::ClassInfo s_info;
       
    95     static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)
       
    96     {
       
    97         return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);
       
    98     }
       
    99 protected:
       
   100     static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags;
       
   101     static JSC::EncodedJSValue JSC_HOST_CALL constructJSFileReader(JSC::ExecState*);
       
   102     virtual JSC::ConstructType getConstructData(JSC::ConstructData&);
       
   103 };
       
   104 
       
   105 const ClassInfo JSFileReaderConstructor::s_info = { "FileReaderConstructor", 0, &JSFileReaderConstructorTable, 0 };
       
   106 
       
   107 JSFileReaderConstructor::JSFileReaderConstructor(ExecState* exec, JSDOMGlobalObject* globalObject)
       
   108     : DOMConstructorObject(JSFileReaderConstructor::createStructure(globalObject->objectPrototype()), globalObject)
       
   109 {
       
   110     putDirect(exec->propertyNames().prototype, JSFileReaderPrototype::self(exec, globalObject), DontDelete | ReadOnly);
       
   111 }
       
   112 
       
   113 bool JSFileReaderConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   114 {
       
   115     return getStaticValueSlot<JSFileReaderConstructor, DOMObject>(exec, &JSFileReaderConstructorTable, this, propertyName, slot);
       
   116 }
       
   117 
       
   118 bool JSFileReaderConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
   119 {
       
   120     return getStaticValueDescriptor<JSFileReaderConstructor, DOMObject>(exec, &JSFileReaderConstructorTable, this, propertyName, descriptor);
       
   121 }
       
   122 
       
   123 EncodedJSValue JSC_HOST_CALL JSFileReaderConstructor::constructJSFileReader(ExecState* exec)
       
   124 {
       
   125     ScriptExecutionContext* context = static_cast<JSFileReaderConstructor*>(exec->callee())->scriptExecutionContext();
       
   126     if (!context)
       
   127         return throwVMError(exec, createReferenceError(exec, "Reference error"));
       
   128     return JSValue::encode(asObject(toJS(exec, static_cast<JSFileReaderConstructor*>(exec->callee())->globalObject(), FileReader::create(context))));
       
   129 }
       
   130 
       
   131 ConstructType JSFileReaderConstructor::getConstructData(ConstructData& constructData)
       
   132 {
       
   133     constructData.native.function = constructJSFileReader;
       
   134     return ConstructTypeHost;
       
   135 }
       
   136 
       
   137 /* Hash table for prototype */
       
   138 #if ENABLE(JIT)
       
   139 #define THUNK_GENERATOR(generator) , generator
       
   140 #else
       
   141 #define THUNK_GENERATOR(generator)
       
   142 #endif
       
   143 
       
   144 static const HashTableValue JSFileReaderPrototypeTableValues[8] =
       
   145 {
       
   146     { "EMPTY", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileReaderEMPTY), (intptr_t)0 THUNK_GENERATOR(0) },
       
   147     { "LOADING", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileReaderLOADING), (intptr_t)0 THUNK_GENERATOR(0) },
       
   148     { "DONE", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileReaderDONE), (intptr_t)0 THUNK_GENERATOR(0) },
       
   149     { "readAsBinaryString", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsFileReaderPrototypeFunctionReadAsBinaryString), (intptr_t)1 THUNK_GENERATOR(0) },
       
   150     { "readAsText", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsFileReaderPrototypeFunctionReadAsText), (intptr_t)2 THUNK_GENERATOR(0) },
       
   151     { "readAsDataURL", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsFileReaderPrototypeFunctionReadAsDataURL), (intptr_t)1 THUNK_GENERATOR(0) },
       
   152     { "abort", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsFileReaderPrototypeFunctionAbort), (intptr_t)0 THUNK_GENERATOR(0) },
       
   153     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
   154 };
       
   155 
       
   156 #undef THUNK_GENERATOR
       
   157 static JSC_CONST_HASHTABLE HashTable JSFileReaderPrototypeTable = { 17, 15, JSFileReaderPrototypeTableValues, 0 };
       
   158 static const HashTable* getJSFileReaderPrototypeTable(ExecState* exec)
       
   159 {
       
   160     return getHashTableForGlobalData(exec->globalData(), &JSFileReaderPrototypeTable);
       
   161 }
       
   162 const ClassInfo JSFileReaderPrototype::s_info = { "FileReaderPrototype", 0, 0, getJSFileReaderPrototypeTable };
       
   163 
       
   164 JSObject* JSFileReaderPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
       
   165 {
       
   166     return getDOMPrototype<JSFileReader>(exec, globalObject);
       
   167 }
       
   168 
       
   169 bool JSFileReaderPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   170 {
       
   171     return getStaticPropertySlot<JSFileReaderPrototype, JSObject>(exec, getJSFileReaderPrototypeTable(exec), this, propertyName, slot);
       
   172 }
       
   173 
       
   174 bool JSFileReaderPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
   175 {
       
   176     return getStaticPropertyDescriptor<JSFileReaderPrototype, JSObject>(exec, getJSFileReaderPrototypeTable(exec), this, propertyName, descriptor);
       
   177 }
       
   178 
       
   179 static const HashTable* getJSFileReaderTable(ExecState* exec)
       
   180 {
       
   181     return getHashTableForGlobalData(exec->globalData(), &JSFileReaderTable);
       
   182 }
       
   183 const ClassInfo JSFileReader::s_info = { "FileReader", 0, 0, getJSFileReaderTable };
       
   184 
       
   185 JSFileReader::JSFileReader(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<FileReader> impl)
       
   186     : DOMObjectWithGlobalPointer(structure, globalObject)
       
   187     , m_impl(impl)
       
   188 {
       
   189 }
       
   190 
       
   191 JSFileReader::~JSFileReader()
       
   192 {
       
   193     impl()->invalidateJSEventListeners(this);
       
   194     forgetDOMObject(this, impl());
       
   195 }
       
   196 
       
   197 void JSFileReader::markChildren(MarkStack& markStack)
       
   198 {
       
   199     Base::markChildren(markStack);
       
   200     impl()->markJSEventListeners(markStack);
       
   201 }
       
   202 
       
   203 JSObject* JSFileReader::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
       
   204 {
       
   205     return new (exec) JSFileReaderPrototype(globalObject, JSFileReaderPrototype::createStructure(globalObject->objectPrototype()));
       
   206 }
       
   207 
       
   208 bool JSFileReader::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   209 {
       
   210     return getStaticValueSlot<JSFileReader, Base>(exec, getJSFileReaderTable(exec), this, propertyName, slot);
       
   211 }
       
   212 
       
   213 bool JSFileReader::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
   214 {
       
   215     return getStaticValueDescriptor<JSFileReader, Base>(exec, getJSFileReaderTable(exec), this, propertyName, descriptor);
       
   216 }
       
   217 
       
   218 JSValue jsFileReaderReadyState(ExecState* exec, JSValue slotBase, const Identifier&)
       
   219 {
       
   220     JSFileReader* castedThis = static_cast<JSFileReader*>(asObject(slotBase));
       
   221     UNUSED_PARAM(exec);
       
   222     FileReader* imp = static_cast<FileReader*>(castedThis->impl());
       
   223     JSValue result = jsNumber(exec, imp->readyState());
       
   224     return result;
       
   225 }
       
   226 
       
   227 JSValue jsFileReaderResult(ExecState* exec, JSValue slotBase, const Identifier&)
       
   228 {
       
   229     JSFileReader* castedThis = static_cast<JSFileReader*>(asObject(slotBase));
       
   230     UNUSED_PARAM(exec);
       
   231     FileReader* imp = static_cast<FileReader*>(castedThis->impl());
       
   232     JSValue result = jsOwnedStringOrNull(exec, imp->result());
       
   233     return result;
       
   234 }
       
   235 
       
   236 JSValue jsFileReaderError(ExecState* exec, JSValue slotBase, const Identifier&)
       
   237 {
       
   238     JSFileReader* castedThis = static_cast<JSFileReader*>(asObject(slotBase));
       
   239     UNUSED_PARAM(exec);
       
   240     FileReader* imp = static_cast<FileReader*>(castedThis->impl());
       
   241     JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->error()));
       
   242     return result;
       
   243 }
       
   244 
       
   245 JSValue jsFileReaderOnloadstart(ExecState* exec, JSValue slotBase, const Identifier&)
       
   246 {
       
   247     JSFileReader* castedThis = static_cast<JSFileReader*>(asObject(slotBase));
       
   248     UNUSED_PARAM(exec);
       
   249     FileReader* imp = static_cast<FileReader*>(castedThis->impl());
       
   250     if (EventListener* listener = imp->onloadstart()) {
       
   251         if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {
       
   252             if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext()))
       
   253                 return jsFunction;
       
   254         }
       
   255     }
       
   256     return jsNull();
       
   257 }
       
   258 
       
   259 JSValue jsFileReaderOnprogress(ExecState* exec, JSValue slotBase, const Identifier&)
       
   260 {
       
   261     JSFileReader* castedThis = static_cast<JSFileReader*>(asObject(slotBase));
       
   262     UNUSED_PARAM(exec);
       
   263     FileReader* imp = static_cast<FileReader*>(castedThis->impl());
       
   264     if (EventListener* listener = imp->onprogress()) {
       
   265         if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {
       
   266             if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext()))
       
   267                 return jsFunction;
       
   268         }
       
   269     }
       
   270     return jsNull();
       
   271 }
       
   272 
       
   273 JSValue jsFileReaderOnload(ExecState* exec, JSValue slotBase, const Identifier&)
       
   274 {
       
   275     JSFileReader* castedThis = static_cast<JSFileReader*>(asObject(slotBase));
       
   276     UNUSED_PARAM(exec);
       
   277     FileReader* imp = static_cast<FileReader*>(castedThis->impl());
       
   278     if (EventListener* listener = imp->onload()) {
       
   279         if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {
       
   280             if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext()))
       
   281                 return jsFunction;
       
   282         }
       
   283     }
       
   284     return jsNull();
       
   285 }
       
   286 
       
   287 JSValue jsFileReaderOnabort(ExecState* exec, JSValue slotBase, const Identifier&)
       
   288 {
       
   289     JSFileReader* castedThis = static_cast<JSFileReader*>(asObject(slotBase));
       
   290     UNUSED_PARAM(exec);
       
   291     FileReader* imp = static_cast<FileReader*>(castedThis->impl());
       
   292     if (EventListener* listener = imp->onabort()) {
       
   293         if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {
       
   294             if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext()))
       
   295                 return jsFunction;
       
   296         }
       
   297     }
       
   298     return jsNull();
       
   299 }
       
   300 
       
   301 JSValue jsFileReaderOnerror(ExecState* exec, JSValue slotBase, const Identifier&)
       
   302 {
       
   303     JSFileReader* castedThis = static_cast<JSFileReader*>(asObject(slotBase));
       
   304     UNUSED_PARAM(exec);
       
   305     FileReader* imp = static_cast<FileReader*>(castedThis->impl());
       
   306     if (EventListener* listener = imp->onerror()) {
       
   307         if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {
       
   308             if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext()))
       
   309                 return jsFunction;
       
   310         }
       
   311     }
       
   312     return jsNull();
       
   313 }
       
   314 
       
   315 JSValue jsFileReaderOnloadend(ExecState* exec, JSValue slotBase, const Identifier&)
       
   316 {
       
   317     JSFileReader* castedThis = static_cast<JSFileReader*>(asObject(slotBase));
       
   318     UNUSED_PARAM(exec);
       
   319     FileReader* imp = static_cast<FileReader*>(castedThis->impl());
       
   320     if (EventListener* listener = imp->onloadend()) {
       
   321         if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {
       
   322             if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext()))
       
   323                 return jsFunction;
       
   324         }
       
   325     }
       
   326     return jsNull();
       
   327 }
       
   328 
       
   329 JSValue jsFileReaderConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
       
   330 {
       
   331     JSFileReader* domObject = static_cast<JSFileReader*>(asObject(slotBase));
       
   332     return JSFileReader::getConstructor(exec, domObject->globalObject());
       
   333 }
       
   334 void JSFileReader::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
       
   335 {
       
   336     lookupPut<JSFileReader, Base>(exec, propertyName, value, getJSFileReaderTable(exec), this, slot);
       
   337 }
       
   338 
       
   339 void setJSFileReaderOnloadstart(ExecState* exec, JSObject* thisObject, JSValue value)
       
   340 {
       
   341     UNUSED_PARAM(exec);
       
   342     FileReader* imp = static_cast<FileReader*>(static_cast<JSFileReader*>(thisObject)->impl());
       
   343     imp->setOnloadstart(createJSAttributeEventListener(exec, value, thisObject));
       
   344 }
       
   345 
       
   346 void setJSFileReaderOnprogress(ExecState* exec, JSObject* thisObject, JSValue value)
       
   347 {
       
   348     UNUSED_PARAM(exec);
       
   349     FileReader* imp = static_cast<FileReader*>(static_cast<JSFileReader*>(thisObject)->impl());
       
   350     imp->setOnprogress(createJSAttributeEventListener(exec, value, thisObject));
       
   351 }
       
   352 
       
   353 void setJSFileReaderOnload(ExecState* exec, JSObject* thisObject, JSValue value)
       
   354 {
       
   355     UNUSED_PARAM(exec);
       
   356     FileReader* imp = static_cast<FileReader*>(static_cast<JSFileReader*>(thisObject)->impl());
       
   357     imp->setOnload(createJSAttributeEventListener(exec, value, thisObject));
       
   358 }
       
   359 
       
   360 void setJSFileReaderOnabort(ExecState* exec, JSObject* thisObject, JSValue value)
       
   361 {
       
   362     UNUSED_PARAM(exec);
       
   363     FileReader* imp = static_cast<FileReader*>(static_cast<JSFileReader*>(thisObject)->impl());
       
   364     imp->setOnabort(createJSAttributeEventListener(exec, value, thisObject));
       
   365 }
       
   366 
       
   367 void setJSFileReaderOnerror(ExecState* exec, JSObject* thisObject, JSValue value)
       
   368 {
       
   369     UNUSED_PARAM(exec);
       
   370     FileReader* imp = static_cast<FileReader*>(static_cast<JSFileReader*>(thisObject)->impl());
       
   371     imp->setOnerror(createJSAttributeEventListener(exec, value, thisObject));
       
   372 }
       
   373 
       
   374 void setJSFileReaderOnloadend(ExecState* exec, JSObject* thisObject, JSValue value)
       
   375 {
       
   376     UNUSED_PARAM(exec);
       
   377     FileReader* imp = static_cast<FileReader*>(static_cast<JSFileReader*>(thisObject)->impl());
       
   378     imp->setOnloadend(createJSAttributeEventListener(exec, value, thisObject));
       
   379 }
       
   380 
       
   381 JSValue JSFileReader::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
       
   382 {
       
   383     return getDOMConstructor<JSFileReaderConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
       
   384 }
       
   385 
       
   386 EncodedJSValue JSC_HOST_CALL jsFileReaderPrototypeFunctionReadAsBinaryString(ExecState* exec)
       
   387 {
       
   388     JSValue thisValue = exec->hostThisValue();
       
   389     if (!thisValue.inherits(&JSFileReader::s_info))
       
   390         return throwVMTypeError(exec);
       
   391     JSFileReader* castedThis = static_cast<JSFileReader*>(asObject(thisValue));
       
   392     FileReader* imp = static_cast<FileReader*>(castedThis->impl());
       
   393     Blob* fileBlob = toBlob(exec->argument(0));
       
   394 
       
   395     imp->readAsBinaryString(fileBlob);
       
   396     return JSValue::encode(jsUndefined());
       
   397 }
       
   398 
       
   399 EncodedJSValue JSC_HOST_CALL jsFileReaderPrototypeFunctionReadAsText(ExecState* exec)
       
   400 {
       
   401     JSValue thisValue = exec->hostThisValue();
       
   402     if (!thisValue.inherits(&JSFileReader::s_info))
       
   403         return throwVMTypeError(exec);
       
   404     JSFileReader* castedThis = static_cast<JSFileReader*>(asObject(thisValue));
       
   405     FileReader* imp = static_cast<FileReader*>(castedThis->impl());
       
   406     Blob* fileBlob = toBlob(exec->argument(0));
       
   407 
       
   408     int argsCount = exec->argumentCount();
       
   409     if (argsCount < 2) {
       
   410         imp->readAsText(fileBlob);
       
   411         return JSValue::encode(jsUndefined());
       
   412     }
       
   413 
       
   414     const String& encoding = ustringToString(exec->argument(1).toString(exec));
       
   415 
       
   416     imp->readAsText(fileBlob, encoding);
       
   417     return JSValue::encode(jsUndefined());
       
   418 }
       
   419 
       
   420 EncodedJSValue JSC_HOST_CALL jsFileReaderPrototypeFunctionReadAsDataURL(ExecState* exec)
       
   421 {
       
   422     JSValue thisValue = exec->hostThisValue();
       
   423     if (!thisValue.inherits(&JSFileReader::s_info))
       
   424         return throwVMTypeError(exec);
       
   425     JSFileReader* castedThis = static_cast<JSFileReader*>(asObject(thisValue));
       
   426     FileReader* imp = static_cast<FileReader*>(castedThis->impl());
       
   427     File* file = toFile(exec->argument(0));
       
   428 
       
   429     imp->readAsDataURL(file);
       
   430     return JSValue::encode(jsUndefined());
       
   431 }
       
   432 
       
   433 EncodedJSValue JSC_HOST_CALL jsFileReaderPrototypeFunctionAbort(ExecState* exec)
       
   434 {
       
   435     JSValue thisValue = exec->hostThisValue();
       
   436     if (!thisValue.inherits(&JSFileReader::s_info))
       
   437         return throwVMTypeError(exec);
       
   438     JSFileReader* castedThis = static_cast<JSFileReader*>(asObject(thisValue));
       
   439     FileReader* imp = static_cast<FileReader*>(castedThis->impl());
       
   440 
       
   441     imp->abort();
       
   442     return JSValue::encode(jsUndefined());
       
   443 }
       
   444 
       
   445 // Constant getters
       
   446 
       
   447 JSValue jsFileReaderEMPTY(ExecState* exec, JSValue, const Identifier&)
       
   448 {
       
   449     return jsNumber(exec, static_cast<int>(0));
       
   450 }
       
   451 
       
   452 JSValue jsFileReaderLOADING(ExecState* exec, JSValue, const Identifier&)
       
   453 {
       
   454     return jsNumber(exec, static_cast<int>(1));
       
   455 }
       
   456 
       
   457 JSValue jsFileReaderDONE(ExecState* exec, JSValue, const Identifier&)
       
   458 {
       
   459     return jsNumber(exec, static_cast<int>(2));
       
   460 }
       
   461 
       
   462 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, FileReader* object)
       
   463 {
       
   464     return getDOMObjectWrapper<JSFileReader>(exec, globalObject, object);
       
   465 }
       
   466 FileReader* toFileReader(JSC::JSValue value)
       
   467 {
       
   468     return value.inherits(&JSFileReader::s_info) ? static_cast<JSFileReader*>(asObject(value))->impl() : 0;
       
   469 }
       
   470 
       
   471 }
       
   472 
       
   473 #endif // ENABLE(FILE_READER)