Lichen

templates/ops.h

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