Skip to content

Commit f60c79b

Browse files
committed
fix enum reader
1 parent 4c73ec0 commit f60c79b

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

app/src/metadata_reader.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,13 @@ parser_error_t read_enum_variant(parser_context_t *ctx, enum_variant_t *variant)
289289
CHECK_ERROR(read_u8(ctx, (uint8_t*)&variant->discriminant));
290290
printf("discriminant: %d\n", variant->discriminant);
291291

292-
//TODO: check why is this byte here
293-
uint8_t unknown = 0;
294-
CHECK_ERROR(read_u8(ctx, &unknown));
295-
printf("unknown: %d\n", unknown);
296-
297-
//read value
298-
CHECK_ERROR(read_link(ctx, &variant->value));
292+
//read has_value
293+
CHECK_ERROR(read_u8(ctx, (uint8_t*)&variant->has_value));
294+
printf("has_value: %d\n", variant->has_value);
295+
if (variant->has_value) {
296+
//read value
297+
CHECK_ERROR(read_link(ctx, &variant->value));
298+
}
299299

300300
return parser_ok;
301301
}
@@ -530,7 +530,7 @@ parser_error_t metadata_read(parser_context_t *ctx, parser_tx_t *txObj) {
530530
}
531531

532532
// TODO: go through all schemes
533-
for (uint32_t i = 0; i < 36; i++) {
533+
for (uint32_t i = 0; i < txObj->schema.types.qty; i++) {
534534
// read type
535535
CHECK_ERROR(read_u8(ctx, (uint8_t*)&txObj->schema.types.schemes[i].type));
536536
switch (txObj->schema.types.schemes[i].type) {

app/src/parser_txdef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ typedef struct {
189189
typedef struct {
190190
bytes_t name;
191191
uint8_t discriminant;
192+
bool has_value;
192193
link_t value;
193194
} enum_variant_t;
194195

0 commit comments

Comments
 (0)