@@ -26,7 +26,6 @@ using v8::Object;
26
26
using v8::ONLY_CONFIGURABLE;
27
27
using v8::ONLY_ENUMERABLE;
28
28
using v8::ONLY_WRITABLE;
29
- using v8::Private;
30
29
using v8::Promise;
31
30
using v8::PropertyFilter;
32
31
using v8::Proxy;
@@ -159,44 +158,6 @@ static void PreviewEntries(const FunctionCallbackInfo<Value>& args) {
159
158
Array::New (env->isolate (), ret, arraysize (ret)));
160
159
}
161
160
162
- inline Local<Private> IndexToPrivateSymbol (Environment* env, uint32_t index) {
163
- #define V (name, _ ) &Environment::name,
164
- static Local<Private> (Environment::*const methods[])() const = {
165
- PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES (V)
166
- };
167
- #undef V
168
- CHECK_LT (index , arraysize (methods));
169
- return (env->*methods[index ])();
170
- }
171
-
172
- static void GetHiddenValue (const FunctionCallbackInfo<Value>& args) {
173
- Environment* env = Environment::GetCurrent (args);
174
-
175
- CHECK (args[0 ]->IsObject ());
176
- CHECK (args[1 ]->IsUint32 ());
177
-
178
- Local<Object> obj = args[0 ].As <Object>();
179
- uint32_t index = args[1 ].As <Uint32>()->Value ();
180
- Local<Private> private_symbol = IndexToPrivateSymbol (env, index );
181
- Local<Value> ret;
182
- if (obj->GetPrivate (env->context (), private_symbol).ToLocal (&ret))
183
- args.GetReturnValue ().Set (ret);
184
- }
185
-
186
- static void SetHiddenValue (const FunctionCallbackInfo<Value>& args) {
187
- Environment* env = Environment::GetCurrent (args);
188
-
189
- CHECK (args[0 ]->IsObject ());
190
- CHECK (args[1 ]->IsUint32 ());
191
-
192
- Local<Object> obj = args[0 ].As <Object>();
193
- uint32_t index = args[1 ].As <Uint32>()->Value ();
194
- Local<Private> private_symbol = IndexToPrivateSymbol (env, index );
195
- bool ret;
196
- if (obj->SetPrivate (env->context (), private_symbol, args[2 ]).To (&ret))
197
- args.GetReturnValue ().Set (ret);
198
- }
199
-
200
161
static void Sleep (const FunctionCallbackInfo<Value>& args) {
201
162
CHECK (args[0 ]->IsUint32 ());
202
163
uint32_t msec = args[0 ].As <Uint32>()->Value ();
@@ -386,8 +347,6 @@ static void ToUSVString(const FunctionCallbackInfo<Value>& args) {
386
347
}
387
348
388
349
void RegisterExternalReferences (ExternalReferenceRegistry* registry) {
389
- registry->Register (GetHiddenValue);
390
- registry->Register (SetHiddenValue);
391
350
registry->Register (GetPromiseDetails);
392
351
registry->Register (GetProxyDetails);
393
352
registry->Register (PreviewEntries);
@@ -412,16 +371,22 @@ void Initialize(Local<Object> target,
412
371
Environment* env = Environment::GetCurrent (context);
413
372
Isolate* isolate = env->isolate ();
414
373
415
- #define V (name, _ ) \
416
- target->Set (context, \
417
- FIXED_ONE_BYTE_STRING (env->isolate (), #name), \
418
- Integer::NewFromUnsigned (env->isolate (), index ++)).Check ();
419
374
{
420
- uint32_t index = 0 ;
375
+ Local<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New (isolate);
376
+ #define V (PropertyName, _ ) \
377
+ tmpl->Set (FIXED_ONE_BYTE_STRING (env->isolate (), #PropertyName), \
378
+ env->PropertyName ());
379
+
421
380
PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES (V)
422
- }
423
381
#undef V
424
382
383
+ target
384
+ ->Set (context,
385
+ FIXED_ONE_BYTE_STRING (isolate, " privateSymbols" ),
386
+ tmpl->NewInstance (context).ToLocalChecked ())
387
+ .Check ();
388
+ }
389
+
425
390
#define V (name ) \
426
391
target->Set (context, \
427
392
FIXED_ONE_BYTE_STRING (env->isolate (), #name), \
@@ -432,8 +397,6 @@ void Initialize(Local<Object> target,
432
397
V (kRejected );
433
398
#undef V
434
399
435
- SetMethodNoSideEffect (context, target, " getHiddenValue" , GetHiddenValue);
436
- SetMethod (context, target, " setHiddenValue" , SetHiddenValue);
437
400
SetMethodNoSideEffect (
438
401
context, target, " getPromiseDetails" , GetPromiseDetails);
439
402
SetMethodNoSideEffect (context, target, " getProxyDetails" , GetProxyDetails);
0 commit comments