Result status codes#
This project adopts widely used convention of returning integer encoded status codes as function results.
Each function, that needs to notify it’s execution status (success or error),
returns lsp_status_t (alias for lsp_int8_t).
Available status codes are:
LSP_SUCCESSExecution successful.
LSP_EOFEnd of file encountered during reading/writing.
LSP_ERRGeneric error (unknown error).
LSP_ERR_MEMMemory error (usually out of memory).
LSP_ERR_CTXContext error (usually symbol resolution error).
LSP_ERR_READReader error.
LSP_ERR_WRITEWriter error.
LSP_ERR_EVALEvaluation error.
LSP_ERR_APPLYApplication error.
LSP_ERR_ARG_COUNTInvalid argument count.
LSP_ERR_ARG_TYPEInvalid argument type.
LSP_ERR_ARG_VALUEInvalid argument value.
LSP_ERR_USERSpecial status value representing beginning of user status codes.
User has ability to raise user error with error builtin function. This
error is additionally described with integer value in range [0, 126] and
encoded as status code.
Source code#
status.h#
#ifndef LSP_STATUS_H
#define LSP_STATUS_H
#include "arch.h"
#define LSP_STATUS(x) ((lsp_status_t)x)
#define LSP_SUCCESS LSP_STATUS(0)
#define LSP_EOF LSP_STATUS(-1)
#define LSP_ERR LSP_STATUS(1)
#define LSP_ERR_MEM LSP_STATUS(2)
#define LSP_ERR_CTX LSP_STATUS(3)
#define LSP_ERR_READ LSP_STATUS(4)
#define LSP_ERR_WRITE LSP_STATUS(5)
#define LSP_ERR_EVAL LSP_STATUS(6)
#define LSP_ERR_APPLY LSP_STATUS(7)
#define LSP_ERR_ARG_COUNT LSP_STATUS(8)
#define LSP_ERR_ARG_TYPE LSP_STATUS(9)
#define LSP_ERR_ARG_VALUE LSP_STATUS(10)
#define LSP_ERR_USER LSP_STATUS(0x80)
typedef lsp_int8_t lsp_status_t;
#endif