diff options
author | Josh Haberman <haberman@google.com> | 2013-02-15 16:27:18 -0800 |
---|---|---|
committer | Josh Haberman <haberman@google.com> | 2013-02-15 16:27:18 -0800 |
commit | 7d3e2bd2c4cfd1296d1d6f996d7548de26540d41 (patch) | |
tree | b4b35967b3322c65cfb1a32220e8718de09d85fc /benchmarks | |
parent | ea198bdcf947ba4bd51474bdd4f7b82b5e4cf41d (diff) |
Sync with 8 months of Google-internal development.
Many things have changed and been simplified.
The memory-management story for upb_def and upb_handlers
is much more robust; upb_def and upb_handlers should be
fairly stable interfaces now. There is still much work
to do for the runtime component (upb_sink).
Diffstat (limited to 'benchmarks')
-rw-r--r-- | benchmarks/parsestream.upb.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/benchmarks/parsestream.upb.c b/benchmarks/parsestream.upb.c index 781b97a..b5a353c 100644 --- a/benchmarks/parsestream.upb.c +++ b/benchmarks/parsestream.upb.c @@ -27,11 +27,16 @@ static upb_flow_t value(void *closure, upb_value fval, upb_value val) { return UPB_CONTINUE; } +void onfreg(void *c, upb_fhandlers *fh, const upb_fielddef *f) { + upb_fhandlers_setvalue(fh, &value); + upb_fhandlers_setstartsubmsg(fh, &startsubmsg); +} + static bool initialize() { // Initialize upb state, decode descriptor. upb_status status = UPB_STATUS_INIT; - upb_symtab *s = upb_symtab_new(&s); + upb_symtab *s = upb_symtab_new(); upb_load_descriptor_file_into_symtab(s, MESSAGE_DESCRIPTOR_FILE, &status); if(!upb_ok(&status)) { fprintf(stderr, "Error reading descriptor: %s\n", @@ -44,7 +49,7 @@ static bool initialize() fprintf(stderr, "Error finding symbol '%s'.\n", MESSAGE_NAME); return false; } - upb_symtab_unref(s, &s); + upb_symtab_unref(s); // Read the message data itself. input_str = upb_readfile(MESSAGE_FILE, &input_len); @@ -55,8 +60,7 @@ static bool initialize() upb_handlers *handlers = upb_handlers_new(); // Cause all messages to be read, but do nothing when they are. - upb_handlerset hset = {NULL, NULL, value, startsubmsg, NULL, NULL, NULL}; - upb_handlers_reghandlerset(handlers, def, &hset); + upb_handlers_regmsgdef(handlers, def, NULL, &upb_onfreg_hset, NULL); upb_decoder_init(&decoder); plan = upb_decoderplan_new(handlers, JIT); upb_decoder_resetplan(&decoder, plan, 0); |