Reduct  v4.0.5-1-g4851deb
A functional and immutable language.
Loading...
Searching...
No Matches
Native Functions and Intrinsics

Detailed Description

A "native" is a C function that can be called at runtime, each native may have an associated "intrinsic", which is a function that is called during compilation.

Both are stored in a unified hash map keyed by name.

See also
intrinsic

Data Structures

struct  reduct_native_t
 Native function definition structure. More...
 
struct  reduct_native_global_t
 Global native-related state structure. More...
 
struct  reduct_native_entry_t
 Native map entry. More...
 

Macros

#define REDUCT_NATIVE_MAP_INITIAL   256
 The initial size of the native map.
 
#define REDUCT_NATIVE_MAP_GROWTH   2
 The growth factor of the native map.
 

Functions

REDUCT_API void reduct_native_global_init (reduct_native_global_t *global)
 Initialize a global native state.
 
REDUCT_API void reduct_native_global_deinit (reduct_native_global_t *global)
 Deinitialize a global native state.
 
REDUCT_API reduct_native_entry_treduct_native_map_find (struct reduct *reduct, uint32_t hash, const char *str, size_t len)
 Find a native entry in the map.
 
REDUCT_API void reduct_native_register (struct reduct *reduct, const reduct_native_t *array, size_t count)
 Register native functions.
 

Macro Definition Documentation

◆ REDUCT_NATIVE_MAP_INITIAL

#define REDUCT_NATIVE_MAP_INITIAL   256

The initial size of the native map.

Definition at line 38 of file native.h.

◆ REDUCT_NATIVE_MAP_GROWTH

#define REDUCT_NATIVE_MAP_GROWTH   2

The growth factor of the native map.

Definition at line 39 of file native.h.

Function Documentation

◆ reduct_native_global_init()

REDUCT_API void reduct_native_global_init ( reduct_native_global_t global)

Initialize a global native state.

Parameters
globalPointer to the global native state to initialize.

◆ reduct_native_global_deinit()

REDUCT_API void reduct_native_global_deinit ( reduct_native_global_t global)

Deinitialize a global native state.

Parameters
globalPointer to the global native state to deinitialize.

◆ reduct_native_map_find()

REDUCT_API reduct_native_entry_t * reduct_native_map_find ( struct reduct *  reduct,
uint32_t  hash,
const char *  str,
size_t  len 
)

Find a native entry in the map.

Parameters
reductPointer to the Reduct structure.
hashThe hash of the name.
strThe name string.
lenThe length of the name.
Returns
A pointer to the native entry, or NULL if not found.

◆ reduct_native_register()

REDUCT_API void reduct_native_register ( struct reduct *  reduct,
const reduct_native_t array,
size_t  count 
)

Register native functions.

Parameters
reductPointer to the Reduct structure.
arrayAn array of native function definitions.
countThe number of functions in the array.