Commit f5d4253
src: refactor
- Instead of storing a pointer whose type refers to the specific
subclass of `BaseObject`, just store a `BaseObject*` directly.
This means in particular that one can cast to classes along
the way of the inheritance chain without issues, and that
`BaseObject*` no longer needs to be the first superclass
in the case of multiple inheritance.
In particular, this renders hack-y solutions to this problem (like
ddc19be) obsolete and addresses
a `TODO` comment of mine.
- Move wrapping/unwrapping methods to the `BaseObject` class.
We use these almost exclusively for `BaseObject`s, and I hope
that this gives a better idea of how (and for what) these are used
in our code.
- Perform initialization/deinitialization of the internal field
in the `BaseObject*` constructor/destructor. This makes the code
a bit more obviously correct, avoids explicit calls for this
in subclass constructors, and in particular allows us to avoid
crash situations when we previously called `ClearWrap()`
during GC.
This also means that we enforce that the object passed to the
`BaseObject` constructor needs to have an internal field.
This is the only reason for the test change.
- Change the signature of `MakeWeak()` to not require a pointer
argument. Previously, this would always have been the same
as `this`, and no other value made sense. Also, the parameter
was something that I personally found somewhat confusing
when becoming familiar with Node’s code.
- Add a `TODO` comment that motivates switching to real inheritance
for the JS types we expose from the native side. This patch
brings us a lot closer to being able to do that.
- Some less significant drive-by cleanup.
Since we *effectively* already store the `BaseObject*` pointer
anyway since ddc19be, I do not
think that this is going to have any impact on diagnostic tooling.
Fixes: #18897
PR-URL: #20455
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>BaseObject internal field management1 parent c21a52f commit f5d4253Copy full SHA for f5d4253
File tree
Expand file treeCollapse file tree
40 files changed
+147
-244
lines changedOpen diff view settings
Filter options
- src
- test/cctest
Expand file treeCollapse file tree
40 files changed
+147
-244
lines changedOpen diff view settings
Collapse file
+3-3Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
123 | 123 | |
124 | 124 | |
125 | 125 | |
126 | | - |
127 | | - |
| 126 | + |
| 127 | + |
128 | 128 | |
129 | 129 | |
130 | 130 | |
| ||
231 | 231 | |
232 | 232 | |
233 | 233 | |
234 | | - |
| 234 | + |
235 | 235 | |
236 | 236 | |
237 | 237 | |
|
Collapse file
+57-21Lines changed: 57 additions & 21 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
31 | 31 | |
32 | 32 | |
33 | 33 | |
34 | | - |
| 34 | + |
35 | 35 | |
36 | 36 | |
37 | 37 | |
38 | | - |
39 | | - |
40 | | - |
41 | | - |
| 38 | + |
| 39 | + |
42 | 40 | |
43 | 41 | |
44 | 42 | |
45 | | - |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
46 | 57 | |
47 | 58 | |
48 | 59 | |
49 | 60 | |
50 | | - |
| 61 | + |
51 | 62 | |
52 | 63 | |
53 | 64 | |
54 | 65 | |
55 | | - |
| 66 | + |
56 | 67 | |
57 | 68 | |
58 | 69 | |
59 | 70 | |
60 | | - |
61 | | - |
62 | | - |
63 | | - |
| 71 | + |
| 72 | + |
| 73 | + |
64 | 74 | |
65 | 75 | |
66 | 76 | |
67 | | - |
68 | | - |
69 | | - |
70 | | - |
71 | | - |
72 | | - |
73 | | - |
74 | | - |
| 77 | + |
| 78 | + |
| 79 | + |
75 | 80 | |
76 | 81 | |
77 | 82 | |
78 | | - |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | + |
79 | 99 | |
80 | 100 | |
81 | 101 | |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | + |
82 | 118 | |
83 | 119 | |
84 | 120 | |
|
Collapse file
+38-12Lines changed: 38 additions & 12 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
26 | 26 | |
27 | 27 | |
28 | 28 | |
| 29 | + |
29 | 30 | |
30 | 31 | |
31 | 32 | |
32 | 33 | |
33 | 34 | |
34 | 35 | |
35 | 36 | |
| 37 | + |
| 38 | + |
36 | 39 | |
37 | | - |
| 40 | + |
38 | 41 | |
39 | 42 | |
40 | 43 | |
| ||
44 | 47 | |
45 | 48 | |
46 | 49 | |
47 | | - |
48 | | - |
49 | | - |
50 | | - |
51 | | - |
52 | | - |
53 | | - |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
54 | 57 | |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
55 | 63 | |
56 | 64 | |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + |
57 | 71 | |
58 | 72 | |
59 | 73 | |
60 | | - |
61 | | - |
62 | | - |
63 | | - |
64 | 74 | |
65 | 75 | |
66 | 76 | |
| ||
71 | 81 | |
72 | 82 | |
73 | 83 | |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | + |
74 | 100 | |
75 | 101 | |
76 | 102 | |
|
Collapse file
+4-27Lines changed: 4 additions & 27 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
187 | 187 | |
188 | 188 | |
189 | 189 | |
190 | | - |
| 190 | + |
191 | 191 | |
192 | 192 | |
193 | 193 | |
| ||
205 | 205 | |
206 | 206 | |
207 | 207 | |
208 | | - |
209 | 208 | |
210 | 209 | |
211 | 210 | |
| ||
219 | 218 | |
220 | 219 | |
221 | 220 | |
222 | | - |
223 | | - |
224 | | - |
225 | | - |
226 | | - |
227 | 221 | |
228 | 222 | |
229 | 223 | |
230 | 224 | |
231 | 225 | |
232 | 226 | |
233 | | - |
234 | 227 | |
235 | 228 | |
236 | 229 | |
237 | 230 | |
238 | 231 | |
239 | 232 | |
240 | 233 | |
241 | | - |
242 | | - |
243 | | - |
244 | | - |
245 | | - |
246 | 234 | |
247 | 235 | |
248 | 236 | |
| ||
587 | 575 | |
588 | 576 | |
589 | 577 | |
590 | | - |
591 | | - |
592 | 578 | |
593 | 579 | |
594 | 580 | |
| ||
597 | 583 | |
598 | 584 | |
599 | 585 | |
600 | | - |
601 | 586 | |
602 | 587 | |
603 | 588 | |
| ||
2143 | 2128 | |
2144 | 2129 | |
2145 | 2130 | |
2146 | | - |
2147 | | - |
2148 | | - |
2149 | | - |
2150 | | - |
2151 | 2131 | |
2152 | | - |
2153 | | - |
| 2132 | + |
2154 | 2133 | |
2155 | 2134 | |
2156 | 2135 | |
2157 | 2136 | |
2158 | 2137 | |
2159 | 2138 | |
2160 | 2139 | |
2161 | | - |
2162 | | - |
| 2140 | + |
2163 | 2141 | |
2164 | 2142 | |
2165 | 2143 | |
2166 | 2144 | |
2167 | 2145 | |
2168 | 2146 | |
2169 | 2147 | |
2170 | | - |
2171 | | - |
| 2148 | + |
2172 | 2149 | |
2173 | 2150 | |
2174 | 2151 | |
|
Collapse file
-6Lines changed: 0 additions & 6 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
13 | 13 | |
14 | 14 | |
15 | 15 | |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | | - |
21 | | - |
22 | 16 | |
23 | 17 | |
24 | 18 | |
Collapse file
-1Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
15 | 15 | |
16 | 16 | |
17 | 17 | |
18 | | - |
19 | 18 | |
20 | 19 | |
21 | 20 | |
|
Collapse file
-1Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
29 | 29 | |
30 | 30 | |
31 | 31 | |
32 | | - |
33 | 32 | |
34 | 33 | |
35 | 34 | |
|
Collapse file
+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
131 | 131 | |
132 | 132 | |
133 | 133 | |
134 | | - |
| 134 | + |
135 | 135 | |
136 | 136 | |
137 | 137 | |
|
Collapse file
-2Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
93 | 93 | |
94 | 94 | |
95 | 95 | |
96 | | - |
97 | 96 | |
98 | 97 | |
99 | 98 | |
| ||
114 | 113 | |
115 | 114 | |
116 | 115 | |
117 | | - |
118 | 116 | |
119 | 117 | |
120 | 118 | |
|
Collapse file
-4Lines changed: 0 additions & 4 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
64 | 64 | |
65 | 65 | |
66 | 66 | |
67 | | - |
68 | 67 | |
69 | 68 | |
70 | 69 | |
| ||
83 | 82 | |
84 | 83 | |
85 | 84 | |
86 | | - |
87 | | - |
88 | | - |
89 | 85 | |
90 | 86 | |
91 | 87 | |
|
0 commit comments