WebCore/generated/JSNotification.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(NOTIFICATIONS)
       
    24 
       
    25 #include "JSNotification.h"
       
    26 
       
    27 #include "Event.h"
       
    28 #include "EventListener.h"
       
    29 #include "JSEvent.h"
       
    30 #include "JSEventListener.h"
       
    31 #include "KURL.h"
       
    32 #include "Notification.h"
       
    33 #include "RegisteredEventListener.h"
       
    34 #include <runtime/Error.h>
       
    35 #include <runtime/JSString.h>
       
    36 #include <wtf/GetPtr.h>
       
    37 
       
    38 using namespace JSC;
       
    39 
       
    40 namespace WebCore {
       
    41 
       
    42 ASSERT_CLASS_FITS_IN_CELL(JSNotification);
       
    43 
       
    44 /* Hash table */
       
    45 #if ENABLE(JIT)
       
    46 #define THUNK_GENERATOR(generator) , generator
       
    47 #else
       
    48 #define THUNK_GENERATOR(generator)
       
    49 #endif
       
    50 
       
    51 static const HashTableValue JSNotificationTableValues[6] =
       
    52 {
       
    53     { "ondisplay", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNotificationOndisplay), (intptr_t)setJSNotificationOndisplay THUNK_GENERATOR(0) },
       
    54     { "onerror", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNotificationOnerror), (intptr_t)setJSNotificationOnerror THUNK_GENERATOR(0) },
       
    55     { "onclose", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNotificationOnclose), (intptr_t)setJSNotificationOnclose THUNK_GENERATOR(0) },
       
    56     { "dir", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNotificationDir), (intptr_t)setJSNotificationDir THUNK_GENERATOR(0) },
       
    57     { "replaceId", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNotificationReplaceId), (intptr_t)setJSNotificationReplaceId THUNK_GENERATOR(0) },
       
    58     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
    59 };
       
    60 
       
    61 #undef THUNK_GENERATOR
       
    62 static JSC_CONST_HASHTABLE HashTable JSNotificationTable = { 17, 15, JSNotificationTableValues, 0 };
       
    63 /* Hash table for prototype */
       
    64 #if ENABLE(JIT)
       
    65 #define THUNK_GENERATOR(generator) , generator
       
    66 #else
       
    67 #define THUNK_GENERATOR(generator)
       
    68 #endif
       
    69 
       
    70 static const HashTableValue JSNotificationPrototypeTableValues[6] =
       
    71 {
       
    72     { "show", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsNotificationPrototypeFunctionShow), (intptr_t)0 THUNK_GENERATOR(0) },
       
    73     { "cancel", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsNotificationPrototypeFunctionCancel), (intptr_t)0 THUNK_GENERATOR(0) },
       
    74     { "addEventListener", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsNotificationPrototypeFunctionAddEventListener), (intptr_t)3 THUNK_GENERATOR(0) },
       
    75     { "removeEventListener", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsNotificationPrototypeFunctionRemoveEventListener), (intptr_t)3 THUNK_GENERATOR(0) },
       
    76     { "dispatchEvent", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsNotificationPrototypeFunctionDispatchEvent), (intptr_t)1 THUNK_GENERATOR(0) },
       
    77     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
    78 };
       
    79 
       
    80 #undef THUNK_GENERATOR
       
    81 static JSC_CONST_HASHTABLE HashTable JSNotificationPrototypeTable = { 16, 15, JSNotificationPrototypeTableValues, 0 };
       
    82 const ClassInfo JSNotificationPrototype::s_info = { "NotificationPrototype", 0, &JSNotificationPrototypeTable, 0 };
       
    83 
       
    84 JSObject* JSNotificationPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
       
    85 {
       
    86     return getDOMPrototype<JSNotification>(exec, globalObject);
       
    87 }
       
    88 
       
    89 bool JSNotificationPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
    90 {
       
    91     return getStaticFunctionSlot<JSObject>(exec, &JSNotificationPrototypeTable, this, propertyName, slot);
       
    92 }
       
    93 
       
    94 bool JSNotificationPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
    95 {
       
    96     return getStaticFunctionDescriptor<JSObject>(exec, &JSNotificationPrototypeTable, this, propertyName, descriptor);
       
    97 }
       
    98 
       
    99 const ClassInfo JSNotification::s_info = { "Notification", 0, &JSNotificationTable, 0 };
       
   100 
       
   101 JSNotification::JSNotification(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<Notification> impl)
       
   102     : DOMObjectWithGlobalPointer(structure, globalObject)
       
   103     , m_impl(impl)
       
   104 {
       
   105 }
       
   106 
       
   107 JSNotification::~JSNotification()
       
   108 {
       
   109     impl()->invalidateJSEventListeners(this);
       
   110     forgetDOMObject(this, impl());
       
   111 }
       
   112 
       
   113 void JSNotification::markChildren(MarkStack& markStack)
       
   114 {
       
   115     Base::markChildren(markStack);
       
   116     impl()->markJSEventListeners(markStack);
       
   117 }
       
   118 
       
   119 JSObject* JSNotification::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
       
   120 {
       
   121     return new (exec) JSNotificationPrototype(globalObject, JSNotificationPrototype::createStructure(globalObject->objectPrototype()));
       
   122 }
       
   123 
       
   124 bool JSNotification::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   125 {
       
   126     return getStaticValueSlot<JSNotification, Base>(exec, &JSNotificationTable, this, propertyName, slot);
       
   127 }
       
   128 
       
   129 bool JSNotification::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
   130 {
       
   131     return getStaticValueDescriptor<JSNotification, Base>(exec, &JSNotificationTable, this, propertyName, descriptor);
       
   132 }
       
   133 
       
   134 JSValue jsNotificationOndisplay(ExecState* exec, JSValue slotBase, const Identifier&)
       
   135 {
       
   136     JSNotification* castedThis = static_cast<JSNotification*>(asObject(slotBase));
       
   137     UNUSED_PARAM(exec);
       
   138     Notification* imp = static_cast<Notification*>(castedThis->impl());
       
   139     if (EventListener* listener = imp->ondisplay()) {
       
   140         if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {
       
   141             if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext()))
       
   142                 return jsFunction;
       
   143         }
       
   144     }
       
   145     return jsNull();
       
   146 }
       
   147 
       
   148 JSValue jsNotificationOnerror(ExecState* exec, JSValue slotBase, const Identifier&)
       
   149 {
       
   150     JSNotification* castedThis = static_cast<JSNotification*>(asObject(slotBase));
       
   151     UNUSED_PARAM(exec);
       
   152     Notification* imp = static_cast<Notification*>(castedThis->impl());
       
   153     if (EventListener* listener = imp->onerror()) {
       
   154         if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {
       
   155             if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext()))
       
   156                 return jsFunction;
       
   157         }
       
   158     }
       
   159     return jsNull();
       
   160 }
       
   161 
       
   162 JSValue jsNotificationOnclose(ExecState* exec, JSValue slotBase, const Identifier&)
       
   163 {
       
   164     JSNotification* castedThis = static_cast<JSNotification*>(asObject(slotBase));
       
   165     UNUSED_PARAM(exec);
       
   166     Notification* imp = static_cast<Notification*>(castedThis->impl());
       
   167     if (EventListener* listener = imp->onclose()) {
       
   168         if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {
       
   169             if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext()))
       
   170                 return jsFunction;
       
   171         }
       
   172     }
       
   173     return jsNull();
       
   174 }
       
   175 
       
   176 JSValue jsNotificationDir(ExecState* exec, JSValue slotBase, const Identifier&)
       
   177 {
       
   178     JSNotification* castedThis = static_cast<JSNotification*>(asObject(slotBase));
       
   179     UNUSED_PARAM(exec);
       
   180     Notification* imp = static_cast<Notification*>(castedThis->impl());
       
   181     JSValue result = jsString(exec, imp->dir());
       
   182     return result;
       
   183 }
       
   184 
       
   185 JSValue jsNotificationReplaceId(ExecState* exec, JSValue slotBase, const Identifier&)
       
   186 {
       
   187     JSNotification* castedThis = static_cast<JSNotification*>(asObject(slotBase));
       
   188     UNUSED_PARAM(exec);
       
   189     Notification* imp = static_cast<Notification*>(castedThis->impl());
       
   190     JSValue result = jsString(exec, imp->replaceId());
       
   191     return result;
       
   192 }
       
   193 
       
   194 void JSNotification::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
       
   195 {
       
   196     lookupPut<JSNotification, Base>(exec, propertyName, value, &JSNotificationTable, this, slot);
       
   197 }
       
   198 
       
   199 void setJSNotificationOndisplay(ExecState* exec, JSObject* thisObject, JSValue value)
       
   200 {
       
   201     UNUSED_PARAM(exec);
       
   202     Notification* imp = static_cast<Notification*>(static_cast<JSNotification*>(thisObject)->impl());
       
   203     imp->setOndisplay(createJSAttributeEventListener(exec, value, thisObject));
       
   204 }
       
   205 
       
   206 void setJSNotificationOnerror(ExecState* exec, JSObject* thisObject, JSValue value)
       
   207 {
       
   208     UNUSED_PARAM(exec);
       
   209     Notification* imp = static_cast<Notification*>(static_cast<JSNotification*>(thisObject)->impl());
       
   210     imp->setOnerror(createJSAttributeEventListener(exec, value, thisObject));
       
   211 }
       
   212 
       
   213 void setJSNotificationOnclose(ExecState* exec, JSObject* thisObject, JSValue value)
       
   214 {
       
   215     UNUSED_PARAM(exec);
       
   216     Notification* imp = static_cast<Notification*>(static_cast<JSNotification*>(thisObject)->impl());
       
   217     imp->setOnclose(createJSAttributeEventListener(exec, value, thisObject));
       
   218 }
       
   219 
       
   220 void setJSNotificationDir(ExecState* exec, JSObject* thisObject, JSValue value)
       
   221 {
       
   222     JSNotification* castedThis = static_cast<JSNotification*>(thisObject);
       
   223     Notification* imp = static_cast<Notification*>(castedThis->impl());
       
   224     imp->setDir(ustringToString(value.toString(exec)));
       
   225 }
       
   226 
       
   227 void setJSNotificationReplaceId(ExecState* exec, JSObject* thisObject, JSValue value)
       
   228 {
       
   229     JSNotification* castedThis = static_cast<JSNotification*>(thisObject);
       
   230     Notification* imp = static_cast<Notification*>(castedThis->impl());
       
   231     imp->setReplaceId(ustringToString(value.toString(exec)));
       
   232 }
       
   233 
       
   234 EncodedJSValue JSC_HOST_CALL jsNotificationPrototypeFunctionShow(ExecState* exec)
       
   235 {
       
   236     JSValue thisValue = exec->hostThisValue();
       
   237     if (!thisValue.inherits(&JSNotification::s_info))
       
   238         return throwVMTypeError(exec);
       
   239     JSNotification* castedThis = static_cast<JSNotification*>(asObject(thisValue));
       
   240     Notification* imp = static_cast<Notification*>(castedThis->impl());
       
   241 
       
   242     imp->show();
       
   243     return JSValue::encode(jsUndefined());
       
   244 }
       
   245 
       
   246 EncodedJSValue JSC_HOST_CALL jsNotificationPrototypeFunctionCancel(ExecState* exec)
       
   247 {
       
   248     JSValue thisValue = exec->hostThisValue();
       
   249     if (!thisValue.inherits(&JSNotification::s_info))
       
   250         return throwVMTypeError(exec);
       
   251     JSNotification* castedThis = static_cast<JSNotification*>(asObject(thisValue));
       
   252     Notification* imp = static_cast<Notification*>(castedThis->impl());
       
   253 
       
   254     imp->cancel();
       
   255     return JSValue::encode(jsUndefined());
       
   256 }
       
   257 
       
   258 EncodedJSValue JSC_HOST_CALL jsNotificationPrototypeFunctionAddEventListener(ExecState* exec)
       
   259 {
       
   260     JSValue thisValue = exec->hostThisValue();
       
   261     if (!thisValue.inherits(&JSNotification::s_info))
       
   262         return throwVMTypeError(exec);
       
   263     JSNotification* castedThis = static_cast<JSNotification*>(asObject(thisValue));
       
   264     Notification* imp = static_cast<Notification*>(castedThis->impl());
       
   265     JSValue listener = exec->argument(1);
       
   266     if (!listener.isObject())
       
   267         return JSValue::encode(jsUndefined());
       
   268     imp->addEventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)), exec->argument(2).toBoolean(exec));
       
   269     return JSValue::encode(jsUndefined());
       
   270 }
       
   271 
       
   272 EncodedJSValue JSC_HOST_CALL jsNotificationPrototypeFunctionRemoveEventListener(ExecState* exec)
       
   273 {
       
   274     JSValue thisValue = exec->hostThisValue();
       
   275     if (!thisValue.inherits(&JSNotification::s_info))
       
   276         return throwVMTypeError(exec);
       
   277     JSNotification* castedThis = static_cast<JSNotification*>(asObject(thisValue));
       
   278     Notification* imp = static_cast<Notification*>(castedThis->impl());
       
   279     JSValue listener = exec->argument(1);
       
   280     if (!listener.isObject())
       
   281         return JSValue::encode(jsUndefined());
       
   282     imp->removeEventListener(ustringToAtomicString(exec->argument(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)).get(), exec->argument(2).toBoolean(exec));
       
   283     return JSValue::encode(jsUndefined());
       
   284 }
       
   285 
       
   286 EncodedJSValue JSC_HOST_CALL jsNotificationPrototypeFunctionDispatchEvent(ExecState* exec)
       
   287 {
       
   288     JSValue thisValue = exec->hostThisValue();
       
   289     if (!thisValue.inherits(&JSNotification::s_info))
       
   290         return throwVMTypeError(exec);
       
   291     JSNotification* castedThis = static_cast<JSNotification*>(asObject(thisValue));
       
   292     Notification* imp = static_cast<Notification*>(castedThis->impl());
       
   293     ExceptionCode ec = 0;
       
   294     Event* evt = toEvent(exec->argument(0));
       
   295 
       
   296 
       
   297     JSC::JSValue result = jsBoolean(imp->dispatchEvent(evt, ec));
       
   298     setDOMException(exec, ec);
       
   299     return JSValue::encode(result);
       
   300 }
       
   301 
       
   302 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Notification* object)
       
   303 {
       
   304     return getDOMObjectWrapper<JSNotification>(exec, globalObject, object);
       
   305 }
       
   306 Notification* toNotification(JSC::JSValue value)
       
   307 {
       
   308     return value.inherits(&JSNotification::s_info) ? static_cast<JSNotification*>(asObject(value))->impl() : 0;
       
   309 }
       
   310 
       
   311 }
       
   312 
       
   313 #endif // ENABLE(NOTIFICATIONS)