@@ -40,7 +40,7 @@ class RealEnvStore final : public KVStore {
40
40
Local<Array> Enumerate (Isolate* isolate) const override ;
41
41
};
42
42
43
- class GenericKVStore final : public KVStore {
43
+ class MapKVStore final : public KVStore {
44
44
public:
45
45
Local<String> Get (Isolate* isolate, Local<String> key) const override ;
46
46
void Set (Isolate* isolate, Local<String> key, Local<String> value) override ;
@@ -50,8 +50,8 @@ class GenericKVStore final : public KVStore {
50
50
51
51
std::shared_ptr<KVStore> Clone (Isolate* isolate) const override ;
52
52
53
- GenericKVStore () {}
54
- GenericKVStore (const GenericKVStore & other) : map_(other.map_) {}
53
+ MapKVStore () {}
54
+ MapKVStore (const MapKVStore & other) : map_(other.map_) {}
55
55
56
56
private:
57
57
mutable Mutex mutex_;
@@ -60,7 +60,7 @@ class GenericKVStore final : public KVStore {
60
60
61
61
namespace per_process {
62
62
Mutex env_var_mutex;
63
- std::shared_ptr<KVStore> real_environment = std::make_shared<RealEnvStore>();
63
+ std::shared_ptr<KVStore> system_environment = std::make_shared<RealEnvStore>();
64
64
} // namespace per_process
65
65
66
66
Local<String> RealEnvStore::Get (Isolate* isolate,
@@ -207,7 +207,7 @@ std::shared_ptr<KVStore> KVStore::Clone(v8::Isolate* isolate) const {
207
207
HandleScope handle_scope (isolate);
208
208
Local<Context> context = isolate->GetCurrentContext ();
209
209
210
- std::shared_ptr<KVStore> copy = KVStore::CreateGenericKVStore ();
210
+ std::shared_ptr<KVStore> copy = KVStore::CreateMapKVStore ();
211
211
Local<Array> keys = Enumerate (isolate);
212
212
uint32_t keys_length = keys->Length ();
213
213
for (uint32_t i = 0 ; i < keys_length; i++) {
@@ -218,41 +218,40 @@ std::shared_ptr<KVStore> KVStore::Clone(v8::Isolate* isolate) const {
218
218
return copy;
219
219
}
220
220
221
- Local<String> GenericKVStore ::Get (Isolate* isolate, Local<String> key) const {
221
+ Local<String> MapKVStore ::Get (Isolate* isolate, Local<String> key) const {
222
222
Mutex::ScopedLock lock (mutex_);
223
- String:: Utf8Value str (isolate, key);
223
+ Utf8Value str (isolate, key);
224
224
auto it = map_.find (std::string (*str, str.length ()));
225
225
if (it == map_.end ()) return Local<String>();
226
226
return String::NewFromUtf8 (isolate, it->second .data (),
227
227
NewStringType::kNormal , it->second .size ())
228
228
.ToLocalChecked ();
229
229
}
230
230
231
- void GenericKVStore::Set (Isolate* isolate, Local<String> key,
232
- Local<String> value) {
231
+ void MapKVStore::Set (Isolate* isolate, Local<String> key, Local<String> value) {
233
232
Mutex::ScopedLock lock (mutex_);
234
- String:: Utf8Value key_str (isolate, key);
235
- String:: Utf8Value value_str (isolate, value);
233
+ Utf8Value key_str (isolate, key);
234
+ Utf8Value value_str (isolate, value);
236
235
if (*key_str != nullptr && *value_str != nullptr ) {
237
236
map_[std::string (*key_str, key_str.length ())] =
238
237
std::string (*value_str, value_str.length ());
239
238
}
240
239
}
241
240
242
- int32_t GenericKVStore ::Query (Isolate* isolate, Local<String> key) const {
241
+ int32_t MapKVStore ::Query (Isolate* isolate, Local<String> key) const {
243
242
Mutex::ScopedLock lock (mutex_);
244
- String:: Utf8Value str (isolate, key);
243
+ Utf8Value str (isolate, key);
245
244
auto it = map_.find (std::string (*str, str.length ()));
246
245
return it == map_.end () ? -1 : 0 ;
247
246
}
248
247
249
- void GenericKVStore ::Delete (Isolate* isolate, Local<String> key) {
248
+ void MapKVStore ::Delete (Isolate* isolate, Local<String> key) {
250
249
Mutex::ScopedLock lock (mutex_);
251
- String:: Utf8Value str (isolate, key);
250
+ Utf8Value str (isolate, key);
252
251
map_.erase (std::string (*str, str.length ()));
253
252
}
254
253
255
- Local<Array> GenericKVStore ::Enumerate (Isolate* isolate) const {
254
+ Local<Array> MapKVStore ::Enumerate (Isolate* isolate) const {
256
255
Mutex::ScopedLock lock (mutex_);
257
256
std::vector<Local<Value>> values;
258
257
values.reserve (map_.size ());
@@ -265,12 +264,12 @@ Local<Array> GenericKVStore::Enumerate(Isolate* isolate) const {
265
264
return Array::New (isolate, values.data (), values.size ());
266
265
}
267
266
268
- std::shared_ptr<KVStore> GenericKVStore ::Clone (Isolate* isolate) const {
269
- return std::make_shared<GenericKVStore >(*this );
267
+ std::shared_ptr<KVStore> MapKVStore ::Clone (Isolate* isolate) const {
268
+ return std::make_shared<MapKVStore >(*this );
270
269
}
271
270
272
- std::shared_ptr<KVStore> KVStore::CreateGenericKVStore () {
273
- return std::make_shared<GenericKVStore >();
271
+ std::shared_ptr<KVStore> KVStore::CreateMapKVStore () {
272
+ return std::make_shared<MapKVStore >();
274
273
}
275
274
276
275
Maybe<bool > KVStore::AssignFromObject (Local<Context> context,
@@ -307,7 +306,7 @@ static void EnvGetter(Local<Name> property,
307
306
}
308
307
CHECK (property->IsString ());
309
308
info.GetReturnValue ().Set (
310
- env->envvars ()->Get (env->isolate (), property.As <String>()));
309
+ env->env_vars ()->Get (env->isolate (), property.As <String>()));
311
310
}
312
311
313
312
static void EnvSetter (Local<Name> property,
@@ -338,7 +337,7 @@ static void EnvSetter(Local<Name> property,
338
337
return ;
339
338
}
340
339
341
- env->envvars ()->Set (env->isolate (), key, value_string);
340
+ env->env_vars ()->Set (env->isolate (), key, value_string);
342
341
343
342
// Whether it worked or not, always return value.
344
343
info.GetReturnValue ().Set (value);
@@ -348,7 +347,7 @@ static void EnvQuery(Local<Name> property,
348
347
const PropertyCallbackInfo<Integer>& info) {
349
348
Environment* env = Environment::GetCurrent (info);
350
349
if (property->IsString ()) {
351
- int32_t rc = env->envvars ()->Query (env->isolate (), property.As <String>());
350
+ int32_t rc = env->env_vars ()->Query (env->isolate (), property.As <String>());
352
351
if (rc != -1 ) info.GetReturnValue ().Set (rc);
353
352
}
354
353
}
@@ -357,7 +356,7 @@ static void EnvDeleter(Local<Name> property,
357
356
const PropertyCallbackInfo<Boolean >& info) {
358
357
Environment* env = Environment::GetCurrent (info);
359
358
if (property->IsString ()) {
360
- env->envvars ()->Delete (env->isolate (), property.As <String>());
359
+ env->env_vars ()->Delete (env->isolate (), property.As <String>());
361
360
}
362
361
363
362
// process.env never has non-configurable properties, so always
@@ -369,7 +368,7 @@ static void EnvEnumerator(const PropertyCallbackInfo<Array>& info) {
369
368
Environment* env = Environment::GetCurrent (info);
370
369
371
370
info.GetReturnValue ().Set (
372
- env->envvars ()->Enumerate (env->isolate ()));
371
+ env->env_vars ()->Enumerate (env->isolate ()));
373
372
}
374
373
375
374
MaybeLocal<Object> CreateEnvVarProxy (Local<Context> context,
0 commit comments