2 This file is part of the WebKit open source project.
3 This file has been generated by generate-bindings.pl. DO NOT MODIFY!
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.
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.
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.
22 #include "JSNodeIterator.h"
24 #include "ExceptionCode.h"
25 #include "JSDOMBinding.h"
27 #include "JSNodeFilter.h"
29 #include "NodeFilter.h"
30 #include "NodeIterator.h"
31 #include <runtime/Error.h>
32 #include <wtf/GetPtr.h>
38 ASSERT_CLASS_FITS_IN_CELL(JSNodeIterator);
42 #define THUNK_GENERATOR(generator) , generator
44 #define THUNK_GENERATOR(generator)
47 #define INTRINSIC(intrinsic) , intrinsic
49 #define INTRINSIC(intrinsic)
52 static const HashTableValue JSNodeIteratorTableValues[] =
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) }
64 #undef THUNK_GENERATOR
65 static const HashTable JSNodeIteratorTable = { 18, 15, JSNodeIteratorTableValues, 0 };
66 /* Hash table for constructor */
68 #define THUNK_GENERATOR(generator) , generator
70 #define THUNK_GENERATOR(generator)
73 #define INTRINSIC(intrinsic) , intrinsic
75 #define INTRINSIC(intrinsic)
78 static const HashTableValue JSNodeIteratorConstructorTableValues[] =
80 { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
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) };
87 JSNodeIteratorConstructor::JSNodeIteratorConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
88 : DOMConstructorObject(structure, globalObject)
92 void JSNodeIteratorConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
94 Base::finishCreation(exec->globalData());
95 ASSERT(inherits(&s_info));
96 putDirect(exec->globalData(), exec->propertyNames().prototype, JSNodeIteratorPrototype::self(exec, globalObject), DontDelete | ReadOnly);
99 bool JSNodeIteratorConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
101 return getStaticValueSlot<JSNodeIteratorConstructor, JSDOMWrapper>(exec, &JSNodeIteratorConstructorTable, static_cast<JSNodeIteratorConstructor*>(cell), propertyName, slot);
104 bool JSNodeIteratorConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
106 return getStaticValueDescriptor<JSNodeIteratorConstructor, JSDOMWrapper>(exec, &JSNodeIteratorConstructorTable, static_cast<JSNodeIteratorConstructor*>(object), propertyName, descriptor);
109 /* Hash table for prototype */
111 #define THUNK_GENERATOR(generator) , generator
113 #define THUNK_GENERATOR(generator)
116 #define INTRINSIC(intrinsic) , intrinsic
118 #define INTRINSIC(intrinsic)
121 static const HashTableValue JSNodeIteratorPrototypeTableValues[] =
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) }
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) };
133 JSObject* JSNodeIteratorPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
135 return getDOMPrototype<JSNodeIterator>(exec, globalObject);
138 bool JSNodeIteratorPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
140 JSNodeIteratorPrototype* thisObject = jsCast<JSNodeIteratorPrototype*>(cell);
141 return getStaticFunctionSlot<JSObject>(exec, &JSNodeIteratorPrototypeTable, thisObject, propertyName, slot);
144 bool JSNodeIteratorPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
146 JSNodeIteratorPrototype* thisObject = jsCast<JSNodeIteratorPrototype*>(object);
147 return getStaticFunctionDescriptor<JSObject>(exec, &JSNodeIteratorPrototypeTable, thisObject, propertyName, descriptor);
150 const ClassInfo JSNodeIterator::s_info = { "NodeIterator", &JSDOMWrapper::s_info, &JSNodeIteratorTable, 0 , CREATE_METHOD_TABLE(JSNodeIterator) };
152 JSNodeIterator::JSNodeIterator(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<NodeIterator> impl)
153 : JSDOMWrapper(structure, globalObject)
154 , m_impl(impl.leakRef())
158 void JSNodeIterator::finishCreation(JSGlobalData& globalData)
160 Base::finishCreation(globalData);
161 ASSERT(inherits(&s_info));
164 JSObject* JSNodeIterator::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
166 return JSNodeIteratorPrototype::create(exec->globalData(), globalObject, JSNodeIteratorPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
169 bool JSNodeIterator::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
171 JSNodeIterator* thisObject = jsCast<JSNodeIterator*>(cell);
172 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
173 return getStaticValueSlot<JSNodeIterator, Base>(exec, &JSNodeIteratorTable, thisObject, propertyName, slot);
176 bool JSNodeIterator::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
178 JSNodeIterator* thisObject = jsCast<JSNodeIterator*>(object);
179 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
180 return getStaticValueDescriptor<JSNodeIterator, Base>(exec, &JSNodeIteratorTable, thisObject, propertyName, descriptor);
183 JSValue jsNodeIteratorRoot(ExecState* exec, JSValue slotBase, const Identifier&)
185 JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(slotBase));
187 NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
188 JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->root()));
193 JSValue jsNodeIteratorWhatToShow(ExecState* exec, JSValue slotBase, const Identifier&)
195 JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(slotBase));
197 NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
198 JSValue result = jsNumber(imp->whatToShow());
203 JSValue jsNodeIteratorFilter(ExecState* exec, JSValue slotBase, const Identifier&)
205 JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(slotBase));
207 NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
208 JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->filter()));
213 JSValue jsNodeIteratorExpandEntityReferences(ExecState* exec, JSValue slotBase, const Identifier&)
215 JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(slotBase));
217 NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
218 JSValue result = jsBoolean(imp->expandEntityReferences());
223 JSValue jsNodeIteratorReferenceNode(ExecState* exec, JSValue slotBase, const Identifier&)
225 JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(slotBase));
227 NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
228 JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->referenceNode()));
233 JSValue jsNodeIteratorPointerBeforeReferenceNode(ExecState* exec, JSValue slotBase, const Identifier&)
235 JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(slotBase));
237 NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
238 JSValue result = jsBoolean(imp->pointerBeforeReferenceNode());
243 JSValue jsNodeIteratorConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
245 JSNodeIterator* domObject = static_cast<JSNodeIterator*>(asObject(slotBase));
246 return JSNodeIterator::getConstructor(exec, domObject->globalObject());
249 JSValue JSNodeIterator::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
251 return getDOMConstructor<JSNodeIteratorConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
254 EncodedJSValue JSC_HOST_CALL jsNodeIteratorPrototypeFunctionNextNode(ExecState* exec)
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;
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);
271 EncodedJSValue JSC_HOST_CALL jsNodeIteratorPrototypeFunctionPreviousNode(ExecState* exec)
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;
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);
288 EncodedJSValue JSC_HOST_CALL jsNodeIteratorPrototypeFunctionDetach(ExecState* exec)
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());
297 return JSValue::encode(jsUndefined());
300 static inline bool isObservable(JSNodeIterator* jsNodeIterator)
302 if (jsNodeIterator->hasCustomProperties())
307 bool JSNodeIteratorOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
309 JSNodeIterator* jsNodeIterator = static_cast<JSNodeIterator*>(handle.get().asCell());
310 if (!isObservable(jsNodeIterator))
312 UNUSED_PARAM(visitor);
316 void JSNodeIteratorOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
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();
324 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, NodeIterator* impl)
326 return wrap<JSNodeIterator>(exec, globalObject, impl);
329 NodeIterator* toNodeIterator(JSC::JSValue value)
331 return value.inherits(&JSNodeIterator::s_info) ? static_cast<JSNodeIterator*>(asObject(value))->impl() : 0;