mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-02 14:51:15 +00:00
Implement Component using vtable
(the C++ part not yet ported)
This commit is contained in:
parent
4b19818f6c
commit
fb691e0808
2 changed files with 8 additions and 5 deletions
|
@ -177,6 +177,8 @@ pub fn vtable(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|||
}
|
||||
// Remove pub, if any
|
||||
field.vis = Visibility::Inherited;
|
||||
// FIXME!!!
|
||||
field.vis = Visibility::Public(VisPublic{ pub_token: Default::default() });
|
||||
|
||||
let mut wrap_trait_call = None;
|
||||
if !has_self {
|
||||
|
|
|
@ -54,18 +54,19 @@ unsafe fn set_property<T: PropertyWriter>(ptr: *mut u8, e: &Expression) {
|
|||
T::write(ptr, e);
|
||||
}
|
||||
|
||||
unsafe extern "C" fn dummy_destroy(_: *const ComponentType, _: *mut ComponentImpl) {
|
||||
unsafe extern "C" fn dummy_destroy(_: *const ComponentVTable, _: *mut ComponentImpl) {
|
||||
panic!();
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
struct MyComponentType {
|
||||
ct: ComponentType,
|
||||
ct: ComponentVTable,
|
||||
it: Vec<corelib::abi::datastructures::ItemTreeNode>,
|
||||
}
|
||||
|
||||
unsafe extern "C" fn item_tree(
|
||||
c: *const ComponentType,
|
||||
c: *const ComponentVTable,
|
||||
i: *const ComponentImpl,
|
||||
) -> *const corelib::abi::datastructures::ItemTreeNode {
|
||||
(*(c as *const MyComponentType)).it.as_ptr()
|
||||
}
|
||||
|
@ -148,7 +149,7 @@ fn main() -> std::io::Result<()> {
|
|||
current_offset += rt.size;
|
||||
});
|
||||
|
||||
let t = ComponentType { create: None, destroy: dummy_destroy, item_tree };
|
||||
let t = ComponentVTable {/* create: None, */ drop: dummy_destroy, item_tree };
|
||||
let t = MyComponentType { ct: t, it: tree_array };
|
||||
|
||||
let mut my_impl = Vec::<u64>::new();
|
||||
|
@ -167,7 +168,7 @@ fn main() -> std::io::Result<()> {
|
|||
}
|
||||
|
||||
gl::sixtyfps_runtime_run_component_with_gl_renderer(
|
||||
&t as *const MyComponentType as *const ComponentType,
|
||||
&t as *const MyComponentType as *const ComponentVTable,
|
||||
std::ptr::NonNull::new(mem).unwrap().cast(),
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue