Skip to content

Commit

Permalink
Renames Config Options
Browse files Browse the repository at this point in the history
Reasons:
* Consistency and redundancy (wasi.wasi_context?).
* Group config options with their targets.
  • Loading branch information
Dheatly23 committed Feb 7, 2024
1 parent 5b69a07 commit e8444fb
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 45 deletions.
36 changes: 18 additions & 18 deletions doc/WasmConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ Configuration value is a dictionary with key is configuration name.

## Configs

### engine.use_epoch
### epoch.enable

* Feature gate: `epoch-timeout`
* Type: `bool`
* Default: `false`

Enables epoch-based timeout.

### engine.epoch_timeout
### epoch.timeout

* Feature gate: `epoch-timeout`
* Type: `null|int|float`
Expand All @@ -26,37 +26,37 @@ Enables epoch-based timeout.
Sets how many second the instance can run.
If not set or `null`, it defaults to 5 seconds.

### engine.epoch_autoreset
### epoch.useAutoreset

* Feature gate: `epoch-timeout`
* Type: `bool`
* Default: `false`

If enabled, automatically resets epoch timer whenever it returns from host.

### engine.max_memory
### memory.maxGrowBytes

* Feature gate: `memory-limiter`
* Type: `int`

If set, it limits the amount of memories Webassembly can allocate in bytes.
If set, it limits the amount of **extra** bytes all Webassembly memories can allocate.

### engine.max_entries
### table.maxGrowEntries

* Feature gate: `memory-limiter`
* Type: `int`

If set, it limits the size of tables Webassembly can allocate.
If set, it limits the amount of **extra** entries all Webassembly tables can allocate.

### engine.use_wasi
### wasi.enable

* Feature gate: `wasi`
* Type: `bool`
* Default: `false`

Enables usage of WASI.

### wasi.wasi_context
### wasi.context

* Feature gate: `wasi`
* Type: `WasiContext`
Expand All @@ -78,7 +78,7 @@ NOTE: First argument is the "executable name".

Sets additional environment variables for the instance.

### wasi.fs_readonly
### wasi.fsReadonly

* Feature gate: `wasi`
* Type: `bool`
Expand All @@ -87,7 +87,7 @@ Sets additional environment variables for the instance.
If enabled, it prevents Webassembly from writing to filesystem.
Only useful with context set, as by default it can't access anything.

### wasi.stdin
### wasi.stdin.bindMode

* Feature gate: `wasi`
* Type: `String`
Expand All @@ -97,22 +97,22 @@ Must be one of these value:
* `"unbound"` : Do not connect standard input.
* `"instance"` : Connect standard input to instance object.

### wasi.stdin_data
### wasi.stdin.inputData

* Feature gate: `wasi`
* Type: `PackedByteArray`

Prefill standard input with data.

### wasi.stdin_file
### wasi.stdin.inputFile

* Feature gate: `wasi`
* Type: `string`

Prefill standard input with in-memory file.
Useful only with context set.

### wasi.stdout
### wasi.stdout.bindMode

* Feature gate: `wasi`
* Type: `String`
Expand All @@ -122,7 +122,7 @@ Must be one of these value:
* `"unbound"` : Do not connect standard output.
* `"instance"` : Connect standard output to instance object.

### wasi.stdout_buffer
### wasi.stdout.bufferMode

* Feature gate: `wasi`
* Type: `String`
Expand All @@ -132,7 +132,7 @@ Must be one of these value:
* `"block"` : Buffers by block. Emits as PackedByteArray.
* `"unbuffered"` : Disable buffering. Emits as PackedByteArray.

### wasi.stderr
### wasi.stderr.bindMode

* Feature gate: `wasi`
* Type: `String`
Expand All @@ -142,7 +142,7 @@ Must be one of these value:
* `"unbound"` : Do not connect standard error.
* `"instance"` : Connect standard error to instance object.

### wasi.stderr_buffer
### wasi.stderr.bufferMode

* Feature gate: `wasi`
* Type: `String`
Expand All @@ -152,7 +152,7 @@ Must be one of these value:
* `"block"` : Buffers by block. Emits as PackedByteArray.
* `"unbuffered"` : Disable buffering. Emits as PackedByteArray.

### godot.extern_binding
### extern.bindMode

* Type: `String`

