diff options
author | Joshua Haberman <joshua@reverberate.org> | 2010-01-11 19:54:46 -0800 |
---|---|---|
committer | Joshua Haberman <joshua@reverberate.org> | 2010-01-11 19:54:46 -0800 |
commit | b05205d224020d45d2a69978732758703f0eb7cf (patch) | |
tree | b57cdd3771a2086f478502ea08c87e0890116bf9 /benchmarks | |
parent | 527c0945000315ed8589436d2807bd5f8ad7a543 (diff) |
Defined upb_sink interface and ported the parser to it.
Diffstat (limited to 'benchmarks')
-rw-r--r-- | benchmarks/parsetostruct.upb_table.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/benchmarks/parsetostruct.upb_table.c b/benchmarks/parsetostruct.upb_table.c index e387de6..7614b30 100644 --- a/benchmarks/parsetostruct.upb_table.c +++ b/benchmarks/parsetostruct.upb_table.c @@ -3,12 +3,14 @@ #include "upb_data.h" #include "upb_def.h" +#include "upb_parse.h" static struct upb_symtab *s; static upb_strptr str; static struct upb_msgdef *def; static upb_msg *msgs[NUM_MESSAGES]; -static struct upb_msgparser *mp; +static upb_parser *parser; +static upb_msgsink *sink; static bool initialize() { @@ -47,7 +49,8 @@ static bool initialize() fprintf(stderr, "Error reading " MESSAGE_FILE "\n"); return false; } - mp = upb_msgparser_new(def); + parser = upb_parser_new(def); + sink = upb_msgsink_new(def); return true; } @@ -57,17 +60,19 @@ static void cleanup() upb_msg_unref(msgs[i], def); upb_string_unref(str); upb_symtab_unref(s); - upb_msgparser_free(mp); + upb_parser_free(parser); + upb_msgsink_free(sink); } static size_t run(int i) { struct upb_status status = UPB_STATUS_INIT; upb_msg *msg = msgs[i%NUM_MESSAGES]; - upb_msgparser_reset(mp, msg); + upb_msgsink_reset(sink, msg); + upb_parser_reset(parser, upb_msgsink_sink(sink)); upb_msg_clear(msg, def); - upb_msgparser_parse(mp, str, &status); - if(!upb_ok(&status)) { + size_t parsed = upb_parser_parse(parser, str, &status); + if(!upb_ok(&status) || parsed != upb_strlen(str)) { fprintf(stderr, "Parse error: %s\n", status.msg); return 0; } |