update edtion to 2024 and reworke lib unsfae functions

This commit is contained in:
Christoph Brandau
2025-11-15 22:16:49 +01:00
parent dd36949a63
commit e9eebc0dd3
3 changed files with 226 additions and 227 deletions
Generated
+1 -1
View File
@@ -26,7 +26,7 @@ checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]] [[package]]
name = "xMVMOpenApiWrapper" name = "xMVMOpenApiWrapper"
version = "0.1.2" version = "0.1.3"
dependencies = [ dependencies = [
"libloading", "libloading",
] ]
+5 -2
View File
@@ -1,7 +1,10 @@
[package] [package]
name = "xMVMOpenApiWrapper" name = "xMVMOpenApiWrapper"
version = "0.1.2" version = "0.1.3"
edition = "2021" edition = "2024"
description = "A Wrapper for the XMVM Open interface for Rust"
license = "AGPL-3.0"
repository = "https://git.cbsk-tech.de/Christoph/xMVMOpenApiWrapper"
publish = ["cbsk"] publish = ["cbsk"]
[dependencies] [dependencies]
+220 -224
View File
@@ -1,6 +1,6 @@
#![allow(non_snake_case)] #![allow(non_snake_case)]
use libloading::{ Library, Symbol }; use libloading::{Library, Symbol};
use std::path::{ Path, PathBuf }; use std::path::{Path, PathBuf};
/// Pointer to a UTF-16 string (wide char) terminated with `0`. /// Pointer to a UTF-16 string (wide char) terminated with `0`.
pub type PCWSTR = *const u16; pub type PCWSTR = *const u16;
@@ -256,21 +256,15 @@ type DisconnectFn = unsafe extern "C" fn() -> OpenReturnCodes;
type OpenProjectFn = unsafe extern "C" fn(PCWSTR) -> OpenReturnCodes; type OpenProjectFn = unsafe extern "C" fn(PCWSTR) -> OpenReturnCodes;
type CreateProjectFn = unsafe extern "C" fn(PCWSTR, PCWSTR) -> OpenReturnCodes; type CreateProjectFn = unsafe extern "C" fn(PCWSTR, PCWSTR) -> OpenReturnCodes;
type CreateProjectWithScalingFn = unsafe extern "C" fn(PCWSTR, PCWSTR, PCWSTR) -> OpenReturnCodes; type CreateProjectWithScalingFn = unsafe extern "C" fn(PCWSTR, PCWSTR, PCWSTR) -> OpenReturnCodes;
type CreateProjectWithScalingNcuNumberFn = unsafe extern "C" fn( type CreateProjectWithScalingNcuNumberFn =
PCWSTR, unsafe extern "C" fn(PCWSTR, PCWSTR, PCWSTR, u32) -> OpenReturnCodes;
PCWSTR,
PCWSTR,
u32
) -> OpenReturnCodes;
type SaveProjectFn = unsafe extern "C" fn() -> OpenReturnCodes; type SaveProjectFn = unsafe extern "C" fn() -> OpenReturnCodes;
type CloseProjectFn = unsafe extern "C" fn() -> OpenReturnCodes; type CloseProjectFn = unsafe extern "C" fn() -> OpenReturnCodes;
type BootControllerFn = unsafe extern "C" fn() -> OpenReturnCodes; type BootControllerFn = unsafe extern "C" fn() -> OpenReturnCodes;
type ShutdownControllerFn = unsafe extern "C" fn() -> OpenReturnCodes; type ShutdownControllerFn = unsafe extern "C" fn() -> OpenReturnCodes;
type ResetControllerFn = unsafe extern "C" fn() -> OpenReturnCodes; type ResetControllerFn = unsafe extern "C" fn() -> OpenReturnCodes;
type RegisterForEventsFn = unsafe extern "C" fn( type RegisterForEventsFn =
u32, unsafe extern "C" fn(u32, *const OpenEventMaskDefinition) -> OpenReturnCodes;
*const OpenEventMaskDefinition
) -> OpenReturnCodes;
type UnregisterEventsFn = unsafe extern "C" fn() -> OpenReturnCodes; type UnregisterEventsFn = unsafe extern "C" fn() -> OpenReturnCodes;
type WaitForEventsFn = unsafe extern "C" fn() -> OpenReturnCodes; type WaitForEventsFn = unsafe extern "C" fn() -> OpenReturnCodes;
type ContinueSimulationFn = unsafe extern "C" fn() -> OpenReturnCodes; type ContinueSimulationFn = unsafe extern "C" fn() -> OpenReturnCodes;
@@ -430,7 +424,7 @@ impl OpenApi {
} else { } else {
provided_path provided_path
}; };
let lib = Library::new(dll_path)?; let lib = unsafe { Library::new(dll_path)? };
// Extend the library's lifetime to 'static by leaking it. // Extend the library's lifetime to 'static by leaking it.
// (Alternatively: design OpenApi with lifetimes and avoid leaking.) // (Alternatively: design OpenApi with lifetimes and avoid leaking.)
let lib: &'static Library = Box::leak(Box::new(lib)); let lib: &'static Library = Box::leak(Box::new(lib));
@@ -441,15 +435,13 @@ impl OpenApi {
let disconnect = load_symbol::<DisconnectFn>(lib, b"disconnect")?; let disconnect = load_symbol::<DisconnectFn>(lib, b"disconnect")?;
let open_project = load_symbol::<OpenProjectFn>(lib, b"openProject")?; let open_project = load_symbol::<OpenProjectFn>(lib, b"openProject")?;
let create_project = load_symbol::<CreateProjectFn>(lib, b"createProject")?; let create_project = load_symbol::<CreateProjectFn>(lib, b"createProject")?;
let create_project_with_scaling = load_symbol::<CreateProjectWithScalingFn>( let create_project_with_scaling =
lib, load_symbol::<CreateProjectWithScalingFn>(lib, b"createProjectWithScaling")?;
b"createProjectWithScaling" let create_project_with_scaling_ncu_number = load_symbol::<
CreateProjectWithScalingNcuNumberFn,
>(
lib, b"createProjectWithScalingNCUNumber"
)?; )?;
let create_project_with_scaling_ncu_number =
load_symbol::<CreateProjectWithScalingNcuNumberFn>(
lib,
b"createProjectWithScalingNCUNumber"
)?;
let save_project = load_symbol::<SaveProjectFn>(lib, b"saveProject")?; let save_project = load_symbol::<SaveProjectFn>(lib, b"saveProject")?;
let close_project = load_symbol::<CloseProjectFn>(lib, b"closeProject")?; let close_project = load_symbol::<CloseProjectFn>(lib, b"closeProject")?;
let boot_controller = load_symbol::<BootControllerFn>(lib, b"bootController")?; let boot_controller = load_symbol::<BootControllerFn>(lib, b"bootController")?;
@@ -462,62 +454,36 @@ impl OpenApi {
let get_dictionary_id = load_symbol::<GetDictionaryIdFn>(lib, b"getDictionaryId")?; let get_dictionary_id = load_symbol::<GetDictionaryIdFn>(lib, b"getDictionaryId")?;
let register_watch = load_symbol::<RegisterWatchFn>(lib, b"registerWatch")?; let register_watch = load_symbol::<RegisterWatchFn>(lib, b"registerWatch")?;
let unregister_watch = load_symbol::<UnregisterWatchFn>(lib, b"unregisterWatch")?; let unregister_watch = load_symbol::<UnregisterWatchFn>(lib, b"unregisterWatch")?;
let get_dictionary_element_type = load_symbol::<GetDictionaryElementTypeFn>( let get_dictionary_element_type =
lib, load_symbol::<GetDictionaryElementTypeFn>(lib, b"getDictionaryElementType")?;
b"getDictionaryElementType" let read_unsigned_integer_64_bit_array =
)?; load_symbol::<ReadUnsignedInteger64BitArrayFn>(lib, b"readUnsignedInteger64BitArray")?;
let read_unsigned_integer_64_bit_array = load_symbol::<ReadUnsignedInteger64BitArrayFn>( let read_signed_integer_32_bit_array =
lib, load_symbol::<ReadSignedInteger32BitArrayFn>(lib, b"readSignedInteger32BitArray")?;
b"readUnsignedInteger64BitArray" let read_unsigned_integer_32_bit_array =
)?; load_symbol::<ReadUnsignedInteger32BitArrayFn>(lib, b"readUnsignedInteger32BitArray")?;
let read_signed_integer_32_bit_array = load_symbol::<ReadSignedInteger32BitArrayFn>( let read_unsigned_integer_16_bit_array =
lib, load_symbol::<ReadUnsignedInteger16BitArrayFn>(lib, b"readUnsignedInteger16BitArray")?;
b"readSignedInteger32BitArray" let read_unsigned_integer_8_bit_array =
)?; load_symbol::<ReadUnsignedInteger8BitArrayFn>(lib, b"readUnsignedInteger8BitArray")?;
let read_unsigned_integer_32_bit_array = load_symbol::<ReadUnsignedInteger32BitArrayFn>(
lib,
b"readUnsignedInteger32BitArray"
)?;
let read_unsigned_integer_16_bit_array = load_symbol::<ReadUnsignedInteger16BitArrayFn>(
lib,
b"readUnsignedInteger16BitArray"
)?;
let read_unsigned_integer_8_bit_array = load_symbol::<ReadUnsignedInteger8BitArrayFn>(
lib,
b"readUnsignedInteger8BitArray"
)?;
let read_bool_array = load_symbol::<ReadBoolArrayFn>(lib, b"readBoolArray")?; let read_bool_array = load_symbol::<ReadBoolArrayFn>(lib, b"readBoolArray")?;
let read_double_array = load_symbol::<ReadDoubleArrayFn>(lib, b"readDoubleArray")?; let read_double_array = load_symbol::<ReadDoubleArrayFn>(lib, b"readDoubleArray")?;
let read_string = load_symbol::<ReadStringFn>(lib, b"readString")?; let read_string = load_symbol::<ReadStringFn>(lib, b"readString")?;
let read_string_array = load_symbol::<ReadStringArrayFn>(lib, b"readStringArray")?; let read_string_array = load_symbol::<ReadStringArrayFn>(lib, b"readStringArray")?;
let read_unsigned_integer_16_bit = load_symbol::<ReadUnsignedInteger16BitFn>( let read_unsigned_integer_16_bit =
lib, load_symbol::<ReadUnsignedInteger16BitFn>(lib, b"readUnsignedInteger16Bit")?;
b"readUnsignedInteger16Bit" let read_signed_integer_16_bit =
)?; load_symbol::<ReadSignedInteger16BitFn>(lib, b"readSignedInteger16Bit")?;
let read_signed_integer_16_bit = load_symbol::<ReadSignedInteger16BitFn>( let read_unsigned_integer_32_bit =
lib, load_symbol::<ReadUnsignedInteger32BitFn>(lib, b"readUnsignedInteger32Bit")?;
b"readSignedInteger16Bit" let read_signed_integer_32_bit =
)?; load_symbol::<ReadSignedInteger32BitFn>(lib, b"readSignedInteger32Bit")?;
let read_unsigned_integer_32_bit = load_symbol::<ReadUnsignedInteger32BitFn>( let read_unsigned_integer_64_bit =
lib, load_symbol::<ReadUnsignedInteger64BitFn>(lib, b"readUnsignedInteger64Bit")?;
b"readUnsignedInteger32Bit" let read_signed_integer_64_bit =
)?; load_symbol::<ReadSignedInteger64BitFn>(lib, b"readSignedInteger64Bit")?;
let read_signed_integer_32_bit = load_symbol::<ReadSignedInteger32BitFn>( let get_num_array_elements =
lib, load_symbol::<GetNumArrayElementsFn>(lib, b"getNumArrayElements")?;
b"readSignedInteger32Bit"
)?;
let read_unsigned_integer_64_bit = load_symbol::<ReadUnsignedInteger64BitFn>(
lib,
b"readUnsignedInteger64Bit"
)?;
let read_signed_integer_64_bit = load_symbol::<ReadSignedInteger64BitFn>(
lib,
b"readSignedInteger64Bit"
)?;
let get_num_array_elements = load_symbol::<GetNumArrayElementsFn>(
lib,
b"getNumArrayElements"
)?;
let read_bit = load_symbol::<ReadBitFn>(lib, b"readBit")?; let read_bit = load_symbol::<ReadBitFn>(lib, b"readBit")?;
let read_bool = load_symbol::<ReadBoolFn>(lib, b"readBool")?; let read_bool = load_symbol::<ReadBoolFn>(lib, b"readBool")?;
let read_byte = load_symbol::<ReadByteFn>(lib, b"readByte")?; let read_byte = load_symbol::<ReadByteFn>(lib, b"readByte")?;
@@ -526,10 +492,8 @@ impl OpenApi {
let read_double_word = load_symbol::<ReadDoubleWordFn>(lib, b"readDoubleWord")?; let read_double_word = load_symbol::<ReadDoubleWordFn>(lib, b"readDoubleWord")?;
let read_long_word = load_symbol::<ReadLongWordFn>(lib, b"readLongWord")?; let read_long_word = load_symbol::<ReadLongWordFn>(lib, b"readLongWord")?;
let read_next_event = load_symbol::<ReadNextEventFn>(lib, b"readNextEvent")?; let read_next_event = load_symbol::<ReadNextEventFn>(lib, b"readNextEvent")?;
let read_next_event_with_ncu_index = load_symbol::<ReadNextEventWithNcuIndexFn>( let read_next_event_with_ncu_index =
lib, load_symbol::<ReadNextEventWithNcuIndexFn>(lib, b"readNextEventWithNcuIndex")?;
b"readNextEventWithNcuIndex"
)?;
let write_bit = load_symbol::<WriteBitFn>(lib, b"writeBit")?; let write_bit = load_symbol::<WriteBitFn>(lib, b"writeBit")?;
let write_bool = load_symbol::<WriteBoolFn>(lib, b"writeBool")?; let write_bool = load_symbol::<WriteBoolFn>(lib, b"writeBool")?;
let write_byte = load_symbol::<WriteByteFn>(lib, b"writeByte")?; let write_byte = load_symbol::<WriteByteFn>(lib, b"writeByte")?;
@@ -549,34 +513,20 @@ impl OpenApi {
let delete_directory = load_symbol::<DeleteDirectoryFn>(lib, b"deleteDirectory")?; let delete_directory = load_symbol::<DeleteDirectoryFn>(lib, b"deleteDirectory")?;
let create_directory = load_symbol::<CreateDirectoryFn>(lib, b"createDirectory")?; let create_directory = load_symbol::<CreateDirectoryFn>(lib, b"createDirectory")?;
let list_directory = load_symbol::<ListDirectoryFn>(lib, b"listDirectory")?; let list_directory = load_symbol::<ListDirectoryFn>(lib, b"listDirectory")?;
let get_version_information = load_symbol::<GetVersionInformationFn>( let get_version_information =
lib, load_symbol::<GetVersionInformationFn>(lib, b"getVersionInformation")?;
b"getVersionInformation" let get_project_information =
)?; load_symbol::<GetProjectInformationFn>(lib, b"getProjectInformation")?;
let get_project_information = load_symbol::<GetProjectInformationFn>( let get_current_project_information =
lib, load_symbol::<GetCurrentProjectInformationFn>(lib, b"getCurrentProjectInformation")?;
b"getProjectInformation" let get_current_project_state =
)?; load_symbol::<GetCurrentProjectStateFn>(lib, b"getCurrentProjectState")?;
let get_current_project_information = load_symbol::<GetCurrentProjectInformationFn>( let import_project_settings =
lib, load_symbol::<ImportProjectSettingsFn>(lib, b"importProjectSettings")?;
b"getCurrentProjectInformation" let export_project_settings =
)?; load_symbol::<ExportProjectSettingsFn>(lib, b"exportProjectSettings")?;
let get_current_project_state = load_symbol::<GetCurrentProjectStateFn>( let write_unsigned_integer_8_bit_array =
lib, load_symbol::<WriteUnsignedInteger8BitArrayFn>(lib, b"writeUnsignedInteger8BitArray")?;
b"getCurrentProjectState"
)?;
let import_project_settings = load_symbol::<ImportProjectSettingsFn>(
lib,
b"importProjectSettings"
)?;
let export_project_settings = load_symbol::<ExportProjectSettingsFn>(
lib,
b"exportProjectSettings"
)?;
let write_unsigned_integer_8_bit_array = load_symbol::<WriteUnsignedInteger8BitArrayFn>(
lib,
b"writeUnsignedInteger8BitArray"
)?;
let get_number_of_ncus = load_symbol::<GetNumberOfNcusFn>(lib, b"getNumberOfNCUs")?; let get_number_of_ncus = load_symbol::<GetNumberOfNcusFn>(lib, b"getNumberOfNCUs")?;
Ok(Self { Ok(Self {
@@ -658,36 +608,36 @@ impl OpenApi {
} }
#[inline] #[inline]
pub unsafe fn start_application(&self, str_profile_file_name: PCWSTR) -> OpenReturnCodes { pub unsafe fn start_application(&self, str_profile_file_name: PCWSTR) -> OpenReturnCodes {
(self.start_application)(str_profile_file_name) unsafe { (self.start_application)(str_profile_file_name) }
} }
#[inline] #[inline]
pub unsafe fn stop_application(&self) -> OpenReturnCodes { pub unsafe fn stop_application(&self) -> OpenReturnCodes {
(self.stop_application)() unsafe { (self.stop_application)() }
} }
#[inline] #[inline]
pub unsafe fn connect(&self) -> OpenReturnCodes { pub unsafe fn connect(&self) -> OpenReturnCodes {
(self.connect)() unsafe { (self.connect)() }
} }
#[inline] #[inline]
pub unsafe fn disconnect(&self) -> OpenReturnCodes { pub unsafe fn disconnect(&self) -> OpenReturnCodes {
(self.disconnect)() unsafe { (self.disconnect)() }
} }
#[inline] #[inline]
pub unsafe fn open_project(&self, str_file_name: PCWSTR) -> OpenReturnCodes { pub unsafe fn open_project(&self, str_file_name: PCWSTR) -> OpenReturnCodes {
(self.open_project)(str_file_name) unsafe { (self.open_project)(str_file_name) }
} }
#[inline] #[inline]
pub unsafe fn create_project( pub unsafe fn create_project(
&self, &self,
str_file_name: PCWSTR, str_file_name: PCWSTR,
str_version: PCWSTR str_version: PCWSTR,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.create_project)(str_file_name, str_version) unsafe { (self.create_project)(str_file_name, str_version) }
} }
#[inline] #[inline]
@@ -695,9 +645,9 @@ impl OpenApi {
&self, &self,
str_file_name: PCWSTR, str_file_name: PCWSTR,
str_version: PCWSTR, str_version: PCWSTR,
str_nck_scaling: PCWSTR str_nck_scaling: PCWSTR,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.create_project_with_scaling)(str_file_name, str_version, str_nck_scaling) unsafe { (self.create_project_with_scaling)(str_file_name, str_version, str_nck_scaling) }
} }
#[inline] #[inline]
@@ -706,95 +656,97 @@ impl OpenApi {
str_file_name: PCWSTR, str_file_name: PCWSTR,
str_version: PCWSTR, str_version: PCWSTR,
str_nck_scaling: PCWSTR, str_nck_scaling: PCWSTR,
ncu_number: u32 ncu_number: u32,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.create_project_with_scaling_ncu_number)( unsafe {
str_file_name, (self.create_project_with_scaling_ncu_number)(
str_version, str_file_name,
str_nck_scaling, str_version,
ncu_number str_nck_scaling,
) ncu_number,
)
}
} }
#[inline] #[inline]
pub unsafe fn save_project(&self) -> OpenReturnCodes { pub unsafe fn save_project(&self) -> OpenReturnCodes {
(self.save_project)() unsafe { (self.save_project)() }
} }
#[inline] #[inline]
pub unsafe fn close_project(&self) -> OpenReturnCodes { pub unsafe fn close_project(&self) -> OpenReturnCodes {
(self.close_project)() unsafe { (self.close_project)() }
} }
#[inline] #[inline]
pub unsafe fn boot_controller(&self) -> OpenReturnCodes { pub unsafe fn boot_controller(&self) -> OpenReturnCodes {
(self.boot_controller)() unsafe { (self.boot_controller)() }
} }
#[inline] #[inline]
pub unsafe fn shutdown_controller(&self) -> OpenReturnCodes { pub unsafe fn shutdown_controller(&self) -> OpenReturnCodes {
(self.shutdown_controller)() unsafe { (self.shutdown_controller)() }
} }
#[inline] #[inline]
pub unsafe fn reset_controller(&self) -> OpenReturnCodes { pub unsafe fn reset_controller(&self) -> OpenReturnCodes {
(self.reset_controller)() unsafe { (self.reset_controller)() }
} }
#[inline] #[inline]
pub unsafe fn register_for_events( pub unsafe fn register_for_events(
&self, &self,
event_list_length: u32, event_list_length: u32,
event_list: *const OpenEventMaskDefinition event_list: *const OpenEventMaskDefinition,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.register_for_events)(event_list_length, event_list) unsafe { (self.register_for_events)(event_list_length, event_list) }
} }
#[inline] #[inline]
pub unsafe fn unregister_events(&self) -> OpenReturnCodes { pub unsafe fn unregister_events(&self) -> OpenReturnCodes {
(self.unregister_events)() unsafe { (self.unregister_events)() }
} }
#[inline] #[inline]
pub unsafe fn wait_for_events(&self) -> OpenReturnCodes { pub unsafe fn wait_for_events(&self) -> OpenReturnCodes {
(self.wait_for_events)() unsafe { (self.wait_for_events)() }
} }
#[inline] #[inline]
pub unsafe fn continue_simulation(&self) -> OpenReturnCodes { pub unsafe fn continue_simulation(&self) -> OpenReturnCodes {
(self.continue_simulation)() unsafe { (self.continue_simulation)() }
} }
#[inline] #[inline]
pub unsafe fn get_dictionary_id( pub unsafe fn get_dictionary_id(
&self, &self,
dictionary_element: PCWSTR, dictionary_element: PCWSTR,
dictionary_id: *mut u32 dictionary_id: *mut u32,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.get_dictionary_id)(dictionary_element, dictionary_id) unsafe { (self.get_dictionary_id)(dictionary_element, dictionary_id) }
} }
#[inline] #[inline]
pub unsafe fn register_watch( pub unsafe fn register_watch(
&self, &self,
watch_list_length: u32, watch_list_length: u32,
dictionary_id_list: *const u32 dictionary_id_list: *const u32,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.register_watch)(watch_list_length, dictionary_id_list) unsafe { (self.register_watch)(watch_list_length, dictionary_id_list) }
} }
#[inline] #[inline]
pub unsafe fn unregister_watch(&self) -> OpenReturnCodes { pub unsafe fn unregister_watch(&self) -> OpenReturnCodes {
(self.unregister_watch)() unsafe { (self.unregister_watch)() }
} }
#[inline] #[inline]
pub unsafe fn get_dictionary_element_type( pub unsafe fn get_dictionary_element_type(
&self, &self,
dictionary_id: u32, dictionary_id: u32,
value: *mut u8 value: *mut u8,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.get_dictionary_element_type)(dictionary_id, value) unsafe { (self.get_dictionary_element_type)(dictionary_id, value) }
} }
#[inline] #[inline]
@@ -802,9 +754,15 @@ impl OpenApi {
&self, &self,
dictionary_id: u32, dictionary_id: u32,
value_list_max_length: u32, value_list_max_length: u32,
value_list: *mut u64 value_list: *mut u64,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.read_unsigned_integer_64_bit_array)(dictionary_id, value_list_max_length, value_list) unsafe {
(self.read_unsigned_integer_64_bit_array)(
dictionary_id,
value_list_max_length,
value_list,
)
}
} }
#[inline] #[inline]
@@ -812,9 +770,15 @@ impl OpenApi {
&self, &self,
dictionary_id: u32, dictionary_id: u32,
value_list_max_length: u32, value_list_max_length: u32,
value_list: *mut i32 value_list: *mut i32,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.read_signed_integer_32_bit_array)(dictionary_id, value_list_max_length, value_list) unsafe {
(self.read_signed_integer_32_bit_array)(
dictionary_id,
value_list_max_length,
value_list,
)
}
} }
#[inline] #[inline]
@@ -822,9 +786,15 @@ impl OpenApi {
&self, &self,
dictionary_id: u32, dictionary_id: u32,
value_list_max_length: u32, value_list_max_length: u32,
value_list: *mut u32 value_list: *mut u32,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.read_unsigned_integer_32_bit_array)(dictionary_id, value_list_max_length, value_list) unsafe {
(self.read_unsigned_integer_32_bit_array)(
dictionary_id,
value_list_max_length,
value_list,
)
}
} }
#[inline] #[inline]
@@ -832,9 +802,15 @@ impl OpenApi {
&self, &self,
dictionary_id: u32, dictionary_id: u32,
value_list_max_length: u32, value_list_max_length: u32,
value_list: *mut u16 value_list: *mut u16,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.read_unsigned_integer_16_bit_array)(dictionary_id, value_list_max_length, value_list) unsafe {
(self.read_unsigned_integer_16_bit_array)(
dictionary_id,
value_list_max_length,
value_list,
)
}
} }
#[inline] #[inline]
@@ -842,9 +818,15 @@ impl OpenApi {
&self, &self,
dictionary_id: u32, dictionary_id: u32,
value_list_max_length: u32, value_list_max_length: u32,
value_list: *mut u8 value_list: *mut u8,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.read_unsigned_integer_8_bit_array)(dictionary_id, value_list_max_length, value_list) unsafe {
(self.read_unsigned_integer_8_bit_array)(
dictionary_id,
value_list_max_length,
value_list,
)
}
} }
#[inline] #[inline]
@@ -852,9 +834,9 @@ impl OpenApi {
&self, &self,
dictionary_id: u32, dictionary_id: u32,
value_list_max_length: u32, value_list_max_length: u32,
value_list: *mut bool value_list: *mut bool,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.read_bool_array)(dictionary_id, value_list_max_length, value_list) unsafe { (self.read_bool_array)(dictionary_id, value_list_max_length, value_list) }
} }
#[inline] #[inline]
@@ -862,9 +844,9 @@ impl OpenApi {
&self, &self,
dictionary_id: u32, dictionary_id: u32,
value_list_max_length: u32, value_list_max_length: u32,
value_list: *mut f64 value_list: *mut f64,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.read_double_array)(dictionary_id, value_list_max_length, value_list) unsafe { (self.read_double_array)(dictionary_id, value_list_max_length, value_list) }
} }
#[inline] #[inline]
@@ -872,9 +854,9 @@ impl OpenApi {
&self, &self,
dictionary_id: u32, dictionary_id: u32,
string_max_length: u32, string_max_length: u32,
string_buffer: PWSTR string_buffer: PWSTR,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.read_string)(dictionary_id, string_max_length, string_buffer) unsafe { (self.read_string)(dictionary_id, string_max_length, string_buffer) }
} }
#[inline] #[inline]
@@ -883,161 +865,163 @@ impl OpenApi {
dictionary_id: u32, dictionary_id: u32,
string_array_max_length: u32, string_array_max_length: u32,
string_max_length: u32, string_max_length: u32,
string_array: PPWSTR string_array: PPWSTR,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.read_string_array)( unsafe {
dictionary_id, (self.read_string_array)(
string_array_max_length, dictionary_id,
string_max_length, string_array_max_length,
string_array string_max_length,
) string_array,
)
}
} }
#[inline] #[inline]
pub unsafe fn read_unsigned_integer_16_bit( pub unsafe fn read_unsigned_integer_16_bit(
&self, &self,
dictionary_id: u32, dictionary_id: u32,
value: *mut u16 value: *mut u16,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.read_unsigned_integer_16_bit)(dictionary_id, value) unsafe { (self.read_unsigned_integer_16_bit)(dictionary_id, value) }
} }
#[inline] #[inline]
pub unsafe fn read_signed_integer_16_bit( pub unsafe fn read_signed_integer_16_bit(
&self, &self,
dictionary_id: u32, dictionary_id: u32,
value: *mut i16 value: *mut i16,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.read_signed_integer_16_bit)(dictionary_id, value) unsafe { (self.read_signed_integer_16_bit)(dictionary_id, value) }
} }
#[inline] #[inline]
pub unsafe fn read_unsigned_integer_32_bit( pub unsafe fn read_unsigned_integer_32_bit(
&self, &self,
dictionary_id: u32, dictionary_id: u32,
value: *mut u32 value: *mut u32,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.read_unsigned_integer_32_bit)(dictionary_id, value) unsafe { (self.read_unsigned_integer_32_bit)(dictionary_id, value) }
} }
#[inline] #[inline]
pub unsafe fn read_signed_integer_32_bit( pub unsafe fn read_signed_integer_32_bit(
&self, &self,
dictionary_id: u32, dictionary_id: u32,
value: *mut i32 value: *mut i32,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.read_signed_integer_32_bit)(dictionary_id, value) unsafe { (self.read_signed_integer_32_bit)(dictionary_id, value) }
} }
#[inline] #[inline]
pub unsafe fn read_unsigned_integer_64_bit( pub unsafe fn read_unsigned_integer_64_bit(
&self, &self,
dictionary_id: u32, dictionary_id: u32,
value: *mut u64 value: *mut u64,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.read_unsigned_integer_64_bit)(dictionary_id, value) unsafe { (self.read_unsigned_integer_64_bit)(dictionary_id, value) }
} }
#[inline] #[inline]
pub unsafe fn read_signed_integer_64_bit( pub unsafe fn read_signed_integer_64_bit(
&self, &self,
dictionary_id: u32, dictionary_id: u32,
value: *mut i64 value: *mut i64,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.read_signed_integer_64_bit)(dictionary_id, value) unsafe { (self.read_signed_integer_64_bit)(dictionary_id, value) }
} }
#[inline] #[inline]
pub unsafe fn get_num_array_elements( pub unsafe fn get_num_array_elements(
&self, &self,
dictionary_id: u32, dictionary_id: u32,
num_array_elements: *mut u32 num_array_elements: *mut u32,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.get_num_array_elements)(dictionary_id, num_array_elements) unsafe { (self.get_num_array_elements)(dictionary_id, num_array_elements) }
} }
#[inline] #[inline]
pub unsafe fn read_bit(&self, dictionary_id: u32, value: *mut Bool32) -> OpenReturnCodes { pub unsafe fn read_bit(&self, dictionary_id: u32, value: *mut Bool32) -> OpenReturnCodes {
(self.read_bit)(dictionary_id, value) unsafe { (self.read_bit)(dictionary_id, value) }
} }
#[inline] #[inline]
pub unsafe fn read_bool(&self, dictionary_id: u32, value: *mut Bool32) -> OpenReturnCodes { pub unsafe fn read_bool(&self, dictionary_id: u32, value: *mut Bool32) -> OpenReturnCodes {
(self.read_bool)(dictionary_id, value) unsafe { (self.read_bool)(dictionary_id, value) }
} }
#[inline] #[inline]
pub unsafe fn read_byte(&self, dictionary_id: u32, value: *mut u8) -> OpenReturnCodes { pub unsafe fn read_byte(&self, dictionary_id: u32, value: *mut u8) -> OpenReturnCodes {
(self.read_byte)(dictionary_id, value) unsafe { (self.read_byte)(dictionary_id, value) }
} }
#[inline] #[inline]
pub unsafe fn read_double(&self, dictionary_id: u32, value: *mut f64) -> OpenReturnCodes { pub unsafe fn read_double(&self, dictionary_id: u32, value: *mut f64) -> OpenReturnCodes {
(self.read_double)(dictionary_id, value) unsafe { (self.read_double)(dictionary_id, value) }
} }
#[inline] #[inline]
pub unsafe fn read_word(&self, dictionary_id: u32, value: *mut u16) -> OpenReturnCodes { pub unsafe fn read_word(&self, dictionary_id: u32, value: *mut u16) -> OpenReturnCodes {
(self.read_word)(dictionary_id, value) unsafe { (self.read_word)(dictionary_id, value) }
} }
#[inline] #[inline]
pub unsafe fn read_double_word(&self, dictionary_id: u32, value: *mut u32) -> OpenReturnCodes { pub unsafe fn read_double_word(&self, dictionary_id: u32, value: *mut u32) -> OpenReturnCodes {
(self.read_double_word)(dictionary_id, value) unsafe { (self.read_double_word)(dictionary_id, value) }
} }
#[inline] #[inline]
pub unsafe fn read_long_word(&self, dictionary_id: u32, value: *mut u64) -> OpenReturnCodes { pub unsafe fn read_long_word(&self, dictionary_id: u32, value: *mut u64) -> OpenReturnCodes {
(self.read_long_word)(dictionary_id, value) unsafe { (self.read_long_word)(dictionary_id, value) }
} }
#[inline] #[inline]
pub unsafe fn read_next_event(&self, event: *mut u64) -> OpenReturnCodes { pub unsafe fn read_next_event(&self, event: *mut u64) -> OpenReturnCodes {
(self.read_next_event)(event) unsafe { (self.read_next_event)(event) }
} }
#[inline] #[inline]
pub unsafe fn read_next_event_with_ncu_index( pub unsafe fn read_next_event_with_ncu_index(
&self, &self,
event: *mut u64, event: *mut u64,
ncu_index: *mut i32 ncu_index: *mut i32,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.read_next_event_with_ncu_index)(event, ncu_index) unsafe { (self.read_next_event_with_ncu_index)(event, ncu_index) }
} }
#[inline] #[inline]
pub unsafe fn write_bit(&self, dictionary_id: u32, value: Bool32) -> OpenReturnCodes { pub unsafe fn write_bit(&self, dictionary_id: u32, value: Bool32) -> OpenReturnCodes {
(self.write_bit)(dictionary_id, value) unsafe { (self.write_bit)(dictionary_id, value) }
} }
#[inline] #[inline]
pub unsafe fn write_bool(&self, dictionary_id: u32, value: Bool32) -> OpenReturnCodes { pub unsafe fn write_bool(&self, dictionary_id: u32, value: Bool32) -> OpenReturnCodes {
(self.write_bool)(dictionary_id, value) unsafe { (self.write_bool)(dictionary_id, value) }
} }
#[inline] #[inline]
pub unsafe fn write_byte(&self, dictionary_id: u32, value: u8) -> OpenReturnCodes { pub unsafe fn write_byte(&self, dictionary_id: u32, value: u8) -> OpenReturnCodes {
(self.write_byte)(dictionary_id, value) unsafe { (self.write_byte)(dictionary_id, value) }
} }
#[inline] #[inline]
pub unsafe fn write_double(&self, dictionary_id: u32, value: f64) -> OpenReturnCodes { pub unsafe fn write_double(&self, dictionary_id: u32, value: f64) -> OpenReturnCodes {
(self.write_double)(dictionary_id, value) unsafe { (self.write_double)(dictionary_id, value) }
} }
#[inline] #[inline]
pub unsafe fn write_word(&self, dictionary_id: u32, value: u16) -> OpenReturnCodes { pub unsafe fn write_word(&self, dictionary_id: u32, value: u16) -> OpenReturnCodes {
(self.write_word)(dictionary_id, value) unsafe { (self.write_word)(dictionary_id, value) }
} }
#[inline] #[inline]
pub unsafe fn write_double_word(&self, dictionary_id: u32, value: u32) -> OpenReturnCodes { pub unsafe fn write_double_word(&self, dictionary_id: u32, value: u32) -> OpenReturnCodes {
(self.write_double_word)(dictionary_id, value) unsafe { (self.write_double_word)(dictionary_id, value) }
} }
#[inline] #[inline]
pub unsafe fn write_long_word(&self, dictionary_id: u32, value: u64) -> OpenReturnCodes { pub unsafe fn write_long_word(&self, dictionary_id: u32, value: u64) -> OpenReturnCodes {
(self.write_long_word)(dictionary_id, value) unsafe { (self.write_long_word)(dictionary_id, value) }
} }
#[inline] #[inline]
@@ -1045,28 +1029,28 @@ impl OpenApi {
&self, &self,
dictionary_id: u32, dictionary_id: u32,
value_list_length: u32, value_list_length: u32,
value_list: *const bool value_list: *const bool,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.write_bool_array)(dictionary_id, value_list_length, value_list) unsafe { (self.write_bool_array)(dictionary_id, value_list_length, value_list) }
} }
#[inline] #[inline]
pub unsafe fn get_simulation_speed(&self, percent: *mut u32) -> OpenReturnCodes { pub unsafe fn get_simulation_speed(&self, percent: *mut u32) -> OpenReturnCodes {
(self.get_simulation_speed)(percent) unsafe { (self.get_simulation_speed)(percent) }
} }
#[inline] #[inline]
pub unsafe fn set_simulation_speed(&self, percent: u32) -> OpenReturnCodes { pub unsafe fn set_simulation_speed(&self, percent: u32) -> OpenReturnCodes {
(self.set_simulation_speed)(percent) unsafe { (self.set_simulation_speed)(percent) }
} }
#[inline] #[inline]
pub unsafe fn get_card_path( pub unsafe fn get_card_path(
&self, &self,
card_path_max_length: u32, card_path_max_length: u32,
card_path: PWSTR card_path: PWSTR,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.get_card_path)(card_path_max_length, card_path) unsafe { (self.get_card_path)(card_path_max_length, card_path) }
} }
#[inline] #[inline]
@@ -1074,104 +1058,110 @@ impl OpenApi {
&self, &self,
card_paths_array_max_length: u32, card_paths_array_max_length: u32,
card_path_max_length: u32, card_path_max_length: u32,
card_paths: PPWSTR card_paths: PPWSTR,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.get_card_paths)(card_paths_array_max_length, card_path_max_length, card_paths) unsafe {
(self.get_card_paths)(
card_paths_array_max_length,
card_path_max_length,
card_paths,
)
}
} }
#[inline] #[inline]
pub unsafe fn get_file( pub unsafe fn get_file(
&self, &self,
source_file_path: PCWSTR, source_file_path: PCWSTR,
destination_file_path: PCWSTR destination_file_path: PCWSTR,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.get_file)(source_file_path, destination_file_path) unsafe { (self.get_file)(source_file_path, destination_file_path) }
} }
#[inline] #[inline]
pub unsafe fn put_file( pub unsafe fn put_file(
&self, &self,
source_file_path: PCWSTR, source_file_path: PCWSTR,
destination_file_path: PCWSTR destination_file_path: PCWSTR,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.put_file)(source_file_path, destination_file_path) unsafe { (self.put_file)(source_file_path, destination_file_path) }
} }
#[inline] #[inline]
pub unsafe fn select_file( pub unsafe fn select_file(
&self, &self,
source_file_path: PCWSTR, source_file_path: PCWSTR,
channel_name: PCWSTR channel_name: PCWSTR,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.select_file)(source_file_path, channel_name) unsafe { (self.select_file)(source_file_path, channel_name) }
} }
#[inline] #[inline]
pub unsafe fn delete_file(&self, file_path: PCWSTR) -> OpenReturnCodes { pub unsafe fn delete_file(&self, file_path: PCWSTR) -> OpenReturnCodes {
(self.delete_file)(file_path) unsafe { (self.delete_file)(file_path) }
} }
#[inline] #[inline]
pub unsafe fn delete_directory(&self, directory_path: PCWSTR) -> OpenReturnCodes { pub unsafe fn delete_directory(&self, directory_path: PCWSTR) -> OpenReturnCodes {
(self.delete_directory)(directory_path) unsafe { (self.delete_directory)(directory_path) }
} }
#[inline] #[inline]
pub unsafe fn create_directory(&self, directory_path: PCWSTR) -> OpenReturnCodes { pub unsafe fn create_directory(&self, directory_path: PCWSTR) -> OpenReturnCodes {
(self.create_directory)(directory_path) unsafe { (self.create_directory)(directory_path) }
} }
#[inline] #[inline]
pub unsafe fn list_directory( pub unsafe fn list_directory(
&self, &self,
directory_path: PCWSTR, directory_path: PCWSTR,
result_file_path: PCWSTR result_file_path: PCWSTR,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.list_directory)(directory_path, result_file_path) unsafe { (self.list_directory)(directory_path, result_file_path) }
} }
#[inline] #[inline]
pub unsafe fn get_version_information(&self, destination_file_path: PCWSTR) -> OpenReturnCodes { pub unsafe fn get_version_information(&self, destination_file_path: PCWSTR) -> OpenReturnCodes {
(self.get_version_information)(destination_file_path) unsafe { (self.get_version_information)(destination_file_path) }
} }
#[inline] #[inline]
pub unsafe fn get_project_information( pub unsafe fn get_project_information(
&self, &self,
vcp_file_path: PCWSTR, vcp_file_path: PCWSTR,
destination_file_path: PCWSTR destination_file_path: PCWSTR,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.get_project_information)(vcp_file_path, destination_file_path) unsafe { (self.get_project_information)(vcp_file_path, destination_file_path) }
} }
#[inline] #[inline]
pub unsafe fn get_current_project_information( pub unsafe fn get_current_project_information(
&self, &self,
destination_file_path: PCWSTR destination_file_path: PCWSTR,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.get_current_project_information)(destination_file_path) unsafe { (self.get_current_project_information)(destination_file_path) }
} }
#[inline] #[inline]
pub unsafe fn get_current_project_state( pub unsafe fn get_current_project_state(
&self, &self,
project_state: *mut OpenProjectStates project_state: *mut OpenProjectStates,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.get_current_project_state)(project_state) unsafe { (self.get_current_project_state)(project_state) }
} }
#[inline] #[inline]
pub unsafe fn import_project_settings( pub unsafe fn import_project_settings(
&self, &self,
file_name: PCWSTR, file_name: PCWSTR,
import_content_file_name: PCWSTR import_content_file_name: PCWSTR,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.import_project_settings)(file_name, import_content_file_name) unsafe { (self.import_project_settings)(file_name, import_content_file_name) }
} }
#[inline] #[inline]
pub unsafe fn export_project_settings(&self, file_name: PCWSTR) -> OpenReturnCodes { pub unsafe fn export_project_settings(&self, file_name: PCWSTR) -> OpenReturnCodes {
(self.export_project_settings)(file_name) unsafe { (self.export_project_settings)(file_name) }
} }
#[inline] #[inline]
@@ -1179,13 +1169,19 @@ impl OpenApi {
&self, &self,
dictionary_id: u32, dictionary_id: u32,
value_list_max_length: u32, value_list_max_length: u32,
value_list: *const u8 value_list: *const u8,
) -> OpenReturnCodes { ) -> OpenReturnCodes {
(self.write_unsigned_integer_8_bit_array)(dictionary_id, value_list_max_length, value_list) unsafe {
(self.write_unsigned_integer_8_bit_array)(
dictionary_id,
value_list_max_length,
value_list,
)
}
} }
#[inline] #[inline]
pub unsafe fn get_number_of_ncus(&self, number_of_ncus: *mut u32) -> OpenReturnCodes { pub unsafe fn get_number_of_ncus(&self, number_of_ncus: *mut u32) -> OpenReturnCodes {
(self.get_number_of_ncus)(number_of_ncus) unsafe { (self.get_number_of_ncus)(number_of_ncus) }
} }
} }