herolib_rust/src/rhai/platform.rs
kristof f0d7636cda
Some checks are pending
Rhai Tests / Run Rhai Tests (push) Waiting to run
...
2025-06-15 22:12:15 +02:00

40 lines
1.0 KiB
Rust

use crate::os::platform;
use rhai::{plugin::*, Engine};
#[export_module]
pub mod platform_functions {
#[rhai_fn(name = "platform_is_osx")]
pub fn is_osx() -> bool {
platform::is_osx()
}
#[rhai_fn(name = "platform_is_linux")]
pub fn is_linux() -> bool {
platform::is_linux()
}
#[rhai_fn(name = "platform_is_arm")]
pub fn is_arm() -> bool {
platform::is_arm()
}
#[rhai_fn(name = "platform_is_x86")]
pub fn is_x86() -> bool {
platform::is_x86()
}
#[rhai_fn(name = "platform_check_linux_x86")]
pub fn check_linux_x86() -> Result<(), crate::rhai::error::SalError> {
platform::check_linux_x86()
}
#[rhai_fn(name = "platform_check_macos_arm")]
pub fn check_macos_arm() -> Result<(), crate::rhai::error::SalError> {
platform::check_macos_arm()
}
}
pub fn register(engine: &mut Engine) {
let platform_module = exported_module!(platform_functions);
engine.register_global_module(platform_module.into());
}