WebCore/generated/JSNotificationCenter.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 "JSNotificationCenter.h"
       
    26 
       
    27 #include "JSNotification.h"
       
    28 #include "Notification.h"
       
    29 #include "NotificationCenter.h"
       
    30 #include <runtime/Error.h>
       
    31 #include <runtime/JSNumberCell.h>
       
    32 #include <wtf/GetPtr.h>
       
    33 
       
    34 using namespace JSC;
       
    35 
       
    36 namespace WebCore {
       
    37 
       
    38 ASSERT_CLASS_FITS_IN_CELL(JSNotificationCenter);
       
    39 
       
    40 /* Hash table for prototype */
       
    41 #if ENABLE(JIT)
       
    42 #define THUNK_GENERATOR(generator) , generator
       
    43 #else
       
    44 #define THUNK_GENERATOR(generator)
       
    45 #endif
       
    46 
       
    47 static const HashTableValue JSNotificationCenterPrototypeTableValues[5] =
       
    48 {
       
    49     { "createHTMLNotification", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsNotificationCenterPrototypeFunctionCreateHTMLNotification), (intptr_t)1 THUNK_GENERATOR(0) },
       
    50     { "createNotification", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsNotificationCenterPrototypeFunctionCreateNotification), (intptr_t)3 THUNK_GENERATOR(0) },
       
    51     { "checkPermission", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsNotificationCenterPrototypeFunctionCheckPermission), (intptr_t)0 THUNK_GENERATOR(0) },
       
    52     { "requestPermission", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsNotificationCenterPrototypeFunctionRequestPermission), (intptr_t)1 THUNK_GENERATOR(0) },
       
    53     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
    54 };
       
    55 
       
    56 #undef THUNK_GENERATOR
       
    57 static JSC_CONST_HASHTABLE HashTable JSNotificationCenterPrototypeTable = { 8, 7, JSNotificationCenterPrototypeTableValues, 0 };
       
    58 const ClassInfo JSNotificationCenterPrototype::s_info = { "NotificationCenterPrototype", 0, &JSNotificationCenterPrototypeTable, 0 };
       
    59 
       
    60 JSObject* JSNotificationCenterPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
       
    61 {
       
    62     return getDOMPrototype<JSNotificationCenter>(exec, globalObject);
       
    63 }
       
    64 
       
    65 bool JSNotificationCenterPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
    66 {
       
    67     return getStaticFunctionSlot<JSObject>(exec, &JSNotificationCenterPrototypeTable, this, propertyName, slot);
       
    68 }
       
    69 
       
    70 bool JSNotificationCenterPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
    71 {
       
    72     return getStaticFunctionDescriptor<JSObject>(exec, &JSNotificationCenterPrototypeTable, this, propertyName, descriptor);
       
    73 }
       
    74 
       
    75 const ClassInfo JSNotificationCenter::s_info = { "NotificationCenter", 0, 0, 0 };
       
    76 
       
    77 JSNotificationCenter::JSNotificationCenter(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<NotificationCenter> impl)
       
    78     : DOMObjectWithGlobalPointer(structure, globalObject)
       
    79     , m_impl(impl)
       
    80 {
       
    81 }
       
    82 
       
    83 JSNotificationCenter::~JSNotificationCenter()
       
    84 {
       
    85     forgetDOMObject(this, impl());
       
    86 }
       
    87 
       
    88 JSObject* JSNotificationCenter::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
       
    89 {
       
    90     return new (exec) JSNotificationCenterPrototype(globalObject, JSNotificationCenterPrototype::createStructure(globalObject->objectPrototype()));
       
    91 }
       
    92 
       
    93 EncodedJSValue JSC_HOST_CALL jsNotificationCenterPrototypeFunctionCreateHTMLNotification(ExecState* exec)
       
    94 {
       
    95     JSValue thisValue = exec->hostThisValue();
       
    96     if (!thisValue.inherits(&JSNotificationCenter::s_info))
       
    97         return throwVMTypeError(exec);
       
    98     JSNotificationCenter* castedThis = static_cast<JSNotificationCenter*>(asObject(thisValue));
       
    99     NotificationCenter* imp = static_cast<NotificationCenter*>(castedThis->impl());
       
   100     ExceptionCode ec = 0;
       
   101     const String& url = ustringToString(exec->argument(0).toString(exec));
       
   102 
       
   103 
       
   104     JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->createHTMLNotification(url, ec)));
       
   105     setDOMException(exec, ec);
       
   106     return JSValue::encode(result);
       
   107 }
       
   108 
       
   109 EncodedJSValue JSC_HOST_CALL jsNotificationCenterPrototypeFunctionCreateNotification(ExecState* exec)
       
   110 {
       
   111     JSValue thisValue = exec->hostThisValue();
       
   112     if (!thisValue.inherits(&JSNotificationCenter::s_info))
       
   113         return throwVMTypeError(exec);
       
   114     JSNotificationCenter* castedThis = static_cast<JSNotificationCenter*>(asObject(thisValue));
       
   115     NotificationCenter* imp = static_cast<NotificationCenter*>(castedThis->impl());
       
   116     ExceptionCode ec = 0;
       
   117     const String& iconUrl = ustringToString(exec->argument(0).toString(exec));
       
   118     const String& title = ustringToString(exec->argument(1).toString(exec));
       
   119     const String& body = ustringToString(exec->argument(2).toString(exec));
       
   120 
       
   121 
       
   122     JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->createNotification(iconUrl, title, body, ec)));
       
   123     setDOMException(exec, ec);
       
   124     return JSValue::encode(result);
       
   125 }
       
   126 
       
   127 EncodedJSValue JSC_HOST_CALL jsNotificationCenterPrototypeFunctionCheckPermission(ExecState* exec)
       
   128 {
       
   129     JSValue thisValue = exec->hostThisValue();
       
   130     if (!thisValue.inherits(&JSNotificationCenter::s_info))
       
   131         return throwVMTypeError(exec);
       
   132     JSNotificationCenter* castedThis = static_cast<JSNotificationCenter*>(asObject(thisValue));
       
   133     NotificationCenter* imp = static_cast<NotificationCenter*>(castedThis->impl());
       
   134 
       
   135 
       
   136     JSC::JSValue result = jsNumber(exec, imp->checkPermission());
       
   137     return JSValue::encode(result);
       
   138 }
       
   139 
       
   140 EncodedJSValue JSC_HOST_CALL jsNotificationCenterPrototypeFunctionRequestPermission(ExecState* exec)
       
   141 {
       
   142     JSValue thisValue = exec->hostThisValue();
       
   143     if (!thisValue.inherits(&JSNotificationCenter::s_info))
       
   144         return throwVMTypeError(exec);
       
   145     JSNotificationCenter* castedThis = static_cast<JSNotificationCenter*>(asObject(thisValue));
       
   146     return JSValue::encode(castedThis->requestPermission(exec));
       
   147 }
       
   148 
       
   149 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, NotificationCenter* object)
       
   150 {
       
   151     return getDOMObjectWrapper<JSNotificationCenter>(exec, globalObject, object);
       
   152 }
       
   153 NotificationCenter* toNotificationCenter(JSC::JSValue value)
       
   154 {
       
   155     return value.inherits(&JSNotificationCenter::s_info) ? static_cast<JSNotificationCenter*>(asObject(value))->impl() : 0;
       
   156 }
       
   157 
       
   158 }
       
   159 
       
   160 #endif // ENABLE(NOTIFICATIONS)