Header menu logo Nu

NativePtr Module

Native pointer operations.

Functions and values

Function or value Description

NativePtr.asNativeInt managedPtr

Full Usage: NativePtr.asNativeInt managedPtr

Parameters:
    managedPtr : byref<'a>

Returns: nativeint

Convert a managed pointer to a nativeint.

managedPtr : byref<'a>
Returns: nativeint

NativePtr.asPointer managedPtr

Full Usage: NativePtr.asPointer managedPtr

Parameters:
    managedPtr : byref<'a>

Returns: nativeptr<'a>

Convert a managed pointer to a typed native pointer.

managedPtr : byref<'a>
Returns: nativeptr<'a>

NativePtr.asVoidPtr managedPtr

Full Usage: NativePtr.asVoidPtr managedPtr

Parameters:
    managedPtr : byref<'a>

Returns: voidptr

Convert a managed pointer to a void pointer.

managedPtr : byref<'a>
Returns: voidptr

NativePtr.fixedBufferToArray length fixedBuffer

Full Usage: NativePtr.fixedBufferToArray length fixedBuffer

Parameters:
    length : int
    fixedBuffer : obj

Returns: 'a array

Convert a fixed-size buffer to an array of given type and length.

length : int
fixedBuffer : obj
Returns: 'a array

NativePtr.fixedBufferToString fixedBuffer

Full Usage: NativePtr.fixedBufferToString fixedBuffer

Parameters:
    fixedBuffer : 'a

Returns: string

Convert a fixed-size buffer to a string.

fixedBuffer : 'a
Returns: string

NativePtr.freeUnmanagedString ptr

Full Usage: NativePtr.freeUnmanagedString ptr

Parameters:
    ptr : nativeptr<'a>

Free an unmanaged string.

ptr : nativeptr<'a>

NativePtr.memCopy offset size source dest

Full Usage: NativePtr.memCopy offset size source dest

Parameters:
    offset : int
    size : int
    source : voidptr
    dest : voidptr

Copy data of the given size from source to destination at the given offset.

offset : int
size : int
source : voidptr
dest : voidptr

NativePtr.nativeintToBytePtr nint

Full Usage: NativePtr.nativeintToBytePtr nint

Parameters:
    nint : nativeint

Returns: nativeptr<byte>

Convert nativeint to byte pointer.

nint : nativeint
Returns: nativeptr<byte>

NativePtr.nativeintToVoidPtr nint

Full Usage: NativePtr.nativeintToVoidPtr nint

Parameters:
    nint : nativeint

Returns: voidptr

Convert nativeint to void pointer.

nint : nativeint
Returns: voidptr

NativePtr.notNullPtr ptr

Full Usage: NativePtr.notNullPtr ptr

Parameters:
    ptr : nativeptr<'a>

Returns: bool

Tests whether the given native ptr is not null.

ptr : nativeptr<'a>
Returns: bool

NativePtr.offsetOf fieldName

Full Usage: NativePtr.offsetOf fieldName

Parameters:
    fieldName : string

Returns: int

Get the byte offset of a field within the unmanaged form of a managed type. This is valid for any struct that does not contain non-blittable types like bool.

fieldName : string
Returns: int

NativePtr.reinterpretRef source

Full Usage: NativePtr.reinterpretRef source

Parameters:
    source : byref<'a>

Returns: byref<'b>

Reinterprets the type of a managed pointer from 'a to 'b in an unsafe manner. NOTE: Because of automatic dereferencing, the result must be *re*referenced after calling.

source : byref<'a>
Returns: byref<'b>

NativePtr.spanToString span

Full Usage: NativePtr.spanToString span

Parameters:
Returns: string

Convert a ReadOnlySpan to a string.

span : ReadOnlySpan<byte>
Returns: string

NativePtr.stringToUnmanaged str

Full Usage: NativePtr.stringToUnmanaged str

Parameters:
    str : string

Returns: nativeptr<byte>

Convert a managed string to an unmanaged string that must be manually freed.

str : string
Returns: nativeptr<byte>

NativePtr.unmanagedToString ptr

Full Usage: NativePtr.unmanagedToString ptr

Parameters:
    ptr : nativeptr<byte>

Returns: string

Convert an unmanaged string to a managed string.

ptr : nativeptr<byte>
Returns: string

NativePtr.writeArrayToFixedBuffer array fixedBuffer

Full Usage: NativePtr.writeArrayToFixedBuffer array fixedBuffer

Parameters:
    array : 'a array
    fixedBuffer : 'b

Returns: 'b

Write an array onto a fixed-size buffer. This is an INSECURE pure function that will corrupt the stack if you exceed fixedBuffer's size.

array : 'a array
fixedBuffer : 'b
Returns: 'b

Type something to start searching.