tizen beta release
[framework/web/webkit-efl.git] / DerivedSources / WebCore / JSAudioNode.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
23 #if ENABLE(WEB_AUDIO)
24
25 #include "JSAudioNode.h"
26
27 #include "AudioContext.h"
28 #include "AudioNode.h"
29 #include "JSAudioContext.h"
30 #include <runtime/Error.h>
31 #include <wtf/GetPtr.h>
32
33 using namespace JSC;
34
35 namespace WebCore {
36
37 ASSERT_CLASS_FITS_IN_CELL(JSAudioNode);
38
39 /* Hash table */
40 #if ENABLE(JIT)
41 #define THUNK_GENERATOR(generator) , generator
42 #else
43 #define THUNK_GENERATOR(generator)
44 #endif
45 #if ENABLE(DFG_JIT)
46 #define INTRINSIC(intrinsic) , intrinsic
47 #else
48 #define INTRINSIC(intrinsic)
49 #endif
50
51 static const HashTableValue JSAudioNodeTableValues[] =
52 {
53     { "context", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAudioNodeContext), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
54     { "numberOfInputs", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAudioNodeNumberOfInputs), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
55     { "numberOfOutputs", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAudioNodeNumberOfOutputs), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
56     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAudioNodeConstructor), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
57     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
58 };
59
60 #undef THUNK_GENERATOR
61 static const HashTable JSAudioNodeTable = { 8, 7, JSAudioNodeTableValues, 0 };
62 /* Hash table for constructor */
63 #if ENABLE(JIT)
64 #define THUNK_GENERATOR(generator) , generator
65 #else
66 #define THUNK_GENERATOR(generator)
67 #endif
68 #if ENABLE(DFG_JIT)
69 #define INTRINSIC(intrinsic) , intrinsic
70 #else
71 #define INTRINSIC(intrinsic)
72 #endif
73
74 static const HashTableValue JSAudioNodeConstructorTableValues[] =
75 {
76     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
77 };
78
79 #undef THUNK_GENERATOR
80 static const HashTable JSAudioNodeConstructorTable = { 1, 0, JSAudioNodeConstructorTableValues, 0 };
81 const ClassInfo JSAudioNodeConstructor::s_info = { "AudioNodeConstructor", &DOMConstructorObject::s_info, &JSAudioNodeConstructorTable, 0, CREATE_METHOD_TABLE(JSAudioNodeConstructor) };
82
83 JSAudioNodeConstructor::JSAudioNodeConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
84     : DOMConstructorObject(structure, globalObject)
85 {
86 }
87
88 void JSAudioNodeConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
89 {
90     Base::finishCreation(exec->globalData());
91     ASSERT(inherits(&s_info));
92     putDirect(exec->globalData(), exec->propertyNames().prototype, JSAudioNodePrototype::self(exec, globalObject), DontDelete | ReadOnly);
93 }
94
95 bool JSAudioNodeConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
96 {
97     return getStaticValueSlot<JSAudioNodeConstructor, JSDOMWrapper>(exec, &JSAudioNodeConstructorTable, static_cast<JSAudioNodeConstructor*>(cell), propertyName, slot);
98 }
99
100 bool JSAudioNodeConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
101 {
102     return getStaticValueDescriptor<JSAudioNodeConstructor, JSDOMWrapper>(exec, &JSAudioNodeConstructorTable, static_cast<JSAudioNodeConstructor*>(object), propertyName, descriptor);
103 }
104
105 /* Hash table for prototype */
106 #if ENABLE(JIT)
107 #define THUNK_GENERATOR(generator) , generator
108 #else
109 #define THUNK_GENERATOR(generator)
110 #endif
111 #if ENABLE(DFG_JIT)
112 #define INTRINSIC(intrinsic) , intrinsic
113 #else
114 #define INTRINSIC(intrinsic)
115 #endif
116
117 static const HashTableValue JSAudioNodePrototypeTableValues[] =
118 {
119     { "connect", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsAudioNodePrototypeFunctionConnect), (intptr_t)3 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
120     { "disconnect", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsAudioNodePrototypeFunctionDisconnect), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
121     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
122 };
123
124 #undef THUNK_GENERATOR
125 static const HashTable JSAudioNodePrototypeTable = { 4, 3, JSAudioNodePrototypeTableValues, 0 };
126 const ClassInfo JSAudioNodePrototype::s_info = { "AudioNodePrototype", &JSC::JSNonFinalObject::s_info, &JSAudioNodePrototypeTable, 0, CREATE_METHOD_TABLE(JSAudioNodePrototype) };
127
128 JSObject* JSAudioNodePrototype::self(ExecState* exec, JSGlobalObject* globalObject)
129 {
130     return getDOMPrototype<JSAudioNode>(exec, globalObject);
131 }
132
133 bool JSAudioNodePrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
134 {
135     JSAudioNodePrototype* thisObject = jsCast<JSAudioNodePrototype*>(cell);
136     return getStaticFunctionSlot<JSObject>(exec, &JSAudioNodePrototypeTable, thisObject, propertyName, slot);
137 }
138
139 bool JSAudioNodePrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
140 {
141     JSAudioNodePrototype* thisObject = jsCast<JSAudioNodePrototype*>(object);
142     return getStaticFunctionDescriptor<JSObject>(exec, &JSAudioNodePrototypeTable, thisObject, propertyName, descriptor);
143 }
144
145 const ClassInfo JSAudioNode::s_info = { "AudioNode", &JSDOMWrapper::s_info, &JSAudioNodeTable, 0 , CREATE_METHOD_TABLE(JSAudioNode) };
146
147 JSAudioNode::JSAudioNode(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<AudioNode> impl)
148     : JSDOMWrapper(structure, globalObject)
149     , m_impl(impl.leakRef())
150 {
151 }
152
153 void JSAudioNode::finishCreation(JSGlobalData& globalData)
154 {
155     Base::finishCreation(globalData);
156     ASSERT(inherits(&s_info));
157 }
158
159 JSObject* JSAudioNode::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
160 {
161     return JSAudioNodePrototype::create(exec->globalData(), globalObject, JSAudioNodePrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
162 }
163
164 bool JSAudioNode::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
165 {
166     JSAudioNode* thisObject = jsCast<JSAudioNode*>(cell);
167     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
168     return getStaticValueSlot<JSAudioNode, Base>(exec, &JSAudioNodeTable, thisObject, propertyName, slot);
169 }
170
171 bool JSAudioNode::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
172 {
173     JSAudioNode* thisObject = jsCast<JSAudioNode*>(object);
174     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
175     return getStaticValueDescriptor<JSAudioNode, Base>(exec, &JSAudioNodeTable, thisObject, propertyName, descriptor);
176 }
177
178 JSValue jsAudioNodeContext(ExecState* exec, JSValue slotBase, const Identifier&)
179 {
180     JSAudioNode* castedThis = static_cast<JSAudioNode*>(asObject(slotBase));
181     UNUSED_PARAM(exec);
182     AudioNode* imp = static_cast<AudioNode*>(castedThis->impl());
183     JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->context()));
184     return result;
185 }
186
187
188 JSValue jsAudioNodeNumberOfInputs(ExecState* exec, JSValue slotBase, const Identifier&)
189 {
190     JSAudioNode* castedThis = static_cast<JSAudioNode*>(asObject(slotBase));
191     UNUSED_PARAM(exec);
192     AudioNode* imp = static_cast<AudioNode*>(castedThis->impl());
193     JSValue result = jsNumber(imp->numberOfInputs());
194     return result;
195 }
196
197
198 JSValue jsAudioNodeNumberOfOutputs(ExecState* exec, JSValue slotBase, const Identifier&)
199 {
200     JSAudioNode* castedThis = static_cast<JSAudioNode*>(asObject(slotBase));
201     UNUSED_PARAM(exec);
202     AudioNode* imp = static_cast<AudioNode*>(castedThis->impl());
203     JSValue result = jsNumber(imp->numberOfOutputs());
204     return result;
205 }
206
207
208 JSValue jsAudioNodeConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
209 {
210     JSAudioNode* domObject = static_cast<JSAudioNode*>(asObject(slotBase));
211     return JSAudioNode::getConstructor(exec, domObject->globalObject());
212 }
213
214 JSValue JSAudioNode::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
215 {
216     return getDOMConstructor<JSAudioNodeConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
217 }
218
219 EncodedJSValue JSC_HOST_CALL jsAudioNodePrototypeFunctionConnect(ExecState* exec)
220 {
221     JSValue thisValue = exec->hostThisValue();
222     if (!thisValue.inherits(&JSAudioNode::s_info))
223         return throwVMTypeError(exec);
224     JSAudioNode* castedThis = static_cast<JSAudioNode*>(asObject(thisValue));
225     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSAudioNode::s_info);
226     return JSValue::encode(castedThis->connect(exec));
227 }
228
229 EncodedJSValue JSC_HOST_CALL jsAudioNodePrototypeFunctionDisconnect(ExecState* exec)
230 {
231     JSValue thisValue = exec->hostThisValue();
232     if (!thisValue.inherits(&JSAudioNode::s_info))
233         return throwVMTypeError(exec);
234     JSAudioNode* castedThis = static_cast<JSAudioNode*>(asObject(thisValue));
235     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSAudioNode::s_info);
236     return JSValue::encode(castedThis->disconnect(exec));
237 }
238
239 static inline bool isObservable(JSAudioNode* jsAudioNode)
240 {
241     if (jsAudioNode->hasCustomProperties())
242         return true;
243     return false;
244 }
245
246 bool JSAudioNodeOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
247 {
248     JSAudioNode* jsAudioNode = static_cast<JSAudioNode*>(handle.get().asCell());
249     if (!isObservable(jsAudioNode))
250         return false;
251     UNUSED_PARAM(visitor);
252     return false;
253 }
254
255 void JSAudioNodeOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
256 {
257     JSAudioNode* jsAudioNode = static_cast<JSAudioNode*>(handle.get().asCell());
258     DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
259     uncacheWrapper(world, jsAudioNode->impl(), jsAudioNode);
260     jsAudioNode->releaseImpl();
261 }
262
263 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, AudioNode* impl)
264 {
265     return wrap<JSAudioNode>(exec, globalObject, impl);
266 }
267
268 AudioNode* toAudioNode(JSC::JSValue value)
269 {
270     return value.inherits(&JSAudioNode::s_info) ? static_cast<JSAudioNode*>(asObject(value))->impl() : 0;
271 }
272
273 }
274
275 #endif // ENABLE(WEB_AUDIO)