mirror of
https://github.com/lune-org/lune.git
synced 2025-04-10 21:40:54 +01:00
Merge branch 'main' into feature/jit-toggle
This commit is contained in:
commit
8c60009c5e
6 changed files with 35 additions and 27 deletions
|
@ -113,7 +113,6 @@ pub fn add_methods<'lua, M: LuaUserDataMethods<'lua, Instance>>(m: &mut M) {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
m.add_method("IsA", |_, this, class_name: String| {
|
m.add_method("IsA", |_, this, class_name: String| {
|
||||||
ensure_not_destroyed(this)?;
|
|
||||||
Ok(class_is_a(&this.class_name, class_name).unwrap_or(false))
|
Ok(class_is_a(&this.class_name, class_name).unwrap_or(false))
|
||||||
});
|
});
|
||||||
m.add_method(
|
m.add_method(
|
||||||
|
@ -217,19 +216,20 @@ fn instance_property_get<'lua>(
|
||||||
this: &Instance,
|
this: &Instance,
|
||||||
prop_name: String,
|
prop_name: String,
|
||||||
) -> LuaResult<LuaValue<'lua>> {
|
) -> LuaResult<LuaValue<'lua>> {
|
||||||
ensure_not_destroyed(this)?;
|
|
||||||
|
|
||||||
match prop_name.as_str() {
|
match prop_name.as_str() {
|
||||||
"ClassName" => return this.get_class_name().into_lua(lua),
|
"ClassName" => return this.get_class_name().into_lua(lua),
|
||||||
"Name" => {
|
|
||||||
return this.get_name().into_lua(lua);
|
|
||||||
}
|
|
||||||
"Parent" => {
|
"Parent" => {
|
||||||
return this.get_parent().into_lua(lua);
|
return this.get_parent().into_lua(lua);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ensure_not_destroyed(this)?;
|
||||||
|
|
||||||
|
if prop_name.as_str() == "Name" {
|
||||||
|
return this.get_name().into_lua(lua);
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(info) = find_property_info(&this.class_name, &prop_name) {
|
if let Some(info) = find_property_info(&this.class_name, &prop_name) {
|
||||||
if let Some(prop) = this.get_property(&prop_name) {
|
if let Some(prop) = this.get_property(&prop_name) {
|
||||||
if let DomValue::Enum(enum_value) = prop {
|
if let DomValue::Enum(enum_value) = prop {
|
||||||
|
|
|
@ -302,10 +302,7 @@ impl Instance {
|
||||||
pub fn get_parent(&self) -> Option<Instance> {
|
pub fn get_parent(&self) -> Option<Instance> {
|
||||||
let dom = INTERNAL_DOM.lock().expect("Failed to lock document");
|
let dom = INTERNAL_DOM.lock().expect("Failed to lock document");
|
||||||
|
|
||||||
let parent_ref = dom
|
let parent_ref = dom.get_by_ref(self.dom_ref)?.parent();
|
||||||
.get_by_ref(self.dom_ref)
|
|
||||||
.expect("Failed to find instance in document")
|
|
||||||
.parent();
|
|
||||||
|
|
||||||
if parent_ref == dom.root_ref() {
|
if parent_ref == dom.root_ref() {
|
||||||
None
|
None
|
||||||
|
|
|
@ -50,6 +50,11 @@ pub fn module(lua: &Lua) -> LuaResult<LuaTable> {
|
||||||
// Create constants for OS & processor architecture
|
// Create constants for OS & processor architecture
|
||||||
let os = lua.create_string(OS.to_lowercase())?;
|
let os = lua.create_string(OS.to_lowercase())?;
|
||||||
let arch = lua.create_string(ARCH.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
|
// Create readonly args array
|
||||||
let args_vec = lua
|
let args_vec = lua
|
||||||
.app_data_ref::<Vec<String>>()
|
.app_data_ref::<Vec<String>>()
|
||||||
|
@ -75,6 +80,7 @@ pub fn module(lua: &Lua) -> LuaResult<LuaTable> {
|
||||||
TableBuilder::new(lua)?
|
TableBuilder::new(lua)?
|
||||||
.with_value("os", os)?
|
.with_value("os", os)?
|
||||||
.with_value("arch", arch)?
|
.with_value("arch", arch)?
|
||||||
|
.with_value("endianness", endianness)?
|
||||||
.with_value("args", args_tab)?
|
.with_value("args", args_tab)?
|
||||||
.with_value("cwd", cwd_str)?
|
.with_value("cwd", cwd_str)?
|
||||||
.with_value("env", env_tab)?
|
.with_value("env", env_tab)?
|
||||||
|
|
|
@ -20,14 +20,10 @@ assert(not pcall(function()
|
||||||
return child1.Name
|
return child1.Name
|
||||||
end))
|
end))
|
||||||
|
|
||||||
assert(not pcall(function()
|
assert(not child1.Parent)
|
||||||
return child1.Parent
|
|
||||||
end))
|
|
||||||
|
|
||||||
assert(not pcall(function()
|
assert(not pcall(function()
|
||||||
return child2.Name
|
return child2.Name
|
||||||
end))
|
end))
|
||||||
|
|
||||||
assert(not pcall(function()
|
assert(not child2.Parent)
|
||||||
return child2.Parent
|
|
||||||
end))
|
|
||||||
|
|
|
@ -14,22 +14,16 @@ assert(not pcall(function()
|
||||||
return root.Name
|
return root.Name
|
||||||
end))
|
end))
|
||||||
|
|
||||||
assert(not pcall(function()
|
assert(not root.Parent)
|
||||||
return root.Parent
|
|
||||||
end))
|
|
||||||
|
|
||||||
assert(not pcall(function()
|
assert(not pcall(function()
|
||||||
return child.Name
|
return child.Name
|
||||||
end))
|
end))
|
||||||
|
|
||||||
assert(not pcall(function()
|
assert(not child.Parent)
|
||||||
return child.Parent
|
|
||||||
end))
|
|
||||||
|
|
||||||
assert(not pcall(function()
|
assert(not pcall(function()
|
||||||
return descendant.Name
|
return descendant.Name
|
||||||
end))
|
end))
|
||||||
|
|
||||||
assert(not pcall(function()
|
assert(not descendant.Parent)
|
||||||
return descendant.Parent
|
|
||||||
end))
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
export type OS = "linux" | "macos" | "windows"
|
export type OS = "linux" | "macos" | "windows"
|
||||||
export type Arch = "x86_64" | "aarch64"
|
export type Arch = "x86_64" | "aarch64"
|
||||||
|
export type Endianness = "big" | "little"
|
||||||
|
|
||||||
export type SpawnOptionsStdioKind = "default" | "inherit" | "forward" | "none"
|
export type SpawnOptionsStdioKind = "default" | "inherit" | "forward" | "none"
|
||||||
export type SpawnOptionsStdio = {
|
export type SpawnOptionsStdio = {
|
||||||
|
@ -117,8 +118,8 @@ export type ChildProcess = {
|
||||||
stdin: typeof(ChildProcessWriter),
|
stdin: typeof(ChildProcessWriter),
|
||||||
stdout: typeof(ChildProcessReader),
|
stdout: typeof(ChildProcessReader),
|
||||||
stderr: typeof(ChildProcessReader),
|
stderr: typeof(ChildProcessReader),
|
||||||
kill: () -> ();
|
kill: () -> (),
|
||||||
status: () -> { ok: boolean, code: number }
|
status: () -> { ok: boolean, code: number },
|
||||||
}
|
}
|
||||||
|
|
||||||
--[=[
|
--[=[
|
||||||
|
@ -222,6 +223,20 @@ process.os = (nil :: any) :: OS
|
||||||
]=]
|
]=]
|
||||||
process.arch = (nil :: any) :: Arch
|
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
|
@within Process
|
||||||
@prop args { string }
|
@prop args { string }
|
||||||
|
|
Loading…
Add table
Reference in a new issue