@@ -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 ();
@@ -379,8 +340,6 @@ static void ToUSVString(const FunctionCallbackInfo<Value>& args) {
379340}
380341
381342void RegisterExternalReferences (ExternalReferenceRegistry* registry) {
382- registry->Register (GetHiddenValue);
383- registry->Register (SetHiddenValue);
384343 registry->Register (GetPromiseDetails);
385344 registry->Register (GetProxyDetails);
386345 registry->Register (PreviewEntries);
@@ -404,16 +363,22 @@ void Initialize(Local<Object> target,
404363 Environment* env = Environment::GetCurrent (context);
405364 Isolate* isolate = env->isolate ();
406365
407- #define V (name, _ ) \
408- target->Set (context, \
409- FIXED_ONE_BYTE_STRING (env->isolate (), #name), \
410- Integer::NewFromUnsigned (env->isolate (), index++)).Check ();
411366 {
412- uint32_t index = 0 ;
367+ Local<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New (isolate);
368+ #define V (PropertyName, _ ) \
369+ tmpl->Set (FIXED_ONE_BYTE_STRING (env->isolate (), #PropertyName), \
370+ env->PropertyName ());
371+
413372 PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES (V)
414- }
415373#undef V
416374
375+ target
376+ ->Set (context,
377+ FIXED_ONE_BYTE_STRING (isolate, " privateSymbols" ),
378+ tmpl->NewInstance (context).ToLocalChecked ())
379+ .Check ();
380+ }
381+
417382#define V (name ) \
418383 target->Set (context, \
419384 FIXED_ONE_BYTE_STRING (env->isolate (), #name), \
@@ -435,8 +400,6 @@ void Initialize(Local<Object> target,
435400 V (kHasExitCode );
436401#undef V
437402
438- SetMethodNoSideEffect (context, target, " getHiddenValue" , GetHiddenValue);
439- SetMethod (context, target, " setHiddenValue" , SetHiddenValue);
440403 SetMethodNoSideEffect (
441404 context, target, " getPromiseDetails" , GetPromiseDetails);
442405 SetMethodNoSideEffect (context, target, " getProxyDetails" , GetProxyDetails);
0 commit comments