From 7d3e2bd2c4cfd1296d1d6f996d7548de26540d41 Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Fri, 15 Feb 2013 16:27:18 -0800 Subject: 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). --- benchmarks/parsestream.upb.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'benchmarks/parsestream.upb.c') 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); -- cgit v1.2.3