1.1 --- a/templates/progops.h Wed Jul 11 23:53:09 2018 +0200
1.2 +++ b/templates/progops.h Thu Jul 12 00:15:16 2018 +0200
1.3 @@ -1,6 +1,6 @@
1.4 /* Operations depending on program specifics.
1.5
1.6 -Copyright (C) 2015, 2016, 2017 Paul Boddie <paul@boddie.org.uk>
1.7 +Copyright (C) 2015, 2016, 2017, 2018 Paul Boddie <paul@boddie.org.uk>
1.8
1.9 This program is free software; you can redistribute it and/or modify it under
1.10 the terms of the GNU General Public License as published by the Free Software
1.11 @@ -38,25 +38,22 @@
1.12 #define __newliteral___builtins___list_list(NUM, ...) __newdata_list(NUM, __ARGS(__VA_ARGS__))
1.13 #define __newliteral___builtins___tuple_tuple(NUM, ...) __newdata_tuple(NUM, __ARGS(__VA_ARGS__))
1.14
1.15 +/* Potentially superfluous operations. */
1.16 +
1.17 #ifdef __HAVE___builtins___dict_dict
1.18 __attr __newdata_dict(unsigned int number, __attr args[]);
1.19 #define __newliteral___builtins___dict_dict(NUM, ...) __newdata_dict(NUM, __ARGS(__VA_ARGS__))
1.20 -#endif /* __HAVE___builtins___dict_dict */
1.21 +#endif
1.22
1.23 /* Helpers for raising errors within common operations. */
1.24
1.25 void __raise_eof_error();
1.26 -
1.27 void __raise_io_error(__attr value);
1.28 -
1.29 void __raise_memory_error();
1.30 -
1.31 void __raise_os_error(__attr value, __attr arg);
1.32 -
1.33 void __raise_overflow_error();
1.34 -
1.35 +void __raise_underflow_error();
1.36 void __raise_zero_division_error();
1.37 -
1.38 void __raise_type_error();
1.39
1.40 /* Helper for raising exception instances. */
1.41 @@ -76,17 +73,21 @@
1.42 /* Generic operations depending on specific program details. */
1.43
1.44 void __SETDEFAULT(__ref obj, int pos, __attr value);
1.45 -
1.46 __attr __GETDEFAULT(__ref obj, int pos);
1.47 -
1.48 int __BOOL(__attr attr);
1.49
1.50 /* Convenience definitions. */
1.51
1.52 -#define __INSTANCESIZE(CLS) sizeof(__obj_##CLS)
1.53 +#define __OBJTYPE(CLS) __obj_##CLS
1.54 +#define __INSTANCESIZE(CLS) sizeof(__OBJTYPE(CLS))
1.55 #define __INSTANCETABLE(CLS) (__InstanceTable_##CLS)
1.56 #define __NEWINSTANCE(CLS) __new(&__INSTANCETABLE(CLS), &CLS, __INSTANCESIZE(CLS), 0)
1.57 #define __NEWINSTANCEIM(CLS) __new(&__INSTANCETABLE(CLS), &CLS, __INSTANCESIZE(CLS), 1)
1.58 #define __ISINSTANCE(ATTR, TYPE) __BOOL(__fn_native_introspection_isinstance(__NULL, ATTR, TYPE))
1.59
1.60 +/* Operations for accessing trailing data. */
1.61 +
1.62 +#define __get_trailing_data(ATTR, TYPE) (((__OBJTYPE(TYPE) *) ((ATTR).value))->trailing)
1.63 +#define __set_trailing_data(ATTR, TYPE, VALUE) ((__OBJTYPE(TYPE) *) ((ATTR).value))->trailing = VALUE;
1.64 +
1.65 #endif /* __PROGOPS_H__ */