use crate::core_types::GodotString;
pub struct TerminateInfo {
in_editor: bool,
}
impl TerminateInfo {
#[doc(hidden)]
#[inline]
pub unsafe fn new(options: *mut crate::sys::godot_gdnative_terminate_options) -> Self {
assert!(!options.is_null(), "options were NULL");
let crate::sys::godot_gdnative_terminate_options { in_editor } = *options;
Self { in_editor }
}
#[inline]
pub fn in_editor(&self) -> bool {
self.in_editor
}
}
pub struct InitializeInfo {
in_editor: bool,
active_library_path: GodotString,
options: *mut crate::sys::godot_gdnative_init_options,
}
impl InitializeInfo {
#[inline]
pub fn in_editor(&self) -> bool {
self.in_editor
}
#[inline]
pub fn active_library_path(&self) -> &GodotString {
&self.active_library_path
}
#[doc(hidden)]
#[inline]
pub unsafe fn new(options: *mut crate::sys::godot_gdnative_init_options) -> Self {
assert!(!options.is_null(), "options were NULL");
let crate::sys::godot_gdnative_init_options {
in_editor,
active_library_path,
..
} = *options;
let active_library_path =
crate::core_types::GodotString::clone_from_sys(*active_library_path);
Self {
options,
in_editor,
active_library_path,
}
}
#[inline]
pub fn report_loading_error<T>(&self, message: T)
where
T: std::fmt::Display,
{
let crate::sys::godot_gdnative_init_options {
report_loading_error,
gd_native_library,
..
} = unsafe { *self.options };
if let Some(report_loading_error_fn) = report_loading_error {
let message = format!("{}\0", message);
let message = std::ffi::CStr::from_bytes_with_nul(message.as_bytes())
.expect("message should not have a NULL");
unsafe {
report_loading_error_fn(gd_native_library, message.as_ptr());
}
}
}
}