Commit graph

97 commits

Author SHA1 Message Date
Olivier Goffart
8361ef4019 Start code egeneration for the two ways binding
This is only meant to include the cases in which the property are optimized.
Does not work yet for the dynamic component
2020-09-24 14:37:16 +02:00
Olivier Goffart
4981c3ca75 Some check for the two way bindings 2020-09-23 14:06:08 +02:00
Olivier Goffart
8561106a15 Fix $children when there are two levels of insertion 2020-09-22 17:39:51 +02:00
Olivier Goffart
d4e1bfe360 Fix using local exported components
Components need to be processed in source order.
Not exported last as it was before.
2020-09-17 09:09:38 +02:00
Olivier Goffart
1c8150cb35 One should not be able to instantiate structures 2020-09-16 18:38:08 +02:00
Olivier Goffart
e0ed5252a8 Parse type declaration
```
export Foo := {
    property <int> xxx;
}
```
2020-09-16 18:26:13 +02:00
Simon Hausmann
ad77896312 Change the way Text's default color is implemented
Instead of via an item constructor, implement support for default
bindings in the compiler.
2020-09-16 13:41:18 +02:00
Olivier Goffart
637a0e792c Some more progress in signal connection with arguments 2020-09-07 18:49:38 +02:00
Olivier Goffart
9f026c820d Parse declaration of signal with arguments 2020-09-07 17:41:24 +02:00
Olivier Goffart
9d405060e2 Parse object and array type 2020-09-03 07:43:20 +02:00
Olivier Goffart
59dbb610be Materialize fake properties such as layout width/height 2020-09-01 18:49:49 +02:00
Simon Hausmann
7976a4057f Improve handling of nested layouts
We support directly nested layouts, but we did not support indirect
nesting:

    GridLayout {
        Rectangle {
            l2 := GridLayout { ... }
        }
    }

This patch fixes that by detecting this scenario and merging the layout
info of the element (Rectangle) and the layout inside (l2). This makes
it much easier to create re-usable components that use layouts
themselves and allows placing them in layouts.
2020-08-28 15:06:14 +02:00
Simon Hausmann
c1aa4b28c6 Add support for children insertion points for components
Sometimes re-usable components need to act as containers that allow the
user to place other items inside. The component needs to be able to
control the placement of these user-provided elements. That is what the
new

    $children

expression inside elements does.
2020-08-28 15:05:21 +02:00
Olivier Goffart
58cdaeb8dd Update license header to mention that commertial option are available 2020-08-26 13:23:42 +02:00
Simon Hausmann
2823f32692 Apply license headers to all non-binary/non-json sources 2020-08-17 17:55:20 +02:00
Simon Hausmann
5b9c41b76b Add referenced image resources to the dependencies for the rust build 2020-08-07 13:35:44 +02:00
Olivier Goffart
2518af41b1 Fix for in a declared component 2020-08-04 18:51:39 +02:00
Olivier Goffart
283387bc44 Add the self and parent implicit id 2020-08-04 15:58:40 +02:00
Olivier Goffart
f02512f467 Allow to get the span of a binding 2020-07-28 18:02:23 +02:00
Olivier Goffart
def42ba3df Add reserved properties that every item has
These properties are materialized if used
2020-07-27 12:18:55 +02:00
Simon Hausmann
7aa7bd8492 Add support for exporting imports
This will allow us to break up the styles, so that one can have for example

    button.60
    checkbox.60

and finally widgets.60:

    import { Button } from "button.60";
    import { CheckBox } from "checkbox.60";
    export { Button, CheckBox };

and then the users have to only import "widgets.60";
2020-07-24 18:33:01 +02:00
Simon Hausmann
6c27451761 Begin separating builtin elements from the underlying types
This uses a NativeClass type in the registry to represent the underlying
Rust/C++ types.
2020-07-24 16:11:46 +02:00
Simon Hausmann
bd1c760eca Change object_tree::Document to take a syntax_nodes::Document
We're going to need the Document earlier on anyway for dependency
analysis.
2020-07-23 08:35:35 +02:00
Simon Hausmann
a9b0d84a72 Improve source file propagation
Instead of doing the SyntaxNodeWithSourceFile construction as late as
possible (in Document::from_node), we can do it as early as possible.
That'll reduce the chances of missing out the source file and prepares
for dependency loading just based on a SNWS :)

