2 This file is part of the WebKit open source project.
3 This file has been generated by generate-bindings.pl. DO NOT MODIFY!
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.
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.
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.
22 #include "JSCanvasGradient.h"
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>
35 ASSERT_CLASS_FITS_IN_CELL(JSCanvasGradient);
39 #define THUNK_GENERATOR(generator) , generator
41 #define THUNK_GENERATOR(generator)
44 #define INTRINSIC(intrinsic) , intrinsic
46 #define INTRINSIC(intrinsic)
49 static const HashTableValue JSCanvasGradientTableValues[] =
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) }
55 #undef THUNK_GENERATOR
56 static const HashTable JSCanvasGradientTable = { 2, 1, JSCanvasGradientTableValues, 0 };
57 /* Hash table for constructor */
59 #define THUNK_GENERATOR(generator) , generator
61 #define THUNK_GENERATOR(generator)
64 #define INTRINSIC(intrinsic) , intrinsic
66 #define INTRINSIC(intrinsic)
69 static const HashTableValue JSCanvasGradientConstructorTableValues[] =
71 { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
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) };
78 JSCanvasGradientConstructor::JSCanvasGradientConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
79 : DOMConstructorObject(structure, globalObject)
83 void JSCanvasGradientConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
85 Base::finishCreation(exec->globalData());
86 ASSERT(inherits(&s_info));
87 putDirect(exec->globalData(), exec->propertyNames().prototype, JSCanvasGradientPrototype::self(exec, globalObject), DontDelete | ReadOnly);
90 bool JSCanvasGradientConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
92 return getStaticValueSlot<JSCanvasGradientConstructor, JSDOMWrapper>(exec, &JSCanvasGradientConstructorTable, static_cast<JSCanvasGradientConstructor*>(cell), propertyName, slot);
95 bool JSCanvasGradientConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
97 return getStaticValueDescriptor<JSCanvasGradientConstructor, JSDOMWrapper>(exec, &JSCanvasGradientConstructorTable, static_cast<JSCanvasGradientConstructor*>(object), propertyName, descriptor);
100 /* Hash table for prototype */
102 #define THUNK_GENERATOR(generator) , generator
104 #define THUNK_GENERATOR(generator)
107 #define INTRINSIC(intrinsic) , intrinsic
109 #define INTRINSIC(intrinsic)
112 static const HashTableValue JSCanvasGradientPrototypeTableValues[] =
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) }
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) };
122 JSObject* JSCanvasGradientPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
124 return getDOMPrototype<JSCanvasGradient>(exec, globalObject);
127 bool JSCanvasGradientPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
129 JSCanvasGradientPrototype* thisObject = jsCast<JSCanvasGradientPrototype*>(cell);
130 return getStaticFunctionSlot<JSObject>(exec, &JSCanvasGradientPrototypeTable, thisObject, propertyName, slot);
133 bool JSCanvasGradientPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
135 JSCanvasGradientPrototype* thisObject = jsCast<JSCanvasGradientPrototype*>(object);
136 return getStaticFunctionDescriptor<JSObject>(exec, &JSCanvasGradientPrototypeTable, thisObject, propertyName, descriptor);
139 const ClassInfo JSCanvasGradient::s_info = { "CanvasGradient", &JSDOMWrapper::s_info, &JSCanvasGradientTable, 0 , CREATE_METHOD_TABLE(JSCanvasGradient) };
141 JSCanvasGradient::JSCanvasGradient(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<CanvasGradient> impl)
142 : JSDOMWrapper(structure, globalObject)
143 , m_impl(impl.leakRef())
147 void JSCanvasGradient::finishCreation(JSGlobalData& globalData)
149 Base::finishCreation(globalData);
150 ASSERT(inherits(&s_info));
153 JSObject* JSCanvasGradient::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
155 return JSCanvasGradientPrototype::create(exec->globalData(), globalObject, JSCanvasGradientPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
158 bool JSCanvasGradient::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
160 JSCanvasGradient* thisObject = jsCast<JSCanvasGradient*>(cell);
161 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
162 return getStaticValueSlot<JSCanvasGradient, Base>(exec, &JSCanvasGradientTable, thisObject, propertyName, slot);
165 bool JSCanvasGradient::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
167 JSCanvasGradient* thisObject = jsCast<JSCanvasGradient*>(object);
168 ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
169 return getStaticValueDescriptor<JSCanvasGradient, Base>(exec, &JSCanvasGradientTable, thisObject, propertyName, descriptor);
172 JSValue jsCanvasGradientConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
174 JSCanvasGradient* domObject = static_cast<JSCanvasGradient*>(asObject(slotBase));
175 return JSCanvasGradient::getConstructor(exec, domObject->globalObject());
178 JSValue JSCanvasGradient::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
180 return getDOMConstructor<JSCanvasGradientConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
183 EncodedJSValue JSC_HOST_CALL jsCanvasGradientPrototypeFunctionAddColorStop(ExecState* exec)
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());
203 static inline bool isObservable(JSCanvasGradient* jsCanvasGradient)
205 if (jsCanvasGradient->hasCustomProperties())
210 bool JSCanvasGradientOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
212 JSCanvasGradient* jsCanvasGradient = static_cast<JSCanvasGradient*>(handle.get().asCell());
213 if (!isObservable(jsCanvasGradient))
215 UNUSED_PARAM(visitor);
219 void JSCanvasGradientOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
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();
227 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, CanvasGradient* impl)
229 return wrap<JSCanvasGradient>(exec, globalObject, impl);
232 CanvasGradient* toCanvasGradient(JSC::JSValue value)
234 return value.inherits(&JSCanvasGradient::s_info) ? static_cast<JSCanvasGradient*>(asObject(value))->impl() : 0;