]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Use C++ naming for structures
authorDale Weiler <weilercdale@gmail.com>
Thu, 15 Jan 2015 04:56:52 +0000 (23:56 -0500)
committerDale Weiler <weilercdale@gmail.com>
Thu, 15 Jan 2015 04:56:52 +0000 (23:56 -0500)
conout.cpp
exec.cpp
fold.cpp
ftepp.cpp
gmqcc.h
ir.cpp
ir.h
lexer.h
main.cpp
parser.h

index 9d0659b4b691c3a9f44fb1b011af5f514b608cf2..98c428934652a3d36bf58677e8651ea19afb7513 100644 (file)
@@ -5,12 +5,12 @@
 #define GMQCC_IS_STDERR(X) ((X) == stderr)
 #define GMQCC_IS_DEFINE(X) (GMQCC_IS_STDERR(X) || GMQCC_IS_STDOUT(X))
 
 #define GMQCC_IS_STDERR(X) ((X) == stderr)
 #define GMQCC_IS_DEFINE(X) (GMQCC_IS_STDERR(X) || GMQCC_IS_STDOUT(X))
 
-typedef struct {
+struct con_t {
     FILE *handle_err;
     FILE *handle_out;
     int color_err;
     int color_out;
     FILE *handle_err;
     FILE *handle_out;
     int color_err;
     int color_out;
-} con_t;
+};
 
 static con_t console;
 
 
 static con_t console;
 
index 8ec97e4302d38f7d5099fee6b0a9622bf565de74..5b1fe23505061d240c2cfa93342b1949ffe67d4d 100644 (file)
--- a/exec.cpp
+++ b/exec.cpp
@@ -633,10 +633,10 @@ const char *type_name[TYPE_COUNT] = {
     "noexpr"
 };
 
     "noexpr"
 };
 
-typedef struct {
+struct qcvm_parameter {
     int         vtype;
     const char *value;
     int         vtype;
     const char *value;
-} qcvm_parameter;
+};
 
 static qcvm_parameter *main_params = NULL;
 
 
 static qcvm_parameter *main_params = NULL;
 
index 64b20d94e7662f7d1802293c39ebe670e2803da1..a2d6339f841986c973c92ee93273aaf81ebb28f7 100644 (file)
--- a/fold.cpp
+++ b/fold.cpp
  */
 typedef uint32_t sfloat_t;
 
  */
 typedef uint32_t sfloat_t;
 
-typedef union {
+union sfloat_cast_t {
     qcfloat_t f;
     sfloat_t  s;
     qcfloat_t f;
     sfloat_t  s;
-} sfloat_cast_t;
+};
 
 /* Exception flags */
 
 /* Exception flags */
