Releases: kzha0/deno-bindgen2
Releases · kzha0/deno-bindgen2
v1.0.0
This is the first public release of deno-bindgen2.
This release provides most of the features from the predecessor project deno_bindgen, along with some improvements:
- No code-generation-related artifacts in the compiled library. The original deno bindgen project statically embeds information about symbols as part of its typescript code generation/translation process. Although we may not fully understand its reason for, this process introduces some level of unnecessary bloat on the final binary. This would be concerning if, say, you're compiling a big project with many exported FFI symbols and functions.
deno-bindgen2handles things differently by parsing the whole source code directly to get data about what functions the user is trying to "export" over to FFI. This circumvents entirely the need to embed any redundant symbol information in the final binary. - Full source code parsing (through the
rustc -Zunpretty=expandedcommand). As mentioned above, deno-bindgen2 reads expanded version of user's source code to collect type information such as user-defined types, structs, and implement blocks. This allows deno-bindgen2 to handle cases of multiple implement blocks appearing in the code, and collate them under one JavaScript class during code generation/translation. - Optimized parser function and macro. deno-bindgen2 includes custom syn parser functions that optimize the way source code is read. Through this, it avoids redundant parsing and discarding of unused/irrelevant syntax tree nodes, leading to generally improved macro performance (although these gains are offsetted by the double compilation process involving the source code expansion and build command. This will be addressed in the future).
- Consistent representation of standard library types in TypeScript (through the
deno-bindgen2-utilslibrary).deno-bindgen2provides a common representation of the standard Rust types and data structures through a common utility library. This allows different deno FFI libraries to use the same set of standard Rust types for interoperability. It also provides some utilities for interacting with the underlying data structures, such as decoding Rust strings and chars into a JavaScript string (in the future, more types will be given support for these interactions).
Feature differences:
- Disallow assigning a
#[constructor]attribute on associated functions. One important difference between this project and the originaldeno_bindgenproject is that deno-bindgen2 prevents users from declaring an associated function as a constructor for a custom type or object. The reason for this is that the type representation of the utility library requires that the constructor function is consistent so it can properly provide inheritance of "Rust type" abstractions in TypeScript.