-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to import Rust and C struct as .slint struct #1726
Comments
This would be great for instance when I want to derive Serialize and Deserialize for a struct that I'm using in a slint file. |
It's useful,can use it by slint 0.3.1? |
How will this work with interpreted Slint code ? |
The idea is that the compiler will load and parse the C /Rust file and extract the struct so that it works also in the preview/interpreter/... |
For rust, we can use the For C , i don't know if there is a library that does this already that we can use. Maybe we'd be good with a simple lexer and find the |
You could also use libclang rust bindings (like https://github.com/KyleMayes/clang-sys ) to do this. |
HI!
Where I have two crates: "project" which contains the application itself and "project-lib" which is a library that holds the business logic and the UI widgets in Slint (slint macro and/or .slint file). In the Slint/ directory, within slint macro or .slint file I can't use the business logic objects/structs. As you said, it will be awesome to import those structs as .slint structs. Also, accessing the methods of a struct so we can bind/alias a callback to an actual business logic function or just call that struct method:
Also, being able to cast structs, something like this:
For the above, I'm not sure about the syntax but I hope the idea is clear. |
Hopefully this is coming down the line. At the moment it is very cumbersome to redefine structs in Slint, and then have rust code to translate the native struct into the slint struct via callback. |
Something like (in slint)
The slint compiler would use the syn crate to parse the rust file, or some simple C parser to parse the header file.
The struct themselves needs to be Clone, Default, Eq (and equivalent in C ) and only have public fields of type that are understood by Slint (without typedef or use or stuff, as the parser will stay simple)
The text was updated successfully, but these errors were encountered: