Commit graph

166 commits

Author SHA1 Message Date
Olivier Goffart
8d47b298b3 Make sure everything in the vtable crate is documented 2020-12-04 13:06:50 +01:00
Olivier Goffart
d85df00126 Fix cargo clippy warning on the vtable crate 2020-12-04 13:04:14 +01:00
Simon Hausmann
52aae34f94 Fix Deref for VRc<VTable, Dyn>
As outlined in commit 753ec83a05,
converting from a VRc<VT, X> to VRc<VT, Dyn> requires subsequent use of
the data_offset in order to determine the correct instance pointer.

This applies also to VRc's Deref implementation, which isn't used with
Dyn right now, but will be soon in order to determine the bare instance
address for item tree traversal.
2020-11-19 16:24:12 +01:00
Simon Hausmann
b94054855f Remove as_ptr member function from VRef
This reverts that part of commit
e5dfb3a4c0 since:

    * it's apparently not needed anymore
    * bad API for a type that also implements deref
2020-11-19 15:57:13 +01:00
Olivier Goffart
8dbd0828a4 Make the vtable test pass with cargo miri 2020-11-16 14:33:19 +01:00
Simon Hausmann
79bfa080c6 Fix crash of the online editor
Component's get_item_ref has a life time attached to it, and in the
interpreter we're having two vtable implementations, one for
ErasedComponentBox and another generated one. The approach with
as_pin_ref to transfer the lifetime to a reference to the trait object
for the other vtable isn't working because as_pin_ref consumes the VRef
and then takes the address of a temporary on the stack.

Short of a cleaner solution, this patch circumvents the second vtable
indirection and calls our extern "C" function directly.
2020-11-12 14:35:01 +01:00
Simon Hausmann
753ec83a05 Fix crash with VRc::borrow() on wasm32
When converting a Weak<VT, T> into Weak<VT, Dyn>, we were ignoring that
while T inside VRcInner may be at a certain offset to satisfy alignment,
the empty Dyn field may not and thus be at a different offset.

On wasm32 for example the compiler generated component struct has a
16-byte alignment, while the Dyn has none. So converting the Weak<VT,
Dyn> to a VRc<VT, Dyn> and then calling borrow() would use the wrong
instance pointer.

To fix this, this patch introduces an extra offset field that's
preserved during the casting and that's used for borrow() as well as
drop().
2020-11-12 11:04:56 +01:00
Olivier Goffart
7f66ca9584 Add a function in the ComponentVTable to get an ItemRef from an index
Needed to adjust vtable so it can work if the return type has a reference
2020-11-11 14:29:44 +01:00
Olivier Goffart
3194dd21ca Expose VRc to the C++ API
(Not yet in use in the code gen)
2020-11-10 12:43:19 +01:00
Olivier Goffart
a1f1fcb3a6 Use VRc<ComponentVTable> in the rust generated code 2020-11-09 14:58:37 +01:00
Olivier Goffart
7fbcb78606 vtable: change VRc and VWeak to add the concrete type as a parameter
... or `Dyn` if unkown.

So we can implement Deref for the concreate type.

Sicne Deref is implemented for VRc, all the method of VRc are now
associated function.
2020-11-06 11:50:31 +01:00
Olivier Goffart
270408d485 vtable::VRc: Add few comments and missing function found in review 2020-11-06 10:11:44 +01:00
Olivier Goffart
2c10daa6b2 Update helper_crates/vtable/macro/macro.rs
Co-authored-by: Simon Hausmann <simon.hausmann@sixtyfps.io>
2020-11-06 10:11:44 +01:00
Olivier Goffart
f852b0bb6a vtable: new VRc and VWeak pointer 2020-11-06 10:11:44 +01:00
Olivier Goffart
1138c9dbed Normalize the spelling of SixtyFPS 2020-10-13 07:48:55 +02:00
Simon Hausmann
e5dfb3a4c0 Implement basic focus handling
Similar to the mouse_grabber, we use a VisitChildrenResult field to
track the focus item within a component. Unlike the mouse grabber
however, it is set/cleared using dedicated focus events.

The key event now routes the key event directly to the focus item.

The focus can be requested via set_focus_item on a window, which the
TextItem does.
2020-09-25 10:43:47 +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
46911f60ee Minor doc fixes to the vtable crate 2020-08-25 16:22:07 +02:00
Olivier Goffart
697aa61a0c Some doc polish 2020-08-25 15:33:15 +02:00
Olivier Goffart
6a77142dec Add the version field for the vtable crate 2020-08-25 12:33:17 +02:00
Olivier Goffart
ea1f215367 Some polishinbg of the .toml files
- Give all the sixtyfps-* create a 0.0.1 version
 - Make sure that the internal dependences are using the exact same version
   (so "=0.0.1")
 - Add the description/homepage/repository fields in the .toml files
 - Set publish=false  to crates that are not meant to be published on crates.io
2020-08-24 16:28:11 +02:00
Olivier Goffart
cbeb982684 Use the FieldOffset struct from the upstream create 2020-08-24 11:20:38 +02:00
Simon Hausmann
7f1d9f5252 Commit correct license tags to Cargo.toml
For now that's GPL-3.0 only, but this can be changed :-)
2020-08-18 10:12:59 +02:00
Simon Hausmann
2823f32692 Apply license headers to all non-binary/non-json sources 2020-08-17 17:55:20 +02:00
Olivier Goffart
681f304768 Add a few Debug impl 2020-08-10 17:25:15 +02:00
Olivier Goffart
0a56912d0f Mouse grab in rust 2020-08-07 16:06:49 +02:00
Olivier Goffart
0b1648d891 Fix formating 2020-08-04 11:52:47 +02:00
Olivier Goffart
1bfd708784 Change the field_offsets() function to a FIELD_OFFSETS associated const 2020-08-03 16:04:55 +02:00
Olivier Goffart
86a85cf838 vtable: change #[offset] to #[field_offset]
And add a documentation for it
2020-08-03 11:26:48 +02:00
Olivier Goffart
00c32e9c6d vtable: remove the convinient type alias from the macro
If one really need them, they can be implemented by the user
2020-08-03 11:03:24 +02:00
Olivier Goffart
77cf1e1e83 Some documentation change following today review 2020-07-31 16:28:59 +02:00
Olivier Goffart
1b748792ad Visit the item as Pin
A preparation to have Property::get to take Pin<Self>
2020-06-25 18:50:20 +02:00
Simon Hausmann
c18861125d Small typo fix :-) 2020-06-25 14:22:10 +02:00
Olivier Goffart
f50a705e00 Add the #[pin] attribute to be able to project to the pinned item 2020-06-25 12:18:09 +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
30b201d946 Reduce the use of unsafe in corelib and in the rust backend 2020-06-12 19:03:15 +02:00
Olivier Goffart
bbb2b487b9 Implement a way to create a VRef for non static vtable 2020-06-12 17:09:51 +02:00
Olivier Goffart
34931e58c0 Polishing of the documentation 2020-06-08 17:57:18 +02:00
Simon Hausmann
5e7c6372fd Fix cross-compilation of vtable
syn/quote/proc-macro are not needed at run-time for the vtable use.
2020-06-08 13:00:55 +02:00
Olivier Goffart
0a48252702 Interpreter: implement the ComponentVTable properly
with the drop and construct function
2020-06-03 17:33:26 +02:00
Olivier Goffart
9c3dbe1a81 Small doc fixup to workaround rustdoc bug
https://github.com/rust-lang/rust/issues/45939
https://github.com/rust-lang/rust/issues/60543
2020-05-31 16:20:22 +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
8c39ada671 Add downcast method to VRef and VRefMut 2020-05-28 09:18:28 +02:00
Olivier Goffart
0f977cbb25 Some documentation fixes for item generated with #[vtable] 2020-05-22 12:38:55 +02:00
Olivier Goffart
bf3a0878b5 Add documentation for the vtable crate 2020-05-22 11:17:45 +02:00
Olivier Goffart
f4714f2f5b Add missing file 2020-05-18 16:00:18 +02:00
Olivier Goffart
07942da4bb vtable: introduce VOffset 2020-05-18 11:06:44 +02:00
Olivier Goffart
1addcad615 vtable: Fix the repr 2020-05-18 11:06:44 +02:00
Olivier Goffart
5a9cbaae66 vtable add support for field offset in the vtable 2020-05-18 11:06:44 +02:00
Olivier Goffart
aff3d7e14b vtable: add safe way to construct references 2020-05-18 11:06:44 +02:00