#ifndef __HYDROFORTH__RESULT_H__ #define __HYDROFORTH__RESULT_H__ typedef enum HYDROFORTH__RESULT__ERROR { OK = 0, ERR_UNKNOWN, ERR_INVALID_HEX_CHAR, ERR_UNKNOWN_SINGLE_CHAR_WORD, ERR_UNKNOWN_WORD, ERR_UNTERMINATED_WORD_DEFINITION, ERR_WORD_NAME_CANT_BE_NUMBER, ERR_WORD_DEF_INSIDE_WORD_DEF, } HYDROFORTH__RESULT__ERROR; typedef HYDROFORTH__RESULT__ERROR HYDROFORTH__ERROR; typedef struct HYDROFORTH__RESULT__RESULT { HYDROFORTH__ERROR error; const char **backtrace; unsigned short backtrace_len; } HYDROFORTH__RESULT__RESULT; typedef HYDROFORTH__RESULT__RESULT HYDROFORTH__RESULT; extern void hydroforth__result__add_backtrace(HYDROFORTH__RESULT *const result, const char *const s); extern void hydroforth__result__set(HYDROFORTH__RESULT *const result, HYDROFORTH__ERROR error, const char *const s); extern const char *hydroforth__result__get_error_message(HYDROFORTH__ERROR error); #define hydroforth__set_func_result(result, error) hydroforth__result__set(result, error, __func__); #define hydroforth__add_func_backtrace(result) hydroforth__result__add_backtrace(result, __func__); extern int hydroforth__result__unwrap(HYDROFORTH__RESULT *const result, int code); typedef struct __HYDROFORTH__RESULT { void (*add_backtrace)(HYDROFORTH__RESULT *const result, const char *const s); void (*set)(HYDROFORTH__RESULT *const result, HYDROFORTH__ERROR error, const char *const s); const char *(*get_error_message)(HYDROFORTH__ERROR error); int (*unwrap)(HYDROFORTH__RESULT *const result, int code); } __HYDROFORTH__RESULT; #endif