@@ -26,7 +26,6 @@ using v8::Object;
2626using v8::ONLY_CONFIGURABLE;
2727using v8::ONLY_ENUMERABLE;
2828using v8::ONLY_WRITABLE;
29- using v8::Private;
3029using v8::Promise;
3130using v8::PropertyFilter;
3231using v8::Proxy;
@@ -159,44 +158,6 @@ static void PreviewEntries(const FunctionCallbackInfo<Value>& args) {
159158 Array::New (env->isolate (), ret, arraysize (ret)));
160159}
161160
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-
200161static void Sleep (const FunctionCallbackInfo<Value>& args) {
201162 CHECK (args[0 ]->IsUint32 ());
202163 uint32_t msec = args[0 ].As <Uint32>()->Value ();
@@ -386,8 +347,6 @@ static void ToUSVString(const FunctionCallbackInfo<Value>& args) {
386347}
387348
388349void RegisterExternalReferences (ExternalReferenceRegistry* registry) {
389- registry->Register (GetHiddenValue);
390- registry->Register (SetHiddenValue);
391350 registry->Register (GetPromiseDetails);
392351 registry->Register (GetProxyDetails);
393352 registry->Register (PreviewEntries);
@@ -412,16 +371,22 @@ void Initialize(Local<Object> target,
412371 Environment* env = Environment::GetCurrent (context);
413372 Isolate* isolate = env->isolate ();
414373
415- #define V (name, _ ) \
416- target->Set (context, \
417- FIXED_ONE_BYTE_STRING (env->isolate (), #name), \
418- Integer::NewFromUnsigned (env->isolate (), index++)).Check ();
419374 {
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+
421380 PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES (V)
422- }
423381#undef V
424382
383+ target
384+ ->Set (context,
385+ FIXED_ONE_BYTE_STRING (isolate, " privateSymbols" ),
386+ tmpl->NewInstance (context).ToLocalChecked ())
387+ .Check ();
388+ }
389+
425390#define V (name ) \
426391 target->Set (context, \
427392 FIXED_ONE_BYTE_STRING (env->isolate (), #name), \
@@ -432,8 +397,6 @@ void Initialize(Local<Object> target,
432397 V (kRejected );
433398#undef V
434399
435- SetMethodNoSideEffect (context, target, " getHiddenValue" , GetHiddenValue);
436- SetMethod (context, target, " setHiddenValue" , SetHiddenValue);
437400 SetMethodNoSideEffect (
438401 context, target, " getPromiseDetails" , GetPromiseDetails);
439402 SetMethodNoSideEffect (context, target, " getProxyDetails" , GetProxyDetails);
0 commit comments