Skip to content

Commit

Permalink
Adds More Documentation and Change Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Dheatly23 committed Jul 6, 2023
1 parent dd4270c commit c181ec4
Show file tree
Hide file tree
Showing 6 changed files with 230 additions and 142 deletions.
2 changes: 2 additions & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ addon. Each class is separated into it's own file, named accordingly.

* [WasmModule](./WasmModule.md)
* [WasmInstance](./WasmInstance.md)
* [WasmConfig](./WasmConfig.md)
* [WasiContext](./WasiContext.md)
* [WasmHelper](./WasmHelper.md)
* [WasmFile](./WasmFile.md)
50 changes: 25 additions & 25 deletions doc/WasiContext.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,51 @@ This class defines a WASI execution context.

## Signals

* `stdout_emit(Variant message)`
### `stdout_emit(Variant message)`

_Feature gate:_ `wasi`
_Feature gate:_ `wasi`

Used to handle standard output.
Depending on the config, data can be a `String` or `PackedByteArray`.
Used to handle standard output.
Depending on the config, data can be a `String` or `PackedByteArray`.

* `stderr_emit(Variant message)`
### `stderr_emit(Variant message)`

_Feature gate:_ `wasi`
_Feature gate:_ `wasi`

Used to handle standard error.
Depending on the config, data can be a `String` or `PackedByteArray`.
Used to handle standard error.
Depending on the config, data can be a `String` or `PackedByteArray`.

## Properties

* `bool fs_readonly`
### `bool fs_readonly`

If set to `true`, prevents any instance from writing to filesystem.
If set to `true`, prevents any instance from writing to filesystem.

* `bool bypass_stdio`
### `bool bypass_stdio`

If set to `true`, pass standard output and standard error to Godot
instead of emitting signal.
If set to `true`, pass standard output and standard error to Godot
instead of emitting signal.

## Methods

* `void add_env_variable(String key, String value)`
### `void add_env_variable(String key, String value)`

Sets environment variable.
Sets environment variable.

* `String get_env_variable(String key)`
### `String get_env_variable(String key)`

Gets environment variable.
Gets environment variable.

* `void mount_physical_dir(String host_path [String guest_path])`
### `void mount_physical_dir(String host_path, [String guest_path])`

Mounts path to Webassembly.
Host and guest path must be global path, not Godot specific paths.
If guest path is not set, it is set the same as host path.
Mounts path to Webassembly.
Host and guest path must be global path, not Godot specific paths.
If guest path is not set, it is set the same as host path.

* `void write_memory_file(String path, String|PackedByteArray data, [int offset])`
### `void write_memory_file(String path, String|PackedByteArray data, [int offset])`

Writes data into in-memory file. Creates file if non-existent.
Writes data into in-memory file. Creates file if non-existent.

* `PackedByteArray read_memory_file(String path, int length, [int offset])`
### `PackedByteArray read_memory_file(String path, int length, [int offset])`

Reads in-memory file content.
Reads in-memory file content.
28 changes: 28 additions & 0 deletions doc/WasmFile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# WasmFile

_Defined in: [WasmFile.gd](../out/addons/godot_wasm/WasmFile.gd)_

_Inherits: [PackedDataContainer](https://docs.godotengine.org/en/stable/classes/class_packeddatacontainer.html)_

This class (along with WasmFileHelper) helps importing WASM and WAT file into Godot.

## Properties

### `String name`

The name of the module. Is exported and editable.

### `Dictionary imports`

Imports for this module. Values are also `WasmFile` objects.

## Methods

### `WasmModule get_module()`

Gets the compiled module.
Module object is cached, so calling this twice will yield the same object.

### `WasmInstance instantiate(Dictionary host = {}, Dictionary config = {})`

Creates a new instance from the module.
26 changes: 26 additions & 0 deletions doc/WasmHelper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# WasmHelper

_Defined in: [WasmHelper.gd](../out/addons/godot_wasm/WasmHelper.gd)_

The script contains helper constants and functions for using the addon.

## Constants

```gdscript
const TYPE_I32 = 1
const TYPE_I64 = 2
const TYPE_F32 = 3
const TYPE_F64 = 4
const TYPE_VARIANT = 6
```

## Static Functions

### `WasmModule load_wasm(String name, Variant data, Dictionary imports = {})`

Loads a new Webassembly module. Returns `null` if it fails.

### `WasmModule load_wasm_file(String name, String path, Dictionary imports = {})`

Loads a new Webassembly module from file.
Path can be a Godot-specific path or global path. Returns `null` if it fails.
Loading

0 comments on commit c181ec4

Please sign in to comment.