WebCore/generated/JSWorker.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 "JSWorker.h"
       
    26 
       
    27 #include "EventListener.h"
       
    28 #include "JSEventListener.h"
       
    29 #include "Worker.h"
       
    30 #include <runtime/Error.h>
       
    31 #include <wtf/GetPtr.h>
       
    32 
       
    33 using namespace JSC;
       
    34 
       
    35 namespace WebCore {
       
    36 
       
    37 ASSERT_CLASS_FITS_IN_CELL(JSWorker);
       
    38 
       
    39 /* Hash table */
       
    40 #if ENABLE(JIT)
       
    41 #define THUNK_GENERATOR(generator) , generator
       
    42 #else
       
    43 #define THUNK_GENERATOR(generator)
       
    44 #endif
       
    45 
       
    46 static const HashTableValue JSWorkerTableValues[3] =
       
    47 {
       
    48     { "onmessage", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWorkerOnmessage), (intptr_t)setJSWorkerOnmessage THUNK_GENERATOR(0) },
       
    49     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWorkerConstructor), (intptr_t)0 THUNK_GENERATOR(0) },
       
    50     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
    51 };
       
    52 
       
    53 #undef THUNK_GENERATOR
       
    54 static JSC_CONST_HASHTABLE HashTable JSWorkerTable = { 4, 3, JSWorkerTableValues, 0 };
       
    55 /* Hash table for constructor */
       
    56 #if ENABLE(JIT)
       
    57 #define THUNK_GENERATOR(generator) , generator
       
    58 #else
       
    59 #define THUNK_GENERATOR(generator)
       
    60 #endif
       
    61 
       
    62 static const HashTableValue JSWorkerConstructorTableValues[1] =
       
    63 {
       
    64     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
    65 };
       
    66 
       
    67 #undef THUNK_GENERATOR
       
    68 static JSC_CONST_HASHTABLE HashTable JSWorkerConstructorTable = { 1, 0, JSWorkerConstructorTableValues, 0 };
       
    69 const ClassInfo JSWorkerConstructor::s_info = { "WorkerConstructor", 0, &JSWorkerConstructorTable, 0 };
       
    70 
       
    71 JSWorkerConstructor::JSWorkerConstructor(ExecState* exec, JSDOMGlobalObject* globalObject)
       
    72     : DOMConstructorObject(JSWorkerConstructor::createStructure(globalObject->objectPrototype()), globalObject)
       
    73 {
       
    74     putDirect(exec->propertyNames().prototype, JSWorkerPrototype::self(exec, globalObject), DontDelete | ReadOnly);
       
    75     putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontDelete | DontEnum);
       
    76 }
       
    77 
       
    78 bool JSWorkerConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
    79 {
       
    80     return getStaticValueSlot<JSWorkerConstructor, DOMObject>(exec, &JSWorkerConstructorTable, this, propertyName, slot);
       
    81 }
       
    82 
       
    83 bool JSWorkerConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
    84 {
       
    85     return getStaticValueDescriptor<JSWorkerConstructor, DOMObject>(exec, &JSWorkerConstructorTable, this, propertyName, descriptor);
       
    86 }
       
    87 
       
    88 ConstructType JSWorkerConstructor::getConstructData(ConstructData& constructData)
       
    89 {
       
    90     constructData.native.function = constructJSWorker;
       
    91     return ConstructTypeHost;
       
    92 }
       
    93 
       
    94 /* Hash table for prototype */
       
    95 #if ENABLE(JIT)
       
    96 #define THUNK_GENERATOR(generator) , generator
       
    97 #else
       
    98 #define THUNK_GENERATOR(generator)
       
    99 #endif
       
   100 
       
   101 static const HashTableValue JSWorkerPrototypeTableValues[3] =
       
   102 {
       
   103     { "postMessage", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsWorkerPrototypeFunctionPostMessage), (intptr_t)2 THUNK_GENERATOR(0) },
       
   104     { "terminate", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsWorkerPrototypeFunctionTerminate), (intptr_t)0 THUNK_GENERATOR(0) },
       
   105     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
   106 };
       
   107 
       
   108 #undef THUNK_GENERATOR
       
   109 static JSC_CONST_HASHTABLE HashTable JSWorkerPrototypeTable = { 5, 3, JSWorkerPrototypeTableValues, 0 };
       
   110 const ClassInfo JSWorkerPrototype::s_info = { "WorkerPrototype", 0, &JSWorkerPrototypeTable, 0 };
       
   111 
       
   112 JSObject* JSWorkerPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
       
   113 {
       
   114     return getDOMPrototype<JSWorker>(exec, globalObject);
       
   115 }
       
   116 
       
   117 bool JSWorkerPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   118 {
       
   119     return getStaticFunctionSlot<JSObject>(exec, &JSWorkerPrototypeTable, this, propertyName, slot);
       
   120 }
       
   121 
       
   122 bool JSWorkerPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
   123 {
       
   124     return getStaticFunctionDescriptor<JSObject>(exec, &JSWorkerPrototypeTable, this, propertyName, descriptor);
       
   125 }
       
   126 
       
   127 const ClassInfo JSWorker::s_info = { "Worker", &JSAbstractWorker::s_info, &JSWorkerTable, 0 };
       
   128 
       
   129 JSWorker::JSWorker(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<Worker> impl)
       
   130     : JSAbstractWorker(structure, globalObject, impl)
       
   131 {
       
   132 }
       
   133 
       
   134 JSObject* JSWorker::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
       
   135 {
       
   136     return new (exec) JSWorkerPrototype(globalObject, JSWorkerPrototype::createStructure(JSAbstractWorkerPrototype::self(exec, globalObject)));
       
   137 }
       
   138 
       
   139 bool JSWorker::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   140 {
       
   141     return getStaticValueSlot<JSWorker, Base>(exec, &JSWorkerTable, this, propertyName, slot);
       
   142 }
       
   143 
       
   144 bool JSWorker::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
   145 {
       
   146     return getStaticValueDescriptor<JSWorker, Base>(exec, &JSWorkerTable, this, propertyName, descriptor);
       
   147 }
       
   148 
       
   149 JSValue jsWorkerOnmessage(ExecState* exec, JSValue slotBase, const Identifier&)
       
   150 {
       
   151     JSWorker* castedThis = static_cast<JSWorker*>(asObject(slotBase));
       
   152     UNUSED_PARAM(exec);
       
   153     Worker* imp = static_cast<Worker*>(castedThis->impl());
       
   154     if (EventListener* listener = imp->onmessage()) {
       
   155         if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {
       
   156             if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext()))
       
   157                 return jsFunction;
       
   158         }
       
   159     }
       
   160     return jsNull();
       
   161 }
       
   162 
       
   163 JSValue jsWorkerConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
       
   164 {
       
   165     JSWorker* domObject = static_cast<JSWorker*>(asObject(slotBase));
       
   166     return JSWorker::getConstructor(exec, domObject->globalObject());
       
   167 }
       
   168 void JSWorker::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
       
   169 {
       
   170     lookupPut<JSWorker, Base>(exec, propertyName, value, &JSWorkerTable, this, slot);
       
   171 }
       
   172 
       
   173 void setJSWorkerOnmessage(ExecState* exec, JSObject* thisObject, JSValue value)
       
   174 {
       
   175     UNUSED_PARAM(exec);
       
   176     Worker* imp = static_cast<Worker*>(static_cast<JSWorker*>(thisObject)->impl());
       
   177     imp->setOnmessage(createJSAttributeEventListener(exec, value, thisObject));
       
   178 }
       
   179 
       
   180 JSValue JSWorker::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
       
   181 {
       
   182     return getDOMConstructor<JSWorkerConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
       
   183 }
       
   184 
       
   185 EncodedJSValue JSC_HOST_CALL jsWorkerPrototypeFunctionPostMessage(ExecState* exec)
       
   186 {
       
   187     JSValue thisValue = exec->hostThisValue();
       
   188     if (!thisValue.inherits(&JSWorker::s_info))
       
   189         return throwVMTypeError(exec);
       
   190     JSWorker* castedThis = static_cast<JSWorker*>(asObject(thisValue));
       
   191     return JSValue::encode(castedThis->postMessage(exec));
       
   192 }
       
   193 
       
   194 EncodedJSValue JSC_HOST_CALL jsWorkerPrototypeFunctionTerminate(ExecState* exec)
       
   195 {
       
   196     JSValue thisValue = exec->hostThisValue();
       
   197     if (!thisValue.inherits(&JSWorker::s_info))
       
   198         return throwVMTypeError(exec);
       
   199     JSWorker* castedThis = static_cast<JSWorker*>(asObject(thisValue));
       
   200     Worker* imp = static_cast<Worker*>(castedThis->impl());
       
   201 
       
   202     imp->terminate();
       
   203     return JSValue::encode(jsUndefined());
       
   204 }
       
   205 
       
   206 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Worker* object)
       
   207 {
       
   208     return getDOMObjectWrapper<JSWorker>(exec, globalObject, object);
       
   209 }
       
   210 Worker* toWorker(JSC::JSValue value)
       
   211 {
       
   212     return value.inherits(&JSWorker::s_info) ? static_cast<JSWorker*>(asObject(value))->impl() : 0;
       
   213 }
       
   214 
       
   215 }
       
   216 
       
   217 #endif // ENABLE(WORKERS)