-
-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from godot-rust/feature/api-string-names
GDExtension catch-up: class registration via `StringName`
- Loading branch information
Showing
28 changed files
with
1,129 additions
and
458 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ name: Minimal CI | |
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
# branches: | ||
# - master | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,43 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
use godot_ffi as sys; | ||
|
||
use std::fmt::{Display, Formatter, Result as FmtResult}; | ||
|
||
use crate::builtin::*; | ||
use crate::obj::GodotClass; | ||
|
||
/// Utility to construct class names known at compile time. | ||
/// Cannot be a function since the backing string must be retained. | ||
#[derive(Eq, PartialEq, Hash, Clone, Debug)] | ||
pub struct ClassName { | ||
backing: StringName, | ||
} | ||
|
||
impl ClassName { | ||
pub fn new<T: GodotClass>() -> Self { | ||
Self { | ||
backing: StringName::from(T::CLASS_NAME), | ||
} | ||
} | ||
|
||
pub fn from_static(string: &'static str) -> Self { | ||
Self { | ||
backing: StringName::from(string), | ||
} | ||
} | ||
|
||
pub fn string_sys(&self) -> sys::GDNativeStringNamePtr { | ||
self.backing.string_sys() | ||
} | ||
} | ||
|
||
impl Display for ClassName { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { | ||
self.backing.fmt(f) | ||
} | ||
} |
Oops, something went wrong.