This also makes the source_file optional in the SNWS, but that's
consistent with what the diagnostics expect.
2020-07-22 16:10:02 +02:00
Simon Hausmann
3e21aafab9 Add support for direct export for convenience 2020-07-22 08:45:49 +02:00
Simon Hausmann
921a41b07c Add support for explicit exports from files
Using an ES module inspired syntax, this allows free naming and control
over exported names.
2020-07-22 08:40:30 +02:00
Olivier Goffart
a5985a3162 fix last commit 2020-07-21 19:10:19 +02:00
Olivier Goffart
bdea34d8c4 Generate an expression for states 2020-07-21 19:01:48 +02:00
Simon Hausmann
abe6888296 Collect proper per-file diagnostics in the compiler passes
When creating diagnostics in the passes, report them correctly in the
build diagnostics. There's no automated test yet, but it was manually
verified.
2020-07-21 15:27:41 +02:00
Simon Hausmann
26528a8e9c Keep track of the source file in the syntax tree
When going from the plain rowan::SyntaxNode tree to the syntax_nodes::*
elements, attach the source file and keep track of it from that point
on. That'll pave the way for proper multi-file diagnostics generated
later on from the passes, where we store syntax_nodes::* types.
2020-07-21 15:27:41 +02:00
Olivier Goffart
e486505bb6 Fix the rustwasm build
Somehow in this case, the repeated element stayed borrowed
2020-07-21 13:44:52 +02:00
Olivier Goffart
46ca98b159 Make sure to visit all the expressions in the different passes
Including the new expressions in the states
2020-07-21 13:30:04 +02:00
Olivier Goffart
d27bd60e45 Fix tests 2020-07-21 12:15:48 +02:00
Olivier Goffart
9d735d98cd Build the transitions tree and more flexible animations 2020-07-20 18:46:04 +02:00
Simon Hausmann
2055a2fbd7 Eliminate a few more span call sites
SyntaxToken supports Spanned and this appears to be equivalent to the manual span creation.
2020-07-20 16:12:40 +02:00
Simon Hausmann
f8c0eb0bd6 Prepare for passing passing more information from syntax node to diagnostics
Let the bulk of the push_error() calls take a Spanned trait impl, so
that we can pass node on the call sites. Then when later change the
underyling trait to pass something that can also provide the source file
and we don't have to change all call sites again.
2020-07-20 16:01:15 +02:00
Simon Hausmann
0cb59381e4 Fix type of PropertyDeclaration::type_location
In preparation for passing through the source file, avoid storing the Span
in the object tree and instead store the syntax node.
2020-07-20 15:36:17 +02:00
Olivier Goffart
c0fab1c3e9 More progress in states and transition parsing
Fill the object_tree with states, and part of the transition

Also make sure to duplicate animations properly in inlining
2020-07-20 15:04:06 +02:00
Simon Hausmann
e914715d88 Rename Diagnostics to FileDiagnostics
As this structure holds the diagnostics just for one file.
2020-07-16 18:25:42 +02:00
Simon Hausmann
3611d274eb Prepare type registry hierarchy for run-time extension
It should be possible to load multiple times into the same registry,
which will require interior mutability: While a loaded type has a
reference to the registry, a newly loaded type shall be added.
2020-07-16 14:59:09 +02:00
Simon Hausmann
2ac0805409 Minor cleanup
Don't need an accessor function in the Document for a public field. That said,
the choice of registry instance for the path "compilation" doesn't really matter,
as the lookup shall always end up
in the global registry.
2020-07-15 13:36:30 +02:00
Simon Hausmann
5b43962bb2 Split up TypeRegistry
For a .60 files the locally defined components are now stored in a separate
per-document TypeRegistry instance that falls back to the global registry
for lookups.
2020-07-15 13:09:43 +02:00
Simon Hausmann
38b605998c Fix build 2020-06-29 16:44:54 +02:00
Simon Hausmann
85ac4ad824 Generalize the handling of contextual elements
Certainly elements are only allowed as children of certain others, such
as Row only within GridLayout, for example. This patch implements this
constraint at type lookup type and allows removing "Row" from the
general list of types that can be instantiated anywhere.

This mechanism will also be used for path elements, in the future.
2020-06-29 15:43:55 +02:00
Olivier Goffart
19a8559d3f WIP: Conditional elements
The parsing part is implemented, but not the backend as it requires
non-const "models"
2020-06-29 15:03:09 +02:00
Simon Hausmann
ab697ab71d Parse animation declarations into the object tree
So

    animate x { ... }

is basically a short-hand for

    PropertyAnimation {
        ...
    }

    <magically associated that animation with x whenever x is changed>

We could also support a shared animation syntax in the future:

    blah := PropertyAnimation { ... }

    animate x with blah;
    animate y with blah;

This patch also adds a primitive PropertyAnimation struct, which will be
used by the generated code to collect the values specified in the .60
markup.
2020-06-24 17:43:48 +02:00
Olivier Goffart
d7fe69ff74 Lookup the index from a repeater expression 2020-06-16 17:23:38 +02:00
Olivier Goffart
56aad7f474 Fix looking up of 'id' so that we can't access inaccessible id 2020-06-16 16:04:38 +02:00
Olivier Goffart
81ce11ee8b Add a reference to the enclosing component in the element itself 2020-06-15 16:40:55 +02:00
Olivier Goffart
9adc55cd70 Partially revert the refactoring that changed the Element::children list
Put the information about RepeatedElement in an Option within the normlal Element
2020-06-15 13:42:11 +02:00