@@ -44,14 +44,24 @@ namespace node {
4444#define NODE_PUSH_VAL_TO_ARRAY_MAX 8
4545#endif
4646
47+ // Private symbols are per-isolate primitives but Environment proxies them
48+ // for the sake of convenience. Strings should be ASCII-only and have a
49+ // "node:" prefix to avoid name clashes with third-party code.
50+ #define PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES (V ) \
51+ V (alpn_buffer_private_symbol, " node:alpnBuffer" ) \
52+ V (arrow_message_private_symbol, " node:arrowMessage" ) \
53+ V (contextify_private_symbol, " node:contextify" ) \
54+ V (decorated_private_symbol, " node:decorated" ) \
55+ V (npn_buffer_private_symbol, " node:npnBuffer" ) \
56+ V (processed_private_symbol, " node:processed" ) \
57+ V (selected_npn_buffer_private_symbol, " node:selectedNpnBuffer" ) \
58+
4759// Strings are per-isolate primitives but Environment proxies them
4860// for the sake of convenience. Strings should be ASCII-only.
4961#define PER_ISOLATE_STRING_PROPERTIES (V ) \
5062 V (address_string, " address" ) \
51- V (alpn_buffer_string, " alpnBuffer" ) \
5263 V (args_string, " args" ) \
5364 V (argv_string, " argv" ) \
54- V (arrow_message_string, " node:arrowMessage" ) \
5565 V (async, " async" ) \
5666 V (async_queue_string, " _asyncQueue" ) \
5767 V (atime_string, " atime" ) \
@@ -73,7 +83,6 @@ namespace node {
7383 V (cwd_string, " cwd" ) \
7484 V (debug_port_string, " debugPort" ) \
7585 V (debug_string, " debug" ) \
76- V (decorated_string, " node:decorated" ) \
7786 V (dest_string, " dest" ) \
7887 V (detached_string, " detached" ) \
7988 V (dev_string, " dev" ) \
@@ -140,7 +149,6 @@ namespace node {
140149 V (netmask_string, " netmask" ) \
141150 V (nice_string, " nice" ) \
142151 V (nlink_string, " nlink" ) \
143- V (npn_buffer_string, " npnBuffer" ) \
144152 V (nsname_string, " nsname" ) \
145153 V (ocsp_request_string, " OCSPRequest" ) \
146154 V (offset_string, " offset" ) \
@@ -176,7 +184,6 @@ namespace node {
176184 V (port_string, " port" ) \
177185 V (preference_string, " preference" ) \
178186 V (priority_string, " priority" ) \
179- V (processed_string, " processed" ) \
180187 V (produce_cached_data_string, " produceCachedData" ) \
181188 V (prototype_string, " prototype" ) \
182189 V (raw_string, " raw" ) \
@@ -192,7 +199,6 @@ namespace node {
192199 V (serial_string, " serial" ) \
193200 V (scavenge_string, " scavenge" ) \
194201 V (scopeid_string, " scopeid" ) \
195- V (selected_npn_buffer_string, " selectedNpnBuffer" ) \
196202 V (sent_shutdown_string, " sentShutdown" ) \
197203 V (serial_number_string, " serialNumber" ) \
198204 V (service_string, " service" ) \
@@ -507,12 +513,17 @@ class Environment {
507513
508514 inline v8::Local<v8::Object> NewInternalFieldObject ();
509515
510- // Strings are shared across shared contexts. The getters simply proxy to
511- // the per-isolate primitive.
512- #define V (PropertyName, StringValue ) \
513- inline v8::Local<v8::String> PropertyName () const ;
514- PER_ISOLATE_STRING_PROPERTIES (V)
516+ // Strings and private symbols are shared across shared contexts
517+ // The getters simply proxy to the per-isolate primitive.
518+ #define VP (PropertyName, StringValue ) V(v8::Private, PropertyName, StringValue)
519+ #define VS (PropertyName, StringValue ) V(v8::String, PropertyName, StringValue)
520+ #define V (TypeName, PropertyName, StringValue ) \
521+ inline v8::Local<TypeName> PropertyName () const ;
522+ PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES (VP)
523+ PER_ISOLATE_STRING_PROPERTIES(VS)
515524#undef V
525+ #undef VS
526+ #undef VP
516527
517528#define V (PropertyName, TypeName ) \
518529 inline v8::Local<TypeName> PropertyName () const ; \
@@ -585,10 +596,15 @@ class Environment {
585596 inline void Put ();
586597 inline uv_loop_t * event_loop () const ;
587598
588- #define V (PropertyName, StringValue ) \
589- inline v8::Local<v8::String> PropertyName () const ;
590- PER_ISOLATE_STRING_PROPERTIES (V)
599+ #define VP (PropertyName, StringValue ) V(v8::Private, PropertyName, StringValue)
600+ #define VS (PropertyName, StringValue ) V(v8::String, PropertyName, StringValue)
601+ #define V (TypeName, PropertyName, StringValue ) \
602+ inline v8::Local<TypeName> PropertyName () const ;
603+ PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES (VP)
604+ PER_ISOLATE_STRING_PROPERTIES (VS)
591605#undef V
606+ #undef VS
607+ #undef VP
592608
593609 private:
594610 inline static IsolateData* Get (v8::Isolate* isolate);
@@ -598,10 +614,15 @@ class Environment {
598614 uv_loop_t * const event_loop_;
599615 v8::Isolate* const isolate_;
600616
601- #define V (PropertyName, StringValue ) \
602- v8::Eternal<v8::String> PropertyName ## _;
603- PER_ISOLATE_STRING_PROPERTIES (V)
617+ #define VP (PropertyName, StringValue ) V(v8::Private, PropertyName, StringValue)
618+ #define VS (PropertyName, StringValue ) V(v8::String, PropertyName, StringValue)
619+ #define V (TypeName, PropertyName, StringValue ) \
620+ v8::Eternal<TypeName> PropertyName ## _;
621+ PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES (VP)
622+ PER_ISOLATE_STRING_PROPERTIES (VS)
604623#undef V
624+ #undef VS
625+ #undef VP
605626
606627 unsigned int ref_count_;
607628
0 commit comments