godot_core/registry/signal/
mod.rs

1/*
2 * Copyright (c) godot-rust; Bromeon and contributors.
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
6 */
7
8mod connect_builder;
9mod connect_handle;
10mod signal_object;
11mod signal_receiver;
12mod typed_signal;
13
14pub(crate) use connect_builder::*;
15pub(crate) use connect_handle::*;
16pub(crate) use signal_object::*;
17pub(crate) use typed_signal::*;
18
19use crate::builtin::{GString, Variant};
20use crate::meta;
21
22// Used in `godot` crate.
23pub mod re_export {
24    pub use super::connect_builder::ConnectBuilder;
25    pub use super::connect_handle::ConnectHandle;
26    pub use super::signal_receiver::{IndirectSignalReceiver, SignalReceiver};
27    pub use super::typed_signal::TypedSignal;
28}
29
30// Used in `godot::private` module.
31pub mod priv_re_export {
32    pub use super::signal_object::{
33        signal_collection_to_base, signal_collection_to_base_mut, UserSignalObject,
34    };
35}
36
37// ParamTuple re-exported in crate::meta.
38
39// ----------------------------------------------------------------------------------------------------------------------------------------------
40
41// Used by both `TypedSignal` and `ConnectBuilder`.
42fn make_godot_fn<Ps, F>(mut input: F) -> impl FnMut(&[&Variant]) -> Variant
43where
44    F: FnMut(Ps),
45    Ps: meta::InParamTuple,
46{
47    move |variant_args: &[&Variant]| {
48        let args = Ps::from_variant_array(variant_args);
49        input(args);
50        Variant::nil()
51    }
52}
53
54// Used by both `TypedSignal` and `ConnectBuilder`.
55fn make_callable_name<F>() -> GString {
56    // When using sys::short_type_name() in the future, make sure global "func" and member "MyClass::func" are rendered as such.
57    // PascalCase heuristic should then be good enough.
58
59    std::any::type_name::<F>().into()
60}