better enums - more like our struct typedefs

This commit is contained in:
Richard Thier 2024-09-14 13:00:43 +02:00
parent 4107f42b53
commit 87164e7a65

View File

@ -14,8 +14,11 @@ struct wordstart {
typedef struct wordstart wordstart;
enum SLC_SYM_OP { SLC_SYM_SET, SLC_SYM_GET, SLC_SYM_ERASE };
typedef enum SLC_SYM_OP SLC_SYM_OP;
enum SLC_STACK_OP { SLC_STACK_PUSH, SLC_STACK_POP, SLC_STACK_AT, SLC_STACK_COUNT, SLC_STACK_ERASE };
typedef enum SLC_STACK_OP SLC_STACK_OP;
enum SLC_SESSION_OP { SLC_SESSION_ALLOC, SLC_SESSION_ERASE, SLC_SESSION_GET };
typedef enum SLC_SESSION_OP SLC_SESSION_OP;
enum SLC_IO_OP {
SLC_IO_OPEN,
SLC_IO_OPEN_TMP,
@ -27,6 +30,7 @@ enum SLC_IO_OP {
SLC_IO_UNLOCK,
SLC_IO_CMD,
};
typedef enum SLC_IO_OP SLC_IO_OP;
/**
* Function-abstraction for a "symbol-table".
@ -42,7 +46,7 @@ enum SLC_IO_OP {
* @param word When adding a found word to the symbol table, the key will point to this word
* @returns The word definition stored for the key, or NULL when it is not stored yet or op is SET and there was an error.
*/
typedef wordstart* (*sym)(enum SLC_SYM_OP op, char *key, wordstart *word);
typedef wordstart* (*sym)(SLC_SYM_OP op, char *key, wordstart *word);
/**
* Function-abstraction for an integer "stack".
@ -59,7 +63,7 @@ typedef wordstart* (*sym)(enum SLC_SYM_OP op, char *key, wordstart *word);
* @param param On SLC_STACK_PUSH, this is the element to push onto the stack, in case of SLC_STACK_AT, its the index.
* @return The element at the given stack location in case of SLC_STACK_AT or the count in case of SLC_STACK_COUNT. Can show error!
*/
typedef uint32_t (*stack)(enum SLC_STACK_OP op, uint32_t param);
typedef uint32_t (*stack)(SLC_STACK_OP op, uint32_t param);
/**
* Function-abstraction for an integer "session-storage".
@ -73,7 +77,7 @@ typedef uint32_t (*stack)(enum SLC_STACK_OP op, uint32_t param);
* @param i Used on SESSION_GET and is the accessor index
* @returns The accessor index in case of ALLOC (0xFFFFFFFF == -1 means error), on get it returns the store BYTE as uint32_t
*/
typedef uint32_t (*session)(enum SLC_SESSION_OP op, uint32_t i);
typedef uint32_t (*session)(SLC_SESSION_OP op, uint32_t i);
/**
* Function-abstraction for io connectors.
@ -94,7 +98,7 @@ typedef uint32_t (*session)(enum SLC_SESSION_OP op, uint32_t i);
* @param param The name or temporary name or command or the handle pointer parameter depending on op.
* @returns A handle pointer or pointer to character to read / written or closed/unlocked handle (NULL on errors). Also cmd stdout.
*/
typedef const char* (*ioconn)(enum SLC_IO_OP op, const char *param);
typedef const char* (*ioconn)(SLC_IO_OP op, const char *param);
/**
* This function runs the main slc engine over a snippet of code.