Add [ActiveDOMObject] to IDLs of ActiveDOMObjects
[WebKit-https.git] / Source / WebCore / bindings / scripts / test / JS / JSTestStringifierOperationImplementedAs.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 "JSTestStringifierOperationImplementedAs.h"
23
24 #include "ActiveDOMObject.h"
25 #include "JSDOMBinding.h"
26 #include "JSDOMConstructorNotConstructable.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/HeapAnalyzer.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 jsTestStringifierOperationImplementedAsPrototypeFunctionIdentifier(JSC::JSGlobalObject*, JSC::CallFrame*);
46 JSC::EncodedJSValue JSC_HOST_CALL jsTestStringifierOperationImplementedAsPrototypeFunctionToString(JSC::JSGlobalObject*, JSC::CallFrame*);
47
48 // Attributes
49
50 JSC::EncodedJSValue jsTestStringifierOperationImplementedAsConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
51 bool setJSTestStringifierOperationImplementedAsConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
52
53 class JSTestStringifierOperationImplementedAsPrototype : public JSC::JSNonFinalObject {
54 public:
55     using Base = JSC::JSNonFinalObject;
56     static JSTestStringifierOperationImplementedAsPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
57     {
58         JSTestStringifierOperationImplementedAsPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestStringifierOperationImplementedAsPrototype>(vm.heap)) JSTestStringifierOperationImplementedAsPrototype(vm, globalObject, structure);
59         ptr->finishCreation(vm);
60         return ptr;
61     }
62
63     DECLARE_INFO;
64     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
65     {
66         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
67     }
68
69 private:
70     JSTestStringifierOperationImplementedAsPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
71         : JSC::JSNonFinalObject(vm, structure)
72     {
73     }
74
75     void finishCreation(JSC::VM&);
76 };
77
78 using JSTestStringifierOperationImplementedAsConstructor = JSDOMConstructorNotConstructable<JSTestStringifierOperationImplementedAs>;
79
80 template<> JSValue JSTestStringifierOperationImplementedAsConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
81 {
82     UNUSED_PARAM(vm);
83     return globalObject.functionPrototype();
84 }
85
86 template<> void JSTestStringifierOperationImplementedAsConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
87 {
88     putDirect(vm, vm.propertyNames->prototype, JSTestStringifierOperationImplementedAs::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
89     putDirect(vm, vm.propertyNames->name, jsNontrivialString(vm, String("TestStringifierOperationImplementedAs"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
90     putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
91 }
92
93 template<> const ClassInfo JSTestStringifierOperationImplementedAsConstructor::s_info = { "TestStringifierOperationImplementedAs", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestStringifierOperationImplementedAsConstructor) };
94
95 /* Hash table for prototype */
96
97 static const HashTableValue JSTestStringifierOperationImplementedAsPrototypeTableValues[] =
98 {
99     { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestStringifierOperationImplementedAsConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestStringifierOperationImplementedAsConstructor) } },
100     { "identifier", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestStringifierOperationImplementedAsPrototypeFunctionIdentifier), (intptr_t) (0) } },
101     { "toString", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestStringifierOperationImplementedAsPrototypeFunctionToString), (intptr_t) (0) } },
102 };
103
104 const ClassInfo JSTestStringifierOperationImplementedAsPrototype::s_info = { "TestStringifierOperationImplementedAsPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestStringifierOperationImplementedAsPrototype) };
105
106 void JSTestStringifierOperationImplementedAsPrototype::finishCreation(VM& vm)
107 {
108     Base::finishCreation(vm);
109     reifyStaticProperties(vm, JSTestStringifierOperationImplementedAs::info(), JSTestStringifierOperationImplementedAsPrototypeTableValues, *this);
110 }
111
112 const ClassInfo JSTestStringifierOperationImplementedAs::s_info = { "TestStringifierOperationImplementedAs", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestStringifierOperationImplementedAs) };
113
114 JSTestStringifierOperationImplementedAs::JSTestStringifierOperationImplementedAs(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestStringifierOperationImplementedAs>&& impl)
115     : JSDOMWrapper<TestStringifierOperationImplementedAs>(structure, globalObject, WTFMove(impl))
116 {
117 }
118
119 void JSTestStringifierOperationImplementedAs::finishCreation(VM& vm)
120 {
121     Base::finishCreation(vm);
122     ASSERT(inherits(vm, info()));
123
124     static_assert(!std::is_base_of<ActiveDOMObject, TestStringifierOperationImplementedAs>::value, "Interface is not marked as [ActiveDOMObject] even though implementation class subclasses ActiveDOMObject.");
125
126 }
127
128 JSObject* JSTestStringifierOperationImplementedAs::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
129 {
130     return JSTestStringifierOperationImplementedAsPrototype::create(vm, &globalObject, JSTestStringifierOperationImplementedAsPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
131 }
132
133 JSObject* JSTestStringifierOperationImplementedAs::prototype(VM& vm, JSDOMGlobalObject& globalObject)
134 {
135     return getDOMPrototype<JSTestStringifierOperationImplementedAs>(vm, globalObject);
136 }
137
138 JSValue JSTestStringifierOperationImplementedAs::getConstructor(VM& vm, const JSGlobalObject* globalObject)
139 {
140     return getDOMConstructor<JSTestStringifierOperationImplementedAsConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
141 }
142
143 void JSTestStringifierOperationImplementedAs::destroy(JSC::JSCell* cell)
144 {
145     JSTestStringifierOperationImplementedAs* thisObject = static_cast<JSTestStringifierOperationImplementedAs*>(cell);
146     thisObject->JSTestStringifierOperationImplementedAs::~JSTestStringifierOperationImplementedAs();
147 }
148
149 template<> inline JSTestStringifierOperationImplementedAs* IDLOperation<JSTestStringifierOperationImplementedAs>::cast(ExecState& state)
150 {
151     return jsDynamicCast<JSTestStringifierOperationImplementedAs*>(state.vm(), state.thisValue());
152 }
153
154 EncodedJSValue jsTestStringifierOperationImplementedAsConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
155 {
156     VM& vm = state->vm();
157     auto throwScope = DECLARE_THROW_SCOPE(vm);
158     auto* prototype = jsDynamicCast<JSTestStringifierOperationImplementedAsPrototype*>(vm, JSValue::decode(thisValue));
159     if (UNLIKELY(!prototype))
160         return throwVMTypeError(state, throwScope);
161     return JSValue::encode(JSTestStringifierOperationImplementedAs::getConstructor(state->vm(), prototype->globalObject()));
162 }
163
164 bool setJSTestStringifierOperationImplementedAsConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
165 {
166     VM& vm = state->vm();
167     auto throwScope = DECLARE_THROW_SCOPE(vm);
168     auto* prototype = jsDynamicCast<JSTestStringifierOperationImplementedAsPrototype*>(vm, JSValue::decode(thisValue));
169     if (UNLIKELY(!prototype)) {
170         throwVMTypeError(state, throwScope);
171         return false;
172     }
173     // Shadowing a built-in constructor
174     return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
175 }
176
177 static inline JSC::EncodedJSValue jsTestStringifierOperationImplementedAsPrototypeFunctionIdentifierBody(JSC::ExecState* state, typename IDLOperation<JSTestStringifierOperationImplementedAs>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
178 {
179     UNUSED_PARAM(state);
180     UNUSED_PARAM(throwScope);
181     auto& impl = castedThis->wrapped();
182     return JSValue::encode(toJS<IDLDOMString>(*state, impl.alternateIdentifier()));
183 }
184
185 EncodedJSValue JSC_HOST_CALL jsTestStringifierOperationImplementedAsPrototypeFunctionIdentifier(JSGlobalObject* globalObject, CallFrame* state)
186 {
187     UNUSED_PARAM(globalObject);
188     return IDLOperation<JSTestStringifierOperationImplementedAs>::call<jsTestStringifierOperationImplementedAsPrototypeFunctionIdentifierBody>(*state, "identifier");
189 }
190
191 static inline JSC::EncodedJSValue jsTestStringifierOperationImplementedAsPrototypeFunctionToStringBody(JSC::ExecState* state, typename IDLOperation<JSTestStringifierOperationImplementedAs>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
192 {
193     UNUSED_PARAM(state);
194     UNUSED_PARAM(throwScope);
195     auto& impl = castedThis->wrapped();
196     return JSValue::encode(toJS<IDLDOMString>(*state, impl.alternateIdentifier()));
197 }
198
199 EncodedJSValue JSC_HOST_CALL jsTestStringifierOperationImplementedAsPrototypeFunctionToString(JSGlobalObject* globalObject, CallFrame* state)
200 {
201     UNUSED_PARAM(globalObject);
202     return IDLOperation<JSTestStringifierOperationImplementedAs>::call<jsTestStringifierOperationImplementedAsPrototypeFunctionToStringBody>(*state, "toString");
203 }
204
205 void JSTestStringifierOperationImplementedAs::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
206 {
207     auto* thisObject = jsCast<JSTestStringifierOperationImplementedAs*>(cell);
208     analyzer.setWrappedObjectForCell(cell, &thisObject->wrapped());
209     if (thisObject->scriptExecutionContext())
210         analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
211     Base::analyzeHeap(cell, analyzer);
212 }
213
214 bool JSTestStringifierOperationImplementedAsOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
215 {
216     UNUSED_PARAM(handle);
217     UNUSED_PARAM(visitor);
218     UNUSED_PARAM(reason);
219     return false;
220 }
221
222 void JSTestStringifierOperationImplementedAsOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
223 {
224     auto* jsTestStringifierOperationImplementedAs = static_cast<JSTestStringifierOperationImplementedAs*>(handle.slot()->asCell());
225     auto& world = *static_cast<DOMWrapperWorld*>(context);
226     uncacheWrapper(world, &jsTestStringifierOperationImplementedAs->wrapped(), jsTestStringifierOperationImplementedAs);
227 }
228
229 #if ENABLE(BINDING_INTEGRITY)
230 #if PLATFORM(WIN)
231 #pragma warning(disable: 4483)
232 extern "C" { extern void (*const __identifier("??_7TestStringifierOperationImplementedAs@WebCore@@6B@")[])(); }
233 #else
234 extern "C" { extern void* _ZTVN7WebCore37TestStringifierOperationImplementedAsE[]; }
235 #endif
236 #endif
237
238 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TestStringifierOperationImplementedAs>&& impl)
239 {
240
241 #if ENABLE(BINDING_INTEGRITY)
242     void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
243 #if PLATFORM(WIN)
244     void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7TestStringifierOperationImplementedAs@WebCore@@6B@"));
245 #else
246     void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore37TestStringifierOperationImplementedAsE[2]);
247 #endif
248
249     // If this fails TestStringifierOperationImplementedAs does not have a vtable, so you need to add the
250     // ImplementationLacksVTable attribute to the interface definition
251     static_assert(std::is_polymorphic<TestStringifierOperationImplementedAs>::value, "TestStringifierOperationImplementedAs is not polymorphic");
252
253     // If you hit this assertion you either have a use after free bug, or
254     // TestStringifierOperationImplementedAs has subclasses. If TestStringifierOperationImplementedAs has subclasses that get passed
255     // to toJS() we currently require TestStringifierOperationImplementedAs you to opt out of binding hardening
256     // by adding the SkipVTableValidation attribute to the interface IDL definition
257     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
258 #endif
259     return createWrapper<TestStringifierOperationImplementedAs>(globalObject, WTFMove(impl));
260 }
261
262 JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestStringifierOperationImplementedAs& impl)
263 {
264     return wrap(state, globalObject, impl);
265 }
266
267 TestStringifierOperationImplementedAs* JSTestStringifierOperationImplementedAs::toWrapped(JSC::VM& vm, JSC::JSValue value)
268 {
269     if (auto* wrapper = jsDynamicCast<JSTestStringifierOperationImplementedAs*>(vm, value))
270         return &wrapper->wrapped();
271     return nullptr;
272 }
273
274 }