PACK_ENUM
This commit is contained in:
parent
169165ac5a
commit
31c7d4e31b
@ -13,7 +13,7 @@ Array_declare(FilePath);
|
|||||||
typedef FILE File;
|
typedef FILE File;
|
||||||
ktid_declare(File);
|
ktid_declare(File);
|
||||||
|
|
||||||
typedef enum FileOpenMode{
|
PACK_ENUM(FileOpenMode,
|
||||||
// open a file for reading
|
// open a file for reading
|
||||||
FileOpenMode_Read=1,
|
FileOpenMode_Read=1,
|
||||||
// (re)create a file for writing
|
// (re)create a file for writing
|
||||||
@ -24,7 +24,7 @@ typedef enum FileOpenMode{
|
|||||||
FileOpenMode_ReadWrite=FileOpenMode_Read|FileOpenMode_Write,
|
FileOpenMode_ReadWrite=FileOpenMode_Read|FileOpenMode_Write,
|
||||||
// opens file for readng/writing additional data to the end / creates new file
|
// opens file for readng/writing additional data to the end / creates new file
|
||||||
FileOpenMode_ReadAppend=FileOpenMode_Read|FileOpenMode_Append
|
FileOpenMode_ReadAppend=FileOpenMode_Read|FileOpenMode_Append
|
||||||
} FileOpenMode;
|
)
|
||||||
|
|
||||||
|
|
||||||
/// @brief opens file
|
/// @brief opens file
|
||||||
|
|||||||
@ -7,13 +7,13 @@ extern "C" {
|
|||||||
#include "std.h"
|
#include "std.h"
|
||||||
#include "type_system/unitype.h"
|
#include "type_system/unitype.h"
|
||||||
|
|
||||||
typedef enum ErrorId {
|
PACK_ENUM(ErrorId,
|
||||||
SUCCESS, // not an error
|
SUCCESS, // not an error
|
||||||
ERR_MAXLENGTH, ERR_WRONGTYPE, ERR_WRONGINDEX,
|
ERR_MAXLENGTH, ERR_WRONGTYPE, ERR_WRONGINDEX,
|
||||||
ERR_NOTIMPLEMENTED, ERR_NULLPTR, ERR_ENDOFSTR,
|
ERR_NOTIMPLEMENTED, ERR_NULLPTR, ERR_ENDOFSTR,
|
||||||
ERR_KEYNOTFOUND, ERR_FORMAT, ERR_UNEXPECTEDVAL,
|
ERR_KEYNOTFOUND, ERR_FORMAT, ERR_UNEXPECTEDVAL,
|
||||||
ERR_IO, ERR_IO_EOF
|
ERR_IO, ERR_IO_EOF
|
||||||
} ErrorId;
|
)
|
||||||
|
|
||||||
char* errname(ErrorId err);
|
char* errname(ErrorId err);
|
||||||
|
|
||||||
|
|||||||
@ -118,6 +118,10 @@ You can even embed it into macro in header (see kprint.h)
|
|||||||
CODE;\
|
CODE;\
|
||||||
PRAGMA_WARNING_POP
|
PRAGMA_WARNING_POP
|
||||||
|
|
||||||
|
#define PACK_ENUM(ENUM_NAME, ENUM_MEMBERS...) typedef enum ENUM_NAME {\
|
||||||
|
ENUM_MEMBERS\
|
||||||
|
} __attribute__((__packed__)) ENUM_NAME;
|
||||||
|
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -8,7 +8,7 @@ extern "C" {
|
|||||||
// ^ ^^^^
|
// ^ ^^^^
|
||||||
// | color num
|
// | color num
|
||||||
// fgColorSet flag
|
// fgColorSet flag
|
||||||
typedef enum kp_fgColor{
|
PACK_ENUM(kp_fgColor,
|
||||||
/// black foreground
|
/// black foreground
|
||||||
kp_fgBlack = 0x80000000,
|
kp_fgBlack = 0x80000000,
|
||||||
/// dark red foreground
|
/// dark red foreground
|
||||||
@ -41,12 +41,12 @@ typedef enum kp_fgColor{
|
|||||||
kp_fgCyan = 0x8e000000,
|
kp_fgCyan = 0x8e000000,
|
||||||
/// white foreground
|
/// white foreground
|
||||||
kp_fgWhite = 0x8f000000
|
kp_fgWhite = 0x8f000000
|
||||||
} kp_fgColor;
|
)
|
||||||
|
|
||||||
// 01000000 00000000 00000000 00000000
|
// 01000000 00000000 00000000 00000000
|
||||||
// ^ ^^^^
|
// ^ ^^^^
|
||||||
// bgColorSet flag color num
|
// bgColorSet flag color num
|
||||||
typedef enum kp_bgColor{
|
PACK_ENUM(kp_bgColor,
|
||||||
/// black background
|
/// black background
|
||||||
kp_bgBlack = 0x40000000,
|
kp_bgBlack = 0x40000000,
|
||||||
/// dark red background
|
/// dark red background
|
||||||
@ -79,7 +79,7 @@ typedef enum kp_bgColor{
|
|||||||
kp_bgCyan = 0x40e00000,
|
kp_bgCyan = 0x40e00000,
|
||||||
/// white background
|
/// white background
|
||||||
kp_bgWhite = 0x40f00000
|
kp_bgWhite = 0x40f00000
|
||||||
} kp_bgColor;
|
)
|
||||||
|
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ extern "C" {
|
|||||||
/// kprint_format
|
/// kprint_format
|
||||||
typedef uint32 kp_fmt;
|
typedef uint32 kp_fmt;
|
||||||
|
|
||||||
typedef enum kp_dataFmt{
|
PACK_ENUM(kp_dataFmt,
|
||||||
// 00000000 00000000 00000000 00000000
|
// 00000000 00000000 00000000 00000000
|
||||||
// ^^^^
|
// ^^^^
|
||||||
// type
|
// type
|
||||||
@ -32,7 +32,7 @@ typedef enum kp_dataFmt{
|
|||||||
// ^
|
// ^
|
||||||
// uppercase flag
|
// uppercase flag
|
||||||
kp_upper=0x10000000
|
kp_upper=0x10000000
|
||||||
} kp_dataFmt;
|
)
|
||||||
|
|
||||||
#define kp_fmt_fgColorSet(FMT) (bool)((FMT&0x80000000)!=0)
|
#define kp_fmt_fgColorSet(FMT) (bool)((FMT&0x80000000)!=0)
|
||||||
#define kp_fmt_bgColorSet(FMT) (bool)((FMT&0x40000000)!=0)
|
#define kp_fmt_bgColorSet(FMT) (bool)((FMT&0x40000000)!=0)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user