Expand Down
8 changes: 4 additions & 4 deletions example/script/3DRender.gd
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ func _ready():
module,
{},
{
"engine.use_epoch": true,
"engine.epoch_timeout": 1.0,
"engine.use_wasi": true,
"wasi.wasi_context": wasi_ctx,
"epoch.enable": true,
"epoch.timeout": 1.0,
"wasi.enable": true,
"wasi.context": wasi_ctx,
}
)
if instance == null:
Expand Down
4 changes: 2 additions & 2 deletions example/script/Connect4.gd
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func init_game() -> void:
module,
{},
{
"engine.use_epoch": true,
"engine.epoch_timeout": 60,
"epoch.enable": true,
"epoch.timeout": 60,
},
self, "__log"
)
Expand Down
2 changes: 1 addition & 1 deletion example/script/HostBindings.gd
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func _ready():
},
},
{
"engine.use_epoch": true,
"epoch.enable": true,
},
self, "__log"
)
Expand Down
4 changes: 2 additions & 2 deletions example/script/Pendulum.gd
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ func _ready():
module,
{},
{
"engine.use_epoch": true,
"engine.epoch_timeout": 1,
"epoch.enable": true,
"epoch.timeout": 1,
},
self, "__log"
)
Expand Down
4 changes: 2 additions & 2 deletions example/script/RunWasi.gd
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ func __execute():
wasm_module,
{},
{
"engine.use_wasi": true,
"wasi.wasi_context": wasi_ctx,
"wasi.enable": true,
"wasi.context": wasi_ctx,
"wasi.args": args,
}
)
Expand Down
32 changes: 16 additions & 16 deletions src/wasm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,43 +96,43 @@ impl FromVariant for Config {

Ok(Self {
#[cfg(feature = "epoch-timeout")]
with_epoch: get_field(&dict, "engine.use_epoch")?.unwrap_or_default(),
with_epoch: get_field(&dict, "epoch.enable")?.unwrap_or_default(),
#[cfg(feature = "epoch-timeout")]
epoch_autoreset: get_field(&dict, "engine.epoch_autoreset")?.unwrap_or_default(),
epoch_autoreset: get_field(&dict, "epoch.useAutoreset")?.unwrap_or_default(),
#[cfg(feature = "epoch-timeout")]
epoch_timeout: compute_epoch(dict.get("engine.epoch_timeout"))?,
epoch_timeout: compute_epoch(dict.get("epoch.timeout"))?,

#[cfg(feature = "memory-limiter")]
max_memory: get_field(&dict, "engine.max_memory")?,
max_memory: get_field(&dict, "memory.maxGrowBytes")?,
#[cfg(feature = "memory-limiter")]
max_entries: get_field(&dict, "engine.max_entries")?,
max_entries: get_field(&dict, "table.maxGrowEntries")?,

#[cfg(feature = "wasi")]
with_wasi: get_field(&dict, "engine.use_wasi")?.unwrap_or_default(),
with_wasi: get_field(&dict, "wasi.enable")?.unwrap_or_default(),
#[cfg(feature = "wasi")]
wasi_context: get_field(&dict, "wasi.wasi_context")?,
wasi_context: get_field(&dict, "wasi.context")?,
#[cfg(feature = "wasi")]
wasi_args: get_field(&dict, "wasi.args")?.unwrap_or_default(),
#[cfg(feature = "wasi")]
wasi_envs: get_field(&dict, "wasi.envs")?.unwrap_or_default(),
#[cfg(feature = "wasi")]
wasi_fs_readonly: get_field(&dict, "wasi.fs_readonly")?.unwrap_or_default(),
wasi_fs_readonly: get_field(&dict, "wasi.fsReadonly")?.unwrap_or_default(),
#[cfg(feature = "wasi")]
wasi_stdin: get_field(&dict, "wasi.stdin")?.unwrap_or_default(),
wasi_stdin: get_field(&dict, "wasi.stdin.bindMode")?.unwrap_or_default(),
#[cfg(feature = "wasi")]
wasi_stdout: get_field(&dict, "wasi.stdout")?.unwrap_or_default(),
wasi_stdout: get_field(&dict, "wasi.stdout.bindMode")?.unwrap_or_default(),
#[cfg(feature = "wasi")]
wasi_stderr: get_field(&dict, "wasi.stderr")?.unwrap_or_default(),
wasi_stderr: get_field(&dict, "wasi.stderr.bindMode")?.unwrap_or_default(),
#[cfg(feature = "wasi")]
wasi_stdout_buffer: get_field(&dict, "wasi.stdout_buffer")?.unwrap_or_default(),
wasi_stdout_buffer: get_field(&dict, "wasi.stdout.bufferMode")?.unwrap_or_default(),
#[cfg(feature = "wasi")]
wasi_stderr_buffer: get_field(&dict, "wasi.stderr_buffer")?.unwrap_or_default(),
wasi_stderr_buffer: get_field(&dict, "wasi.stderr.bufferMode")?.unwrap_or_default(),
#[cfg(feature = "wasi")]
wasi_stdin_data: get_field(&dict, "wasi.stdin_data")?,
wasi_stdin_data: get_field(&dict, "wasi.stdin.inputData")?,
#[cfg(feature = "wasi")]
wasi_stdin_file: get_field(&dict, "wasi.stdin_file")?,
wasi_stdin_file: get_field(&dict, "wasi.stdin.inputFile")?,

extern_bind: get_field(&dict, "godot.extern_binding")?.unwrap_or_default(),
extern_bind: get_field(&dict, "extern.bindMode")?.unwrap_or_default(),
})
}
}
Expand Down

0 comments on commit e8444fb

Please sign in to comment.