tizen beta release
[profile/ivi/webkit-efl.git] / DerivedSources / WebCore / JSCanvasGradient.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 "JSCanvasGradient.h"
23
24 #include "CanvasGradient.h"
25 #include "ExceptionCode.h"
26 #include "JSDOMBinding.h"
27 #include "PlatformString.h"
28 #include <runtime/Error.h>
29 #include <wtf/GetPtr.h>
30
31 using namespace JSC;
32
33 namespace WebCore {
34
35 ASSERT_CLASS_FITS_IN_CELL(JSCanvasGradient);
36
37 /* Hash table */
38 #if ENABLE(JIT)
39 #define THUNK_GENERATOR(generator) , generator
40 #else
41 #define THUNK_GENERATOR(generator)
42 #endif
43 #if ENABLE(DFG_JIT)
44 #define INTRINSIC(intrinsic) , intrinsic
45 #else
46 #define INTRINSIC(intrinsic)
47 #endif
48
49 static const HashTableValue JSCanvasGradientTableValues[] =
50 {
51     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCanvasGradientConstructor), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
52     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
53 };
54
55 #undef THUNK_GENERATOR
56 static const HashTable JSCanvasGradientTable = { 2, 1, JSCanvasGradientTableValues, 0 };
57 /* Hash table for constructor */
58 #if ENABLE(JIT)
59 #define THUNK_GENERATOR(generator) , generator
60 #else
61 #define THUNK_GENERATOR(generator)
62 #endif
63 #if ENABLE(DFG_JIT)
64 #define INTRINSIC(intrinsic) , intrinsic
65 #else
66 #define INTRINSIC(intrinsic)
67 #endif
68
69 static const HashTableValue JSCanvasGradientConstructorTableValues[] =
70 {
71     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
72 };
73
74 #undef THUNK_GENERATOR
75 static const HashTable JSCanvasGradientConstructorTable = { 1, 0, JSCanvasGradientConstructorTableValues, 0 };
76 const ClassInfo JSCanvasGradientConstructor::s_info = { "CanvasGradientConstructor", &DOMConstructorObject::s_info, &JSCanvasGradientConstructorTable, 0, CREATE_METHOD_TABLE(JSCanvasGradientConstructor) };
77
78 JSCanvasGradientConstructor::JSCanvasGradientConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
79     : DOMConstructorObject(structure, globalObject)
80 {
81 }
82
83 void JSCanvasGradientConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
84 {
85     Base::finishCreation(exec->globalData());
86     ASSERT(inherits(&s_info));
87     putDirect(exec->globalData(), exec->propertyNames().prototype, JSCanvasGradientPrototype::self(exec, globalObject), DontDelete | ReadOnly);
88 }
89
90 bool JSCanvasGradientConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
91 {
92     return getStaticValueSlot<JSCanvasGradientConstructor, JSDOMWrapper>(exec, &JSCanvasGradientConstructorTable, static_cast<JSCanvasGradientConstructor*>(cell), propertyName, slot);
93 }
94
95 bool JSCanvasGradientConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
96 {
97     return getStaticValueDescriptor<JSCanvasGradientConstructor, JSDOMWrapper>(exec, &JSCanvasGradientConstructorTable, static_cast<JSCanvasGradientConstructor*>(object), propertyName, descriptor);
98 }
99
100 /* Hash table for prototype */
101 #if ENABLE(JIT)
102 #define THUNK_GENERATOR(generator) , generator
103 #else
104 #define THUNK_GENERATOR(generator)
105 #endif
106 #if ENABLE(DFG_JIT)
107 #define INTRINSIC(intrinsic) , intrinsic
108 #else
109 #define INTRINSIC(intrinsic)
110 #endif
111
112 static const HashTableValue JSCanvasGradientPrototypeTableValues[] =
113 {
114     { "addColorStop", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsCanvasGradientPrototypeFunctionAddColorStop), (intptr_t)2 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
115     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
116 };
117
118 #undef THUNK_GENERATOR
119 static const HashTable JSCanvasGradientPrototypeTable = { 2, 1, JSCanvasGradientPrototypeTableValues, 0 };
120 const ClassInfo JSCanvasGradientPrototype::s_info = { "CanvasGradientPrototype", &JSC::JSNonFinalObject::s_info, &JSCanvasGradientPrototypeTable, 0, CREATE_METHOD_TABLE(JSCanvasGradientPrototype) };
121
122 JSObject* JSCanvasGradientPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
123 {
124     return getDOMPrototype<JSCanvasGradient>(exec, globalObject);
125 }
126
127 bool JSCanvasGradientPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
128 {
129     JSCanvasGradientPrototype* thisObject = jsCast<JSCanvasGradientPrototype*>(cell);
130     return getStaticFunctionSlot<JSObject>(exec, &JSCanvasGradientPrototypeTable, thisObject, propertyName, slot);
131 }
132
133 bool JSCanvasGradientPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
134 {
135     JSCanvasGradientPrototype* thisObject = jsCast<JSCanvasGradientPrototype*>(object);
136     return getStaticFunctionDescriptor<JSObject>(exec, &JSCanvasGradientPrototypeTable, thisObject, propertyName, descriptor);
137 }
138
139 const ClassInfo JSCanvasGradient::s_info = { "CanvasGradient", &JSDOMWrapper::s_info, &JSCanvasGradientTable, 0 , CREATE_METHOD_TABLE(JSCanvasGradient) };
140
141 JSCanvasGradient::JSCanvasGradient(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<CanvasGradient> impl)
142     : JSDOMWrapper(structure, globalObject)
143     , m_impl(impl.leakRef())
144 {
145 }
146
147 void JSCanvasGradient::finishCreation(JSGlobalData& globalData)
148 {
149     Base::finishCreation(globalData);
150     ASSERT(inherits(&s_info));
151 }
152
153 JSObject* JSCanvasGradient::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
154 {
155     return JSCanvasGradientPrototype::create(exec->globalData(), globalObject, JSCanvasGradientPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
156 }
157
158 bool JSCanvasGradient::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
159 {
160     JSCanvasGradient* thisObject = jsCast<JSCanvasGradient*>(cell);
161     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
162     return getStaticValueSlot<JSCanvasGradient, Base>(exec, &JSCanvasGradientTable, thisObject, propertyName, slot);
163 }
164
165 bool JSCanvasGradient::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
166 {
167     JSCanvasGradient* thisObject = jsCast<JSCanvasGradient*>(object);
168     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
169     return getStaticValueDescriptor<JSCanvasGradient, Base>(exec, &JSCanvasGradientTable, thisObject, propertyName, descriptor);
170 }
171
172 JSValue jsCanvasGradientConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
173 {
174     JSCanvasGradient* domObject = static_cast<JSCanvasGradient*>(asObject(slotBase));
175     return JSCanvasGradient::getConstructor(exec, domObject->globalObject());
176 }
177
178 JSValue JSCanvasGradient::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
179 {
180     return getDOMConstructor<JSCanvasGradientConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
181 }
182
183 EncodedJSValue JSC_HOST_CALL jsCanvasGradientPrototypeFunctionAddColorStop(ExecState* exec)
184 {
185     JSValue thisValue = exec->hostThisValue();
186     if (!thisValue.inherits(&JSCanvasGradient::s_info))
187         return throwVMTypeError(exec);
188     JSCanvasGradient* castedThis = static_cast<JSCanvasGradient*>(asObject(thisValue));
189     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSCanvasGradient::s_info);
190     CanvasGradient* imp = static_cast<CanvasGradient*>(castedThis->impl());
191     ExceptionCode ec = 0;
192     float offset(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toFloat(exec));
193     if (exec->hadException())
194         return JSValue::encode(jsUndefined());
195     const String& color(ustringToString(MAYBE_MISSING_PARAMETER(exec, 1, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 1, MissingIsUndefined).toString(exec)));
196     if (exec->hadException())
197         return JSValue::encode(jsUndefined());
198     imp->addColorStop(offset, color, ec);
199     setDOMException(exec, ec);
200     return JSValue::encode(jsUndefined());
201 }
202
203 static inline bool isObservable(JSCanvasGradient* jsCanvasGradient)
204 {
205     if (jsCanvasGradient->hasCustomProperties())
206         return true;
207     return false;
208 }
209
210 bool JSCanvasGradientOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
211 {
212     JSCanvasGradient* jsCanvasGradient = static_cast<JSCanvasGradient*>(handle.get().asCell());
213     if (!isObservable(jsCanvasGradient))
214         return false;
215     UNUSED_PARAM(visitor);
216     return false;
217 }
218
219 void JSCanvasGradientOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
220 {
221     JSCanvasGradient* jsCanvasGradient = static_cast<JSCanvasGradient*>(handle.get().asCell());
222     DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
223     uncacheWrapper(world, jsCanvasGradient->impl(), jsCanvasGradient);
224     jsCanvasGradient->releaseImpl();
225 }
226
227 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, CanvasGradient* impl)
228 {
229     return wrap<JSCanvasGradient>(exec, globalObject, impl);
230 }
231
232 CanvasGradient* toCanvasGradient(JSC::JSValue value)
233 {
234     return value.inherits(&JSCanvasGradient::s_info) ? static_cast<JSCanvasGradient*>(asObject(value))->impl() : 0;
235 }
236
237 }