mirror of
https://github.com/denoland/deno
synced 2024-11-05 18:45:24 +00:00
Rename EnvPair to KeyValue.
This commit is contained in:
parent
edd12b90a8
commit
ee24254bad
5 changed files with 30 additions and 19 deletions
7
js/os.ts
7
js/os.ts
|
@ -81,12 +81,11 @@ export function codeCache(
|
|||
assert(baseRes == null); // Expect null or error.
|
||||
}
|
||||
|
||||
function createEnv(_inner: msg.EnvironRes): { [index: string]: string } {
|
||||
function createEnv(inner: msg.EnvironRes): { [index: string]: string } {
|
||||
const env: { [index: string]: string } = {};
|
||||
|
||||
for (let i = 0; i < _inner.mapLength(); i++) {
|
||||
const item = _inner.map(i)!;
|
||||
|
||||
for (let i = 0; i < inner.mapLength(); i++) {
|
||||
const item = inner.map(i)!;
|
||||
env[item.key()!] = item.value()!;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ mod http_util;
|
|||
pub mod isolate;
|
||||
pub mod libdeno;
|
||||
pub mod msg;
|
||||
pub mod msg_util;
|
||||
pub mod ops;
|
||||
pub mod permissions;
|
||||
pub mod resources;
|
||||
|
|
|
@ -182,10 +182,10 @@ table SetEnv {
|
|||
}
|
||||
|
||||
table EnvironRes {
|
||||
map: [EnvPair];
|
||||
map: [KeyValue];
|
||||
}
|
||||
|
||||
table EnvPair {
|
||||
table KeyValue {
|
||||
key: string;
|
||||
value: string;
|
||||
}
|
||||
|
|
21
src/msg_util.rs
Normal file
21
src/msg_util.rs
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
// Helpers for serialization.
|
||||
use flatbuffers;
|
||||
use msg;
|
||||
|
||||
pub fn serialize_key_value<'bldr>(
|
||||
builder: &mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
key: &str,
|
||||
value: &str,
|
||||
) -> flatbuffers::WIPOffset<msg::KeyValue<'bldr>> {
|
||||
let key = builder.create_string(&key);
|
||||
let value = builder.create_string(&value);
|
||||
msg::KeyValue::create(
|
||||
builder,
|
||||
&msg::KeyValueArgs {
|
||||
key: Some(key),
|
||||
value: Some(value),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
}
|
16
src/ops.rs
16
src/ops.rs
|
@ -8,6 +8,7 @@ use isolate::Isolate;
|
|||
use isolate::IsolateState;
|
||||
use isolate::Op;
|
||||
use msg;
|
||||
use msg_util;
|
||||
use resources;
|
||||
use resources::Resource;
|
||||
use version;
|
||||
|
@ -358,19 +359,8 @@ fn op_env(
|
|||
|
||||
let builder = &mut FlatBufferBuilder::new();
|
||||
let vars: Vec<_> = std::env::vars()
|
||||
.map(|(key, value)| {
|
||||
let key = builder.create_string(&key);
|
||||
let value = builder.create_string(&value);
|
||||
|
||||
msg::EnvPair::create(
|
||||
builder,
|
||||
&msg::EnvPairArgs {
|
||||
key: Some(key),
|
||||
value: Some(value),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
}).collect();
|
||||
.map(|(key, value)| msg_util::serialize_key_value(builder, &key, &value))
|
||||
.collect();
|
||||
let tables = builder.create_vector(&vars);
|
||||
let inner = msg::EnvironRes::create(
|
||||
builder,
|
||||
|
|
Loading…
Reference in a new issue