qtbridge_runtime/dispatchmetacall.rs
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only
3
4use qtbridge_type_lib::QVariant;
5
6/// # Safety
7///
8/// The C++ metaobject dispatch trusts an implementation to honor each slot's
9/// and property's declared argument, return, and property types: it hands
10/// `invoke_slot` raw `outputs` buffers sized to those types and reads them
11/// back afterwards. A wrong-sized or wrong-typed write is undefined behavior
12/// on the C++ side. Implementations are generated by `#[qobject]`. Must be
13/// in sync with the `QMetaInfo` implementation.
14#[doc(hidden)]
15pub unsafe trait DispatchMetaCall {
16 /// # Safety
17 ///
18 /// `inputs`/`outputs` are raw argument pointers from the C++ metaobject
19 /// dispatch; the caller must guarantee they are valid and match the slot's
20 /// declared argument and return types.
21 unsafe fn invoke_slot(&self, slot_id: u32, inputs: &[*const u8], outputs: &[*mut u8]);
22 /// # Safety
23 ///
24 /// Same raw-argument-pointer contract as [`invoke_slot`](DispatchMetaCall::invoke_slot).
25 unsafe fn invoke_slot_mut(&mut self, slot_id: u32, inputs: &[*const u8], outputs: &[*mut u8]);
26 /// # Safety
27 ///
28 /// The returned `QVariant` carries an untracked `QObject*` for
29 /// `QObject`-backed properties. The caller must consume it and start
30 /// tracking its state before the object can be droped by the registry;
31 /// the C++ metaobject dispatch does so synchronously.
32 unsafe fn read_property(&self, prop_id: u32) -> QVariant;
33 /// # Safety
34 ///
35 /// For `QObject`-backed properties `value` carries a raw `QObject*` that
36 /// is dereferenced. The caller must guarantee it holds a live, compatible
37 /// `QObject`; the C++ metaobject dispatch does so (Qt type-checks writes).
38 unsafe fn write_property(&mut self, prop_id: u32, value: &QVariant);
39}