luaur_analysis/methods/
stringifier_state_emit_to_string_alt_c.rs1use crate::records::stringifier_state::StringifierState;
2use core::ffi::c_char;
3
4impl StringifierState {
5 pub fn emit_c_char(&mut self, s: *const c_char) {
6 if self.opts.is_null() {
7 return;
8 }
9
10 let max_type_length = unsafe { (*self.opts).max_type_length };
11 if max_type_length > 0 {
12 let result_name = unsafe { &(*self.result).name };
13 if result_name.len() > max_type_length as usize {
14 return;
15 }
16 }
17
18 if s.is_null() {
19 return;
20 }
21
22 let slice = unsafe {
23 let mut len = 0;
24 while *s.add(len) != 0 {
25 len += 1;
26 }
27 core::slice::from_raw_parts(s as *const u8, len)
28 };
29
30 let s_str = core::str::from_utf8(slice).unwrap_or("");
31 self.emit_string(s_str);
32 }
33}