mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
No more flexible array members (not standard C++) (#1307)
* Replace FAMs with `std::vector`s (or one `std::string`) in four `struct`s * Anonymous types declared in an anonymous union are also non-standard Only Clang complains about this (-Wnested-anon-types)
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "asm/lexer.hpp"
|
||||
|
||||
@@ -28,14 +29,12 @@ struct FileStackNode {
|
||||
|
||||
struct FileStackReptNode { // NODE_REPT
|
||||
struct FileStackNode node;
|
||||
uint32_t reptDepth;
|
||||
// WARNING: if changing this type, change overflow check in `fstk_Init`
|
||||
uint32_t iters[]; // REPT iteration counts since last named node, in reverse depth order
|
||||
std::vector<uint32_t> *iters; // REPT iteration counts since last named node, in reverse depth order
|
||||
};
|
||||
|
||||
struct FileStackNamedNode { // NODE_FILE, NODE_MACRO
|
||||
struct FileStackNode node;
|
||||
char name[]; // File name for files, file::macro name for macros
|
||||
std::string *name; // File name for files, file::macro name for macros
|
||||
};
|
||||
|
||||
#define DEFAULT_MAX_DEPTH 64
|
||||
|
||||
@@ -15,7 +15,7 @@ struct MacroArgs;
|
||||
|
||||
struct MacroArgs *macro_GetCurrentArgs(void);
|
||||
struct MacroArgs *macro_NewArgs(void);
|
||||
void macro_AppendArg(struct MacroArgs **args, char *s);
|
||||
void macro_AppendArg(struct MacroArgs *args, char *s);
|
||||
void macro_UseNewArgs(struct MacroArgs *args);
|
||||
void macro_FreeArgs(struct MacroArgs *args);
|
||||
char const *macro_GetArg(uint32_t i);
|
||||
|
||||
@@ -23,6 +23,12 @@ enum SymbolType {
|
||||
SYM_REF // Forward reference to a label
|
||||
};
|
||||
|
||||
// Only used in an anonymous union by `struct Symbol`
|
||||
struct strValue {
|
||||
size_t size;
|
||||
char *value;
|
||||
};
|
||||
|
||||
struct Symbol {
|
||||
char name[MAXSYMLEN + 1];
|
||||
enum SymbolType type;
|
||||
@@ -36,18 +42,12 @@ struct Symbol {
|
||||
union {
|
||||
// If sym_IsNumeric
|
||||
int32_t value;
|
||||
int32_t (*numCallback)(void);
|
||||
int32_t (*numCallback)(void); // If hasCallback
|
||||
// For SYM_MACRO
|
||||
struct {
|
||||
size_t size;
|
||||
char *value;
|
||||
} macro;
|
||||
struct strValue macro;
|
||||
// For SYM_EQUS
|
||||
struct {
|
||||
size_t size;
|
||||
char *value;
|
||||
} equs;
|
||||
char const *(*strCallback)(void);
|
||||
struct strValue equs;
|
||||
char const *(*strCallback)(void); // If hasCallback
|
||||
};
|
||||
|
||||
uint32_t ID; // ID of the symbol in the object file (-1 if none)
|
||||
|
||||
@@ -28,6 +28,12 @@ extern bool beVerbose;
|
||||
extern bool isWRA0Mode;
|
||||
extern bool disablePadding;
|
||||
|
||||
// Only used in an anonymous union by `struct FileStackNode`
|
||||
struct reptNodeData {
|
||||
uint32_t depth;
|
||||
uint32_t *iters;
|
||||
};
|
||||
|
||||
struct FileStackNode {
|
||||
struct FileStackNode *parent;
|
||||
// Line at which the parent context was exited; meaningless for the root level
|
||||
@@ -36,10 +42,7 @@ struct FileStackNode {
|
||||
enum FileStackNodeType type;
|
||||
union {
|
||||
char *name; // NODE_FILE, NODE_MACRO
|
||||
struct { // NODE_REPT
|
||||
uint32_t depth;
|
||||
uint32_t *iters;
|
||||
} rept;
|
||||
struct reptNodeData rept; // NODE_REPT
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user