qtbridge-runtime 0.3.0

Qt Bridge: bridging code to be run in applications.
// Copyright (C) 2026 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only

use qtbridge_type_lib::QVariant;

/// # Safety
///
/// The C++ metaobject dispatch trusts an implementation to honor each slot's
/// and property's declared argument, return, and property types: it hands
/// `invoke_slot` raw `outputs` buffers sized to those types and reads them
/// back afterwards. A wrong-sized or wrong-typed write is undefined behavior
/// on the C++ side. Implementations are generated by `#[qobject]`. Must be
/// in sync with the `QMetaInfo` implementation.
#[doc(hidden)]
pub unsafe trait DispatchMetaCall {
    /// # Safety
    ///
    /// `inputs`/`outputs` are raw argument pointers from the C++ metaobject
    /// dispatch; the caller must guarantee they are valid and match the slot's
    /// declared argument and return types.
    unsafe fn invoke_slot(&self, slot_id: u32, inputs: &[*const u8], outputs: &[*mut u8]);
    /// # Safety
    ///
    /// Same raw-argument-pointer contract as [`invoke_slot`](DispatchMetaCall::invoke_slot).
    unsafe fn invoke_slot_mut(&mut self, slot_id: u32, inputs: &[*const u8], outputs: &[*mut u8]);
    /// # Safety
    ///
    /// The returned `QVariant` carries an untracked `QObject*` for
    /// `QObject`-backed properties. The caller must consume it and start
    /// tracking its state before the object can be droped by the registry;
    /// the C++ metaobject dispatch does so synchronously.
    unsafe fn read_property(&self, prop_id: u32) -> QVariant;
    /// # Safety
    ///
    /// For `QObject`-backed properties `value` carries a raw `QObject*` that
    /// is dereferenced. The caller must guarantee it holds a live, compatible
    /// `QObject`; the C++ metaobject dispatch does so (Qt type-checks writes).
    unsafe fn write_property(&mut self, prop_id: u32, value: &QVariant);
}