X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Flib%2Fstruct.qh;h=3caf8aaf5717ff3d413e26af362b0aeab7497eba;hb=30626ce6c5cf206210781441d1af567b2bea0e4d;hp=507c417f57afba820771429592d7867267c6ff6c;hpb=c0582a52156c4e74e4c5313e5f360275493a8733;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/lib/struct.qh b/qcsrc/lib/struct.qh index 507c417f5..3caf8aaf5 100644 --- a/qcsrc/lib/struct.qh +++ b/qcsrc/lib/struct.qh @@ -1,35 +1,32 @@ -#ifndef STRUCT_H -#define STRUCT_H +#pragma once #ifndef QCC_SUPPORT_STRUCT - #define _STRUCT_DECLARE(x, id, type, END) noref type x ##_## id ; - #define STRUCT_DECLARE(id, s) s(_STRUCT_DECLARE, id) + #define _STRUCT_DECLARE(x, id, type, END) noref type x##_##id; + #define STRUCT_DECLARE(id, s) s(_STRUCT_DECLARE, id) - #define _STRUCT_PARAM_(x, id, type) type x ##_## id , - #define _STRUCT_PARAM_END(x, id, type) type x ##_## id - #define _STRUCT_PARAM(x, id, type, isend) _STRUCT_PARAM_##isend(x, id, type) - #define STRUCT_PARAM(id, s) s(_STRUCT_PARAM, id) + #define _STRUCT_PARAM_(x, id, type) type x##_##id, + #define _STRUCT_PARAM_END(x, id, type) type x##_##id + #define _STRUCT_PARAM(x, id, type, isend) _STRUCT_PARAM_##isend(x, id, type) + #define STRUCT_PARAM(id, s) s(_STRUCT_PARAM, id) - #define _STRUCT_PASS_(x, id, type) x ##_## id , - #define _STRUCT_PASS_END(x, id, type) x ##_## id - #define _STRUCT_PASS(x, id, type, END) _STRUCT_PASS_##END(x, id, type) - #define STRUCT_PASS(id, s) s(_STRUCT_PASS, id) + #define _STRUCT_PASS_(x, id, type) x##_##id, + #define _STRUCT_PASS_END(x, id, type) x##_##id + #define _STRUCT_PASS(x, id, type, END) _STRUCT_PASS_##END(x, id, type) + #define STRUCT_PASS(id, s) s(_STRUCT_PASS, id) - #define _STRUCT_STORE_DST(_, it) it - #define _STRUCT_STORE_SRC(it, _) it - #define _CONCAT3_(a, b, c) a ## b ## c - #define _CONCAT3(a, b, c) _CONCAT3_(a, b, c) - #define _STRUCT_STORE(x, id, type, END) _CONCAT3(_STRUCT_STORE_DST x, _, id) = _CONCAT3(_STRUCT_STORE_SRC x, _, id); - #define STRUCT_STORE(from, to, s) s(_STRUCT_STORE, (from, to)) + #define _STRUCT_STORE_DST(_, it) it + #define _STRUCT_STORE_SRC(it, _) it + #define _CONCAT3_(a, b, c) a##b##c + #define _CONCAT3(a, b, c) _CONCAT3_(a, b, c) + #define _STRUCT_STORE(x, id, type, END) _CONCAT3(_STRUCT_STORE_DST x, _, id) = _CONCAT3(_STRUCT_STORE_SRC x, _, id); + #define STRUCT_STORE(from, to, s) s(_STRUCT_STORE, (from, to)) - #define STRUCT(id, ...) + #define STRUCT(id, ...) #else - #define STRUCT_DECLARE(id, type) type id; - #define STRUCT_PARAM(id, type) type id - #define STRUCT_PASS(id, type) id - #define STRUCT_STORE(from, to, s) to = from - #define _STRUCT_MEMBER(my, id, type, END) type id; - #define STRUCT(id, s) struct STRUCT_##id { s(_STRUCT_MEMBER, ) }; -#endif - + #define STRUCT_DECLARE(id, type) type id; + #define STRUCT_PARAM(id, type) type id + #define STRUCT_PASS(id, type) id + #define STRUCT_STORE(from, to, s) to = from + #define _STRUCT_MEMBER(my, id, type, END) type id; + #define STRUCT(id, s) struct STRUCT_##id { s(_STRUCT_MEMBER, ) }; #endif