Skip to content

Commit b4a91a6

Browse files
authored
Merge pull request #581 from lilizoey/fix/static-mut-safety
Remove usage of `static mut`
2 parents 6243fc6 + fdf5ae0 commit b4a91a6

File tree

10 files changed

+692
-201
lines changed

10 files changed

+692
-201
lines changed

godot-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ codegen-lazy-fptrs = [
1818
custom-godot = ["godot-ffi/custom-godot", "godot-codegen/custom-godot"]
1919
double-precision = ["godot-codegen/double-precision"]
2020
experimental-godot-api = ["godot-codegen/experimental-godot-api"]
21-
experimental-threads = []
21+
experimental-threads = ["godot-ffi/experimental-threads"]
2222
trace = ["godot-ffi/trace"]
2323

2424
[dependencies]

godot-core/src/builtin/meta/signature.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub trait VarcallSignatureTuple: PtrcallSignatureTuple {
3939
);
4040

4141
unsafe fn out_class_varcall(
42-
method_bind: sys::GDExtensionMethodBindPtr,
42+
method_bind: ClassMethodBind,
4343
method_name: &'static str,
4444
object_ptr: sys::GDExtensionObjectPtr,
4545
maybe_instance_id: Option<InstanceId>, // if not static
@@ -74,7 +74,7 @@ pub trait PtrcallSignatureTuple {
7474
);
7575

7676
unsafe fn out_class_ptrcall<Rr: PtrcallReturn<Ret = Self::Ret>>(
77-
method_bind: sys::GDExtensionMethodBindPtr,
77+
method_bind: ClassMethodBind,
7878
method_name: &'static str,
7979
object_ptr: sys::GDExtensionObjectPtr,
8080
maybe_instance_id: Option<InstanceId>, // if not static
@@ -202,7 +202,7 @@ macro_rules! impl_varcall_signature_for_tuple {
202202
let variant = Variant::from_var_sys_init(|return_ptr| {
203203
let mut err = sys::default_call_error();
204204
class_fn(
205-
method_bind,
205+
method_bind.0,
206206
object_ptr,
207207
variant_ptrs.as_ptr(),
208208
variant_ptrs.len() as i64,
@@ -318,7 +318,7 @@ macro_rules! impl_ptrcall_signature_for_tuple {
318318
];
319319

320320
let result = Rr::call(|return_ptr| {
321-
class_fn(method_bind, object_ptr, type_ptrs.as_ptr(), return_ptr);
321+
class_fn(method_bind.0, object_ptr, type_ptrs.as_ptr(), return_ptr);
322322
});
323323
result.unwrap_or_else(|err| return_error::<Self::Ret>(method_name, err))
324324
}

godot-core/src/init/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
use godot_ffi as sys;
99

10-
use std::cell;
1110
use sys::GodotFfi;
1211

1312
use crate::builtin::{GString, StringName};
@@ -28,10 +27,7 @@ pub unsafe fn __gdext_load_library<E: ExtensionLibrary>(
2827
EditorRunBehavior::AllClasses => false,
2928
};
3029

31-
let config = sys::GdextConfig {
32-
tool_only_in_editor,
33-
is_editor: cell::OnceCell::new(),
34-
};
30+
let config = sys::GdextConfig::new(tool_only_in_editor);
3531

3632
sys::initialize(interface_or_get_proc_address, library, config);
3733

godot-core/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub mod private {
8181
let is_editor = || crate::engine::Engine::singleton().is_editor_hint();
8282

8383
global_config.tool_only_in_editor //.
84-
&& *global_config.is_editor.get_or_init(is_editor)
84+
&& global_config.is_editor_or_init(is_editor)
8585
}
8686

8787
pub fn print_panic(err: Box<dyn std::any::Any + Send>) {

godot-ffi/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ custom-godot = ["godot-bindings/custom-godot"]
1212
codegen-fmt = ["godot-codegen/codegen-fmt"]
1313
codegen-lazy-fptrs = ["godot-codegen/codegen-lazy-fptrs"]
1414
experimental-godot-api = ["godot-codegen/experimental-godot-api"]
15+
experimental-threads = []
1516
trace = []
1617

1718
# TODO: get rid of paste and gensym, they are trivially implementable with proc-macros. Update cargo-deny.

0 commit comments

Comments
 (0)