Replace define private with __friends

This commit is contained in:
Jaby 2023-10-06 14:50:44 +02:00 committed by Jaby
parent 8f915dfb9a
commit dbf3e5d1de
10 changed files with 11 additions and 15 deletions

View File

@ -5,7 +5,7 @@
namespace JabyEngine { namespace JabyEngine {
namespace FileProcessor { namespace FileProcessor {
class State { class State {
private: __friends:
struct Reserved { struct Reserved {
uint32_t reserved[4]; uint32_t reserved[4];
}; };
@ -33,7 +33,7 @@ namespace JabyEngine {
} }
}; };
private: __friends:
Configuration config; Configuration config;
Reserved reserved; Reserved reserved;

View File

@ -5,7 +5,7 @@
namespace JabyEngine { namespace JabyEngine {
class MasterTime { class MasterTime {
private: __friends:
static uint32_t value; static uint32_t value;
public: public:

View File

@ -54,7 +54,7 @@ namespace JabyEngine {
friend class HighResTime; friend class HighResTime;
}; };
private: __friends:
static constexpr uint16_t TicksFor100us = CPUTicks::ticks_per_us<uint16_t>(CPUTicks::Frequency_Hz_Div8, 100.0); static constexpr uint16_t TicksFor100us = CPUTicks::ticks_per_us<uint16_t>(CPUTicks::Frequency_Hz_Div8, 100.0);
static constexpr uint16_t TicksFor1ms = CPUTicks::ticks_per_ms<uint16_t>(CPUTicks::Frequency_Hz_Div8, 1.0); static constexpr uint16_t TicksFor1ms = CPUTicks::ticks_per_ms<uint16_t>(CPUTicks::Frequency_Hz_Div8, 1.0);
static constexpr uint16_t TicksFor10ms = CPUTicks::ticks_per_ms<uint16_t>(CPUTicks::Frequency_Hz_Div8, 10.0); static constexpr uint16_t TicksFor10ms = CPUTicks::ticks_per_ms<uint16_t>(CPUTicks::Frequency_Hz_Div8, 10.0);

View File

@ -10,6 +10,10 @@
#define __section(name) __attribute__((section(name))) #define __section(name) __attribute__((section(name)))
#define __collect(...) __VA_ARGS__ #define __collect(...) __VA_ARGS__
#ifndef __friends
#define __friends private
#endif //!__friends
#ifdef __cplusplus #ifdef __cplusplus
#define __constexpr constexpr #define __constexpr constexpr
#define START_C_FUNCTIONS extern "C" { #define START_C_FUNCTIONS extern "C" {

View File

@ -62,7 +62,8 @@
"C_Cpp.default.compilerArgs": [ "C_Cpp.default.compilerArgs": [
], ],
"C_Cpp.default.defines": [ "C_Cpp.default.defines": [
"JABYENGINE_PAL" "JABYENGINE_PAL",
"__friends=public"
], ],
"files.exclude": { "files.exclude": {
"**/*.o": true, "**/*.o": true,

View File

@ -7,7 +7,7 @@ BUILD_DIR = bin
SPLASH_IMAGE = src/BootLoader/splash_image_pal_boot.hpp SPLASH_IMAGE = src/BootLoader/splash_image_pal_boot.hpp
SPLASH_IMAGE_NTSC = src/BootLoader/splash_image_ntsc_boot.hpp SPLASH_IMAGE_NTSC = src/BootLoader/splash_image_ntsc_boot.hpp
CCFLAGS += -Iinclude -I../../include CCFLAGS += -Iinclude -I../../include -D__friends=public
CCFLAGS += -save-temps=obj CCFLAGS += -save-temps=obj
include ../../lib/Wildcard.mk include ../../lib/Wildcard.mk

View File

@ -1,8 +1,6 @@
#include <PSX/System/IOPorts/interrupt_io.hpp> #include <PSX/System/IOPorts/interrupt_io.hpp>
#include <PSX/System/syscalls.hpp> #include <PSX/System/syscalls.hpp>
#define private public
#include <PSX/Timer/high_res_timer.hpp> #include <PSX/Timer/high_res_timer.hpp>
#undef private
namespace JabyEngine { namespace JabyEngine {
namespace Timer { namespace Timer {

View File

@ -1,8 +1,6 @@
#ifndef __JABYENGINE_INTERNAL_SIMPLE_HELPER_HPP__ #ifndef __JABYENGINE_INTERNAL_SIMPLE_HELPER_HPP__
#define __JABYENGINE_INTERNAL_SIMPLE_HELPER_HPP__ #define __JABYENGINE_INTERNAL_SIMPLE_HELPER_HPP__
// Instead of using friend we use this to access the private members
#define private public
#include <PSX/File/Processor/file_processor.hpp> #include <PSX/File/Processor/file_processor.hpp>
namespace JabyEngine { namespace JabyEngine {

View File

@ -1,8 +1,5 @@
#include "../../internal-include/GPU/gpu_internal.hpp" #include "../../internal-include/GPU/gpu_internal.hpp"
// We need to access the master time
#define private public
#include <PSX/Timer/frame_timer.hpp> #include <PSX/Timer/frame_timer.hpp>
#undef private
#include <PSX/System/IOPorts/interrupt_io.hpp> #include <PSX/System/IOPorts/interrupt_io.hpp>
#include <PSX/System/syscalls.hpp> #include <PSX/System/syscalls.hpp>

View File

@ -1,8 +1,6 @@
#define private public
#include <PSX/System/IOPorts/timer_io.hpp> #include <PSX/System/IOPorts/timer_io.hpp>
#include <PSX/System/syscalls.hpp> #include <PSX/System/syscalls.hpp>
#include <PSX/Timer/high_res_timer.hpp> #include <PSX/Timer/high_res_timer.hpp>
#undef private
namespace JabyEngine { namespace JabyEngine {
volatile uint16_t HighResTime :: global_counter_10ms = 0; volatile uint16_t HighResTime :: global_counter_10ms = 0;