libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_result.h
Go to the documentation of this file.
1/*! \file
2 * \brief GBL_RESULT values, stringifiers, and utilities
3 * \ingroup core
4 *
5 * \author Falco Girgis
6 */
7
8#ifndef GIMBAL_RESULT_H
9#define GIMBAL_RESULT_H
10
11#include "gimbal_decls.h"
12
14
15#define GBL_META_RESULT_TABLE (
16 ( GBL_RESULT, Result, "C API Return Status Code", gblResultString),
17 (
18 (GBL_RESULT_UNKNOWN, 0x0, Unknown, "Unknown"),
19 (GBL_RESULT_SUCCESS, 0x1, Success, "Success"),
20 (GBL_RESULT_EVENT_IGNORED, 0x2, EventIgnored, "Event Ignored"),
21 (GBL_RESULT_EVENT_ACCEPTED, 0x3, EventAccepted, "Event Accepted"),
22 (GBL_RESULT_PARTIAL, 0xa, Partial, "Generic Partial Success"),
23 (GBL_RESULT_TRUNCATED, GBL_RESULT_PARTIAL + 1, Truncated, "Truncated"),
24 (GBL_RESULT_LOSSY_CONVERSION, GBL_RESULT_PARTIAL + 2, LossyConversion, "Lossy Conversion"),
25 (GBL_RESULT_TIMEOUT, GBL_RESULT_PARTIAL + 3, Timeout, "Timeout"),
26 (GBL_RESULT_NOT_READY, GBL_RESULT_PARTIAL + 4, NotReady, "Not Ready"),
27 (GBL_RESULT_NOT_FOUND, GBL_RESULT_PARTIAL + 5, NotFound, "Not Found"),
28 (GBL_RESULT_INCOMPLETE, GBL_RESULT_PARTIAL + 6, Incomplete, "Incomplete"),
29 (GBL_RESULT_UNIMPLEMENTED, GBL_RESULT_PARTIAL + 7, Unimplemented, "Unimplemented"),
30 (GBL_RESULT_UNSUPPORTED, GBL_RESULT_PARTIAL + 8, Unsupported, "Unsupported"),
31 (GBL_RESULT_VERSION_MISMATCH, GBL_RESULT_PARTIAL + 9, VersionMismatch, "Version Mismatch"),
32 (GBL_RESULT_SKIPPED, GBL_RESULT_PARTIAL + 10,Skipped, "Skipped"),
33 (GBL_RESULT_ERROR, 0xbad00000, Error, "Generic Error"),
34 (GBL_RESULT_ERROR_UNHANDLED_EXCEPTION, GBL_RESULT_ERROR | 1, ErrorUnhandledException, "Unhandled Exception"),
35 (GBL_RESULT_ERROR_INTERNAL, GBL_RESULT_ERROR | 2, ErrorInternal, "Internal Error"),
36 (GBL_RESULT_ERROR_TYPE_MISMATCH, GBL_RESULT_ERROR | 3, ErrorTypeMismatch, "Type Mismatch"),
37 (GBL_RESULT_ERROR_INVALID_VARIANT_ACCESS, GBL_RESULT_ERROR | 4, ErrorInvalidVariantAccess, "Invalid Variant Access"),
38 (GBL_RESULT_ERROR_UNDERFLOW, GBL_RESULT_ERROR | 5, ErrorUnderflow, "Underflow"),
39 (GBL_RESULT_ERROR_OVERFLOW, GBL_RESULT_ERROR | 6, ErrorOverflow, "Overflow"),
40 (GBL_RESULT_ERROR_OUT_OF_RANGE, GBL_RESULT_ERROR | 7, ErrorOutOfRange, "Out of Range"),
41 (GBL_RESULT_ERROR_INVALID_HANDLE, GBL_RESULT_ERROR | 8, ErrorInvalidHandle, "Invalid Handle"),
42 (GBL_RESULT_ERROR_INVALID_POINTER, GBL_RESULT_ERROR | 9, ErrorInvalidPointer, "Invalid Pointer"),
43 (GBL_RESULT_ERROR_INVALID_ARG, GBL_RESULT_ERROR | 10, ErrorInvalidArg, "Invalid Argument"),
44 (GBL_RESULT_ERROR_INVALID_CMDLINE_ARG, GBL_RESULT_ERROR | 11, ErrorInvalidCmdLineArg, "Invalid CmdLine Argument"),
45 (GBL_RESULT_ERROR_INVALID_EXPRESSION, GBL_RESULT_ERROR | 12, ErrorInvalidExpression, "Invalid Expression"),
46 (GBL_RESULT_ERROR_INVALID_OPERATION, GBL_RESULT_ERROR | 13, ErrorInvalidOperation, "Invalid Operation"),
47 (GBL_RESULT_ERROR_INVALID_CONVERSION, GBL_RESULT_ERROR | 14, ErrorInvalidConversion, "Invalid Conversion"),
48 (GBL_RESULT_ERROR_INVALID_VIRTUAL_CALL, GBL_RESULT_ERROR | 15, ErrorInvalidVirtualCall, "Invalid Virtual Function Called"),
49 (GBL_RESULT_ERROR_INVALID_KEY, GBL_RESULT_ERROR | 16, ErrorInvalidKey, "Invalid Key"),
50 (GBL_RESULT_ERROR_INVALID_PROPERTY, GBL_RESULT_ERROR | 17, ErrorInvalidProperty, "Invalid Property"),
51 (GBL_RESULT_ERROR_INVALID_INSTANCE, GBL_RESULT_ERROR | 18, ErrorInvalidInstance, "Invalid Instance"),
52 (GBL_RESULT_ERROR_INVALID_CLASS, GBL_RESULT_ERROR | 19, ErrorInvalidClass, "Invalid Class"),
53 (GBL_RESULT_ERROR_INVALID_TYPE, GBL_RESULT_ERROR | 20, ErrorInvalidType, "Invalid Type"),
54 (GBL_RESULT_ERROR_INVALID_DATE_TIME, GBL_RESULT_ERROR | 21, ErrorInvalidDateTime, "Invalid Date/Time"),
55 (GBL_RESULT_ERROR_INVALID_THREAD, GBL_RESULT_ERROR | 22, ErrorInvalidThread, "Invalid Thread"),
56 (GBL_RESULT_ERROR_INVALID_TOKEN, GBL_RESULT_ERROR | 23, ErrorInvalidToken, "Invalid Token"),
57 (GBL_RESULT_ERROR_MEM_ALLOC, GBL_RESULT_ERROR | 24, ErrorMemAlloc, "Memory Allocation Failed"),
58 (GBL_RESULT_ERROR_MEM_REALLOC, GBL_RESULT_ERROR | 25, ErrorMemRealloc, "Memory Reallocation Failed"),
59 (GBL_RESULT_ERROR_MEM_FREE, GBL_RESULT_ERROR | 26, ErrorMemFree, "Memory Free Failed"),
60 (GBL_RESULT_ERROR_FILE_OPEN, GBL_RESULT_ERROR | 27, ErrorFileOpen, "Failed to Open File Descriptor"),
61 (GBL_RESULT_ERROR_FILE_CLOSE, GBL_RESULT_ERROR | 28, ErrorFileClose, "Failed to Close File Descriptor"),
62 (GBL_RESULT_ERROR_FILE_READ, GBL_RESULT_ERROR | 29, ErrorFileRead, "Failed to Read from File Descriptor"),
63 (GBL_RESULT_ERROR_FILE_WRITE, GBL_RESULT_ERROR | 30, ErrorFileWrite, "Failed to Write to File Descriptor"),
64 (GBL_RESULT_COUNT, GBL_RESULT_ERROR | 31, Count, "# of Different Error Codes")
65 )
66 )
67
69
70#define GBL_RESULT_UNKNOWN(value)
71 ((GBL_RESULT)value == GBL_RESULT_UNKNOWN)
72
73#define GBL_RESULT_SUCCESS(value)
74 ((GBL_RESULT)value == GBL_RESULT_SUCCESS || (GBL_RESULT)value == GBL_RESULT_EVENT_IGNORED || (GBL_RESULT)value == GBL_RESULT_EVENT_ACCEPTED)
75
76#define GBL_RESULT_PARTIAL(value)
77 (!(GBL_RESULT_SUCCESS(value) || GBL_RESULT_ERROR(value) || GBL_RESULT_UNKNOWN(value)))
78
79#define GBL_RESULT_UNAVAILABLE(value)
80 ((GBL_RESULT)value == GBL_RESULT_UNIMPLEMENTED || (GBL_RESULT)value == GBL_RESULT_UNSUPPORTED || (GBL_RESULT)value == GBL_RESULT_VERSION_MISMATCH)
81
82#define GBL_RESULT_ERROR(value)
83 ((GBL_RESULT)((value) & 0xfff00000) == GBL_RESULT_ERROR)
84
85#define GBL_RESULT_ISSUE(value)
86 (!GBL_RESULT_SUCCESS(value))
87
89
90#endif // GIMBAL_RESULT_H
#define GBL_DECLS_BEGIN
#define GBL_ENUM_TABLE_DECLARE(table)
#define GBL_RESULT_PARTIAL(value)
#define GBL_RESULT_ERROR(value)
#define GBL_META_RESULT_TABLE
#define GBL_RESULT_SUCCESS(value)
#define GBL_RESULT_UNKNOWN(value)