Skip to content

Commit

Permalink
Merge pull request #581 from lilizoey/fix/static-mut-safety
Browse files Browse the repository at this point in the history
Remove usage of `static mut`
  • Loading branch information
Bromeon authored Feb 4, 2024
2 parents 6243fc6 + fdf5ae0 commit b4a91a6
Show file tree
Hide file tree
Showing 10 changed files with 692 additions and 201 deletions.
2 changes: 1 addition & 1 deletion godot-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ codegen-lazy-fptrs = [
custom-godot = ["godot-ffi/custom-godot", "godot-codegen/custom-godot"]
double-precision = ["godot-codegen/double-precision"]
experimental-godot-api = ["godot-codegen/experimental-godot-api"]
experimental-threads = []
experimental-threads = ["godot-ffi/experimental-threads"]
trace = ["godot-ffi/trace"]

[dependencies]
Expand Down
8 changes: 4 additions & 4 deletions godot-core/src/builtin/meta/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub trait VarcallSignatureTuple: PtrcallSignatureTuple {
);

unsafe fn out_class_varcall(
method_bind: sys::GDExtensionMethodBindPtr,
method_bind: ClassMethodBind,
method_name: &'static str,
object_ptr: sys::GDExtensionObjectPtr,
maybe_instance_id: Option<InstanceId>, // if not static
Expand Down Expand Up @@ -74,7 +74,7 @@ pub trait PtrcallSignatureTuple {
);

unsafe fn out_class_ptrcall<Rr: PtrcallReturn<Ret = Self::Ret>>(
method_bind: sys::GDExtensionMethodBindPtr,
method_bind: ClassMethodBind,
method_name: &'static str,
object_ptr: sys::GDExtensionObjectPtr,
maybe_instance_id: Option<InstanceId>, // if not static
Expand Down Expand Up @@ -202,7 +202,7 @@ macro_rules! impl_varcall_signature_for_tuple {
let variant = Variant::from_var_sys_init(|return_ptr| {
let mut err = sys::default_call_error();
class_fn(
method_bind,
method_bind.0,
object_ptr,
variant_ptrs.as_ptr(),
variant_ptrs.len() as i64,
Expand Down Expand Up @@ -318,7 +318,7 @@ macro_rules! impl_ptrcall_signature_for_tuple {
];

let result = Rr::call(|return_ptr| {
class_fn(method_bind, object_ptr, type_ptrs.as_ptr(), return_ptr);
class_fn(method_bind.0, object_ptr, type_ptrs.as_ptr(), return_ptr);
});
result.unwrap_or_else(|err| return_error::<Self::Ret>(method_name, err))
}
Expand Down
6 changes: 1 addition & 5 deletions godot-core/src/init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

use godot_ffi as sys;

use std::cell;
use sys::GodotFfi;

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

let config = sys::GdextConfig {
tool_only_in_editor,
is_editor: cell::OnceCell::new(),
};
let config = sys::GdextConfig::new(tool_only_in_editor);

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

Expand Down
2 changes: 1 addition & 1 deletion godot-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub mod private {
let is_editor = || crate::engine::Engine::singleton().is_editor_hint();

global_config.tool_only_in_editor //.
&& *global_config.is_editor.get_or_init(is_editor)
&& global_config.is_editor_or_init(is_editor)
}

pub fn print_panic(err: Box<dyn std::any::Any + Send>) {
Expand Down
1 change: 1 addition & 0 deletions godot-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ custom-godot = ["godot-bindings/custom-godot"]
codegen-fmt = ["godot-codegen/codegen-fmt"]
codegen-lazy-fptrs = ["godot-codegen/codegen-lazy-fptrs"]
experimental-godot-api = ["godot-codegen/experimental-godot-api"]
experimental-threads = []
trace = []

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

0 comments on commit b4a91a6

Please sign in to comment.