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 and manipulation of static objects. */ 10 11 __attr __load_static(__ref parent, __ref obj); 12 13 /* Direct retrieval operations, returning attributes. */ 14 15 __attr __load_via_class(__ref obj, int pos); 16 __attr __load_via_object(__ref obj, int pos); 17 __attr __get_class_and_load(__ref obj, int pos); 18 19 /* Direct storage operations. */ 20 21 int __store_via_object(__ref obj, int pos, __attr value); 22 int __get_class_and_store(__ref obj, int pos, __attr value); 23 24 /* Introspection. */ 25 26 int __is_instance(__ref obj); 27 __ref __get_class(__ref obj); 28 __attr __get_class_attr(__ref obj); 29 30 /* Attribute testing operations. */ 31 32 __ref __test_specific_instance(__ref obj, __ref type); 33 __ref __test_specific_object(__ref obj, __ref type); 34 __ref __test_specific_type(__ref obj, __ref type); 35 __ref __test_common_instance(__ref obj, int pos, int code); 36 __ref __test_common_object(__ref obj, int pos, int code); 37 __ref __test_common_type(__ref obj, int pos, int code); 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_class(__ref obj, int pos, int code, __attr value); 48 int __check_and_store_via_object(__ref obj, int pos, int code, __attr value); 49 int __check_and_store_via_any(__ref obj, int pos, int code, __attr value); 50 51 /* Context-related operations. */ 52 53 __attr __test_context(__ref context, __attr attr); 54 __attr __replace_context(__ref context, __attr attr); 55 __attr __update_context(__ref context, __attr attr); 56 57 #define __set_context(__ATTR) (__tmp_context = (__ATTR).value) 58 #define __set_accessor(__ATTR) (__tmp_value = (__ATTR).value) 59 60 /* Basic structure tests. */ 61 62 int __WITHIN(__ref obj, int pos); 63 int __HASATTR(__ref obj, int pos, int code); 64 65 /* Parameter position operations. */ 66 67 int __HASPARAM(const __ptable *ptable, int ppos, int pcode); 68 69 /* Conversions. */ 70 71 __attr __CONTEXT_AS_VALUE(__attr attr); 72 73 /* Type testing. */ 74 75 __ref __ISFUNC(__ref obj); 76 int __ISNULL(__attr value); 77 78 /* __TEST(obj, __A) -> test obj for the special type attribute __A */ 79 80 #define __TEST(__OBJ, __TYPE) (__test_common_instance(__OBJ, __pos_##__TYPE, __code_##__TYPE)) 81 82 /* Attribute codes and positions for type objects. */ 83 84 unsigned int __TYPECODE(__ref obj); 85 unsigned int __TYPEPOS(__ref obj); 86 87 /* Attribute codes and positions for attribute names. */ 88 89 #define __ATTRCODE(__ATTRNAME) (__code_##__ATTRNAME) 90 #define __ATTRPOS(__ATTRNAME) (__pos_##__ATTRNAME) 91 92 /* Memory allocation. */ 93 94 void *__ALLOCATE(size_t nmemb, size_t size); 95 void *__REALLOCATE(void *ptr, size_t size); 96 97 /* Copying of structures. */ 98 99 __ref __COPY(__ref obj, int size); 100 101 #endif /* __OPS_H__ */