2
2
#include " memory_tracker.h"
3
3
#include " node.h"
4
4
#include " node_builtins.h"
5
+ #include " node_external_reference.h"
5
6
#include " node_i18n.h"
6
7
#include " node_options.h"
7
8
#include " util-inl.h"
8
9
9
10
namespace node {
10
11
11
12
using v8::Context;
13
+ using v8::FunctionCallbackInfo;
12
14
using v8::Isolate;
13
15
using v8::Local;
14
16
using v8::Number;
15
17
using v8::Object;
18
+ using v8::String;
16
19
using v8::Value;
17
20
21
+ void GetDefaultLocale (const FunctionCallbackInfo<Value>& args) {
22
+ Isolate* isolate = args.GetIsolate ();
23
+ Local<Context> context = isolate->GetCurrentContext ();
24
+ std::string locale = isolate->GetDefaultLocale ();
25
+ Local<Value> result;
26
+ if (ToV8Value (context, locale).ToLocal (&result)) {
27
+ args.GetReturnValue ().Set (result);
28
+ }
29
+ }
30
+
18
31
// The config binding is used to provide an internal view of compile time
19
32
// config options that are required internally by lib/*.js code. This is an
20
33
// alternative to dropping additional properties onto the process object as
@@ -23,7 +36,7 @@ using v8::Value;
23
36
// Command line arguments are already accessible in the JS land via
24
37
// require('internal/options').getOptionValue('--some-option'). Do not add them
25
38
// here.
26
- static void Initialize (Local<Object> target,
39
+ static void InitConfig (Local<Object> target,
27
40
Local<Value> unused,
28
41
Local<Context> context,
29
42
void * priv) {
@@ -76,8 +89,15 @@ static void Initialize(Local<Object> target,
76
89
#endif // NODE_NO_BROWSER_GLOBALS
77
90
78
91
READONLY_PROPERTY (target, " bits" , Number::New (isolate, 8 * sizeof (intptr_t )));
92
+
93
+ SetMethodNoSideEffect (context, target, " getDefaultLocale" , GetDefaultLocale);
79
94
} // InitConfig
80
95
96
+ void RegisterConfigExternalReferences (ExternalReferenceRegistry* registry) {
97
+ registry->Register (GetDefaultLocale);
98
+ }
99
+
81
100
} // namespace node
82
101
83
- NODE_BINDING_CONTEXT_AWARE_INTERNAL (config, node::Initialize)
102
+ NODE_BINDING_CONTEXT_AWARE_INTERNAL (config, node::InitConfig)
103
+ NODE_BINDING_EXTERNAL_REFERENCE(config, node::RegisterConfigExternalReferences)
0 commit comments