Skip to content

Commit 34c1b23

Browse files
committed
doc updates
1 parent 5d33af0 commit 34c1b23

File tree

8 files changed

+27
-16
lines changed

8 files changed

+27
-16
lines changed

docs/api/api-ts-library.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ twr-wasm Libraries are used to expose TypeScript code to C/C++ as C APIs. All o
99
There are two kinds of Libraries:
1010

1111
- Those that have only once instance (such as the math library)
12-
- Those that can have multiple instances across one more more library types, where each library type implements the same interface. Consoles are an example of this (see [interfaceName](#interfacename)).
12+
- Those that can have multiple instances across one or more library types, where each library type implements the same interface. Consoles are an example of this (see [interfaceName](#interfacename)).
1313

1414
## Basic Steps
1515
twr-wasm Libraries support both `twrWasmModule` and `twrWasmModuleAsync`. That is, when you create a twrLibrary, it will function with either type of module. In many cases no extra work is needed for the `twrWasmModuleAsync`, but in some cases, extra code is needed.
@@ -352,7 +352,7 @@ In a twrLibrary,
352352

353353
- An "interface" refers to the set of functions that the library exposes to C. Ie, the functions in the `import` object.
354354
- The name of the interface is anonymous, unless `interfaceName` is set.
355-
- An undefined interfaceName (anonymous interface) means that only one instance of that class is allowed (for example `twrLibMath`)
355+
- An undefined interfaceName (anonymous interface) also means that only one instance of that class is allowed (for example `twrLibMath`)
356356
- Set `interfaceName` to a unique name when multiple instances that support the same interface are allowed (for example the twr-wasm Consoles).
357357
- Multiple classes may have the same interfaceName (a class is identified by its libSourcePath). For example `twrConDiv`, `twrConDebug`, `twrConTerminal` all have the same interface.
358358

docs/api/api-ts-modules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const mod = new twrWasmModule();
1717
~~~
1818

1919
## About `twrWasmModuleAsync`
20-
`class twrWasmModuleAsync` allows you to integrate WebAssembly C/C++ code into your Web Page that uses a CLI pattern or code that blocks. For example, with `twrWasmModuleAsync` your C/C++ code can call a synchronous function for keyboard input (that blocks until the user has entered the keyboard input). Or your C/C++ code can `sleep` or otherwise block. This is the pattern that is used by many standard C library functions - `fread`, etc.
20+
`class twrWasmModuleAsync` allows you to integrate WebAssembly C/C++ code into your Web Page that uses a Read-Eval-Print Loop (REPL) pattern, a CLI pattern or code that blocks. For example, with `twrWasmModuleAsync` your C/C++ code can call a synchronous function for keyboard input (that blocks until the user has entered the keyboard input). Or your C/C++ code can `sleep` or otherwise block. This is the pattern that is used by many standard C library functions - `fread`, etc.
2121

2222
`class twrWasmModuleAsync` creates a WorkerThread that runs in parallel to the JavaScript main thread. This Worker thread executes your C/C++ code, and proxies functionality that needs to execute in the JavaScript main thread via remote procedure calls. This allows the JavaScript main thread to `await` on a blocking `callC` in your JavaScript main thread.
2323

docs/examples/examples-divcon.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
---
22
title: Stdio Printf and Input Using a div Tag
3-
description: This C WebAssembly example shows how to printf and get characters to and from an HTML div tag using twr-wasm
3+
description: This C WebAssembly example shows how to implement a Read-Eval-Print Loop (REPL) in twr-wasm
44
---
55

6-
# divcon - Printf and Input Using a div Tag
7-
This simple WebAssembly C program demos inputting and printing characters with a `div` tag.
6+
# divcon - Printf and Input Using a `div` Tag
7+
## What It Does
8+
This example inputs a number, squares it, and prints the result using standard C library functions.
9+
10+
The divcon example demos:
11+
12+
* A Read-Eval-Print Loop (REPL)
13+
* using twr-wasm `class twrWasmModuleAsync` to `await` on blocking C code
14+
* getting and print characters to a `div` tag using twr-wasm `class twrConsoleDiv`
15+
16+
## Running Examples and Source:
817

918
- [view divcon example running live](/examples/dist/divcon/index.html)
1019
- [View divcon source code](https://github.com/twiddlingbits/twr-wasm/tree/main/examples/divcon)

docs/examples/examples-multi-io.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Multi-io - WebAssembly C++ Multiple Console Example
33
description: This example demos 6 simultaneous consoles. 2 div as streams, 2 canvas as terminals, and 2 canvas as 2D draw surfaces.
44
---
55

6-
# Multi-io -Multiple Console Example
6+
# Multi-io Multiple Console Example
77
## What It Does
88
This example demos six simultaneous consoles:
99

docs/examples/examples-overview.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ These examples are a good place to learn how to configure clang and wasm-ld to c
2727
| terminal |A simple C program demos writing and inputting from a `<canvas>` tag<br>that twr-wasm configures as a windowed "terminal" | [terminal](examples-terminal.md)|
2828
| multi-io | Demo 6 simultaneous consoles: stream i/o, terminal, and 2D Drawing. | [multi-io](examples-multi-io.md)|
2929

30-
## Draw 2D Examples
30+
## Draw 2D and Audio Examples
3131
| Name | Description | Link |
3232
| -----| ----------- | ---- |
3333
| balls | These fun Bouncing Balls are written in C++ and demo the 2D drawing<br>APIs with a C++ Canvas wrapper class | [balls](examples-balls.md) |
34-
| pong | A simple game of Pong written in C++ to demo 2D drawing APIs with a<br>C++ canvas wrapper class and taking user input from JS | [pong](examples-pong.md)
34+
| pong | A simple game of Pong written in C++ to demo 2D drawing and Audio APIs with<br>a C++ canvas wrapper class and taking user input from JS | [pong](examples-pong.md)
3535
| maze | This is an old Win32 program ported to wasm and demos 2D Draw APIs | [maze](examples-maze.md) |
3636

3737
## Call Argument Examples
@@ -40,7 +40,7 @@ These examples are a good place to learn how to configure clang and wasm-ld to c
4040
| callC | A demo of passing and returning values between JavaScript and Wasm module | [callc](examples-callc.md) |
4141
| fft | A demo of calling a C library to perform an FFT that is graphed in TypeScript | [fft](examples-fft.md) |
4242

43-
## twrLibrary examples
43+
## twrLibrary Examples
4444
| Name | Description | Link |
4545
| -----| ----------- | ---- |
4646
| lib | A demo of createing a twrLibrary (use TypeScript to create C/C++ APIs) | [library](examples-lib.md) |

docs/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ twr-wasm is a simple, lightweight and easy to use library for building C/C++ Web
2020

2121
- the optional TypeScript `class twrWasmModuleAsync` can be used to:
2222

23-
- integrate CLI C/C++ code with JavaScript
23+
- integrate a C/C++ Read-Eval-Print Loop (REPL) with JavaScript
24+
- integrate a C/C++ CLI or Shell with JavaScript
2425
- In JavaScript `await` on blocking/synchronous C/C++ functions.
2526

2627
- 2D drawing API for C/C++ compatible with JavaScript Canvas

examples/divcon/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<!doctype html>
22
<html>
33
<head>
4-
<title>Div Console WebAssembly Example</title>
5-
<meta name="description" content="Use a streaming character console with C/C++ WebAssembly that maps stdin and stdout to a div tag. Uses twr-wasm.">
4+
<title>Div Console WebAssembly C/C++ Example</title>
5+
<meta name="description" content="Map stdin and stdout to a div tag using twr-wasm class twrConsoleDiv. Implements a Read-Eval-Print Loop (REPL)">
66

77
<!-- importmap used to find unbundled twr-wasm -->
88
<!-- also see package.json 'alias' for parcel bundler example -->
@@ -17,7 +17,7 @@
1717
</head>
1818
<body style="background-color:white;font-family: Arial">
1919
<h1>twrConsoleDiv Demo</h1>
20-
This example shows how to map a simple streaming character twr-wasm Console onto a div tag as stdio.
20+
This example shows how to map a simple streaming character twr-wasm Console onto a div tag as stdio. A Read-Eval-Print Loop (REPL) is also implemented.
2121
<br><br>
2222
<a href="/docsite/examples/examples-overview/">docs and more examples here</a>
2323
<br><br>

readme.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ twr-wasm is a simple, lightweight and easy to use library for building C/C++ Web
1212
- in C/C++, print and get characters to/from a `<canvas>` based "terminal"
1313
- localization support, UTF-8, and windows-1252 support
1414
- the optional TypeScript `class twrWasmModuleAsync` can be used to:
15-
- integrate CLI C/C++ code with JavaScript
16-
- In JavaScript `await` on blocking/synchronous C/C++ functions.
15+
- integrate a C/C++ Read-Eval-Print Loop (REPL) with JavaScript
16+
- integrate a C/C++ CLI or Shell with JavaScript
17+
- In JavaScript `await` on blocking/synchronous C/C++ functions.
1718
- 2D drawing API for C/C++ compatible with JavaScript Canvas
1819
- audio playback APIs for C/C++
1920
- create your own C/C++ APIs using TypeScript by extending `class twrLibrary`

0 commit comments

Comments
 (0)