Commit graph

97 commits

Author SHA1 Message Date
Simon Hausmann
778c6c8cca Fix the C++ tests
Don't link against the corelib shared library anymore
2020-06-17 19:14:56 +02:00
Olivier Goffart
7bd186a159 Small fixups 2020-06-17 10:35:30 +02:00
Olivier Goffart
5cd4ed7347 Arithmetic operations 2020-06-16 19:04:03 +02:00
Olivier Goffart
e8c825b434 Add a test for embedded conditionals
Also fix the initialization of properties in C++, make them zero-initialized like in rust
2020-06-16 17:47:10 +02:00
Olivier Goffart
d7fe69ff74 Lookup the index from a repeater expression 2020-06-16 17:23:38 +02:00
Olivier Goffart
c940e8d734 Add missing files 2020-06-16 14:11:26 +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
58b450b7de Supress warning about unused variable and add a small test
No need to chack that the signal exist since `emit_signal` will
actually return an error in that case already, and this is not
possible to call emit_signal on a invalid signal from the public
API

The test is unrelated
2020-06-12 11:11:45 +02:00
Simon Hausmann
84d8eaa130 Add support for emitting signals for nodejs and the interpreter
This also enables the property and signal accessor test case for js.
2020-06-12 10:38:01 +02:00
Olivier Goffart
ef9d3963e4 Fix casting of conditional operator 2020-06-12 10:32:56 +02:00
Simon Hausmann
9a935bdd0f Provide convenience accessors for public signals in C++ and Rust
Typically their emission requires an evaluation context parameter.
Similar to properties, provide a public emitter function that takes care
of the context.

This also required two fixes in the compiler, in order to make the
following (as part of the test case) work:

    signal foo;
    foo => { ... }

    (1) Register declared signals before attempting to implement the
    connection handlers.
    (2) When looking up the signal property, not only look in the base
    type but also in the current type.
2020-06-11 21:05:52 +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
Simon Hausmann
ee1c879071 Extend the conditional expression test case to also test JS/interpreter
The property accessors already work nicely :-)
2020-06-11 15:52:44 +02:00
Simon Hausmann
0cf86dced2 Provide convenience accessors for public properties in C++
See parent commit for the rationale :-)
2020-06-11 15:45:16 +02:00
Simon Hausmann
be3d0ab369 Provide convenience accessors for public properties in C++
While properties declared in the root component are named as-is and
exposed as Property<T>, their get() function in particular is hard to
use because it requires an EvaluationContext as a parameter.

This patch adds get_foo() and set_foo() accessors for each public
property and hides the evaluation context business for the getter.

The added test uses this right away and adds missing test coverage for
the conditional expression.
2020-06-11 15:45:16 +02:00
Simon Hausmann
03bef6dba3 Fix casting with conditional expressions
The following scenario would fail compiling to C++ because we failed to
determine the return type of the conditional expression:

    Test := Rectangle {
        property<bool> condition;
        property<color> extra_color;
        color: condition ? root.extra_color : 4289374890;
    }

The type of the true branch would be color and the false branch would be
a float. Since they "disagree", ty() on the expression would return
Type::Invalid. This was temporarily worked around in the C++ generator
by always returning the type of the true branch, but that's wrong.

Instead this patch changes maybe_convert_to to apply the Cast expression
to the individual branches, placing the cast only to the numberic
literal and correcting the return value of ty() on the conditional
expression.
2020-06-11 13:38:24 +02:00
Olivier Goffart
0d4f370e95 Fix linking error in the tests
We also need to link against corelib
2020-06-10 19:53:06 +02:00
Olivier Goffart
96a372e45d Grid layout in the interpreter
current imploementation is just a prototype
2020-06-10 19:40:47 +02:00
Olivier Goffart
300cb26208 Rename the interpreter crate to sixtyfps_interpreter 2020-06-10 08:41:49 +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
547a732e33 Fix rebuild issues, part 10523
By setting RUSTFLAGS in the Cargo config we run into the situation that
when doing a host build, all rust files are compiled with the flags,
including build.rs. When cross-compiling, build.rs is not build with the
RUSTFLAGS specified. That makes kind of sense, but it also means that
all the build scripts are always recompiled when switching between a
target and a host build - and that applies to *all* packages, including
dependencies.

So short of a better solution, this patch removes the need to set
RUSTFLAGS. It was used to extract the system library dependencies for
the static library we'd create. Instead we're now building two shared
libraries and are linking against them. They contain the rust library
twice, so that's not really a desirable final state either, but
productivity wins right now :-)

