mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-03 07:04:34 +00:00
Dummy structure for the rust example
This commit is contained in:
parent
f3deea066b
commit
dc33cbbcda
7 changed files with 72 additions and 10 deletions
|
@ -5,6 +5,8 @@ members = [
|
||||||
'sixtyfps_compiler',
|
'sixtyfps_compiler',
|
||||||
'sixtyfps_compiler/parser_test_macro',
|
'sixtyfps_compiler/parser_test_macro',
|
||||||
'api/sixtyfps-rs',
|
'api/sixtyfps-rs',
|
||||||
|
'api/sixtyfps-rs/sixtyfps-rs-macro',
|
||||||
'examples/graphicstest',
|
'examples/graphicstest',
|
||||||
|
'examples/rusttest',
|
||||||
'helper_crates/const-field-offset',
|
'helper_crates/const-field-offset',
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "sixtyfps-rs"
|
name = "sixtyfps"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Sixty FPS <info@sixtyfps.io>"]
|
authors = ["Sixty FPS <info@sixtyfps.io>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
@ -7,6 +7,5 @@ edition = "2018"
|
||||||
[lib]
|
[lib]
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
sixtyfps-rs-macro= { path = "sixtyfps-rs-macro" }
|
||||||
|
|
|
@ -1,7 +1 @@
|
||||||
#[cfg(test)]
|
pub use sixtyfps_rs_macro::sixtyfps;
|
||||||
mod tests {
|
|
||||||
#[test]
|
|
||||||
fn it_works() {
|
|
||||||
assert_eq!(2 + 2, 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
13
api/sixtyfps-rs/sixtyfps-rs-macro/Cargo.toml
Normal file
13
api/sixtyfps-rs/sixtyfps-rs-macro/Cargo.toml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
[package]
|
||||||
|
name = "sixtyfps-rs-macro"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Sixty FPS <info@sixtyfps.io>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
proc-macro = true
|
||||||
|
path = "lib.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
quote = "1.0"
|
||||||
|
|
18
api/sixtyfps-rs/sixtyfps-rs-macro/lib.rs
Normal file
18
api/sixtyfps-rs/sixtyfps-rs-macro/lib.rs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
extern crate proc_macro;
|
||||||
|
use proc_macro::TokenStream;
|
||||||
|
use quote::quote;
|
||||||
|
|
||||||
|
#[proc_macro]
|
||||||
|
pub fn sixtyfps(_item: TokenStream) -> TokenStream {
|
||||||
|
quote!(
|
||||||
|
#[derive(Default)]
|
||||||
|
struct SuperSimple;
|
||||||
|
impl SuperSimple {
|
||||||
|
fn run(&self) {
|
||||||
|
println!("Hello world");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.into()
|
||||||
|
}
|
8
examples/rusttest/Cargo.toml
Normal file
8
examples/rusttest/Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[package]
|
||||||
|
name = "rusttest"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Sixty FPS <info@sixtyfps.io>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
sixtyfps = { path = "../../api/sixtyfps-rs" }
|
28
examples/rusttest/src/main.rs
Normal file
28
examples/rusttest/src/main.rs
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
// Using a macro for now. But there could be others ways to do that
|
||||||
|
sixtyfps::sixtyfps! {
|
||||||
|
SuperSimple = Rectangle {
|
||||||
|
color: white;
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
width: 100;
|
||||||
|
height: 100;
|
||||||
|
color: blue;
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
x: 100;
|
||||||
|
y: 100;
|
||||||
|
width: (100);
|
||||||
|
height: {100}
|
||||||
|
color: green;
|
||||||
|
}
|
||||||
|
Image {
|
||||||
|
x: 200;
|
||||||
|
y: 200;
|
||||||
|
source: "../graphicstest/logo.png";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
SuperSimple.run();
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue