Skip to main content

luaur_code_gen/records/
base_code_gen_context.rs

1extern crate alloc;
2
3use crate::records::code_allocation_data::CodeAllocationData;
4use crate::records::code_allocator::CodeAllocator;
5use crate::records::module_bind_result::ModuleBindResult;
6use crate::records::native_context::NativeContext;
7use crate::records::unwind_builder::UnwindBuilder;
8use crate::type_aliases::allocation_callback::AllocationCallback;
9use crate::type_aliases::module_id::ModuleId;
10use crate::type_aliases::native_proto_exec_data_ptr::NativeProtoExecDataPtr;
11use crate::type_aliases::userdata_remapper_callback::UserdataRemapperCallback;
12use alloc::vec::Vec;
13use core::ffi::c_void;
14use luaur_vm::records::proto::Proto;
15
16#[derive(Debug)]
17#[repr(C)]
18pub struct BaseCodeGenContext {
19    pub(crate) code_allocator: CodeAllocator,
20    pub try_bind_existing_module_fn: Option<
21        unsafe fn(*mut BaseCodeGenContext, &ModuleId, &Vec<*mut Proto>) -> Option<ModuleBindResult>,
22    >,
23    pub bind_module_fn: Option<
24        unsafe fn(
25            *mut BaseCodeGenContext,
26            &Option<ModuleId>,
27            &Vec<*mut Proto>,
28            Vec<NativeProtoExecDataPtr>,
29            *const u8,
30            usize,
31            *const u8,
32            usize,
33        ) -> ModuleBindResult,
34    >,
35    pub(crate) unwind_builder: *mut UnwindBuilder,
36    pub gate_data_deprecated: *mut u8,
37    pub gate_data_size_deprecated: usize,
38    pub gate_allocation_data: CodeAllocationData,
39    pub userdata_remapping_context: *mut c_void,
40    // C++ field: `UserdataRemapperCallback* userdataRemapper` where the C++ alias
41    // is a *function type*, so the field is a nullable function pointer. Rust's
42    // `UserdataRemapperCallback` alias is already the function-pointer type, so
43    // the faithful equivalent is `Option<UserdataRemapperCallback>` (Some == the
44    // function pointer, None == nullptr).
45    pub userdata_remapper: Option<UserdataRemapperCallback>,
46    pub context: NativeContext,
47}