It might make sense to go back to creating *one* shared library through
a dedicated crate and -- since 'pub extern "C"' functions are not
transitively exported, it may require re-exporting them by hand or using
some clever build trick perhaps.
2020-06-09 13:08:59 +02:00
Olivier Goffart
c05da294a1 Add GridLayout and Row
The compiler currently lowers them to nothing
2020-06-09 12:46:16 +02:00
Olivier Goffart
b7bc884447 Run the JS test without using npm install 2020-06-09 10:25:38 +02:00
Olivier Goffart
34931e58c0 Polishing of the documentation 2020-06-08 17:57:18 +02:00
Olivier Goffart
11ac0cfad0 Test for nodejs 2020-06-08 12:24:39 +02:00
Olivier Goffart
11a0e89827 Test framework: extract the cpp and rust snippets 2020-06-08 10:54:17 +02:00
Olivier Goffart
772f77b700 Rust test: generate a different file for each test
So that the file name show which test it cames from in case of error
2020-06-05 19:51:41 +02:00
Olivier Goffart
e18689af5c Test the rist frontend 2020-06-05 19:29:40 +02:00
Olivier Goffart
d0332fafbf Revert "Not-working Tests for the Rust frontend"
This reverts commit 87bce9c106688516ab66de3f81cc907bee0a8b9b.

Because it is not working
2020-06-05 19:04:07 +02:00
Olivier Goffart
9f6639631c Not-working Tests for the Rust frontend
This is not working because spawning cargo for each tests is too slow,
and cannot even re-use the same target directory because it would block
on the cargo lock file. and rebuild all the dependences because of
different flags
2020-06-05 19:04:07 +02:00
Simon Hausmann
d574a088a6 Remove unnecessary CARGO environment variable forwarding
In contrast to the others, this one seems to be universally set :)
2020-06-05 18:01:40 +02:00
Simon Hausmann
8b475440c6 Reduce build ping-pong due to system library extraction 2020-06-05 17:22:42 +02:00
Olivier Goffart
6adbf1a077 Test: Slightly better error output when the C++ code does not compile 2020-06-05 17:03:42 +02:00
Simon Hausmann
975d0603e6 Fix scopeguard API usage
This is more idiomatic and nicer :)
2020-06-05 16:53:31 +02:00
Simon Hausmann
2579d4e84c Don't exit the process if there's an issue with the C++ generator 2020-06-05 16:15:32 +02:00
Simon Hausmann
3aa0c94f83 Run tests through the interpreter as well, at least for instantiation. 2020-06-05 16:02:59 +02:00
Simon Hausmann
d20eec1b4e Pick up newly added test cases
Add all the directories of the tests to the watch list of cargo. Adding
a new file will change the mtime of the directory and trigger a rebuild
then.
2020-06-05 15:18:14 +02:00
Simon Hausmann
5a5ab27f70 Minor cleanups
* Remove the dependency to the rust frontend and library from the test
  driver. Tests are compiled and run as standalone programs.
* Add diagnostics for the initial cargo run for the dependencies.
2020-06-05 15:11:26 +02:00
Simon Hausmann
54b02d2b0d Change the test driver to use the rust test framework
Collect all tests are build time in build.rs and generate Rust code that
uses #[test] annotated functions. This gives nice reporting and the
ability to run individual tests.
2020-06-05 14:47:05 +02:00
Simon Hausmann
46d7aaa2cb WIP 2020-06-05 14:11:29 +02:00
Simon Hausmann
31da762245 Complete compilation and running of .60 to mapped c++ tests
* Fix text-file-busy error when running the binary by replacing the use
  of named temp file with simply using the input source file and the
  extension replaced. A scope guard make sure to also delete the binary.
* Fix hard-coded library dependencies by sharing code with the cmake
  xtask that needs the same list.
2020-06-05 13:30:13 +02:00
Simon Hausmann
a69594530f First step towards compiling the generated C++ in the test driver
This extracts a compiler command line from the cc crate, runs the
compiler and tries to run the resulting binary. Unfortunately the latter
fails still.
2020-06-05 11:08:05 +02:00
Simon Hausmann
19a2777aec Fix build 2020-06-05 09:28:09 +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
3d1064f2e8 Separate the C++ bits into a separate module 2020-06-05 09:00:49 +02:00
Simon Hausmann
8624566e5c Add boilerplate for new testing harness
The objective is to have a bunch of .60 files with annotations inside
and the test harness picks them up and runs them through the Rust and
C++ frontend.
2020-06-05 08:56:16 +02:00