Skip to content

Commit 443ede5

Browse files
committed
deprecate godot-4.1 & add 4.5
1 parent b3972e6 commit 443ede5

File tree

5 files changed

+27
-60
lines changed

5 files changed

+27
-60
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
RUSTFLAGS: "-D warnings"
2020
strategy:
2121
matrix:
22-
api_version: ["4-1", "4-2", "4-3", "4-4"]
22+
api_version: ["4-2", "4-3", "4-4", "4-5"]
2323

2424
steps:
2525
- name: Checkout
@@ -49,7 +49,7 @@ jobs:
4949
runs-on: "ubuntu-22.04"
5050
strategy:
5151
matrix:
52-
api_version: ["4-1", "4-2", "4-3", "4-4"]
52+
api_version: ["4-2", "4-3", "4-4", "4-5"]
5353

5454
steps:
5555
- name: Checkout
@@ -75,7 +75,7 @@ jobs:
7575
runs-on: "ubuntu-22.04"
7676
strategy:
7777
matrix:
78-
api_version: ["4-1", "4-2", "4-3", "4-4", "custom"]
78+
api_version: ["4-2", "4-3", "4-4", "4-5", "custom"]
7979

8080
steps:
8181
- name: Checkout

.github/workflows/nightly-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
RUSTFLAGS: "-D warnings"
1717
strategy:
1818
matrix:
19-
api_version: ["4-1", "4-2", "4-3", "4-4"]
19+
api_version: ["4-2", "4-3", "4-4", "4-5"]
2020

2121
steps:
2222
- name: Checkout

Cargo.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ version = "0.1.0"
1010
edition = "2021"
1111

1212
[workspace.dependencies]
13-
godot = { version = "0.4.0", features = ["experimental-threads"] }
14-
godot-cell = "0.4"
15-
godot-bindings = "0.4"
13+
godot = { version = ">=0.4.1", features = ["experimental-threads"] }
14+
godot-cell = "0.4.0"
15+
godot-bindings = "0.4.0"
1616
itertools = "0.10"
1717
rand = "0.8"
1818
darling = { version = "0.20" }

rust-script/src/static_script_registry.rs

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
*/
66

77
use std::borrow::Cow;
8-
use std::collections::{BTreeMap, HashMap};
8+
use std::collections::BTreeMap;
99
use std::fmt::Debug;
10-
use std::sync::{Arc, LazyLock, RwLock};
10+
use std::sync::Arc;
1111

1212
use godot::builtin::{GString, StringName};
1313
use godot::global::{MethodFlags, PropertyHint, PropertyUsageFlags};
@@ -208,7 +208,6 @@ pub fn assemble_metadata<'a>(
208208

209209
RustScriptMetaData::new(
210210
class.class_name,
211-
class.class_name_cstr,
212211
class.base_type_name.as_ref().into(),
213212
props,
214213
methods,
@@ -266,7 +265,7 @@ impl From<&RustScriptMethodInfo> for MethodInfo {
266265
Self {
267266
id: value.id,
268267
method_name: value.method_name.into(),
269-
class_name: ClassId::new_script(value.class_name, value.class_name_cstr),
268+
class_name: ClassId::__alloc_next_unicode(value.class_name),
270269
return_type: (&value.return_type).into(),
271270
arguments: value.arguments.iter().map(|arg| arg.into()).collect(),
272271
default_arguments: vec![],
@@ -317,10 +316,8 @@ pub struct RustScriptMetaData {
317316
}
318317

319318
impl RustScriptMetaData {
320-
#[expect(clippy::too_many_arguments)]
321319
pub fn new(
322320
class_name: &'static str,
323-
class_name_cstr: &'static std::ffi::CStr,
324321
base_type_name: StringName,
325322
properties: Box<[RustScriptPropertyInfo]>,
326323
methods: Box<[RustScriptMethodInfo]>,
@@ -329,7 +326,7 @@ impl RustScriptMetaData {
329326
description: &'static str,
330327
) -> Self {
331328
Self {
332-
class_name: ClassId::new_script(class_name, class_name_cstr),
329+
class_name: ClassId::__alloc_next_unicode(class_name),
333330

334331
base_type_name,
335332
properties,
@@ -384,51 +381,21 @@ where
384381
}
385382
}
386383

387-
static DYNAMIC_INDEX_BY_CLASS_NAME: LazyLock<RwLock<HashMap<&'static str, ClassId>>> =
388-
LazyLock::new(RwLock::default);
389-
390-
trait ClassNameExtension {
391-
fn new_script(str: &'static str, cstr: &'static std::ffi::CStr) -> Self;
392-
}
393-
394-
impl ClassNameExtension for ClassId {
395-
fn new_script(str: &'static str, cstr: &'static std::ffi::CStr) -> Self {
396-
// Check if class name exists.
397-
if let Some(name) = DYNAMIC_INDEX_BY_CLASS_NAME.read().unwrap().get(str) {
398-
return *name;
399-
}
400-
401-
let mut map = DYNAMIC_INDEX_BY_CLASS_NAME.write().unwrap();
402-
403-
let class_name = *map.entry(str).or_insert_with(|| {
404-
if str.is_ascii() {
405-
ClassId::__alloc_next_ascii(cstr)
406-
} else {
407-
ClassId::__alloc_next_unicode(str)
408-
}
409-
});
410-
411-
class_name
412-
}
413-
}
414-
415384
#[cfg(test)]
416385
mod tests {
417386
use godot::meta::ClassId;
418387

419-
use crate::static_script_registry::ClassNameExtension;
420-
421388
#[test]
422389
fn new_class_name() {
423-
let script_name = ClassId::new_script("TestScript", c"TestScript");
390+
let script_name = ClassId::__alloc_next_unicode("TestScript");
424391

425392
assert_eq!(script_name.to_cow_str(), "TestScript");
426393
}
427394

428395
#[cfg(since_api = "4.4")]
429396
#[test]
430397
fn new_unicode_class_name() {
431-
let script_name = ClassId::new_script("ÜbertragungsScript", c"ÜbertragungsScript");
398+
let script_name = ClassId::__alloc_next_unicode("ÜbertragungsScript");
432399

433400
assert_eq!(script_name.to_cow_str(), "ÜbertragungsScript");
434401
}

0 commit comments

Comments
 (0)