Reduct  v1.0.4-3-gdaf0d70
A functional and immutable language.
Loading...
Searching...
No Matches
native.h
Go to the documentation of this file.
1#ifndef REDUCT_NATIVE_H
2#define REDUCT_NATIVE_H 1
3
4#include "defs.h"
5
6struct reduct;
7
8/**
9 * @file native.h
10 * @brief Native function registration.
11 * @defgroup native Native Functions
12 *
13 * A "native" is a C function that can be called at runtime.
14 *
15 * @{
16 */
17
18/**
19 * @brief Native function pointer type.
20 *
21 * @param reduct The Reduct structure.
22 * @param argc The number of arguments.
23 * @param argv The array of arguments.
24 * @return The result of the function.
25 */
26typedef reduct_handle_t (*reduct_native_fn)(struct reduct* reduct, reduct_size_t argc, reduct_handle_t* argv);
27
28/**
29 * @brief Native function definition structure.
30 */
31typedef struct
32{
33 const char* name;
36
37/**
38 * @brief Register native functions.
39 *
40 * @param reduct The Reduct structure.
41 * @param array An array of native function definitions.
42 * @param count The number of functions in the array.
43 */
44REDUCT_API void reduct_native_register(struct reduct* reduct, reduct_native_t* array, reduct_size_t count);
45
46/** @} */
47
48#endif
size_t reduct_size_t
Definition defs.h:100
reduct_uint64_t reduct_handle_t
Handle type.
Definition defs.h:189
#define REDUCT_API
Definition defs.h:7
reduct_handle_t(* reduct_native_fn)(struct reduct *reduct, reduct_size_t argc, reduct_handle_t *argv)
Native function pointer type.
Definition native.h:26
REDUCT_API void reduct_native_register(struct reduct *reduct, reduct_native_t *array, reduct_size_t count)
Register native functions.
Native function definition structure.
Definition native.h:32
const char * name
Definition native.h:33
reduct_native_fn fn
Definition native.h:34