use super::guard::{clear_last_error, ffi_guard, take_last_error};
use super::types::*;
use crate::prelude::*;
use std::ffi::{c_char, CString};
use std::ptr;
#[no_mangle]
pub const extern "C" fn alice_sdf_version() -> VersionInfo {
VersionInfo::current()
}
#[no_mangle]
pub extern "C" fn alice_sdf_version_string() -> *mut c_char {
ffi_guard(std::ptr::null_mut(), || {
let version = format!(
"ALICE-SDF v{}.{}.{} (Deep Fried)",
VersionInfo::current().major,
VersionInfo::current().minor,
VersionInfo::current().patch
);
CString::new(version).map_or_else(|_| ptr::null_mut(), CString::into_raw)
})
}
#[no_mangle]
pub extern "C" fn alice_sdf_last_error() -> *mut c_char {
ffi_guard(ptr::null_mut(), || {
take_last_error()
.and_then(|m| CString::new(m).ok())
.map_or_else(ptr::null_mut, CString::into_raw)
})
}
#[no_mangle]
pub extern "C" fn alice_sdf_clear_last_error() {
ffi_guard((), clear_last_error);
}
#[no_mangle]
pub const extern "C" fn alice_sdf_primitive_count() -> u32 {
SdfCategory::Primitive.count()
}
#[no_mangle]
pub const extern "C" fn alice_sdf_operation_count() -> u32 {
SdfCategory::Operation.count()
}
#[no_mangle]
pub const extern "C" fn alice_sdf_transform_count() -> u32 {
SdfCategory::Transform.count()
}
#[no_mangle]
pub const extern "C" fn alice_sdf_modifier_count() -> u32 {
SdfCategory::Modifier.count()
}
#[no_mangle]
pub const extern "C" fn alice_sdf_total_count() -> u32 {
SdfCategory::total()
}