mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-03-21 10:21:03 +00:00
Use C++ naming for structures
This commit is contained in:
parent
aabefd1bfe
commit
878195bdec
9 changed files with 90 additions and 95 deletions
30
fold.cpp
30
fold.cpp
|
@ -41,24 +41,24 @@ enum sfloat_exceptionflags_t {
|
|||
};
|
||||
|
||||
/* Rounding modes */
|
||||
typedef enum {
|
||||
enum sfloat_roundingmode_t {
|
||||
SFLOAT_ROUND_NEAREST_EVEN,
|
||||
SFLOAT_ROUND_DOWN,
|
||||
SFLOAT_ROUND_UP,
|
||||
SFLOAT_ROUND_TO_ZERO
|
||||
} sfloat_roundingmode_t;
|
||||
};
|
||||
|
||||
/* Underflow tininess-detection mode */
|
||||
typedef enum {
|
||||
enum sfloat_tdetect_t {
|
||||
SFLOAT_TAFTER,
|
||||
SFLOAT_TBEFORE
|
||||
} sfloat_tdetect_t;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
sfloat_roundingmode_t roundingmode;
|
||||
struct sfloat_state_t {
|
||||
sfloat_roundingmode_t roundingmode;
|
||||
sfloat_exceptionflags_t exceptionflags;
|
||||
sfloat_tdetect_t tiny;
|
||||
} sfloat_state_t;
|
||||
sfloat_tdetect_t tiny;
|
||||
};
|
||||
|
||||
/* Counts the number of leading zero bits before the most-significand one bit. */
|
||||
#ifdef _MSC_VER
|
||||
|
@ -544,22 +544,22 @@ static GMQCC_INLINE void sfloat_init(sfloat_state_t *state) {
|
|||
*
|
||||
* TODO: gcc/clang hinting for autovectorization
|
||||
*/
|
||||
typedef enum {
|
||||
enum vec3_comp_t {
|
||||
VEC_COMP_X = 1 << 0,
|
||||
VEC_COMP_Y = 1 << 1,
|
||||
VEC_COMP_Z = 1 << 2
|
||||
} vec3_comp_t;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct vec3_soft_t {
|
||||
sfloat_cast_t x;
|
||||
sfloat_cast_t y;
|
||||
sfloat_cast_t z;
|
||||
} vec3_soft_t;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
vec3_comp_t faults;
|
||||
struct vec3_soft_state_t {
|
||||
vec3_comp_t faults;
|
||||
sfloat_state_t state[3];
|
||||
} vec3_soft_state_t;
|
||||
};
|
||||
|
||||
static GMQCC_INLINE vec3_soft_t vec3_soft_convert(vec3_t vec) {
|
||||
vec3_soft_t soft;
|
||||
|
|
12
ftepp.cpp
12
ftepp.cpp
|
@ -145,10 +145,10 @@ static char *ftepp_predef_timestamp(ftepp_t *context) {
|
|||
return value;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
char *(*func)(ftepp_t *);
|
||||
} ftepp_predef_t;
|
||||
struct ftepp_predef_t {
|
||||
const char *name;
|
||||
char *(*func)(ftepp_t *);
|
||||
};
|
||||
|
||||
static const ftepp_predef_t ftepp_predefs[] = {
|
||||
{ "__LINE__", &ftepp_predef_line },
|
||||
|
@ -565,9 +565,9 @@ static bool ftepp_define(ftepp_t *ftepp)
|
|||
* this kind of parens. Curly braces or [] don't count towards the
|
||||
* paren-level.
|
||||
*/
|
||||
typedef struct {
|
||||
struct macroparam {
|
||||
pptoken **tokens;
|
||||
} macroparam;
|
||||
};
|
||||
|
||||
static void macroparam_clean(macroparam *self)
|
||||
{
|
||||
|
|
75
gmqcc.h
75
gmqcc.h
|
@ -207,12 +207,12 @@ size_t hash(const char *key);
|
|||
* us to use the array [] to access individual elements from the vector
|
||||
* opposed to using set/get methods.
|
||||
*/
|
||||
typedef struct {
|
||||
struct vector_t {
|
||||
size_t allocated;
|
||||
size_t used;
|
||||
|
||||
/* can be extended now! whoot */
|
||||
} vector_t;
|
||||
};
|
||||
|
||||
/* hidden interface */
|
||||
void _util_vec_grow(void **a, size_t i, size_t s);
|
||||
|
@ -300,12 +300,12 @@ extern const uint16_t type_eq_instr [TYPE_COUNT];
|
|||
extern const uint16_t type_ne_instr [TYPE_COUNT];
|
||||
extern const uint16_t type_not_instr [TYPE_COUNT];
|
||||
|
||||
typedef struct {
|
||||
struct prog_section_t {
|
||||
uint32_t offset; /* Offset in file of where data begins */
|
||||
uint32_t length; /* Length of section (how many of) */
|
||||
} prog_section_t;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct prog_header_t {
|
||||
uint32_t version; /* Program version (6) */
|
||||
uint16_t crc16;
|
||||
uint16_t skip;
|
||||
|
@ -317,7 +317,7 @@ typedef struct {
|
|||
prog_section_t strings;
|
||||
prog_section_t globals;
|
||||
uint32_t entfield; /* Number of entity fields */
|
||||
} prog_header_t;
|
||||
};
|
||||
|
||||
/*
|
||||
* Each paramater incerements by 3 since vector types hold
|
||||
|
@ -334,19 +334,19 @@ typedef struct {
|
|||
#define OFS_PARM6 (OFS_PARM5 +3)
|
||||
#define OFS_PARM7 (OFS_PARM6 +3)
|
||||
|
||||
typedef union {
|
||||
union operand_t {
|
||||
int16_t s1;
|
||||
uint16_t u1;
|
||||
} operand_t;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct prog_section_statement_t {
|
||||
uint16_t opcode;
|
||||
operand_t o1;
|
||||
operand_t o2;
|
||||
operand_t o3;
|
||||
} prog_section_statement_t;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct prog_section_both_t {
|
||||
/*
|
||||
* The types:
|
||||
* 0 = ev_void
|
||||
|
@ -362,7 +362,7 @@ typedef struct {
|
|||
uint16_t type;
|
||||
uint16_t offset;
|
||||
uint32_t name;
|
||||
} prog_section_both_t;
|
||||
};
|
||||
|
||||
typedef prog_section_both_t prog_section_def_t;
|
||||
typedef prog_section_both_t prog_section_field_t;
|
||||
|
@ -371,7 +371,7 @@ typedef prog_section_both_t prog_section_field_t;
|
|||
#define DEF_SAVEGLOBAL (1<<15)
|
||||
#define DEF_TYPEMASK ((1<<15)-1)
|
||||
|
||||
typedef struct {
|
||||
struct prog_section_function_t {
|
||||
int32_t entry; /* in statement table for instructions */
|
||||
uint32_t firstlocal; /* First local in local table */
|
||||
uint32_t locals; /* Total ints of params + locals */
|
||||
|
@ -380,7 +380,7 @@ typedef struct {
|
|||
uint32_t file; /* file of the source file */
|
||||
int32_t nargs; /* number of arguments */
|
||||
uint8_t argsize[8]; /* size of arguments (keep 8 always?) */
|
||||
} prog_section_function_t;
|
||||
};
|
||||
|
||||
/*
|
||||
* Instructions
|
||||
|
@ -596,9 +596,9 @@ enum store_types {
|
|||
store_return /* unassignable, at OFS_RETURN */
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct vec3_t {
|
||||
qcfloat_t x, y, z;
|
||||
} vec3_t;
|
||||
};
|
||||
|
||||
/* exec.c */
|
||||
|
||||
|
@ -635,16 +635,16 @@ enum {
|
|||
#define VMXF_TRACE 0x0001 /* trace: print statements before executing */
|
||||
#define VMXF_PROFILE 0x0002 /* profile: increment the profile counters */
|
||||
|
||||
struct qc_program_s;
|
||||
typedef int (*prog_builtin_t)(struct qc_program_s *prog);
|
||||
struct qc_program_t;
|
||||
typedef int (*prog_builtin_t)(qc_program_t *prog);
|
||||
|
||||
typedef struct {
|
||||
qcint_t stmt;
|
||||
size_t localsp;
|
||||
struct qc_exec_stack_t {
|
||||
qcint_t stmt;
|
||||
size_t localsp;
|
||||
prog_section_function_t *function;
|
||||
} qc_exec_stack_t;
|
||||
};
|
||||
|
||||
typedef struct qc_program_s {
|
||||
struct qc_program_t {
|
||||
char *filename;
|
||||
prog_section_statement_t *code;
|
||||
prog_section_def_t *defs;
|
||||
|
@ -695,7 +695,7 @@ typedef struct qc_program_s {
|
|||
} cached_globals;
|
||||
|
||||
bool supports_state; /* is INSTR_STATE supported? */
|
||||
} qc_program_t;
|
||||
};
|
||||
|
||||
qc_program_t* prog_load (const char *filename, bool ignoreversion);
|
||||
void prog_delete (qc_program_t *prog);
|
||||
|
@ -732,10 +732,10 @@ void ftepp_add_macro(ftepp_t *ftepp, const char *name, const char *value);
|
|||
/* Helpers to allow for a whole lot of flags. Otherwise we'd limit
|
||||
* to 32 or 64 -f options...
|
||||
*/
|
||||
typedef struct {
|
||||
struct longbit {
|
||||
size_t idx; /* index into an array of 32 bit words */
|
||||
uint8_t bit; /* bit index for the 8 bit group idx points to */
|
||||
} longbit;
|
||||
};
|
||||
#define LONGBIT(bit) { ((bit)/32), ((bit)%32) }
|
||||
#define LONGBIT_SET(B, I) ((B).idx = (I)/32, (B).bit = ((I)%32))
|
||||
#else
|
||||
|
@ -750,10 +750,10 @@ int utf8_from(char *, utf8ch_t);
|
|||
int utf8_to(utf8ch_t *, const unsigned char *, size_t);
|
||||
|
||||
/* opts.c */
|
||||
typedef struct {
|
||||
struct opts_flag_def_t {
|
||||
const char *name;
|
||||
longbit bit;
|
||||
} opts_flag_def_t;
|
||||
};
|
||||
|
||||
bool opts_setflag (const char *, bool);
|
||||
bool opts_setwarn (const char *, bool);
|
||||
|
@ -807,30 +807,27 @@ extern const unsigned int opts_opt_oflag[COUNT_OPTIMIZATIONS+1];
|
|||
extern unsigned int opts_optimizationcount[COUNT_OPTIMIZATIONS];
|
||||
|
||||
/* other options: */
|
||||
typedef enum {
|
||||
enum {
|
||||
COMPILER_QCC, /* circa QuakeC */
|
||||
COMPILER_FTEQCC, /* fteqcc QuakeC */
|
||||
COMPILER_QCCX, /* qccx QuakeC */
|
||||
COMPILER_GMQCC /* this QuakeC */
|
||||
} opts_std_t;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct opt_value_t {
|
||||
union {
|
||||
bool b;
|
||||
bool b;
|
||||
uint16_t u16;
|
||||
uint32_t u32;
|
||||
|
||||
union {
|
||||
char *p;
|
||||
char *p;
|
||||
const char *c;
|
||||
} str;
|
||||
} data;
|
||||
|
||||
bool allocated;
|
||||
} opt_value_t;
|
||||
};
|
||||
|
||||
|
||||
typedef struct {
|
||||
struct opts_cmd_t {
|
||||
opt_value_t options [OPTION_COUNT];
|
||||
uint32_t flags [1 + (COUNT_FLAGS / 32)];
|
||||
uint32_t warn [1 + (COUNT_WARNINGS / 32)];
|
||||
|
@ -839,7 +836,7 @@ typedef struct {
|
|||
uint32_t werror_backup[1 + (COUNT_WARNINGS / 32)];
|
||||
uint32_t optimization [1 + (COUNT_OPTIMIZATIONS / 32)];
|
||||
bool optimizeoff; /* True when -O0 */
|
||||
} opts_cmd_t;
|
||||
};
|
||||
|
||||
extern opts_cmd_t opts;
|
||||
|
||||
|
|
10
ir.cpp
10
ir.cpp
|
@ -2118,12 +2118,12 @@ void ir_function_enumerate(ir_function *self)
|
|||
* we can allocate their global-positions.
|
||||
* This is the counterpart to register-allocation in register machines.
|
||||
*/
|
||||
typedef struct {
|
||||
struct function_allocator {
|
||||
ir_value **locals;
|
||||
size_t *sizes;
|
||||
size_t *positions;
|
||||
bool *unique;
|
||||
} function_allocator;
|
||||
size_t *sizes;
|
||||
size_t *positions;
|
||||
bool *unique;
|
||||
};
|
||||
|
||||
static bool function_allocator_alloc(function_allocator *alloc, ir_value *var)
|
||||
{
|
||||
|
|
4
ir.h
4
ir.h
|
@ -14,11 +14,11 @@ struct ir_block;
|
|||
struct ir_function;
|
||||
struct ir_builder;
|
||||
|
||||
typedef struct {
|
||||
struct ir_life_entry_t {
|
||||
/* both inclusive */
|
||||
size_t start;
|
||||
size_t end;
|
||||
} ir_life_entry_t;
|
||||
};
|
||||
|
||||
enum {
|
||||
IR_FLAG_HAS_ARRAYS = 1 << 0,
|
||||
|
|
11
main.cpp
11
main.cpp
|
@ -7,12 +7,11 @@
|
|||
/* TODO: cleanup this whole file .. it's a fuckign mess */
|
||||
|
||||
/* set by the standard */
|
||||
const oper_info *operators = NULL;
|
||||
size_t operator_count = 0;
|
||||
static bool opts_output_wasset = false;
|
||||
|
||||
typedef struct { char *filename; int type; } argitem;
|
||||
typedef struct { char *name; char *value; } ppitem;
|
||||
const oper_info *operators = NULL;
|
||||
size_t operator_count = 0;
|
||||
static bool opts_output_wasset = false;
|
||||
struct argitem { char *filename; int type; };
|
||||
struct ppitem { char *name; char *value; };
|
||||
static argitem *items = NULL;
|
||||
static ppitem *ppems = NULL;
|
||||
|
||||
|
|
21
parser.cpp
21
parser.cpp
|
@ -147,15 +147,14 @@ static ast_value* parser_find_typedef(parser_t *parser, const char *name, size_t
|
|||
return NULL;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct sy_elem {
|
||||
size_t etype; /* 0 = expression, others are operators */
|
||||
bool isparen;
|
||||
size_t off;
|
||||
bool isparen;
|
||||
size_t off;
|
||||
ast_expression *out;
|
||||
ast_block *block; /* for commas and function calls */
|
||||
ast_block *block; /* for commas and function calls */
|
||||
lex_ctx_t ctx;
|
||||
} sy_elem;
|
||||
};
|
||||
|
||||
enum {
|
||||
PAREN_EXPR,
|
||||
|
@ -164,13 +163,13 @@ enum {
|
|||
PAREN_TERNARY1,
|
||||
PAREN_TERNARY2
|
||||
};
|
||||
typedef struct
|
||||
{
|
||||
|
||||
struct shunt {
|
||||
sy_elem *out;
|
||||
sy_elem *ops;
|
||||
size_t *argc;
|
||||
unsigned int *paren;
|
||||
} shunt;
|
||||
};
|
||||
|
||||
static sy_elem syexp(lex_ctx_t ctx, ast_expression *v) {
|
||||
sy_elem e;
|
||||
|
@ -2724,10 +2723,10 @@ static bool parse_break_continue(parser_t *parser, ast_block *block, ast_express
|
|||
/* returns true when it was a variable qualifier, false otherwise!
|
||||
* on error, cvq is set to CV_WRONG
|
||||
*/
|
||||
typedef struct {
|
||||
struct attribute_t {
|
||||
const char *name;
|
||||
size_t flag;
|
||||
} attribute_t;
|
||||
};
|
||||
|
||||
static bool parse_qualifiers(parser_t *parser, bool with_local, int *cvq, bool *noref, bool *is_static, uint32_t *_flags, char **message)
|
||||
{
|
||||
|
|
10
stat.cpp
10
stat.cpp
|
@ -55,11 +55,11 @@ void _util_vec_delete(void *data) {
|
|||
* all around. This is the internal interface, please look for
|
||||
* EXPOSED INTERFACE comment below
|
||||
*/
|
||||
typedef struct hash_node_t {
|
||||
char *key; /* the key for this node in table */
|
||||
void *value; /* pointer to the data as void* */
|
||||
struct hash_node_t *next; /* next node (linked list) */
|
||||
} hash_node_t;
|
||||
struct hash_node_t {
|
||||
char *key; /* the key for this node in table */
|
||||
void *value; /* pointer to the data as void* */
|
||||
hash_node_t *next; /* next node (linked list) */
|
||||
};
|
||||
|
||||
size_t hash(const char *key);
|
||||
|
||||
|
|
12
test.cpp
12
test.cpp
|
@ -16,13 +16,13 @@ static const char *task_bins[] = {
|
|||
"./qcvm"
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct popen_t {
|
||||
FILE *handles[3];
|
||||
int pipes[3];
|
||||
int stderr_fd;
|
||||
int stdout_fd;
|
||||
int pid;
|
||||
} popen_t;
|
||||
};
|
||||
|
||||
static FILE **task_popen(const char *command, const char *mode) {
|
||||
int inhandle [2];
|
||||
|
@ -188,7 +188,7 @@ static int task_pclose(FILE **handles) {
|
|||
* that need not be set), as well as missing tags, and error accordingly
|
||||
* this will result in the task failing.
|
||||
*/
|
||||
typedef struct {
|
||||
struct task_template_t {
|
||||
char *description;
|
||||
char *compileflags;
|
||||
char *executeflags;
|
||||
|
@ -198,7 +198,7 @@ typedef struct {
|
|||
char **comparematch;
|
||||
char *rulesfile;
|
||||
char *testflags;
|
||||
} task_template_t;
|
||||
};
|
||||
|
||||
/*
|
||||
* This is very much like a compiler code generator :-). This generates
|
||||
|
@ -571,7 +571,7 @@ static void task_template_destroy(task_template_t *tmpl) {
|
|||
* Now comes the task manager, this system allows adding tasks in and out
|
||||
* of a task list. This is the executor of the tasks essentially as well.
|
||||
*/
|
||||
typedef struct {
|
||||
struct task_t {
|
||||
task_template_t *tmpl;
|
||||
FILE **runhandles;
|
||||
FILE *stderrlog;
|
||||
|
@ -579,7 +579,7 @@ typedef struct {
|
|||
char *stdoutlogfile;
|
||||
char *stderrlogfile;
|
||||
bool compiled;
|
||||
} task_t;
|
||||
};
|
||||
|
||||
static task_t *task_tasks = NULL;
|
||||
|
||||
|
|
Loading…
Reference in a new issue