a1a824308f4f080c9d2cd7c6da78a9140f1bad9f
[WebKit.git] / Source / WebCore / bindings / scripts / test / JS / JSTestSerializationInherit.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 "JSTestSerializationInherit.h"
23
24 #include "JSDOMAttribute.h"
25 #include "JSDOMBinding.h"
26 #include "JSDOMConstructorNotConstructable.h"
27 #include "JSDOMConvertNumbers.h"
28 #include "JSDOMExceptionHandling.h"
29 #include "JSDOMOperation.h"
30 #include "JSDOMWrapperCache.h"
31 #include "ScriptExecutionContext.h"
32 #include <JavaScriptCore/HeapSnapshotBuilder.h>
33 #include <JavaScriptCore/JSCInlines.h>
34 #include <JavaScriptCore/ObjectConstructor.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 jsTestSerializationInheritPrototypeFunctionToJSON(JSC::ExecState*);
46
47 // Attributes
48
49 JSC::EncodedJSValue jsTestSerializationInheritConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
50 bool setJSTestSerializationInheritConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
51 JSC::EncodedJSValue jsTestSerializationInheritInheritLongAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
52 bool setJSTestSerializationInheritInheritLongAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
53
54 class JSTestSerializationInheritPrototype : public JSC::JSNonFinalObject {
55 public:
56     using Base = JSC::JSNonFinalObject;
57     static JSTestSerializationInheritPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
58     {
59         JSTestSerializationInheritPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestSerializationInheritPrototype>(vm.heap)) JSTestSerializationInheritPrototype(vm, globalObject, structure);
60         ptr->finishCreation(vm);
61         return ptr;
62     }
63
64     DECLARE_INFO;
65     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
66     {
67         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
68     }
69
70 private:
71     JSTestSerializationInheritPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
72         : JSC::JSNonFinalObject(vm, structure)
73     {
74         didBecomePrototype();
75     }
76
77     void finishCreation(JSC::VM&);
78 };
79
80 using JSTestSerializationInheritConstructor = JSDOMConstructorNotConstructable<JSTestSerializationInherit>;
81
82 template<> JSValue JSTestSerializationInheritConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
83 {
84     auto result = JSTestSerialization::getConstructor(vm, &globalObject);
85     result.getObject()->didBecomePrototype();
86     return result;
87 }
88
89 template<> void JSTestSerializationInheritConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
90 {
91     putDirect(vm, vm.propertyNames->prototype, JSTestSerializationInherit::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
92     putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("TestSerializationInherit"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
93     putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
94 }
95
96 template<> const ClassInfo JSTestSerializationInheritConstructor::s_info = { "TestSerializationInherit", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestSerializationInheritConstructor) };
97
98 /* Hash table for prototype */
99
100 static const HashTableValue JSTestSerializationInheritPrototypeTableValues[] =
101 {
102     { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationInheritConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationInheritConstructor) } },
103     { "inheritLongAttribute", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationInheritInheritLongAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationInheritInheritLongAttribute) } },
104     { "toJSON", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestSerializationInheritPrototypeFunctionToJSON), (intptr_t) (0) } },
105 };
106
107 const ClassInfo JSTestSerializationInheritPrototype::s_info = { "TestSerializationInheritPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestSerializationInheritPrototype) };
108
109 void JSTestSerializationInheritPrototype::finishCreation(VM& vm)
110 {
111     Base::finishCreation(vm);
112     reifyStaticProperties(vm, JSTestSerializationInherit::info(), JSTestSerializationInheritPrototypeTableValues, *this);
113 }
114
115 const ClassInfo JSTestSerializationInherit::s_info = { "TestSerializationInherit", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestSerializationInherit) };
116
117 JSTestSerializationInherit::JSTestSerializationInherit(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestSerializationInherit>&& impl)
118     : JSTestSerialization(structure, globalObject, WTFMove(impl))
119 {
120 }
121
122 void JSTestSerializationInherit::finishCreation(VM& vm)
123 {
124     Base::finishCreation(vm);
125     ASSERT(inherits(vm, info()));
126
127 }
128
129 JSObject* JSTestSerializationInherit::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
130 {
131     return JSTestSerializationInheritPrototype::create(vm, &globalObject, JSTestSerializationInheritPrototype::createStructure(vm, &globalObject, JSTestSerialization::prototype(vm, globalObject)));
132 }
133
134 JSObject* JSTestSerializationInherit::prototype(VM& vm, JSDOMGlobalObject& globalObject)
135 {
136     return getDOMPrototype<JSTestSerializationInherit>(vm, globalObject);
137 }
138
139 JSValue JSTestSerializationInherit::getConstructor(VM& vm, const JSGlobalObject* globalObject)
140 {
141     return getDOMConstructor<JSTestSerializationInheritConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
142 }
143
144 template<> inline JSTestSerializationInherit* IDLAttribute<JSTestSerializationInherit>::cast(ExecState& state, EncodedJSValue thisValue)
145 {
146     return jsDynamicCast<JSTestSerializationInherit*>(state.vm(), JSValue::decode(thisValue));
147 }
148
149 template<> inline JSTestSerializationInherit* IDLOperation<JSTestSerializationInherit>::cast(ExecState& state)
150 {
151     return jsDynamicCast<JSTestSerializationInherit*>(state.vm(), state.thisValue());
152 }
153
154 EncodedJSValue jsTestSerializationInheritConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
155 {
156     VM& vm = state->vm();
157     auto throwScope = DECLARE_THROW_SCOPE(vm);
158     auto* prototype = jsDynamicCast<JSTestSerializationInheritPrototype*>(vm, JSValue::decode(thisValue));
159     if (UNLIKELY(!prototype))
160         return throwVMTypeError(state, throwScope);
161     return JSValue::encode(JSTestSerializationInherit::getConstructor(state->vm(), prototype->globalObject()));
162 }
163
164 bool setJSTestSerializationInheritConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
165 {
166     VM& vm = state->vm();
167     auto throwScope = DECLARE_THROW_SCOPE(vm);
168     auto* prototype = jsDynamicCast<JSTestSerializationInheritPrototype*>(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 JSValue jsTestSerializationInheritInheritLongAttributeGetter(ExecState& state, JSTestSerializationInherit& thisObject, ThrowScope& throwScope)
178 {
179     UNUSED_PARAM(throwScope);
180     UNUSED_PARAM(state);
181     auto& impl = thisObject.wrapped();
182     JSValue result = toJS<IDLLong>(state, throwScope, impl.inheritLongAttribute());
183     return result;
184 }
185
186 EncodedJSValue jsTestSerializationInheritInheritLongAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
187 {
188     return IDLAttribute<JSTestSerializationInherit>::get<jsTestSerializationInheritInheritLongAttributeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "inheritLongAttribute");
189 }
190
191 static inline bool setJSTestSerializationInheritInheritLongAttributeSetter(ExecState& state, JSTestSerializationInherit& thisObject, JSValue value, ThrowScope& throwScope)
192 {
193     UNUSED_PARAM(throwScope);
194     auto& impl = thisObject.wrapped();
195     auto nativeValue = convert<IDLLong>(state, value);
196     RETURN_IF_EXCEPTION(throwScope, false);
197     AttributeSetter::call(state, throwScope, [&] {
198         return impl.setInheritLongAttribute(WTFMove(nativeValue));
199     });
200     return true;
201 }
202
203 bool setJSTestSerializationInheritInheritLongAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
204 {
205     return IDLAttribute<JSTestSerializationInherit>::set<setJSTestSerializationInheritInheritLongAttributeSetter>(*state, thisValue, encodedValue, "inheritLongAttribute");
206 }
207
208 JSC::JSObject* JSTestSerializationInherit::serialize(ExecState& state, JSTestSerializationInherit& thisObject, JSDOMGlobalObject& globalObject, ThrowScope& throwScope)
209 {
210     auto& vm = state.vm();
211     auto* result = JSTestSerialization::serialize(state, thisObject, globalObject, throwScope);
212
213     auto inheritLongAttributeValue = jsTestSerializationInheritInheritLongAttributeGetter(state, thisObject, throwScope);
214     throwScope.assertNoException();
215     result->putDirect(vm, Identifier::fromString(&vm, "inheritLongAttribute"), inheritLongAttributeValue);
216
217     return result;
218 }
219
220 static inline EncodedJSValue jsTestSerializationInheritPrototypeFunctionToJSONBody(ExecState* state, JSTestSerializationInherit* thisObject, JSC::ThrowScope& throwScope)
221 {
222     return JSValue::encode(JSTestSerializationInherit::serialize(*state, *thisObject, *thisObject->globalObject(), throwScope));
223 }
224
225 EncodedJSValue JSC_HOST_CALL jsTestSerializationInheritPrototypeFunctionToJSON(ExecState* state)
226 {
227     return IDLOperation<JSTestSerializationInherit>::call<jsTestSerializationInheritPrototypeFunctionToJSONBody>(*state, "toJSON");
228 }
229
230 void JSTestSerializationInherit::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
231 {
232     auto* thisObject = jsCast<JSTestSerializationInherit*>(cell);
233     builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
234     if (thisObject->scriptExecutionContext())
235         builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
236     Base::heapSnapshot(cell, builder);
237 }
238
239
240 }