From e140c56525cca0eb490bdd77eac4701f4748d34f Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Sun, 26 Feb 2023 19:10:51 -0400 Subject: pso/macros: Add getters/setters macros This'll come in handy later. --- include/pso/macros.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'include') diff --git a/include/pso/macros.h b/include/pso/macros.h index 1434e16..a341b7f 100644 --- a/include/pso/macros.h +++ b/include/pso/macros.h @@ -57,4 +57,40 @@ #define __packed__ +#define PRIVATE_MEMBER_GETTER(type, name) \ + type name() { \ + return m_##name; \ + } + +#define PRIVATE_MEMBER_SETTER(type, name) \ + void set_##name(type val) { \ + m_##name = val; \ + } + +#define PRIVATE_MEMBER_GETTER_ARRAY(type, name, size) \ + TArray &name() { \ + return m_##name; \ + } + +#define PRIVATE_MEMBER_GETTER_FUNC(ret_type, name, ...) \ + ret_type (*name())(__VA_ARGS__) { \ + return m_##name; \ + } + +#define PRIVATE_MEMBER_SETTER_FUNC(ret_type, name, ...) \ + void set_##name(ret_type (*val)(__VA_ARGS__)) { \ + m_##name = val; \ + } + +#define PRIVATE_MEMBER_ACCESSORS(type, name) \ + PRIVATE_MEMBER_GETTER(type, name); \ + PRIVATE_MEMBER_SETTER(type, name) + +#define PRIVATE_MEMBER_ACCESSORS_ARRAY(type, name, size) \ + PRIVATE_MEMBER_GETTER_ARRAY(type, name, size) + +#define PRIVATE_MEMBER_ACCESSORS_FUNC(ret_type, name, ...) \ + PRIVATE_MEMBER_GETTER_FUNC(ret_type, name, __VA_ARGS__); \ + PRIVATE_MEMBER_SETTER_FUNC(ret_type, name, __VA_ARGS__) + #endif -- cgit v1.2.3-13-gbd6f