Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
c9ea12f
Basic setup of `wit-bindgen-d`
QuantumSegfault Mar 6, 2026
c03aa43
Initial support for most types.
QuantumSegfault Mar 10, 2026
4fdcb12
Basic implementation of `wit.common` type templates.
QuantumSegfault Mar 10, 2026
ddfb9f6
Refactor type generation
QuantumSegfault Mar 12, 2026
b0e48e2
Resource import handles, WitVariant, and raw function imports.
QuantumSegfault Mar 15, 2026
47ad1f8
Initial pass implementing of `FunctionBindgen` for imports.
QuantumSegfault Mar 18, 2026
18ec4bf
Basic export support.
QuantumSegfault Mar 20, 2026
5234a97
Begin support for `cargo run test`
QuantumSegfault Mar 25, 2026
13662bf
Finish world-level imports & exports.
QuantumSegfault Mar 31, 2026
b426696
Fix resource lookups
QuantumSegfault Apr 2, 2026
3981268
Reorder emit instructions
QuantumSegfault Apr 3, 2026
cf6bcdd
Fixed length lists
QuantumSegfault Apr 3, 2026
2de8895
Bitcasts, fixed export _retArea, make sure async fails.
QuantumSegfault Apr 3, 2026
fb85285
Import and export static methods
QuantumSegfault Apr 8, 2026
3bff021
Add export stub generation
QuantumSegfault Apr 8, 2026
9168144
Implement resource exports + stubs
QuantumSegfault Apr 9, 2026
69cb904
cabi_post_* and cabi_realloc
QuantumSegfault Apr 9, 2026
e63e17a
Resource constructors
QuantumSegfault Apr 13, 2026
77efc5c
Resource alloc/dealloc
QuantumSegfault Apr 14, 2026
8eb52fc
GitHub CI integration
QuantumSegfault Apr 14, 2026
2788e0e
`ci/publish.rs` crate whitelist
QuantumSegfault Apr 14, 2026
ba26baf
Fix warnings, fix CI integration
QuantumSegfault Apr 14, 2026
28418f6
Replace `add_extension` with `set_extension`
QuantumSegfault Apr 14, 2026
3040ce7
Fix clippy warnings
QuantumSegfault Apr 14, 2026
c61ff22
Don't use `in` on simple parameters
QuantumSegfault Apr 14, 2026
76ff89e
Begin work on runtime tests
QuantumSegfault Apr 14, 2026
3ed314b
Add free and clone utilities for WIT types. Add some runtime tests.
QuantumSegfault May 14, 2026
8f26e27
Component type custom section
QuantumSegfault Jun 3, 2026
826d01d
`flavorful` test and cast removals
QuantumSegfault Jun 3, 2026
988a65b
Allow changing root package.
QuantumSegfault Jun 8, 2026
d028409
Force component types to be linked
QuantumSegfault Jun 8, 2026
21dbcc8
Use `walloc` instead of bump allocator in tests.
QuantumSegfault Jul 17, 2026
32d6236
Make emitting `wit_common.d` optional
QuantumSegfault Jul 17, 2026
6187871
Add `--required-d-versions`
QuantumSegfault Jul 18, 2026
34d3124
Tweak test runner
QuantumSegfault Jul 25, 2026
28958f3
Fix memory leaks
QuantumSegfault Jul 25, 2026
e62ceb2
Fixes for 0.60.0
QuantumSegfault Jul 26, 2026
f1961c2
Use LDC 1.42, etc.
QuantumSegfault Jul 28, 2026
aeceb79
Clippy
QuantumSegfault Jul 28, 2026
65eee4c
self-contained only, fix malloc asserts, witClone, and `variant` lower
QuantumSegfault Jul 29, 2026
1611f8e
Fix more memory leaks
QuantumSegfault Jul 29, 2026
a04fe05
Add `tuple` helper.
QuantumSegfault Jul 30, 2026
df69eb4
`runtime` tests up through `lists`
QuantumSegfault Jul 30, 2026
7d0bb36
tests through `records` and fixes
QuantumSegfault Jul 30, 2026
e182480
Tweaks to `in`, and fixes for handle lifetime management
QuantumSegfault Aug 5, 2026
ad8a8e2
Result construction helpers & make resource containing parameters
QuantumSegfault Aug 7, 2026
383d8c4
Start on resource-related tests
QuantumSegfault Aug 7, 2026
4037fff
Fix `list-in-variant` with new Result helpers
QuantumSegfault Aug 8, 2026
f8e1ff6
`variant` test (+ param qual fix)
QuantumSegfault Aug 10, 2026
24d135f
Remaining non-resource tests
QuantumSegfault Aug 11, 2026
106fab3
Most of the rest of the resource tests
QuantumSegfault Aug 20, 2026
f546d20
Fix `crates/test/src/d.rs`
QuantumSegfault Aug 20, 2026
1dda1bf
`resource_alias` tests and brief README
QuantumSegfault Aug 20, 2026
aabf807
Rewind back to 0.60.0
QuantumSegfault Aug 20, 2026
b281155
Fix `witList` parameter, and same for `witClone` & `witFree` for `T[L]`
QuantumSegfault Aug 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# moonbit removed from language matrix for now - causing CI failures
lang: [c, rust, csharp, cpp, go]
lang: [c, rust, csharp, cpp, go, d]
exclude:
# For now csharp doesn't work on macos, so exclude it from testing.
- os: macos-latest
Expand Down Expand Up @@ -121,6 +121,12 @@ jobs:
go-version: 1.25.4
if: matrix.lang == 'go' && matrix.os != 'ubuntu-latest'

