Skip to main content

qtbridge_runtime/
qmetainfo.rs

1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only
3
4use crate::DynamicMetaObjectBuilder;
5
6/// Describes the Rust-side additions to a QObject's meta-object: the
7/// signals, slots, and properties declared on the type.
8///
9/// Pure description: the realized meta-object and metatypes live on the
10/// proxy pair in [`crate::QObjectHolder`], since they chain to the concrete
11/// C++ proxy class.
12/// # Safety
13///
14/// [`build_dynamic_meta_type`](QMetaInfo::build_dynamic_meta_type) declares the
15/// argument, return, and property types the C++ metaobject sizes its dispatch
16/// buffers from. These must match what the paired [`DispatchMetaCall`] impl
17/// marshals, or the C++ dispatch reads/writes wrongly sized buffers (undefined
18/// behavior). Implementations are generated by `#[qobject]`. Must be
19/// in sync with the `DispatchMetaCall` implementation.
20#[doc(hidden)]
21pub unsafe trait QMetaInfo : 'static {
22    /// The class_name in the Qt meta-object system
23    fn class_name() -> &'static str {
24        std::any::type_name::<Self>()
25    }
26
27    /// This function takes the meta_obj_builder and builds a meta object
28    /// that contains all slots, signals and properties for the respective type.
29    /// This function is usually implemented by a macro.
30    fn build_dynamic_meta_type(meta_obj_builder: std::pin::Pin<&mut DynamicMetaObjectBuilder>);
31}