package core.js
ValuePool :: struct {
values: [..] Value
} To aid in managing Values that are created over the life time of the program, ValuePool collects all of the Values and allows for releasing them all at once.
Type :: enum {
Undefined :: 0
Null :: 1
Boolean :: 2
Number :: 3
String :: 4
Symbol :: 5
Object :: 6
Function :: 7
}Func :: #distinct DISTINCT TYPERepresents an Onyx function that can be called by JavaScript.
Value :: #distinct u64Used to represent a JavaScript value.
Value.as_bool :: (v: Value) -> ? bool Converts a Value into a bool. If the value is not internally of boolean type, None is returned.
Value.as_float :: (v: Value) -> ? f64 Converts a Value into a f64. If the value is not internally of float type, None is returned.
Value.as_int :: (v: Value) -> ? i32 Converts a Value into a i32. If the value is not internally of float type, None is returned.
Value.as_str :: (v: Value) -> ? [] u8 Converts a Value into a str. If the value is not internally of str type, None is returned.
Note that this function returns a string that is allocated on the heap. The caller is responsible for managing the returned string.
Value.call :: (v: Value, method: [] u8, args: [] any) -> ValueValue.call :: (v: Value, method: [] u8, args: ..any) -> ValueValue.copy_to_js :: (v: Value, buf: [] u8) -> i32Copies data into a Uint8Array in JS from a buffer in Onyx. Returns the number of bytes copied, or -1 if the value was not a Uint8Array.
Value.copy_to_onyx :: (v: Value, buf: [] u8) -> i32Copies data from a Uint8Array in JS to a buffer in Onyx. Returns the number of bytes copied, or -1 if the value was not a Uint8Array.
Value.delete :: (v: Value, property: [] u8) -> void Invokes the JavaScript delete operator on the specified property.
Value.get :: (v: Value, prop: [] u8) -> Value Retrieves the evaluation of vprop] in JavaScript.
Value.index :: (v: Value, i: i32) -> Value Retrieves the evaluation of vi] in JavaScript.
Value.instance_of :: (v: Value, base: Value) -> bool Returns the evaluation of the instanceof operator in JavaScript.
Value.invoke :: (v: Value, args: ..any) -> ValueValue.invoke :: (v: Value, args: ..any) -> ValueValue.leak :: (v: Value) -> Value Removes the Value from current ValuePool. This means that the Value will not be automatically collected, and must be released with Value.release.
Value.length :: (v: Value) -> i32 Special case for ->get("length"). Because it is required so often, this optimization is quite nice.
Value.new :: (v: Value, args: ..any) -> Value Invokes the new operator on the Value, with arguments args.
Value.new_array :: () -> Value Creates a new JavaScript array and returns the Value handle to it.
Value.new_object :: () -> Value Creates a new JavaScript object and returns the Value handle to it.
Value.release :: (v: Value) -> void Releases the Value from the JavaScript heap. The Value should not be used after this method is called.
Value.set :: (v: Value, prop: [] u8, value: Value) -> voidValue.set :: (v: Value, prop: str, value: $T) -> voidValue.set :: (v: Value, index: i32, value: Value) -> voidValue.set :: (v: Value, index: i32, value: $T) -> voidValue.truthy :: (v: Value) -> boolJavaScript defines a "falsesy" value as undefined, null, false, 0, and "". All other values are "truthy".
release_pooled_objects :: () -> void Releases all objects in the current ValuePool.
setup_default_pool :: () -> void Creates a new ValuePool and uses it. The old ValuePool is forgotten.