Skip to content

Commit

Permalink
Fix TS index (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian authored Dec 9, 2023
1 parent 32513d0 commit 6085136
Show file tree
Hide file tree
Showing 18 changed files with 83 additions and 86 deletions.
14 changes: 7 additions & 7 deletions example/js/lib/api/index.d.ts

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

52 changes: 26 additions & 26 deletions feature_tests/js/api/index.d.ts

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

27 changes: 12 additions & 15 deletions tool/src/js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,25 @@ pub fn gen_bindings(
let mut all_types = util::get_all_custom_types(env);
all_types.sort_by_key(|t| t.1.name());

let header_exports: String = {
let mut buf = String::new();
for (_, custom_type) in &all_types {
writeln!(
buf,
"export {{ {0} }} from './{0}.mjs';",
custom_type.name()
)?;
}
buf
};

let index_ts = outs.entry("index.d.ts".to_string()).or_default();
writeln!(index_ts, "export {{ FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char }} from './diplomat-runtime.mjs';")?;
index_ts.write_str(&header_exports)?;
writeln!(
index_ts,
"export {{ FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char }} from './diplomat-runtime';"
)?;
for (_, custom_type) in &all_types {
let name = custom_type.name();
writeln!(index_ts, "export {{ {name} }} from './{name}';",)?;
}

let index_js = outs.entry("index.mjs".to_string()).or_default();
writeln!(
index_js,
"export {{ FFIError }} from './diplomat-runtime.mjs';"
)?;
index_js.write_str(&header_exports)?;
for (_, custom_type) in &all_types {
let name = custom_type.name();
writeln!(index_js, "export {{ {name} }} from './{name}.mjs';",)?;
}

for (in_path, custom_type) in &all_types {
let imports = Imports::new(custom_type, in_path, env);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: tool/src/js/conversions.rs
expression: out_texts.get(out).unwrap()
---
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs';
export { BorrowingOpaque } from './BorrowingOpaque.mjs';
export { BorrowingStruct } from './BorrowingStruct.mjs';
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime';
export { BorrowingOpaque } from './BorrowingOpaque';
export { BorrowingStruct } from './BorrowingStruct';

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
source: tool/src/js/conversions.rs
expression: out_texts.get(out).unwrap()
---
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs';
export { MyStruct } from './MyStruct.mjs';
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime';
export { MyStruct } from './MyStruct';

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
source: tool/src/js/conversions.rs
expression: out_texts.get(out).unwrap()
---
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs';
export { Point } from './Point.mjs';
export { PointTranspose } from './PointTranspose.mjs';
export { Scalar } from './Scalar.mjs';
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime';
export { Point } from './Point';
export { PointTranspose } from './PointTranspose';
export { Scalar } from './Scalar';

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: tool/src/js/conversions.rs
expression: out_texts.get(out).unwrap()
---
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs';
export { Line } from './Line.mjs';
export { Point } from './Point.mjs';
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime';
export { Line } from './Line';
export { Point } from './Point';

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: tool/src/js/structs.rs
expression: out_texts.get(out).unwrap()
---
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs';
export { MyStruct } from './MyStruct.mjs';
export { NonOpaqueStruct } from './NonOpaqueStruct.mjs';
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime';
export { MyStruct } from './MyStruct';
export { NonOpaqueStruct } from './NonOpaqueStruct';

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
source: tool/src/js/structs.rs
expression: out_texts.get(out).unwrap()
---
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs';
export { MyStruct } from './MyStruct.mjs';
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime';
export { MyStruct } from './MyStruct';

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
source: tool/src/js/structs.rs
expression: out_texts.get(out).unwrap()
---
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs';
export { MyStruct } from './MyStruct.mjs';
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime';
export { MyStruct } from './MyStruct';

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
source: tool/src/js/structs.rs
expression: out_texts.get(out).unwrap()
---
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs';
export { MyStruct } from './MyStruct.mjs';
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime';
export { MyStruct } from './MyStruct';

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
source: tool/src/js/structs.rs
expression: out_texts.get(out).unwrap()
---
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs';
export { MyStruct } from './MyStruct.mjs';
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime';
export { MyStruct } from './MyStruct';

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: tool/src/js/types.rs
expression: out_texts.get(out).unwrap()
---
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs';
export { MyOpaqueStruct } from './MyOpaqueStruct.mjs';
export { MyStruct } from './MyStruct.mjs';
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime';
export { MyOpaqueStruct } from './MyOpaqueStruct';
export { MyStruct } from './MyStruct';

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: tool/src/js/types.rs
expression: out_texts.get(out).unwrap()
---
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs';
export { MyOpaqueStruct } from './MyOpaqueStruct.mjs';
export { MyStruct } from './MyStruct.mjs';
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime';
export { MyOpaqueStruct } from './MyOpaqueStruct';
export { MyStruct } from './MyStruct';

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: tool/src/js/types.rs
expression: out_texts.get(out).unwrap()
---
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs';
export { MyOpaqueStruct } from './MyOpaqueStruct.mjs';
export { MyStruct } from './MyStruct.mjs';
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime';
export { MyOpaqueStruct } from './MyOpaqueStruct';
export { MyStruct } from './MyStruct';

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
source: tool/src/js/types.rs
expression: out_texts.get(out).unwrap()
---
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs';
export { MyStruct } from './MyStruct.mjs';
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime';
export { MyStruct } from './MyStruct';

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
source: tool/src/js/types.rs
expression: out_texts.get(out).unwrap()
---
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs';
export { MyStruct } from './MyStruct.mjs';
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime';
export { MyStruct } from './MyStruct';

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
source: tool/src/js/types.rs
expression: out_texts.get(out).unwrap()
---
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.mjs';
export { MyStruct } from './MyStruct.mjs';
export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime';
export { MyStruct } from './MyStruct';

0 comments on commit 6085136

Please sign in to comment.