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 22 /* Direct storage operations. */ 23 24 int __store_via_object(__ref obj, int pos, __attr value); 25 26 /* Introspection. */ 27 28 int __is_instance(__ref obj); 29 __ref __get_class(__ref obj); 30 31 /* Attribute testing operations. */ 32 33 __ref __test_common_instance(__ref obj, int pos, int code); 34 __ref __test_common_object(__ref obj, int pos, int code); 35 __ref __test_common_type(__ref obj, int pos, int code); 36 __ref __test_specific_instance(__ref obj, __ref type); 37 38 /* Attribute testing and retrieval operations. */ 39 40 __attr __check_and_load_via_class(__ref obj, int pos, int code); 41 __attr __check_and_load_via_object(__ref obj, int pos, int code); 42 __attr __check_and_load_via_any(__ref obj, int pos, int code); 43 44 /* Attribute testing and storage operations. */ 45 46 int __check_and_store_via_object(__ref obj, int pos, int code, __attr value); 47 int __check_and_store_via_any(__ref obj, int pos, int code, __attr value); 48 49 /* Context-related operations. */ 50 51 __attr __test_context(__ref context, __attr attr); 52 __attr __replace_context(__ref context, __attr attr); 53 __attr __update_context(__ref context, __attr attr); 54 55 #define __set_context(__ATTR) (__tmp_context = (__ATTR).value) 56 #define __set_accessor(__ATTR) (__tmp_value = (__ATTR).value) 57 58 /* Basic structure tests. */ 59 60 int __WITHIN(__ref obj, int pos); 61 int __HASATTR(__ref obj, int pos, int code); 62 63 /* Parameter position operations. */ 64 65 int __HASPARAM(const __ptable *ptable, int ppos, int pcode); 66 67 /* Conversions. */ 68 69 __attr __CONTEXT_AS_VALUE(__attr attr); 70 71 /* Type testing. */ 72 73 __ref __ISFUNC(__ref obj); 74 int __ISNULL(__attr value); 75 76 /* __TEST(obj, __A) -> test obj for the special type attribute __A */ 77 78 #define __TEST(__OBJ, __TYPE) (__test_common_instance(__OBJ, __pos_##__TYPE, __code_##__TYPE)) 79 80 /* Attribute codes and positions for type objects. */ 81 82 unsigned int __TYPECODE(__ref obj); 83 unsigned int __TYPEPOS(__ref obj); 84 85 /* Attribute codes and positions for attribute names. */ 86 87 #define __ATTRCODE(__ATTRNAME) (__code_##__ATTRNAME) 88 #define __ATTRPOS(__ATTRNAME) (__pos_##__ATTRNAME) 89 90 /* Copying of structures. */ 91 92 __ref __COPY(__ref obj, int size); 93 94 #endif /* __OPS_H__ */