Implement standard errors

This commit is contained in:
2024-12-30 18:48:19 -05:00
parent 9edd9fb7b6
commit dd22d7a164
5 changed files with 56 additions and 15 deletions

View File

@ -54,6 +54,7 @@ fn main() {
})
.constified_enum("SlangProfileID")
.constified_enum("SlangCapabilityID")
.new_type_alias("SlangResult")
.vtable_generation(true)
.layout_tests(false)
.derive_copy(true)

View File

@ -3,7 +3,7 @@
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
use std::ffi::{c_char, c_int, c_void};
use std::fmt::{Display, Formatter};
// Based on Slang version 2024.14.5
#[repr(C)]
@ -135,3 +135,13 @@ pub struct IModuleVtable {
pub getDependencyFilePath: unsafe extern "C" fn(*mut c_void, index: SlangInt32) -> *const c_char,
pub getModuleReflection: unsafe extern "C" fn(*mut c_void) -> *mut slang_DeclReflection,
}
impl Display for SlangResult {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
if self.0 > 0 {
write!(f, "success")
} else {
write!(f, "failure")
}
}
}