Lichen

templates/types.h

128:e3392c6469c9
2016-10-24 Paul Boddie Tidied up statement spacing and simple attribute access presentation. Added missing include and variable declarations.
     1 /* Runtime types. */     2      3 #ifndef __TYPES_H__     4 #define __TYPES_H__     5      6 /* Attribute tables are lists of codes confirming the presence of attributes. */     7      8 typedef struct __table     9 {    10     const unsigned int size, attrs[];    11 } __table;    12     13 /* Parameter tables are lists of codes confirming the presence of parameters, as    14    well as the positions of those parameters in the list for a given function.    15 */    16     17 typedef struct __param    18 {    19     unsigned short code, pos;    20 } __param;    21     22 typedef struct __ptable    23 {    24     const unsigned int size;    25     const __param params[];    26 } __ptable;    27     28 /* Attributes are context and value pairs.    29    Objects are collections of attributes.    30    Object references are references to tables and collections of attributes.    31    Attribute references are references to single attributes. */    32     33 typedef struct __obj __obj;    34     35 typedef struct __attr    36 {    37     /* One of... */    38     union    39     {    40         __obj * context;        /* attribute context */    41         unsigned int min;       /* minimum number of parameters */    42         __obj * b;              /* bound callable object */    43     };    44     45     /* One of... */    46     union    47     {    48         __obj * value;          /* attribute value */    49         const __ptable * ptable;/* parameter table */    50         struct __attr (*fn)();  /* callable details */    51     };    52 } __attr;    53     54 typedef struct __obj    55 {    56     const __table * table;      /* attribute table */    57     unsigned int pos;           /* position of attribute indicating class */    58     __attr attrs[];             /* attributes */    59 } __obj;    60     61 typedef __obj * __ref;    62     63 /* Special instance position value. The pos member of __obj refers to the    64    special type attribute for classes. For instances, it is set to zero. */    65     66 #define __INSTANCEPOS 0    67     68 /* Function pointer type. */    69     70 typedef __attr (*__func)();    71     72 /* Convenience macros. */    73     74 #define __ARGS(...) ((__attr[]) {__VA_ARGS__})    75 #define __KWARGS(...) ((__param[]) {__VA_ARGS__})    76     77 #endif /* __TYPES_H__ */