1/*
2 * Copyright (C) 1999-2000 Harri Porten ([email protected])
3 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
4 * Copyright (C) 2015 Yusuke Suzuki <[email protected]>.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 */
21
22#pragma once
23
24#include "JSWrapperObject.h"
25#include "Symbol.h"
26
27namespace JSC {
28
29class SymbolObject final : public JSWrapperObject {
30public:
31 using Base = JSWrapperObject;
32
33 static SymbolObject* create(VM& vm, Structure* structure)
34 {
35 Symbol* symbol = Symbol::create(vm);
36 SymbolObject* object = new (NotNull, allocateCell<SymbolObject>(vm.heap)) SymbolObject(vm, structure);
37 object->finishCreation(vm, symbol);
38 return object;
39 }
40 static SymbolObject* create(VM& vm, Structure* structure, Symbol* symbol)
41 {
42 SymbolObject* object = new (NotNull, allocateCell<SymbolObject>(vm.heap)) SymbolObject(vm, structure);
43 object->finishCreation(vm, symbol);
44 return object;
45 }
46 static SymbolObject* create(VM&, JSGlobalObject*, Symbol*);
47
48 DECLARE_EXPORT_INFO;
49
50 Symbol* internalValue() const { return asSymbol(JSWrapperObject::internalValue()); }
51
52 static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
53 {
54 return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
55 }
56
57 static JSValue defaultValue(const JSObject*, ExecState*, PreferredPrimitiveType);
58
59 static String toStringName(const JSObject*, ExecState*);
60
61protected:
62 JS_EXPORT_PRIVATE void finishCreation(VM&, Symbol*);
63 JS_EXPORT_PRIVATE SymbolObject(VM&, Structure*);
64};
65
66} // namespace JSC
67