fixed nested unions
This commit is contained in:
parent
49f22e2aff
commit
8f427b5a6d
2 changed files with 28 additions and 0 deletions
|
|
@ -2,3 +2,4 @@
|
||||||
|
|
||||||
%import "hammer/allocator.h"
|
%import "hammer/allocator.h"
|
||||||
%import "hammer/hammer.h"
|
%import "hammer/hammer.h"
|
||||||
|
|
||||||
|
|
|
||||||
27
src/hammer.h
27
src/hammer.h
|
|
@ -70,8 +70,21 @@ typedef struct HBytes_ {
|
||||||
size_t len;
|
size_t len;
|
||||||
} HBytes;
|
} HBytes;
|
||||||
|
|
||||||
|
#ifdef SWIG
|
||||||
|
typedef union {
|
||||||
|
HBytes bytes;
|
||||||
|
int64_t sint;
|
||||||
|
uint64_t uint;
|
||||||
|
double dbl;
|
||||||
|
float flt;
|
||||||
|
HCountedArray *seq;
|
||||||
|
void *user;
|
||||||
|
} HTokenData;
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct HParsedToken_ {
|
typedef struct HParsedToken_ {
|
||||||
HTokenType token_type;
|
HTokenType token_type;
|
||||||
|
#ifndef SWIG
|
||||||
union {
|
union {
|
||||||
HBytes bytes;
|
HBytes bytes;
|
||||||
int64_t sint;
|
int64_t sint;
|
||||||
|
|
@ -81,6 +94,9 @@ typedef struct HParsedToken_ {
|
||||||
HCountedArray *seq; // a sequence of HParsedToken's
|
HCountedArray *seq; // a sequence of HParsedToken's
|
||||||
void *user;
|
void *user;
|
||||||
};
|
};
|
||||||
|
#else
|
||||||
|
HTokenData token_data;
|
||||||
|
#endif
|
||||||
size_t index;
|
size_t index;
|
||||||
char bit_offset;
|
char bit_offset;
|
||||||
} HParsedToken;
|
} HParsedToken;
|
||||||
|
|
@ -144,12 +160,23 @@ typedef struct HParserTestcase_ {
|
||||||
char* output_unambiguous;
|
char* output_unambiguous;
|
||||||
} HParserTestcase;
|
} HParserTestcase;
|
||||||
|
|
||||||
|
#ifdef SWIG
|
||||||
|
typedef union {
|
||||||
|
const char* actual_results;
|
||||||
|
size_t parse_time;
|
||||||
|
} HResultTiming;
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct HCaseResult_ {
|
typedef struct HCaseResult_ {
|
||||||
bool success;
|
bool success;
|
||||||
|
#ifndef SWIG
|
||||||
union {
|
union {
|
||||||
const char* actual_results; // on failure, filled in with the results of h_write_result_unamb
|
const char* actual_results; // on failure, filled in with the results of h_write_result_unamb
|
||||||
size_t parse_time; // on success, filled in with time for a single parse, in nsec
|
size_t parse_time; // on success, filled in with time for a single parse, in nsec
|
||||||
};
|
};
|
||||||
|
#else
|
||||||
|
HResultTiming timestamp;
|
||||||
|
#endif
|
||||||
} HCaseResult;
|
} HCaseResult;
|
||||||
|
|
||||||
typedef struct HBackendResults_ {
|
typedef struct HBackendResults_ {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue