Skip to content

Handle natives

IllidanS4 edited this page Apr 28, 2020 · 3 revisions

handle_new

native Handle:handle_new(AnyTag:value, bool:weak=false, TagTag:tag_id=tagof(value));
native Handle:handle_new_arr(const AnyTag:value[], bool:weak=false, size=sizeof(value), TagTag:tag_id=tagof(value));
native Handle:handle_new_var(ConstVariantTag:value, bool:weak=false);

Creates a new handle from a value. A "weak" handle will have access to the lifetime of the value, but will not destroy it upon collection. A non-weak handle invokes acquire upon creation and release upon destruction on the object.

handle_alias

native Handle:handle_alias(HandleTag:handle, AnyTag:value, TagTag:tag_id=tagof(value));
native Handle:handle_alias_arr(HandleTag:handle, const AnyTag:value[], size=sizeof(value), TagTag:tag_id=tagof(value));
native Handle:handle_alias_var(HandleTag:handle, ConstVariantTag:value);

Creates an aliasing handle from handle, having a new value but sharing the lifetime.

handle_acquire

native Handle:handle_acquire(HandleTag:handle);

Increases the reference count stored in the handle object.

handle_release

native Handle:handle_release(HandleTag:handle);

Decreases the reference count stored in the handle object.

handle_delete

native handle_delete(HandleTag:handle);

Deletes a handle object. A deleted handle will try to destroy the resources owned by its value, if it was not created as a weak handle.

handle_valid

native bool:handle_valid(HandleTag:handle);

Returns true if the argument is a valid handle reference.

handle_linked

native bool:handle_linked(HandleTag:handle);

Returns true if the handle is linked with an existing object (i.e. observing its lifetime).

handle_alive

native bool:handle_alive(HandleTag:handle);

Returns true if the handle is linked with an existing object or wasn't linked to any object at all. Only handles that are alive will cause their resources to be released.

handle_weak

native bool:handle_weak(HandleTag:handle);

Returns true if the handle is a weak handle. Weak handles will not cause objects to be destroyed upon their collection.

handle_get

native handle_get(HandleTag:handle, offset=0);
native handle_get_arr(HandleTag:handle, AnyTag:value[], size=sizeof(value));
native Variant:handle_get_var(HandleTag:handle);
native bool:handle_get_safe(HandleTag:handle, &AnyTag:value, offset=0, TagTag:tag_id=tagof(value));
native handle_get_arr_safe(ConstVariantTag:var, AnyTag:value[], size=sizeof(value), TagTag:tag_id=tagof(value));

Obtains the value stored in the handle. The handle can be in any state.

handle_eq

native bool:handle_eq(HandleTag:handle1, HandleTag:handle2);

Returns true if two handles are equal, i.e. watching the same object and having the same values.

handle_tagof

native handle_tagof(HandleTag:handle);

Returns the tag of the value inside the handle.

handle_sizeof

native handle_sizeof(HandleTag:handle);

Returns the size of the value inside the handle.

handle_iter

native Iter:handle_iter(HandleTag:handle, count=1);

Creates an iterator that points to a handle. Count can be used to specify the number of copies of the element in the iterator.

Clone this wiki locally