Commit graph

177 commits

Author SHA1 Message Date
Olivier Goffart
009addf9b4 Logical operations and comparisons and unary operators 2020-06-29 18:40:37 +02:00
Olivier Goffart
c4b1feeea0 Parse Equality opreration
(Code generation still missing)
2020-06-29 18:40:37 +02:00
Simon Hausmann
f7517f403c Make the color a valid property type
This replaces Property<u32> with Property<Color>
2020-06-26 21:46:37 +02:00
Olivier Goffart
d267039fa8 Put a pointer to the parent component in the component
This means we must use Rc for the component so we can use Weak for the parent pointer.

The idea is to get rid later of the context
2020-06-26 19:26:55 +02:00
Olivier Goffart
caca0d0ba4 Put the component in a Pin<>
Removed the drop and create from the ComponentVTable:
since we are not using VBox<ComponentVTable>, this simplifies a bit
the code of the interpreter and everything else.

But there is still a lot of changes everywhere to support that the Component
is pinned.
This is just for the component. Which would be required if later we want
to access the properties as Pin<Property<_>>. But we have not yet ability
to do projections
2020-06-24 14:13:27 +02:00
Olivier Goffart
1bb8d94ab8 Support array for model in rust and in the interpreter 2020-06-19 19:46:59 +02:00
Olivier Goffart
56a75a69e5 Move the repeater part that is specific to rust within the rust lib 2020-06-19 10:06:13 +02:00
Olivier Goffart
93dbc3b02d Parse array 2020-06-18 12:20:04 +02:00
Simon Hausmann
9df888578f Expose a ComponentWindow type in Rust
This comes with a factory function that re-directs to the backend and a
run member function to replace
sixtyfps_runtime_run_component_with_gl_renderer. For now it's all still
hidden in the generated run() method.
2020-06-17 19:15:18 +02:00
Olivier Goffart
6122f91fba Begin with the generation of rhe repeater (rust only for now) 2020-06-16 13:47:02 +02:00
Olivier Goffart
e9b75d30b7 Add a bunch of deny(unsafe_code) 2020-06-12 21:04:27 +02:00
Olivier Goffart
30b201d946 Reduce the use of unsafe in corelib and in the rust backend 2020-06-12 19:03:15 +02:00
Olivier Goffart
66dc643bf9 WIP: refactor the item visitor
The C++ part hasn't been ported yet and some things still need polish

Introduce a visitor to not rely on the unsafe ItemTreeNode array.
2020-06-12 13:32:40 +02:00
Olivier Goffart
8713c10d48 Color literals 2020-06-11 19:26:41 +02:00
Olivier Goffart
e95d7da888 Parser: typed syntax node accessor 2020-06-11 17:50:28 +02:00
Olivier Goffart
788137e3d5 Parser: allow to specify an index token in bracket in the for loop 2020-06-11 16:55:22 +02:00
Olivier Goffart
907bea3d3b Layout for rust 2020-06-10 19:41:24 +02:00
Olivier Goffart
96a372e45d Grid layout in the interpreter
current imploementation is just a prototype
2020-06-10 19:40:47 +02:00
Simon Hausmann
fdbef8c3c4 Add support for parsing conditional expression syntax 2020-06-10 15:40:27 +02:00
Simon Hausmann
1404cb73ae 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.
2020-06-09 22:54:29 +02:00
Simon Hausmann
5bae6e01a5 Prepare for the ability to embed image data
The Image's source property used to be a string. Now it is a Resource
enum, which can either be None or an absolute file path to the image on
disk. This also replaces the internal Image type.

The compiler internally resolves the img bang expression to a resource
reference, which shall remain just an absolute path. For now the target
generator passes that through, but in the future the target generator
may choose a target specific way of embedding the data and thus
generating a different Resource type in the final code (through
compile_expression in the cpp and rust generator).

The C++ binding is a bit messy as cbindgen doesn't really support
exporting enums that can be constructed on the C++ side. So instead we
use cbindgen to merely export the type internally and only use the tag
from it then. The public API is then a custom Resource type that is
meant to be binary compatible.
2020-06-09 22:54:29 +02:00
Simon Hausmann
afd7319ae5 Rename corelib to sixtyfps_corelib
This is consistent with the other packages and since corelib is now also
a cdylib, libsixtyfps_corelib.so looks much better than libcorelib.so
:-)
2020-06-09 13:27:18 +02:00
Olivier Goffart
d1febde6c7 Fix warning in the generated code 2020-06-08 10:07:17 +02:00
Simon Hausmann
318e65b1d4 Fix typo 2020-06-05 17:41:59 +02:00
Olivier Goffart
9fc60e104f Add another way to load .60 files from a build script 2020-06-05 13:45:38 +02:00
Olivier Goffart
0553ab8b1a Use env::var_os instead of env::var
For the unliekly case in which the git repository is checked out in a directory
that cannot be represented with unicode
2020-06-05 13:45:37 +02:00
Olivier Goffart
e6681a7087 Move the rust generator to the compiler lib 2020-06-05 10:54:22 +02:00
Olivier Goffart
3651885d87 Move the compiler binary in tools/
And rename sixtyfps_compiler to sixtyfps_compilerlib
2020-06-05 09:23:38 +02:00
Simon Hausmann
a2c5e66bee Rename gl renderer backend package
Use a full prefixed name (sixtyfps_rendering_backend_gl) to ensure that
the created static lib can be installed without file conflicts (libgl is
not a unique name).
2020-06-04 15:30:41 +02:00
Olivier Goffart
7b8df5ca9d Use interior mutability for the cache
So we do not need a mutable reference to the Component
2020-06-04 14:03:30 +02:00
Olivier Goffart
e4366efb67 Do not require the component to be static to show a window 2020-06-04 13:44:40 +02:00
Olivier Goffart
c024f97890 Viewer: use binding when needed 2020-05-30 17:42:17 +02:00
Olivier Goffart
5f01ec30ee Fix the viewer using generated rtti from a macro
One thing that needed to change is that we needed the vtable to be unique
2020-05-30 15:08:51 +02:00
Olivier Goffart
dc276290e9 Add support for self assignment (+=, -=, ...) 2020-05-28 17:02:06 +02:00
Simon Hausmann
993caa1cd4 Fix conversion from float to string in Rust frontend
Use as_str() to fix the compilation and call the macro with a bang :)
2020-05-28 15:20:30 +02:00
Simon Hausmann
97dc677854 Emit signal handler bindings and expressions for emitting signals in the Rust frontend 2020-05-28 15:20:30 +02:00
Simon Hausmann
a3892ea102 Emit declared signals in the rust frontend 2020-05-28 15:20:30 +02:00
Simon Hausmann
e227f8a46e Use both set() and set_binding() in the rust frontend
When an expression holds just a constant value, then we can avoid creating a binding.
2020-05-28 14:41:15 +02:00
Olivier Goffart
e86a7d3192 Merge signal and property declaration
A Signal is just a property of type Type::Signal

Simplifies the code a bit
2020-05-28 12:49:18 +02:00
Olivier Goffart
95b671c97c Support for code blocks and signal call 2020-05-28 12:30:08 +02:00
Simon Hausmann
f2df9293a9 Fix the C++ build
Remove the Optional from the evaluation context passing for property
evaluation. Unfortunately there are nullptr uses left on the C++ side,
that need to be replaced with passing through.
2020-05-28 12:07:11 +02:00
Simon Hausmann
4f9c53879b Implement property references as bindings in the Rust frontend 2020-05-28 11:37:59 +02:00
Olivier Goffart
250b0a2e5b Rust macro: get the right span for the diagnostics
Merge the features proc_macro_span and proc_macro_diagnostics, they are the same.
2020-05-27 18:37:45 +02:00
Olivier Goffart
486b2ab8f8 Do type checking and convert from number to string 2020-05-27 15:43:45 +02:00
Simon Hausmann
c8b64f5c4b Remove the lowering
The LoweredItem and LoweredComponent contained, in essence, the same
information as the Element and Component in object_tree. Since the
moving declarations pass moved everything to the root element and the
LoweredPropertyDeclarations have been removed as well, this is the last
step.
2020-05-27 14:45:35 +02:00
Simon Hausmann
32990e15e2 Remove LoweredPropertyDeclaration
This type that allowed indexing the property declarations in the hierarchy
to the properties moved to the root is not needed anymore.
For now a simple set remains in the LoweredItem to generate
correct accessor prefixes.
2020-05-27 11:13:58 +02:00
Simon Hausmann
0504ea566c Add support for declaring properties in Rust 2020-05-26 15:21:33 +02:00
Simon Hausmann
e77fe37568 Make it more convenient to deal with diagnostics in the Rust frontend
Provide a ToTokens implementation of Diagnostics by moving the code from the macro.
This makes it easier later to re-use the same logic to return
with diagnostics.
2020-05-26 15:17:18 +02:00
Olivier Goffart
36fb526811 Do inlining in a pass before the lowering 2020-05-26 15:10:27 +02:00
Olivier Goffart
4ea78134d8 Recactor the compiler so there are passes 2020-05-26 09:40:36 +02:00