tizen beta release
[profile/ivi/webkit-efl.git] / DerivedSources / WebCore / JSNodeIterator.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 "JSNodeIterator.h"
23
24 #include "ExceptionCode.h"
25 #include "JSDOMBinding.h"
26 #include "JSNode.h"
27 #include "JSNodeFilter.h"
28 #include "Node.h"
29 #include "NodeFilter.h"
30 #include "NodeIterator.h"
31 #include <runtime/Error.h>
32 #include <wtf/GetPtr.h>
33
34 using namespace JSC;
35
36 namespace WebCore {
37
38 ASSERT_CLASS_FITS_IN_CELL(JSNodeIterator);
39
40 /* Hash table */
41 #if ENABLE(JIT)
42 #define THUNK_GENERATOR(generator) , generator
43 #else
44 #define THUNK_GENERATOR(generator)
45 #endif
46 #if ENABLE(DFG_JIT)
47 #define INTRINSIC(intrinsic) , intrinsic
48 #else
49 #define INTRINSIC(intrinsic)
50 #endif
51
52 static const HashTableValue JSNodeIteratorTableValues[] =
53 {
54     { "root", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeIteratorRoot), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
55     { "whatToShow", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeIteratorWhatToShow), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
56     { "filter", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeIteratorFilter), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
57     { "expandEntityReferences", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeIteratorExpandEntityReferences), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
58     { "referenceNode", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeIteratorReferenceNode), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
59     { "pointerBeforeReferenceNode", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeIteratorPointerBeforeReferenceNode), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
60     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeIteratorConstructor), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
61     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
62 };
63
64 #undef THUNK_GENERATOR
65 static const HashTable JSNodeIteratorTable = { 18, 15, JSNodeIteratorTableValues, 0 };
66 /* Hash table for constructor */
67 #if ENABLE(JIT)
68 #define THUNK_GENERATOR(generator) , generator
69 #else
70 #define THUNK_GENERATOR(generator)
71 #endif
72 #if ENABLE(DFG_JIT)
73 #define INTRINSIC(intrinsic) , intrinsic
74 #else
75 #define INTRINSIC(intrinsic)
76 #endif
77
78 static const HashTableValue JSNodeIteratorConstructorTableValues[] =
79 {
80     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
81 };
82
83 #undef THUNK_GENERATOR
84 static const HashTable JSNodeIteratorConstructorTable = { 1, 0, JSNodeIteratorConstructorTableValues, 0 };
85 const ClassInfo JSNodeIteratorConstructor::s_info = { "NodeIteratorConstructor", &DOMConstructorObject::s_info, &JSNodeIteratorConstructorTable, 0, CREATE_METHOD_TABLE(JSNodeIteratorConstructor) };
86
87 JSNodeIteratorConstructor::JSNodeIteratorConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
88     : DOMConstructorObject(structure, globalObject)
89 {
90 }
91
92 void JSNodeIteratorConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
93 {
94     Base::finishCreation(exec->globalData());
95     ASSERT(inherits(&s_info));
96     putDirect(exec->globalData(), exec->propertyNames().prototype, JSNodeIteratorPrototype::self(exec, globalObject), DontDelete | ReadOnly);
97 }
98
99 bool JSNodeIteratorConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
100 {
101     return getStaticValueSlot<JSNodeIteratorConstructor, JSDOMWrapper>(exec, &JSNodeIteratorConstructorTable, static_cast<JSNodeIteratorConstructor*>(cell), propertyName, slot);
102 }
103
104 bool JSNodeIteratorConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
105 {
106     return getStaticValueDescriptor<JSNodeIteratorConstructor, JSDOMWrapper>(exec, &JSNodeIteratorConstructorTable, static_cast<JSNodeIteratorConstructor*>(object), propertyName, descriptor);
107 }
108
109 /* Hash table for prototype */
110 #if ENABLE(JIT)
111 #define THUNK_GENERATOR(generator) , generator
112 #else
113 #define THUNK_GENERATOR(generator)
114 #endif
115 #if ENABLE(DFG_JIT)
116 #define INTRINSIC(intrinsic) , intrinsic
117 #else
118 #define INTRINSIC(intrinsic)
119 #endif
120
121 static const HashTableValue JSNodeIteratorPrototypeTableValues[] =
122 {
123     { "nextNode", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsNodeIteratorPrototypeFunctionNextNode), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
124     { "previousNode", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsNodeIteratorPrototypeFunctionPreviousNode), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
125     { "detach", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsNodeIteratorPrototypeFunctionDetach), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
126     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
127 };
128
129 #undef THUNK_GENERATOR
130 static const HashTable JSNodeIteratorPrototypeTable = { 8, 7, JSNodeIteratorPrototypeTableValues, 0 };
131 const ClassInfo JSNodeIteratorPrototype::s_info = { "NodeIteratorPrototype", &JSC::JSNonFinalObject::s_info, &JSNodeIteratorPrototypeTable, 0, CREATE_METHOD_TABLE(JSNodeIteratorPrototype) };
132
133 JSObject* JSNodeIteratorPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
134 {
135     return getDOMPrototype<JSNodeIterator>(exec, globalObject);
136 }
137
138 bool JSNodeIteratorPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
139 {
140     JSNodeIteratorPrototype* thisObject = jsCast<JSNodeIteratorPrototype*>(cell);
141     return getStaticFunctionSlot<JSObject>(exec, &JSNodeIteratorPrototypeTable, thisObject, propertyName, slot);
142 }
143
144 bool JSNodeIteratorPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
145 {
146     JSNodeIteratorPrototype* thisObject = jsCast<JSNodeIteratorPrototype*>(object);
147     return getStaticFunctionDescriptor<JSObject>(exec, &JSNodeIteratorPrototypeTable, thisObject, propertyName, descriptor);
148 }
149
150 const ClassInfo JSNodeIterator::s_info = { "NodeIterator", &JSDOMWrapper::s_info, &JSNodeIteratorTable, 0 , CREATE_METHOD_TABLE(JSNodeIterator) };
151
152 JSNodeIterator::JSNodeIterator(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<NodeIterator> impl)
153     : JSDOMWrapper(structure, globalObject)
154     , m_impl(impl.leakRef())
155 {
156 }
157
158 void JSNodeIterator::finishCreation(JSGlobalData& globalData)
159 {
160     Base::finishCreation(globalData);
161     ASSERT(inherits(&s_info));
162 }
163
164 JSObject* JSNodeIterator::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
165 {
166     return JSNodeIteratorPrototype::create(exec->globalData(), globalObject, JSNodeIteratorPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
167 }
168
169 bool JSNodeIterator::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
170 {
171     JSNodeIterator* thisObject = jsCast<JSNodeIterator*>(cell);
172     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
173     return getStaticValueSlot<JSNodeIterator, Base>(exec, &JSNodeIteratorTable, thisObject, propertyName, slot);
174 }
175
176 bool JSNodeIterator::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
177 {
178     JSNodeIterator* thisObject = jsCast<JSNodeIterator*>(object);
179     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
180     return getStaticValueDescriptor<JSNodeIterator, Base>(exec, &JSNodeIteratorTable, thisObject, propertyName, descriptor);
181 }
182
183 JSValue jsNodeIteratorRoot(ExecState* exec, JSValue slotBase, const Identifier&)
184 {
185     JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(slotBase));
186     UNUSED_PARAM(exec);
187     NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
188     JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->root()));
189     return result;
190 }
191
192
193 JSValue jsNodeIteratorWhatToShow(ExecState* exec, JSValue slotBase, const Identifier&)
194 {
195     JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(slotBase));
196     UNUSED_PARAM(exec);
197     NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
198     JSValue result = jsNumber(imp->whatToShow());
199     return result;
200 }
201
202
203 JSValue jsNodeIteratorFilter(ExecState* exec, JSValue slotBase, const Identifier&)
204 {
205     JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(slotBase));
206     UNUSED_PARAM(exec);
207     NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
208     JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->filter()));
209     return result;
210 }
211
212
213 JSValue jsNodeIteratorExpandEntityReferences(ExecState* exec, JSValue slotBase, const Identifier&)
214 {
215     JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(slotBase));
216     UNUSED_PARAM(exec);
217     NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
218     JSValue result = jsBoolean(imp->expandEntityReferences());
219     return result;
220 }
221
222
223 JSValue jsNodeIteratorReferenceNode(ExecState* exec, JSValue slotBase, const Identifier&)
224 {
225     JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(slotBase));
226     UNUSED_PARAM(exec);
227     NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
228     JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->referenceNode()));
229     return result;
230 }
231
232
233 JSValue jsNodeIteratorPointerBeforeReferenceNode(ExecState* exec, JSValue slotBase, const Identifier&)
234 {
235     JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(slotBase));
236     UNUSED_PARAM(exec);
237     NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
238     JSValue result = jsBoolean(imp->pointerBeforeReferenceNode());
239     return result;
240 }
241
242
243 JSValue jsNodeIteratorConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
244 {
245     JSNodeIterator* domObject = static_cast<JSNodeIterator*>(asObject(slotBase));
246     return JSNodeIterator::getConstructor(exec, domObject->globalObject());
247 }
248
249 JSValue JSNodeIterator::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
250 {
251     return getDOMConstructor<JSNodeIteratorConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
252 }
253
254 EncodedJSValue JSC_HOST_CALL jsNodeIteratorPrototypeFunctionNextNode(ExecState* exec)
255 {
256     JSValue thisValue = exec->hostThisValue();
257     if (!thisValue.inherits(&JSNodeIterator::s_info))
258         return throwVMTypeError(exec);
259     JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(thisValue));
260     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSNodeIterator::s_info);
261     NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
262     ExceptionCode ec = 0;
263
264     JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->nextNode(exec, ec)));
265     setDOMException(exec, ec);
266     if (exec->hadException())
267         return JSValue::encode(jsUndefined());
268     return JSValue::encode(result);
269 }
270
271 EncodedJSValue JSC_HOST_CALL jsNodeIteratorPrototypeFunctionPreviousNode(ExecState* exec)
272 {
273     JSValue thisValue = exec->hostThisValue();
274     if (!thisValue.inherits(&JSNodeIterator::s_info))
275         return throwVMTypeError(exec);
276     JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(thisValue));
277     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSNodeIterator::s_info);
278     NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
279     ExceptionCode ec = 0;
280
281     JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->previousNode(exec, ec)));
282     setDOMException(exec, ec);
283     if (exec->hadException())
284         return JSValue::encode(jsUndefined());
285     return JSValue::encode(result);
286 }
287
288 EncodedJSValue JSC_HOST_CALL jsNodeIteratorPrototypeFunctionDetach(ExecState* exec)
289 {
290     JSValue thisValue = exec->hostThisValue();
291     if (!thisValue.inherits(&JSNodeIterator::s_info))
292         return throwVMTypeError(exec);
293     JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(thisValue));
294     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSNodeIterator::s_info);
295     NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
296     imp->detach();
297     return JSValue::encode(jsUndefined());
298 }
299
300 static inline bool isObservable(JSNodeIterator* jsNodeIterator)
301 {
302     if (jsNodeIterator->hasCustomProperties())
303         return true;
304     return false;
305 }
306
307 bool JSNodeIteratorOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
308 {
309     JSNodeIterator* jsNodeIterator = static_cast<JSNodeIterator*>(handle.get().asCell());
310     if (!isObservable(jsNodeIterator))
311         return false;
312     UNUSED_PARAM(visitor);
313     return false;
314 }
315
316 void JSNodeIteratorOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
317 {
318     JSNodeIterator* jsNodeIterator = static_cast<JSNodeIterator*>(handle.get().asCell());
319     DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
320     uncacheWrapper(world, jsNodeIterator->impl(), jsNodeIterator);
321     jsNodeIterator->releaseImpl();
322 }
323
324 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, NodeIterator* impl)
325 {
326     return wrap<JSNodeIterator>(exec, globalObject, impl);
327 }
328
329 NodeIterator* toNodeIterator(JSC::JSValue value)
330 {
331     return value.inherits(&JSNodeIterator::s_info) ? static_cast<JSNodeIterator*>(asObject(value))->impl() : 0;
332 }
333
334 }