-
Notifications
You must be signed in to change notification settings - Fork 0
/
adt.h
42 lines (33 loc) · 841 Bytes
/
adt.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
#ifndef adt_H_
#define adt_H_
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
// Send message macros
#define SEND(receiver, wutdo)\
receiver->methods->wutdo(receiver)
#define SEND1(receiver,wutdo,arg)\
receiver->methods->wutdo(receiver,arg)
// Declare csAdt instance.
typedef struct csAdt {
struct csAdtMethods *methods;
uint32_t hash;
} csAdt, *csAdtRef;
// Declare types of methods.
typedef uint32_t (*pfn_uint32_adtRef)(csAdtRef);
typedef bool (*pfn_bool_adtRefAdtRef)(csAdtRef, csAdtRef);
typedef char * (*pfn_cstr_adtRef)(csAdtRef);
// Declare csAdt interface.
typedef struct csAdtMethods {
pfn_uint32_adtRef hash;
pfn_bool_adtRefAdtRef equals;
pfn_cstr_adtRef description;
} csAdtMethods, *csAdtMethodsRef;
#ifdef __cplusplus
extern "C" {
#endif
csAdtRef newCsAdt(void);
#ifdef __cplusplus
}
#endif
#endif