diff --git a/docs/cli-usage.md b/docs/cli-usage.md index 3c27b842..1981a151 100644 --- a/docs/cli-usage.md +++ b/docs/cli-usage.md @@ -149,9 +149,12 @@ djinni \ | Argument | Description | |----------------------------------------|----------------------------------------------------------------------------| -| `--wasm-out ` | WebAssembly bridge code output folder | -| `--ts-out ` | Path to the Typescript type definitions output folder | -| `--ts-module ` | Name of the module for the Typescript types. `module.ts` by default. | +| `--wasm-out ` | WebAssembly bridge code output folder. | +| `--wasm-include-prefix` | The prefix for #includes of WASM bridge C++ header files. | +| `--wasm-include-cpp-prefix` | The prefix for #includes of C++ header files. | +| `--wasm-base-lib-include-prefix` | The path prefix to be added to djinni support library inlcude lines in generated files | +| `--ts-out ` | Path to the Typescript type definitions output folder | +| `--ts-module ` | Name of the module for the Typescript types. `module.ts` by default. | ### Yaml Generation diff --git a/docs/generated-code-usage.md b/docs/generated-code-usage.md index c2f88304..8aac8fd3 100644 --- a/docs/generated-code-usage.md +++ b/docs/generated-code-usage.md @@ -166,6 +166,41 @@ Add all generated files to your build target, and link against the [djinni-suppo C++/CLI sources have to be compiled with MSVC and the [`/clr` (Common Language Runtime Compilation)](https://docs.microsoft.com/en-us/cpp/build/reference/clr-common-language-runtime-compilation?view=msvc-160) option. +## TS/JS C++/WASM Project + +Djinni can generate code that bridges C++ (that compiles to Web Assembly) and Javascript/TypeScript in web browsers. + +For WASM, Djinni generates: +- C++ code, which should be compiled into the WASM bindary +- TypeScript code, provides optional TypeScript interface definitions + +The generated code can be used with both plain Javascript and TypeScript. + +Almost all Djinni features are supported, including importing external types via +yaml. + +Notable differences when comparing to the Java/ObjC support: + +- deriving(ord, eq) is not applicable to Javascript because JS doesn't support + overloading standard comparison methods. + +### Includes & Build target + +The following code will be generated for each defined type: + +| Type | C++ header | C++ source | WASM header/sources | TS definitions | +|------------|--------------------------|----------------------------|-------------------------------------|----------------------| +| Enum/Flags | my\_enum.hpp | | my_enum.hpp, my_enum.cpp | module.ts :three: | +| | my\_enum+json.hpp :two: | | | | +| Record | my\_record.hpp | my\_record.cpp | my_record.hpp, my_enum.cpp | | +| | my\_record+json.hpp :two:| | | | +| Interface | my\_interface.hpp | my\_interface.cpp :one: | my_interface.hpp, my_interface.cpp | | + +- :one: Generated only for types that contain constants. +- :two: Generated only if cpp json serialization is enabled. +- :three: Name of file configurable via command-line options. + + ## C++ JSON Serialization support Serialization from C++ types to/from JSON is supported. This feature is currently only enabled for `nlohmann/json`, and if enabled creates `to_json`/`from_json` methods for all djinni records and enums. @@ -219,4 +254,4 @@ namespace nlohmann { } }; } -``` \ No newline at end of file +```