1.1 --- a/templates/ops.h Sat Sep 02 01:19:52 2023 +0200
1.2 +++ b/templates/ops.h Sat Sep 02 01:48:44 2023 +0200
1.3 @@ -32,6 +32,20 @@
1.4 __attr __load_static_replace(__attr context, __ref obj);
1.5 __attr __load_static_test(__attr context, __ref obj);
1.6
1.7 +/* Direct retrieval operations, returning attribute locations. */
1.8 +
1.9 +__attr *__get_class_attr_ref__(__ref obj, int pos);
1.10 +
1.11 +#define __get_object_attr_ref__(OBJ, POS) (&(OBJ)->attrs[POS])
1.12 +
1.13 +#define __get_object_attr_ref(OBJ, ATTRNAME) (__get_object_attr_ref__(OBJ, __ATTRPOS(ATTRNAME)))
1.14 +#define __get_class_attr_ref(OBJ, ATTRNAME) (__get_class_attr_ref__(OBJ, __ATTRPOS(ATTRNAME)))
1.15 +
1.16 +/* Attribute location operations. */
1.17 +
1.18 +#define __load_via_attr_ref(ATTR) (*(ATTR))
1.19 +#define __store_via_attr_ref(ATTR, VALUE) __set_attr(ATTR, VALUE)
1.20 +
1.21 /* Direct retrieval operations, returning attributes. */
1.22
1.23 __attr __load_via_class__(__ref obj, int pos);
1.24 @@ -42,16 +56,6 @@
1.25 #define __load_via_object(OBJ, ATTRNAME) (__load_via_object__(OBJ, __ATTRPOS(ATTRNAME)))
1.26 #define __get_class_and_load(OBJ, ATTRNAME) (__get_class_and_load__(OBJ, __ATTRPOS(ATTRNAME)))
1.27
1.28 -/* Direct storage operations. */
1.29 -
1.30 -int __store_via_class__(__ref obj, int pos, __attr value);
1.31 -int __store_via_object__(__ref obj, int pos, __attr value);
1.32 -int __get_class_and_store__(__ref obj, int pos, __attr value);
1.33 -
1.34 -#define __store_via_class(OBJ, ATTRNAME, VALUE) (__store_via_class__(OBJ, __ATTRPOS(ATTRNAME), VALUE))
1.35 -#define __store_via_object(OBJ, ATTRNAME, VALUE) (__store_via_object__(OBJ, __ATTRPOS(ATTRNAME), VALUE))
1.36 -#define __get_class_and_store(OBJ, ATTRNAME, VALUE) (__get_class_and_store__(OBJ, __ATTRPOS(ATTRNAME), VALUE))
1.37 -
1.38 /* Introspection. */
1.39
1.40 int __is_instance(__ref obj);
1.41 @@ -77,6 +81,15 @@
1.42 #define __test_common_object(OBJ, TYPENAME) (__test_common_object__(OBJ, __ATTRPOS(TYPENAME), __ATTRCODE(TYPENAME)))
1.43 #define __test_common_type(OBJ, TYPENAME) (__test_common_type__(OBJ, __ATTRPOS(TYPENAME), __ATTRCODE(TYPENAME)))
1.44
1.45 +/* Attribute testing and location operations, returning the address of the
1.46 + attribute as opposed to its value. */
1.47 +
1.48 +__attr *__check_and_get_object_attr_ref_null(__ref obj, int pos, int code);
1.49 +
1.50 +__attr *__check_and_get_object_attr_ref__(__ref obj, int pos, int code);
1.51 +
1.52 +#define __check_and_get_object_attr_ref(OBJ, ATTRNAME) (__check_and_get_object_attr_ref__(OBJ, __ATTRPOS(ATTRNAME), __ATTRCODE(ATTRNAME)))
1.53 +
1.54 /* Attribute testing and retrieval operations. */
1.55
1.56 __attr __check_and_load_via_object_null(__ref obj, int pos, int code);
1.57 @@ -89,16 +102,6 @@
1.58 #define __check_and_load_via_object(OBJ, ATTRNAME) (__check_and_load_via_object__(OBJ, __ATTRPOS(ATTRNAME), __ATTRCODE(ATTRNAME)))
1.59 #define __check_and_load_via_any(OBJ, ATTRNAME) (__check_and_load_via_any__(OBJ, __ATTRPOS(ATTRNAME), __ATTRCODE(ATTRNAME)))
1.60
1.61 -/* Attribute testing and storage operations. */
1.62 -
1.63 -int __check_and_store_via_class__(__ref obj, int pos, int code, __attr value);
1.64 -int __check_and_store_via_object__(__ref obj, int pos, int code, __attr value);
1.65 -int __check_and_store_via_any__(__ref obj, int pos, int code, __attr value);
1.66 -
1.67 -#define __check_and_store_via_class(OBJ, ATTRNAME, VALUE) (__check_and_store_via_class__(OBJ, __ATTRPOS(ATTRNAME), __ATTRCODE(ATTRNAME), VALUE))
1.68 -#define __check_and_store_via_object(OBJ, ATTRNAME, VALUE) (__check_and_store_via_object__(OBJ, __ATTRPOS(ATTRNAME), __ATTRCODE(ATTRNAME), VALUE))
1.69 -#define __check_and_store_via_any(OBJ, ATTRNAME, VALUE) (__check_and_store_via_any__(OBJ, __ATTRPOS(ATTRNAME), __ATTRCODE(ATTRNAME), VALUE))
1.70 -
1.71 /* Context-related operations. */
1.72
1.73 int __test_context_update(__attr context, __attr attr, int invoke);
1.74 @@ -108,11 +111,13 @@
1.75 __attr __test_context_static(int target, __attr context, __ref value, __attr contexts[]);
1.76
1.77 #define __get_accessor(__TARGET) (__tmp_values[__TARGET])
1.78 +#define __get_attr_ref(__TARGET) (__tmp_attr_refs[__TARGET])
1.79 #define __get_context(__TARGET) (__tmp_contexts[__TARGET])
1.80 #define __set_context(__TARGET, __ATTR) (__tmp_contexts[__TARGET] = (__ATTR))
1.81 #define __set_private_context(__ATTR) (__tmp_private_context = (__ATTR))
1.82 #define __set_accessor(__TARGET, __ATTR) (__tmp_values[__TARGET] = (__ATTR))
1.83 #define __set_target_accessor(__ATTR) (__tmp_target_value = (__ATTR))
1.84 +#define __set_attr_ref(__TARGET, __ATTR) (__tmp_attr_refs[__TARGET] = (__ATTR))
1.85
1.86 /* Context testing for invocations. */
1.87
1.88 @@ -155,6 +160,6 @@
1.89
1.90 /* Result target administration for potential value replacement. */
1.91
1.92 -__attr __set_local(volatile __attr *local, __attr attr);
1.93 +__attr __set_attr(volatile __attr *target, __attr attr);
1.94
1.95 #endif /* __OPS_H__ */