separated errinf to errbinf and erruinf
This commit is contained in:
parent
0efc4f8344
commit
0380496460
31
lib/err.c
31
lib/err.c
@ -287,11 +287,40 @@ void hawk_rtx_errortohawk (hawk_rtx_t* rtx, hawk_t* hawk)
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
void hawk_gem_geterrinf (hawk_gem_t* gem, hawk_errinf_t* errinf)
|
||||
void hawk_gem_geterrbinf (hawk_gem_t* gem, hawk_errbinf_t* errinf)
|
||||
{
|
||||
#if defined(HAWK_OOCH_IS_BCH)
|
||||
errinf->num = gem->errnum;
|
||||
errinf->loc = gem->errloc;
|
||||
hawk_copy_oocstr (errinf->msg, HAWK_COUNTOF(errinf->msg), (gem->errmsg[0] == '\0'? gem->errstr(gem->errnum): gem->errmsg));
|
||||
#else
|
||||
const hawk_ooch_t* msg;
|
||||
hawk_oow_t wcslen, mbslen;
|
||||
|
||||
errinf->num = gem->errnum;
|
||||
errinf->loc = gem->errloc;
|
||||
msg = (gem->errmsg[0] == '\0')? gem->errstr(gem->errnum): gem->errmsg;
|
||||
|
||||
mbslen = HAWK_COUNTOF(errinf->msg);
|
||||
hawk_conv_ucstr_to_bcstr_with_cmgr (msg, &wcslen, errinf->msg, &mbslen, gem->cmgr);
|
||||
#endif
|
||||
}
|
||||
|
||||
void hawk_gem_geterruinf (hawk_gem_t* gem, hawk_erruinf_t* errinf)
|
||||
{
|
||||
#if defined(HAWK_OOCH_IS_BCH)
|
||||
const hawk_ooch_t* msg;
|
||||
hawk_oow_t wcslen, mbslen;
|
||||
|
||||
msg = (gem->errmsg[0] == '\0')? gem->errstr(gem->errnum): gem->errmsg;
|
||||
|
||||
wcslen = HAWK_COUNTOF(errinf->msg);
|
||||
hawk_conv_bcstr_to_ucstr_with_cmgr (msg, &mbslen, errinf->msg, &wcslen, gem->cmgr, 1);
|
||||
#else
|
||||
errinf->num = gem->errnum;
|
||||
errinf->loc = gem->errloc;
|
||||
hawk_copy_oocstr (errinf->msg, HAWK_COUNTOF(errinf->msg), (gem->errmsg[0] == '\0'? gem->errstr(gem->errnum): gem->errmsg));
|
||||
#endif
|
||||
}
|
||||
|
||||
void hawk_gem_geterror (hawk_gem_t* gem, hawk_errnum_t* errnum, const hawk_ooch_t** errmsg, hawk_loc_t* errloc)
|
||||
|
@ -1086,14 +1086,27 @@ typedef struct hawk_loc_t hawk_loc_t;
|
||||
/**
|
||||
* The hawk_errinf_t type defines a placeholder for error information.
|
||||
*/
|
||||
struct hawk_errinf_t
|
||||
struct hawk_errbinf_t
|
||||
{
|
||||
hawk_errnum_t num; /**< error number */
|
||||
hawk_ooch_t msg[HAWK_ERRMSG_CAPA]; /**< error message */
|
||||
hawk_bch_t msg[HAWK_ERRMSG_CAPA]; /**< error message */
|
||||
hawk_loc_t loc; /**< error location */
|
||||
};
|
||||
typedef struct hawk_errinf_t hawk_errinf_t;
|
||||
typedef struct hawk_errbinf_t hawk_errbinf_t;
|
||||
|
||||
struct hawk_erruinf_t
|
||||
{
|
||||
hawk_errnum_t num; /**< error number */
|
||||
hawk_uch_t msg[HAWK_ERRMSG_CAPA]; /**< error message */
|
||||
hawk_loc_t loc; /**< error location */
|
||||
};
|
||||
typedef struct hawk_erruinf_t hawk_erruinf_t;
|
||||
|
||||
#if defined(HAWK_OOCH_IS_BCH)
|
||||
typedef hawk_errbinf_t hawk_errinf_t;
|
||||
#else
|
||||
typedef hawk_erruinf_t hawk_errinf_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The hawk_errstr_t type defines an error string getter. It should return
|
||||
|
@ -439,11 +439,6 @@ static HAWK_INLINE const hawk_loc_t* hawk_gem_geterrloc (hawk_gem_t* gem) { retu
|
||||
#define hawk_gem_geterrloc(gem) (&((hawk_gem_t*)(gem))->errloc)
|
||||
#endif
|
||||
|
||||
HAWK_EXPORT void hawk_gem_geterrinf (
|
||||
hawk_gem_t* gem,
|
||||
hawk_errinf_t* errinf
|
||||
);
|
||||
|
||||
HAWK_EXPORT void hawk_gem_geterror (
|
||||
hawk_gem_t* gem,
|
||||
hawk_errnum_t* errnum,
|
||||
@ -451,6 +446,16 @@ HAWK_EXPORT void hawk_gem_geterror (
|
||||
hawk_loc_t* errloc
|
||||
);
|
||||
|
||||
HAWK_EXPORT void hawk_gem_geterrbinf (
|
||||
hawk_gem_t* gem,
|
||||
hawk_errbinf_t* errinf
|
||||
);
|
||||
|
||||
HAWK_EXPORT void hawk_gem_geterruinf (
|
||||
hawk_gem_t* gem,
|
||||
hawk_erruinf_t* errinf
|
||||
);
|
||||
|
||||
HAWK_EXPORT const hawk_bch_t* hawk_gem_geterrbmsg (
|
||||
hawk_gem_t* gem
|
||||
);
|
||||
@ -460,8 +465,10 @@ HAWK_EXPORT const hawk_uch_t* hawk_gem_geterrumsg (
|
||||
);
|
||||
|
||||
#if defined(HAWK_OOCH_IS_BCH)
|
||||
# define hawk_gem_geterrinf hawk_gem_geterrbinf
|
||||
# define hawk_gem_geterrmsg hawk_gem_geterrbmsg
|
||||
#else
|
||||
# define hawk_gem_geterrinf hawk_gem_geterruinf
|
||||
# define hawk_gem_geterrmsg hawk_gem_geterrumsg
|
||||
#endif
|
||||
|
||||
|
@ -557,21 +557,25 @@ static HAWK_INLINE hawk_errnum_t hawk_sed_geterrnum (hawk_sed_t* sed) { return h
|
||||
static HAWK_INLINE const hawk_loc_t* hawk_sed_geterrloc (hawk_sed_t* sed) { return hawk_gem_geterrloc(hawk_sed_getgem(sed)); }
|
||||
static HAWK_INLINE const hawk_bch_t* hawk_sed_geterrbmsg (hawk_sed_t* sed) { return hawk_gem_geterrbmsg(hawk_sed_getgem(sed)); }
|
||||
static HAWK_INLINE const hawk_uch_t* hawk_sed_geterrumsg (hawk_sed_t* sed) { return hawk_gem_geterrumsg(hawk_sed_getgem(sed)); }
|
||||
static HAWK_INLINE void hawk_sed_geterrinf (hawk_sed_t* sed, hawk_errinf_t* errinf) { return hawk_gem_geterrinf(hawk_sed_getgem(sed), errinf); }
|
||||
static HAWK_INLINE void hawk_sed_geterrbinf (hawk_sed_t* sed, hawk_errbinf_t* errinf) { return hawk_gem_geterrbinf(hawk_sed_getgem(sed), errinf); }
|
||||
static HAWK_INLINE void hawk_sed_geterruinf (hawk_sed_t* sed, hawk_erruinf_t* errinf) { return hawk_gem_geterruinf(hawk_sed_getgem(sed), errinf); }
|
||||
static HAWK_INLINE void hawk_sed_geterror (hawk_sed_t* sed, hawk_errnum_t* errnum, const hawk_ooch_t** errmsg, hawk_loc_t* errloc) { return hawk_gem_geterror(hawk_sed_getgem(sed), errnum, errmsg, errloc); }
|
||||
#else
|
||||
#define hawk_sed_geterrnum(sed) hawk_gem_geterrnum(hawk_sed_getgem(sed))
|
||||
#define hawk_sed_geterrloc(sed) hawk_gem_geterrloc(hawk_sed_getgem(sed))
|
||||
#define hawk_sed_geterrbmsg(sed) hawk_gem_geterrbmsg(hawk_sed_getgem(sed))
|
||||
#define hawk_sed_geterrumsg(sed) hawk_gem_geterrumsg(hawk_sed_getgem(sed))
|
||||
#define hawk_sed_geterrinf(sed, errinf) (hawk_gem_geterrinf(hawk_sed_getgem(sed), errinf))
|
||||
#define hawk_sed_geterrbinf(sed, errinf) (hawk_gem_geterrbinf(hawk_sed_getgem(sed), errinf))
|
||||
#define hawk_sed_geterruinf(sed, errinf) (hawk_gem_geterruinf(hawk_sed_getgem(sed), errinf))
|
||||
#define hawk_sed_geterror(sed, errnum, errmsg, errloc) (hawk_gem_geterror(hawk_sed_getgem(sed), errnum, errmsg, errloc))
|
||||
#endif
|
||||
|
||||
#if defined(HAWK_OOCH_IS_BCH)
|
||||
# define hawk_sed_geterrmsg hawk_sed_geterrbmsg
|
||||
# define hawk_sed_geterrinf hawk_sed_geterrbinf
|
||||
#else
|
||||
# define hawk_sed_geterrmsg hawk_sed_geterrumsg
|
||||
# define hawk_sed_geterrinf hawk_sed_geterruinf
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1622,19 +1622,23 @@ static HAWK_INLINE hawk_errnum_t hawk_geterrnum (hawk_t* hawk) { return ((hawk_a
|
||||
static HAWK_INLINE const hawk_loc_t* hawk_geterrloc (hawk_t* hawk) { return hawk_gem_geterrloc(hawk_getgem(hawk)); }
|
||||
static HAWK_INLINE const hawk_bch_t* hawk_geterrbmsg (hawk_t* hawk) { return hawk_gem_geterrbmsg(hawk_getgem(hawk)); }
|
||||
static HAWK_INLINE const hawk_uch_t* hawk_geterrumsg (hawk_t* hawk) { return hawk_gem_geterrumsg(hawk_getgem(hawk)); }
|
||||
static HAWK_INLINE void hawk_geterrinf (hawk_t* hawk, hawk_errinf_t* errinf) { return hawk_gem_geterrinf(hawk_getgem(hawk), errinf); }
|
||||
static HAWK_INLINE void hawk_geterrbinf (hawk_t* hawk, hawk_errbinf_t* errinf) { return hawk_gem_geterrbinf(hawk_getgem(hawk), errinf); }
|
||||
static HAWK_INLINE void hawk_geterruinf (hawk_t* hawk, hawk_erruinf_t* errinf) { return hawk_gem_geterruinf(hawk_getgem(hawk), errinf); }
|
||||
#else
|
||||
#define hawk_geterrnum(hawk) (((hawk_alt_t*)(hawk))->_gem.errnum)
|
||||
#define hawk_geterrloc(hawk) (hawk_gem_geterrloc(hawk_getgem(hawk)))
|
||||
#define hawk_geterrbmsg(hawk) (hawk_gem_geterrbmsg(hawk_getgem(hawk)))
|
||||
#define hawk_geterrumsg(hawk) (hawk_gem_geterrumsg(hawk_getgem(hawk)))
|
||||
#define hawk_geterrinf(hawk, errinf) (hawk_gem_geterrinf(hawk_getgem(hawk), errinf))
|
||||
#define hawk_geterrbinf(hawk, errinf) (hawk_gem_geterrbinf(hawk_getgem(hawk), errinf))
|
||||
#define hawk_geterruinf(hawk, errinf) (hawk_gem_geterruinf(hawk_getgem(hawk), errinf))
|
||||
#endif
|
||||
|
||||
#if defined(HAWK_OOCH_IS_BCH)
|
||||
# define hawk_geterrmsg hawk_geterrbmsg
|
||||
# define hawk_geterrinf hawk_geterrbinf
|
||||
#else
|
||||
# define hawk_geterrmsg hawk_geterrumsg
|
||||
# define hawk_geterrinf hawk_geterruinf
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user