WebCore/generated/JSAbstractWorker.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(WORKERS)
       
    24 
       
    25 #include "JSAbstractWorker.h"
       
    26 
       
    27 #include "AbstractWorker.h"
       
    28 #include "Event.h"
       
    29 #include "EventListener.h"
       
    30 #include "JSEvent.h"
       
    31 #include "JSEventListener.h"
       
    32 #include "RegisteredEventListener.h"
       
    33 #include <runtime/Error.h>
       
    34 #include <wtf/GetPtr.h>
       
    35 
       
    36 using namespace JSC;
       
    37 
       
    38 namespace WebCore {
       
    39 
       
    40 ASSERT_CLASS_FITS_IN_CELL(JSAbstractWorker);
       
    41 
       
    42 /* Hash table */
       
    43 #if ENABLE(JIT)
       
    44 #define THUNK_GENERATOR(generator) , generator
       
    45 #else
       
    46 #define THUNK_GENERATOR(generator)
       
    47 #endif
       
    48 
       
    49 static const HashTableValue JSAbstractWorkerTableValues[3] =
       
    50 {
       
    51     { "onerror", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAbstractWorkerOnerror), (intptr_t)setJSAbstractWorkerOnerror THUNK_GENERATOR(0) },
       
    52     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAbstractWorkerConstructor), (intptr_t)0 THUNK_GENERATOR(0) },
       
    53     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
    54 };
       
    55 
       
    56 #undef THUNK_GENERATOR
       
    57 static JSC_CONST_HASHTABLE HashTable JSAbstractWorkerTable = { 4, 3, JSAbstractWorkerTableValues, 0 };
       
    58 /* Hash table for constructor */
       
    59 #if ENABLE(JIT)
       
    60 #define THUNK_GENERATOR(generator) , generator
       
    61 #else
       
    62 #define THUNK_GENERATOR(generator)
       
    63 #endif
       
    64 
       
    65 static const HashTableValue JSAbstractWorkerConstructorTableValues[1] =
       
    66 {
       
    67     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
    68 };
       
    69 
       
    70 #undef THUNK_GENERATOR
       
    71 static JSC_CONST_HASHTABLE HashTable JSAbstractWorkerConstructorTable = { 1, 0, JSAbstractWorkerConstructorTableValues, 0 };
       
    72 class JSAbstractWorkerConstructor : public DOMConstructorObject {
       
    73 public:
       
    74     JSAbstractWorkerConstructor(JSC::ExecState*, JSDOMGlobalObject*);
       
    75 
       
    76     virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);
       
    77     virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&);
       
    78     virtual const JSC::ClassInfo* classInfo() const { return &s_info; }
       
    79     static const JSC::ClassInfo s_info;
       
    80     static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)
       
    81     {
       
    82         return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);
       
    83     }
       
    84 protected:
       
    85     static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags;
       
    86 };
       
    87 
       
    88 const ClassInfo JSAbstractWorkerConstructor::s_info = { "AbstractWorkerConstructor", 0, &JSAbstractWorkerConstructorTable, 0 };
       
    89 
       
    90 JSAbstractWorkerConstructor::JSAbstractWorkerConstructor(ExecState* exec, JSDOMGlobalObject* globalObject)
       
    91     : DOMConstructorObject(JSAbstractWorkerConstructor::createStructure(globalObject->objectPrototype()), globalObject)
       
    92 {
       
    93     putDirect(exec->propertyNames().prototype, JSAbstractWorkerPrototype::self(exec, globalObject), DontDelete | ReadOnly);
       
    94 }
       
    95 
       
    96 bool JSAbstractWorkerConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
    97 {
       
    98     return getStaticValueSlot<JSAbstractWorkerConstructor, DOMObject>(exec, &JSAbstractWorkerConstructorTable, this, propertyName, slot);
       
    99 }
       
   100 
       
   101 bool JSAbstractWorkerConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
   102 {
       
   103     return getStaticValueDescriptor<JSAbstractWorkerConstructor, DOMObject>(exec, &JSAbstractWorkerConstructorTable, this, propertyName, descriptor);
       
   104 }
       
   105 
       
   106 /* Hash table for prototype */
       
   107 #if ENABLE(JIT)
       
   108 #define THUNK_GENERATOR(generator) , generator
       
   109 #else
       
   110 #define THUNK_GENERATOR(generator)
       
   111 #endif
       
   112 
       
   113 static const HashTableValue JSAbstractWorkerPrototypeTableValues[4] =
       
   114 {
       
   115     { "addEventListener", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsAbstractWorkerPrototypeFunctionAddEventListener), (intptr_t)3 THUNK_GENERATOR(0) },
       
   116     { "removeEventListener", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsAbstractWorkerPrototypeFunctionRemoveEventListener), (intptr_t)3 THUNK_GENERATOR(0) },
       
   117     { "dispatchEvent", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsAbstractWorkerPrototypeFunctionDispatchEvent), (intptr_t)1 THUNK_GENERATOR(0) },
       
   118     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
   119 };
       
   120 
       
   121 #undef THUNK_GENERATOR
       
   122 static JSC_CONST_HASHTABLE HashTable JSAbstractWorkerPrototypeTable = { 8, 7, JSAbstractWorkerPrototypeTableValues, 0 };
       
   123 const ClassInfo JSAbstractWorkerPrototype::s_info = { "AbstractWorkerPrototype", 0, &JSAbstractWorkerPrototypeTable, 0 };
       
   124 
       
   125 JSObject* JSAbstractWorkerPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
       
   126 {
       
   127     return getDOMPrototype<JSAbstractWorker>(exec, globalObject);
       
   128 }
       
   129 
       
   130 bool JSAbstractWorkerPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   131 {
       
   132     return getStaticFunctionSlot<JSObject>(exec, &JSAbstractWorkerPrototypeTable, this, propertyName, slot);
       
   133 }
       
   134 
       
   135 bool JSAbstractWorkerPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
   136 {
       
   137     return getStaticFunctionDescriptor<JSObject>(exec, &JSAbstractWorkerPrototypeTable, this, propertyName, descriptor);
       
   138 }
       
   139 
       
   140 const ClassInfo JSAbstractWorker::s_info = { "AbstractWorker", 0, &JSAbstractWorkerTable, 0 };
       
   141 
       
   142 JSAbstractWorker::JSAbstractWorker(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<AbstractWorker> impl)
       
   143     : DOMObjectWithGlobalPointer(structure, globalObject)
       
   144     , m_impl(impl)
       
   145 {
       
   146 }
       
   147 
       
   148 JSAbstractWorker::~JSAbstractWorker()
       
   149 {
       
   150     impl()->invalidateJSEventListeners(this);
       
   151     forgetDOMObject(this, impl());
       
   152 }
       
   153 
       
   154 void JSAbstractWorker::markChildren(MarkStack& markStack)
       
   155 {
       
   156     Base::markChildren(markStack);
       
   157     impl()->markJSEventListeners(markStack);
       
   158 }
       
   159 
       
   160 JSObject* JSAbstractWorker::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
       
   161 {
       
   162     return new (exec) JSAbstractWorkerPrototype(globalObject, JSAbstractWorkerPrototype::createStructure(globalObject->objectPrototype()));
       
   163 }
       
   164 
       
   165 bool JSAbstractWorker::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   166 {
       
   167     return getStaticValueSlot<JSAbstractWorker, Base>(exec, &JSAbstractWorkerTable, this, propertyName, slot);
       
   168 }
       
   169 
       
   170 bool JSAbstractWorker::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
   171 {
       
   172     return getStaticValueDescriptor<JSAbstractWorker, Base>(exec, &JSAbstractWorkerTable, this, propertyName, descriptor);
       
   173 }
       
   174 
       
   175 JSValue jsAbstractWorkerOnerror(ExecState* exec, JSValue slotBase, const Identifier&)
       
   176 {
       
   177     JSAbstractWorker* castedThis = static_cast<JSAbstractWorker*>(asObject(slotBase));
       
   178     UNUSED_PARAM(exec);
       
   179     AbstractWorker* imp = static_cast<AbstractWorker*>(castedThis->impl());
       
   180     if (EventListener* listener = imp->onerror()) {
       
   181         if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {
       
   182             if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext()))
       
   183                 return jsFunction;
       
   184         }
       
   185     }
       
   186     return jsNull();
       
   187 }
       
   188 
       
   189 JSValue jsAbstractWorkerConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
       
   190 {
       
   191     JSAbstractWorker* domObject = static_cast<JSAbstractWorker*>(asObject(slotBase));
       
   192     return JSAbstractWorker::getConstructor(exec, domObject->globalObject());
       
   193 }
       
   194 void JSAbstractWorker::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
       
   195 {
       
   196     lookupPut<JSAbstractWorker, Base>(exec, propertyName, value, &JSAbstractWorkerTable, this, slot);
       
   197 }
       
   198 
       
   199 void setJSAbstractWorkerOnerror(ExecState* exec, JSObject* thisObject, JSValue value)
       
   200 {
       
   201     UNUSED_PARAM(exec);
       
   202     AbstractWorker* imp = static_cast<AbstractWorker*>(static_cast<JSAbstractWorker*>(thisObject)->impl());
       
   203     imp->setOnerror(createJSAttributeEventListener(exec, value, thisObject));
       
   204 }
       
   205 
       
   206 JSValue JSAbstractWorker::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
       
   207 {
       
   208     return getDOMConstructor<JSAbstractWorkerConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
       
   209 }
       
   210 
       
   211 EncodedJSValue JSC_HOST_CALL jsAbstractWorkerPrototypeFunctionAddEventListener(ExecState* exec)
       
   212 {
       
   213     JSValue thisValue = exec->hostThisValue();
       
   214     if (!thisValue.inherits(&JSAbstractWorker::s_info))
       
   215         return throwVMTypeError(exec);
       
   216     JSAbstractWorker* castedThis = static_cast<JSAbstractWorker*>(asObject(thisValue));
       
   217     AbstractWorker* imp = static_cast<AbstractWorker*>(castedThis->impl());
       
   218     JSValue listener = exec->argument(1);
       
   219     if (!listener.isObject())
       
   220         return JSValue::encode(jsUndefined());
       
   221     imp->addEventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)), exec->argument(2).toBoolean(exec));
       
   222     return JSValue::encode(jsUndefined());
       
   223 }
       
   224 
       
   225 EncodedJSValue JSC_HOST_CALL jsAbstractWorkerPrototypeFunctionRemoveEventListener(ExecState* exec)
       
   226 {
       
   227     JSValue thisValue = exec->hostThisValue();
       
   228     if (!thisValue.inherits(&JSAbstractWorker::s_info))
       
   229         return throwVMTypeError(exec);
       
   230     JSAbstractWorker* castedThis = static_cast<JSAbstractWorker*>(asObject(thisValue));
       
   231     AbstractWorker* imp = static_cast<AbstractWorker*>(castedThis->impl());
       
   232     JSValue listener = exec->argument(1);
       
   233     if (!listener.isObject())
       
   234         return JSValue::encode(jsUndefined());
       
   235     imp->removeEventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)).get(), exec->argument(2).toBoolean(exec));
       
   236     return JSValue::encode(jsUndefined());
       
   237 }
       
   238 
       
   239 EncodedJSValue JSC_HOST_CALL jsAbstractWorkerPrototypeFunctionDispatchEvent(ExecState* exec)
       
   240 {
       
   241     JSValue thisValue = exec->hostThisValue();
       
   242     if (!thisValue.inherits(&JSAbstractWorker::s_info))
       
   243         return throwVMTypeError(exec);
       
   244     JSAbstractWorker* castedThis = static_cast<JSAbstractWorker*>(asObject(thisValue));
       
   245     AbstractWorker* imp = static_cast<AbstractWorker*>(castedThis->impl());
       
   246     ExceptionCode ec = 0;
       
   247     Event* evt = toEvent(exec->argument(0));
       
   248 
       
   249 
       
   250     JSC::JSValue result = jsBoolean(imp->dispatchEvent(evt, ec));
       
   251     setDOMException(exec, ec);
       
   252     return JSValue::encode(result);
       
   253 }
       
   254 
       
   255 AbstractWorker* toAbstractWorker(JSC::JSValue value)
       
   256 {
       
   257     return value.inherits(&JSAbstractWorker::s_info) ? static_cast<JSAbstractWorker*>(asObject(value))->impl() : 0;
       
   258 }
       
   259 
       
   260 }
       
   261 
       
   262 #endif // ENABLE(WORKERS)