use wasm_bindgen::prelude::*;
#[cfg(feature = "mmo")]
use crate::{enums::action_error_codes::game::cpu::*, prelude::*};
#[cfg(feature = "mmo")]
use js_sys::{JsString, Object};
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_name = "cpu")]
type Cpu;
#[wasm_bindgen(js_namespace = ["Game"], js_class = "cpu", static_method_of = Cpu, getter, js_name = limit)]
fn limit() -> u32;
#[wasm_bindgen(js_namespace = ["Game"], js_class = "cpu", static_method_of = Cpu, getter, js_name = tickLimit)]
fn tick_limit() -> f64;
#[wasm_bindgen(js_namespace = ["Game"], js_class = "cpu", static_method_of = Cpu, getter, js_name = bucket)]
fn bucket() -> i32;
#[cfg(feature = "mmo")]
#[wasm_bindgen(js_namespace = ["Game"], js_class = "cpu", static_method_of = Cpu, js_name = shardLimits)]
fn shard_limits() -> Object;
#[cfg(feature = "mmo")]
#[wasm_bindgen(js_namespace = ["Game"], js_class = "cpu", static_method_of = Cpu, getter, js_name = unlocked)]
fn unlocked() -> bool;
#[cfg(feature = "mmo")]
#[wasm_bindgen(js_namespace = ["Game"], js_class = "cpu", static_method_of = Cpu, getter, js_name = unlockedTime)]
fn unlocked_time() -> Option<f64>;
#[wasm_bindgen(js_namespace = ["Game"], js_class = "cpu", static_method_of = Cpu, js_name = getHeapStatistics)]
fn get_heap_statistics() -> HeapStatistics;
#[wasm_bindgen(js_namespace = ["Game"], js_class = "cpu", static_method_of = Cpu, js_name = getUsed)]
fn get_used() -> f64;
#[wasm_bindgen(js_namespace = ["Game"], js_class = "cpu", static_method_of = Cpu, js_name = halt)]
fn halt();
#[cfg(feature = "mmo")]
#[wasm_bindgen(js_namespace = ["Game"], js_class = "cpu", static_method_of = Cpu, js_name = setShardLimits)]
fn set_shard_limits(limits: &Object) -> i8;
#[cfg(feature = "mmo")]
#[wasm_bindgen(js_namespace = ["Game"], js_class = "cpu", static_method_of = Cpu, js_name = unlock)]
fn unlock() -> i8;
#[cfg(feature = "mmo")]
#[wasm_bindgen(js_namespace = ["Game"], js_class = "cpu", static_method_of = Cpu, js_name = generatePixel)]
fn generate_pixel() -> i8;
}
pub fn limit() -> u32 {
Cpu::limit()
}
pub fn tick_limit() -> f64 {
Cpu::tick_limit()
}
pub fn bucket() -> i32 {
Cpu::bucket()
}
#[cfg(feature = "mmo")]
pub fn shard_limits() -> JsHashMap<JsString, u32> {
Cpu::shard_limits().into()
}
#[cfg(feature = "mmo")]
pub fn unlocked() -> bool {
Cpu::unlocked()
}
#[cfg(feature = "mmo")]
pub fn unlocked_time() -> Option<f64> {
Cpu::unlocked_time()
}
pub fn get_heap_statistics() -> HeapStatistics {
Cpu::get_heap_statistics()
}
pub fn get_used() -> f64 {
Cpu::get_used()
}
pub fn halt() {
Cpu::halt()
}
#[cfg(feature = "mmo")]
pub fn set_shard_limits(limits: &Object) -> Result<(), SetShardLimitsErrorCode> {
SetShardLimitsErrorCode::result_from_i8(Cpu::set_shard_limits(limits))
}
#[cfg(feature = "mmo")]
pub fn unlock() -> Result<(), UnlockErrorCode> {
UnlockErrorCode::result_from_i8(Cpu::unlock())
}
#[cfg(feature = "mmo")]
pub fn generate_pixel() -> Result<(), GeneratePixelErrorCode> {
GeneratePixelErrorCode::result_from_i8(Cpu::generate_pixel())
}
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen]
pub type HeapStatistics;
#[wasm_bindgen(method, getter)]
pub fn total_heap_size(this: &HeapStatistics) -> u32;
#[wasm_bindgen(method, getter)]
pub fn total_heap_size_executable(this: &HeapStatistics) -> u32;
#[wasm_bindgen(method, getter)]
pub fn total_physical_size(this: &HeapStatistics) -> u32;
#[wasm_bindgen(method, getter)]
pub fn total_available_size(this: &HeapStatistics) -> u32;
#[wasm_bindgen(method, getter)]
pub fn used_heap_size(this: &HeapStatistics) -> u32;
#[wasm_bindgen(method, getter)]
pub fn heap_size_limit(this: &HeapStatistics) -> u32;
#[wasm_bindgen(method, getter)]
pub fn malloced_memory(this: &HeapStatistics) -> u32;
#[wasm_bindgen(method, getter)]
pub fn peak_malloced_memory(this: &HeapStatistics) -> u32;
#[wasm_bindgen(method, getter)]
pub fn does_zap_garbage(this: &HeapStatistics) -> u32;
#[wasm_bindgen(method, getter)]
pub fn externally_allocated_size(this: &HeapStatistics) -> u32;
}