Skip to main content

luaur_vm/functions/
lua_pushvalue.rs

1//! Node: `cxx:Function:Luau.VM:VM/src/lapi.cpp:310:lua_pushvalue`
2//! Source: `VM/src/lapi.cpp:310-316` (hand-ported)
3
4use core::ffi::c_int;
5
6use crate::functions::index_2_addr::index2addr;
7use crate::functions::lua_concat::lua_c_threadbarrier_lapi;
8use crate::macros::api_incr_top::api_incr_top;
9use crate::macros::setobj_2_s::setobj2s;
10use crate::type_aliases::lua_state::lua_State;
11use crate::type_aliases::stk_id::StkId;
12
13#[allow(non_snake_case)]
14pub unsafe fn lua_pushvalue(L: *mut lua_State, idx: c_int) {
15    lua_c_threadbarrier_lapi(L);
16    let o: StkId = index2addr(L, idx);
17    setobj2s!(L, (*L).top, o);
18    api_incr_top!(L);
19}