|
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 "PlatformString.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(JSCanvasGradient); |
|
34 |
|
35 /* Hash table */ |
|
36 #if ENABLE(JIT) |
|
37 #define THUNK_GENERATOR(generator) , generator |
|
38 #else |
|
39 #define THUNK_GENERATOR(generator) |
|
40 #endif |
|
41 |
|
42 static const HashTableValue JSCanvasGradientTableValues[2] = |
|
43 { |
|
44 { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCanvasGradientConstructor), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
45 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
46 }; |
|
47 |
|
48 #undef THUNK_GENERATOR |
|
49 static JSC_CONST_HASHTABLE HashTable JSCanvasGradientTable = { 2, 1, JSCanvasGradientTableValues, 0 }; |
|
50 /* Hash table for constructor */ |
|
51 #if ENABLE(JIT) |
|
52 #define THUNK_GENERATOR(generator) , generator |
|
53 #else |
|
54 #define THUNK_GENERATOR(generator) |
|
55 #endif |
|
56 |
|
57 static const HashTableValue JSCanvasGradientConstructorTableValues[1] = |
|
58 { |
|
59 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
60 }; |
|
61 |
|
62 #undef THUNK_GENERATOR |
|
63 static JSC_CONST_HASHTABLE HashTable JSCanvasGradientConstructorTable = { 1, 0, JSCanvasGradientConstructorTableValues, 0 }; |
|
64 class JSCanvasGradientConstructor : public DOMConstructorObject { |
|
65 public: |
|
66 JSCanvasGradientConstructor(JSC::ExecState*, JSDOMGlobalObject*); |
|
67 |
|
68 virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); |
|
69 virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); |
|
70 virtual const JSC::ClassInfo* classInfo() const { return &s_info; } |
|
71 static const JSC::ClassInfo s_info; |
|
72 static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) |
|
73 { |
|
74 return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); |
|
75 } |
|
76 protected: |
|
77 static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; |
|
78 }; |
|
79 |
|
80 const ClassInfo JSCanvasGradientConstructor::s_info = { "CanvasGradientConstructor", 0, &JSCanvasGradientConstructorTable, 0 }; |
|
81 |
|
82 JSCanvasGradientConstructor::JSCanvasGradientConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) |
|
83 : DOMConstructorObject(JSCanvasGradientConstructor::createStructure(globalObject->objectPrototype()), globalObject) |
|
84 { |
|
85 putDirect(exec->propertyNames().prototype, JSCanvasGradientPrototype::self(exec, globalObject), DontDelete | ReadOnly); |
|
86 } |
|
87 |
|
88 bool JSCanvasGradientConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
89 { |
|
90 return getStaticValueSlot<JSCanvasGradientConstructor, DOMObject>(exec, &JSCanvasGradientConstructorTable, this, propertyName, slot); |
|
91 } |
|
92 |
|
93 bool JSCanvasGradientConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
94 { |
|
95 return getStaticValueDescriptor<JSCanvasGradientConstructor, DOMObject>(exec, &JSCanvasGradientConstructorTable, this, propertyName, descriptor); |
|
96 } |
|
97 |
|
98 /* Hash table for prototype */ |
|
99 #if ENABLE(JIT) |
|
100 #define THUNK_GENERATOR(generator) , generator |
|
101 #else |
|
102 #define THUNK_GENERATOR(generator) |
|
103 #endif |
|
104 |
|
105 static const HashTableValue JSCanvasGradientPrototypeTableValues[2] = |
|
106 { |
|
107 { "addColorStop", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsCanvasGradientPrototypeFunctionAddColorStop), (intptr_t)2 THUNK_GENERATOR(0) }, |
|
108 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
109 }; |
|
110 |
|
111 #undef THUNK_GENERATOR |
|
112 static JSC_CONST_HASHTABLE HashTable JSCanvasGradientPrototypeTable = { 2, 1, JSCanvasGradientPrototypeTableValues, 0 }; |
|
113 const ClassInfo JSCanvasGradientPrototype::s_info = { "CanvasGradientPrototype", 0, &JSCanvasGradientPrototypeTable, 0 }; |
|
114 |
|
115 JSObject* JSCanvasGradientPrototype::self(ExecState* exec, JSGlobalObject* globalObject) |
|
116 { |
|
117 return getDOMPrototype<JSCanvasGradient>(exec, globalObject); |
|
118 } |
|
119 |
|
120 bool JSCanvasGradientPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
121 { |
|
122 return getStaticFunctionSlot<JSObject>(exec, &JSCanvasGradientPrototypeTable, this, propertyName, slot); |
|
123 } |
|
124 |
|
125 bool JSCanvasGradientPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
126 { |
|
127 return getStaticFunctionDescriptor<JSObject>(exec, &JSCanvasGradientPrototypeTable, this, propertyName, descriptor); |
|
128 } |
|
129 |
|
130 const ClassInfo JSCanvasGradient::s_info = { "CanvasGradient", 0, &JSCanvasGradientTable, 0 }; |
|
131 |
|
132 JSCanvasGradient::JSCanvasGradient(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<CanvasGradient> impl) |
|
133 : DOMObjectWithGlobalPointer(structure, globalObject) |
|
134 , m_impl(impl) |
|
135 { |
|
136 } |
|
137 |
|
138 JSCanvasGradient::~JSCanvasGradient() |
|
139 { |
|
140 forgetDOMObject(this, impl()); |
|
141 } |
|
142 |
|
143 JSObject* JSCanvasGradient::createPrototype(ExecState* exec, JSGlobalObject* globalObject) |
|
144 { |
|
145 return new (exec) JSCanvasGradientPrototype(globalObject, JSCanvasGradientPrototype::createStructure(globalObject->objectPrototype())); |
|
146 } |
|
147 |
|
148 bool JSCanvasGradient::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
149 { |
|
150 return getStaticValueSlot<JSCanvasGradient, Base>(exec, &JSCanvasGradientTable, this, propertyName, slot); |
|
151 } |
|
152 |
|
153 bool JSCanvasGradient::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
154 { |
|
155 return getStaticValueDescriptor<JSCanvasGradient, Base>(exec, &JSCanvasGradientTable, this, propertyName, descriptor); |
|
156 } |
|
157 |
|
158 JSValue jsCanvasGradientConstructor(ExecState* exec, JSValue slotBase, const Identifier&) |
|
159 { |
|
160 JSCanvasGradient* domObject = static_cast<JSCanvasGradient*>(asObject(slotBase)); |
|
161 return JSCanvasGradient::getConstructor(exec, domObject->globalObject()); |
|
162 } |
|
163 JSValue JSCanvasGradient::getConstructor(ExecState* exec, JSGlobalObject* globalObject) |
|
164 { |
|
165 return getDOMConstructor<JSCanvasGradientConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); |
|
166 } |
|
167 |
|
168 EncodedJSValue JSC_HOST_CALL jsCanvasGradientPrototypeFunctionAddColorStop(ExecState* exec) |
|
169 { |
|
170 JSValue thisValue = exec->hostThisValue(); |
|
171 if (!thisValue.inherits(&JSCanvasGradient::s_info)) |
|
172 return throwVMTypeError(exec); |
|
173 JSCanvasGradient* castedThis = static_cast<JSCanvasGradient*>(asObject(thisValue)); |
|
174 CanvasGradient* imp = static_cast<CanvasGradient*>(castedThis->impl()); |
|
175 ExceptionCode ec = 0; |
|
176 float offset = exec->argument(0).toFloat(exec); |
|
177 const String& color = ustringToString(exec->argument(1).toString(exec)); |
|
178 |
|
179 imp->addColorStop(offset, color, ec); |
|
180 setDOMException(exec, ec); |
|
181 return JSValue::encode(jsUndefined()); |
|
182 } |
|
183 |
|
184 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, CanvasGradient* object) |
|
185 { |
|
186 return getDOMObjectWrapper<JSCanvasGradient>(exec, globalObject, object); |
|
187 } |
|
188 CanvasGradient* toCanvasGradient(JSC::JSValue value) |
|
189 { |
|
190 return value.inherits(&JSCanvasGradient::s_info) ? static_cast<JSCanvasGradient*>(asObject(value))->impl() : 0; |
|
191 } |
|
192 |
|
193 } |