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 "JSDOMBinding.h" |
25 | #include "JSDOMConstructorNotConstructable.h" |
26 | #include "JSDOMConvertNumbers.h" |
27 | #include "JSDOMConvertStrings.h" |
28 | #include "JSDOMExceptionHandling.h" |
29 | #include "JSDOMOperation.h" |
30 | #include "JSDOMWrapperCache.h" |
31 | #include "ScriptExecutionContext.h" |
32 | #include <JavaScriptCore/FunctionPrototype.h> |
33 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
34 | #include <JavaScriptCore/JSCInlines.h> |
35 | #include <wtf/GetPtr.h> |
36 | #include <wtf/PointerPreparations.h> |
37 | #include <wtf/URL.h> |
38 | |
39 | |
40 | namespace WebCore { |
41 | using namespace JSC; |
42 | |
43 | // Functions |
44 | |
45 | JSC::EncodedJSValue JSC_HOST_CALL jsCanvasGradientPrototypeFunctionAddColorStop(JSC::ExecState*); |
46 | |
47 | // Attributes |
48 | |
49 | JSC::EncodedJSValue jsCanvasGradientConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
50 | bool setJSCanvasGradientConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
51 | |
52 | class JSCanvasGradientPrototype : public JSC::JSNonFinalObject { |
53 | public: |
54 | using Base = JSC::JSNonFinalObject; |
55 | static JSCanvasGradientPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
56 | { |
57 | JSCanvasGradientPrototype* ptr = new (NotNull, JSC::allocateCell<JSCanvasGradientPrototype>(vm.heap)) JSCanvasGradientPrototype(vm, globalObject, structure); |
58 | ptr->finishCreation(vm); |
59 | return ptr; |
60 | } |
61 | |
62 | DECLARE_INFO; |
63 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
64 | { |
65 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
66 | } |
67 | |
68 | private: |
69 | JSCanvasGradientPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
70 | : JSC::JSNonFinalObject(vm, structure) |
71 | { |
72 | } |
73 | |
74 | void finishCreation(JSC::VM&); |
75 | }; |
76 | |
77 | using JSCanvasGradientConstructor = JSDOMConstructorNotConstructable<JSCanvasGradient>; |
78 | |
79 | template<> JSValue JSCanvasGradientConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
80 | { |
81 | UNUSED_PARAM(vm); |
82 | return globalObject.functionPrototype(); |
83 | } |
84 | |
85 | template<> void JSCanvasGradientConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
86 | { |
87 | putDirect(vm, vm.propertyNames->prototype, JSCanvasGradient::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
88 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("CanvasGradient"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
89 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
90 | } |
91 | |
92 | template<> const ClassInfo JSCanvasGradientConstructor::s_info = { "CanvasGradient" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCanvasGradientConstructor) }; |
93 | |
94 | /* Hash table for prototype */ |
95 | |
96 | static const HashTableValue JSCanvasGradientPrototypeTableValues[] = |
97 | { |
98 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCanvasGradientConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSCanvasGradientConstructor) } }, |
99 | { "addColorStop" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsCanvasGradientPrototypeFunctionAddColorStop), (intptr_t) (2) } }, |
100 | }; |
101 | |
102 | const ClassInfo JSCanvasGradientPrototype::s_info = { "CanvasGradientPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCanvasGradientPrototype) }; |
103 | |
104 | void JSCanvasGradientPrototype::finishCreation(VM& vm) |
105 | { |
106 | Base::finishCreation(vm); |
107 | reifyStaticProperties(vm, JSCanvasGradient::info(), JSCanvasGradientPrototypeTableValues, *this); |
108 | } |
109 | |
110 | const ClassInfo JSCanvasGradient::s_info = { "CanvasGradient" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCanvasGradient) }; |
111 | |
112 | JSCanvasGradient::JSCanvasGradient(Structure* structure, JSDOMGlobalObject& globalObject, Ref<CanvasGradient>&& impl) |
113 | : JSDOMWrapper<CanvasGradient>(structure, globalObject, WTFMove(impl)) |
114 | { |
115 | } |
116 | |
117 | void JSCanvasGradient::finishCreation(VM& vm) |
118 | { |
119 | Base::finishCreation(vm); |
120 | ASSERT(inherits(vm, info())); |
121 | |
122 | } |
123 | |
124 | JSObject* JSCanvasGradient::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
125 | { |
126 | return JSCanvasGradientPrototype::create(vm, &globalObject, JSCanvasGradientPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
127 | } |
128 | |
129 | JSObject* JSCanvasGradient::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
130 | { |
131 | return getDOMPrototype<JSCanvasGradient>(vm, globalObject); |
132 | } |
133 | |
134 | JSValue JSCanvasGradient::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
135 | { |
136 | return getDOMConstructor<JSCanvasGradientConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
137 | } |
138 | |
139 | void JSCanvasGradient::destroy(JSC::JSCell* cell) |
140 | { |
141 | JSCanvasGradient* thisObject = static_cast<JSCanvasGradient*>(cell); |
142 | thisObject->JSCanvasGradient::~JSCanvasGradient(); |
143 | } |
144 | |
145 | template<> inline JSCanvasGradient* IDLOperation<JSCanvasGradient>::cast(ExecState& state) |
146 | { |
147 | return jsDynamicCast<JSCanvasGradient*>(state.vm(), state.thisValue()); |
148 | } |
149 | |
150 | EncodedJSValue jsCanvasGradientConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
151 | { |
152 | VM& vm = state->vm(); |
153 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
154 | auto* prototype = jsDynamicCast<JSCanvasGradientPrototype*>(vm, JSValue::decode(thisValue)); |
155 | if (UNLIKELY(!prototype)) |
156 | return throwVMTypeError(state, throwScope); |
157 | return JSValue::encode(JSCanvasGradient::getConstructor(state->vm(), prototype->globalObject())); |
158 | } |
159 | |
160 | bool setJSCanvasGradientConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
161 | { |
162 | VM& vm = state->vm(); |
163 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
164 | auto* prototype = jsDynamicCast<JSCanvasGradientPrototype*>(vm, JSValue::decode(thisValue)); |
165 | if (UNLIKELY(!prototype)) { |
166 | throwVMTypeError(state, throwScope); |
167 | return false; |
168 | } |
169 | // Shadowing a built-in constructor |
170 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
171 | } |
172 | |
173 | static inline JSC::EncodedJSValue jsCanvasGradientPrototypeFunctionAddColorStopBody(JSC::ExecState* state, typename IDLOperation<JSCanvasGradient>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
174 | { |
175 | UNUSED_PARAM(state); |
176 | UNUSED_PARAM(throwScope); |
177 | auto& impl = castedThis->wrapped(); |
178 | if (UNLIKELY(state->argumentCount() < 2)) |
179 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
180 | auto offset = convert<IDLFloat>(*state, state->uncheckedArgument(0)); |
181 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
182 | auto color = convert<IDLDOMString>(*state, state->uncheckedArgument(1)); |
183 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
184 | propagateException(*state, throwScope, impl.addColorStop(WTFMove(offset), WTFMove(color))); |
185 | return JSValue::encode(jsUndefined()); |
186 | } |
187 | |
188 | EncodedJSValue JSC_HOST_CALL jsCanvasGradientPrototypeFunctionAddColorStop(ExecState* state) |
189 | { |
190 | return IDLOperation<JSCanvasGradient>::call<jsCanvasGradientPrototypeFunctionAddColorStopBody>(*state, "addColorStop" ); |
191 | } |
192 | |
193 | void JSCanvasGradient::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
194 | { |
195 | auto* thisObject = jsCast<JSCanvasGradient*>(cell); |
196 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
197 | if (thisObject->scriptExecutionContext()) |
198 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
199 | Base::heapSnapshot(cell, builder); |
200 | } |
201 | |
202 | bool JSCanvasGradientOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
203 | { |
204 | UNUSED_PARAM(handle); |
205 | UNUSED_PARAM(visitor); |
206 | UNUSED_PARAM(reason); |
207 | return false; |
208 | } |
209 | |
210 | void JSCanvasGradientOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
211 | { |
212 | auto* jsCanvasGradient = static_cast<JSCanvasGradient*>(handle.slot()->asCell()); |
213 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
214 | uncacheWrapper(world, &jsCanvasGradient->wrapped(), jsCanvasGradient); |
215 | } |
216 | |
217 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<CanvasGradient>&& impl) |
218 | { |
219 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
220 | // attribute. You should remove that attribute. If the class has subclasses |
221 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
222 | // attribute to CanvasGradient. |
223 | static_assert(!std::is_polymorphic<CanvasGradient>::value, "CanvasGradient is polymorphic but the IDL claims it is not" ); |
224 | return createWrapper<CanvasGradient>(globalObject, WTFMove(impl)); |
225 | } |
226 | |
227 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, CanvasGradient& impl) |
228 | { |
229 | return wrap(state, globalObject, impl); |
230 | } |
231 | |
232 | CanvasGradient* JSCanvasGradient::toWrapped(JSC::VM& vm, JSC::JSValue value) |
233 | { |
234 | if (auto* wrapper = jsDynamicCast<JSCanvasGradient*>(vm, value)) |
235 | return &wrapper->wrapped(); |
236 | return nullptr; |
237 | } |
238 | |
239 | } |
240 | |