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. --- context.h | 36 ++++++++++++++++++++++++++++++++++++ include/pso/macros.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/context.h b/context.h index def7359..1e0952b 100644 --- a/context.h +++ b/context.h @@ -87,6 +87,42 @@ typedef long ptrdiff_t; #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__) + // pso/TMainTask.h #define X_OR_Y_CHILD(flags, old_flags, one_prefix, zero_prefix, suffix) \ if (flags != old_flags) { \ 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