diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2017-09-25 18:00:12 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-25 18:00:12 -0700 |
commit | bcb62b7fbfb0c959f7d3671b40c1b7efbb3a4156 (patch) | |
tree | 85c6e64d44beb2c970728290c7f88d87c736642e /upb/sink.h | |
parent | ae30b4a816a57a8101ce187245edc3050d515c06 (diff) | |
parent | 0a9681874ee9ec1e3104b4bdb8e6b2396561ccb6 (diff) |
Merge pull request #92 from TeBoring/unknown
Add new "unknown field" handler.
Diffstat (limited to 'upb/sink.h')
-rw-r--r-- | upb/sink.h | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -315,6 +315,18 @@ UPB_INLINE size_t upb_sink_putstring(upb_sink *s, upb_selector_t sel, return handler(s->closure, hd, buf, n, handle); } +UPB_INLINE bool upb_sink_putunknown(upb_sink *s, const char *buf, size_t n) { + typedef upb_unknown_handlerfunc func; + func *handler; + const void *hd; + if (!s->handlers) return true; + handler = (func *)upb_handlers_gethandler(s->handlers, UPB_UNKNOWN_SELECTOR); + + if (!handler) return n; + hd = upb_handlers_gethandlerdata(s->handlers, UPB_UNKNOWN_SELECTOR); + return handler(s->closure, hd, buf, n); +} + UPB_INLINE bool upb_sink_startmsg(upb_sink *s) { typedef upb_startmsg_handlerfunc func; func *startmsg; |