~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/WebCore/generated/JSHTMLCollection.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
*/
20
20
 
21
21
#include "config.h"
22
 
 
23
22
#include "JSHTMLCollection.h"
24
23
 
25
 
#include <wtf/GetPtr.h>
26
 
 
27
 
#include <runtime/PropertyNameArray.h>
28
24
#include "AtomicString.h"
29
25
#include "HTMLCollection.h"
30
26
#include "JSNode.h"
32
28
#include "NameNodeList.h"
33
29
#include "Node.h"
34
30
#include "NodeList.h"
35
 
 
36
31
#include <runtime/Error.h>
37
32
#include <runtime/JSNumberCell.h>
 
33
#include <runtime/PropertyNameArray.h>
 
34
#include <wtf/GetPtr.h>
38
35
 
39
36
using namespace JSC;
40
37
 
41
38
namespace WebCore {
42
39
 
43
 
ASSERT_CLASS_FITS_IN_CELL(JSHTMLCollection)
 
40
ASSERT_CLASS_FITS_IN_CELL(JSHTMLCollection);
44
41
 
45
42
/* Hash table */
46
43
 
51
48
    { 0, 0, 0, 0 }
52
49
};
53
50
 
54
 
static const HashTable JSHTMLCollectionTable =
 
51
static JSC_CONST_HASHTABLE HashTable JSHTMLCollectionTable =
55
52
#if ENABLE(PERFECT_HASH_SIZE)
56
53
    { 15, JSHTMLCollectionTableValues, 0 };
57
54
#else
65
62
    { 0, 0, 0, 0 }
66
63
};
67
64
 
68
 
static const HashTable JSHTMLCollectionConstructorTable =
 
65
static JSC_CONST_HASHTABLE HashTable JSHTMLCollectionConstructorTable =
69
66
#if ENABLE(PERFECT_HASH_SIZE)
70
67
    { 0, JSHTMLCollectionConstructorTableValues, 0 };
71
68
#else
72
69
    { 1, 0, JSHTMLCollectionConstructorTableValues, 0 };
73
70
#endif
74
71
 
75
 
class JSHTMLCollectionConstructor : public DOMObject {
 
72
class JSHTMLCollectionConstructor : public DOMConstructorObject {
76
73
public:
77
 
    JSHTMLCollectionConstructor(ExecState* exec)
78
 
        : DOMObject(JSHTMLCollectionConstructor::createStructure(exec->lexicalGlobalObject()->objectPrototype()))
 
74
    JSHTMLCollectionConstructor(ExecState* exec, JSDOMGlobalObject* globalObject)
 
75
        : DOMConstructorObject(JSHTMLCollectionConstructor::createStructure(globalObject->objectPrototype()), globalObject)
79
76
    {
80
 
        putDirect(exec->propertyNames().prototype, JSHTMLCollectionPrototype::self(exec, exec->lexicalGlobalObject()), None);
 
77
        putDirect(exec->propertyNames().prototype, JSHTMLCollectionPrototype::self(exec, globalObject), None);
81
78
    }
82
79
    virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
 
80
    virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
83
81
    virtual const ClassInfo* classInfo() const { return &s_info; }
84
82
    static const ClassInfo s_info;
85
83
 
86
 
    static PassRefPtr<Structure> createStructure(JSValuePtr proto) 
 
84
    static PassRefPtr<Structure> createStructure(JSValue proto) 
87
85
    { 
88
86
        return Structure::create(proto, TypeInfo(ObjectType, ImplementsHasInstance)); 
89
87
    }
96
94
    return getStaticValueSlot<JSHTMLCollectionConstructor, DOMObject>(exec, &JSHTMLCollectionConstructorTable, this, propertyName, slot);
97
95
}
98
96
 
 
97
bool JSHTMLCollectionConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
 
98
{
 
99
    return getStaticValueDescriptor<JSHTMLCollectionConstructor, DOMObject>(exec, &JSHTMLCollectionConstructorTable, this, propertyName, descriptor);
 
100
}
 
101
 
99
102
/* Hash table for prototype */
100
103
 
101
104
static const HashTableValue JSHTMLCollectionPrototypeTableValues[4] =
106
109
    { 0, 0, 0, 0 }
107
110
};
108
111
 
109
 
static const HashTable JSHTMLCollectionPrototypeTable =
 
112
static JSC_CONST_HASHTABLE HashTable JSHTMLCollectionPrototypeTable =
110
113
#if ENABLE(PERFECT_HASH_SIZE)
111
114
    { 7, JSHTMLCollectionPrototypeTableValues, 0 };
112
115
#else
125
128
    return getStaticFunctionSlot<JSObject>(exec, &JSHTMLCollectionPrototypeTable, this, propertyName, slot);
126
129
}
127
130
 
 
131
bool JSHTMLCollectionPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
 
132
{
 
133
    return getStaticFunctionDescriptor<JSObject>(exec, &JSHTMLCollectionPrototypeTable, this, propertyName, descriptor);
 
134
}
 
135
 
128
136
const ClassInfo JSHTMLCollection::s_info = { "HTMLCollection", 0, &JSHTMLCollectionTable, 0 };
129
137
 
130
 
JSHTMLCollection::JSHTMLCollection(PassRefPtr<Structure> structure, PassRefPtr<HTMLCollection> impl)
131
 
    : DOMObject(structure)
 
138
JSHTMLCollection::JSHTMLCollection(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<HTMLCollection> impl)
 
139
    : DOMObjectWithGlobalPointer(structure, globalObject)
132
140
    , m_impl(impl)
133
141
{
134
142
}
135
143
 
136
144
JSHTMLCollection::~JSHTMLCollection()
137
145
{
138
 
    forgetDOMObject(*Heap::heap(this)->globalData(), m_impl.get());
139
 
 
 
146
    forgetDOMObject(*Heap::heap(this)->globalData(), impl());
140
147
}
141
148
 
142
149
JSObject* JSHTMLCollection::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
146
153
 
147
154
bool JSHTMLCollection::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
148
155
{
149
 
    JSValuePtr proto = prototype();
150
 
    if (proto->isObject() && static_cast<JSObject*>(asObject(proto))->hasProperty(exec, propertyName))
 
156
    JSValue proto = prototype();
 
157
    if (proto.isObject() && static_cast<JSObject*>(asObject(proto))->hasProperty(exec, propertyName))
151
158
        return false;
152
159
 
153
160
    const HashEntry* entry = JSHTMLCollectionTable.entry(exec, propertyName);
168
175
    return getStaticValueSlot<JSHTMLCollection, Base>(exec, &JSHTMLCollectionTable, this, propertyName, slot);
169
176
}
170
177
 
 
178
bool JSHTMLCollection::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
 
179
{
 
180
    JSValue proto = prototype();
 
181
    if (proto.isObject() && static_cast<JSObject*>(asObject(proto))->hasProperty(exec, propertyName))
 
182
        return false;
 
183
 
 
184
    const HashEntry* entry = JSHTMLCollectionTable.entry(exec, propertyName);
 
185
    if (entry) {
 
186
        PropertySlot slot;
 
187
        slot.setCustom(this, entry->propertyGetter());
 
188
        descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
 
189
        return true;
 
190
    }
 
191
    bool ok;
 
192
    unsigned index = propertyName.toUInt32(&ok, false);
 
193
    if (ok && index < static_cast<HTMLCollection*>(impl())->length()) {
 
194
        PropertySlot slot;
 
195
        slot.setCustomIndex(this, index, indexGetter);
 
196
        descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly);
 
197
        return true;
 
198
    }
 
199
    if (canGetItemsForName(exec, static_cast<HTMLCollection*>(impl()), propertyName)) {
 
200
        PropertySlot slot;
 
201
        slot.setCustom(this, nameGetter);
 
202
        descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
 
203
        return true;
 
204
    }
 
205
    return getStaticValueDescriptor<JSHTMLCollection, Base>(exec, &JSHTMLCollectionTable, this, propertyName, descriptor);
 
206
}
 
207
 
171
208
bool JSHTMLCollection::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
172
209
{
173
210
    if (propertyName < static_cast<HTMLCollection*>(impl())->length()) {
177
214
    return getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot);
178
215
}
179
216
 
180
 
JSValuePtr jsHTMLCollectionLength(ExecState* exec, const Identifier&, const PropertySlot& slot)
 
217
JSValue jsHTMLCollectionLength(ExecState* exec, const Identifier&, const PropertySlot& slot)
181
218
{
182
 
    HTMLCollection* imp = static_cast<HTMLCollection*>(static_cast<JSHTMLCollection*>(asObject(slot.slotBase()))->impl());
 
219
    JSHTMLCollection* castedThis = static_cast<JSHTMLCollection*>(asObject(slot.slotBase()));
 
220
    UNUSED_PARAM(exec);
 
221
    HTMLCollection* imp = static_cast<HTMLCollection*>(castedThis->impl());
183
222
    return jsNumber(exec, imp->length());
184
223
}
185
224
 
186
 
JSValuePtr jsHTMLCollectionConstructor(ExecState* exec, const Identifier&, const PropertySlot& slot)
 
225
JSValue jsHTMLCollectionConstructor(ExecState* exec, const Identifier&, const PropertySlot& slot)
187
226
{
188
 
    return static_cast<JSHTMLCollection*>(asObject(slot.slotBase()))->getConstructor(exec);
 
227
    JSHTMLCollection* domObject = static_cast<JSHTMLCollection*>(asObject(slot.slotBase()));
 
228
    return JSHTMLCollection::getConstructor(exec, domObject->globalObject());
189
229
}
190
 
