Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add process.endianness for ffi support #267

Merged
merged 3 commits into from
Nov 5, 2024
Merged
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
6 changes: 6 additions & 0 deletions crates/lune-std-process/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ pub fn module(lua: &Lua) -> LuaResult<LuaTable> {
// Create constants for OS & processor architecture
let os = lua.create_string(OS.to_lowercase())?;
let arch = lua.create_string(ARCH.to_lowercase())?;
let endianness = lua.create_string(if cfg!(target_endian = "big") {
"big"
} else {
"little"
})?;
// Create readonly args array
let args_vec = lua
.app_data_ref::<Vec<String>>()
Expand All @@ -75,6 +80,7 @@ pub fn module(lua: &Lua) -> LuaResult<LuaTable> {
TableBuilder::new(lua)?
.with_value("os", os)?
.with_value("arch", arch)?
.with_value("endianness", endianness)?
.with_value("args", args_tab)?
.with_value("cwd", cwd_str)?
.with_value("env", env_tab)?
Expand Down
19 changes: 17 additions & 2 deletions types/process.luau
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export type OS = "linux" | "macos" | "windows"
export type Arch = "x86_64" | "aarch64"
export type Endianness = "big" | "little"

export type SpawnOptionsStdioKind = "default" | "inherit" | "forward" | "none"
export type SpawnOptionsStdio = {
Expand Down Expand Up @@ -117,8 +118,8 @@ export type ChildProcess = {
stdin: typeof(ChildProcessWriter),
stdout: typeof(ChildProcessReader),
stderr: typeof(ChildProcessReader),
kill: () -> ();
status: () -> { ok: boolean, code: number }
kill: () -> (),
status: () -> { ok: boolean, code: number },
}

--[=[
Expand Down Expand Up @@ -222,6 +223,20 @@ process.os = (nil :: any) :: OS
]=]
process.arch = (nil :: any) :: Arch

--[=[
@within Process
@prop endianness Endianness
@tag read_only

The endianness of the processor currently being used.

Possible values:

* `"big"`
* `"little"`
]=]
process.endianness = (nil :: any) :: Endianness

--[=[
@within Process
@prop args { string }
Expand Down