-typedef enum {
+enum sfloat_exceptionflags_t {
     SFLOAT_NOEXCEPT  = 0,
     SFLOAT_INVALID   = 1,
     SFLOAT_DIVBYZERO = 4,
     SFLOAT_OVERFLOW  = 8,
     SFLOAT_UNDERFLOW = 16,
     SFLOAT_INEXACT   = 32
     SFLOAT_NOEXCEPT  = 0,
     SFLOAT_INVALID   = 1,
     SFLOAT_DIVBYZERO = 4,
     SFLOAT_OVERFLOW  = 8,
     SFLOAT_UNDERFLOW = 16,
     SFLOAT_INEXACT   = 32
-} sfloat_exceptionflags_t;
+};
 
 /* Rounding modes */
 typedef enum {
 
 /* Rounding modes */
 typedef enum {
index 1c80d9ed6f27287e71ddcd10b976da81f08cf6e8..2cfe4cb61bd50d5eb93b0563c29409b3dc1e29e1 100644 (file)
--- a/ftepp.cpp
+++ b/ftepp.cpp
@@ -7,54 +7,48 @@
 
 #define HT_MACROS 1024
 
 
 #define HT_MACROS 1024
 
-typedef struct {
+struct ppcondition {
     bool on;
     bool was_on;
     bool had_else;
     bool on;
     bool was_on;
     bool had_else;
-} ppcondition;
+};
 
 
-typedef struct {
-    int   token;
+struct pptoken {
+    int token;
     char *value;
     /* a copy from the lexer */
     union {
         vec3_t v;
     char *value;
     /* a copy from the lexer */
     union {
         vec3_t v;
-        int    i;
+        int i;
         double f;
         double f;
-        int    t; /* type */
+        int t; /* type */
     } constval;
     } constval;
-} pptoken;
+};
 
 
-typedef struct {
+struct ppmacro {
     lex_ctx_t ctx;
     lex_ctx_t ctx;
-
-    char   *name;
-    char  **params;
+    char *name;
+    char **params;
     /* yes we need an extra flag since `#define FOO x` is not the same as `#define FOO() x` */
     /* yes we need an extra flag since `#define FOO x` is not the same as `#define FOO() x` */
-    bool    has_params;
-    bool    variadic;
-
+    bool has_params;
+    bool variadic;
     pptoken **output;
     pptoken **output;
-} ppmacro;
+};
 
 
-typedef struct ftepp_s {
-    lex_file    *lex;
-    int          token;
+struct ftepp_t {
+    lex_file *lex;
+    int token;
     unsigned int errors;
     unsigned int errors;
-
-    bool         output_on;
+    bool output_on;
     ppcondition *conditions;
     ppcondition *conditions;
-    /*ppmacro    **macros;*/
-    ht           macros;  /* hashtable<string, ppmacro*> */
-    char        *output_string;
-
-    char        *itemname;
-    char        *includename;
-    bool         in_macro;
-
+    ht macros;  /* hashtable<string, ppmacro*> */
+    char *output_string;
+    char *itemname;
+    char *includename;
+    bool in_macro;
     uint32_t predef_countval;
     uint32_t predef_randval;
     uint32_t predef_countval;
     uint32_t predef_randval;
-} ftepp_t;
+};
 
 /* __DATE__ */
 static char *ftepp_predef_date(ftepp_t *context) {
 
 /* __DATE__ */
 static char *ftepp_predef_date(ftepp_t *context) {
diff --git a/gmqcc.h b/gmqcc.h
index 07cdddd536d5bb3f5f501356625a51ca9276b685..38aba65aaa2b0edcd9d4934003188f3b0dc99d42 100644 (file)
--- a/gmqcc.h
+++ b/gmqcc.h
@@ -496,7 +496,7 @@ typedef float    qcfloat_t;
 typedef int32_t  qcint_t;
 typedef uint32_t qcuint_t;
 
 typedef int32_t  qcint_t;
 typedef uint32_t qcuint_t;
 
-typedef struct {
+struct code_t {
     prog_section_statement_t *statements;
     int                      *linenums;
     int                      *columnnums;
     prog_section_statement_t *statements;
     int                      *linenums;
     int                      *columnnums;
@@ -509,17 +509,17 @@ typedef struct {
     uint32_t                  entfields;
     ht                        string_cache;
     qcint_t                   string_cached_empty;
     uint32_t                  entfields;
     ht                        string_cache;
     qcint_t                   string_cached_empty;
-} code_t;
+};
 
 /*
  * A shallow copy of a lex_file to remember where which ast node
  * came from.
  */
 
 /*
  * A shallow copy of a lex_file to remember where which ast node
  * came from.
  */
-typedef struct {
+struct lex_ctx_t {
     const char *file;
     size_t      line;
     size_t      column;
     const char *file;
     size_t      line;
     size_t      column;
-} lex_ctx_t;
+};
 
 /*
  * code_write          -- writes out the compiled file
 
 /*
  * code_write          -- writes out the compiled file
@@ -704,27 +704,27 @@ const char*         prog_getstring (qc_program_t *prog, qcint_t str);
 prog_section_def_t* prog_entfield  (qc_program_t *prog, qcint_t off);
 prog_section_def_t* prog_getdef    (qc_program_t *prog, qcint_t off);
 qcany_t*            prog_getedict  (qc_program_t *prog, qcint_t e);
 prog_section_def_t* prog_entfield  (qc_program_t *prog, qcint_t off);
 prog_section_def_t* prog_getdef    (qc_program_t *prog, qcint_t off);
 qcany_t*            prog_getedict  (qc_program_t *prog, qcint_t e);
-qcint_t               prog_tempstring(qc_program_t *prog, const char *_str);
+qcint_t             prog_tempstring(qc_program_t *prog, const char *_str);
 
 
 /* parser.c */
 
 
 /* parser.c */
-struct parser_s;
-struct parser_s *parser_create        (void);
-bool             parser_compile_file  (struct parser_s *parser, const char *);
-bool             parser_compile_string(struct parser_s *parser, const char *, const char *, size_t);
-bool             parser_finish        (struct parser_s *parser, const char *);
-void             parser_cleanup       (struct parser_s *parser);
+struct parser_t;
+parser_t *parser_create(void);
+bool parser_compile_file(parser_t *parser, const char *);
+bool parser_compile_string(parser_t *parser, const char *, const char *, size_t);
+bool parser_finish(parser_t *parser, const char *);
+void parser_cleanup(parser_t *parser);
 
 /* ftepp.c */
 
 /* ftepp.c */
-struct ftepp_s;
-struct ftepp_s *ftepp_create           (void);
-bool            ftepp_preprocess_file  (struct ftepp_s *ftepp, const char *filename);
-bool            ftepp_preprocess_string(struct ftepp_s *ftepp, const char *name, const char *str);
-void            ftepp_finish           (struct ftepp_s *ftepp);
-const char     *ftepp_get              (struct ftepp_s *ftepp);
-void            ftepp_flush            (struct ftepp_s *ftepp);
-void            ftepp_add_define       (struct ftepp_s *ftepp, const char *source, const char *name);
-void            ftepp_add_macro        (struct ftepp_s *ftepp, const char *name,   const char *value);
+struct ftepp_t;
+ftepp_t *ftepp_create           (void);
+bool ftepp_preprocess_file  (ftepp_t *ftepp, const char *filename);
+bool ftepp_preprocess_string(ftepp_t *ftepp, const char *name, const char *str);
+void ftepp_finish(ftepp_t *ftepp);
+const char *ftepp_get(ftepp_t *ftepp);
+void ftepp_flush(ftepp_t *ftepp);
+void ftepp_add_define(ftepp_t *ftepp, const char *source, const char *name);
+void ftepp_add_macro(ftepp_t *ftepp, const char *name,   const char *value);
 
 /* main.c */
 
 
 /* main.c */
 
diff --git a/ir.cpp b/ir.cpp
index 8c3d23423ed75267574d47c4d7fafa493c93f51e..5920361c7314bb36394bb16a09058adcb665754e 100644 (file)
--- a/ir.cpp
+++ b/ir.cpp
@@ -199,7 +199,7 @@ static void            ir_gen_extparam      (ir_builder *ir);
 
 static bool            ir_builder_set_name(ir_builder *self, const char *name);
 
 
 static bool            ir_builder_set_name(ir_builder *self, const char *name);
 
-static ir_function*    ir_function_new(struct ir_builder_s *owner, int returntype);
+static ir_function*    ir_function_new(ir_builder *owner, int returntype);
 static bool            ir_function_set_name(ir_function*, const char *name);
 static void            ir_function_delete(ir_function*);
 static void            ir_function_dump(ir_function*, char *ind, int (*oprintf)(const char*,...));
 static bool            ir_function_set_name(ir_function*, const char *name);
 static void            ir_function_delete(ir_function*);
 static void            ir_function_dump(ir_function*, char *ind, int (*oprintf)(const char*,...));
@@ -207,7 +207,7 @@ static void            ir_function_dump(ir_function*, char *ind, int (*oprintf)(
 static ir_value*       ir_block_create_general_instr(ir_block *self, lex_ctx_t, const char *label,
                                         int op, ir_value *a, ir_value *b, int outype);
 static void            ir_block_delete(ir_block*);
 static ir_value*       ir_block_create_general_instr(ir_block *self, lex_ctx_t, const char *label,
                                         int op, ir_value *a, ir_value *b, int outype);
 static void            ir_block_delete(ir_block*);
-static ir_block*       ir_block_new(struct ir_function_s *owner, const char *label);
+static ir_block*       ir_block_new(ir_function *owner, const char *label);
 static bool GMQCC_WARN ir_block_create_store(ir_block*, lex_ctx_t, ir_value *target, ir_value *what);
 static bool            ir_block_set_label(ir_block*, const char *label);
 static void            ir_block_dump(ir_block*, char *ind, int (*oprintf)(const char*,...));
 static bool GMQCC_WARN ir_block_create_store(ir_block*, lex_ctx_t, ir_value *target, ir_value *what);
 static bool            ir_block_set_label(ir_block*, const char *label);
 static void            ir_block_dump(ir_block*, char *ind, int (*oprintf)(const char*,...));
diff --git a/ir.h b/ir.h
index a767a0dfd7da43ad348a310ddfb7276e1fbd5c87..7f4106ee902eff29a63a17b71b93d254778f3d23 100644 (file)
--- a/ir.h
+++ b/ir.h
@@ -8,11 +8,11 @@
  */
 typedef uint8_t ir_flag_t;
 
  */
 typedef uint8_t ir_flag_t;
 
-typedef struct ir_value_s    ir_value;
-typedef struct ir_instr_s    ir_instr;
-typedef struct ir_block_s    ir_block;
-typedef struct ir_function_s ir_function;
-typedef struct ir_builder_s  ir_builder;
+struct ir_value;
+struct ir_instr;
+struct ir_block;
+struct ir_function;
+struct ir_builder;
 
 typedef struct {
     /* both inclusive */
 
 typedef struct {
     /* both inclusive */
@@ -35,7 +35,7 @@ enum {
     IR_FLAG_MASK_NO_LOCAL_TEMPS  = (IR_FLAG_HAS_ARRAYS | IR_FLAG_HAS_UNINITIALIZED)
 };
 
     IR_FLAG_MASK_NO_LOCAL_TEMPS  = (IR_FLAG_HAS_ARRAYS | IR_FLAG_HAS_UNINITIALIZED)
 };
 
-struct ir_value_s {
+struct ir_value {
     char      *name;
     int        vtype;
     int        store;
     char      *name;
     int        vtype;
     int        store;
@@ -98,32 +98,32 @@ bool            ir_value_lives(ir_value*, size_t);
 void            ir_value_dump_life(const ir_value *self, int (*oprintf)(const char*,...));
 
 /* PHI data */
 void            ir_value_dump_life(const ir_value *self, int (*oprintf)(const char*,...));
 
 /* PHI data */
-typedef struct ir_phi_entry_s {
+struct ir_phi_entry_t {
     ir_value *value;
     ir_block *from;
     ir_value *value;
     ir_block *from;
-} ir_phi_entry_t;
+};
 
 /* instruction */
 
 /* instruction */
-struct ir_instr_s {
-    int        opcode;
-    lex_ctx_t  context;
-    ir_value(_ops[3]);
-    ir_block(bops[2]);
+struct ir_instr {
+    int opcode;
+    lex_ctx_t context;
+    ir_value *(_ops[3]);
+    ir_block *(bops[2]);
 
     ir_phi_entry_t *phi;
 
     ir_phi_entry_t *phi;
-    ir_value      **params;
+    ir_value **params;
 
     /* For the temp-allocation */
     size_t eid;
 
     /* For IFs */
 
     /* For the temp-allocation */
     size_t eid;
 
     /* For IFs */
-    bool   likely;
+    bool likely;
 
     ir_block *owner;
 };
 
 /* block */
 
     ir_block *owner;
 };
 
 /* block */
-struct ir_block_s {
+struct ir_block {
     char      *label;
     lex_ctx_t  context;
     bool       final; /* once a jump is added we're done */
     char      *label;
     lex_ctx_t  context;
     bool       final; /* once a jump is added we're done */
@@ -177,7 +177,7 @@ bool GMQCC_WARN ir_block_create_jump(ir_block*, lex_ctx_t, ir_block *to);
 bool GMQCC_WARN ir_block_create_goto(ir_block*, lex_ctx_t, ir_block *to);
 
 /* function */
 bool GMQCC_WARN ir_block_create_goto(ir_block*, lex_ctx_t, ir_block *to);
 
 /* function */
-struct ir_function_s {
+struct ir_function {
     char      *name;
     int        outtype;
     int       *params;
     char      *name;
     int        outtype;
     int       *params;
@@ -229,7 +229,7 @@ ir_block*       ir_function_create_block(lex_ctx_t ctx, ir_function*, const char
 #define IR_HT_SIZE          1024
 #define IR_MAX_VINSTR_TEMPS 1
 
 #define IR_HT_SIZE          1024
 #define IR_MAX_VINSTR_TEMPS 1
 
-struct ir_builder_s {
+struct ir_builder {
     char *name;
     ir_function **functions;
     ir_value    **globals;
     char *name;
     ir_function **functions;
     ir_value    **globals;
diff --git a/lexer.h b/lexer.h
index 73749dbf10c96be2bffbf47adc094e01af4120ec..dc180f086de368186bd698536f5f530b127e2ba0 100644 (file)
--- a/lexer.h
+++ b/lexer.h
@@ -2,20 +2,15 @@
 #define GMQCC_LEXER_HDR
 #include "gmqcc.h"
 
 #define GMQCC_LEXER_HDR
 #include "gmqcc.h"
 
-typedef struct token_s token;
-
-struct token_s {
+struct token {
     int ttype;
     int ttype;
-
     char *value;
     char *value;
-
     union {
     union {
-        vec3_t    v;
-        int       i;
+        vec3_t v;
+        int i;
         qcfloat_t f;
         qcfloat_t f;
-        int       t; /* type */
+        int t; /* type */
     } constval;
     } constval;
-
     lex_ctx_t ctx;
 };
 
     lex_ctx_t ctx;
 };
 
@@ -66,12 +61,12 @@ enum {
     TOKEN_FATAL /* internal error, eg out of memory */
 };
 
     TOKEN_FATAL /* internal error, eg out of memory */
 };
 
-typedef struct {
+struct frame_macro {
     char *name;
     char *name;
-    int   value;
-} frame_macro;
+    int value;
+};
 
 
-typedef struct lex_file_s {
+struct lex_file {
     FILE  *file;
     const char *open_string;
     size_t      open_string_length;
     FILE  *file;
     const char *open_string;
     size_t      open_string_length;
@@ -101,7 +96,7 @@ typedef struct lex_file_s {
     char *modelname;
 
     size_t push_line;
     char *modelname;
 
     size_t push_line;
-} lex_file;
+};
 
 lex_file* lex_open (const char *file);
 lex_file* lex_open_string(const char *str, size_t len, const char *name);
 
 lex_file* lex_open (const char *file);
 lex_file* lex_open_string(const char *str, size_t len, const char *name);
@@ -121,7 +116,7 @@ enum {
 #define OP_SUFFIX 1
 #define OP_PREFIX 2
 
 #define OP_SUFFIX 1
 #define OP_PREFIX 2
 
-typedef struct {
+struct oper_info {
     const char   *op;
     unsigned int operands;
     unsigned int id;
     const char   *op;
     unsigned int operands;
     unsigned int id;
@@ -129,7 +124,7 @@ typedef struct {
     signed int   prec;
     unsigned int flags;
     bool         folds;
     signed int   prec;
     unsigned int flags;
     bool         folds;
-} oper_info;
+};
 
 /*
  * Explicit uint8_t casts since the left operand of shift operator cannot
 
 /*
  * Explicit uint8_t casts since the left operand of shift operator cannot
index ac715d5b4186bc1d18cff1e6a2b16a154dff1dc3..c0868f8f1502ba8a95a34e1d8f2c7f77b6b29c9a 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -520,8 +520,8 @@ int main(int argc, char **argv) {
     bool            operators_free   = false;
     bool            progs_src        = false;
     FILE       *outfile         = NULL;
     bool            operators_free   = false;
     bool            progs_src        = false;
     FILE       *outfile         = NULL;
-    struct parser_s *parser          = NULL;
-    struct ftepp_s  *ftepp           = NULL;
+    parser_t *parser          = NULL;
+    ftepp_t  *ftepp           = NULL;
 
     app_name = argv[0];
     con_init ();
 
     app_name = argv[0];
     con_init ();
index 43ebe6f0b0e3902c3173e666922a88039abdf0ad..7f07bdf404c5e746bec00091421fe912bbbf617a 100644 (file)
--- a/parser.h
+++ b/parser.h
@@ -4,26 +4,26 @@
 #include "lexer.h"
 #include "ast.h"
 
 #include "lexer.h"
 #include "ast.h"
 
-typedef struct intrin_s intrin_t;
-typedef struct parser_s parser_t;
-
-typedef struct {
-    struct parser_s *parser;
-    ast_value      **imm_float;              /* vector<ast_value*> */
-    ast_value      **imm_vector;             /* vector<ast_value*> */
-    ast_value      **imm_string;             /* vector<ast_value*> */
-    hash_table_t    *imm_string_untranslate; /* map<string, ast_value*> */
-    hash_table_t    *imm_string_dotranslate; /* map<string, ast_value*> */
-} fold_t;
-
-typedef struct {
+struct parser_t;
+struct intrin_t;
+
+struct fold_t {
+    parser_t *parser;
+    ast_value **imm_float;              /* vector<ast_value*> */
+    ast_value **imm_vector;             /* vector<ast_value*> */
+    ast_value **imm_string;             /* vector<ast_value*> */
+    hash_table_t *imm_string_untranslate; /* map<string, ast_value*> */
+    hash_table_t *imm_string_dotranslate; /* map<string, ast_value*> */
+};
+
+struct intrin_func_t {
     ast_expression *(*intrin)(intrin_t *);
     ast_expression *(*intrin)(intrin_t *);
-    const char       *name;
-    const char       *alias;
-    size_t            args;
-} intrin_func_t;
+    const char *name;
+    const char *alias;
+    size_t args;
+};
 
 
-struct intrin_s {
+struct intrin_t {
     intrin_func_t  *intrinsics;              /* vector<intrin_func_t>   */
     ast_expression **generated;              /* vector<ast_expression*> */
     parser_t       *parser;
     intrin_func_t  *intrinsics;              /* vector<intrin_func_t>   */
     ast_expression **generated;              /* vector<ast_expression*> */
     parser_t       *parser;
@@ -32,7 +32,7 @@ struct intrin_s {
 
 #define parser_ctx(p) ((p)->lex->tok.ctx)
 
 
 #define parser_ctx(p) ((p)->lex->tok.ctx)
 
-struct parser_s {
+struct parser_t {
     lex_file *lex;
     int      tok;
 
     lex_file *lex;
     int      tok;