struct
DLHandle
Represents a dynamically linked library that can be loaded and unloaded.
The library is loaded on initialization and unloaded on deletion of the object.
Fields
- handle (
DTypePointer[int8, 0]
): The handle to the dynamic library.
Implemented traits
AnyType
,
Boolable
,
CollectionElement
,
Copyable
,
Movable
Methods
__init__
__init__(path: String, flags: Int = __or__(2, 256 if os_is_linux() else 8)) -> Self
Initialize a DLHandle object by loading the dynamic library at the given path.
Args:
- path (
String
): The path to the dynamic library file. - flags (
Int
): The flags to load the dynamic library.
Returns:
The constructed handle object.
__bool__
__bool__(self: Self) -> Bool
Checks if the handle is valid.
Returns:
True if the DLHandle is not null and False otherwise.
close
close(inout self: Self)
Delete the DLHandle object unloading the associated dynamic library.
get_function
get_function[result_type: AnyRegType](self: Self, name: String) -> $0
Returns a handle to the function with the given name in the dynamic library.
Parameters:
- result_type (
AnyRegType
): The type of the function pointer to return.
Args:
- name (
String
): The name of the function to get the handle for.
Returns:
A handle to the function.