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