/
types.h
105 lines (88 loc) · 2.08 KB
/
types.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
97
98
99
100
101
102
103
104
105
#define T_STRING 's'
#define T_INT 'i'
#define T_REAL 'r'
#define T_FUNCTION 'f'
#define T_WILDCARD '*'
#define T_LIST '['
#define T_LIST_END ']'
#define T_NOLIST 'x'
//#define T_PARAM 'p'
#define T_OSCSTREAM 'o'
#define T_OSC 'O'
#define T_NOTHING '~'
#define NUM_OF_TYPES 11
#define MAXLEN 255
#define MAXNAMES 2048
#define MAXDEPTH 32
#define MAXEDGES MAXNAMES
#define MAX_CONSTRAINTS NUM_OF_TYPES
#include <clutter/clutter.h>
typedef struct var t_var;
typedef struct function t_function;
typedef struct {
int depth;
t_var *vars[MAXDEPTH];
} t_edge;
struct function {
t_var *input;
t_var *output;
};
struct {
t_var *vars[MAXLEN];
int var_n;
} t_list;
// represent wildcard as a separate t_var, link others to it, then
// change it
typedef t_var *t_wildcard[MAX_CONSTRAINTS + 1];
struct var {
ClutterText *text;
t_var *output_from;
t_var *input_to;
t_var *applied_as;
char typetag;
int assigned;
float x, y;
float width, height;
float applied_x, applied_y;
float applied_width, applied_height;
t_var *list_next;
t_var *list_first; // first element in T_START_LIST types
int list_function; // list specified as function, not as [ ]
t_wildcard wildcard;
t_wildcard wildcard_test;
int wildcard_curry_id;
union {
int i;
float r;
char s[MAXLEN + 1];
t_function f;
t_var *list_type;
};
};
typedef struct {
char name[MAXLEN + 1];
t_var *var;
} t_name;
typedef struct {
int n;
t_name names[MAXNAMES];
} t_namespace;
extern t_var *i();
extern t_var *r();
extern t_var *s();
extern t_var *p();
extern t_var *o();
extern t_var *n();
extern t_var *l(t_var *type);
extern t_var *l_end();
extern t_var *w(t_var *a, ...);
extern t_var *f(t_var *input, t_var *output);
extern t_namespace *get_namespace(void);
extern t_name *find_name(t_namespace *namespace, char *str);
extern char *show_type(t_var *t);
extern char *show_name(t_name *name);
extern t_var *applied_type(t_var *v);
extern int type_eq(t_var *a, t_var *b, int curry_id);
extern void reset_mempool();
extern t_var *next_mempool();
//extern ClutterColor *type_colour(t_var *var);