tizen beta release
[profile/ivi/webkit-efl.git] / DerivedSources / WebCore / JSHistory.cpp
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 #include "JSHistory.h"
23
24 #include "ExceptionCode.h"
25 #include "History.h"
26 #include "JSDOMBinding.h"
27 #include "JSHistoryCustom.h"
28 #include <runtime/Error.h>
29 #include <wtf/GetPtr.h>
30
31 using namespace JSC;
32
33 namespace WebCore {
34
35 ASSERT_CLASS_FITS_IN_CELL(JSHistory);
36
37 /* Hash table */
38 #if ENABLE(JIT)
39 #define THUNK_GENERATOR(generator) , generator
40 #else
41 #define THUNK_GENERATOR(generator)
42 #endif
43 #if ENABLE(DFG_JIT)
44 #define INTRINSIC(intrinsic) , intrinsic
45 #else
46 #define INTRINSIC(intrinsic)
47 #endif
48
49 static const HashTableValue JSHistoryTableValues[] =
50 {
51     { "length", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHistoryLength), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
52     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
53 };
54
55 #undef THUNK_GENERATOR
56 static const HashTable JSHistoryTable = { 2, 1, JSHistoryTableValues, 0 };
57 /* Hash table for prototype */
58 #if ENABLE(JIT)
59 #define THUNK_GENERATOR(generator) , generator
60 #else
61 #define THUNK_GENERATOR(generator)
62 #endif
63 #if ENABLE(DFG_JIT)
64 #define INTRINSIC(intrinsic) , intrinsic
65 #else
66 #define INTRINSIC(intrinsic)
67 #endif
68
69 static const HashTableValue JSHistoryPrototypeTableValues[] =
70 {
71     { "back", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsHistoryPrototypeFunctionBack), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
72     { "forward", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsHistoryPrototypeFunctionForward), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
73     { "go", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsHistoryPrototypeFunctionGo), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
74     { "pushState", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsHistoryPrototypeFunctionPushState), (intptr_t)3 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
75     { "replaceState", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsHistoryPrototypeFunctionReplaceState), (intptr_t)3 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
76     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
77 };
78
79 #undef THUNK_GENERATOR
80 static const HashTable JSHistoryPrototypeTable = { 17, 15, JSHistoryPrototypeTableValues, 0 };
81 const ClassInfo JSHistoryPrototype::s_info = { "HistoryPrototype", &JSC::JSNonFinalObject::s_info, &JSHistoryPrototypeTable, 0, CREATE_METHOD_TABLE(JSHistoryPrototype) };
82
83 JSObject* JSHistoryPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
84 {
85     return getDOMPrototype<JSHistory>(exec, globalObject);
86 }
87
88 bool JSHistoryPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
89 {
90     JSHistoryPrototype* thisObject = jsCast<JSHistoryPrototype*>(cell);
91     return getStaticFunctionSlot<JSObject>(exec, &JSHistoryPrototypeTable, thisObject, propertyName, slot);
92 }
93
94 bool JSHistoryPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
95 {
96     JSHistoryPrototype* thisObject = jsCast<JSHistoryPrototype*>(object);
97     return getStaticFunctionDescriptor<JSObject>(exec, &JSHistoryPrototypeTable, thisObject, propertyName, descriptor);
98 }
99
100 const ClassInfo JSHistory::s_info = { "History", &JSDOMWrapper::s_info, &JSHistoryTable, 0 , CREATE_METHOD_TABLE(JSHistory) };
101
102 JSHistory::JSHistory(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<History> impl)
103     : JSDOMWrapper(structure, globalObject)
104     , m_impl(impl.leakRef())
105 {
106 }
107
108 void JSHistory::finishCreation(JSGlobalData& globalData)
109 {
110     Base::finishCreation(globalData);
111     ASSERT(inherits(&s_info));
112 }
113
114 JSObject* JSHistory::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
115 {
116     return JSHistoryPrototype::create(exec->globalData(), globalObject, JSHistoryPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
117 }
118
119 bool JSHistory::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
120 {
121     JSHistory* thisObject = jsCast<JSHistory*>(cell);
122     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
123     if (thisObject->getOwnPropertySlotDelegate(exec, propertyName, slot))
124         return true;
125     return getStaticValueSlot<JSHistory, Base>(exec, &JSHistoryTable, thisObject, propertyName, slot);
126 }
127
128 bool JSHistory::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
129 {
130     JSHistory* thisObject = jsCast<JSHistory*>(object);
131     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
132     if (thisObject->getOwnPropertyDescriptorDelegate(exec, propertyName, descriptor))
133         return true;
134     return getStaticValueDescriptor<JSHistory, Base>(exec, &JSHistoryTable, thisObject, propertyName, descriptor);
135 }
136
137 JSValue jsHistoryLength(ExecState* exec, JSValue slotBase, const Identifier&)
138 {
139     JSHistory* castedThis = static_cast<JSHistory*>(asObject(slotBase));
140     UNUSED_PARAM(exec);
141     History* imp = static_cast<History*>(castedThis->impl());
142     JSValue result = jsNumber(imp->length());
143     return result;
144 }
145
146
147 void JSHistory::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
148 {
149     JSHistory* thisObject = jsCast<JSHistory*>(cell);
150     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
151     if (thisObject->putDelegate(exec, propertyName, value, slot))
152         return;
153     Base::put(thisObject, exec, propertyName, value, slot);
154 }
155
156 EncodedJSValue JSC_HOST_CALL jsHistoryPrototypeFunctionBack(ExecState* exec)
157 {
158     JSValue thisValue = exec->hostThisValue();
159     if (!thisValue.inherits(&JSHistory::s_info))
160         return throwVMTypeError(exec);
161     JSHistory* castedThis = static_cast<JSHistory*>(asObject(thisValue));
162     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSHistory::s_info);
163     History* imp = static_cast<History*>(castedThis->impl());
164     ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();
165     if (!scriptContext)
166         return JSValue::encode(jsUndefined());
167     imp->back(scriptContext);
168     return JSValue::encode(jsUndefined());
169 }
170
171 EncodedJSValue JSC_HOST_CALL jsHistoryPrototypeFunctionForward(ExecState* exec)
172 {
173     JSValue thisValue = exec->hostThisValue();
174     if (!thisValue.inherits(&JSHistory::s_info))
175         return throwVMTypeError(exec);
176     JSHistory* castedThis = static_cast<JSHistory*>(asObject(thisValue));
177     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSHistory::s_info);
178     History* imp = static_cast<History*>(castedThis->impl());
179     ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();
180     if (!scriptContext)
181         return JSValue::encode(jsUndefined());
182     imp->forward(scriptContext);
183     return JSValue::encode(jsUndefined());
184 }
185
186 EncodedJSValue JSC_HOST_CALL jsHistoryPrototypeFunctionGo(ExecState* exec)
187 {
188     JSValue thisValue = exec->hostThisValue();
189     if (!thisValue.inherits(&JSHistory::s_info))
190         return throwVMTypeError(exec);
191     JSHistory* castedThis = static_cast<JSHistory*>(asObject(thisValue));
192     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSHistory::s_info);
193     History* imp = static_cast<History*>(castedThis->impl());
194     ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();
195     if (!scriptContext)
196         return JSValue::encode(jsUndefined());
197     int distance(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toInt32(exec));
198     if (exec->hadException())
199         return JSValue::encode(jsUndefined());
200     imp->go(scriptContext, distance);
201     return JSValue::encode(jsUndefined());
202 }
203
204 EncodedJSValue JSC_HOST_CALL jsHistoryPrototypeFunctionPushState(ExecState* exec)
205 {
206     JSValue thisValue = exec->hostThisValue();
207     if (!thisValue.inherits(&JSHistory::s_info))
208         return throwVMTypeError(exec);
209     JSHistory* castedThis = static_cast<JSHistory*>(asObject(thisValue));
210     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSHistory::s_info);
211     return JSValue::encode(castedThis->pushState(exec));
212 }
213
214 EncodedJSValue JSC_HOST_CALL jsHistoryPrototypeFunctionReplaceState(ExecState* exec)
215 {
216     JSValue thisValue = exec->hostThisValue();
217     if (!thisValue.inherits(&JSHistory::s_info))
218         return throwVMTypeError(exec);
219     JSHistory* castedThis = static_cast<JSHistory*>(asObject(thisValue));
220     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSHistory::s_info);
221     return JSValue::encode(castedThis->replaceState(exec));
222 }
223
224 static inline bool isObservable(JSHistory* jsHistory)
225 {
226     if (jsHistory->hasCustomProperties())
227         return true;
228     return false;
229 }
230
231 bool JSHistoryOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
232 {
233     JSHistory* jsHistory = static_cast<JSHistory*>(handle.get().asCell());
234     if (!isObservable(jsHistory))
235         return false;
236     Frame* root = jsHistory->impl()->frame();
237     if (!root)
238         return false;
239     return visitor.containsOpaqueRoot(root);
240 }
241
242 void JSHistoryOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
243 {
244     JSHistory* jsHistory = static_cast<JSHistory*>(handle.get().asCell());
245     DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
246     uncacheWrapper(world, jsHistory->impl(), jsHistory);
247     jsHistory->releaseImpl();
248 }
249
250 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, History* impl)
251 {
252     return wrap<JSHistory>(exec, globalObject, impl);
253 }
254
255 History* toHistory(JSC::JSValue value)
256 {
257     return value.inherits(&JSHistory::s_info) ? static_cast<JSHistory*>(asObject(value))->impl() : 0;
258 }
259
260 }