godot_core/builder/
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
8use std::marker::PhantomData;
9
10use crate::obj::GodotClass;
11
12mod method;
13
14/// Class builder to store state for registering a class with Godot.
15///
16/// In the future this will be used, but for now it's a dummy struct.
17pub struct ClassBuilder<C> {
18    _c: PhantomData<C>,
19}
20
21impl<C> ClassBuilder<C>
22where
23    C: GodotClass,
24{
25    pub(crate) fn new() -> Self {
26        Self { _c: PhantomData }
27    }
28
29    pub fn virtual_method<'cb, F>(
30        &'cb mut self,
31        name: &'cb str,
32        method: F,
33    ) -> MethodBuilder<'cb, C, F> {
34        MethodBuilder::new(self, name, method)
35    }
36}
37
38// ----------------------------------------------------------------------------------------------------------------------------------------------
39
40#[allow(dead_code)] // TODO rm
41#[must_use]
42pub struct MethodBuilder<'cb, C, F> {
43    class_builder: &'cb mut ClassBuilder<C>,
44    name: &'cb str,
45    method: F,
46}
47
48impl<'cb, C, F> MethodBuilder<'cb, C, F> {
49    pub(super) fn new(class_builder: &'cb mut ClassBuilder<C>, name: &'cb str, method: F) -> Self {
50        Self {
51            class_builder,
52            name,
53            method,
54        }
55    }
56
57    pub fn done(self) {}
58}