Lichen

templates/ops.h

128:e3392c6469c9
2016-10-24 Paul Boddie Tidied up statement spacing and simple attribute access presentation. Added missing include and variable declarations.
     1 /* Common operations. */     2      3 #ifndef __OPS_H__     4 #define __OPS_H__     5      6 #include "types.h"     7      8 extern __attr null;     9     10 /* Direct access to functions. */    11     12 __attr __load_function(__func fn);    13     14 /* Direct access and manipulation of static objects. */    15     16 __attr __load_static(__ref obj);    17     18 /* Direct retrieval operations, returning attributes. */    19     20 __attr __load_via_class(__ref obj, int pos);    21 __attr __load_via_object(__ref obj, int pos);    22     23 /* Direct storage operations. */    24     25 int __store_via_object(__ref obj, int pos, __attr value);    26     27 /* Introspection. */    28     29 int __is_instance(__ref obj);    30 __ref __get_class(__ref obj);    31     32 /* Attribute testing operations. */    33     34 int __test_common_instance(__ref obj, int pos, int code);    35 int __test_specific_instance(__ref obj, __ref type);    36     37 /* Attribute testing and retrieval operations. */    38     39 __attr __check_and_load_via_class(__ref obj, int pos, int code);    40 __attr __check_and_load_via_object(__ref obj, int pos, int code);    41 __attr __check_and_load_via_any(__ref obj, int pos, int code);    42     43 /* Attribute testing and storage operations. */    44     45 int __check_and_store_via_object(__ref obj, int pos, int code, __attr value);    46 int __check_and_store_via_any(__ref obj, int pos, int code, __attr value);    47     48 /* Context-related operations. */    49     50 __attr __test_context(__ref context, __attr attr);    51 __attr __replace_context(__ref context, __attr attr);    52 __attr __update_context(__ref context, __attr attr);    53     54 #define __set_context(__ATTR) (__tmp_context = (__ATTR).value)    55 #define __set_accessor(__ATTR) (__tmp_value = (__ATTR).value)    56     57 /* Basic structure tests. */    58     59 int __WITHIN(__ref obj, int pos);    60 int __HASATTR(__ref obj, int pos, int code);    61     62 /* Parameter position operations. */    63     64 int __HASPARAM(const __ptable *ptable, int ppos, int pcode);    65     66 /* Conversions. */    67     68 __attr __CONTEXT_AS_VALUE(__attr attr);    69     70 /* Type testing. */    71     72 int __ISFUNC(__ref obj);    73 int __ISNULL(__attr value);    74     75 /* __TEST(obj, __A) -> test obj for the special type attribute __A */    76     77 #define __TEST(__OBJ, __TYPE) (__test_common_instance(__OBJ, __pos_##__TYPE, __code_##__TYPE))    78     79 /* Attribute codes and positions for type objects. */    80     81 unsigned int __TYPECODE(__ref obj);    82 unsigned int __TYPEPOS(__ref obj);    83     84 /* Attribute codes and positions for attribute names. */    85     86 #define __ATTRCODE(__ATTRNAME) (__code_##__ATTRNAME)    87 #define __ATTRPOS(__ATTRNAME) (__pos_##__ATTRNAME)    88     89 #endif /* __OPS_H__ */