KinoSearch
view release on metacpan or search on metacpan
core/KinoSearch/Object/Err.cfh view on Meta::CPAN
/** Invoke host warning mechanism. Clean up the supplied message by
* decrementing its refcount.
*
* @param message Error message, to be output verbatim.
*/
inert void
warn_mess(decremented CharBuf *message);
/** Create a formatted error message. Ususally invoked via the MAKE_MESS
* macro.
*/
inert CharBuf*
make_mess(const char *file, int line, const char *func,
const char *pattern, ...);
/** Verify that <code>obj</code> is either NULL or inherits from
* the class represented by <code>vtable</code>.
*
* @return the object.
*/
inert nullable Obj*
downcast(Obj *obj, VTable *vtable, const char *file, int line,
const char *func);
/** Verify that <code>obj</code> is not NULL and inherits from the class
* represented by <code>vtable</code>.
*
* @return the object.
*/
inert Obj*
certify(Obj *obj, VTable *vtable, const char *file, int line,
const char *func);
/** Verify that an object belongs to a subclass and not an abstract class.
*/
inert inline void
abstract_class_check(Obj *obj, VTable *vtable);
/** On Windows, return a newly allocated buffer containing the string
* description for the the last error in the thread.
*/
inert char*
win_error();
}
__C__
#ifdef CHY_HAS_FUNC_MACRO
#define CFISH_ERR_FUNC_MACRO CHY_FUNC_MACRO
#else
#define CFISH_ERR_FUNC_MACRO NULL
#endif
#define CFISH_ERR_ADD_FRAME(_error) \
Kino_Err_Add_Frame(_error, __FILE__, __LINE__, \
CFISH_ERR_FUNC_MACRO)
#define CFISH_RETHROW(_error) \
kino_Err_rethrow((kino_Err*)_error, __FILE__, __LINE__, \
CFISH_ERR_FUNC_MACRO)
/** Macro version of kino_Err_throw_at which inserts contextual information
* automatically, provided that the compiler supports the necessary features.
*/
#ifdef CHY_HAS_VARIADIC_MACROS
#ifdef CHY_HAS_ISO_VARIADIC_MACROS
#define CFISH_THROW(_vtable, ...) \
kino_Err_throw_at(_vtable, __FILE__, __LINE__, CFISH_ERR_FUNC_MACRO, \
__VA_ARGS__)
#define CFISH_WARN(...) \
kino_Err_warn_at(__FILE__, __LINE__, CFISH_ERR_FUNC_MACRO, __VA_ARGS__)
#define CFISH_MAKE_MESS(...) \
kino_Err_make_mess(__FILE__, __LINE__, CFISH_ERR_FUNC_MACRO, \
__VA_ARGS__)
#elif defined(CHY_HAS_GNUC_VARIADIC_MACROS)
#define CFISH_THROW(_vtable, args...) \
kino_Err_throw_at(_vtable, __FILE__, __LINE__, \
CFISH_ERR_FUNC_MACRO, ##args)
#define CFISH_WARN(args...) \
kino_Err_warn_at(__FILE__, __LINE__, CFISH_ERR_FUNC_MACRO, ##args)
#define CFISH_MAKE_MESS(args...) \
kino_Err_make_mess(__FILE__, __LINE__, CFISH_ERR_FUNC_MACRO, ##args)
#endif
#else
void
CFISH_THROW(kino_VTable *vtable, char* format, ...);
void
CFISH_WARN(char* format, ...);
void
CFISH_MAKE_MESS(char* format, ...);
#endif
#define CFISH_DOWNCAST(_obj, _vtable) \
kino_Err_downcast((kino_Obj*)(_obj), (_vtable), \
__FILE__, __LINE__, CFISH_ERR_FUNC_MACRO)
#define CFISH_CERTIFY(_obj, _vtable) \
kino_Err_certify((kino_Obj*)(_obj), (_vtable), \
__FILE__, __LINE__, CFISH_ERR_FUNC_MACRO)
static CHY_INLINE void
kino_Err_abstract_class_check(kino_Obj *obj, kino_VTable *vtable)
{
kino_VTable *const my_vtable = *(kino_VTable**)obj;
if (my_vtable == vtable) {
kino_CharBuf *mess = CFISH_MAKE_MESS("%o is an abstract class",
Kino_Obj_Get_Class_Name(obj));
Kino_Obj_Dec_RefCount(obj);
kino_Err_throw_mess(KINO_ERR, mess);
}
}
#define CFISH_ABSTRACT_CLASS_CHECK(_obj, _vtable) \
kino_Err_abstract_class_check(((kino_Obj*)_obj), _vtable)
#ifdef KINO_USE_SHORT_NAMES
#define THROW CFISH_THROW
#define RETHROW CFISH_RETHROW
#define WARN CFISH_WARN
#define MAKE_MESS CFISH_MAKE_MESS
#define ERR_ADD_FRAME CFISH_ERR_ADD_FRAME
( run in 0.456 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )