summaryrefslogtreecommitdiff
path: root/src/upb_msg.h
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2011-05-19 10:56:34 -0700
committerJoshua Haberman <joshua@reverberate.org>2011-05-19 10:56:34 -0700
commitd619852e06983dc30d2070f6c4af32d563b101f2 (patch)
treeaad6f6c1e2221ec2f0703fab2a842022156fa520 /src/upb_msg.h
parenta5506318aa6f815f8c9439de99247463ad8883e0 (diff)
Change dispatcher error handling model.
Now the dispatcher will call error handlers instaed of returning statuses that the caller has to constantly check.
Diffstat (limited to 'src/upb_msg.h')
-rw-r--r--src/upb_msg.h37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/upb_msg.h b/src/upb_msg.h
index 33f5d1c..a0b2ad2 100644
--- a/src/upb_msg.h
+++ b/src/upb_msg.h
@@ -169,7 +169,6 @@ INLINE void upb_array_unref(upb_array *a, upb_fielddef *f) {
}
void upb_array_recycle(upb_array **arr);
-
INLINE uint32_t upb_array_len(upb_array *a) {
return a->len;
}
@@ -279,8 +278,40 @@ INLINE void upb_msg_clear(upb_msg *msg, upb_msgdef *md) {
// The upb_msg itself must be passed as the param to the src.
upb_mhandlers *upb_msg_reghandlers(upb_handlers *h, upb_msgdef *md);
-void upb_msg_runhandlers(upb_msg *msg, upb_msgdef *md, upb_handlers *h,
- void *closure, upb_status *status);
+
+/* upb_msgvisitor *************************************************************/
+
+// Calls a set of upb_handlers with the contents of a upb_msg.
+typedef struct {
+ upb_fhandlers *fh;
+ upb_fielddef *f;
+ uint16_t msgindex; // Only when upb_issubmsg(f).
+} upb_msgvisitor_field;
+
+typedef struct {
+ upb_msgvisitor_field *fields;
+ int fields_len;
+} upb_msgvisitor_msg;
+
+typedef struct {
+ uint16_t msgindex;
+ uint16_t fieldindex;
+ uint32_t arrayindex; // UINT32_MAX if not an array frame.
+} upb_msgvisitor_frame;
+
+typedef struct {
+ upb_msgvisitor_msg *messages;
+ int messages_len;
+ upb_dispatcher dispatcher;
+} upb_msgvisitor;
+
+// Initializes a msgvisitor that will push data from messages of the given
+// msgdef to the given set of handlers.
+void upb_msgvisitor_init(upb_msgvisitor *v, upb_msgdef *md, upb_handlers *h);
+void upb_msgvisitor_uninit(upb_msgvisitor *v);
+
+void upb_msgvisitor_reset(upb_msgvisitor *v, upb_msg *m);
+void upb_msgvisitor_visit(upb_msgvisitor *v, upb_status *status);
#ifdef __cplusplus
} /* extern "C" */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback