Rust: fix compilation if the slint code declares struct named core

This commit is contained in:
Olivier Goffart 2025-06-30 12:37:13 +02:00
parent a319fe4ce9
commit ac24e0274e
5 changed files with 52 additions and 42 deletions

View file

@ -49,7 +49,7 @@ pub struct ItemTreeVTable {
/// Note that the root item is at index 0, so passing 0 would visit the item under root (the children of root).
/// If you want to visit the root item, you need to pass -1 as an index.
pub visit_children_item: extern "C" fn(
core::pin::Pin<VRef<ItemTreeVTable>>,
::core::pin::Pin<VRef<ItemTreeVTable>>,
index: isize,
order: TraversalOrder,
visitor: VRefMut<ItemVisitorVTable>,
@ -57,17 +57,17 @@ pub struct ItemTreeVTable {
/// Return a reference to an item using the given index
pub get_item_ref: extern "C" fn(
core::pin::Pin<VRef<ItemTreeVTable>>,
::core::pin::Pin<VRef<ItemTreeVTable>>,
index: u32,
) -> core::pin::Pin<VRef<ItemVTable>>,
) -> ::core::pin::Pin<VRef<ItemVTable>>,
/// Return the range of indices below the dynamic `ItemTreeNode` at `index`
pub get_subtree_range:
extern "C" fn(core::pin::Pin<VRef<ItemTreeVTable>>, index: u32) -> IndexRange,
extern "C" fn(::core::pin::Pin<VRef<ItemTreeVTable>>, index: u32) -> IndexRange,
/// Return the `ItemTreeRc` at `subindex` below the dynamic `ItemTreeNode` at `index`
pub get_subtree: extern "C" fn(
core::pin::Pin<VRef<ItemTreeVTable>>,
::core::pin::Pin<VRef<ItemTreeVTable>>,
index: u32,
subindex: usize,
result: &mut vtable::VWeak<ItemTreeVTable, Dyn>,
@ -76,7 +76,7 @@ pub struct ItemTreeVTable {
/// Return the item tree that is defined by this `ItemTree`.
/// The return value is an item weak because it can be null if there is no parent.
/// And the return value is passed by &mut because ItemWeak has a destructor
pub get_item_tree: extern "C" fn(core::pin::Pin<VRef<ItemTreeVTable>>) -> Slice<ItemTreeNode>,
pub get_item_tree: extern "C" fn(::core::pin::Pin<VRef<ItemTreeVTable>>) -> Slice<ItemTreeNode>,
/// Return the node this ItemTree is a part of in the parent ItemTree.
///
@ -84,35 +84,36 @@ pub struct ItemTreeVTable {
/// And the return value is passed by &mut because ItemWeak has a destructor
/// Note that the returned value will typically point to a repeater node, which is
/// strictly speaking not an Item at all!
pub parent_node: extern "C" fn(core::pin::Pin<VRef<ItemTreeVTable>>, result: &mut ItemWeak),
pub parent_node: extern "C" fn(::core::pin::Pin<VRef<ItemTreeVTable>>, result: &mut ItemWeak),
/// This embeds this ItemTree into the item tree of another ItemTree
///
/// Returns `true` if this ItemTree was embedded into the `parent`
/// at `parent_item_tree_index`.
pub embed_component: extern "C" fn(
core::pin::Pin<VRef<ItemTreeVTable>>,
::core::pin::Pin<VRef<ItemTreeVTable>>,
parent: &VWeak<ItemTreeVTable>,
parent_item_tree_index: u32,
) -> bool,
/// Return the index of the current subtree or usize::MAX if this is not a subtree
pub subtree_index: extern "C" fn(core::pin::Pin<VRef<ItemTreeVTable>>) -> usize,
pub subtree_index: extern "C" fn(::core::pin::Pin<VRef<ItemTreeVTable>>) -> usize,
/// Returns the layout info for the root of the ItemTree
pub layout_info: extern "C" fn(core::pin::Pin<VRef<ItemTreeVTable>>, Orientation) -> LayoutInfo,
pub layout_info:
extern "C" fn(::core::pin::Pin<VRef<ItemTreeVTable>>, Orientation) -> LayoutInfo,
/// Returns the item's geometry (relative to its parent item)
pub item_geometry:
extern "C" fn(core::pin::Pin<VRef<ItemTreeVTable>>, item_index: u32) -> LogicalRect,
extern "C" fn(::core::pin::Pin<VRef<ItemTreeVTable>>, item_index: u32) -> LogicalRect,
/// Returns the accessible role for a given item
pub accessible_role:
extern "C" fn(core::pin::Pin<VRef<ItemTreeVTable>>, item_index: u32) -> AccessibleRole,
extern "C" fn(::core::pin::Pin<VRef<ItemTreeVTable>>, item_index: u32) -> AccessibleRole,
/// Returns the accessible property via the `result`. Returns true if such a property exists.
pub accessible_string_property: extern "C" fn(
core::pin::Pin<VRef<ItemTreeVTable>>,
::core::pin::Pin<VRef<ItemTreeVTable>>,
item_index: u32,
what: AccessibleStringProperty,
result: &mut SharedString,
@ -120,27 +121,27 @@ pub struct ItemTreeVTable {
/// Executes an accessibility action.
pub accessibility_action: extern "C" fn(
core::pin::Pin<VRef<ItemTreeVTable>>,
::core::pin::Pin<VRef<ItemTreeVTable>>,
item_index: u32,
action: &AccessibilityAction,
),
/// Returns the supported accessibility actions.
pub supported_accessibility_actions: extern "C" fn(
core::pin::Pin<VRef<ItemTreeVTable>>,
::core::pin::Pin<VRef<ItemTreeVTable>>,
item_index: u32,
) -> SupportedAccessibilityAction,
/// Add the `ElementName::id` entries of the given item
pub item_element_infos: extern "C" fn(
core::pin::Pin<VRef<ItemTreeVTable>>,
::core::pin::Pin<VRef<ItemTreeVTable>>,
item_index: u32,
result: &mut SharedString,
) -> bool,
/// Returns a Window, creating a fresh one if `do_create` is true.
pub window_adapter: extern "C" fn(
core::pin::Pin<VRef<ItemTreeVTable>>,
::core::pin::Pin<VRef<ItemTreeVTable>>,
do_create: bool,
result: &mut Option<WindowAdapterRc>,
),