From cb65b3794af4b47c3551b0943c9a76d463380ea7 Mon Sep 17 00:00:00 2001 From: trillian Date: Sun, 28 Jan 2024 00:42:21 +0200 Subject: [PATCH] fix(?) msvc, update documentation generator --- docs/newbook/parse_warnings.py | 4 ++-- src/asar/errors.h | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/newbook/parse_warnings.py b/docs/newbook/parse_warnings.py index fc5e1a3f..3f62fa4b 100644 --- a/docs/newbook/parse_warnings.py +++ b/docs/newbook/parse_warnings.py @@ -4,7 +4,7 @@ import string warning_pattern = re.compile(r'WRN\((.*?)\),\s*"(.*)"\s*,?\s*(true|false)?\s*}') -error_pattern = re.compile(r'ERR\((.*?)\),\s*"(.*)"\s*}') +error_pattern = re.compile(r'ERR\((.*?),\s*"(.*)"\)\s*\\') escaping = str.maketrans({x: '\\'+x for x in string.punctuation}) def escape(s): @@ -14,7 +14,7 @@ def escape(s): def get_errors(): yield "| Error name | Message |" yield "| ---------- | ------- |" - with open("../../src/asar/errors.cpp") as f: + with open("../../src/asar/errors.h") as f: for line in f: if 'ERR(' in line and not line.startswith('#define'): name, description = re.findall(error_pattern, line)[0] diff --git a/src/asar/errors.h b/src/asar/errors.h index 0dfeefd7..b2971ef0 100644 --- a/src/asar/errors.h +++ b/src/asar/errors.h @@ -225,10 +225,12 @@ struct errblock : public errline {}; struct errnull : public errblock {}; #ifdef __clang__ -// let's see if this causes msvc to explode... +// okay so this ## thing isn't very nice of me, but it works on all compilers +// for now. i'll refactor all use sites of asar_throw_error at some point so i +// can do a different hack to always pass at least 1 variadic argument #pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments" #endif [[gnu::format(printf, 4, 5)]] void asar_throw_error_impl(int whichpass, asar_error_type type, asar_error_id errid, const char* fmt, ...); -#define asar_throw_error(whichpass, type, errid, ...) asar_throw_error_impl(whichpass, type, errid, get_error_fmt(errid) __VA_OPT__(,) __VA_ARGS__) +#define asar_throw_error(whichpass, type, errid, ...) asar_throw_error_impl(whichpass, type, errid, get_error_fmt(errid), ## __VA_ARGS__) const char* get_error_name(asar_error_id errid);