1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/templates/ops.h Mon Oct 24 21:18:10 2016 +0200
1.3 @@ -0,0 +1,89 @@
1.4 +/* Common operations. */
1.5 +
1.6 +#ifndef __OPS_H__
1.7 +#define __OPS_H__
1.8 +
1.9 +#include "types.h"
1.10 +
1.11 +extern __attr null;
1.12 +
1.13 +/* Direct access to functions. */
1.14 +
1.15 +__attr __load_function(__func fn);
1.16 +
1.17 +/* Direct access and manipulation of static objects. */
1.18 +
1.19 +__attr __load_static(__ref obj);
1.20 +
1.21 +/* Direct retrieval operations, returning attributes. */
1.22 +
1.23 +__attr __load_via_class(__ref obj, int pos);
1.24 +__attr __load_via_object(__ref obj, int pos);
1.25 +
1.26 +/* Direct storage operations. */
1.27 +
1.28 +int __store_via_object(__ref obj, int pos, __attr value);
1.29 +
1.30 +/* Introspection. */
1.31 +
1.32 +int __is_instance(__ref obj);
1.33 +__ref __get_class(__ref obj);
1.34 +
1.35 +/* Attribute testing operations. */
1.36 +
1.37 +int __test_common_instance(__ref obj, int pos, int code);
1.38 +int __test_specific_instance(__ref obj, __ref type);
1.39 +
1.40 +/* Attribute testing and retrieval operations. */
1.41 +
1.42 +__attr __check_and_load_via_class(__ref obj, int pos, int code);
1.43 +__attr __check_and_load_via_object(__ref obj, int pos, int code);
1.44 +__attr __check_and_load_via_any(__ref obj, int pos, int code);
1.45 +
1.46 +/* Attribute testing and storage operations. */
1.47 +
1.48 +int __check_and_store_via_object(__ref obj, int pos, int code, __attr value);
1.49 +int __check_and_store_via_any(__ref obj, int pos, int code, __attr value);
1.50 +
1.51 +/* Context-related operations. */
1.52 +
1.53 +__attr __test_context(__ref context, __attr attr);
1.54 +__attr __replace_context(__ref context, __attr attr);
1.55 +__attr __update_context(__ref context, __attr attr);
1.56 +
1.57 +#define __set_context(__ATTR) (__tmp_context = (__ATTR).value)
1.58 +#define __set_accessor(__ATTR) (__tmp_value = (__ATTR).value)
1.59 +
1.60 +/* Basic structure tests. */
1.61 +
1.62 +int __WITHIN(__ref obj, int pos);
1.63 +int __HASATTR(__ref obj, int pos, int code);
1.64 +
1.65 +/* Parameter position operations. */
1.66 +
1.67 +int __HASPARAM(const __ptable *ptable, int ppos, int pcode);
1.68 +
1.69 +/* Conversions. */
1.70 +
1.71 +__attr __CONTEXT_AS_VALUE(__attr attr);
1.72 +
1.73 +/* Type testing. */
1.74 +
1.75 +int __ISFUNC(__ref obj);
1.76 +int __ISNULL(__attr value);
1.77 +
1.78 +/* __TEST(obj, __A) -> test obj for the special type attribute __A */
1.79 +
1.80 +#define __TEST(__OBJ, __TYPE) (__test_common_instance(__OBJ, __pos_##__TYPE, __code_##__TYPE))
1.81 +
1.82 +/* Attribute codes and positions for type objects. */
1.83 +
1.84 +unsigned int __TYPECODE(__ref obj);
1.85 +unsigned int __TYPEPOS(__ref obj);
1.86 +
1.87 +/* Attribute codes and positions for attribute names. */
1.88 +
1.89 +#define __ATTRCODE(__ATTRNAME) (__code_##__ATTRNAME)
1.90 +#define __ATTRPOS(__ATTRNAME) (__pos_##__ATTRNAME)
1.91 +
1.92 +#endif /* __OPS_H__ */