From 7ab504c8bcba97afe07bb58587689c005ec69c4c Mon Sep 17 00:00:00 2001 From: dzaima Date: Sun, 1 May 2022 01:53:45 +0300 Subject: [PATCH] =?UTF-8?q?unified=20int=20&=20char=20cases=20for=20?= =?UTF-8?q?=E2=8A=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/arrFns.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/core/arrFns.h b/src/core/arrFns.h index 1a2e2757..5c9e3513 100644 --- a/src/core/arrFns.h +++ b/src/core/arrFns.h @@ -20,17 +20,19 @@ static void* tyany_ptr(B x) { return IS_SLICE(t)? c(TySlice,x)->a : c(TyArr,x)->a; } -#define M_TYARR(OVER, MID, RV) { \ +#define M_TYARR(OVER, MID, RV, PRE) { PRE \ Arr* r = m_arr(TYARR_SZW(w, ia) OVER, type, ia); \ MID \ *rp = RV; \ return ((TyArr*)r)->a; \ } // width in bytes for m_tyarr*; overalloc is a byte count -static void* m_tyarrp (Arr** rp, usz w, usz ia, u8 type ) M_TYARR( , , r) -static void* m_tyarrpO(Arr** rp, usz w, usz ia, u8 type, usz over) M_TYARR(+over, , r) -static void* m_tyarrv (B* rp, usz w, usz ia, u8 type ) M_TYARR( , arr_shVec((Arr*)r);, taga(r)) -static void* m_tyarrvO(B* rp, usz w, usz ia, u8 type, usz over) M_TYARR(+over, arr_shVec((Arr*)r);, taga(r)) +static void* m_tyarrp (Arr** rp, usz w, usz ia, u8 type ) M_TYARR( , , r, ) +static void* m_tyarrpO(Arr** rp, usz w, usz ia, u8 type, usz over) M_TYARR(+over, , r, ) +static void* m_tyarrv (B* rp, usz w, usz ia, u8 type ) M_TYARR( , arr_shVec((Arr*)r);, taga(r), ) +static void* m_tyarrvO(B* rp, usz w, usz ia, u8 type, usz over) M_TYARR(+over, arr_shVec((Arr*)r);, taga(r), ) +static void* m_tyarrc (B* rp, usz w, B x, u8 type ) M_TYARR( , arr_shCopy((Arr*)r,x);, taga(r), usz ia = a(x)->ia;) +static void* m_tyarrcO(B* rp, usz w, B x, u8 type, usz over) M_TYARR(+over, arr_shCopy((Arr*)r,x);, taga(r), usz ia = a(x)->ia;) extern u8 elType2type[]; #define el2t(X) elType2type[X] // TODO maybe reorganize array types such that this can just be addition? \ No newline at end of file