webengine/osswebengine/DerivedSources/WebCore/JSHistory.cpp
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     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 #include "JSHistory.h"
       
    24 
       
    25 #include <wtf/GetPtr.h>
       
    26 
       
    27 #include "ExceptionCode.h"
       
    28 #include "History.h"
       
    29 
       
    30 using namespace KJS;
       
    31 
       
    32 namespace WebCore {
       
    33 
       
    34 /* Hash table */
       
    35 
       
    36 static const HashEntry JSHistoryTableEntries[] =
       
    37 {
       
    38     { "length", JSHistory::LengthAttrNum, DontDelete|ReadOnly, 0, 0 }
       
    39 };
       
    40 
       
    41 static const HashTable JSHistoryTable = 
       
    42 {
       
    43     2, 1, JSHistoryTableEntries, 1
       
    44 };
       
    45 
       
    46 /* Hash table for prototype */
       
    47 
       
    48 static const HashEntry JSHistoryPrototypeTableEntries[] =
       
    49 {
       
    50     { 0, 0, 0, 0, 0 },
       
    51     { "forward", JSHistory::ForwardFuncNum, DontDelete|Function, 0, 0 },
       
    52     { "back", JSHistory::BackFuncNum, DontDelete|Function, 0, &JSHistoryPrototypeTableEntries[3] },
       
    53     { "go", JSHistory::GoFuncNum, DontDelete|Function, 1, 0 }
       
    54 };
       
    55 
       
    56 static const HashTable JSHistoryPrototypeTable = 
       
    57 {
       
    58     2, 4, JSHistoryPrototypeTableEntries, 3
       
    59 };
       
    60 
       
    61 const ClassInfo JSHistoryPrototype::info = { "HistoryPrototype", 0, &JSHistoryPrototypeTable, 0 };
       
    62 
       
    63 JSObject* JSHistoryPrototype::self(ExecState* exec)
       
    64 {
       
    65     return KJS::cacheGlobalObject<JSHistoryPrototype>(exec, "[[JSHistory.prototype]]");
       
    66 }
       
    67 
       
    68 bool JSHistoryPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
    69 {
       
    70     return getStaticFunctionSlot<JSHistoryPrototypeFunction, JSObject>(exec, &JSHistoryPrototypeTable, this, propertyName, slot);
       
    71 }
       
    72 
       
    73 const ClassInfo JSHistory::info = { "History", 0, &JSHistoryTable, 0 };
       
    74 
       
    75 JSHistory::JSHistory(ExecState* exec, History* impl)
       
    76     : m_impl(impl)
       
    77 {
       
    78     setPrototype(JSHistoryPrototype::self(exec));
       
    79 }
       
    80 
       
    81 JSHistory::~JSHistory()
       
    82 {
       
    83     ScriptInterpreter::forgetDOMObject(m_impl.get());
       
    84 }
       
    85 
       
    86 bool JSHistory::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
    87 {
       
    88     return getStaticValueSlot<JSHistory, KJS::DOMObject>(exec, &JSHistoryTable, this, propertyName, slot);
       
    89 }
       
    90 
       
    91 JSValue* JSHistory::getValueProperty(ExecState* exec, int token) const
       
    92 {
       
    93     switch (token) {
       
    94     case LengthAttrNum: {
       
    95         History* imp = static_cast<History*>(impl());
       
    96 
       
    97         return jsNumber(imp->length());
       
    98     }
       
    99     }
       
   100     return 0;
       
   101 }
       
   102 
       
   103 JSValue* JSHistoryPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
       
   104 {
       
   105     if (!thisObj->inherits(&JSHistory::info))
       
   106       return throwError(exec, TypeError);
       
   107 
       
   108     History* imp = static_cast<History*>(static_cast<JSHistory*>(thisObj)->impl());
       
   109 
       
   110     switch (id) {
       
   111     case JSHistory::BackFuncNum: {
       
   112 
       
   113         imp->back();
       
   114         return jsUndefined();
       
   115     }
       
   116     case JSHistory::ForwardFuncNum: {
       
   117 
       
   118         imp->forward();
       
   119         return jsUndefined();
       
   120     }
       
   121     case JSHistory::GoFuncNum: {
       
   122         bool distanceOk;
       
   123         int distance = args[0]->toInt32(exec, distanceOk);
       
   124         if (!distanceOk) {
       
   125             setDOMException(exec, TYPE_MISMATCH_ERR);
       
   126             return jsUndefined();
       
   127         }
       
   128 
       
   129         imp->go(distance);
       
   130         return jsUndefined();
       
   131     }
       
   132     }
       
   133     return 0;
       
   134 }
       
   135 KJS::JSValue* toJS(KJS::ExecState* exec, History* obj)
       
   136 {
       
   137     return KJS::cacheDOMObject<History, JSHistory>(exec, obj);
       
   138 }
       
   139 History* toHistory(KJS::JSValue* val)
       
   140 {
       
   141     return val->isObject(&JSHistory::info) ? static_cast<JSHistory*>(val)->impl() : 0;
       
   142 }
       
   143 
       
   144 }