Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SignalBuilder in place of manual Signal construction
- Loading branch information
Showing
12 changed files
with
125 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use crate::core_types::{GodotString, Variant}; | ||
use crate::export::{ClassBuilder, ExportInfo, NativeClass, PropertyUsage}; | ||
|
||
pub struct SignalBuilder<'a, C> { | ||
class_builder: &'a ClassBuilder<C>, | ||
name: GodotString, | ||
args: Vec<SignalArgument>, | ||
} | ||
|
||
impl<'a, C: NativeClass> SignalBuilder<'a, C> { | ||
pub(super) fn new(class_builder: &'a ClassBuilder<C>, name: &str) -> Self { | ||
Self { | ||
class_builder, | ||
name: GodotString::from(name), | ||
args: vec![], | ||
} | ||
} | ||
|
||
/// Add an argument for the signal. | ||
#[inline] | ||
pub fn arg(mut self, argument: SignalArgument) -> Self { | ||
self.args.push(argument); | ||
self | ||
} | ||
|
||
/// Finish registering the signal. | ||
#[inline] | ||
pub fn done(self) { | ||
self.class_builder.add_signal(Signal { | ||
name: self.name, | ||
args: self.args, | ||
}); | ||
} | ||
} | ||
|
||
pub(crate) struct Signal { | ||
pub name: GodotString, | ||
pub args: Vec<SignalArgument>, | ||
} | ||
|
||
pub struct SignalArgument { | ||
pub name: GodotString, | ||
pub default: Variant, | ||
pub export_info: ExportInfo, | ||
pub usage: PropertyUsage, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters