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