import "task/task";
ParentRef allows to access references in parent heap when using the ComputeTask::run_parallel function. If not used from compute tasks the current heap is used instead to allow code that works in both modes the same.
Internally the references are just the integer portion of the reference. Therefore the references are weak: you must make sure that there exists a strong reference to such objects. It also allows to embed the references directly in shared arrays.
Security implications: this class allows to access arbitrary objects in the
current heap. This may be an issue for specific usages (eg. native code that has some
hidden objects in the heap that are normally not accessible and reading them has
security implications or if they contain shared arrays as these are writable). You
can protect such objects using the fixscript_set_protected
function.
static function create(obj): ParentRef
(obj as Integer)|0
. Additionally it checks for
floats so it leaves them as is so you should use this constructor in
general case (also for better readibility).
function length(): Integer
function array_get(idx: Integer): ParentRef
function is_array(): Boolean
function is_string(): Boolean
function is_hash(): Boolean
function is_shared(): Boolean
function is_funcref(): Boolean
function is_weakref(): Boolean
function is_handle(): Boolean
is_float
for detecting floats as these are passed directly.
Integers can't be tested for.
function get(): Dynamic
function clone(): Dynamic
get
function caches
the clone so it will always return the same cloned reference.
function get_shared_count(): Integer
function get_element_size(): Integer
function copy_to(dest, dest_off: Integer, src_off: Integer, count: Integer)
function extract(off: Integer, count: Integer): Dynamic
function weakref_get(): ParentRef
function hash_get(key, default_value): ParentRef
function hash_contains(key): Boolean
function to_string(): String
function to_string(newlines: Boolean): String