Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions src/glua/lib.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
//// The all the functions under `_G`

import glua.{type Value}

/// Returns the `assert` function.
@external(erlang, "glua_stdlib_ffi", "assert")
pub fn assert_() -> Value

/// Returns the `collectgarbage` function.
@external(erlang, "glua_stdlib_ffi", "collectgarbage")
pub fn collect_garbage() -> Value

/// Returns the `dofile` function.
@external(erlang, "glua_stdlib_ffi", "dofile")
pub fn do_file() -> Value

/// Returns the `eprint` function.
@external(erlang, "glua_stdlib_ffi", "eprint")
pub fn eprint() -> Value

/// Returns the `error` function.
@external(erlang, "glua_stdlib_ffi", "error")
pub fn error() -> Value

/// Returns the `getmetatable` function.
@external(erlang, "glua_stdlib_ffi", "getmetatable")
pub fn get_meta_table() -> Value

/// Returns the `ipairs` function.
@external(erlang, "glua_stdlib_ffi", "ipairs")
pub fn ipairs() -> Value

/// Returns the `load` function.
@external(erlang, "glua_stdlib_ffi", "load")
pub fn load() -> Value

/// Returns the `loadfile` function.
@external(erlang, "glua_stdlib_ffi", "loadfile")
pub fn load_file() -> Value

/// Returns the `loadstring` function.
///
/// As of Lua 5.2, `loadstring` is deprecated.
@external(erlang, "glua_stdlib_ffi", "loadstring")
pub fn load_string() -> Value

/// Returns the `next` function.
@external(erlang, "glua_stdlib_ffi", "next")
pub fn next() -> Value

/// Returns the `pairs` function.
@external(erlang, "glua_stdlib_ffi", "pairs")
pub fn pairs() -> Value

/// Returns the `pcall` function.
@external(erlang, "glua_stdlib_ffi", "pcall")
pub fn pcall() -> Value

/// Returns the `print` function.
@external(erlang, "glua_stdlib_ffi", "print")
pub fn print() -> Value

/// Returns the `rawequal` function.
@external(erlang, "glua_stdlib_ffi", "rawequal")
pub fn raw_equal() -> Value

/// Returns the `rawget` function.
@external(erlang, "glua_stdlib_ffi", "rawget")
pub fn raw_get() -> Value

/// Returns the `rawlen` function.
@external(erlang, "glua_stdlib_ffi", "rawlen")
pub fn raw_len() -> Value

/// Returns the `rawset` function.
@external(erlang, "glua_stdlib_ffi", "rawset")
pub fn raw_set() -> Value

/// Returns the `select` function.
@external(erlang, "glua_stdlib_ffi", "select")
pub fn select() -> Value

/// Returns the `setmetatable` function.
@external(erlang, "glua_stdlib_ffi", "setmetatable")
pub fn set_meta_table() -> Value

/// Returns the `tonumber` function.
@external(erlang, "glua_stdlib_ffi", "tonumber")
pub fn to_number() -> Value

/// Returns the `tostring` function.
@external(erlang, "glua_stdlib_ffi", "tostring")
pub fn to_string() -> Value

/// Returns the `type` function.
@external(erlang, "glua_stdlib_ffi", "type")
pub fn type_() -> Value

/// Returns the `unpack` function.
///
/// As of Lua 5.2, `unpack` was moved to `table.unpack`
@external(erlang, "glua_stdlib_ffi", "unpack")
pub fn unpack() -> Value

/// Returns the `require` function.
@external(erlang, "glua_stdlib_ffi", "require")
pub fn require() -> Value
53 changes: 53 additions & 0 deletions src/glua/lib/bit32.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//// The all the functions under `_G.bit32`.
////
//// As of Lua 5.3, the entire bit32 library is deprecated.

import glua.{type Value}

/// Returns the `bit32.band` function.
@external(erlang, "glua_stdlib_ffi", "bit32_band")
pub fn band() -> Value

/// Returns the `bit32.bnot` function.
@external(erlang, "glua_stdlib_ffi", "bit32_bnot")
pub fn bnot() -> Value

/// Returns the `bit32.bor` function.
@external(erlang, "glua_stdlib_ffi", "bit32_bor")
pub fn bor() -> Value

/// Returns the `bit32.btest` function.
@external(erlang, "glua_stdlib_ffi", "bit32_btest")
pub fn btest() -> Value

/// Returns the `bit32.bxor` function.
@external(erlang, "glua_stdlib_ffi", "bit32_bxor")
pub fn bxor() -> Value

/// Returns the `bit32.lshift` function.
@external(erlang, "glua_stdlib_ffi", "bit32_lshift")
pub fn lshift() -> Value

