WebCore/generated/JSXMLHttpRequest.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 #include "JSXMLHttpRequest.h"
       
    23 
       
    24 #include "Document.h"
       
    25 #include "Event.h"
       
    26 #include "EventListener.h"
       
    27 #include "JSDocument.h"
       
    28 #include "JSEvent.h"
       
    29 #include "JSEventListener.h"
       
    30 #include "JSXMLHttpRequestUpload.h"
       
    31 #include "KURL.h"
       
    32 #include "RegisteredEventListener.h"
       
    33 #include "XMLHttpRequest.h"
       
    34 #include "XMLHttpRequestUpload.h"
       
    35 #include <runtime/Error.h>
       
    36 #include <runtime/JSNumberCell.h>
       
    37 #include <runtime/JSString.h>
       
    38 #include <wtf/GetPtr.h>
       
    39 
       
    40 using namespace JSC;
       
    41 
       
    42 namespace WebCore {
       
    43 
       
    44 ASSERT_CLASS_FITS_IN_CELL(JSXMLHttpRequest);
       
    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 JSXMLHttpRequestTableValues[15] =
       
    54 {
       
    55     { "onabort", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestOnabort), (intptr_t)setJSXMLHttpRequestOnabort THUNK_GENERATOR(0) },
       
    56     { "onerror", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestOnerror), (intptr_t)setJSXMLHttpRequestOnerror THUNK_GENERATOR(0) },
       
    57     { "onload", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestOnload), (intptr_t)setJSXMLHttpRequestOnload THUNK_GENERATOR(0) },
       
    58     { "onloadstart", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestOnloadstart), (intptr_t)setJSXMLHttpRequestOnloadstart THUNK_GENERATOR(0) },
       
    59     { "onprogress", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestOnprogress), (intptr_t)setJSXMLHttpRequestOnprogress THUNK_GENERATOR(0) },
       
    60     { "onreadystatechange", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestOnreadystatechange), (intptr_t)setJSXMLHttpRequestOnreadystatechange THUNK_GENERATOR(0) },
       
    61     { "readyState", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestReadyState), (intptr_t)0 THUNK_GENERATOR(0) },
       
    62     { "withCredentials", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestWithCredentials), (intptr_t)setJSXMLHttpRequestWithCredentials THUNK_GENERATOR(0) },
       
    63     { "upload", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestUpload), (intptr_t)0 THUNK_GENERATOR(0) },
       
    64     { "responseText", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestResponseText), (intptr_t)0 THUNK_GENERATOR(0) },
       
    65     { "responseXML", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestResponseXML), (intptr_t)0 THUNK_GENERATOR(0) },
       
    66     { "status", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestStatus), (intptr_t)0 THUNK_GENERATOR(0) },
       
    67     { "statusText", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestStatusText), (intptr_t)0 THUNK_GENERATOR(0) },
       
    68     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestConstructor), (intptr_t)0 THUNK_GENERATOR(0) },
       
    69     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
    70 };
       
    71 
       
    72 #undef THUNK_GENERATOR
       
    73 static JSC_CONST_HASHTABLE HashTable JSXMLHttpRequestTable = { 35, 31, JSXMLHttpRequestTableValues, 0 };
       
    74 /* Hash table for constructor */
       
    75 #if ENABLE(JIT)
       
    76 #define THUNK_GENERATOR(generator) , generator
       
    77 #else
       
    78 #define THUNK_GENERATOR(generator)
       
    79 #endif
       
    80 
       
    81 static const HashTableValue JSXMLHttpRequestConstructorTableValues[6] =
       
    82 {
       
    83     { "UNSENT", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestUNSENT), (intptr_t)0 THUNK_GENERATOR(0) },
       
    84     { "OPENED", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestOPENED), (intptr_t)0 THUNK_GENERATOR(0) },
       
    85     { "HEADERS_RECEIVED", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestHEADERS_RECEIVED), (intptr_t)0 THUNK_GENERATOR(0) },
       
    86     { "LOADING", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestLOADING), (intptr_t)0 THUNK_GENERATOR(0) },
       
    87     { "DONE", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestDONE), (intptr_t)0 THUNK_GENERATOR(0) },
       
    88     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
    89 };
       
    90 
       
    91 #undef THUNK_GENERATOR
       
    92 static JSC_CONST_HASHTABLE HashTable JSXMLHttpRequestConstructorTable = { 16, 15, JSXMLHttpRequestConstructorTableValues, 0 };
       
    93 
       
    94 COMPILE_ASSERT(0 == XMLHttpRequest::UNSENT, XMLHttpRequestEnumUNSENTIsWrongUseDontCheckEnums);
       
    95 COMPILE_ASSERT(1 == XMLHttpRequest::OPENED, XMLHttpRequestEnumOPENEDIsWrongUseDontCheckEnums);
       
    96 COMPILE_ASSERT(2 == XMLHttpRequest::HEADERS_RECEIVED, XMLHttpRequestEnumHEADERS_RECEIVEDIsWrongUseDontCheckEnums);
       
    97 COMPILE_ASSERT(3 == XMLHttpRequest::LOADING, XMLHttpRequestEnumLOADINGIsWrongUseDontCheckEnums);
       
    98 COMPILE_ASSERT(4 == XMLHttpRequest::DONE, XMLHttpRequestEnumDONEIsWrongUseDontCheckEnums);
       
    99 
       
   100 const ClassInfo JSXMLHttpRequestConstructor::s_info = { "XMLHttpRequestConstructor", 0, &JSXMLHttpRequestConstructorTable, 0 };
       
   101 
       
   102 JSXMLHttpRequestConstructor::JSXMLHttpRequestConstructor(ExecState* exec, JSDOMGlobalObject* globalObject)
       
   103     : DOMConstructorObject(JSXMLHttpRequestConstructor::createStructure(globalObject->objectPrototype()), globalObject)
       
   104 {
       
   105     putDirect(exec->propertyNames().prototype, JSXMLHttpRequestPrototype::self(exec, globalObject), DontDelete | ReadOnly);
       
   106 }
       
   107 
       
   108 bool JSXMLHttpRequestConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   109 {
       
   110     return getStaticValueSlot<JSXMLHttpRequestConstructor, DOMObject>(exec, &JSXMLHttpRequestConstructorTable, this, propertyName, slot);
       
   111 }
       
   112 
       
   113 bool JSXMLHttpRequestConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
   114 {
       
   115     return getStaticValueDescriptor<JSXMLHttpRequestConstructor, DOMObject>(exec, &JSXMLHttpRequestConstructorTable, this, propertyName, descriptor);
       
   116 }
       
   117 
       
   118 ConstructType JSXMLHttpRequestConstructor::getConstructData(ConstructData& constructData)
       
   119 {
       
   120     constructData.native.function = constructJSXMLHttpRequest;
       
   121     return ConstructTypeHost;
       
   122 }
       
   123 
       
   124 /* Hash table for prototype */
       
   125 #if ENABLE(JIT)
       
   126 #define THUNK_GENERATOR(generator) , generator
       
   127 #else
       
   128 #define THUNK_GENERATOR(generator)
       
   129 #endif
       
   130 
       
   131 static const HashTableValue JSXMLHttpRequestPrototypeTableValues[16] =
       
   132 {
       
   133     { "UNSENT", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestUNSENT), (intptr_t)0 THUNK_GENERATOR(0) },
       
   134     { "OPENED", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestOPENED), (intptr_t)0 THUNK_GENERATOR(0) },
       
   135     { "HEADERS_RECEIVED", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestHEADERS_RECEIVED), (intptr_t)0 THUNK_GENERATOR(0) },
       
   136     { "LOADING", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestLOADING), (intptr_t)0 THUNK_GENERATOR(0) },
       
   137     { "DONE", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsXMLHttpRequestDONE), (intptr_t)0 THUNK_GENERATOR(0) },
       
   138     { "open", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsXMLHttpRequestPrototypeFunctionOpen), (intptr_t)5 THUNK_GENERATOR(0) },
       
   139     { "setRequestHeader", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsXMLHttpRequestPrototypeFunctionSetRequestHeader), (intptr_t)2 THUNK_GENERATOR(0) },
       
   140     { "send", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsXMLHttpRequestPrototypeFunctionSend), (intptr_t)1 THUNK_GENERATOR(0) },
       
   141     { "abort", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsXMLHttpRequestPrototypeFunctionAbort), (intptr_t)0 THUNK_GENERATOR(0) },
       
   142     { "getAllResponseHeaders", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsXMLHttpRequestPrototypeFunctionGetAllResponseHeaders), (intptr_t)0 THUNK_GENERATOR(0) },
       
   143     { "getResponseHeader", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsXMLHttpRequestPrototypeFunctionGetResponseHeader), (intptr_t)1 THUNK_GENERATOR(0) },
       
   144     { "overrideMimeType", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsXMLHttpRequestPrototypeFunctionOverrideMimeType), (intptr_t)1 THUNK_GENERATOR(0) },
       
   145     { "addEventListener", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsXMLHttpRequestPrototypeFunctionAddEventListener), (intptr_t)3 THUNK_GENERATOR(0) },
       
   146     { "removeEventListener", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsXMLHttpRequestPrototypeFunctionRemoveEventListener), (intptr_t)3 THUNK_GENERATOR(0) },
       
   147     { "dispatchEvent", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsXMLHttpRequestPrototypeFunctionDispatchEvent), (intptr_t)1 THUNK_GENERATOR(0) },
       
   148     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
   149 };
       
   150 
       
   151 #undef THUNK_GENERATOR
       
   152 static JSC_CONST_HASHTABLE HashTable JSXMLHttpRequestPrototypeTable = { 37, 31, JSXMLHttpRequestPrototypeTableValues, 0 };
       
   153 static const HashTable* getJSXMLHttpRequestPrototypeTable(ExecState* exec)
       
   154 {
       
   155     return getHashTableForGlobalData(exec->globalData(), &JSXMLHttpRequestPrototypeTable);
       
   156 }
       
   157 const ClassInfo JSXMLHttpRequestPrototype::s_info = { "XMLHttpRequestPrototype", 0, 0, getJSXMLHttpRequestPrototypeTable };
       
   158 
       
   159 JSObject* JSXMLHttpRequestPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
       
   160 {
       
   161     return getDOMPrototype<JSXMLHttpRequest>(exec, globalObject);
       
   162 }
       
   163 
       
   164 bool JSXMLHttpRequestPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   165 {
       
   166     return getStaticPropertySlot<JSXMLHttpRequestPrototype, JSObject>(exec, getJSXMLHttpRequestPrototypeTable(exec), this, propertyName, slot);
       
   167 }
       
   168 
       
   169 bool JSXMLHttpRequestPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
   170 {
       
   171     return getStaticPropertyDescriptor<JSXMLHttpRequestPrototype, JSObject>(exec, getJSXMLHttpRequestPrototypeTable(exec), this, propertyName, descriptor);
       
   172 }
       
   173 
       
   174 static const HashTable* getJSXMLHttpRequestTable(ExecState* exec)
       
   175 {
       
   176     return getHashTableForGlobalData(exec->globalData(), &JSXMLHttpRequestTable);
       
   177 }
       
   178 const ClassInfo JSXMLHttpRequest::s_info = { "XMLHttpRequest", 0, 0, getJSXMLHttpRequestTable };
       
   179 
       
   180 JSXMLHttpRequest::JSXMLHttpRequest(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<XMLHttpRequest> impl)
       
   181     : DOMObjectWithGlobalPointer(structure, globalObject)
       
   182     , m_impl(impl)
       
   183 {
       
   184 }
       
   185 
       
   186 JSXMLHttpRequest::~JSXMLHttpRequest()
       
   187 {
       
   188     impl()->invalidateJSEventListeners(this);
       
   189     forgetDOMObject(this, impl());
       
   190 }
       
   191 
       
   192 JSObject* JSXMLHttpRequest::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
       
   193 {
       
   194     return new (exec) JSXMLHttpRequestPrototype(globalObject, JSXMLHttpRequestPrototype::createStructure(globalObject->objectPrototype()));
       
   195 }
       
   196 
       
   197 bool JSXMLHttpRequest::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   198 {
       
   199     return getStaticValueSlot<JSXMLHttpRequest, Base>(exec, getJSXMLHttpRequestTable(exec), this, propertyName, slot);
       
   200 }
       
   201 
       
   202 bool JSXMLHttpRequest::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
   203 {
       
   204     return getStaticValueDescriptor<JSXMLHttpRequest, Base>(exec, getJSXMLHttpRequestTable(exec), this, propertyName, descriptor);
       
   205 }
       
   206 
       
   207 JSValue jsXMLHttpRequestOnabort(ExecState* exec, JSValue slotBase, const Identifier&)
       
   208 {
       
   209     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slotBase));
       
   210     UNUSED_PARAM(exec);
       
   211     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
       
   212     if (EventListener* listener = imp->onabort()) {
       
   213         if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {
       
   214             if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext()))
       
   215                 return jsFunction;
       
   216         }
       
   217     }
       
   218     return jsNull();
       
   219 }
       
   220 
       
   221 JSValue jsXMLHttpRequestOnerror(ExecState* exec, JSValue slotBase, const Identifier&)
       
   222 {
       
   223     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slotBase));
       
   224     UNUSED_PARAM(exec);
       
   225     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
       
   226     if (EventListener* listener = imp->onerror()) {
       
   227         if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {
       
   228             if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext()))
       
   229                 return jsFunction;
       
   230         }
       
   231     }
       
   232     return jsNull();
       
   233 }
       
   234 
       
   235 JSValue jsXMLHttpRequestOnload(ExecState* exec, JSValue slotBase, const Identifier&)
       
   236 {
       
   237     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slotBase));
       
   238     UNUSED_PARAM(exec);
       
   239     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
       
   240     if (EventListener* listener = imp->onload()) {
       
   241         if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {
       
   242             if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext()))
       
   243                 return jsFunction;
       
   244         }
       
   245     }
       
   246     return jsNull();
       
   247 }
       
   248 
       
   249 JSValue jsXMLHttpRequestOnloadstart(ExecState* exec, JSValue slotBase, const Identifier&)
       
   250 {
       
   251     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slotBase));
       
   252     UNUSED_PARAM(exec);
       
   253     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
       
   254     if (EventListener* listener = imp->onloadstart()) {
       
   255         if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {
       
   256             if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext()))
       
   257                 return jsFunction;
       
   258         }
       
   259     }
       
   260     return jsNull();
       
   261 }
       
   262 
       
   263 JSValue jsXMLHttpRequestOnprogress(ExecState* exec, JSValue slotBase, const Identifier&)
       
   264 {
       
   265     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slotBase));
       
   266     UNUSED_PARAM(exec);
       
   267     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
       
   268     if (EventListener* listener = imp->onprogress()) {
       
   269         if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {
       
   270             if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext()))
       
   271                 return jsFunction;
       
   272         }
       
   273     }
       
   274     return jsNull();
       
   275 }
       
   276 
       
   277 JSValue jsXMLHttpRequestOnreadystatechange(ExecState* exec, JSValue slotBase, const Identifier&)
       
   278 {
       
   279     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slotBase));
       
   280     UNUSED_PARAM(exec);
       
   281     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
       
   282     if (EventListener* listener = imp->onreadystatechange()) {
       
   283         if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {
       
   284             if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext()))
       
   285                 return jsFunction;
       
   286         }
       
   287     }
       
   288     return jsNull();
       
   289 }
       
   290 
       
   291 JSValue jsXMLHttpRequestReadyState(ExecState* exec, JSValue slotBase, const Identifier&)
       
   292 {
       
   293     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slotBase));
       
   294     UNUSED_PARAM(exec);
       
   295     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
       
   296     JSValue result = jsNumber(exec, imp->readyState());
       
   297     return result;
       
   298 }
       
   299 
       
   300 JSValue jsXMLHttpRequestWithCredentials(ExecState* exec, JSValue slotBase, const Identifier&)
       
   301 {
       
   302     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slotBase));
       
   303     UNUSED_PARAM(exec);
       
   304     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
       
   305     JSValue result = jsBoolean(imp->withCredentials());
       
   306     return result;
       
   307 }
       
   308 
       
   309 JSValue jsXMLHttpRequestUpload(ExecState* exec, JSValue slotBase, const Identifier&)
       
   310 {
       
   311     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slotBase));
       
   312     UNUSED_PARAM(exec);
       
   313     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
       
   314     JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->upload()));
       
   315     return result;
       
   316 }
       
   317 
       
   318 JSValue jsXMLHttpRequestResponseText(ExecState* exec, JSValue slotBase, const Identifier&)
       
   319 {
       
   320     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slotBase));
       
   321     return castedThis->responseText(exec);
       
   322 }
       
   323 
       
   324 JSValue jsXMLHttpRequestResponseXML(ExecState* exec, JSValue slotBase, const Identifier&)
       
   325 {
       
   326     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slotBase));
       
   327     UNUSED_PARAM(exec);
       
   328     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
       
   329     JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->responseXML()));
       
   330     return result;
       
   331 }
       
   332 
       
   333 JSValue jsXMLHttpRequestStatus(ExecState* exec, JSValue slotBase, const Identifier&)
       
   334 {
       
   335     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slotBase));
       
   336     ExceptionCode ec = 0;
       
   337     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
       
   338     JSC::JSValue result = jsNumber(exec, imp->status(ec));
       
   339     setDOMException(exec, ec);
       
   340     return result;
       
   341 }
       
   342 
       
   343 JSValue jsXMLHttpRequestStatusText(ExecState* exec, JSValue slotBase, const Identifier&)
       
   344 {
       
   345     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(slotBase));
       
   346     ExceptionCode ec = 0;
       
   347     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
       
   348     JSC::JSValue result = jsString(exec, imp->statusText(ec));
       
   349     setDOMException(exec, ec);
       
   350     return result;
       
   351 }
       
   352 
       
   353 JSValue jsXMLHttpRequestConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
       
   354 {
       
   355     JSXMLHttpRequest* domObject = static_cast<JSXMLHttpRequest*>(asObject(slotBase));
       
   356     return JSXMLHttpRequest::getConstructor(exec, domObject->globalObject());
       
   357 }
       
   358 void JSXMLHttpRequest::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
       
   359 {
       
   360     lookupPut<JSXMLHttpRequest, Base>(exec, propertyName, value, getJSXMLHttpRequestTable(exec), this, slot);
       
   361 }
       
   362 
       
   363 void setJSXMLHttpRequestOnabort(ExecState* exec, JSObject* thisObject, JSValue value)
       
   364 {
       
   365     UNUSED_PARAM(exec);
       
   366     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(thisObject)->impl());
       
   367     imp->setOnabort(createJSAttributeEventListener(exec, value, thisObject));
       
   368 }
       
   369 
       
   370 void setJSXMLHttpRequestOnerror(ExecState* exec, JSObject* thisObject, JSValue value)
       
   371 {
       
   372     UNUSED_PARAM(exec);
       
   373     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(thisObject)->impl());
       
   374     imp->setOnerror(createJSAttributeEventListener(exec, value, thisObject));
       
   375 }
       
   376 
       
   377 void setJSXMLHttpRequestOnload(ExecState* exec, JSObject* thisObject, JSValue value)
       
   378 {
       
   379     UNUSED_PARAM(exec);
       
   380     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(thisObject)->impl());
       
   381     imp->setOnload(createJSAttributeEventListener(exec, value, thisObject));
       
   382 }
       
   383 
       
   384 void setJSXMLHttpRequestOnloadstart(ExecState* exec, JSObject* thisObject, JSValue value)
       
   385 {
       
   386     UNUSED_PARAM(exec);
       
   387     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(thisObject)->impl());
       
   388     imp->setOnloadstart(createJSAttributeEventListener(exec, value, thisObject));
       
   389 }
       
   390 
       
   391 void setJSXMLHttpRequestOnprogress(ExecState* exec, JSObject* thisObject, JSValue value)
       
   392 {
       
   393     UNUSED_PARAM(exec);
       
   394     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(thisObject)->impl());
       
   395     imp->setOnprogress(createJSAttributeEventListener(exec, value, thisObject));
       
   396 }
       
   397 
       
   398 void setJSXMLHttpRequestOnreadystatechange(ExecState* exec, JSObject* thisObject, JSValue value)
       
   399 {
       
   400     UNUSED_PARAM(exec);
       
   401     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(thisObject)->impl());
       
   402     imp->setOnreadystatechange(createJSAttributeEventListener(exec, value, thisObject));
       
   403 }
       
   404 
       
   405 void setJSXMLHttpRequestWithCredentials(ExecState* exec, JSObject* thisObject, JSValue value)
       
   406 {
       
   407     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(thisObject);
       
   408     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
       
   409     ExceptionCode ec = 0;
       
   410     imp->setWithCredentials(value.toBoolean(exec), ec);
       
   411     setDOMException(exec, ec);
       
   412 }
       
   413 
       
   414 JSValue JSXMLHttpRequest::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
       
   415 {
       
   416     return getDOMConstructor<JSXMLHttpRequestConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
       
   417 }
       
   418 
       
   419 EncodedJSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionOpen(ExecState* exec)
       
   420 {
       
   421     JSValue thisValue = exec->hostThisValue();
       
   422     if (!thisValue.inherits(&JSXMLHttpRequest::s_info))
       
   423         return throwVMTypeError(exec);
       
   424     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(thisValue));
       
   425     return JSValue::encode(castedThis->open(exec));
       
   426 }
       
   427 
       
   428 EncodedJSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionSetRequestHeader(ExecState* exec)
       
   429 {
       
   430     JSValue thisValue = exec->hostThisValue();
       
   431     if (!thisValue.inherits(&JSXMLHttpRequest::s_info))
       
   432         return throwVMTypeError(exec);
       
   433     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(thisValue));
       
   434     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
       
   435     if (exec->argumentCount() < 2)
       
   436         return throwVMError(exec, createSyntaxError(exec, "Not enough arguments"));
       
   437     ExceptionCode ec = 0;
       
   438     const String& header = ustringToString(exec->argument(0).toString(exec));
       
   439     const String& value = ustringToString(exec->argument(1).toString(exec));
       
   440 
       
   441     imp->setRequestHeader(header, value, ec);
       
   442     setDOMException(exec, ec);
       
   443     return JSValue::encode(jsUndefined());
       
   444 }
       
   445 
       
   446 EncodedJSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionSend(ExecState* exec)
       
   447 {
       
   448     JSValue thisValue = exec->hostThisValue();
       
   449     if (!thisValue.inherits(&JSXMLHttpRequest::s_info))
       
   450         return throwVMTypeError(exec);
       
   451     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(thisValue));
       
   452     return JSValue::encode(castedThis->send(exec));
       
   453 }
       
   454 
       
   455 EncodedJSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionAbort(ExecState* exec)
       
   456 {
       
   457     JSValue thisValue = exec->hostThisValue();
       
   458     if (!thisValue.inherits(&JSXMLHttpRequest::s_info))
       
   459         return throwVMTypeError(exec);
       
   460     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(thisValue));
       
   461     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
       
   462 
       
   463     imp->abort();
       
   464     return JSValue::encode(jsUndefined());
       
   465 }
       
   466 
       
   467 EncodedJSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionGetAllResponseHeaders(ExecState* exec)
       
   468 {
       
   469     JSValue thisValue = exec->hostThisValue();
       
   470     if (!thisValue.inherits(&JSXMLHttpRequest::s_info))
       
   471         return throwVMTypeError(exec);
       
   472     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(thisValue));
       
   473     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
       
   474     ExceptionCode ec = 0;
       
   475 
       
   476 
       
   477     JSC::JSValue result = jsStringOrUndefined(exec, imp->getAllResponseHeaders(ec));
       
   478     setDOMException(exec, ec);
       
   479     return JSValue::encode(result);
       
   480 }
       
   481 
       
   482 EncodedJSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionGetResponseHeader(ExecState* exec)
       
   483 {
       
   484     JSValue thisValue = exec->hostThisValue();
       
   485     if (!thisValue.inherits(&JSXMLHttpRequest::s_info))
       
   486         return throwVMTypeError(exec);
       
   487     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(thisValue));
       
   488     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
       
   489     if (exec->argumentCount() < 1)
       
   490         return throwVMError(exec, createSyntaxError(exec, "Not enough arguments"));
       
   491     ExceptionCode ec = 0;
       
   492     const String& header = ustringToString(exec->argument(0).toString(exec));
       
   493 
       
   494 
       
   495     JSC::JSValue result = jsStringOrNull(exec, imp->getResponseHeader(header, ec));
       
   496     setDOMException(exec, ec);
       
   497     return JSValue::encode(result);
       
   498 }
       
   499 
       
   500 EncodedJSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionOverrideMimeType(ExecState* exec)
       
   501 {
       
   502     JSValue thisValue = exec->hostThisValue();
       
   503     if (!thisValue.inherits(&JSXMLHttpRequest::s_info))
       
   504         return throwVMTypeError(exec);
       
   505     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(thisValue));
       
   506     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
       
   507     if (exec->argumentCount() < 1)
       
   508         return throwVMError(exec, createSyntaxError(exec, "Not enough arguments"));
       
   509     const String& override = ustringToString(exec->argument(0).toString(exec));
       
   510 
       
   511     imp->overrideMimeType(override);
       
   512     return JSValue::encode(jsUndefined());
       
   513 }
       
   514 
       
   515 EncodedJSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionAddEventListener(ExecState* exec)
       
   516 {
       
   517     JSValue thisValue = exec->hostThisValue();
       
   518     if (!thisValue.inherits(&JSXMLHttpRequest::s_info))
       
   519         return throwVMTypeError(exec);
       
   520     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(thisValue));
       
   521     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
       
   522     JSValue listener = exec->argument(1);
       
   523     if (!listener.isObject())
       
   524         return JSValue::encode(jsUndefined());
       
   525     imp->addEventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)), exec->argument(2).toBoolean(exec));
       
   526     return JSValue::encode(jsUndefined());
       
   527 }
       
   528 
       
   529 EncodedJSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionRemoveEventListener(ExecState* exec)
       
   530 {
       
   531     JSValue thisValue = exec->hostThisValue();
       
   532     if (!thisValue.inherits(&JSXMLHttpRequest::s_info))
       
   533         return throwVMTypeError(exec);
       
   534     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(thisValue));
       
   535     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
       
   536     JSValue listener = exec->argument(1);
       
   537     if (!listener.isObject())
       
   538         return JSValue::encode(jsUndefined());
       
   539     imp->removeEventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)).get(), exec->argument(2).toBoolean(exec));
       
   540     return JSValue::encode(jsUndefined());
       
   541 }
       
   542 
       
   543 EncodedJSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionDispatchEvent(ExecState* exec)
       
   544 {
       
   545     JSValue thisValue = exec->hostThisValue();
       
   546     if (!thisValue.inherits(&JSXMLHttpRequest::s_info))
       
   547         return throwVMTypeError(exec);
       
   548     JSXMLHttpRequest* castedThis = static_cast<JSXMLHttpRequest*>(asObject(thisValue));
       
   549     XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThis->impl());
       
   550     ExceptionCode ec = 0;
       
   551     Event* evt = toEvent(exec->argument(0));
       
   552 
       
   553 
       
   554     JSC::JSValue result = jsBoolean(imp->dispatchEvent(evt, ec));
       
   555     setDOMException(exec, ec);
       
   556     return JSValue::encode(result);
       
   557 }
       
   558 
       
   559 // Constant getters
       
   560 
       
   561 JSValue jsXMLHttpRequestUNSENT(ExecState* exec, JSValue, const Identifier&)
       
   562 {
       
   563     return jsNumber(exec, static_cast<int>(0));
       
   564 }
       
   565 
       
   566 JSValue jsXMLHttpRequestOPENED(ExecState* exec, JSValue, const Identifier&)
       
   567 {
       
   568     return jsNumber(exec, static_cast<int>(1));
       
   569 }
       
   570 
       
   571 JSValue jsXMLHttpRequestHEADERS_RECEIVED(ExecState* exec, JSValue, const Identifier&)
       
   572 {
       
   573     return jsNumber(exec, static_cast<int>(2));
       
   574 }
       
   575 
       
   576 JSValue jsXMLHttpRequestLOADING(ExecState* exec, JSValue, const Identifier&)
       
   577 {
       
   578     return jsNumber(exec, static_cast<int>(3));
       
   579 }
       
   580 
       
   581 JSValue jsXMLHttpRequestDONE(ExecState* exec, JSValue, const Identifier&)
       
   582 {
       
   583     return jsNumber(exec, static_cast<int>(4));
       
   584 }
       
   585 
       
   586 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, XMLHttpRequest* object)
       
   587 {
       
   588     return getDOMObjectWrapper<JSXMLHttpRequest>(exec, globalObject, object);
       
   589 }
       
   590 XMLHttpRequest* toXMLHttpRequest(JSC::JSValue value)
       
   591 {
       
   592     return value.inherits(&JSXMLHttpRequest::s_info) ? static_cast<JSXMLHttpRequest*>(asObject(value))->impl() : 0;
       
   593 }
       
   594 
       
   595 }