Skip to content

Conversation

@simlay
Copy link
Contributor

@simlay simlay commented Sep 29, 2023

Ideally this will close #34.

I'm trying out cargo-swift using cargo swift package -p ios -p macos -n LiveViewNativeCore I've added the steps from cargo-swift into our Makefile.toml.

@Bajix
Copy link
Contributor

Bajix commented Sep 29, 2023

The documentation for UniFFI has changed dramatically over the last 2 months and is worth revisiting. When Elle originally tried swift-bridge, UniFFI was without an async section in the guide book and the recommendation was to define types using a UDL file, but there is now procedural macro support and it is all kinds of awesomeness. Hopefully UniFFI is able to replace core-jetpack because JNI is truly awful to work with and lacks async support.

One thing to consider with UniFFI is that types wrapped in Arc by the constructor will need interior mutability. It should be possible to use qcell to provide mutability and in doing so it's conceivable Morph could also be used in a way that doesn't necessitate collecting patches by applying iteratively as to avoid heap allocations. The key here is that by separating the borrow-owner any Cursor that referenced a document could be held beyond the lifetime of the call to get the next patch so that the document editor can take a mutable borrow when otherwise the Cursor borrow would prevent this.

use inflector::Inflector;

fn main() {
uniffi::generate_scaffolding("src/lib.udl").unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you just ignored my input on this one. There are macros for this now; you're doing this in an outdated and harder to maintain way

error: *mut RustString,
) -> support::RustResult {
match dom::Document::parse_fragment_json(text.to_str()) {
match dom::Document::parse_fragment_json(text.to_str().to_string()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's really no need to use owned strings here

Copy link
Contributor

@KronicDeth KronicDeth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's some commented out code that should be removed, but otherwise everything looks fine.

Was there a reason you went with uniffi.toml type definitions instead of using the proc-macros from newer uniffi?

@simlay simlay force-pushed the simlay/34-uniffi-for-ffi branch from 26cb151 to f233919 Compare November 29, 2023 00:26
simlay and others added 3 commits November 28, 2023 20:47
* Replace github url

* Add pull_request trigger to CI

---------

Co-authored-by: simlay <simlay@users.noreply.github.com>
Co-authored-by: Sebastian Imlay <sebastian.imlay@gmail.com>
* Replace github url

* Add pull_request trigger to CI

---------

Co-authored-by: simlay <simlay@users.noreply.github.com>
Co-authored-by: Sebastian Imlay <sebastian.imlay@gmail.com>
author Sebastian Imlay <sebastian.imlay@gmail.com> 1701222784 -0500
committer Sebastian Imlay <sebastian.imlay@gmail.com> 1701222784 -0500

* Replace github url
* Add pull_request trigger to CI
* Rename Node::Element to Node::NodeElement
* swift and kotlin builds
* Add CI workflows for swift and kotlin

---------

Co-authored-by: simlay <simlay@users.noreply.github.com>
Co-authored-by: Sebastian Imlay <sebastian.imlay@gmail.com>
Co-authored-by: May Matyi <may@matyi.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LiveView Native Clients: FFI

4 participants