luaur_vm/functions/
lua_g_aritherror.rs1use core::ffi::{c_char, CStr};
6
7use crate::functions::lua_t_objtypename::lua_t_objtypename;
8use crate::macros::getstr::getstr;
9use crate::macros::lua_g_runerror::lua_g_runerror;
10use crate::type_aliases::lua_state::lua_State;
11use crate::type_aliases::t_value::TValue;
12use crate::type_aliases::tms::TMS;
13
14#[allow(non_snake_case)]
15pub unsafe fn lua_g_aritherror(
16 L: *mut lua_State,
17 p1: *const TValue,
18 p2: *const TValue,
19 op: TMS,
20) -> ! {
21 let t1: *const c_char = lua_t_objtypename(L, p1);
22 let t2: *const c_char = lua_t_objtypename(L, p2);
23 let opname = getstr((*(*L).global).tmname[op as usize]).add(2);
25
26 if t1 == t2 {
27 lua_g_runerror!(
29 L,
30 "attempt to perform arithmetic ({}) on {}",
31 CStr::from_ptr(opname).to_string_lossy(),
32 CStr::from_ptr(t1).to_string_lossy()
33 )
34 } else {
35 lua_g_runerror!(
36 L,
37 "attempt to perform arithmetic ({}) on {} and {}",
38 CStr::from_ptr(opname).to_string_lossy(),
39 CStr::from_ptr(t1).to_string_lossy(),
40 CStr::from_ptr(t2).to_string_lossy()
41 )
42 }
43}
44
45#[allow(non_snake_case)]
46pub unsafe fn luaG_aritherror(
47 L: *mut lua_State,
48 p1: *const TValue,
49 p2: *const TValue,
50 op: TMS,
51) -> ! {
52 lua_g_aritherror(L, p1, p2, op)
53}