Dummy structure for the rust example

This commit is contained in:
Olivier Goffart 2020-05-11 20:39:16 +02:00
parent f3deea066b
commit dc33cbbcda
7 changed files with 72 additions and 10 deletions

View file

@ -5,6 +5,8 @@ members = [
'sixtyfps_compiler',
'sixtyfps_compiler/parser_test_macro',
'api/sixtyfps-rs',
'api/sixtyfps-rs/sixtyfps-rs-macro',
'examples/graphicstest',
'examples/rusttest',
'helper_crates/const-field-offset',
]

View file

@ -1,5 +1,5 @@
[package]
name = "sixtyfps-rs"
name = "sixtyfps"
version = "0.1.0"
authors = ["Sixty FPS <info@sixtyfps.io>"]
edition = "2018"
@ -7,6 +7,5 @@ edition = "2018"
[lib]
path = "lib.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
sixtyfps-rs-macro= { path = "sixtyfps-rs-macro" }

View file

@ -1,7 +1 @@
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}
pub use sixtyfps_rs_macro::sixtyfps;

View 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"

View 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()
}

View 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" }

View 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();
}