void JSHTMLCollection::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
 
230
void JSHTMLCollection::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
191
231
{
192
232
    for (unsigned i = 0; i < static_cast<HTMLCollection*>(impl())->length(); ++i)
193
233
        propertyNames.add(Identifier::from(exec, i));
194
 
     Base::getPropertyNames(exec, propertyNames);
195
 
}
196
 
 
197
 
JSValuePtr JSHTMLCollection::getConstructor(ExecState* exec)
198
 
{
199
 
    return getDOMConstructor<JSHTMLCollectionConstructor>(exec);
200
 
}
201
 
 
202
 
JSValuePtr jsHTMLCollectionPrototypeFunctionItem(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList& args)
203
 
{
204
 
    if (!thisValue->isObject(&JSHTMLCollection::s_info))
 
234
     Base::getOwnPropertyNames(exec, propertyNames);
 
235
}
 
236
 
 
237
JSValue JSHTMLCollection::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
 
238
{
 
239
    return getDOMConstructor<JSHTMLCollectionConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
 
240
}
 
241
 
 
242
JSValue JSC_HOST_CALL jsHTMLCollectionPrototypeFunctionItem(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
 
243
{
 
244
    UNUSED_PARAM(args);
 
245
    if (!thisValue.inherits(&JSHTMLCollection::s_info))
205
246
        return throwError(exec, TypeError);
206
247
    JSHTMLCollection* castedThisObj = static_cast<JSHTMLCollection*>(asObject(thisValue));
207
248
    return castedThisObj->item(exec, args);
208
249
}
209
250
 
210
 
JSValuePtr jsHTMLCollectionPrototypeFunctionNamedItem(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList& args)
 
251
JSValue JSC_HOST_CALL jsHTMLCollectionPrototypeFunctionNamedItem(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
211
252
{
212
 
    if (!thisValue->isObject(&JSHTMLCollection::s_info))
 
253
    UNUSED_PARAM(args);
 
254
    if (!thisValue.inherits(&JSHTMLCollection::s_info))
213
255
        return throwError(exec, TypeError);
214
256
    JSHTMLCollection* castedThisObj = static_cast<JSHTMLCollection*>(asObject(thisValue));
215
257
    return castedThisObj->namedItem(exec, args);
216
258
}
217
259
 
218
 
JSValuePtr jsHTMLCollectionPrototypeFunctionTags(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList& args)
 
260
JSValue JSC_HOST_CALL jsHTMLCollectionPrototypeFunctionTags(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
219
261
{
220
 
    if (!thisValue->isObject(&JSHTMLCollection::s_info))
 
262
    UNUSED_PARAM(args);
 
263
    if (!thisValue.inherits(&JSHTMLCollection::s_info))
221
264
        return throwError(exec, TypeError);
222
265
    JSHTMLCollection* castedThisObj = static_cast<JSHTMLCollection*>(asObject(thisValue));
223
266
    HTMLCollection* imp = static_cast<HTMLCollection*>(castedThisObj->impl());
224
 
    const UString& name = args.at(exec, 0)->toString(exec);
225
 
 
226
 
 
227
 
    JSC::JSValuePtr result = toJS(exec, WTF::getPtr(imp->tags(name)));
 
267
    const UString& name = args.at(0).toString(exec);
 
268
 
 
269
 
 
270
    JSC::JSValue result = toJS(exec, castedThisObj->globalObject(), WTF::getPtr(imp->tags(name)));
228
271
    return result;
229
272
}
230
273
 
231
274
 
232
 
JSValuePtr JSHTMLCollection::indexGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
 
275
JSValue JSHTMLCollection::indexGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
233
276
{
234
277
    JSHTMLCollection* thisObj = static_cast<JSHTMLCollection*>(asObject(slot.slotBase()));
235
 
    return toJS(exec, static_cast<HTMLCollection*>(thisObj->impl())->item(slot.index()));
 
278
    return toJS(exec, thisObj->globalObject(), static_cast<HTMLCollection*>(thisObj->impl())->item(slot.index()));
236
279
}
237
 
HTMLCollection* toHTMLCollection(JSC::JSValuePtr value)
 
280
HTMLCollection* toHTMLCollection(JSC::JSValue value)
238
281
{
239
 
    return value->isObject(&JSHTMLCollection::s_info) ? static_cast<JSHTMLCollection*>(asObject(value))->impl() : 0;
 
282
    return value.inherits(&JSHTMLCollection::s_info) ? static_cast<JSHTMLCollection*>(asObject(value))->impl() : 0;
240
283
}
241
284
 
242
285
}