Skip to content

Commit

Permalink
Remove debug exports (lune-org#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
qwreey committed Nov 2, 2024
1 parent 2a9664a commit de7029a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 24 deletions.
13 changes: 0 additions & 13 deletions crates/lune-std-ffi/src/ffi/association.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,3 @@ where
_ => panic!(),
}
}

// Allows reading of registry tables for debugging.
// This helps keep track of data being gc'd.
// However, for security and safety reasons,
// this will not be allowed unless debug build.
#[cfg(debug_assertions)]
pub fn get_table<'lua>(lua: &'lua Lua, regname: &str) -> LuaResult<Option<LuaTable<'lua>>> {
match lua.named_registry_value::<LuaValue>(regname)? {
LuaValue::Nil => Ok(None),
LuaValue::Table(t) => Ok(Some(t)),
_ => panic!(),
}
}
8 changes: 1 addition & 7 deletions crates/lune-std-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,12 @@ use crate::{
*/
pub fn module(lua: &Lua) -> LuaResult<LuaTable> {
let result = TableBuilder::new(lua)?
.with_values(export_fixed_types(lua)?)?
.with_function("nullRef", |lua, ()| create_nullref(lua))?
.with_function("box", |_lua, size: usize| Ok(BoxData::new(size)))?
.with_function("open", |_lua, name: String| LibData::new(name))?
.with_function("isInteger", |_lua, num: LuaValue| Ok(num.is_integer()))?
.with_values(export_fixed_types(lua)?)?
.with_value("c", export_c(lua)?)?;

#[cfg(debug_assertions)]
let result = result.with_function("debugAssociation", |lua, str: String| {
println!("WARNING: ffi.debug_associate is GC debug function, which only works for debug build. Do not use this function in production level codes.");
ffi::association::get_table(lua, str.as_ref())
})?;

result.build_readonly()
}
2 changes: 1 addition & 1 deletion crates/lune/src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl RunCommand {
// Create a new lune runtime with all globals & run the script
let mut rt = Runtime::new()
.with_args(self.script_args)
.set_unsafe_lib_enabled(self.r#unsafe);
.set_unsafe_library_enabled(self.r#unsafe);

let result = rt
.run(&script_display_name, strip_shebang(script_contents))
Expand Down
2 changes: 1 addition & 1 deletion crates/lune/src/rt/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl Runtime {
Sets arguments to give in `process.args` for Lune scripts.
*/
#[must_use]
pub fn set_unsafe_lib_enabled(self, enabled: bool) -> Self {
pub fn set_unsafe_library_enabled(self, enabled: bool) -> Self {
lune_std::set_unsafe_library_enabled(self.inner.lua(), enabled);
self
}
Expand Down
25 changes: 23 additions & 2 deletions types/ffi.luau
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ export type CFnInfo = {
Create a callable from reference.
@return Struct array type
@return A callable
]=]
callable: (self: CFnInfo, functionRef: RefData) -> CallableData,
--[=[
Expand All @@ -425,7 +425,7 @@ export type CFnInfo = {
Create a closure from lua function.
@return A closure.
@return A closure
]=]
closure: (self: CFnInfo, (ret: RefData, ...RefData) -> ()) -> ClosureData,
}
Expand Down Expand Up @@ -467,7 +467,28 @@ export type CStructInfo = {
]=]
ptr: (self: CStructInfo) -> CPtrInfo<CStructInfo>,

--[=[
@within CSturctInfo
@tag Method
@method box
Create a box with initial value.
@param table The array of field values
@return A box
]=]
box: (self: CStructInfo, table: { any }) -> BoxData,
--[=[
@within CSturctInfo
@tag Method
@method readData
Read a lua table from reference or box.
@param target Target to read data from
@param offset Offset to read data from
@return A table
]=]
readData: (self: CStructInfo, target: RefData | BoxData, offset: number?) -> { any },
writeData: (
self: CStructInfo,
Expand Down

0 comments on commit de7029a

Please sign in to comment.