X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=gmqcc.h;h=10b74f5ab2741e92ff9421fc7a3d8bc2ac888244;hp=88cf7ff21831336c15f1d6d87515af82176fb6f6;hb=031f827da5457ed969bbf66e520105f9600a1229;hpb=90b5a6538a10f60d08ee3059b8f70e4e076dc30d diff --git a/gmqcc.h b/gmqcc.h index 88cf7ff..10b74f5 100644 --- a/gmqcc.h +++ b/gmqcc.h @@ -589,12 +589,28 @@ extern size_t compile_errors; extern size_t compile_Werrors; extern size_t compile_warnings; -void /********/ compile_error (lex_ctx_t ctx, /*LVL_ERROR*/ const char *msg, ...); +void /********/ compile_error_ (lex_ctx_t ctx, /*LVL_ERROR*/ const char *msg, ...); void /********/ vcompile_error (lex_ctx_t ctx, /*LVL_ERROR*/ const char *msg, va_list ap); -bool GMQCC_WARN compile_warning (lex_ctx_t ctx, int warntype, const char *fmt, ...); +bool GMQCC_WARN compile_warning_(lex_ctx_t ctx, int warntype, const char *fmt, ...); bool GMQCC_WARN vcompile_warning(lex_ctx_t ctx, int warntype, const char *fmt, va_list ap); void compile_show_werrors(void); +template +inline constexpr const T formatNormalize(const T argument) { return argument; } + +inline const char *formatNormalize(const std::string &argument) { + return argument.c_str(); +} + +template +inline bool GMQCC_WARN compile_warning(lex_ctx_t ctx, int warntype, const char *fmt, const Ts&... ts) { + return compile_warning_(ctx, warntype, fmt, formatNormalize(ts)...); +} +template +inline void /********/ compile_error (lex_ctx_t ctx, /*LVL_ERROR*/ const char *msg, const Ts&... ts) { + return compile_error_(ctx, msg, formatNormalize(ts)...); +} + /* ir.c */ /* TODO: cleanup */ enum store_type { @@ -644,7 +660,7 @@ enum { #define VMXF_TRACE 0x0001 /* trace: print statements before executing */ #define VMXF_PROFILE 0x0002 /* profile: increment the profile counters */ -struct qc_program_t; +typedef struct qc_program qc_program_t; typedef int (*prog_builtin_t)(qc_program_t *prog); struct qc_exec_stack_t { @@ -653,18 +669,21 @@ struct qc_exec_stack_t { prog_section_function_t *function; }; -struct qc_program_t { - char *filename; +struct qc_program { + qc_program() = delete; + qc_program(const char *name, uint16_t crc, size_t entfields); + + std::string filename; std::vector code; std::vector defs; std::vector fields; std::vector functions; std::vector strings; std::vector globals; - qcint_t *entitydata; - bool *entitypool; + std::vector entitydata; + std::vector entitypool; - const char* *function_stack; + std::vector function_stack; uint16_t crc16; @@ -673,7 +692,7 @@ struct qc_program_t { qcint_t vmerror; - size_t *profile; + std::vector profile; prog_builtin_t *builtins; size_t builtins_count; @@ -683,8 +702,8 @@ struct qc_program_t { size_t entityfields; bool allowworldwrites; - qcint_t *localstack; - qc_exec_stack_t *stack; + std::vector localstack; + std::vector stack; size_t statement; size_t xflags; @@ -722,7 +741,6 @@ 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 */ struct ftepp_t;