From ecd855279d0984b3c0191ce1e60f0b4690af2f39 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 24 Feb 2009 10:36:34 -0800 Subject: Removed CALLBACK() macro and struct of callbacks. --- pbstream.c | 10 +++------- pbstream.h | 11 ++++------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/pbstream.c b/pbstream.c index 2046ec7..5994b9c 100644 --- a/pbstream.c +++ b/pbstream.c @@ -243,14 +243,10 @@ static pbstream_status_t parse_unknown_value( return PBSTREAM_STATUS_OK; } -#define CALLBACK(s, func, ...) do { \ - if(s->callbacks.func) s->callbacks.func(__VA_ARGS__); \ - } while (0) - #define NONFATAL_ERROR(s, code) do { \ - if(s->ignore_nonfatal_errors) CALLBACK(s, error_callback, code); \ - else return code; \ - } while (0) + if(s->ignore_nonfatal_errors) { \ + if(s->error_callback) s->error_callback(s, code); \ + } else return code; } while (0) static struct pbstream_field_descriptor *find_field_descriptor( struct pbstream_message_descriptor* md, diff --git a/pbstream.h b/pbstream.h index a8e623a..36658c5 100644 --- a/pbstream.h +++ b/pbstream.h @@ -168,11 +168,9 @@ typedef enum pbstream_status { // A field was encoded with the wrong wire type. PBSTREAM_ERROR_MISMATCHED_TYPE, } pbstream_status_t; -typedef void (*pbstream_error_callback_t)(pbstream_status_t error); - -struct pbstream_callbacks { - pbstream_error_callback_t error_callback; -}; +struct pbstream_parse_state; +typedef void (*pbstream_error_callback_t)(struct pbstream_parse_state *s, + pbstream_status_t error); struct pbstream_parse_stack_frame { struct pbstream_message_descriptor *message_descriptor; @@ -184,7 +182,7 @@ struct pbstream_parse_stack_frame { /* The stream parser's state. */ struct pbstream_parse_state { - struct pbstream_callbacks callbacks; + pbstream_error_callback_t error_callback; size_t offset; bool ignore_nonfatal_errors; void *user_data; @@ -197,7 +195,6 @@ struct pbstream_parse_state { void pbstream_init_parser( struct pbstream_parse_state *state, struct pbstream_message_descriptor *message_descriptor, - struct pbstream_callbacks *callbacks, void *user_data); /* Call this to parse as much of buf as possible, calling callbacks as -- cgit v1.2.3