@@ -159,44 +159,6 @@ static void PreviewEntries(const FunctionCallbackInfo<Value>& args) {
159159 Array::New (env->isolate (), ret, arraysize (ret)));
160160}
161161
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-
200162static void Sleep (const FunctionCallbackInfo<Value>& args) {
201163 CHECK (args[0 ]->IsUint32 ());
202164 uint32_t msec = args[0 ].As <Uint32>()->Value ();
@@ -379,8 +341,6 @@ static void ToUSVString(const FunctionCallbackInfo<Value>& args) {
379341}
380342
381343void RegisterExternalReferences (ExternalReferenceRegistry* registry) {
382- registry->Register (GetHiddenValue);
383- registry->Register (SetHiddenValue);
384344 registry->Register (GetPromiseDetails);
385345 registry->Register (GetProxyDetails);
386346 registry->Register (PreviewEntries);
@@ -404,16 +364,22 @@ void Initialize(Local<Object> target,
404364 Environment* env = Environment::GetCurrent (context);
405365 Isolate* isolate = env->isolate ();
406366
407- #define V (name, _ ) \
408- target->Set (context, \
409- FIXED_ONE_BYTE_STRING (env->isolate (), #name), \
410- Integer::NewFromUnsigned (env->isolate (), index++)).Check ();
411367 {
412- uint32_t index = 0 ;
368+ Local<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New (isolate);
369+ #define V (PropertyName, _ ) \
370+ tmpl->Set (FIXED_ONE_BYTE_STRING (env->isolate (), #PropertyName), \
371+ env->PropertyName ());
372+
413373 PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES (V)
414- }
415374#undef V
416375
376+ target
377+ ->Set (context,
378+ FIXED_ONE_BYTE_STRING (isolate, " privateSymbols" ),
379+ tmpl->NewInstance (context).ToLocalChecked ())
380+ .Check ();
381+ }
382+
417383#define V (name ) \
418384 target->Set (context, \
419385 FIXED_ONE_BYTE_STRING (env->isolate (), #name), \
@@ -435,8 +401,6 @@ void Initialize(Local<Object> target,
435401 V (kHasExitCode );
436402#undef V
437403
438- SetMethodNoSideEffect (context, target, " getHiddenValue" , GetHiddenValue);
439- SetMethod (context, target, " setHiddenValue" , SetHiddenValue);
440404 SetMethodNoSideEffect (
441405 context, target, " getPromiseDetails" , GetPromiseDetails);
442406 SetMethodNoSideEffect (context, target, " getProxyDetails" , GetProxyDetails);
0 commit comments