-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add type collection pass to get more info about External types (#66)
According to [The Big O of Code Reviews](https://www.egorand.dev/the-big-o-of-code-reviews/), this is a O(_n_) change. This is a large diff, but most of the work is mechanical. 1. Allow the test-runner to initialize more than one C++ file. 2. Adding a lookup for `External` types so the templates have more detail about what the `External` (imported) types actually are. 3. Adding a `ext-types` fixture. The most interesting of these is the second: Before rendering any files, a pass is taken of all `ComponentInterface`s. Each type is collected, and added to a type map, keyed by module-path and name. When an external type is encountered later, the type map is consulted, and the actual type is used. This is to remove a deficiency in `Type::External`: the `ExternalKind` enum did not map completely onto a `Type`: before this change, it wasn't clear what sort of type was being imported, and so it was difficult/impossible to work out __how__ to import (`import { X }` vs `import { type X }`), or __what__ to import: `X` vs `XInterface`. This meant changing the `type_name`, `ffi_converter_name` and some other filter methods, necessitating __many__ template files. These changes can be largely skimmed over. The test also caught a runtime bug, which is also fixed in this PR: when a Rust trait is implemented by Rust, but exposed (as a typescript `interface`), this was erroring at runtime with a `UniffiStaleHandleError`. This is now fixed.
- Loading branch information
Showing
56 changed files
with
1,391 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[alias] | ||
xtask = "run --package xtask --" | ||
xtask = "--quiet run --package xtask --" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
crates/ubrn_bindgen/src/bindings/react_native/gen_cpp/templates/entrypoint.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// This file was autogenerated by some hot garbage in the `uniffi-bindgen-react-native` crate. | ||
// Trust me, you don't want to mess with it! | ||
|
||
// This template is only used when running `cargo xtask run`, i.e. when running `./scripts/run-tests.sh`. | ||
// It is an implementation of the `registerNatives` function which is used by the test-runner to dynamically | ||
// load the native modules without re-compiling the test-runner. | ||
// | ||
// Files generated with this template appear in the fixtures/{fixture}/generated/cpp directory, always called | ||
// `Entrypoint.cpp`, with a captilized `E` to ensure it does not collide with namespaces called "entrypoint". | ||
|
||
#include "registerNatives.h" | ||
|
||
{%- for m in modules %} | ||
#include "{{ m.hpp_filename() }}"; | ||
{%- endfor %} | ||
|
||
extern "C" void registerNatives(jsi::Runtime &rt, std::shared_ptr<react::CallInvoker> callInvoker) { | ||
{%- for m in modules %} | ||
{{ m.cpp_module() }}::registerModule(rt, callInvoker); | ||
{%- endfor %} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
crates/ubrn_bindgen/src/bindings/react_native/gen_cpp/templates/wrapper.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
crates/ubrn_bindgen/src/bindings/react_native/gen_typescript/external.rs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.