- name: Setup D
uses: dlang-community/setup-dlang@v2
with:
compiler: ldc-1.42
if: matrix.lang == 'd'

# Hacky work-around for https://github.com/dotnet/runtime/issues/80619
- run: dotnet new console -o /tmp/foo
if: matrix.os != 'windows-latest' && matrix.lang == 'csharp'
Expand Down
15 changes: 15 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ wit-bindgen-csharp = { path = 'crates/csharp', version = '0.60.0' }
wit-bindgen-markdown = { path = 'crates/markdown', version = '0.60.0' }
wit-bindgen-moonbit = { path = 'crates/moonbit', version = '0.60.0' }
wit-bindgen-go = { path = 'crates/go', version = '0.60.0' }
wit-bindgen-d = { path = 'crates/d', version = '0.60.0' }
wit-bindgen = { path = 'crates/guest-rust', version = '0.60.0', default-features = false }
wit-bindgen-test = { path = 'crates/test', version = '0.60.0' }

Expand Down Expand Up @@ -95,6 +96,7 @@ wit-bindgen-markdown = { workspace = true, features = ['clap'], optional = true
wit-bindgen-moonbit = { workspace = true, features = ['clap'], optional = true }
wit-bindgen-csharp = { workspace = true, features = ['clap'], optional = true }
wit-bindgen-go = { workspace = true, features = ['clap'], optional = true }
wit-bindgen-d = { workspace = true, features = ['clap'], optional = true }
wit-bindgen-test = { workspace = true }
wit-component = { workspace = true }
wasm-encoder = { workspace = true }
Expand All @@ -109,7 +111,8 @@ default = [
'csharp',
'cpp',
'moonbit',
'async',
'd',
'async'
]
c = ['dep:wit-bindgen-c']
cpp = ['dep:wit-bindgen-cpp']
Expand All @@ -119,4 +122,5 @@ go = ['dep:wit-bindgen-go']
csharp = ['dep:wit-bindgen-csharp']
csharp-mono = ['csharp']
moonbit = ['dep:wit-bindgen-moonbit']
d = ['dep:wit-bindgen-d']
async = []
1 change: 1 addition & 0 deletions ci/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const CRATES_TO_PUBLISH: &[&str] = &[
"wit-bindgen-markdown",
"wit-bindgen-moonbit",
"wit-bindgen-go",
"wit-bindgen-d",
"wit-bindgen-rust-macro",
"wit-bindgen-rt",
"wit-bindgen",
Expand Down
33 changes: 33 additions & 0 deletions crates/d/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[package]
name = "wit-bindgen-d"
authors = ["Demetrius Kanios <demetrius@kanios.net>"]
version = { workspace = true }
edition = { workspace = true }
repository = { workspace = true }
license = { workspace = true }
rust-version = { workspace = true }
homepage = 'https://github.com/bytecodealliance/wit-bindgen'
description = """
D bindings generator for WIT and the component model, typically used through the
`wit-bindgen-cli` crate.
"""

[lints]
workspace = true

[lib]
doctest = false
test = false

[dependencies]
wit-bindgen-core = { workspace = true }
wit-component = { workspace = true }
wasm-encoder = { workspace = true }
wasm-metadata = { workspace = true }
anyhow = { workspace = true }
heck = { workspace = true }
clap = { workspace = true, optional = true }
indexmap = { workspace = true }

[features]
clap = ['dep:clap', 'wit-bindgen-core/clap']
1 change: 1 addition & 0 deletions crates/d/LICENSE-APACHE
1 change: 1 addition & 0 deletions crates/d/LICENSE-Apache-2.0_WITH_LLVM-exception
1 change: 1 addition & 0 deletions crates/d/LICENSE-MIT
47 changes: 47 additions & 0 deletions crates/d/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# `wit-bindgen` D Bindings Generator

This tool generates [D](https://dlang.org) bindings for a chosen WIT world.

## Usage

To generate bindings with this crate, issue the `d` subcommand to `wit-bindgen`:

```bash
$ wit-bindgen d [OPTIONS] <WIT>
```

See the output of `wit-bindgen help d` for available options.

## Output Structure

Running `wit-bindgen d` on a WIT world will produce a full package structure mirroring the organization of the WIT world and the interfaces it uses. The default output directory and root package are both `wit`.

`wit.common` holds some definitions used across the generated bindings (for e.g. `result`, `option`, `list`, etc.).

The generated file for the world will by default, `public import` all relavent definitions. More selective imports can be made by importing the appropriate modules corresponding to particular interfaces.

The module for the world `foo:bar/world` will be placed in `wit/foo/bar/world/package.d`. Anonymous interface import and exports for the world will emitted in `wit/foo/bar/world/{imports|exports}`.

Top-level interfaces will be output similarly to worlds. `foo:bar/interface` gets split across multiple modules in `wit/foo/bar/interface/*.d`. Type definitions that are agnostic to import or export (any records, tuples, lists, etc. that do not contain resource handles) will go in `/common.d`. Function imports and import-specific types go in `/imports.d`, and exports go in `/exports.d`

## Memory/Resource Management

Currently, all imports take in parameters as "borrowing" and return memory "owning", with some caveats due to resource handles.

Memory is managed on the C `malloc` heap. This assumption can be used in some cases to reduce copies when unecessary.

When giving parameters to imports, any `list` or `string` memory is NOT freed, and the caller retains ownership/responibility for it. However, the ownership rules of WIT mean that any owning resource handles are invalidated. The bindings will not automatically "consume" these for you, and you will have to zero them out (default init) yourself after the call to prevent double-free.

When receiving parameters to exports, `list` and `string` memory is automatically freed. You must copy this memory elsewhere to retain it past the end of the call. Resource handles are not dropped however, and BOTH owning and borrowing handles (e.g. `Res` and `Res.Borrow`) must be dropped. To drop a handle, use `witDrop`.

When receiving values from imports, you are in charge of freeing the memory and dropping resource handles after you are finished with it/them. `witFree` deeply frees all such memory, and `witDrop` is also deep.

When return values from exports, all memory must be on the WIT/C heap, so it can be reliably `free`d by the bindings. `witClone` deeply copies all `list`s and `string`s.

`scope(exit)` is a valuable tool in helping keep track of this.

In the future, changes may be made to help make this more automatic.

## Examples

It is recommended to peruse `tests/runtime` to find concrete examples of how to use the bindings.
Loading
Loading