Skip to content

Commit 35c9aa7

Browse files
committed
LibJS: Hide all the constructors!
Now that the GC allocator is able to invoke Cell subclass constructors directly via friendship, we no longer need to keep them public. :^)
1 parent d54ba58 commit 35c9aa7

File tree

196 files changed

+455
-241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+455
-241
lines changed

Userland/Libraries/LibJS/Contrib/Test262/$262Object.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ class $262Object final : public Object {
1717
JS_OBJECT($262Object, Object);
1818

1919
public:
20-
explicit $262Object(Realm&);
2120
virtual void initialize(JS::Realm&) override;
2221
virtual ~$262Object() override = default;
2322

2423
private:
24+
explicit $262Object(Realm&);
25+
2526
virtual void visit_edges(Visitor&) override;
2627

2728
AgentObject* m_agent { nullptr };

Userland/Libraries/LibJS/Contrib/Test262/AgentObject.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ class AgentObject final : public Object {
1515
JS_OBJECT(AgentObject, Object);
1616

1717
public:
18-
explicit AgentObject(Realm&);
1918
virtual void initialize(JS::Realm&) override;
2019
virtual ~AgentObject() override = default;
2120

2221
private:
22+
explicit AgentObject(Realm&);
23+
2324
JS_DECLARE_NATIVE_FUNCTION(monotonic_now);
2425
JS_DECLARE_NATIVE_FUNCTION(sleep);
2526
};

Userland/Libraries/LibJS/Contrib/Test262/GlobalObject.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ class GlobalObject final : public JS::GlobalObject {
1515
JS_OBJECT(GlobalObject, JS::GlobalObject);
1616

1717
public:
18-
GlobalObject(JS::Realm& realm)
19-
: JS::GlobalObject(realm)
20-
{
21-
}
2218
virtual void initialize(Realm&) override;
2319
virtual ~GlobalObject() override = default;
2420

2521
$262Object* $262() const { return m_$262; }
2622

2723
private:
24+
GlobalObject(JS::Realm& realm)
25+
: JS::GlobalObject(realm)
26+
{
27+
}
28+
2829
virtual void visit_edges(Visitor&) override;
2930

3031
$262Object* m_$262 { nullptr };

Userland/Libraries/LibJS/Contrib/Test262/IsHTMLDDA.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ class IsHTMLDDA final : public NativeFunction {
1414
JS_OBJECT(IsHTMLDDA, NativeFunction);
1515

1616
public:
17-
explicit IsHTMLDDA(Realm&);
1817
virtual ~IsHTMLDDA() override = default;
1918

2019
virtual ThrowCompletionOr<Value> call() override;
2120

2221
private:
22+
explicit IsHTMLDDA(Realm&);
23+
2324
virtual bool is_htmldda() const override { return true; }
2425
};
2526

Userland/Libraries/LibJS/Runtime/Accessor.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ class Accessor final : public Cell {
2222
return vm.heap().allocate_without_realm<Accessor>(getter, setter);
2323
}
2424

25-
Accessor(FunctionObject* getter, FunctionObject* setter)
26-
: m_getter(getter)
27-
, m_setter(setter)
28-
{
29-
}
30-
3125
FunctionObject* getter() const { return m_getter; }
3226
void set_getter(FunctionObject* getter) { m_getter = getter; }
3327

@@ -41,6 +35,12 @@ class Accessor final : public Cell {
4135
}
4236

4337
private:
38+
Accessor(FunctionObject* getter, FunctionObject* setter)
39+
: m_getter(getter)
40+
, m_setter(setter)
41+
{
42+
}
43+
4444
FunctionObject* m_getter { nullptr };
4545
FunctionObject* m_setter { nullptr };
4646
};

Userland/Libraries/LibJS/Runtime/AggregateError.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ class AggregateError : public Error {
1616

1717
public:
1818
static AggregateError* create(Realm&);
19+
virtual ~AggregateError() override = default;
1920

21+
private:
2022
explicit AggregateError(Object& prototype);
21-
virtual ~AggregateError() override = default;
2223
};
2324

2425
}

Userland/Libraries/LibJS/Runtime/AggregateErrorConstructor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ class AggregateErrorConstructor final : public NativeFunction {
1414
JS_OBJECT(AggregateErrorConstructor, NativeFunction);
1515

1616
public:
17-
explicit AggregateErrorConstructor(Realm&);
1817
virtual void initialize(Realm&) override;
1918
virtual ~AggregateErrorConstructor() override = default;
2019

2120
virtual ThrowCompletionOr<Value> call() override;
2221
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
2322

2423
private:
24+
explicit AggregateErrorConstructor(Realm&);
2525
virtual bool has_constructor() const override { return true; }
2626
};
2727

Userland/Libraries/LibJS/Runtime/AggregateErrorPrototype.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ class AggregateErrorPrototype final : public Object {
1414
JS_OBJECT(AggregateErrorPrototype, Object);
1515

1616
public:
17-
explicit AggregateErrorPrototype(Realm&);
1817
virtual void initialize(Realm&) override;
1918
virtual ~AggregateErrorPrototype() override = default;
19+
20+
private:
21+
explicit AggregateErrorPrototype(Realm&);
2022
};
2123

2224
}

Userland/Libraries/LibJS/Runtime/ArgumentsObject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ class ArgumentsObject final : public Object {
1616
JS_OBJECT(ArgumentsObject, Object);
1717

1818
public:
19-
ArgumentsObject(Realm&, Environment&);
20-
2119
virtual void initialize(Realm&) override;
2220
virtual ~ArgumentsObject() override = default;
2321

@@ -33,6 +31,8 @@ class ArgumentsObject final : public Object {
3331
Object& parameter_map() { return *m_parameter_map; }
3432

3533
private:
34+
ArgumentsObject(Realm&, Environment&);
35+
3636
virtual void visit_edges(Cell::Visitor&) override;
3737

3838
Environment& m_environment;

Userland/Libraries/LibJS/Runtime/Array.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class Array : public Object {
4444

4545
[[nodiscard]] bool length_is_writable() const { return m_length_writable; };
4646

47+
protected:
48+
explicit Array(Object& prototype);
49+
4750
private:
4851
ThrowCompletionOr<bool> set_length(PropertyDescriptor const&);
4952

0 commit comments

Comments
 (0)