@@ -11,6 +11,7 @@ namespace node {
11
11
using v8::Boolean ;
12
12
using v8::Context;
13
13
using v8::Integer;
14
+ using v8::Isolate;
14
15
using v8::Local;
15
16
using v8::Number;
16
17
using v8::Object;
@@ -25,24 +26,24 @@ using v8::Value;
25
26
26
27
#define READONLY_BOOLEAN_PROPERTY (str ) \
27
28
do { \
28
- target->DefineOwnProperty (env-> context (), \
29
- OneByteString (env-> isolate () , str), \
30
- True (env-> isolate ()) , ReadOnly).FromJust (); \
29
+ target->DefineOwnProperty (context, \
30
+ FIXED_ONE_BYTE_STRING ( isolate, str), \
31
+ True (isolate) , ReadOnly).FromJust (); \
31
32
} while (0 )
32
33
33
34
#define READONLY_PROPERTY (obj, name, value ) \
34
35
do { \
35
36
obj->DefineOwnProperty (env->context (), \
36
- OneByteString (env->isolate (), name), \
37
- value, \
38
- ReadOnly).FromJust (); \
37
+ FIXED_ONE_BYTE_STRING (isolate, name), \
38
+ value, ReadOnly).FromJust (); \
39
39
} while (0 )
40
40
41
-
42
41
static void InitConfig (Local<Object> target,
43
42
Local<Value> unused,
44
43
Local<Context> context) {
45
44
Environment* env = Environment::GetCurrent (context);
45
+ Isolate* isolate = env->isolate ();
46
+
46
47
#ifdef NODE_HAVE_I18N_SUPPORT
47
48
48
49
READONLY_BOOLEAN_PROPERTY (" hasIntl" );
@@ -51,10 +52,13 @@ static void InitConfig(Local<Object> target,
51
52
READONLY_BOOLEAN_PROPERTY (" hasSmallICU" );
52
53
#endif // NODE_HAVE_SMALL_ICU
53
54
54
- target->DefineOwnProperty (env->context (),
55
- OneByteString (env->isolate (), " icuDataDir" ),
56
- OneByteString (env->isolate (), icu_data_dir.data ()))
57
- .FromJust ();
55
+ target->DefineOwnProperty (
56
+ context,
57
+ FIXED_ONE_BYTE_STRING (isolate, " icuDataDir" ),
58
+ String::NewFromUtf8 (isolate,
59
+ icu_data_dir.data (),
60
+ v8::NewStringType::kNormal ).ToLocalChecked (),
61
+ ReadOnly).FromJust ();
58
62
59
63
#endif // NODE_HAVE_I18N_SUPPORT
60
64
@@ -64,37 +68,6 @@ static void InitConfig(Local<Object> target,
64
68
if (config_pending_deprecation)
65
69
READONLY_BOOLEAN_PROPERTY (" pendingDeprecation" );
66
70
67
- if (!config_warning_file.empty ()) {
68
- Local<String> name = OneByteString (env->isolate (), " warningFile" );
69
- Local<String> value = String::NewFromUtf8 (env->isolate (),
70
- config_warning_file.data (),
71
- v8::NewStringType::kNormal ,
72
- config_warning_file.size ())
73
- .ToLocalChecked ();
74
- target->DefineOwnProperty (env->context (), name, value).FromJust ();
75
- }
76
-
77
- Local<Object> debugOptions = Object::New (env->isolate ());
78
-
79
- target->DefineOwnProperty (env->context (),
80
- OneByteString (env->isolate (), " debugOptions" ),
81
- debugOptions).FromJust ();
82
-
83
- debugOptions->DefineOwnProperty (env->context (),
84
- OneByteString (env->isolate (), " host" ),
85
- String::NewFromUtf8 (env->isolate (),
86
- debug_options.host_name ().c_str ())).FromJust ();
87
-
88
- debugOptions->DefineOwnProperty (env->context (),
89
- OneByteString (env->isolate (), " port" ),
90
- Integer::New (env->isolate (),
91
- debug_options.port ())).FromJust ();
92
-
93
- debugOptions->DefineOwnProperty (env->context (),
94
- OneByteString (env->isolate (), " inspectorEnabled" ),
95
- Boolean::New (env->isolate (),
96
- debug_options.inspector_enabled ())).FromJust ();
97
-
98
71
if (config_expose_internals)
99
72
READONLY_BOOLEAN_PROPERTY (" exposeInternals" );
100
73
@@ -104,6 +77,43 @@ static void InitConfig(Local<Object> target,
104
77
READONLY_PROPERTY (target,
105
78
" bits" ,
106
79
Number::New (env->isolate (), 8 * sizeof (intptr_t )));
80
+
81
+ if (!config_warning_file.empty ()) {
82
+ target->DefineOwnProperty (
83
+ context,
84
+ FIXED_ONE_BYTE_STRING (isolate, " warningFile" ),
85
+ String::NewFromUtf8 (isolate,
86
+ config_warning_file.data (),
87
+ v8::NewStringType::kNormal ).ToLocalChecked (),
88
+ ReadOnly).FromJust ();
89
+ }
90
+
91
+ Local<Object> debugOptions = Object::New (isolate);
92
+
93
+ target->DefineOwnProperty (
94
+ context,
95
+ FIXED_ONE_BYTE_STRING (isolate, " debugOptions" ),
96
+ debugOptions, ReadOnly).FromJust ();
97
+
98
+ debugOptions->DefineOwnProperty (
99
+ context,
100
+ FIXED_ONE_BYTE_STRING (isolate, " host" ),
101
+ String::NewFromUtf8 (isolate,
102
+ debug_options.host_name ().c_str (),
103
+ v8::NewStringType::kNormal ).ToLocalChecked (),
104
+ ReadOnly).FromJust ();
105
+
106
+ debugOptions->DefineOwnProperty (
107
+ context,
108
+ FIXED_ONE_BYTE_STRING (isolate, " port" ),
109
+ Integer::New (isolate, debug_options.port ()),
110
+ ReadOnly).FromJust ();
111
+
112
+ debugOptions->DefineOwnProperty (
113
+ context,
114
+ FIXED_ONE_BYTE_STRING (isolate, " inspectorEnabled" ),
115
+ Boolean::New (isolate, debug_options.inspector_enabled ()), ReadOnly)
116
+ .FromJust ();
107
117
} // InitConfig
108
118
109
119
} // namespace node
0 commit comments