From 70807ed22b4c34db247fd8fc1ca1c776dd27ab4c Mon Sep 17 00:00:00 2001 From: Timerix22 Date: Wed, 24 May 2023 02:39:19 +0600 Subject: [PATCH] added on_exit arg to tryLast() --- src/base/errors.h | 2 +- src/base/type_system/unitype.h | 4 ++++ src/kprint/kprint.c | 4 ++-- tests/test_dtsod.c | 8 ++++---- tests/test_safethrow.c | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/base/errors.h b/src/base/errors.h index 07b8569..a0e228a 100644 --- a/src/base/errors.h +++ b/src/base/errors.h @@ -80,7 +80,7 @@ char* __unknownErr( ); } #endif -#define tryLast(_funcCall, _rezult) Maybe _rezult=_funcCall; if(_rezult.errmsg){ \ +#define tryLast(_funcCall, _rezult, ON_EXIT) Maybe _rezult=_funcCall; if(_rezult.errmsg){ \ _rezult.errmsg=__extendErrMsg(_rezult.errmsg, __FILE__,__LINE__,__func__); \ __EXIT(_rezult.errmsg); \ } diff --git a/src/base/type_system/unitype.h b/src/base/type_system/unitype.h index aeb2372..1fef31f 100644 --- a/src/base/type_system/unitype.h +++ b/src/base/type_system/unitype.h @@ -40,6 +40,10 @@ STRUCT(Unitype, #define Unitype_isUniNull(UNI) (UNI.typeId==0 && UNI.Int64==0) +#define UniCheckTypeId(UNI, TYPE_ID) (UNI.typeId==TYPE_ID) +#define UniCheckType(UNI, TYPE) UniCheckTypeId(UNI, ktid_name(TYPE)) +#define UniCheckTypePtr(UNI, TYPE) UniCheckTypeId(UNI, ktid_ptrName(TYPE)) + // frees VoidPtr value or does nothing if type isn't pointer void Unitype_free(Unitype u); void __UnitypePtr_free(void* u); diff --git a/src/kprint/kprint.c b/src/kprint/kprint.c index c1e68e6..f90af51 100644 --- a/src/kprint/kprint.c +++ b/src/kprint/kprint.c @@ -71,12 +71,12 @@ Maybe __kfprint(FILE* file, u8 n, kp_fmt* formats, __kp_value_union* objects){ } void __kprint(u8 n, kp_fmt* formats, __kp_value_union* objects){ - tryLast(check_argsN(n), _); + tryLast(check_argsN(n), _,;); n/=2; for(u8 i=0; i