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