-
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow different class names in rust and Godot
There's an issue that two structs with the same name in different modules will conflict with each other when sent to Godot since only the struct name is considered. This resolves that by allowing the API user to manually change the name of the class as Godot understands it. This also improves the error message that occurs when theres are aliased classes. Future work may seek to catch this issue at compile time rather than at runtime. Relevant to #332
- Loading branch information
1 parent
0d4670f
commit 2ab8845
Showing
5 changed files
with
75 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use crate::framework::itest; | ||
use godot::prelude::*; | ||
|
||
pub mod dont_rename { | ||
use super::*; | ||
|
||
#[derive(GodotClass)] | ||
#[class(init, base = Node)] | ||
pub struct RepeatMe {} | ||
} | ||
|
||
pub mod rename { | ||
use super::*; | ||
|
||
#[derive(GodotClass)] | ||
#[class(init, base = Node, rename = NoRepeat)] | ||
pub struct RepeatMe {} | ||
} | ||
|
||
#[itest] | ||
fn renaming_changes_the_name() { | ||
// note: this test doesn't really fail; if it doesn't succeed, then | ||
// the runner hangs. I don't know how to solve that. | ||
assert!(dont_rename::RepeatMe::class_name() != rename::RepeatMe::class_name()); | ||
assert_eq!(dont_rename::RepeatMe::class_name().as_str(), "RepeatMe"); | ||
assert_eq!(rename::RepeatMe::class_name().as_str(), "NoRepeat"); | ||
} |
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
*/ | ||
|
||
mod base_test; | ||
mod class_rename_test; | ||
mod object_test; | ||
mod property_test; | ||
mod singleton_test; | ||
|