Skip to content

Commit b0b9e45

Browse files
authored
gen-markdown: Print world information, and tidy up formatting (#496)
- Start the output with the world name, world documentation, and a table of contents for the world. - Don't print type sizes and alignments, or flags bit numbers. A full description of the canonical ABI may be a useful thing to have, but the current document isn't really close to being that. As user-facing API documentation, it's confusing to have type sizes and alignments because these won't even be correct in some bindings. - Print function return value names, and call them return values, to avoid confusion with "result" which is a type. - Adjust various formatting details.
1 parent 1846165 commit b0b9e45

File tree

5 files changed

+208
-110
lines changed

5 files changed

+208
-110
lines changed

crates/bindgen-core/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ mod tests {
441441
pub trait WorldGenerator {
442442
fn generate(&mut self, resolve: &Resolve, id: WorldId, files: &mut Files) {
443443
let world = &resolve.worlds[id];
444-
self.preprocess(resolve, &world.name);
444+
self.preprocess(resolve, id);
445445

446446
let mut funcs = Vec::new();
447447
let mut types = Vec::new();
@@ -473,9 +473,9 @@ pub trait WorldGenerator {
473473
self.finish(resolve, id, files);
474474
}
475475

476-
fn preprocess(&mut self, resolve: &Resolve, name: &str) {
476+
fn preprocess(&mut self, resolve: &Resolve, world: WorldId) {
477477
drop(resolve);
478-
drop(name);
478+
drop(world);
479479
}
480480

481481
fn import_interface(

crates/gen-guest-c/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ enum Scalar {
6868
}
6969

7070
impl WorldGenerator for C {
71-
fn preprocess(&mut self, resolve: &Resolve, name: &str) {
71+
fn preprocess(&mut self, resolve: &Resolve, world: WorldId) {
72+
let name = &resolve.worlds[world].name;
7273
self.world = name.to_string();
7374
self.sizes.fill(resolve);
7475
}

crates/gen-guest-rust/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl RustWasm {
112112
}
113113

114114
impl WorldGenerator for RustWasm {
115-
fn preprocess(&mut self, resolve: &Resolve, _name: &str) {
115+
fn preprocess(&mut self, resolve: &Resolve, _world: WorldId) {
116116
self.types.analyze(resolve);
117117
}
118118

crates/gen-guest-teavm-java/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ impl TeaVmJava {
8181
}
8282

8383
impl WorldGenerator for TeaVmJava {
84-
fn preprocess(&mut self, resolve: &Resolve, name: &str) {
84+
fn preprocess(&mut self, resolve: &Resolve, world: WorldId) {
85+
let name = &resolve.worlds[world].name;
8586
self.name = name.to_string();
8687
self.sizes.fill(resolve);
8788
}

0 commit comments

Comments
 (0)