|
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 "JSDOMImplementation.h" |
|
23 |
|
24 #include "CSSStyleSheet.h" |
|
25 #include "DOMImplementation.h" |
|
26 #include "Document.h" |
|
27 #include "DocumentType.h" |
|
28 #include "HTMLDocument.h" |
|
29 #include "JSCSSStyleSheet.h" |
|
30 #include "JSDocument.h" |
|
31 #include "JSDocumentType.h" |
|
32 #include "JSHTMLDocument.h" |
|
33 #include "NodeFilter.h" |
|
34 #include <runtime/Error.h> |
|
35 #include <wtf/GetPtr.h> |
|
36 |
|
37 using namespace JSC; |
|
38 |
|
39 namespace WebCore { |
|
40 |
|
41 ASSERT_CLASS_FITS_IN_CELL(JSDOMImplementation); |
|
42 |
|
43 /* Hash table */ |
|
44 #if ENABLE(JIT) |
|
45 #define THUNK_GENERATOR(generator) , generator |
|
46 #else |
|
47 #define THUNK_GENERATOR(generator) |
|
48 #endif |
|
49 |
|
50 static const HashTableValue JSDOMImplementationTableValues[2] = |
|
51 { |
|
52 { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMImplementationConstructor), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
53 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
54 }; |
|
55 |
|
56 #undef THUNK_GENERATOR |
|
57 static JSC_CONST_HASHTABLE HashTable JSDOMImplementationTable = { 2, 1, JSDOMImplementationTableValues, 0 }; |
|
58 /* Hash table for constructor */ |
|
59 #if ENABLE(JIT) |
|
60 #define THUNK_GENERATOR(generator) , generator |
|
61 #else |
|
62 #define THUNK_GENERATOR(generator) |
|
63 #endif |
|
64 |
|
65 static const HashTableValue JSDOMImplementationConstructorTableValues[1] = |
|
66 { |
|
67 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
68 }; |
|
69 |
|
70 #undef THUNK_GENERATOR |
|
71 static JSC_CONST_HASHTABLE HashTable JSDOMImplementationConstructorTable = { 1, 0, JSDOMImplementationConstructorTableValues, 0 }; |
|
72 class JSDOMImplementationConstructor : public DOMConstructorObject { |
|
73 public: |
|
74 JSDOMImplementationConstructor(JSC::ExecState*, JSDOMGlobalObject*); |
|
75 |
|
76 virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); |
|
77 virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); |
|
78 virtual const JSC::ClassInfo* classInfo() const { return &s_info; } |
|
79 static const JSC::ClassInfo s_info; |
|
80 static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) |
|
81 { |
|
82 return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); |
|
83 } |
|
84 protected: |
|
85 static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; |
|
86 }; |
|
87 |
|
88 const ClassInfo JSDOMImplementationConstructor::s_info = { "DOMImplementationConstructor", 0, &JSDOMImplementationConstructorTable, 0 }; |
|
89 |
|
90 JSDOMImplementationConstructor::JSDOMImplementationConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) |
|
91 : DOMConstructorObject(JSDOMImplementationConstructor::createStructure(globalObject->objectPrototype()), globalObject) |
|
92 { |
|
93 putDirect(exec->propertyNames().prototype, JSDOMImplementationPrototype::self(exec, globalObject), DontDelete | ReadOnly); |
|
94 } |
|
95 |
|
96 bool JSDOMImplementationConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
97 { |
|
98 return getStaticValueSlot<JSDOMImplementationConstructor, DOMObject>(exec, &JSDOMImplementationConstructorTable, this, propertyName, slot); |
|
99 } |
|
100 |
|
101 bool JSDOMImplementationConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
102 { |
|
103 return getStaticValueDescriptor<JSDOMImplementationConstructor, DOMObject>(exec, &JSDOMImplementationConstructorTable, this, propertyName, descriptor); |
|
104 } |
|
105 |
|
106 /* Hash table for prototype */ |
|
107 #if ENABLE(JIT) |
|
108 #define THUNK_GENERATOR(generator) , generator |
|
109 #else |
|
110 #define THUNK_GENERATOR(generator) |
|
111 #endif |
|
112 |
|
113 static const HashTableValue JSDOMImplementationPrototypeTableValues[6] = |
|
114 { |
|
115 { "hasFeature", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMImplementationPrototypeFunctionHasFeature), (intptr_t)2 THUNK_GENERATOR(0) }, |
|
116 { "createDocumentType", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMImplementationPrototypeFunctionCreateDocumentType), (intptr_t)3 THUNK_GENERATOR(0) }, |
|
117 { "createDocument", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMImplementationPrototypeFunctionCreateDocument), (intptr_t)3 THUNK_GENERATOR(0) }, |
|
118 { "createCSSStyleSheet", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMImplementationPrototypeFunctionCreateCSSStyleSheet), (intptr_t)2 THUNK_GENERATOR(0) }, |
|
119 { "createHTMLDocument", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMImplementationPrototypeFunctionCreateHTMLDocument), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
120 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
121 }; |
|
122 |
|
123 #undef THUNK_GENERATOR |
|
124 static JSC_CONST_HASHTABLE HashTable JSDOMImplementationPrototypeTable = { 17, 15, JSDOMImplementationPrototypeTableValues, 0 }; |
|
125 const ClassInfo JSDOMImplementationPrototype::s_info = { "DOMImplementationPrototype", 0, &JSDOMImplementationPrototypeTable, 0 }; |
|
126 |
|
127 JSObject* JSDOMImplementationPrototype::self(ExecState* exec, JSGlobalObject* globalObject) |
|
128 { |
|
129 return getDOMPrototype<JSDOMImplementation>(exec, globalObject); |
|
130 } |
|
131 |
|
132 bool JSDOMImplementationPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
133 { |
|
134 return getStaticFunctionSlot<JSObject>(exec, &JSDOMImplementationPrototypeTable, this, propertyName, slot); |
|
135 } |
|
136 |
|
137 bool JSDOMImplementationPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
138 { |
|
139 return getStaticFunctionDescriptor<JSObject>(exec, &JSDOMImplementationPrototypeTable, this, propertyName, descriptor); |
|
140 } |
|
141 |
|
142 const ClassInfo JSDOMImplementation::s_info = { "DOMImplementation", 0, &JSDOMImplementationTable, 0 }; |
|
143 |
|
144 JSDOMImplementation::JSDOMImplementation(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<DOMImplementation> impl) |
|
145 : DOMObjectWithGlobalPointer(structure, globalObject) |
|
146 , m_impl(impl) |
|
147 { |
|
148 } |
|
149 |
|
150 JSDOMImplementation::~JSDOMImplementation() |
|
151 { |
|
152 forgetDOMObject(this, impl()); |
|
153 } |
|
154 |
|
155 JSObject* JSDOMImplementation::createPrototype(ExecState* exec, JSGlobalObject* globalObject) |
|
156 { |
|
157 return new (exec) JSDOMImplementationPrototype(globalObject, JSDOMImplementationPrototype::createStructure(globalObject->objectPrototype())); |
|
158 } |
|
159 |
|
160 bool JSDOMImplementation::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
161 { |
|
162 return getStaticValueSlot<JSDOMImplementation, Base>(exec, &JSDOMImplementationTable, this, propertyName, slot); |
|
163 } |
|
164 |
|
165 bool JSDOMImplementation::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
166 { |
|
167 return getStaticValueDescriptor<JSDOMImplementation, Base>(exec, &JSDOMImplementationTable, this, propertyName, descriptor); |
|
168 } |
|
169 |
|
170 JSValue jsDOMImplementationConstructor(ExecState* exec, JSValue slotBase, const Identifier&) |
|
171 { |
|
172 JSDOMImplementation* domObject = static_cast<JSDOMImplementation*>(asObject(slotBase)); |
|
173 return JSDOMImplementation::getConstructor(exec, domObject->globalObject()); |
|
174 } |
|
175 JSValue JSDOMImplementation::getConstructor(ExecState* exec, JSGlobalObject* globalObject) |
|
176 { |
|
177 return getDOMConstructor<JSDOMImplementationConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); |
|
178 } |
|
179 |
|
180 EncodedJSValue JSC_HOST_CALL jsDOMImplementationPrototypeFunctionHasFeature(ExecState* exec) |
|
181 { |
|
182 JSValue thisValue = exec->hostThisValue(); |
|
183 if (!thisValue.inherits(&JSDOMImplementation::s_info)) |
|
184 return throwVMTypeError(exec); |
|
185 JSDOMImplementation* castedThis = static_cast<JSDOMImplementation*>(asObject(thisValue)); |
|
186 DOMImplementation* imp = static_cast<DOMImplementation*>(castedThis->impl()); |
|
187 const String& feature = ustringToString(exec->argument(0).toString(exec)); |
|
188 const String& version = valueToStringWithNullCheck(exec, exec->argument(1)); |
|
189 |
|
190 |
|
191 JSC::JSValue result = jsBoolean(imp->hasFeature(feature, version)); |
|
192 return JSValue::encode(result); |
|
193 } |
|
194 |
|
195 EncodedJSValue JSC_HOST_CALL jsDOMImplementationPrototypeFunctionCreateDocumentType(ExecState* exec) |
|
196 { |
|
197 JSValue thisValue = exec->hostThisValue(); |
|
198 if (!thisValue.inherits(&JSDOMImplementation::s_info)) |
|
199 return throwVMTypeError(exec); |
|
200 JSDOMImplementation* castedThis = static_cast<JSDOMImplementation*>(asObject(thisValue)); |
|
201 DOMImplementation* imp = static_cast<DOMImplementation*>(castedThis->impl()); |
|
202 ExceptionCode ec = 0; |
|
203 const String& qualifiedName = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0)); |
|
204 const String& publicId = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(1)); |
|
205 const String& systemId = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(2)); |
|
206 |
|
207 |
|
208 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->createDocumentType(qualifiedName, publicId, systemId, ec))); |
|
209 setDOMException(exec, ec); |
|
210 return JSValue::encode(result); |
|
211 } |
|
212 |
|
213 EncodedJSValue JSC_HOST_CALL jsDOMImplementationPrototypeFunctionCreateDocument(ExecState* exec) |
|
214 { |
|
215 JSValue thisValue = exec->hostThisValue(); |
|
216 if (!thisValue.inherits(&JSDOMImplementation::s_info)) |
|
217 return throwVMTypeError(exec); |
|
218 JSDOMImplementation* castedThis = static_cast<JSDOMImplementation*>(asObject(thisValue)); |
|
219 DOMImplementation* imp = static_cast<DOMImplementation*>(castedThis->impl()); |
|
220 ExceptionCode ec = 0; |
|
221 const String& namespaceURI = valueToStringWithNullCheck(exec, exec->argument(0)); |
|
222 const String& qualifiedName = valueToStringWithNullCheck(exec, exec->argument(1)); |
|
223 DocumentType* doctype = toDocumentType(exec->argument(2)); |
|
224 |
|
225 |
|
226 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->createDocument(namespaceURI, qualifiedName, doctype, ec))); |
|
227 setDOMException(exec, ec); |
|
228 return JSValue::encode(result); |
|
229 } |
|
230 |
|
231 EncodedJSValue JSC_HOST_CALL jsDOMImplementationPrototypeFunctionCreateCSSStyleSheet(ExecState* exec) |
|
232 { |
|
233 JSValue thisValue = exec->hostThisValue(); |
|
234 if (!thisValue.inherits(&JSDOMImplementation::s_info)) |
|
235 return throwVMTypeError(exec); |
|
236 JSDOMImplementation* castedThis = static_cast<JSDOMImplementation*>(asObject(thisValue)); |
|
237 DOMImplementation* imp = static_cast<DOMImplementation*>(castedThis->impl()); |
|
238 ExceptionCode ec = 0; |
|
239 const String& title = ustringToString(exec->argument(0).toString(exec)); |
|
240 const String& media = ustringToString(exec->argument(1).toString(exec)); |
|
241 |
|
242 |
|
243 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->createCSSStyleSheet(title, media, ec))); |
|
244 setDOMException(exec, ec); |
|
245 return JSValue::encode(result); |
|
246 } |
|
247 |
|
248 EncodedJSValue JSC_HOST_CALL jsDOMImplementationPrototypeFunctionCreateHTMLDocument(ExecState* exec) |
|
249 { |
|
250 JSValue thisValue = exec->hostThisValue(); |
|
251 if (!thisValue.inherits(&JSDOMImplementation::s_info)) |
|
252 return throwVMTypeError(exec); |
|
253 JSDOMImplementation* castedThis = static_cast<JSDOMImplementation*>(asObject(thisValue)); |
|
254 DOMImplementation* imp = static_cast<DOMImplementation*>(castedThis->impl()); |
|
255 const String& title = ustringToString(exec->argument(0).toString(exec)); |
|
256 |
|
257 |
|
258 JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->createHTMLDocument(title))); |
|
259 return JSValue::encode(result); |
|
260 } |
|
261 |
|
262 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMImplementation* object) |
|
263 { |
|
264 return getDOMObjectWrapper<JSDOMImplementation>(exec, globalObject, object); |
|
265 } |
|
266 DOMImplementation* toDOMImplementation(JSC::JSValue value) |
|
267 { |
|
268 return value.inherits(&JSDOMImplementation::s_info) ? static_cast<JSDOMImplementation*>(asObject(value))->impl() : 0; |
|
269 } |
|
270 |
|
271 } |