32bit operations for session storage + rethinking ownership of char* names for symbol table storage (now it is up to the symbol table and we let it be invalidated)
This commit is contained in:
parent
ac3d9f41c6
commit
967960d9bc
13
engine/slc.h
13
engine/slc.h
@ -144,6 +144,8 @@ enum SLC_SESSION_OP {
|
||||
SLC_SESSION_PUSH,
|
||||
SLC_SESSION_GET,
|
||||
SLC_SESSION_SET,
|
||||
SLC_SESSION_GET32,
|
||||
SLC_SESSION_SET32,
|
||||
SLC_SESSION_PROCESS
|
||||
};
|
||||
typedef enum SLC_SESSION_OP SLC_SESSION_OP;
|
||||
@ -166,6 +168,11 @@ union symptr {
|
||||
};
|
||||
typedef union symptr symptr;
|
||||
|
||||
struct slc_tmp_charptr {
|
||||
char *ptr;
|
||||
};
|
||||
typedef struct slc_tmp_charptr slc_tmp_charptr;
|
||||
|
||||
/**
|
||||
* Function-abstraction for a "symbol-table".
|
||||
*
|
||||
@ -178,11 +185,11 @@ typedef union symptr symptr;
|
||||
* Rem.: On GET we return a word* in case the key is to a word and a regular uint32_t* if its a variable name!
|
||||
*
|
||||
* @param op Defines which operation the caller wants.
|
||||
* @param key The key (both for SET and GET)
|
||||
* @param key The key (both for SET and GET). This pointer can get easily invalidated so you might need a copy on SET.
|
||||
* @param ptr When adding a found word/variable to the symbol table, the key will point to this word* 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.
|
||||
*/
|
||||
typedef symptr (*sym)(SLC_SYM_OP op, char *key, symptr ptr);
|
||||
typedef symptr (*sym)(SLC_SYM_OP op, slc_tmp_charptr key, symptr ptr);
|
||||
|
||||
/**
|
||||
* Function-abstraction for an integer "stack".
|
||||
@ -210,6 +217,8 @@ typedef uint32_t (*stack)(SLC_STACK_OP op, uint32_t param);
|
||||
* SLC_SESSION_PUSH adds the given byte (value in i) to the end of the session storage (by growing it) - j unused
|
||||
* SLC_SESSION_GET gets byte at the ith accessor index - j unused
|
||||
* SLC_SESSION_SET gets byte at the ith accessor index to be of (byte)j
|
||||
* SLC_SESSION_GET32 gets uint32_t at the ith accessor index - j unused. XXX: Beware, architectures unaligned access crash!
|
||||
* SLC_SESSION_SET32 gets uint32_t at the ith accessor index to be of j. XXX: Beware, architectures unaligned access crash!
|
||||
* SLC_SESSION_PROCESS gets the last j bytes and moves them overriding bytes at index i, then "shrinks" the storage by j.
|
||||
*
|
||||
* @param op Defines which operation the caller wants.
|
||||
|
Loading…
x
Reference in New Issue
Block a user