Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CompileFlags:
Add: [-D__CLANGD__]
11 changes: 5 additions & 6 deletions include/decomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ typedef struct ps_f32 {
SECTION_GARBAGE static void __garbage_ordering_hints(void)
#define order_hint_access(var) (void)(var)

#elif defined (__INTELLISENSE__)
#elif defined (__EDITOR_CHECKING__)
// dummy implementations for editor tooling

#define sdata_ps_f32 ps_f32
#define sdata2_ps_f32 ps_f32
Expand All @@ -35,9 +36,7 @@ typedef struct ps_f32 {
#define SECTION_GARBAGE
#define static_order_hints
#define order_hint_access(var) (void)(var)

#endif

#ifdef __clang__
#define __cntlzw(x) __builtin_clz(x)
// TODO(KooShnoo): is builtin preferred?
#define __cntlzw(x) (x)
// #define __cntlzw(x) __builtin_clz(x)
#endif
19 changes: 12 additions & 7 deletions include/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,21 @@

#define DECLTYPE(x) __decltype__(x)

// https://github.com/DarkRTA/rb3/blob/235050f88a263fec0387b7c618dda76a8bb24d2c/src/sdk/RVL_SDK/revolution/os/OSUtils.h#L13-L17
#if defined(__CWCC__) && !defined(__INTELLISENSE__)
#define AT_ADDRESS(addr) : (addr)
#else
#define AT_ADDRESS(addr)
#if defined(__INTELLISENSE__) || defined(__CLANGD__)
// TODO(KooShnoo): are we happy with this name?
#define __EDITOR_CHECKING__
#endif

// For VSCode
#ifdef __INTELLISENSE__
#ifdef __CWCC__
// codewarrior-specific syntax
#define AT_ADDRESS(addr) : (addr)
#elif defined(__EDITOR_CHECKING__)
// dummy implementations for editor tooling
#define AT_ADDRESS(addr)
#define asm
#define __attribute__(x)
#define __declspec(x)
#else
// building with a non-codewarrior compiler is not supported yet
#error "workarounds for codewarrior's language extensions unimplemented"
#endif
2 changes: 1 addition & 1 deletion include/rk_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class NonCopyable {


// Main static assert macro
#if defined(__INTELLISENSE__)
#ifdef __EDITOR_CHECKING__
#if !__has_extension(c_static_assert)
#error "language server lacks `_Static_assert` support"
#endif
Expand Down
9 changes: 6 additions & 3 deletions lib/MSL/include/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ inline f32 sqrtf(f32 x) { return (f32)sqrt(x); }
f64 acos(f64);
inline f32 acosf(f32 x) { return (f32)acos(x); }

#ifdef __INTELLISENSE__
#define __fabsf(x) x
#define __fabs(x) x
#ifdef __CWCC__
// when using the codewarrior compiler, __fabs and __fabsf are builtin intrinsics.
#elif defined(__EDITOR_CHECKING__)
// dummy implementation for editor tooling
#define __fabsf(x) (x)
#define __fabs(x) (x)
#endif

f32 fabsf(f32);
Expand Down
4 changes: 3 additions & 1 deletion lib/MSL/include/stddef.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once

#ifdef __INTELLISENSE__
#include "macros.h"

#ifdef __EDITOR_CHECKING__
#define offsetof(type, m) __builtin_offsetof(type,m)
#else
#define offsetof(type, m) ((size_t) & (((type*)0)->m))
Expand Down
11 changes: 6 additions & 5 deletions lib/MSL/include/stdlib.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "macros.h"

#ifndef SIZE_T_DEFINE
#define SIZE_T_DEFINE
typedef unsigned long size_t;
Expand All @@ -9,11 +11,10 @@ typedef unsigned long size_t;
#ifdef __CWCC__
#define abs(x) __abs(x)
#define labs(x) __labs(x)
#elif defined(__clang__)
#define abs(x) __builtin_abs(x)
#define labs(x) __builtin_labs(x)
#else
#error compiler has no instrinsic abs support, please do some sit ups.
#elif defined(__EDITOR_CHECKING__)
// dummy implementation for editor tooling
#define abs(x) (x)
#define labs(x) (x)
#endif

long strtol(const char* restrict nptr, char** restrict endptr, int base);
Expand Down
2 changes: 2 additions & 0 deletions src/system/CourseMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,11 @@ class MapdataAreaAccessor {
MapdataAreaBase** byPriority;
};
static_assert(sizeof(MapdataAreaAccessor) == 0x14);
#ifndef __EDITOR_CHECKING__
// Ensure the vtable does not exist at offset 0x0
// (It should exist at offset 0x8)
static_assert(offsetof(MapdataAreaAccessor, entries) == 0x0);
#endif

class MapdataCameraAccessor
: public MapdataAccessorBase<MapdataCamera, MapdataCamera::SData> {
Expand Down