1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
use std::os::raw::c_char; use std::ffi::CStr; pub mod types; pub mod engine; pub mod engine_macros; pub mod module; pub fn read_cstring(c_buf: *const c_char) -> String { let c_str: &CStr = unsafe { CStr::from_ptr(c_buf) }; let str_slice: &str = c_str.to_str().unwrap(); let str_buf: String = str_slice.to_owned(); return str_buf; } pub fn get_library_version() -> String { extern { #[link(name="angelscript_c", kind="static")] fn asGetLibraryVersion() -> *const c_char; } let c_buf: *const c_char = unsafe { asGetLibraryVersion() }; return read_cstring(c_buf); } pub fn get_library_options() -> String { extern { #[link(name="angelscript_c", kind="static")] fn asGetLibraryOptions() -> *const c_char; } let c_buf: *const c_char = unsafe { asGetLibraryOptions() }; return read_cstring(c_buf); }