tizen beta release
[profile/ivi/webkit-efl.git] / DerivedSources / WebCore / JSProgressEvent.cpp
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 "JSProgressEvent.h"
23
24 #include "JSDictionary.h"
25 #include "ProgressEvent.h"
26 #include <runtime/Error.h>
27 #include <wtf/GetPtr.h>
28
29 using namespace JSC;
30
31 namespace WebCore {
32
33 ASSERT_CLASS_FITS_IN_CELL(JSProgressEvent);
34
35 /* Hash table */
36 #if ENABLE(JIT)
37 #define THUNK_GENERATOR(generator) , generator
38 #else
39 #define THUNK_GENERATOR(generator)
40 #endif
41 #if ENABLE(DFG_JIT)
42 #define INTRINSIC(intrinsic) , intrinsic
43 #else
44 #define INTRINSIC(intrinsic)
45 #endif
46
47 static const HashTableValue JSProgressEventTableValues[] =
48 {
49     { "lengthComputable", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsProgressEventLengthComputable), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
50     { "loaded", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsProgressEventLoaded), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
51     { "total", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsProgressEventTotal), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
52     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsProgressEventConstructor), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
53     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
54 };
55
56 #undef THUNK_GENERATOR
57 static const HashTable JSProgressEventTable = { 9, 7, JSProgressEventTableValues, 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 #if ENABLE(DFG_JIT)
65 #define INTRINSIC(intrinsic) , intrinsic
66 #else
67 #define INTRINSIC(intrinsic)
68 #endif
69
70 static const HashTableValue JSProgressEventConstructorTableValues[] =
71 {
72     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
73 };
74
75 #undef THUNK_GENERATOR
76 static const HashTable JSProgressEventConstructorTable = { 1, 0, JSProgressEventConstructorTableValues, 0 };
77 const ClassInfo JSProgressEventConstructor::s_info = { "ProgressEventConstructor", &DOMConstructorObject::s_info, &JSProgressEventConstructorTable, 0, CREATE_METHOD_TABLE(JSProgressEventConstructor) };
78
79 JSProgressEventConstructor::JSProgressEventConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
80     : DOMConstructorObject(structure, globalObject)
81 {
82 }
83
84 void JSProgressEventConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
85 {
86     Base::finishCreation(exec->globalData());
87     ASSERT(inherits(&s_info));
88     putDirect(exec->globalData(), exec->propertyNames().prototype, JSProgressEventPrototype::self(exec, globalObject), DontDelete | ReadOnly);
89 }
90
91 bool JSProgressEventConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
92 {
93     return getStaticValueSlot<JSProgressEventConstructor, JSDOMWrapper>(exec, &JSProgressEventConstructorTable, static_cast<JSProgressEventConstructor*>(cell), propertyName, slot);
94 }
95
96 bool JSProgressEventConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
97 {
98     return getStaticValueDescriptor<JSProgressEventConstructor, JSDOMWrapper>(exec, &JSProgressEventConstructorTable, static_cast<JSProgressEventConstructor*>(object), propertyName, descriptor);
99 }
100
101 EncodedJSValue JSC_HOST_CALL JSProgressEventConstructor::constructJSProgressEvent(ExecState* exec)
102 {
103     JSProgressEventConstructor* jsConstructor = static_cast<JSProgressEventConstructor*>(exec->callee());
104
105     ScriptExecutionContext* executionContext = jsConstructor->scriptExecutionContext();
106     if (!executionContext)
107         return throwVMError(exec, createReferenceError(exec, "Constructor associated execution context is unavailable"));
108
109     AtomicString eventType = ustringToAtomicString(exec->argument(0).toString(exec));
110     if (exec->hadException())
111         return JSValue::encode(jsUndefined());
112
113     ProgressEventInit eventInit;
114
115     JSValue initializerValue = exec->argument(1);
116     if (!initializerValue.isUndefinedOrNull()) {
117         // Given the above test, this will always yield an object.
118         JSObject* initializerObject = initializerValue.toObject(exec);
119
120         // Create the dictionary wrapper from the initializer object.
121         JSDictionary dictionary(exec, initializerObject);
122
123         // Attempt to fill in the EventInit.
124         if (!fillProgressEventInit(eventInit, dictionary))
125             return JSValue::encode(jsUndefined());
126     }
127
128     RefPtr<ProgressEvent> event = ProgressEvent::create(eventType, eventInit);
129     return JSValue::encode(toJS(exec, jsConstructor->globalObject(), event.get()));
130 }
131
132 bool fillProgressEventInit(ProgressEventInit& eventInit, JSDictionary& dictionary)
133 {
134     if (!fillEventInit(eventInit, dictionary))
135         return false;
136
137     if (!dictionary.tryGetProperty("lengthComputable", eventInit.lengthComputable))
138         return false;
139     if (!dictionary.tryGetProperty("loaded", eventInit.loaded))
140         return false;
141     if (!dictionary.tryGetProperty("total", eventInit.total))
142         return false;
143     return true;
144 }
145
146 ConstructType JSProgressEventConstructor::getConstructData(JSCell*, ConstructData& constructData)
147 {
148     constructData.native.function = constructJSProgressEvent;
149     return ConstructTypeHost;
150 }
151
152 /* Hash table for prototype */
153 #if ENABLE(JIT)
154 #define THUNK_GENERATOR(generator) , generator
155 #else
156 #define THUNK_GENERATOR(generator)
157 #endif
158 #if ENABLE(DFG_JIT)
159 #define INTRINSIC(intrinsic) , intrinsic
160 #else
161 #define INTRINSIC(intrinsic)
162 #endif
163
164 static const HashTableValue JSProgressEventPrototypeTableValues[] =
165 {
166     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
167 };
168
169 #undef THUNK_GENERATOR
170 static const HashTable JSProgressEventPrototypeTable = { 1, 0, JSProgressEventPrototypeTableValues, 0 };
171 const ClassInfo JSProgressEventPrototype::s_info = { "ProgressEventPrototype", &JSC::JSNonFinalObject::s_info, &JSProgressEventPrototypeTable, 0, CREATE_METHOD_TABLE(JSProgressEventPrototype) };
172
173 JSObject* JSProgressEventPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
174 {
175     return getDOMPrototype<JSProgressEvent>(exec, globalObject);
176 }
177
178 const ClassInfo JSProgressEvent::s_info = { "ProgressEvent", &JSEvent::s_info, &JSProgressEventTable, 0 , CREATE_METHOD_TABLE(JSProgressEvent) };
179
180 JSProgressEvent::JSProgressEvent(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<ProgressEvent> impl)
181     : JSEvent(structure, globalObject, impl)
182 {
183 }
184
185 void JSProgressEvent::finishCreation(JSGlobalData& globalData)
186 {
187     Base::finishCreation(globalData);
188     ASSERT(inherits(&s_info));
189 }
190
191 JSObject* JSProgressEvent::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
192 {
193     return JSProgressEventPrototype::create(exec->globalData(), globalObject, JSProgressEventPrototype::createStructure(exec->globalData(), globalObject, JSEventPrototype::self(exec, globalObject)));
194 }
195
196 bool JSProgressEvent::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
197 {
198     JSProgressEvent* thisObject = jsCast<JSProgressEvent*>(cell);
199     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
200     return getStaticValueSlot<JSProgressEvent, Base>(exec, &JSProgressEventTable, thisObject, propertyName, slot);
201 }
202
203 bool JSProgressEvent::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
204 {
205     JSProgressEvent* thisObject = jsCast<JSProgressEvent*>(object);
206     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
207     return getStaticValueDescriptor<JSProgressEvent, Base>(exec, &JSProgressEventTable, thisObject, propertyName, descriptor);
208 }
209
210 JSValue jsProgressEventLengthComputable(ExecState* exec, JSValue slotBase, const Identifier&)
211 {
212     JSProgressEvent* castedThis = static_cast<JSProgressEvent*>(asObject(slotBase));
213     UNUSED_PARAM(exec);
214     ProgressEvent* imp = static_cast<ProgressEvent*>(castedThis->impl());
215     JSValue result = jsBoolean(imp->lengthComputable());
216     return result;
217 }
218
219
220 JSValue jsProgressEventLoaded(ExecState* exec, JSValue slotBase, const Identifier&)
221 {
222     JSProgressEvent* castedThis = static_cast<JSProgressEvent*>(asObject(slotBase));
223     UNUSED_PARAM(exec);
224     ProgressEvent* imp = static_cast<ProgressEvent*>(castedThis->impl());
225     JSValue result = jsNumber(imp->loaded());
226     return result;
227 }
228
229
230 JSValue jsProgressEventTotal(ExecState* exec, JSValue slotBase, const Identifier&)
231 {
232     JSProgressEvent* castedThis = static_cast<JSProgressEvent*>(asObject(slotBase));
233     UNUSED_PARAM(exec);
234     ProgressEvent* imp = static_cast<ProgressEvent*>(castedThis->impl());
235     JSValue result = jsNumber(imp->total());
236     return result;
237 }
238
239
240 JSValue jsProgressEventConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
241 {
242     JSProgressEvent* domObject = static_cast<JSProgressEvent*>(asObject(slotBase));
243     return JSProgressEvent::getConstructor(exec, domObject->globalObject());
244 }
245
246 JSValue JSProgressEvent::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
247 {
248     return getDOMConstructor<JSProgressEventConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
249 }
250
251
252 }