In Native calling interface§
See primary documentation in context for sub nativecast
sub nativecast($target-type, $source) is export(:DEFAULT)
This will cast the Pointer
$source
to an object of $target-type
. The source pointer will typically have been obtained from a call to a native subroutine that returns a pointer or as a member of a struct
, this may be specified as void *
in the C
library definition for instance, but you may also cast from a pointer to a less specific type to a more specific one.
As a special case, if a Signature
is supplied as $target-type
then a subroutine
will be returned which will call the native function pointed to by $source
in the same way as a subroutine declared with the native
trait. This is described in Function Pointers.