Skip to content

Commit

Permalink
clangd: Started fixing warnings and errors, code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
LagoLunatic committed Oct 18, 2024
1 parent f1d73f7 commit 34afbd8
Show file tree
Hide file tree
Showing 58 changed files with 417 additions and 316 deletions.
5 changes: 5 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# https://clangd.llvm.org/config
CompileFlags:
Add:
- -Wno-c++11-compat-deprecated-writable-strings
- -Wno-undefined-inline
6 changes: 4 additions & 2 deletions include/DynamicLink.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ struct DynamicModuleControlBase {
virtual const char* getModuleName() const { return NULL; }
virtual int getModuleSize() const { return 0; }
virtual const char* getModuleTypeString() const { return "Base"; }
#ifdef __MWERKS__
virtual void dump();
#endif
static void dump();
virtual void dump2() {}
virtual bool do_load() { return true; }
virtual BOOL do_load_async() { return true; }
virtual BOOL do_load_async() { return TRUE; }
virtual bool do_unload() { return true; }
virtual BOOL do_link() { return TRUE; }
virtual bool do_unlink() { return true; }
Expand All @@ -31,7 +34,6 @@ struct DynamicModuleControlBase {
BOOL load_async();
bool force_unlink();

static void dump();
static inline DynamicModuleControlBase* getFirstClass() { return mFirst; }
inline DynamicModuleControlBase* getNextClass() { return mNext; }
bool isLinked() const { return mLinkCount != 0; }
Expand Down
16 changes: 9 additions & 7 deletions include/JSystem/J3DGraphBase/J3DTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,11 @@

struct J3DTextureSRTInfo;

// struct J3DTransformInfo {
// /* 0x00 */ JGeometry::TVec3<f32> mScale;
// /* 0x0C */ JGeometry::TVec3<s16> mRotation;
// /* 0x14 */ JGeometry::TVec3<f32> mTranslate;
// }; // Size: 0x20

// I doubt this is right but it seems like the only way to prevent an empty ctor being added on array construction
struct J3DTransformInfo {
/* 0x00 */ Vec mScale;
/* 0x0C */ SVec mRotation;
/* 0x14 */ Vec mTranslate;

inline J3DTransformInfo& operator=(const J3DTransformInfo& b) {
mScale = b.mScale;
mRotation = b.mRotation;
Expand Down Expand Up @@ -65,6 +59,7 @@ inline void J3DPSMulMtxVec(register MtxP mtx, register Vec* vec, register Vec* d
register f32 fra2;
register f32 fr01;
register f32 fr00;
#ifdef __MWERKS__
asm {
psq_l fr00, 0(vec), 0, 0
psq_l fr2, 0(mtx), 0, 0
Expand All @@ -87,6 +82,7 @@ inline void J3DPSMulMtxVec(register MtxP mtx, register Vec* vec, register Vec* d
ps_sum0 fra6, fra5, fra6, fra5
psq_st fra6, 8(dst), 1, 0
}
#endif
}

// regalloc issues
Expand All @@ -107,6 +103,7 @@ inline void J3DPSMulMtxVec(register MtxP mtx, register SVec* vec, register SVec*
register f32 fra2;
register f32 fr01;
register f32 fr00;
#ifdef __MWERKS__
asm {
psq_l fr00, 0(vec), 0, 7
psq_l fr2, 0(mtx), 0, 0
Expand All @@ -129,6 +126,7 @@ inline void J3DPSMulMtxVec(register MtxP mtx, register SVec* vec, register SVec*
ps_sum0 fra6, fra5, fra6, fra5
psq_st fra6, 4(dst), 1, 7
}
#endif
}

// regalloc issues
Expand All @@ -147,6 +145,7 @@ inline void J3DPSMulMtxVec(register Mtx3P mtx, register Vec* vec, register Vec*
register f32 fr2;
register f32 fr01;
register f32 fr00;
#ifdef __MWERKS__
asm {
lis punit, PSMulUnit01@ha
psq_l fr00, 0(vec), 0, 0
Expand All @@ -173,6 +172,7 @@ inline void J3DPSMulMtxVec(register Mtx3P mtx, register Vec* vec, register Vec*
ps_sum0 fr6, fr5, fr6, fr5
psq_st fr6, 8(dst), 1, 0
}
#endif
}

// regalloc issues
Expand All @@ -186,6 +186,7 @@ inline void J3DPSMulMtxVec(register Mtx3P mtx, register SVec* vec, register SVec
register f32 fr2;
register f32 fr01;
register f32 fr00;
#ifdef __MWERKS__
asm {
lis punit, PSMulUnit01@ha
psq_l fr00, 0(vec), 0, 7
Expand All @@ -212,6 +213,7 @@ inline void J3DPSMulMtxVec(register Mtx3P mtx, register SVec* vec, register SVec
ps_sum0 fr6, fr5, fr6, fr5
psq_st fr6, 4(dst), 1, 7
}
#endif
}

#endif /* J3DTRANSFORM_H */
2 changes: 1 addition & 1 deletion include/JSystem/JGadget/binary.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct TParseValue_raw_ {

template <typename T>
struct TParseValue_endian_big_ : public TParseValue_raw_<T> {
static T parse(const void* data) { return TParseValue_raw_::parse(data); }
static T parse(const void* data) { return TParseValue_raw_<T>::parse(data); }
};

template <typename T, template <class> class Parser>
Expand Down
2 changes: 1 addition & 1 deletion include/JSystem/JGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ struct TBox2 : TBox<TVec2<T> > {

void set(const TBox2& other) { set(other.i, other.f); }
void set(const TVec2<f32>& i, const TVec2<f32>& f) { this->i.set(i), this->f.set(f); }
void set(f32 x0, f32 y0, f32 x1, f32 y1) { i.set(x0, y0); f.set(x1, y1); }
void set(f32 x0, f32 y0, f32 x1, f32 y1) { this->i.set(x0, y0); this->f.set(x1, y1); }
};

// clang-format on
Expand Down
12 changes: 12 additions & 0 deletions include/JSystem/JMath/JMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,23 @@ inline f32 JMAFastReciprocal(f32 value) {
inline float __frsqrtes(register double f) {
register float out;
// clang-format off
#ifdef __MWERKS__
asm {
frsqrte out, f
}
#endif
// clang-format on
return out;
}

inline f32 JMAFastSqrt(register f32 input) {
if (input > 0.0f) {
register f32 out;
#ifdef __MWERKS__
asm {
frsqrte out, input
}
#endif
return out * input;
} else {
return input;
Expand All @@ -43,18 +47,21 @@ inline f32 fastReciprocal(f32 value) {
inline void gekko_ps_copy3(register void* dst, register const void* src) {
register f32 src0;
register f32 src1;
#ifdef __MWERKS__
asm {
psq_l src0, 0(src), 0, 0
lfs src1, 8(src)
psq_st src0, 0(dst), 0, 0
stfs src1, 8(dst)
};
#endif
}

inline void gekko_ps_copy6(register void* dst, register const void* src) {
register f32 src0;
register f32 src1;
register f32 src2;
#ifdef __MWERKS__
asm {
psq_l src0, 0(src), 0, 0
psq_l src1, 8(src), 0, 0
Expand All @@ -63,6 +70,7 @@ inline void gekko_ps_copy6(register void* dst, register const void* src) {
psq_st src1, 8(dst), 0, 0
psq_st src2, 16(dst), 0, 0
};
#endif
}

inline void gekko_ps_copy12(register void* dst, register const void* src) {
Expand All @@ -72,6 +80,7 @@ inline void gekko_ps_copy12(register void* dst, register const void* src) {
register f32 src3;
register f32 src4;
register f32 src5;
#ifdef __MWERKS__
asm {
psq_l src0, 0(src), 0, 0
psq_l src1, 8(src), 0, 0
Expand All @@ -86,6 +95,7 @@ inline void gekko_ps_copy12(register void* dst, register const void* src) {
psq_st src4, 32(dst), 0, 0
psq_st src5, 40(dst), 0, 0
};
#endif
}

inline void gekko_ps_copy16(register void* dst, register const void* src) {
Expand All @@ -97,6 +107,7 @@ inline void gekko_ps_copy16(register void* dst, register const void* src) {
register f32 src5;
register f32 src6;
register f32 src7;
#ifdef __MWERKS__
asm {
psq_l src0, 0(src), 0, 0
psq_l src1, 8(src), 0, 0
Expand All @@ -115,6 +126,7 @@ inline void gekko_ps_copy16(register void* dst, register const void* src) {
psq_st src6, 48(dst), 0, 0
psq_st src7, 56(dst), 0, 0
};
#endif
}

}; // namespace JMath
Expand Down
6 changes: 5 additions & 1 deletion include/JSystem/JMessage/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "JSystem/JGadget/binary.h"
#include "JSystem/JGadget/linklist.h"
#include "JSystem/JMessage/data.h"
#include "JSystem/JUtility/JUTDataHeader.h"

namespace JMessage {
namespace data {
Expand Down Expand Up @@ -47,7 +46,12 @@ namespace JMessage {
/* 0x18 */ data::JUTMesgIDData* mMessageID;
};

#ifdef __MWERKS__
class TResourceContainer : public JGadget::TLinkList_factory<TResource, -offsetof(TResource, mLinkNode)> {
#else
// clangd does not support offsetof in template arguments.
class TResourceContainer : public JGadget::TLinkList_factory<TResource, -0x00> {
#endif
public:
TResourceContainer();
virtual TResource* Do_create();
Expand Down
2 changes: 1 addition & 1 deletion include/JSystem/JStudio/JStudio/functionvalue.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TFunctionValueAttribute_interpolate;

class TFunctionValue {
public:
enum TEProgress { PROG_INIT };
enum TEProgress { PROG_INIT, PROG_UNK1, PROG_UNK2, PROG_UNK3, PROG_UNK4 };
enum TEAdjust { ADJ_INIT, ADJ_UNK1, ADJ_UNK2, ADJ_UNK3, ADJ_UNK4 };
enum TEOutside { OUT_INIT };
enum TEInterpolate {};
Expand Down
12 changes: 6 additions & 6 deletions include/JSystem/JStudio/JStudio/stb.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,30 +166,30 @@ struct TParseData {
}

bool isEnd() const {
return m_data->_0 == 0;
return m_data->status == 0;
}

bool empty() const {
return m_data->_c == NULL;
return m_data->fileCount == NULL;
}

bool isValid() const {
return !empty() && m_data->_0 == 50;
return !empty() && m_data->status == 50;
}

data::TParse_TParagraph_data::TData* m_data;
};

template <int T>
struct TParseData_fixed : public TParseData<T> {
TParseData_fixed(const void* pContent) : TParseData(pContent) {}
TParseData_fixed(const void* pContent) : TParseData<T>(pContent) {}

const void* getNext() const {
return m_data->_c;
return this->m_data->fileCount;
}

bool isValid() const {
return TParseData::isValid() && getNext() != NULL;
return TParseData<T>::isValid() && getNext() != NULL;
}
};

Expand Down
5 changes: 5 additions & 0 deletions include/JSystem/JUtility/JUTConsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ class JUTConsoleManager {

static JUTConsoleManager* sManager;

#ifdef __MWERKS__
typedef JGadget::TLinkList<JUTConsole, -offsetof(JUTConsole, mLinkNode)> ConsoleList;
#else
// clangd does not support offsetof in template arguments.
typedef JGadget::TLinkList<JUTConsole, -sizeof(JKRDisposer)> ConsoleList;
#endif

private:
/* 0x00 */ ConsoleList soLink_;
Expand Down
3 changes: 2 additions & 1 deletion include/d/actor/d_a_player.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#ifndef D_A_PLAYER
#define D_A_PLAYER

#include "f_op/f_op_actor_mng.h"
#include "f_op/f_op_actor.h"
#include "d/d_particle.h"
#include "d/d_cc_d.h"
#include "d/d_item_data.h"

inline u8 dComIfGs_getSelectEquip(int i_no);
inline u8 dComIfGp_getMiniGameType();
Expand Down
9 changes: 1 addition & 8 deletions include/d/actor/d_a_player_main_data.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#include "d/d_cc_d.h"
#include "dolphin/mtx/vec.h"

extern char l_arcName[];

Expand Down Expand Up @@ -37,10 +37,3 @@ extern const Vec l_crawl_rside_offset;
extern const Vec l_crawl_lside_front_offset;
extern const Vec l_crawl_rside_front_offset;
extern const Vec l_crawl_min_side_offset;

extern dCcD_SrcCyl l_cyl_src;
extern dCcD_SrcCyl l_wind_cyl_src;
extern dCcD_SrcCyl l_at_cyl_src;
extern dCcD_SrcCps l_at_cps_src;
extern dCcD_SrcCps l_fan_wind_cps_src;
extern dCcD_SrcSph l_fan_wind_sph_src;
3 changes: 2 additions & 1 deletion include/d/d_com_inf_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -3464,11 +3464,12 @@ inline void dComIfG_TimerDeleteRequest() {
dComIfG_getTimerPtr()->deleteRequest();
}
inline void dComIfG_TimerStart(int timer, s16 mode) {
if (dComIfG_getTimerMode() == mode && dComIfG_getTimerPtr() != NULL)
if (dComIfG_getTimerMode() == mode && dComIfG_getTimerPtr() != NULL) {
if (timer != 0)
dComIfG_getTimerPtr()->start(timer);
else
dComIfG_getTimerPtr()->start();
}
}
inline void dComIfG_TimerReStart(int timer) {
if (dComIfG_getTimerPtr() != NULL)
Expand Down
4 changes: 2 additions & 2 deletions include/d/d_particle_name.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ namespace dPa_name {
ID_SCENE_END = 0x8466,
};

u16 j_o_id[];
u16 s_o_id[];
extern u16 j_o_id[];
extern u16 s_o_id[];
}

#endif /* D_PARTICLE_NAME */
6 changes: 6 additions & 0 deletions include/dolphin/os/OS.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,12 @@ inline s16 __OSf32tos16(register f32 inF) {
u32 tmp;
register u32* tmpPtr = &tmp;
// clang-format off
#ifdef __MWERKS__
asm {
psq_st inF, 0(tmpPtr), 0x1, 5
lha out, 0(tmpPtr)
}
#endif
// clang-format on

return out;
Expand All @@ -139,10 +141,12 @@ inline u8 __OSf32tou8(register f32 inF) {
u32 tmp;
register u32* tmpPtr = &tmp;
// clang-format off
#ifdef __MWERKS__
asm {
psq_st inF, 0(tmpPtr), 0x1, 2
lbz out, 0(tmpPtr)
}
#endif
// clang-format on

return out;
Expand All @@ -154,6 +158,7 @@ inline void OSf32tou8(f32* f, u8* out) {

static inline void OSInitFastCast(void) {
// clang-format off
#ifdef __MWERKS__
asm {
li r3, 4
oris r3, r3, 4
Expand All @@ -168,6 +173,7 @@ static inline void OSInitFastCast(void) {
oris r3, r3, 7
mtspr GQR5, r3
}
#endif
// clang-format on
}

Expand Down
Loading

0 comments on commit 34afbd8

Please sign in to comment.