better architecture with unions
This commit is contained in:
parent
b5419a1a26
commit
3ea872d744
20
engine/slc.h
20
engine/slc.h
@ -107,6 +107,12 @@ enum SLC_IO_OP {
|
|||||||
};
|
};
|
||||||
typedef enum SLC_IO_OP SLC_IO_OP;
|
typedef enum SLC_IO_OP SLC_IO_OP;
|
||||||
|
|
||||||
|
union symptr {
|
||||||
|
uint32_t *varp;
|
||||||
|
wordstart *worp;
|
||||||
|
};
|
||||||
|
typedef union symptr symptr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function-abstraction for a "symbol-table".
|
* Function-abstraction for a "symbol-table".
|
||||||
*
|
*
|
||||||
@ -123,8 +129,7 @@ typedef enum SLC_IO_OP SLC_IO_OP;
|
|||||||
* @param ptr When adding a found word/variable to the symbol table, the key will point to this wordstart* or uint32_t*
|
* @param ptr When adding a found word/variable to the symbol table, the key will point to this wordstart* or uint32_t*
|
||||||
* @returns The word/var definition stored for the key, or NULL when it is not stored yet or op is SET and there was an error.
|
* @returns The word/var definition stored for the key, or NULL when it is not stored yet or op is SET and there was an error.
|
||||||
*/
|
*/
|
||||||
typedef void* (*sym)(SLC_SYM_OP op, char *key, void *ptr);
|
typedef symptr (*sym)(SLC_SYM_OP op, char *key, symptr ptr);
|
||||||
// TODO: union for this?
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function-abstraction for an integer "stack".
|
* Function-abstraction for an integer "stack".
|
||||||
@ -161,6 +166,14 @@ typedef uint32_t (*stack)(SLC_STACK_OP op, uint32_t param);
|
|||||||
*/
|
*/
|
||||||
typedef uint32_t (*session)(SLC_SESSION_OP op, uint32_t i, uint32_t j);
|
typedef uint32_t (*session)(SLC_SESSION_OP op, uint32_t i, uint32_t j);
|
||||||
|
|
||||||
|
union iores {
|
||||||
|
/** Either the cmd result or the handle pointer*/
|
||||||
|
const char *ptr;
|
||||||
|
/** The read character */
|
||||||
|
char c;
|
||||||
|
};
|
||||||
|
typedef union iores iores;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function-abstraction for io connectors.
|
* Function-abstraction for io connectors.
|
||||||
*
|
*
|
||||||
@ -180,8 +193,7 @@ typedef uint32_t (*session)(SLC_SESSION_OP op, uint32_t i, uint32_t j);
|
|||||||
* @param param The name or temporary name or command or the handle pointer parameter depending on op.
|
* @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.
|
* @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)(SLC_IO_OP op, const char *param);
|
typedef iores (*ioconn)(SLC_IO_OP op, const char *param);
|
||||||
// TODO: union for this?
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function-abstraction for reading the source code byte-by-byte.
|
* Function-abstraction for reading the source code byte-by-byte.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user