diff options
author | Jari Vetoniemi <mailroxas@gmail.com> | 2017-04-20 16:49:35 +0300 |
---|---|---|
committer | Jari Vetoniemi <mailroxas@gmail.com> | 2017-05-01 22:58:22 +0300 |
commit | 29086b1d12a2c28cffdbfbf0b3990a7bd75506b9 (patch) | |
tree | 8acd48bc30932812744c0adb102d7a7add494357 /src/fspec/bcode.h | |
parent | 76b8c9e03c97b16d9ff97f3b79c0ecbff0f5e7f2 (diff) |
work in progress
Diffstat (limited to 'src/fspec/bcode.h')
-rw-r--r-- | src/fspec/bcode.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/fspec/bcode.h b/src/fspec/bcode.h new file mode 100644 index 0000000..d84060e --- /dev/null +++ b/src/fspec/bcode.h @@ -0,0 +1,64 @@ +#pragma once + +#include <fspec/memory.h> + +#include <inttypes.h> +#include <stdint.h> +#include <stdbool.h> + +/** maximum range of numbers */ +#define PRI_FSPEC_NUM PRIu64 +typedef uint64_t fspec_num; + +enum fspec_arg { + FSPEC_ARG_DAT, + FSPEC_ARG_OFF, + FSPEC_ARG_NUM, + FSPEC_ARG_VAR, + FSPEC_ARG_STR, + FSPEC_ARG_EOF, + FSPEC_ARG_LAST, +} __attribute__((packed)); + +void +fspec_arg_get_mem(const enum fspec_arg *arg, const void *data, struct fspec_mem *out_mem); + +fspec_num +fspec_arg_get_num(const enum fspec_arg *arg); + +const char* +fspec_arg_get_cstr(const enum fspec_arg *arg, const void *data); + +const enum fspec_arg* +fspec_arg_next(const enum fspec_arg *arg, const void *end, const uint8_t nth, const uint32_t expect); + +enum fspec_declaration { + FSPEC_DECLARATION_STRUCT, + FSPEC_DECLARATION_MEMBER, + FSPEC_DECLARATION_LAST, +} __attribute__((packed)); + +enum fspec_visual { + FSPEC_VISUAL_NUL, + FSPEC_VISUAL_DEC, + FSPEC_VISUAL_HEX, + FSPEC_VISUAL_STR, + FSPEC_VISUAL_LAST, +} __attribute__((packed)); + +enum fspec_op { + FSPEC_OP_ARG, + FSPEC_OP_HEADER, + FSPEC_OP_DECLARATION, + FSPEC_OP_READ, + FSPEC_OP_GOTO, + FSPEC_OP_FILTER, + FSPEC_OP_VISUAL, + FSPEC_OP_LAST, +} __attribute__((packed)); + +const enum fspec_op* +fspec_op_next(const enum fspec_op *op, const void *end, const bool skip_args); + +const enum fspec_arg* +fspec_op_get_arg(const enum fspec_op *op, const void *end, const uint8_t nth, const uint32_t expect); |