|
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 "JSCSSValueList.h" |
|
24 |
|
25 #include <wtf/GetPtr.h> |
|
26 |
|
27 #include "CSSValue.h" |
|
28 #include "CSSValueList.h" |
|
29 #include "ExceptionCode.h" |
|
30 #include "JSCSSValue.h" |
|
31 |
|
32 using namespace KJS; |
|
33 |
|
34 namespace WebCore { |
|
35 |
|
36 /* Hash table */ |
|
37 |
|
38 static const HashEntry JSCSSValueListTableEntries[] = |
|
39 { |
|
40 { 0, 0, 0, 0, 0 }, |
|
41 { "length", JSCSSValueList::LengthAttrNum, DontDelete|ReadOnly, 0, &JSCSSValueListTableEntries[2] }, |
|
42 { "constructor", JSCSSValueList::ConstructorAttrNum, DontDelete|DontEnum|ReadOnly, 0, 0 } |
|
43 }; |
|
44 |
|
45 static const HashTable JSCSSValueListTable = |
|
46 { |
|
47 2, 3, JSCSSValueListTableEntries, 2 |
|
48 }; |
|
49 |
|
50 /* Hash table for constructor */ |
|
51 |
|
52 static const HashEntry JSCSSValueListConstructorTableEntries[] = |
|
53 { |
|
54 { 0, 0, 0, 0, 0 } |
|
55 }; |
|
56 |
|
57 static const HashTable JSCSSValueListConstructorTable = |
|
58 { |
|
59 2, 1, JSCSSValueListConstructorTableEntries, 1 |
|
60 }; |
|
61 |
|
62 class JSCSSValueListConstructor : public DOMObject { |
|
63 public: |
|
64 JSCSSValueListConstructor(ExecState* exec) |
|
65 { |
|
66 setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype()); |
|
67 putDirect(exec->propertyNames().prototype, JSCSSValueListPrototype::self(exec), None); |
|
68 } |
|
69 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); |
|
70 JSValue* getValueProperty(ExecState*, int token) const; |
|
71 virtual const ClassInfo* classInfo() const { return &info; } |
|
72 static const ClassInfo info; |
|
73 |
|
74 virtual bool implementsHasInstance() const { return true; } |
|
75 }; |
|
76 |
|
77 const ClassInfo JSCSSValueListConstructor::info = { "CSSValueListConstructor", 0, &JSCSSValueListConstructorTable, 0 }; |
|
78 |
|
79 bool JSCSSValueListConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
80 { |
|
81 return getStaticValueSlot<JSCSSValueListConstructor, DOMObject>(exec, &JSCSSValueListConstructorTable, this, propertyName, slot); |
|
82 } |
|
83 |
|
84 JSValue* JSCSSValueListConstructor::getValueProperty(ExecState*, int token) const |
|
85 { |
|
86 // The token is the numeric value of its associated constant |
|
87 return jsNumber(token); |
|
88 } |
|
89 |
|
90 /* Hash table for prototype */ |
|
91 |
|
92 static const HashEntry JSCSSValueListPrototypeTableEntries[] = |
|
93 { |
|
94 { "item", JSCSSValueList::ItemFuncNum, DontDelete|Function, 1, 0 } |
|
95 }; |
|
96 |
|
97 static const HashTable JSCSSValueListPrototypeTable = |
|
98 { |
|
99 2, 1, JSCSSValueListPrototypeTableEntries, 1 |
|
100 }; |
|
101 |
|
102 const ClassInfo JSCSSValueListPrototype::info = { "CSSValueListPrototype", 0, &JSCSSValueListPrototypeTable, 0 }; |
|
103 |
|
104 JSObject* JSCSSValueListPrototype::self(ExecState* exec) |
|
105 { |
|
106 return KJS::cacheGlobalObject<JSCSSValueListPrototype>(exec, "[[JSCSSValueList.prototype]]"); |
|
107 } |
|
108 |
|
109 bool JSCSSValueListPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
110 { |
|
111 return getStaticFunctionSlot<JSCSSValueListPrototypeFunction, JSObject>(exec, &JSCSSValueListPrototypeTable, this, propertyName, slot); |
|
112 } |
|
113 |
|
114 const ClassInfo JSCSSValueList::info = { "CSSValueList", &JSCSSValue::info, &JSCSSValueListTable, 0 }; |
|
115 |
|
116 JSCSSValueList::JSCSSValueList(ExecState* exec, CSSValueList* impl) |
|
117 : JSCSSValue(exec, impl) |
|
118 { |
|
119 setPrototype(JSCSSValueListPrototype::self(exec)); |
|
120 } |
|
121 |
|
122 bool JSCSSValueList::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
123 { |
|
124 const HashEntry* entry = Lookup::findEntry(&JSCSSValueListTable, propertyName); |
|
125 if (entry) { |
|
126 slot.setStaticEntry(this, entry, staticValueGetter<JSCSSValueList>); |
|
127 return true; |
|
128 } |
|
129 bool ok; |
|
130 unsigned index = propertyName.toUInt32(&ok, false); |
|
131 if (ok && index < static_cast<CSSValueList*>(impl())->length()) { |
|
132 slot.setCustomIndex(this, index, indexGetter); |
|
133 return true; |
|
134 } |
|
135 return JSCSSValue::getOwnPropertySlot(exec, propertyName, slot); |
|
136 } |
|
137 |
|
138 JSValue* JSCSSValueList::getValueProperty(ExecState* exec, int token) const |
|
139 { |
|
140 switch (token) { |
|
141 case LengthAttrNum: { |
|
142 CSSValueList* imp = static_cast<CSSValueList*>(impl()); |
|
143 |
|
144 return jsNumber(imp->length()); |
|
145 } |
|
146 case ConstructorAttrNum: |
|
147 return getConstructor(exec); |
|
148 } |
|
149 return 0; |
|
150 } |
|
151 |
|
152 JSValue* JSCSSValueList::getConstructor(ExecState* exec) |
|
153 { |
|
154 return KJS::cacheGlobalObject<JSCSSValueListConstructor>(exec, "[[CSSValueList.constructor]]"); |
|
155 } |
|
156 JSValue* JSCSSValueListPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) |
|
157 { |
|
158 if (!thisObj->inherits(&JSCSSValueList::info)) |
|
159 return throwError(exec, TypeError); |
|
160 |
|
161 CSSValueList* imp = static_cast<CSSValueList*>(static_cast<JSCSSValueList*>(thisObj)->impl()); |
|
162 |
|
163 switch (id) { |
|
164 case JSCSSValueList::ItemFuncNum: { |
|
165 bool indexOk; |
|
166 unsigned index = args[0]->toInt32(exec, indexOk); |
|
167 if (!indexOk) { |
|
168 setDOMException(exec, TYPE_MISMATCH_ERR); |
|
169 return jsUndefined(); |
|
170 } |
|
171 |
|
172 |
|
173 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->item(index))); |
|
174 return result; |
|
175 } |
|
176 } |
|
177 return 0; |
|
178 } |
|
179 |
|
180 JSValue* JSCSSValueList::indexGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot) |
|
181 { |
|
182 JSCSSValueList* thisObj = static_cast<JSCSSValueList*>(slot.slotBase()); |
|
183 return toJS(exec, static_cast<CSSValueList*>(thisObj->impl())->item(slot.index())); |
|
184 } |
|
185 |
|
186 } |