-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rid-macro: adding export return types (#13)
This adds support for more return types for function exports via `#[rid::export]`. It contains some WIP for HashMap support as well. While working on that I realized that in order to send the `keys()` as a `Vec` it needs to be supported first. I added lots of tests which verify that the following export return types are now supported: ```rs Vec<&struct> Vec<&primitive> Vec<&String> Vec<&CString> Vec<&str> ``` In the case of vecs with a _string-like_ type the string value is not resolved until the item in the Vec is accessed in order to push out copying the data to convert to a `*const char` until the last possible moment. ```rs // owned u8, i8, u16, i16 .. u64, i64 bool // refererences &u8, &i8, &u16, &i16 .. &u64, &i64 &bool ``` ```rs String, CString &String, &CString, &str ``` They are sent as `*const char` to Dart. Enums are converted to `i8` when sent to Dart and serialized back into an enum on the Dart end. * rid-macro: hash map prepared - composite supports two inner types - hash map match branches added with todos - compiles and all tests pass * rid-macro: hash map rendering without access methods * rid-macro: organizing vec dart render in separate dir * rid-macro: renderable access trait and rendering hash map rust access * deps: upgrade cbindgen to v0.20.0 * rid-macro: ref respected for return type * rid-macro: fixed bool return type for exports * rid-macro: fixed string returns from export * rid-macro: using access type to distinguish return type render * test: adding todo app integration test * rid-macro: fix export Dart return type for enum * test: adding export tests for current status * rid-macro: export returning primitive refs * rid-macro: export for string refs including as_str() * rid-macro: fix numerous vec export issues - key to determine if vec access is needed fixed - vec type names fixed - now multiple vecs can be exported within the same app which was broken before * rid-macro: rust_type::dart_wrapper_rust_ident now returns string * rid-macro: vec to return type rendering - handling enums + struct separately - handling owned vs. referenced primitives * rid-macro: export supporting Vec<&enum> return * rid-macro: Vec<&String> via const char pointer * rid-macro: adding access_string_ref to utils module * rid-macro: removing snapshot assertions, covered by integration tests * rid-macro: Vec<&String> exported via vec of pointers - strings are resolved individually via access - this is more efficient as strings are only cloned + provided to dart when the vec items is accessed - to distinguish when to resolve strings immediately and render proper return type introduced a RustTypeContext * rid-macro: semi working Vec<&CString> solution - realized that CString isn't ffi safe, nor is str * rid-macro: simplifying access of `Vec<&String|&CString>` - now we immediately resolve to *const char * rid-macro: improved way to expose CString struct * rid-macro: handling Vec<&str> exports
- Loading branch information
Showing
81 changed files
with
2,555 additions
and
561 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,3 +1,6 @@ | ||
/target | ||
/.idea | ||
/**/.idea | ||
tests/dart/**/src/wip.rs | ||
tests/dart/export/test/wip.dart | ||
.vimrc |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,4 +1,6 @@ | ||
ROOT:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) | ||
test: | ||
cargo test --all | ||
cd $(ROOT)/tests/dart/field_access && $(MAKE) test-all | ||
cargo test --all && \ | ||
cd $(ROOT)/tests/dart/field_access && $(MAKE) test-all && \ | ||
cd $(ROOT)/tests/dart/export && $(MAKE) test-all && \ | ||
cd $(ROOT)/tests/dart/apps && $(MAKE) test-all |
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
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
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
Oops, something went wrong.