forked from toddjasonblackmon/wren
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwren.h
96 lines (72 loc) · 1.86 KB
/
wren.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/** @file wren.h
*
* @brief Wren configuration and API
*
* @par
* @copyright Copyright © 2018 Doug Currie, Londonderry, NH, USA
*/
#ifndef WREN_H
#define WREN_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdio.h>
/* ############## Configuration ############## */
/** @def WREN_UNALIGNED_ACCESS_OK
* @brief non-zero enables reads and writes of multi-byte values from/to unaligned addresses.
* Default to safe mode: no unaligned accesses.
*/
#ifndef WREN_UNALIGNED_ACCESS_OK
#define WREN_UNALIGNED_ACCESS_OK (0)
#endif
/** @def WREN_STANDALONE
* @brief non-zero enables main() with command line config and read-eval-print loop.
* Default to standalone; set to 0 if you want to use Wren as a library.
*/
#ifndef WREN_STANDALONE
#define WREN_STANDALONE (1)
#endif
/* ################## Types ################## */
#if 0
/** Type of a Wren-language value.
*/
typedef intptr_t wValue;
/* and how to printf it
*/
#define PRVAL "ld"
/** Type of the unsigned version of a Wren-language value.
*/
typedef uintptr_t wUvalu;
#else
/** Type of a Wren-language value.
*/
typedef int32_t wValue;
/* and how to printf it
*/
#define PRVAL "d"
/** Type of the unsigned version of a Wren-language value.
*/
typedef uint32_t wUvalu;
#endif
/** Type of a Wren-language index into the_store. Must be half the size of wValue or smaller.
*/
typedef uint16_t wIndex;
/* and how to printf it
*/
#define PRIDX "u"
/** Type of a Wren-language pointer to C function.
*/
typedef wValue (*apply_t)(); // the type of C functions for CCALL and wren_bind_c_function()
/* and how to printf it
*/
#define PRPTR "p"
/* ################### API ################### */
void wren_initialize (void);
void wren_bind_c_function (const char *name, apply_t fn, const uint8_t arity);
void wren_load_file (FILE *fp);
void wren_read_eval_print_loop (void);
#ifdef __cplusplus
}
#endif
#endif /* WREN_H */