1 | /* |
2 | * Copyright (C) 2015, 2016 Canon Inc. All rights reserved. |
3 | * Copyright (C) 2016 Apple Inc. All rights reserved. |
4 | * |
5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Lesser 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 | * Lesser General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Lesser General Public |
16 | * License along with this library; if not, write to the Free Software |
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
18 | */ |
19 | |
20 | #pragma once |
21 | |
22 | #include "JSDOMWrapper.h" |
23 | |
24 | namespace WebCore { |
25 | |
26 | // Base class for all constructor objects in the JSC bindings. |
27 | class JSDOMConstructorBase : public JSDOMObject { |
28 | public: |
29 | using Base = JSDOMObject; |
30 | |
31 | static const unsigned StructureFlags = Base::StructureFlags | JSC::ImplementsHasInstance | JSC::ImplementsDefaultHasInstance | JSC::OverridesGetCallData; |
32 | static JSC::Structure* createStructure(JSC::VM&, JSC::JSGlobalObject*, JSC::JSValue); |
33 | |
34 | protected: |
35 | JSDOMConstructorBase(JSC::Structure* structure, JSDOMGlobalObject& globalObject) |
36 | : JSDOMObject(structure, globalObject) |
37 | { |
38 | } |
39 | |
40 | static String className(const JSObject*, JSC::VM&); |
41 | static String toStringName(const JSObject*, JSC::ExecState*); |
42 | static JSC::CallType getCallData(JSCell*, JSC::CallData&); |
43 | }; |
44 | |
45 | inline JSC::Structure* JSDOMConstructorBase::createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
46 | { |
47 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
48 | } |
49 | |
50 | } // namespace WebCore |
51 | |