tizen beta release
[framework/web/webkit-efl.git] / DerivedSources / WebCore / JSMessageChannel.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 "JSMessageChannel.h"
23
24 #include "ExceptionCode.h"
25 #include "JSDOMBinding.h"
26 #include "JSMessagePort.h"
27 #include "MessageChannel.h"
28 #include "MessagePort.h"
29 #include <runtime/Error.h>
30 #include <wtf/GetPtr.h>
31
32 using namespace JSC;
33
34 namespace WebCore {
35
36 ASSERT_CLASS_FITS_IN_CELL(JSMessageChannel);
37
38 /* Hash table */
39 #if ENABLE(JIT)
40 #define THUNK_GENERATOR(generator) , generator
41 #else
42 #define THUNK_GENERATOR(generator)
43 #endif
44 #if ENABLE(DFG_JIT)
45 #define INTRINSIC(intrinsic) , intrinsic
46 #else
47 #define INTRINSIC(intrinsic)
48 #endif
49
50 static const HashTableValue JSMessageChannelTableValues[] =
51 {
52     { "port1", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMessageChannelPort1), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
53     { "port2", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMessageChannelPort2), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
54     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMessageChannelConstructor), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
55     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
56 };
57
58 #undef THUNK_GENERATOR
59 static const HashTable JSMessageChannelTable = { 8, 7, JSMessageChannelTableValues, 0 };
60 /* Hash table for constructor */
61 #if ENABLE(JIT)
62 #define THUNK_GENERATOR(generator) , generator
63 #else
64 #define THUNK_GENERATOR(generator)
65 #endif
66 #if ENABLE(DFG_JIT)
67 #define INTRINSIC(intrinsic) , intrinsic
68 #else
69 #define INTRINSIC(intrinsic)
70 #endif
71
72 static const HashTableValue JSMessageChannelConstructorTableValues[] =
73 {
74     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
75 };
76
77 #undef THUNK_GENERATOR
78 static const HashTable JSMessageChannelConstructorTable = { 1, 0, JSMessageChannelConstructorTableValues, 0 };
79 const ClassInfo JSMessageChannelConstructor::s_info = { "MessageChannelConstructor", &DOMConstructorObject::s_info, &JSMessageChannelConstructorTable, 0, CREATE_METHOD_TABLE(JSMessageChannelConstructor) };
80
81 JSMessageChannelConstructor::JSMessageChannelConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
82     : DOMConstructorObject(structure, globalObject)
83 {
84 }
85
86 void JSMessageChannelConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
87 {
88     Base::finishCreation(exec->globalData());
89     ASSERT(inherits(&s_info));
90     putDirect(exec->globalData(), exec->propertyNames().prototype, JSMessageChannelPrototype::self(exec, globalObject), DontDelete | ReadOnly);
91 }
92
93 bool JSMessageChannelConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
94 {
95     return getStaticValueSlot<JSMessageChannelConstructor, JSDOMWrapper>(exec, &JSMessageChannelConstructorTable, static_cast<JSMessageChannelConstructor*>(cell), propertyName, slot);
96 }
97
98 bool JSMessageChannelConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
99 {
100     return getStaticValueDescriptor<JSMessageChannelConstructor, JSDOMWrapper>(exec, &JSMessageChannelConstructorTable, static_cast<JSMessageChannelConstructor*>(object), propertyName, descriptor);
101 }
102
103 EncodedJSValue JSC_HOST_CALL JSMessageChannelConstructor::constructJSMessageChannel(ExecState* exec)
104 {
105     JSMessageChannelConstructor* jsConstructor = static_cast<JSMessageChannelConstructor*>(exec->callee());
106     ScriptExecutionContext* context = jsConstructor->scriptExecutionContext();
107     if (!context)
108         return throwVMError(exec, createReferenceError(exec, "MessageChannel constructor associated document is unavailable"));
109     RefPtr<MessageChannel> object = MessageChannel::create(context);
110     return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), object.get())));
111 }
112
113 ConstructType JSMessageChannelConstructor::getConstructData(JSCell*, ConstructData& constructData)
114 {
115     constructData.native.function = constructJSMessageChannel;
116     return ConstructTypeHost;
117 }
118
119 /* Hash table for prototype */
120 #if ENABLE(JIT)
121 #define THUNK_GENERATOR(generator) , generator
122 #else
123 #define THUNK_GENERATOR(generator)
124 #endif
125 #if ENABLE(DFG_JIT)
126 #define INTRINSIC(intrinsic) , intrinsic
127 #else
128 #define INTRINSIC(intrinsic)
129 #endif
130
131 static const HashTableValue JSMessageChannelPrototypeTableValues[] =
132 {
133     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
134 };
135
136 #undef THUNK_GENERATOR
137 static const HashTable JSMessageChannelPrototypeTable = { 1, 0, JSMessageChannelPrototypeTableValues, 0 };
138 static const HashTable* getJSMessageChannelPrototypeTable(ExecState* exec)
139 {
140     return getHashTableForGlobalData(exec->globalData(), &JSMessageChannelPrototypeTable);
141 }
142
143 const ClassInfo JSMessageChannelPrototype::s_info = { "MessageChannelPrototype", &JSC::JSNonFinalObject::s_info, 0, getJSMessageChannelPrototypeTable, CREATE_METHOD_TABLE(JSMessageChannelPrototype) };
144
145 JSObject* JSMessageChannelPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
146 {
147     return getDOMPrototype<JSMessageChannel>(exec, globalObject);
148 }
149
150 static const HashTable* getJSMessageChannelTable(ExecState* exec)
151 {
152     return getHashTableForGlobalData(exec->globalData(), &JSMessageChannelTable);
153 }
154
155 const ClassInfo JSMessageChannel::s_info = { "MessageChannel", &JSDOMWrapper::s_info, 0, getJSMessageChannelTable , CREATE_METHOD_TABLE(JSMessageChannel) };
156
157 JSMessageChannel::JSMessageChannel(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<MessageChannel> impl)
158     : JSDOMWrapper(structure, globalObject)
159     , m_impl(impl.leakRef())
160 {
161 }
162
163 void JSMessageChannel::finishCreation(JSGlobalData& globalData)
164 {
165     Base::finishCreation(globalData);
166     ASSERT(inherits(&s_info));
167 }
168
169 JSObject* JSMessageChannel::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
170 {
171     return JSMessageChannelPrototype::create(exec->globalData(), globalObject, JSMessageChannelPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
172 }
173
174 bool JSMessageChannel::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
175 {
176     JSMessageChannel* thisObject = jsCast<JSMessageChannel*>(cell);
177     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
178     return getStaticValueSlot<JSMessageChannel, Base>(exec, getJSMessageChannelTable(exec), thisObject, propertyName, slot);
179 }
180
181 bool JSMessageChannel::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
182 {
183     JSMessageChannel* thisObject = jsCast<JSMessageChannel*>(object);
184     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
185     return getStaticValueDescriptor<JSMessageChannel, Base>(exec, getJSMessageChannelTable(exec), thisObject, propertyName, descriptor);
186 }
187
188 JSValue jsMessageChannelPort1(ExecState* exec, JSValue slotBase, const Identifier&)
189 {
190     JSMessageChannel* castedThis = static_cast<JSMessageChannel*>(asObject(slotBase));
191     UNUSED_PARAM(exec);
192     MessageChannel* imp = static_cast<MessageChannel*>(castedThis->impl());
193     JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->port1()));
194     return result;
195 }
196
197
198 JSValue jsMessageChannelPort2(ExecState* exec, JSValue slotBase, const Identifier&)
199 {
200     JSMessageChannel* castedThis = static_cast<JSMessageChannel*>(asObject(slotBase));
201     UNUSED_PARAM(exec);
202     MessageChannel* imp = static_cast<MessageChannel*>(castedThis->impl());
203     JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->port2()));
204     return result;
205 }
206
207
208 JSValue jsMessageChannelConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
209 {
210     JSMessageChannel* domObject = static_cast<JSMessageChannel*>(asObject(slotBase));
211     return JSMessageChannel::getConstructor(exec, domObject->globalObject());
212 }
213
214 JSValue JSMessageChannel::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
215 {
216     return getDOMConstructor<JSMessageChannelConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
217 }
218
219 static inline bool isObservable(JSMessageChannel* jsMessageChannel)
220 {
221     if (jsMessageChannel->hasCustomProperties())
222         return true;
223     return false;
224 }
225
226 bool JSMessageChannelOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
227 {
228     JSMessageChannel* jsMessageChannel = static_cast<JSMessageChannel*>(handle.get().asCell());
229     if (!isObservable(jsMessageChannel))
230         return false;
231     UNUSED_PARAM(visitor);
232     return false;
233 }
234
235 void JSMessageChannelOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
236 {
237     JSMessageChannel* jsMessageChannel = static_cast<JSMessageChannel*>(handle.get().asCell());
238     DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
239     uncacheWrapper(world, jsMessageChannel->impl(), jsMessageChannel);
240     jsMessageChannel->releaseImpl();
241 }
242
243 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, MessageChannel* impl)
244 {
245     return wrap<JSMessageChannel>(exec, globalObject, impl);
246 }
247
248 MessageChannel* toMessageChannel(JSC::JSValue value)
249 {
250     return value.inherits(&JSMessageChannel::s_info) ? static_cast<JSMessageChannel*>(asObject(value))->impl() : 0;
251 }
252
253 }