diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2023-02-12 11:38:48 -0400 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2023-02-12 11:38:48 -0400 |
commit | 0d06559bcc3d60595cedcab343408589dcdb9c94 (patch) | |
tree | 669642efeb2e86d84af98336db6079ce487d89a5 /include | |
parent | 2fdd70e4eeb6b2ac82eb8be81fd23fa61bc2baeb (diff) |
TObject: Make non-function members private, and add getters, and setters
Diffstat (limited to 'include')
-rw-r--r-- | include/pso/TMainTask.h | 24 | ||||
-rw-r--r-- | include/pso/TObject.h | 20 | ||||
-rw-r--r-- | include/pso/macros.h | 8 |
3 files changed, 35 insertions, 17 deletions
diff --git a/include/pso/TMainTask.h b/include/pso/TMainTask.h index 3eab543..3a6e59b 100644 --- a/include/pso/TMainTask.h +++ b/include/pso/TMainTask.h @@ -6,18 +6,18 @@ #include "pso/TObject.h" -#define X_OR_Y_CHILD(flags, old_flags, one_prefix, zero_prefix, suffix) \ - if (flags != old_flags) { \ - TMainTask *child; \ - u32 bit = 1; \ - FOREACH_NODE_NODECL_MULTI_ITER(TMainTask, main_task.down, child, bit <<= 1) { \ - if (flags & bit) { \ - child->one_prefix##_##suffix(); \ - } else { \ - child->zero_prefix##_##suffix(); \ - } \ - } \ - old_flags = flags; \ +#define X_OR_Y_CHILD(flags, old_flags, one_prefix, zero_prefix, suffix) \ + if (flags != old_flags) { \ + TMainTask *child; \ + u32 bit = 1; \ + FOREACH_NODE_NODECL_MULTI_ITER(TMainTask, main_task.get_down(), child, bit <<= 1) { \ + if (flags & bit) { \ + child->one_prefix##_##suffix(); \ + } else { \ + child->zero_prefix##_##suffix(); \ + } \ + } \ + old_flags = flags; \ } #define SET_OR_CLEAR_CHILD_FLAGS(flags, old_flags, flag_bit) \ diff --git a/include/pso/TObject.h b/include/pso/TObject.h index 8d3e6e8..9af0251 100644 --- a/include/pso/TObject.h +++ b/include/pso/TObject.h @@ -44,7 +44,7 @@ static inline void operator&=(object_flags &a, object_flags b) { a = a & b; }; static inline void operator|=(object_flags &a, object_flags b) { a = a | b; }; class TObject { -public: +private: const char *name; union { object_flags flags; @@ -73,6 +73,24 @@ public: void *operator new (size_t size) { return alloc(size); }; void operator delete(void *ptr) { free(ptr); }; + const char *get_name() { return this->name; }; + object_flags get_flags() { return this->flags; }; + u16 get_flags_u16() { return this->flags_u16; }; + u16 get_id() { return this->id; }; + TObject *get_prev() { return this->prev; }; + TObject *get_next() { return this->next; }; + TObject *get_up() { return this->up; }; + TObject *get_down() { return this->down; }; + + void set_name(const char *name) { this->name = name; }; + void set_obj_flags(object_flags flags) { this->flags = flags; }; + void set_flags_u16(u16 flags) { flags_u16 = flags; }; + void set_id(u16 id) { this->id = id; }; + void set_prev(TObject *node) { prev = node; }; + void set_next(TObject *node) { next = node; }; + void set_up(TObject *node) { up = node; }; + void set_down(TObject *node) { down = node; }; + void delete_children(); void queue_destruction_for_each_node(); void run_tasks(); diff --git a/include/pso/macros.h b/include/pso/macros.h index a814e12..64ce214 100644 --- a/include/pso/macros.h +++ b/include/pso/macros.h @@ -27,10 +27,10 @@ o(tl_fade, TL_FADE) \ o(tl_fadeafter, TL_FADEAFTER) -#define FOREACH_NODE(type, first, varname) for (type *varname = (type *)(first); varname != NULL; varname = (type *)(varname->next)) -#define FOREACH_NODE_NODECL(type, first, varname) for (varname = (type *)(first); varname != NULL; varname = (type *)(varname->next)) +#define FOREACH_NODE(type, first, varname) for (type *varname = (type *)(first); varname != NULL; varname = (type *)(varname->get_next())) +#define FOREACH_NODE_NODECL(type, first, varname) for (varname = (type *)(first); varname != NULL; varname = (type *)(varname->get_next())) -#define FOREACH_NODE_MULTI_ITER(type, first, varname, ...) for (type *varname = (type *)(first); varname != NULL; varname = (type *)(varname->next), __VA_ARGS__) -#define FOREACH_NODE_NODECL_MULTI_ITER(type, first, varname, ...) for (varname = (type *)(first); varname != NULL; varname = (type *)(varname->next), __VA_ARGS__) +#define FOREACH_NODE_MULTI_ITER(type, first, varname, ...) for (type *varname = (type *)(first); varname != NULL; varname = (type *)(varname->get_next()), __VA_ARGS__) +#define FOREACH_NODE_NODECL_MULTI_ITER(type, first, varname, ...) for (varname = (type *)(first); varname != NULL; varname = (type *)(varname->get_next()), __VA_ARGS__) #endif |