22#include " memory_tracker.h"
33#include " node.h"
44#include " node_builtins.h"
5+ #include " node_external_reference.h"
56#include " node_i18n.h"
67#include " node_options.h"
78#include " util-inl.h"
89
910namespace node {
1011
1112using v8::Context;
13+ using v8::FunctionCallbackInfo;
1214using v8::Isolate;
1315using v8::Local;
1416using v8::Number;
1517using v8::Object;
1618using v8::Value;
1719
20+ void GetDefaultLocale (const FunctionCallbackInfo<Value>& args) {
21+ Isolate* isolate = args.GetIsolate ();
22+ Local<Context> context = isolate->GetCurrentContext ();
23+ std::string locale = isolate->GetDefaultLocale ();
24+ Local<Value> result;
25+ if (ToV8Value (context, locale).ToLocal (&result)) {
26+ args.GetReturnValue ().Set (result);
27+ }
28+ }
29+
1830// The config binding is used to provide an internal view of compile time
1931// config options that are required internally by lib/*.js code. This is an
2032// alternative to dropping additional properties onto the process object as
@@ -23,7 +35,7 @@ using v8::Value;
2335// Command line arguments are already accessible in the JS land via
2436// require('internal/options').getOptionValue('--some-option'). Do not add them
2537// here.
26- static void Initialize (Local<Object> target,
38+ static void InitConfig (Local<Object> target,
2739 Local<Value> unused,
2840 Local<Context> context,
2941 void * priv) {
@@ -76,8 +88,15 @@ static void Initialize(Local<Object> target,
7688#endif // NODE_NO_BROWSER_GLOBALS
7789
7890 READONLY_PROPERTY (target, " bits" , Number::New (isolate, 8 * sizeof (intptr_t )));
91+
92+ SetMethodNoSideEffect (context, target, " getDefaultLocale" , GetDefaultLocale);
7993} // InitConfig
8094
95+ void RegisterConfigExternalReferences (ExternalReferenceRegistry* registry) {
96+ registry->Register (GetDefaultLocale);
97+ }
98+
8199} // namespace node
82100
83- NODE_BINDING_CONTEXT_AWARE_INTERNAL (config, node::Initialize)
101+ NODE_BINDING_CONTEXT_AWARE_INTERNAL (config, node::InitConfig)
102+ NODE_BINDING_EXTERNAL_REFERENCE(config, node::RegisterConfigExternalReferences)
0 commit comments