/// Returns the `bit32.rshift` function.
@external(erlang, "glua_stdlib_ffi", "bit32_rshift")
pub fn rshift() -> Value

/// Returns the `bit32.arshift` function.
@external(erlang, "glua_stdlib_ffi", "bit32_arshift")
pub fn arshift() -> Value

/// Returns the `bit32.lrotate` function.
@external(erlang, "glua_stdlib_ffi", "bit32_lrotate")
pub fn lrotate() -> Value

/// Returns the `bit32.rrotate` function.
@external(erlang, "glua_stdlib_ffi", "bit32_rrotate")
pub fn rrotate() -> Value

/// Returns the `bit32.extract` function.
@external(erlang, "glua_stdlib_ffi", "bit32_extract")
pub fn extract() -> Value

/// Returns the `bit32.replace` function.
@external(erlang, "glua_stdlib_ffi", "bit32_replace")
pub fn replace() -> Value
19 changes: 19 additions & 0 deletions src/glua/lib/debug.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//// The all the functions under `_G.debug`

import glua.{type Value}

/// Returns the `getmetatable` function.
@external(erlang, "glua_stdlib_ffi", "debug_getmetatable")
pub fn get_meta_table() -> Value

/// Returns the `getuservalue` function.
@external(erlang, "glua_stdlib_ffi", "debug_getuservalue")
pub fn get_user_value() -> Value

/// Returns the `setmetatable` function.
@external(erlang, "glua_stdlib_ffi", "debug_setmetatable")
pub fn set_meta_table() -> Value

/// Returns the `setuservalue` function.
@external(erlang, "glua_stdlib_ffi", "debug_setuservalue")
pub fn set_user_value() -> Value
9 changes: 9 additions & 0 deletions src/glua/lib/io.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import glua.{type Value}

/// Returns the `io.flush` function.
@external(erlang, "glua_stdlib_ffi", "io_flush")
pub fn flush() -> Value

/// Returns the `io.write` function.
@external(erlang, "glua_stdlib_ffi", "io_write")
pub fn write() -> Value
145 changes: 145 additions & 0 deletions src/glua/lib/math.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
//// The all the functions under `_G.math`

import glua.{type Value}

pub const huge = 1.7976931348623157e308

pub const max_integer = 9_223_372_036_854_775_807

pub const min_integer = -9_223_372_036_854_775_808

pub const pi = 3.141592653589793

/// Returns the `math.abs` function.
@external(erlang, "glua_stdlib_ffi", "math_abs")
pub fn abs() -> Value

/// Returns the `math.acos` function.
@external(erlang, "glua_stdlib_ffi", "math_acos")
pub fn acos() -> Value

/// Returns the `math.asin` function.
@external(erlang, "glua_stdlib_ffi", "math_asin")
pub fn asin() -> Value

/// Returns the `math.atan` function.
@external(erlang, "glua_stdlib_ffi", "math_atan")
pub fn atan() -> Value

/// Returns the `math.atan2` function.
///
/// As of Lua 5.3, `math.atan2` is deprecated
@external(erlang, "glua_stdlib_ffi", "math_atan2")
pub fn atan2() -> Value

/// Returns the `math.ceil` function.
@external(erlang, "glua_stdlib_ffi", "math_ceil")
pub fn ceil() -> Value

/// Returns the `math.cos` function.
@external(erlang, "glua_stdlib_ffi", "math_cos")
pub fn cos() -> Value

/// Returns the `math.cosh` function.
///
/// As of Lua 5.3, `math.cosh` is deprecated
@external(erlang, "glua_stdlib_ffi", "math_cosh")
pub fn cosh() -> Value

/// Returns the `math.deg` function.
@external(erlang, "glua_stdlib_ffi", "math_deg")
pub fn deg() -> Value

/// Returns the `math.exp` function.
@external(erlang, "glua_stdlib_ffi", "math_exp")
pub fn exp() -> Value

/// Returns the `math.floor` function.
@external(erlang, "glua_stdlib_ffi", "math_floor")
pub fn floor() -> Value

/// Returns the `math.fmod` function.
@external(erlang, "glua_stdlib_ffi", "math_fmod")
pub fn fmod() -> Value

/// Returns the `math.frexp` function.
///
/// As of Lua 5.3, `math.frexp` is deprecated
@external(erlang, "glua_stdlib_ffi", "math_frexp")
pub fn frexp() -> Value

/// Returns the `math.ldexp` function.
///
/// As of Lua 5.3, `math.ldexp` is deprecated
@external(erlang, "glua_stdlib_ffi", "math_ldexp")
pub fn ldexp() -> Value

/// Returns the `math.log` function.
@external(erlang, "glua_stdlib_ffi", "math_log")
pub fn log() -> Value

/// Returns the `math.log10` function.
@external(erlang, "glua_stdlib_ffi", "math_log10")
pub fn log10() -> Value

/// Returns the `math.max` function.
@external(erlang, "glua_stdlib_ffi", "math_max")
pub fn max() -> Value

/// Returns the `math.min` function.
@external(erlang, "glua_stdlib_ffi", "math_min")
pub fn min() -> Value

/// Returns the `math.modf` function.
@external(erlang, "glua_stdlib_ffi", "math_modf")
pub fn modf() -> Value

/// Returns the `math.pow` function.
///
/// As of Lua 5.3, `math.pow` is deprecated
@external(erlang, "glua_stdlib_ffi", "math_pow")
pub fn pow() -> Value

/// Returns the `math.rad` function.
@external(erlang, "glua_stdlib_ffi", "math_rad")
pub fn rad() -> Value

/// Returns the `math.random` function.
@external(erlang, "glua_stdlib_ffi", "math_random")
pub fn random() -> Value

/// Returns the `math.randomseed` function.
@external(erlang, "glua_stdlib_ffi", "math_randomseed")
pub fn random_seed() -> Value

/// Returns the `math.sin` function.
@external(erlang, "glua_stdlib_ffi", "math_sin")
pub fn sin() -> Value

/// Returns the `math.sinh` function.
///
/// As of Lua 5.3, `math.sinh` is deprecated
@external(erlang, "glua_stdlib_ffi", "math_sinh")
pub fn sinh() -> Value

/// Returns the `math.sqrt` function.
@external(erlang, "glua_stdlib_ffi", "math_sqrt")
pub fn sqrt() -> Value

/// Returns the `math.tan` function.
@external(erlang, "glua_stdlib_ffi", "math_tan")
pub fn tan() -> Value

/// Returns the `math.tanh` function.
///
/// As of Lua 5.3, `math.tanh` is deprecated
@external(erlang, "glua_stdlib_ffi", "math_tanh")
pub fn tanh() -> Value

/// Returns the `math.tointeger` function.
@external(erlang, "glua_stdlib_ffi", "math_tointeger")
pub fn to_integer() -> Value

/// Returns the `math.type` function.
@external(erlang, "glua_stdlib_ffi", "math_type")
pub fn type_() -> Value
43 changes: 43 additions & 0 deletions src/glua/lib/os.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//// The all the functions under `_G.os`

import glua.{type Value}

/// Returns the `os.clock` function.
@external(erlang, "glua_stdlib_ffi", "os_clock")
pub fn clock() -> Value

/// Returns the `os.date` function.
@external(erlang, "glua_stdlib_ffi", "os_date")
pub fn date() -> Value

/// Returns the `os.difftime` function.
@external(erlang, "glua_stdlib_ffi", "os_difftime")
pub fn difftime() -> Value

/// Returns the `os.execute` function.
@external(erlang, "glua_stdlib_ffi", "os_execute")
pub fn execute() -> Value

/// Returns the `os.exit` function.
@external(erlang, "glua_stdlib_ffi", "os_exit")
pub fn exit() -> Value

/// Returns the `os.getenv` function.
@external(erlang, "glua_stdlib_ffi", "os_getenv")
pub fn getenv() -> Value

/// Returns the `os.remove` function.
@external(erlang, "glua_stdlib_ffi", "os_remove")
pub fn remove() -> Value

/// Returns the `os.rename` function.
@external(erlang, "glua_stdlib_ffi", "os_rename")
pub fn rename() -> Value

/// Returns the `os.time` function.
@external(erlang, "glua_stdlib_ffi", "os_time")
pub fn time() -> Value

/// Returns the `os.tmpname` function.
@external(erlang, "glua_stdlib_ffi", "os_tmpname")
pub fn tmpname() -> Value
15 changes: 15 additions & 0 deletions src/glua/lib/package.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//// The all the functions under `_G.package`

import glua.{type Value}

/// Returns the `package.searchpath` function.
@external(erlang, "glua_stdlib_ffi", "package_searchpath")
pub fn search_path() -> Value

/// Returns the `package.searchers[1]` function.
@external(erlang, "glua_stdlib_ffi", "package_preload_searcher")
pub fn preload_searcher() -> Value

/// Returns the `package.searchers[2]` function.
@external(erlang, "glua_stdlib_ffi", "package_lua_searcher")
pub fn lua_searcher() -> Value
1 change: 1 addition & 0 deletions src/glua/lib/require.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading