Debian Codegraph @

texk/web2c/mfluadir/otfcc/include/caryll/element.h

raw
1 #ifndef CARYLL_INCLUDE_ELEMENT_H
2 #define CARYLL_INCLUDE_ELEMENT_H
3
4 #include <stddef.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <stdbool.h>
8
9 #include "ownership.h"
10
11 // We assume all T have trivial move constructors.
12 #define caryll_T(T) \
13 void (*init)(MODIFY T *); \
14 void (*copy)(MODIFY T *, const T *); \
15 void (*move)(MODIFY T *, T *); \
16 void (*dispose)(MOVE T *); \
17 void (*replace)(MODIFY T *, MOVE const T); \
18 void (*copyReplace)(MODIFY T *, const T)
19
20 #define caryll_VT(T) \
21 caryll_T(T); \
22 T (*empty)(); \
23 T (*dup)(const T)
24 #define caryll_RT(T) \
25 caryll_T(T); \
26 T *(*create)(); \
27 void (*free)(MOVE T *)
28
29 #define caryll_ElementInterfaceOf(T) const struct __caryll_elementinterface_##T
30 #define caryll_ElementInterface(T) \
31 caryll_ElementInterfaceOf(T) { \
32 caryll_T(T); \
33 }
34 #define caryll_RefElementInterface(T) \
35 caryll_ElementInterfaceOf(T) { \
36 caryll_RT(T); \
37 }
38 #define caryll_ValElementInterface(T) \
39 caryll_ElementInterfaceOf(T) { \
40 caryll_VT(T); \
41 }
42
43 /// Individual traits
44
45 #define caryll_Show(T) void (*show)(const T)
46 #define caryll_Eq(T) bool (*equal)(const T, const T)
47 #define caryll_Ord(T) \
48 caryll_Eq(T); \
49 int (*compare)(const T a, const T b); \
50 int (*compareRef)(const T *a, const T *b)
51 #define caryll_Monoid(T) \
52 T (*neutral)(); \
53 T (*plus)(const T a, const T b); \
54 void (*inplacePlus)(MODIFY T * a, const T b)
55 #define caryll_Group(T) \
56 caryll_Monoid(T); \
57 void (*inplaceNegate)(MODIFY T * a); \
58 T (*negate)(const T); \
59 void (*inplaceMinus)(MODIFY T *, const T); \
60 T (*minus)(const T, const T)
61 #define caryll_Module(T, TScale) \
62 caryll_Group(T); \
63 void (*inplaceScale)(MODIFY T * a, TScale b); \
64 void (*inplacePlusScale)(MODIFY T * a, TScale b, const T c); \
65 T (*scale)(const T a, TScale b)
66
67 #endif