Add support for embedding resources in the rust generator

This is relatively straight-forward via a pass in the compiler to
collect the resources to embed and then use include_bytes! (once per
resource).

What's really annoying is that the rust resource enum can't store a
&'static [u8] because cbindgen doesn't represent that, probably because
the slice representation isn't guaranteed to stay as it is. So instead
this, for now, uses raw pointers.
This commit is contained in:
Simon Hausmann 2020-06-09 22:00:37 +02:00
parent 82a7c3e070
commit 1404cb73ae
15 changed files with 105 additions and 98 deletions

View file

@ -1,3 +1,3 @@
fn main() {
sixtyfps_build::compile("src/hello.60").unwrap();
sixtyfps_build::compile("../cpptest/hello.60").unwrap();
}

View file

@ -1,84 +0,0 @@
component TwoRectangle := Rectangle {
signal clicked;
Rectangle {
x: 50;
y: 50.;
width: 25;
height: 25;
color: red;
my_area := TouchArea {
width: 25;
height: 25;
clicked => { root.clicked() }
}
}
}
component ButtonRectangle := Rectangle {
property<string> button_text;
signal clicked;
width: 100;
height: 75;
TouchArea {
width: 100;
height: 75;
clicked => { root.clicked() }
}
Text {
x: 50;
y: 10;
text: button_text;
color: black;
}
}
Hello := Rectangle {
signal foobar;
property<int32> counter;
color: white;
TwoRectangle {
width: 100;
height: 100;
color: blue;
clicked => { foobar() }
}
Rectangle {
x: 100;
y: 100;
width: (100);
height: {100}
color: green;
Rectangle {
x: 50;
y: 50.;
width: 25;
height: 25;
color: yellow;
}
}
ButtonRectangle {
color: 4289374890;
x: 50;
y: 225;
clicked => { counter += 1 }
button_text: "+";
}
counter_label := Text { x: 100; y: 300; text: counter; color: black; }
ButtonRectangle {
color: 4289374890;
x: 50;
y: 350;
clicked => { counter -= 1 }
button_text: "-";
}
}