Skip to content

Commit

Permalink
Update bindings accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
AlixANNERAUD committed Jul 6, 2024
1 parent 6a375d0 commit 4906751
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
5 changes: 3 additions & 2 deletions Modules/Bindings/Tests/File_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ fn Integration_test() {

Users::Initialize().expect("Failed to initialize users manager");

let Virtual_file_system = File_system::Initialize(Task::Manager_type::New())
.expect("Failed to initialize file system");
Task::Initialize().expect("Failed to initialize task manager");

let Virtual_file_system = File_system::Initialize().expect("Failed to initialize file system");

let Native_file_system = File_system_type::New().expect("Failed to create file system");

Expand Down
9 changes: 3 additions & 6 deletions Modules/Bindings/Tests/Task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ fn Integration_test() {
"../../../target/wasm32-unknown-unknown/release/File_system_bindings_WASM_test.wasm"
);

let Task_manager = Task::Manager_type::New();
Task::Initialize().expect("Failed to initialize task manager");

let (_Runtime, _Module, Instance) = Instantiate_test_environment(
Binary_buffer,
Task_bindings::New(Task_manager.clone()),
&Data_type::New(),
);
let (_Runtime, _Module, Instance) =
Instantiate_test_environment(Binary_buffer, Task_bindings::New(), &Data_type::New());

assert_eq!(
Instance.Call_export_function("Test_task", &vec![]).unwrap(),
Expand Down
18 changes: 8 additions & 10 deletions Modules/Bindings/src/Task.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::mem::MaybeUninit;

use Binding_tool::Bind_function_native;
use Task::{Error_type, Result_type, Task_identifier_type, Task_type};
use Virtual_machine::{Function_descriptors, Registrable_trait, Runtime_type};
Expand All @@ -12,20 +10,20 @@ impl Registrable_trait for Task_bindings {
}
}

impl Task_bindings {
pub fn New(Manager: Task::Manager_type) -> Self {
unsafe {
Task_manager.write(Manager);
}
impl Default for Task_bindings {
fn default() -> Self {
Self::New()
}
}

impl Task_bindings {
pub fn New() -> Self {
Self {}
}
}

static mut Task_manager: MaybeUninit<Task::Manager_type> = MaybeUninit::uninit();

fn Get_task_manager() -> &'static Task::Manager_type {
unsafe { Task_manager.assume_init_ref() }
Task::Get_instance().expect("Task manager not initialized")
}

const Task_bindings_functions: [Virtual_machine::Function_descriptor_type; 5] = Function_descriptors!(
Expand Down

0 comments on commit 4906751

Please sign in to comment.