|
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 |
|
24 #if ENABLE(SVG) |
|
25 |
|
26 #include "Document.h" |
|
27 #include "Frame.h" |
|
28 #include "SVGDocumentExtensions.h" |
|
29 #include "SVGElement.h" |
|
30 #include "SVGAnimatedTemplate.h" |
|
31 #include "JSSVGStringList.h" |
|
32 |
|
33 #include <wtf/GetPtr.h> |
|
34 |
|
35 #include "ExceptionCode.h" |
|
36 #include "PlatformString.h" |
|
37 #include "SVGStringList.h" |
|
38 |
|
39 using namespace KJS; |
|
40 |
|
41 namespace WebCore { |
|
42 |
|
43 /* Hash table */ |
|
44 |
|
45 static const HashEntry JSSVGStringListTableEntries[] = |
|
46 { |
|
47 { "numberOfItems", JSSVGStringList::NumberOfItemsAttrNum, DontDelete|ReadOnly, 0, 0 } |
|
48 }; |
|
49 |
|
50 static const HashTable JSSVGStringListTable = |
|
51 { |
|
52 2, 1, JSSVGStringListTableEntries, 1 |
|
53 }; |
|
54 |
|
55 /* Hash table for prototype */ |
|
56 |
|
57 static const HashEntry JSSVGStringListPrototypeTableEntries[] = |
|
58 { |
|
59 { 0, 0, 0, 0, 0 }, |
|
60 { "clear", JSSVGStringList::ClearFuncNum, DontDelete|Function, 0, &JSSVGStringListPrototypeTableEntries[9] }, |
|
61 { "getItem", JSSVGStringList::GetItemFuncNum, DontDelete|Function, 1, &JSSVGStringListPrototypeTableEntries[7] }, |
|
62 { "insertItemBefore", JSSVGStringList::InsertItemBeforeFuncNum, DontDelete|Function, 2, &JSSVGStringListPrototypeTableEntries[8] }, |
|
63 { 0, 0, 0, 0, 0 }, |
|
64 { 0, 0, 0, 0, 0 }, |
|
65 { "initialize", JSSVGStringList::InitializeFuncNum, DontDelete|Function, 1, 0 }, |
|
66 { "replaceItem", JSSVGStringList::ReplaceItemFuncNum, DontDelete|Function, 2, 0 }, |
|
67 { "removeItem", JSSVGStringList::RemoveItemFuncNum, DontDelete|Function, 1, 0 }, |
|
68 { "appendItem", JSSVGStringList::AppendItemFuncNum, DontDelete|Function, 1, 0 } |
|
69 }; |
|
70 |
|
71 static const HashTable JSSVGStringListPrototypeTable = |
|
72 { |
|
73 2, 10, JSSVGStringListPrototypeTableEntries, 7 |
|
74 }; |
|
75 |
|
76 const ClassInfo JSSVGStringListPrototype::info = { "SVGStringListPrototype", 0, &JSSVGStringListPrototypeTable, 0 }; |
|
77 |
|
78 JSObject* JSSVGStringListPrototype::self(ExecState* exec) |
|
79 { |
|
80 return KJS::cacheGlobalObject<JSSVGStringListPrototype>(exec, "[[JSSVGStringList.prototype]]"); |
|
81 } |
|
82 |
|
83 bool JSSVGStringListPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
84 { |
|
85 return getStaticFunctionSlot<JSSVGStringListPrototypeFunction, JSObject>(exec, &JSSVGStringListPrototypeTable, this, propertyName, slot); |
|
86 } |
|
87 |
|
88 const ClassInfo JSSVGStringList::info = { "SVGStringList", 0, &JSSVGStringListTable, 0 }; |
|
89 |
|
90 JSSVGStringList::JSSVGStringList(ExecState* exec, SVGStringList* impl) |
|
91 : m_impl(impl) |
|
92 { |
|
93 setPrototype(JSSVGStringListPrototype::self(exec)); |
|
94 } |
|
95 |
|
96 JSSVGStringList::~JSSVGStringList() |
|
97 { |
|
98 ScriptInterpreter::forgetDOMObject(m_impl.get()); |
|
99 } |
|
100 |
|
101 bool JSSVGStringList::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
102 { |
|
103 return getStaticValueSlot<JSSVGStringList, KJS::DOMObject>(exec, &JSSVGStringListTable, this, propertyName, slot); |
|
104 } |
|
105 |
|
106 JSValue* JSSVGStringList::getValueProperty(ExecState* exec, int token) const |
|
107 { |
|
108 switch (token) { |
|
109 case NumberOfItemsAttrNum: { |
|
110 SVGStringList* imp = static_cast<SVGStringList*>(impl()); |
|
111 |
|
112 return jsNumber(imp->numberOfItems()); |
|
113 } |
|
114 } |
|
115 return 0; |
|
116 } |
|
117 |
|
118 JSValue* JSSVGStringListPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) |
|
119 { |
|
120 if (!thisObj->inherits(&JSSVGStringList::info)) |
|
121 return throwError(exec, TypeError); |
|
122 |
|
123 SVGStringList* imp = static_cast<SVGStringList*>(static_cast<JSSVGStringList*>(thisObj)->impl()); |
|
124 |
|
125 switch (id) { |
|
126 case JSSVGStringList::ClearFuncNum: { |
|
127 ExceptionCode ec = 0; |
|
128 |
|
129 imp->clear(ec); |
|
130 setDOMException(exec, ec); |
|
131 return jsUndefined(); |
|
132 } |
|
133 case JSSVGStringList::InitializeFuncNum: { |
|
134 ExceptionCode ec = 0; |
|
135 String item = args[0]->toString(exec); |
|
136 |
|
137 |
|
138 KJS::JSValue* result = jsString(imp->initialize(item, ec)); |
|
139 setDOMException(exec, ec); |
|
140 return result; |
|
141 } |
|
142 case JSSVGStringList::GetItemFuncNum: { |
|
143 ExceptionCode ec = 0; |
|
144 bool indexOk; |
|
145 unsigned index = args[0]->toInt32(exec, indexOk); |
|
146 if (!indexOk) { |
|
147 setDOMException(exec, TYPE_MISMATCH_ERR); |
|
148 return jsUndefined(); |
|
149 } |
|
150 |
|
151 |
|
152 KJS::JSValue* result = jsString(imp->getItem(index, ec)); |
|
153 setDOMException(exec, ec); |
|
154 return result; |
|
155 } |
|
156 case JSSVGStringList::InsertItemBeforeFuncNum: { |
|
157 ExceptionCode ec = 0; |
|
158 String item = args[0]->toString(exec); |
|
159 bool indexOk; |
|
160 unsigned index = args[1]->toInt32(exec, indexOk); |
|
161 if (!indexOk) { |
|
162 setDOMException(exec, TYPE_MISMATCH_ERR); |
|
163 return jsUndefined(); |
|
164 } |
|
165 |
|
166 |
|
167 KJS::JSValue* result = jsString(imp->insertItemBefore(item, index, ec)); |
|
168 setDOMException(exec, ec); |
|
169 return result; |
|
170 } |
|
171 case JSSVGStringList::ReplaceItemFuncNum: { |
|
172 ExceptionCode ec = 0; |
|
173 String item = args[0]->toString(exec); |
|
174 bool indexOk; |
|
175 unsigned index = args[1]->toInt32(exec, indexOk); |
|
176 if (!indexOk) { |
|
177 setDOMException(exec, TYPE_MISMATCH_ERR); |
|
178 return jsUndefined(); |
|
179 } |
|
180 |
|
181 |
|
182 KJS::JSValue* result = jsString(imp->replaceItem(item, index, ec)); |
|
183 setDOMException(exec, ec); |
|
184 return result; |
|
185 } |
|
186 case JSSVGStringList::RemoveItemFuncNum: { |
|
187 ExceptionCode ec = 0; |
|
188 bool indexOk; |
|
189 unsigned index = args[0]->toInt32(exec, indexOk); |
|
190 if (!indexOk) { |
|
191 setDOMException(exec, TYPE_MISMATCH_ERR); |
|
192 return jsUndefined(); |
|
193 } |
|
194 |
|
195 |
|
196 KJS::JSValue* result = jsString(imp->removeItem(index, ec)); |
|
197 setDOMException(exec, ec); |
|
198 return result; |
|
199 } |
|
200 case JSSVGStringList::AppendItemFuncNum: { |
|
201 ExceptionCode ec = 0; |
|
202 String item = args[0]->toString(exec); |
|
203 |
|
204 |
|
205 KJS::JSValue* result = jsString(imp->appendItem(item, ec)); |
|
206 setDOMException(exec, ec); |
|
207 return result; |
|
208 } |
|
209 } |
|
210 return 0; |
|
211 } |
|
212 KJS::JSValue* toJS(KJS::ExecState* exec, SVGStringList* obj) |
|
213 { |
|
214 return KJS::cacheDOMObject<SVGStringList, JSSVGStringList>(exec, obj); |
|
215 } |
|
216 SVGStringList* toSVGStringList(KJS::JSValue* val) |
|
217 { |
|
218 return val->isObject(&JSSVGStringList::info) ? static_cast<JSSVGStringList*>(val)->impl() : 0; |
|
219 } |
|
220 |
|
221 } |
|
222 |
|
223 #endif // ENABLE(SVG) |