|
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 "JSCharacterData.h" |
|
23 |
|
24 #include "CharacterData.h" |
|
25 #include "ExceptionCode.h" |
|
26 #include "KURL.h" |
|
27 #include <runtime/Error.h> |
|
28 #include <runtime/JSNumberCell.h> |
|
29 #include <runtime/JSString.h> |
|
30 #include <wtf/GetPtr.h> |
|
31 |
|
32 using namespace JSC; |
|
33 |
|
34 namespace WebCore { |
|
35 |
|
36 ASSERT_CLASS_FITS_IN_CELL(JSCharacterData); |
|
37 |
|
38 /* Hash table */ |
|
39 #if ENABLE(JIT) |
|
40 #define THUNK_GENERATOR(generator) , generator |
|
41 #else |
|
42 #define THUNK_GENERATOR(generator) |
|
43 #endif |
|
44 |
|
45 static const HashTableValue JSCharacterDataTableValues[4] = |
|
46 { |
|
47 { "data", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCharacterDataData), (intptr_t)setJSCharacterDataData THUNK_GENERATOR(0) }, |
|
48 { "length", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCharacterDataLength), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
49 { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCharacterDataConstructor), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
50 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
51 }; |
|
52 |
|
53 #undef THUNK_GENERATOR |
|
54 static JSC_CONST_HASHTABLE HashTable JSCharacterDataTable = { 9, 7, JSCharacterDataTableValues, 0 }; |
|
55 /* Hash table for constructor */ |
|
56 #if ENABLE(JIT) |
|
57 #define THUNK_GENERATOR(generator) , generator |
|
58 #else |
|
59 #define THUNK_GENERATOR(generator) |
|
60 #endif |
|
61 |
|
62 static const HashTableValue JSCharacterDataConstructorTableValues[1] = |
|
63 { |
|
64 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
65 }; |
|
66 |
|
67 #undef THUNK_GENERATOR |
|
68 static JSC_CONST_HASHTABLE HashTable JSCharacterDataConstructorTable = { 1, 0, JSCharacterDataConstructorTableValues, 0 }; |
|
69 class JSCharacterDataConstructor : public DOMConstructorObject { |
|
70 public: |
|
71 JSCharacterDataConstructor(JSC::ExecState*, JSDOMGlobalObject*); |
|
72 |
|
73 virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); |
|
74 virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); |
|
75 virtual const JSC::ClassInfo* classInfo() const { return &s_info; } |
|
76 static const JSC::ClassInfo s_info; |
|
77 static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) |
|
78 { |
|
79 return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); |
|
80 } |
|
81 protected: |
|
82 static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; |
|
83 }; |
|
84 |
|
85 const ClassInfo JSCharacterDataConstructor::s_info = { "CharacterDataConstructor", 0, &JSCharacterDataConstructorTable, 0 }; |
|
86 |
|
87 JSCharacterDataConstructor::JSCharacterDataConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) |
|
88 : DOMConstructorObject(JSCharacterDataConstructor::createStructure(globalObject->objectPrototype()), globalObject) |
|
89 { |
|
90 putDirect(exec->propertyNames().prototype, JSCharacterDataPrototype::self(exec, globalObject), DontDelete | ReadOnly); |
|
91 } |
|
92 |
|
93 bool JSCharacterDataConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
94 { |
|
95 return getStaticValueSlot<JSCharacterDataConstructor, DOMObject>(exec, &JSCharacterDataConstructorTable, this, propertyName, slot); |
|
96 } |
|
97 |
|
98 bool JSCharacterDataConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
99 { |
|
100 return getStaticValueDescriptor<JSCharacterDataConstructor, DOMObject>(exec, &JSCharacterDataConstructorTable, this, propertyName, descriptor); |
|
101 } |
|
102 |
|
103 /* Hash table for prototype */ |
|
104 #if ENABLE(JIT) |
|
105 #define THUNK_GENERATOR(generator) , generator |
|
106 #else |
|
107 #define THUNK_GENERATOR(generator) |
|
108 #endif |
|
109 |
|
110 static const HashTableValue JSCharacterDataPrototypeTableValues[6] = |
|
111 { |
|
112 { "substringData", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsCharacterDataPrototypeFunctionSubstringData), (intptr_t)2 THUNK_GENERATOR(0) }, |
|
113 { "appendData", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsCharacterDataPrototypeFunctionAppendData), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
114 { "insertData", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsCharacterDataPrototypeFunctionInsertData), (intptr_t)2 THUNK_GENERATOR(0) }, |
|
115 { "deleteData", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsCharacterDataPrototypeFunctionDeleteData), (intptr_t)2 THUNK_GENERATOR(0) }, |
|
116 { "replaceData", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsCharacterDataPrototypeFunctionReplaceData), (intptr_t)3 THUNK_GENERATOR(0) }, |
|
117 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
118 }; |
|
119 |
|
120 #undef THUNK_GENERATOR |
|
121 static JSC_CONST_HASHTABLE HashTable JSCharacterDataPrototypeTable = { 16, 15, JSCharacterDataPrototypeTableValues, 0 }; |
|
122 const ClassInfo JSCharacterDataPrototype::s_info = { "CharacterDataPrototype", 0, &JSCharacterDataPrototypeTable, 0 }; |
|
123 |
|
124 JSObject* JSCharacterDataPrototype::self(ExecState* exec, JSGlobalObject* globalObject) |
|
125 { |
|
126 return getDOMPrototype<JSCharacterData>(exec, globalObject); |
|
127 } |
|
128 |
|
129 bool JSCharacterDataPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
130 { |
|
131 return getStaticFunctionSlot<JSObject>(exec, &JSCharacterDataPrototypeTable, this, propertyName, slot); |
|
132 } |
|
133 |
|
134 bool JSCharacterDataPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
135 { |
|
136 return getStaticFunctionDescriptor<JSObject>(exec, &JSCharacterDataPrototypeTable, this, propertyName, descriptor); |
|
137 } |
|
138 |
|
139 const ClassInfo JSCharacterData::s_info = { "CharacterData", &JSNode::s_info, &JSCharacterDataTable, 0 }; |
|
140 |
|
141 JSCharacterData::JSCharacterData(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<CharacterData> impl) |
|
142 : JSNode(structure, globalObject, impl) |
|
143 { |
|
144 } |
|
145 |
|
146 JSObject* JSCharacterData::createPrototype(ExecState* exec, JSGlobalObject* globalObject) |
|
147 { |
|
148 return new (exec) JSCharacterDataPrototype(globalObject, JSCharacterDataPrototype::createStructure(JSNodePrototype::self(exec, globalObject))); |
|
149 } |
|
150 |
|
151 bool JSCharacterData::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
152 { |
|
153 return getStaticValueSlot<JSCharacterData, Base>(exec, &JSCharacterDataTable, this, propertyName, slot); |
|
154 } |
|
155 |
|
156 bool JSCharacterData::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
157 { |
|
158 return getStaticValueDescriptor<JSCharacterData, Base>(exec, &JSCharacterDataTable, this, propertyName, descriptor); |
|
159 } |
|
160 |
|
161 JSValue jsCharacterDataData(ExecState* exec, JSValue slotBase, const Identifier&) |
|
162 { |
|
163 JSCharacterData* castedThis = static_cast<JSCharacterData*>(asObject(slotBase)); |
|
164 UNUSED_PARAM(exec); |
|
165 CharacterData* imp = static_cast<CharacterData*>(castedThis->impl()); |
|
166 JSValue result = jsString(exec, imp->data()); |
|
167 return result; |
|
168 } |
|
169 |
|
170 JSValue jsCharacterDataLength(ExecState* exec, JSValue slotBase, const Identifier&) |
|
171 { |
|
172 JSCharacterData* castedThis = static_cast<JSCharacterData*>(asObject(slotBase)); |
|
173 UNUSED_PARAM(exec); |
|
174 CharacterData* imp = static_cast<CharacterData*>(castedThis->impl()); |
|
175 JSValue result = jsNumber(exec, imp->length()); |
|
176 return result; |
|
177 } |
|
178 |
|
179 JSValue jsCharacterDataConstructor(ExecState* exec, JSValue slotBase, const Identifier&) |
|
180 { |
|
181 JSCharacterData* domObject = static_cast<JSCharacterData*>(asObject(slotBase)); |
|
182 return JSCharacterData::getConstructor(exec, domObject->globalObject()); |
|
183 } |
|
184 void JSCharacterData::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) |
|
185 { |
|
186 lookupPut<JSCharacterData, Base>(exec, propertyName, value, &JSCharacterDataTable, this, slot); |
|
187 } |
|
188 |
|
189 void setJSCharacterDataData(ExecState* exec, JSObject* thisObject, JSValue value) |
|
190 { |
|
191 JSCharacterData* castedThis = static_cast<JSCharacterData*>(thisObject); |
|
192 CharacterData* imp = static_cast<CharacterData*>(castedThis->impl()); |
|
193 ExceptionCode ec = 0; |
|
194 imp->setData(valueToStringWithNullCheck(exec, value), ec); |
|
195 setDOMException(exec, ec); |
|
196 } |
|
197 |
|
198 JSValue JSCharacterData::getConstructor(ExecState* exec, JSGlobalObject* globalObject) |
|
199 { |
|
200 return getDOMConstructor<JSCharacterDataConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); |
|
201 } |
|
202 |
|
203 EncodedJSValue JSC_HOST_CALL jsCharacterDataPrototypeFunctionSubstringData(ExecState* exec) |
|
204 { |
|
205 JSValue thisValue = exec->hostThisValue(); |
|
206 if (!thisValue.inherits(&JSCharacterData::s_info)) |
|
207 return throwVMTypeError(exec); |
|
208 JSCharacterData* castedThis = static_cast<JSCharacterData*>(asObject(thisValue)); |
|
209 CharacterData* imp = static_cast<CharacterData*>(castedThis->impl()); |
|
210 ExceptionCode ec = 0; |
|
211 int offset = exec->argument(0).toInt32(exec); |
|
212 if (offset < 0) { |
|
213 setDOMException(exec, INDEX_SIZE_ERR); |
|
214 return JSValue::encode(jsUndefined()); |
|
215 } |
|
216 int length = exec->argument(1).toInt32(exec); |
|
217 if (length < 0) { |
|
218 setDOMException(exec, INDEX_SIZE_ERR); |
|
219 return JSValue::encode(jsUndefined()); |
|
220 } |
|
221 |
|
222 |
|
223 JSC::JSValue result = jsStringOrNull(exec, imp->substringData(offset, length, ec)); |
|
224 setDOMException(exec, ec); |
|
225 return JSValue::encode(result); |
|
226 } |
|
227 |
|
228 EncodedJSValue JSC_HOST_CALL jsCharacterDataPrototypeFunctionAppendData(ExecState* exec) |
|
229 { |
|
230 JSValue thisValue = exec->hostThisValue(); |
|
231 if (!thisValue.inherits(&JSCharacterData::s_info)) |
|
232 return throwVMTypeError(exec); |
|
233 JSCharacterData* castedThis = static_cast<JSCharacterData*>(asObject(thisValue)); |
|
234 CharacterData* imp = static_cast<CharacterData*>(castedThis->impl()); |
|
235 ExceptionCode ec = 0; |
|
236 const String& data = ustringToString(exec->argument(0).toString(exec)); |
|
237 |
|
238 imp->appendData(data, ec); |
|
239 setDOMException(exec, ec); |
|
240 return JSValue::encode(jsUndefined()); |
|
241 } |
|
242 |
|
243 EncodedJSValue JSC_HOST_CALL jsCharacterDataPrototypeFunctionInsertData(ExecState* exec) |
|
244 { |
|
245 JSValue thisValue = exec->hostThisValue(); |
|
246 if (!thisValue.inherits(&JSCharacterData::s_info)) |
|
247 return throwVMTypeError(exec); |
|
248 JSCharacterData* castedThis = static_cast<JSCharacterData*>(asObject(thisValue)); |
|
249 CharacterData* imp = static_cast<CharacterData*>(castedThis->impl()); |
|
250 ExceptionCode ec = 0; |
|
251 int offset = exec->argument(0).toInt32(exec); |
|
252 if (offset < 0) { |
|
253 setDOMException(exec, INDEX_SIZE_ERR); |
|
254 return JSValue::encode(jsUndefined()); |
|
255 } |
|
256 const String& data = ustringToString(exec->argument(1).toString(exec)); |
|
257 |
|
258 imp->insertData(offset, data, ec); |
|
259 setDOMException(exec, ec); |
|
260 return JSValue::encode(jsUndefined()); |
|
261 } |
|
262 |
|
263 EncodedJSValue JSC_HOST_CALL jsCharacterDataPrototypeFunctionDeleteData(ExecState* exec) |
|
264 { |
|
265 JSValue thisValue = exec->hostThisValue(); |
|
266 if (!thisValue.inherits(&JSCharacterData::s_info)) |
|
267 return throwVMTypeError(exec); |
|
268 JSCharacterData* castedThis = static_cast<JSCharacterData*>(asObject(thisValue)); |
|
269 CharacterData* imp = static_cast<CharacterData*>(castedThis->impl()); |
|
270 ExceptionCode ec = 0; |
|
271 int offset = exec->argument(0).toInt32(exec); |
|
272 if (offset < 0) { |
|
273 setDOMException(exec, INDEX_SIZE_ERR); |
|
274 return JSValue::encode(jsUndefined()); |
|
275 } |
|
276 int length = exec->argument(1).toInt32(exec); |
|
277 if (length < 0) { |
|
278 setDOMException(exec, INDEX_SIZE_ERR); |
|
279 return JSValue::encode(jsUndefined()); |
|
280 } |
|
281 |
|
282 imp->deleteData(offset, length, ec); |
|
283 setDOMException(exec, ec); |
|
284 return JSValue::encode(jsUndefined()); |
|
285 } |
|
286 |
|
287 EncodedJSValue JSC_HOST_CALL jsCharacterDataPrototypeFunctionReplaceData(ExecState* exec) |
|
288 { |
|
289 JSValue thisValue = exec->hostThisValue(); |
|
290 if (!thisValue.inherits(&JSCharacterData::s_info)) |
|
291 return throwVMTypeError(exec); |
|
292 JSCharacterData* castedThis = static_cast<JSCharacterData*>(asObject(thisValue)); |
|
293 CharacterData* imp = static_cast<CharacterData*>(castedThis->impl()); |
|
294 ExceptionCode ec = 0; |
|
295 int offset = exec->argument(0).toInt32(exec); |
|
296 if (offset < 0) { |
|
297 setDOMException(exec, INDEX_SIZE_ERR); |
|
298 return JSValue::encode(jsUndefined()); |
|
299 } |
|
300 int length = exec->argument(1).toInt32(exec); |
|
301 if (length < 0) { |
|
302 setDOMException(exec, INDEX_SIZE_ERR); |
|
303 return JSValue::encode(jsUndefined()); |
|
304 } |
|
305 const String& data = ustringToString(exec->argument(2).toString(exec)); |
|
306 |
|
307 imp->replaceData(offset, length, data, ec); |
|
308 setDOMException(exec, ec); |
|
309 return JSValue::encode(jsUndefined()); |
|
310 } |
|
311 |
|
312 |
|
313 } |