paul@126 | 1 | /* Common operations. */ |
paul@126 | 2 | |
paul@126 | 3 | #ifndef __OPS_H__ |
paul@126 | 4 | #define __OPS_H__ |
paul@126 | 5 | |
paul@126 | 6 | #include "types.h" |
paul@148 | 7 | #include <string.h> /* for __COPY */ |
paul@126 | 8 | |
paul@126 | 9 | /* Direct access and manipulation of static objects. */ |
paul@126 | 10 | |
paul@200 | 11 | __attr __load_static(__ref parent, __ref obj); |
paul@126 | 12 | |
paul@126 | 13 | /* Direct retrieval operations, returning attributes. */ |
paul@126 | 14 | |
paul@126 | 15 | __attr __load_via_class(__ref obj, int pos); |
paul@126 | 16 | __attr __load_via_object(__ref obj, int pos); |
paul@153 | 17 | __attr __get_class_and_load(__ref obj, int pos); |
paul@126 | 18 | |
paul@126 | 19 | /* Direct storage operations. */ |
paul@126 | 20 | |
paul@126 | 21 | int __store_via_object(__ref obj, int pos, __attr value); |
paul@252 | 22 | int __get_class_and_store(__ref obj, int pos, __attr value); |
paul@126 | 23 | |
paul@126 | 24 | /* Introspection. */ |
paul@126 | 25 | |
paul@126 | 26 | int __is_instance(__ref obj); |
paul@126 | 27 | __ref __get_class(__ref obj); |
paul@231 | 28 | __attr __get_class_attr(__ref obj); |
paul@126 | 29 | |
paul@126 | 30 | /* Attribute testing operations. */ |
paul@126 | 31 | |
paul@237 | 32 | __ref __test_specific_instance(__ref obj, __ref type); |
paul@237 | 33 | __ref __test_specific_object(__ref obj, __ref type); |
paul@237 | 34 | __ref __test_specific_type(__ref obj, __ref type); |
paul@144 | 35 | __ref __test_common_instance(__ref obj, int pos, int code); |
paul@144 | 36 | __ref __test_common_object(__ref obj, int pos, int code); |
paul@144 | 37 | __ref __test_common_type(__ref obj, int pos, int code); |
paul@126 | 38 | |
paul@126 | 39 | /* Attribute testing and retrieval operations. */ |
paul@126 | 40 | |
paul@126 | 41 | __attr __check_and_load_via_class(__ref obj, int pos, int code); |
paul@126 | 42 | __attr __check_and_load_via_object(__ref obj, int pos, int code); |
paul@126 | 43 | __attr __check_and_load_via_any(__ref obj, int pos, int code); |
paul@126 | 44 | |
paul@126 | 45 | /* Attribute testing and storage operations. */ |
paul@126 | 46 | |
paul@252 | 47 | int __check_and_store_via_class(__ref obj, int pos, int code, __attr value); |
paul@126 | 48 | int __check_and_store_via_object(__ref obj, int pos, int code, __attr value); |
paul@126 | 49 | int __check_and_store_via_any(__ref obj, int pos, int code, __attr value); |
paul@126 | 50 | |
paul@126 | 51 | /* Context-related operations. */ |
paul@126 | 52 | |
paul@126 | 53 | __attr __test_context(__ref context, __attr attr); |
paul@126 | 54 | __attr __replace_context(__ref context, __attr attr); |
paul@126 | 55 | __attr __update_context(__ref context, __attr attr); |
paul@126 | 56 | |
paul@126 | 57 | #define __set_context(__ATTR) (__tmp_context = (__ATTR).value) |
paul@126 | 58 | #define __set_accessor(__ATTR) (__tmp_value = (__ATTR).value) |
paul@126 | 59 | |
paul@126 | 60 | /* Basic structure tests. */ |
paul@126 | 61 | |
paul@126 | 62 | int __WITHIN(__ref obj, int pos); |
paul@126 | 63 | int __HASATTR(__ref obj, int pos, int code); |
paul@126 | 64 | |
paul@126 | 65 | /* Parameter position operations. */ |
paul@126 | 66 | |
paul@126 | 67 | int __HASPARAM(const __ptable *ptable, int ppos, int pcode); |
paul@126 | 68 | |
paul@126 | 69 | /* Conversions. */ |
paul@126 | 70 | |
paul@126 | 71 | __attr __CONTEXT_AS_VALUE(__attr attr); |
paul@126 | 72 | |
paul@126 | 73 | /* Type testing. */ |
paul@126 | 74 | |
paul@144 | 75 | __ref __ISFUNC(__ref obj); |
paul@126 | 76 | int __ISNULL(__attr value); |
paul@126 | 77 | |
paul@126 | 78 | /* __TEST(obj, __A) -> test obj for the special type attribute __A */ |
paul@126 | 79 | |
paul@126 | 80 | #define __TEST(__OBJ, __TYPE) (__test_common_instance(__OBJ, __pos_##__TYPE, __code_##__TYPE)) |
paul@126 | 81 | |
paul@126 | 82 | /* Attribute codes and positions for type objects. */ |
paul@126 | 83 | |
paul@126 | 84 | unsigned int __TYPECODE(__ref obj); |
paul@126 | 85 | unsigned int __TYPEPOS(__ref obj); |
paul@126 | 86 | |
paul@126 | 87 | /* Attribute codes and positions for attribute names. */ |
paul@126 | 88 | |
paul@126 | 89 | #define __ATTRCODE(__ATTRNAME) (__code_##__ATTRNAME) |
paul@126 | 90 | #define __ATTRPOS(__ATTRNAME) (__pos_##__ATTRNAME) |
paul@126 | 91 | |
paul@148 | 92 | /* Copying of structures. */ |
paul@148 | 93 | |
paul@151 | 94 | __ref __COPY(__ref obj, int size); |
paul@148 | 95 | |
paul@126 | 96 | #endif /* __OPS_H__ */ |