haku1 API cleanups (removing 2 suffix)
This commit is contained in:
parent
00a48527ca
commit
c80cd1c7fe
6 changed files with 82 additions and 77 deletions
|
@ -370,10 +370,8 @@ unsafe extern "C" fn haku_pixmap_stroke(
|
|||
true
|
||||
}
|
||||
|
||||
// v2 compile-only support
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn haku_compile_brush2(
|
||||
unsafe extern "C" fn haku_compile_brush(
|
||||
instance: *mut Instance,
|
||||
code_len: u32,
|
||||
code: *const u8,
|
||||
|
@ -480,72 +478,78 @@ unsafe extern "C" fn haku_compile_brush2(
|
|||
StatusCode::Ok
|
||||
}
|
||||
|
||||
unsafe fn compile_result<'a>(instance: *const Instance) -> &'a CompileResult {
|
||||
unsafe fn unwrap_compile_result<'a>(instance: *const Instance) -> &'a CompileResult {
|
||||
let cr = (*instance).compile_result2.as_ref().unwrap();
|
||||
cr
|
||||
}
|
||||
|
||||
unsafe fn get_compile_result<'a>(instance: *const Instance) -> Option<&'a CompileResult> {
|
||||
(*instance).compile_result2.as_ref()
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn haku_num_diagnostics2(instance: *const Instance) -> u32 {
|
||||
unsafe extern "C" fn haku_num_diagnostics(instance: *const Instance) -> u32 {
|
||||
(*instance).diagnostics2.len() as u32
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn haku_diagnostic_start2(instance: *const Instance, index: u32) -> u32 {
|
||||
unsafe extern "C" fn haku_diagnostic_start(instance: *const Instance, index: u32) -> u32 {
|
||||
(*instance).diagnostics2[index as usize].span().start
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn haku_diagnostic_end2(instance: *const Instance, index: u32) -> u32 {
|
||||
unsafe extern "C" fn haku_diagnostic_end(instance: *const Instance, index: u32) -> u32 {
|
||||
(*instance).diagnostics2[index as usize].span().end
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn haku_diagnostic_message2(instance: *const Instance, index: u32) -> *const u8 {
|
||||
unsafe extern "C" fn haku_diagnostic_message(instance: *const Instance, index: u32) -> *const u8 {
|
||||
(*instance).diagnostics2[index as usize].message().as_ptr()
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn haku_diagnostic_message_len2(instance: *const Instance, index: u32) -> u32 {
|
||||
unsafe extern "C" fn haku_diagnostic_message_len(instance: *const Instance, index: u32) -> u32 {
|
||||
(*instance).diagnostics2[index as usize].message().len() as u32
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn haku_defs_len2(instance: *const Instance) -> usize {
|
||||
compile_result(instance).defs_string.len()
|
||||
unsafe extern "C" fn haku_defs_len(instance: *const Instance) -> usize {
|
||||
unwrap_compile_result(instance).defs_string.len()
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn haku_defs2(instance: *const Instance) -> *const u8 {
|
||||
compile_result(instance).defs_string.as_ptr()
|
||||
unsafe extern "C" fn haku_defs(instance: *const Instance) -> *const u8 {
|
||||
unwrap_compile_result(instance).defs_string.as_ptr()
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn haku_tags_len2(instance: *const Instance) -> usize {
|
||||
compile_result(instance).tags_string.len()
|
||||
unsafe extern "C" fn haku_tags_len(instance: *const Instance) -> usize {
|
||||
unwrap_compile_result(instance).tags_string.len()
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn haku_tags2(instance: *const Instance) -> *const u8 {
|
||||
compile_result(instance).tags_string.as_ptr()
|
||||
unsafe extern "C" fn haku_tags(instance: *const Instance) -> *const u8 {
|
||||
unwrap_compile_result(instance).tags_string.as_ptr()
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn haku_bytecode_len2(instance: *const Instance) -> usize {
|
||||
compile_result(instance).chunk.bytecode.len()
|
||||
unsafe extern "C" fn haku_bytecode_len(instance: *const Instance) -> usize {
|
||||
unwrap_compile_result(instance).chunk.bytecode.len()
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn haku_bytecode2(instance: *const Instance) -> *const u8 {
|
||||
compile_result(instance).chunk.bytecode.as_ptr()
|
||||
unsafe extern "C" fn haku_bytecode(instance: *const Instance) -> *const u8 {
|
||||
unwrap_compile_result(instance).chunk.bytecode.as_ptr()
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn haku_local_count2(instance: *const Instance) -> u8 {
|
||||
compile_result(instance).closure_spec.local_count
|
||||
unsafe extern "C" fn haku_local_count(instance: *const Instance) -> u8 {
|
||||
unwrap_compile_result(instance).closure_spec.local_count
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn haku_stat_ast_size(instance: *const Instance) -> usize {
|
||||
compile_result(instance).stats.ast_size
|
||||
get_compile_result(instance)
|
||||
.map(|cr| cr.stats.ast_size)
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue