diff -r 000000000000 -r 4f2f89ce4247 WebCore/generated/JSXMLHttpRequest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WebCore/generated/JSXMLHttpRequest.cpp Fri Sep 17 09:02:29 2010 +0300 @@ -0,0 +1,595 @@ +/* + This file is part of the WebKit open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" +#include "JSXMLHttpRequest.h" + +#include "Document.h" +#include "Event.h" +#include "EventListener.h" +#include "JSDocument.h" +#include "JSEvent.h" +#include "JSEventListener.h" +#include "JSXMLHttpRequestUpload.h" +#include "KURL.h" +#include "RegisteredEventListener.h" +#include "XMLHttpRequest.h" +#include "XMLHttpRequestUpload.h" +#include +#include +#include +#include + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSXMLHttpRequest); + +/* Hash table */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSXMLHttpRequestTableValues[15] = +{ + { "onabort", DontDelete, (intptr_t)static_cast(jsXMLHttpRequestOnabort), (intptr_t)setJSXMLHttpRequestOnabort THUNK_GENERATOR(0) }, + { "onerror", DontDelete, (intptr_t)static_cast(jsXMLHttpRequestOnerror), (intptr_t)setJSXMLHttpRequestOnerror THUNK_GENERATOR(0) }, + { "onload", DontDelete, (intptr_t)static_cast(jsXMLHttpRequestOnload), (intptr_t)setJSXMLHttpRequestOnload THUNK_GENERATOR(0) }, + { "onloadstart", DontDelete, (intptr_t)static_cast(jsXMLHttpRequestOnloadstart), (intptr_t)setJSXMLHttpRequestOnloadstart THUNK_GENERATOR(0) }, + { "onprogress", DontDelete, (intptr_t)static_cast(jsXMLHttpRequestOnprogress), (intptr_t)setJSXMLHttpRequestOnprogress THUNK_GENERATOR(0) }, + { "onreadystatechange", DontDelete, (intptr_t)static_cast(jsXMLHttpRequestOnreadystatechange), (intptr_t)setJSXMLHttpRequestOnreadystatechange THUNK_GENERATOR(0) }, + { "readyState", DontDelete | ReadOnly, (intptr_t)static_cast(jsXMLHttpRequestReadyState), (intptr_t)0 THUNK_GENERATOR(0) }, + { "withCredentials", DontDelete, (intptr_t)static_cast(jsXMLHttpRequestWithCredentials), (intptr_t)setJSXMLHttpRequestWithCredentials THUNK_GENERATOR(0) }, + { "upload", DontDelete | ReadOnly, (intptr_t)static_cast(jsXMLHttpRequestUpload), (intptr_t)0 THUNK_GENERATOR(0) }, + { "responseText", DontDelete | ReadOnly, (intptr_t)static_cast(jsXMLHttpRequestResponseText), (intptr_t)0 THUNK_GENERATOR(0) }, + { "responseXML", DontDelete | ReadOnly, (intptr_t)static_cast(jsXMLHttpRequestResponseXML), (intptr_t)0 THUNK_GENERATOR(0) }, + { "status", DontDelete | ReadOnly, (intptr_t)static_cast(jsXMLHttpRequestStatus), (intptr_t)0 THUNK_GENERATOR(0) }, + { "statusText", DontDelete | ReadOnly, (intptr_t)static_cast(jsXMLHttpRequestStatusText), (intptr_t)0 THUNK_GENERATOR(0) }, + { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast(jsXMLHttpRequestConstructor), (intptr_t)0 THUNK_GENERATOR(0) }, + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSXMLHttpRequestTable = { 35, 31, JSXMLHttpRequestTableValues, 0 }; +/* Hash table for constructor */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSXMLHttpRequestConstructorTableValues[6] = +{ + { "UNSENT", DontDelete | ReadOnly, (intptr_t)static_cast(jsXMLHttpRequestUNSENT), (intptr_t)0 THUNK_GENERATOR(0) }, + { "OPENED", DontDelete | ReadOnly, (intptr_t)static_cast(jsXMLHttpRequestOPENED), (intptr_t)0 THUNK_GENERATOR(0) }, + { "HEADERS_RECEIVED", DontDelete | ReadOnly, (intptr_t)static_cast(jsXMLHttpRequestHEADERS_RECEIVED), (intptr_t)0 THUNK_GENERATOR(0) }, + { "LOADING", DontDelete | ReadOnly, (intptr_t)static_cast(jsXMLHttpRequestLOADING), (intptr_t)0 THUNK_GENERATOR(0) }, + { "DONE", DontDelete | ReadOnly, (intptr_t)static_cast(jsXMLHttpRequestDONE), (intptr_t)0 THUNK_GENERATOR(0) }, + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSXMLHttpRequestConstructorTable = { 16, 15, JSXMLHttpRequestConstructorTableValues, 0 }; + +COMPILE_ASSERT(0 == XMLHttpRequest::UNSENT, XMLHttpRequestEnumUNSENTIsWrongUseDontCheckEnums); +COMPILE_ASSERT(1 == XMLHttpRequest::OPENED, XMLHttpRequestEnumOPENEDIsWrongUseDontCheckEnums); +COMPILE_ASSERT(2 == XMLHttpRequest::HEADERS_RECEIVED, XMLHttpRequestEnumHEADERS_RECEIVEDIsWrongUseDontCheckEnums); +COMPILE_ASSERT(3 == XMLHttpRequest::LOADING, XMLHttpRequestEnumLOADINGIsWrongUseDontCheckEnums); +COMPILE_ASSERT(4 == XMLHttpRequest::DONE, XMLHttpRequestEnumDONEIsWrongUseDontCheckEnums); + +const ClassInfo JSXMLHttpRequestConstructor::s_info = { "XMLHttpRequestConstructor", 0, &JSXMLHttpRequestConstructorTable, 0 }; + +JSXMLHttpRequestConstructor::JSXMLHttpRequestConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSXMLHttpRequestConstructor::createStructure(globalObject->objectPrototype()), globalObject) +{ + putDirect(exec->propertyNames().prototype, JSXMLHttpRequestPrototype::self(exec, globalObject), DontDelete | ReadOnly); +} + +bool JSXMLHttpRequestConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot(exec, &JSXMLHttpRequestConstructorTable, this, propertyName, slot); +} + +bool JSXMLHttpRequestConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor(exec, &JSXMLHttpRequestConstructorTable, this, propertyName, descriptor); +} + +ConstructType JSXMLHttpRequestConstructor::getConstructData(ConstructData& constructData) +{ + constructData.native.function = constructJSXMLHttpRequest; + return ConstructTypeHost; +} + +/* Hash table for prototype */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSXMLHttpRequestPrototypeTableValues[16] = +{ + { "UNSENT", DontDelete | ReadOnly, (intptr_t)static_cast(jsXMLHttpRequestUNSENT), (intptr_t)0 THUNK_GENERATOR(0) }, + { "OPENED", DontDelete | ReadOnly, (intptr_t)static_cast(jsXMLHttpRequestOPENED), (intptr_t)0 THUNK_GENERATOR(0) }, + { "HEADERS_RECEIVED", DontDelete | ReadOnly, (intptr_t)static_cast(jsXMLHttpRequestHEADERS_RECEIVED), (intptr_t)0 THUNK_GENERATOR(0) }, + { "LOADING", DontDelete | ReadOnly, (intptr_t)static_cast(jsXMLHttpRequestLOADING), (intptr_t)0 THUNK_GENERATOR(0) }, + { "DONE", DontDelete | ReadOnly, (intptr_t)static_cast(jsXMLHttpRequestDONE), (intptr_t)0 THUNK_GENERATOR(0) }, + { "open", DontDelete | Function, (intptr_t)static_cast(jsXMLHttpRequestPrototypeFunctionOpen), (intptr_t)5 THUNK_GENERATOR(0) }, + { "setRequestHeader", DontDelete | Function, (intptr_t)static_cast(jsXMLHttpRequestPrototypeFunctionSetRequestHeader), (intptr_t)2 THUNK_GENERATOR(0) }, + { "send", DontDelete | Function, (intptr_t)static_cast(jsXMLHttpRequestPrototypeFunctionSend), (intptr_t)1 THUNK_GENERATOR(0) }, + { "abort", DontDelete | Function, (intptr_t)static_cast(jsXMLHttpRequestPrototypeFunctionAbort), (intptr_t)0 THUNK_GENERATOR(0) }, + { "getAllResponseHeaders", DontDelete | Function, (intptr_t)static_cast(jsXMLHttpRequestPrototypeFunctionGetAllResponseHeaders), (intptr_t)0 THUNK_GENERATOR(0) }, + { "getResponseHeader", DontDelete | Function, (intptr_t)static_cast(jsXMLHttpRequestPrototypeFunctionGetResponseHeader), (intptr_t)1 THUNK_GENERATOR(0) }, + { "overrideMimeType", DontDelete | Function, (intptr_t)static_cast(jsXMLHttpRequestPrototypeFunctionOverrideMimeType), (intptr_t)1 THUNK_GENERATOR(0) }, + { "addEventListener", DontDelete | Function, (intptr_t)static_cast(jsXMLHttpRequestPrototypeFunctionAddEventListener), (intptr_t)3 THUNK_GENERATOR(0) }, + { "removeEventListener", DontDelete | Function, (intptr_t)static_cast(jsXMLHttpRequestPrototypeFunctionRemoveEventListener), (intptr_t)3 THUNK_GENERATOR(0) }, + { "dispatchEvent", DontDelete | Function, (intptr_t)static_cast(jsXMLHttpRequestPrototypeFunctionDispatchEvent), (intptr_t)1 THUNK_GENERATOR(0) }, + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSXMLHttpRequestPrototypeTable = { 37, 31, JSXMLHttpRequestPrototypeTableValues, 0 }; +static const HashTable* getJSXMLHttpRequestPrototypeTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSXMLHttpRequestPrototypeTable); +} +const ClassInfo JSXMLHttpRequestPrototype::s_info = { "XMLHttpRequestPrototype", 0, 0, getJSXMLHttpRequestPrototypeTable }; + +JSObject* JSXMLHttpRequestPrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype(exec, globalObject); +} + +bool JSXMLHttpRequestPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticPropertySlot(exec, getJSXMLHttpRequestPrototypeTable(exec), this, propertyName, slot); +} + +bool JSXMLHttpRequestPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticPropertyDescriptor(exec, getJSXMLHttpRequestPrototypeTable(exec), this, propertyName, descriptor); +} + +static const HashTable* getJSXMLHttpRequestTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSXMLHttpRequestTable); +} +const ClassInfo JSXMLHttpRequest::s_info = { "XMLHttpRequest", 0, 0, getJSXMLHttpRequestTable }; + +JSXMLHttpRequest::JSXMLHttpRequest(NonNullPassRefPtr structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) + : DOMObjectWithGlobalPointer(structure, globalObject) + , m_impl(impl) +{ +} + +JSXMLHttpRequest::~JSXMLHttpRequest() +{ + impl()->invalidateJSEventListeners(this); + forgetDOMObject(this, impl()); +} + +JSObject* JSXMLHttpRequest::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return new (exec) JSXMLHttpRequestPrototype(globalObject, JSXMLHttpRequestPrototype::createStructure(globalObject->objectPrototype())); +} + +bool JSXMLHttpRequest::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot(exec, getJSXMLHttpRequestTable(exec), this, propertyName, slot); +} + +bool JSXMLHttpRequest::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor(exec, getJSXMLHttpRequestTable(exec), this, propertyName, descriptor); +} + +JSValue jsXMLHttpRequestOnabort(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSXMLHttpRequest* castedThis = static_cast(asObject(slotBase)); + UNUSED_PARAM(exec); + XMLHttpRequest* imp = static_cast(castedThis->impl()); + if (EventListener* listener = imp->onabort()) { + if (const JSEventListener* jsListener = JSEventListener::cast(listener)) { + if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext())) + return jsFunction; + } + } + return jsNull(); +} + +JSValue jsXMLHttpRequestOnerror(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSXMLHttpRequest* castedThis = static_cast(asObject(slotBase)); + UNUSED_PARAM(exec); + XMLHttpRequest* imp = static_cast(castedThis->impl()); + if (EventListener* listener = imp->onerror()) { + if (const JSEventListener* jsListener = JSEventListener::cast(listener)) { + if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext())) + return jsFunction; + } + } + return jsNull(); +} + +JSValue jsXMLHttpRequestOnload(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSXMLHttpRequest* castedThis = static_cast(asObject(slotBase)); + UNUSED_PARAM(exec); + XMLHttpRequest* imp = static_cast(castedThis->impl()); + if (EventListener* listener = imp->onload()) { + if (const JSEventListener* jsListener = JSEventListener::cast(listener)) { + if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext())) + return jsFunction; + } + } + return jsNull(); +} + +JSValue jsXMLHttpRequestOnloadstart(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSXMLHttpRequest* castedThis = static_cast(asObject(slotBase)); + UNUSED_PARAM(exec); + XMLHttpRequest* imp = static_cast(castedThis->impl()); + if (EventListener* listener = imp->onloadstart()) { + if (const JSEventListener* jsListener = JSEventListener::cast(listener)) { + if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext())) + return jsFunction; + } + } + return jsNull(); +} + +JSValue jsXMLHttpRequestOnprogress(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSXMLHttpRequest* castedThis = static_cast(asObject(slotBase)); + UNUSED_PARAM(exec); + XMLHttpRequest* imp = static_cast(castedThis->impl()); + if (EventListener* listener = imp->onprogress()) { + if (const JSEventListener* jsListener = JSEventListener::cast(listener)) { + if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext())) + return jsFunction; + } + } + return jsNull(); +} + +JSValue jsXMLHttpRequestOnreadystatechange(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSXMLHttpRequest* castedThis = static_cast(asObject(slotBase)); + UNUSED_PARAM(exec); + XMLHttpRequest* imp = static_cast(castedThis->impl()); + if (EventListener* listener = imp->onreadystatechange()) { + if (const JSEventListener* jsListener = JSEventListener::cast(listener)) { + if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext())) + return jsFunction; + } + } + return jsNull(); +} + +JSValue jsXMLHttpRequestReadyState(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSXMLHttpRequest* castedThis = static_cast(asObject(slotBase)); + UNUSED_PARAM(exec); + XMLHttpRequest* imp = static_cast(castedThis->impl()); + JSValue result = jsNumber(exec, imp->readyState()); + return result; +} + +JSValue jsXMLHttpRequestWithCredentials(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSXMLHttpRequest* castedThis = static_cast(asObject(slotBase)); + UNUSED_PARAM(exec); + XMLHttpRequest* imp = static_cast(castedThis->impl()); + JSValue result = jsBoolean(imp->withCredentials()); + return result; +} + +JSValue jsXMLHttpRequestUpload(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSXMLHttpRequest* castedThis = static_cast(asObject(slotBase)); + UNUSED_PARAM(exec); + XMLHttpRequest* imp = static_cast(castedThis->impl()); + JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->upload())); + return result; +} + +JSValue jsXMLHttpRequestResponseText(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSXMLHttpRequest* castedThis = static_cast(asObject(slotBase)); + return castedThis->responseText(exec); +} + +JSValue jsXMLHttpRequestResponseXML(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSXMLHttpRequest* castedThis = static_cast(asObject(slotBase)); + UNUSED_PARAM(exec); + XMLHttpRequest* imp = static_cast(castedThis->impl()); + JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->responseXML())); + return result; +} + +JSValue jsXMLHttpRequestStatus(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSXMLHttpRequest* castedThis = static_cast(asObject(slotBase)); + ExceptionCode ec = 0; + XMLHttpRequest* imp = static_cast(castedThis->impl()); + JSC::JSValue result = jsNumber(exec, imp->status(ec)); + setDOMException(exec, ec); + return result; +} + +JSValue jsXMLHttpRequestStatusText(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSXMLHttpRequest* castedThis = static_cast(asObject(slotBase)); + ExceptionCode ec = 0; + XMLHttpRequest* imp = static_cast(castedThis->impl()); + JSC::JSValue result = jsString(exec, imp->statusText(ec)); + setDOMException(exec, ec); + return result; +} + +JSValue jsXMLHttpRequestConstructor(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSXMLHttpRequest* domObject = static_cast(asObject(slotBase)); + return JSXMLHttpRequest::getConstructor(exec, domObject->globalObject()); +} +void JSXMLHttpRequest::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) +{ + lookupPut(exec, propertyName, value, getJSXMLHttpRequestTable(exec), this, slot); +} + +void setJSXMLHttpRequestOnabort(ExecState* exec, JSObject* thisObject, JSValue value) +{ + UNUSED_PARAM(exec); + XMLHttpRequest* imp = static_cast(static_cast(thisObject)->impl()); + imp->setOnabort(createJSAttributeEventListener(exec, value, thisObject)); +} + +void setJSXMLHttpRequestOnerror(ExecState* exec, JSObject* thisObject, JSValue value) +{ + UNUSED_PARAM(exec); + XMLHttpRequest* imp = static_cast(static_cast(thisObject)->impl()); + imp->setOnerror(createJSAttributeEventListener(exec, value, thisObject)); +} + +void setJSXMLHttpRequestOnload(ExecState* exec, JSObject* thisObject, JSValue value) +{ + UNUSED_PARAM(exec); + XMLHttpRequest* imp = static_cast(static_cast(thisObject)->impl()); + imp->setOnload(createJSAttributeEventListener(exec, value, thisObject)); +} + +void setJSXMLHttpRequestOnloadstart(ExecState* exec, JSObject* thisObject, JSValue value) +{ + UNUSED_PARAM(exec); + XMLHttpRequest* imp = static_cast(static_cast(thisObject)->impl()); + imp->setOnloadstart(createJSAttributeEventListener(exec, value, thisObject)); +} + +void setJSXMLHttpRequestOnprogress(ExecState* exec, JSObject* thisObject, JSValue value) +{ + UNUSED_PARAM(exec); + XMLHttpRequest* imp = static_cast(static_cast(thisObject)->impl()); + imp->setOnprogress(createJSAttributeEventListener(exec, value, thisObject)); +} + +void setJSXMLHttpRequestOnreadystatechange(ExecState* exec, JSObject* thisObject, JSValue value) +{ + UNUSED_PARAM(exec); + XMLHttpRequest* imp = static_cast(static_cast(thisObject)->impl()); + imp->setOnreadystatechange(createJSAttributeEventListener(exec, value, thisObject)); +} + +void setJSXMLHttpRequestWithCredentials(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSXMLHttpRequest* castedThis = static_cast(thisObject); + XMLHttpRequest* imp = static_cast(castedThis->impl()); + ExceptionCode ec = 0; + imp->setWithCredentials(value.toBoolean(exec), ec); + setDOMException(exec, ec); +} + +JSValue JSXMLHttpRequest::getConstructor(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMConstructor(exec, static_cast(globalObject)); +} + +EncodedJSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionOpen(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSXMLHttpRequest::s_info)) + return throwVMTypeError(exec); + JSXMLHttpRequest* castedThis = static_cast(asObject(thisValue)); + return JSValue::encode(castedThis->open(exec)); +} + +EncodedJSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionSetRequestHeader(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSXMLHttpRequest::s_info)) + return throwVMTypeError(exec); + JSXMLHttpRequest* castedThis = static_cast(asObject(thisValue)); + XMLHttpRequest* imp = static_cast(castedThis->impl()); + if (exec->argumentCount() < 2) + return throwVMError(exec, createSyntaxError(exec, "Not enough arguments")); + ExceptionCode ec = 0; + const String& header = ustringToString(exec->argument(0).toString(exec)); + const String& value = ustringToString(exec->argument(1).toString(exec)); + + imp->setRequestHeader(header, value, ec); + setDOMException(exec, ec); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionSend(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSXMLHttpRequest::s_info)) + return throwVMTypeError(exec); + JSXMLHttpRequest* castedThis = static_cast(asObject(thisValue)); + return JSValue::encode(castedThis->send(exec)); +} + +EncodedJSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionAbort(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSXMLHttpRequest::s_info)) + return throwVMTypeError(exec); + JSXMLHttpRequest* castedThis = static_cast(asObject(thisValue)); + XMLHttpRequest* imp = static_cast(castedThis->impl()); + + imp->abort(); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionGetAllResponseHeaders(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSXMLHttpRequest::s_info)) + return throwVMTypeError(exec); + JSXMLHttpRequest* castedThis = static_cast(asObject(thisValue)); + XMLHttpRequest* imp = static_cast(castedThis->impl()); + ExceptionCode ec = 0; + + + JSC::JSValue result = jsStringOrUndefined(exec, imp->getAllResponseHeaders(ec)); + setDOMException(exec, ec); + return JSValue::encode(result); +} + +EncodedJSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionGetResponseHeader(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSXMLHttpRequest::s_info)) + return throwVMTypeError(exec); + JSXMLHttpRequest* castedThis = static_cast(asObject(thisValue)); + XMLHttpRequest* imp = static_cast(castedThis->impl()); + if (exec->argumentCount() < 1) + return throwVMError(exec, createSyntaxError(exec, "Not enough arguments")); + ExceptionCode ec = 0; + const String& header = ustringToString(exec->argument(0).toString(exec)); + + + JSC::JSValue result = jsStringOrNull(exec, imp->getResponseHeader(header, ec)); + setDOMException(exec, ec); + return JSValue::encode(result); +} + +EncodedJSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionOverrideMimeType(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSXMLHttpRequest::s_info)) + return throwVMTypeError(exec); + JSXMLHttpRequest* castedThis = static_cast(asObject(thisValue)); + XMLHttpRequest* imp = static_cast(castedThis->impl()); + if (exec->argumentCount() < 1) + return throwVMError(exec, createSyntaxError(exec, "Not enough arguments")); + const String& override = ustringToString(exec->argument(0).toString(exec)); + + imp->overrideMimeType(override); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionAddEventListener(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSXMLHttpRequest::s_info)) + return throwVMTypeError(exec); + JSXMLHttpRequest* castedThis = static_cast(asObject(thisValue)); + XMLHttpRequest* imp = static_cast(castedThis->impl()); + JSValue listener = exec->argument(1); + if (!listener.isObject()) + return JSValue::encode(jsUndefined()); + imp->addEventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)), exec->argument(2).toBoolean(exec)); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionRemoveEventListener(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSXMLHttpRequest::s_info)) + return throwVMTypeError(exec); + JSXMLHttpRequest* castedThis = static_cast(asObject(thisValue)); + XMLHttpRequest* imp = static_cast(castedThis->impl()); + JSValue listener = exec->argument(1); + if (!listener.isObject()) + return JSValue::encode(jsUndefined()); + imp->removeEventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)).get(), exec->argument(2).toBoolean(exec)); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsXMLHttpRequestPrototypeFunctionDispatchEvent(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSXMLHttpRequest::s_info)) + return throwVMTypeError(exec); + JSXMLHttpRequest* castedThis = static_cast(asObject(thisValue)); + XMLHttpRequest* imp = static_cast(castedThis->impl()); + ExceptionCode ec = 0; + Event* evt = toEvent(exec->argument(0)); + + + JSC::JSValue result = jsBoolean(imp->dispatchEvent(evt, ec)); + setDOMException(exec, ec); + return JSValue::encode(result); +} + +// Constant getters + +JSValue jsXMLHttpRequestUNSENT(ExecState* exec, JSValue, const Identifier&) +{ + return jsNumber(exec, static_cast(0)); +} + +JSValue jsXMLHttpRequestOPENED(ExecState* exec, JSValue, const Identifier&) +{ + return jsNumber(exec, static_cast(1)); +} + +JSValue jsXMLHttpRequestHEADERS_RECEIVED(ExecState* exec, JSValue, const Identifier&) +{ + return jsNumber(exec, static_cast(2)); +} + +JSValue jsXMLHttpRequestLOADING(ExecState* exec, JSValue, const Identifier&) +{ + return jsNumber(exec, static_cast(3)); +} + +JSValue jsXMLHttpRequestDONE(ExecState* exec, JSValue, const Identifier&) +{ + return jsNumber(exec, static_cast(4)); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, XMLHttpRequest* object) +{ + return getDOMObjectWrapper(exec, globalObject, object); +} +XMLHttpRequest* toXMLHttpRequest(JSC::JSValue value) +{ + return value.inherits(&JSXMLHttpRequest::s_info) ? static_cast(asObject(value))->impl() : 0; +} + +}