• Home
  • Raw
  • Download

Lines Matching full:handlers

1978    * indicates whether this field should have lazy parsing handlers that yield
3755 uint32_t selector_base; /* Used to index into a upb::Handlers table. */
3862 ** upb::Handlers (upb_handlers)
3866 ** parsing or visiting a stream of data. This is similar to how handlers work
3869 ** The handlers have no idea where the data is coming from, so a single set of
3870 ** handlers could be used with two completely different data sources (for
3888 class Handlers;
3897 UPB_DECLARE_DERIVED_TYPE(upb::Handlers, upb::RefCounted,
3906 * of Handlers::Freeze that allows specifying this as a parameter. */
3909 /* All the different types of handlers that can be registered.
3910 * Only needed for the advanced functions in upb::Handlers. */
3936 /* A selector refers to a specific field handler in the Handlers object
3962 /* Static selectors for upb::Handlers. */
3983 * handler. To free this pointer when the handlers are freed, call
3984 * Handlers::AddCleanup(). */
3996 * Start*{String,SubMessage,Sequence} handlers. This must match the closure
3997 * type of any handlers that use it (for example, the StringBuf handler must
4032 * If/when the size and locality of handlers is an issue, we can optimize this
4092 /* A upb::Handlers object represents the set of handlers associated with a
4097 * Any handlers that are not set behave as if they had successfully consumed
4098 * the value. Any unset Start* handlers will propagate their closure to the
4103 class upb::Handlers {
4134 /* Returns a new handlers object for the given frozen msgdef.
4136 static reffed_ptr<Handlers> New(const MessageDef *m);
4138 /* Convenience function for registering a graph of handlers that mirrors the
4140 * of handlers will be created and the given callback will be invoked,
4141 * allowing the client to register handlers for this message. Note that any
4143 static reffed_ptr<const Handlers> NewFrozen(const MessageDef *m,
4152 * failure does occur, it must be cleared before the Handlers are frozen,
4154 * used while the Handlers are mutable. */
4158 /* Call to freeze these Handlers. Requires that any SubHandlers are already
4163 /* Freezes the given set of handlers. You may not freeze a handler without
4164 * also freezing any handlers they point to. */
4165 static bool Freeze(Handlers*const* handlers, int n, Status* s);
4166 static bool Freeze(const std::vector<Handlers*>& handlers, Status* s);
4168 /* Returns the msgdef associated with this handlers object. */
4172 * will be run when these handlers are freed. If this pointer has previously
4233 /* Sets handlers for a string field, which are defined as follows:
4332 /* Sets or gets the object that specifies handlers for the given field, which
4333 * must be a submessage or group. Returns NULL if no handlers are set. */
4334 bool SetSubHandlers(const FieldDef* f, const Handlers* sub);
4335 const Handlers* GetSubHandlers(const FieldDef* f) const;
4339 const Handlers* GetSubHandlers(Selector startsubmsg) const;
4341 /* A selector refers to a specific field handler in the Handlers object
4345 * The returned selector is ONLY valid for Handlers whose MessageDef
4369 UPB_DISALLOW_POD_OPS(Handlers, upb::Handlers)
4421 * handlers->SetInt32Handler(f1, UpbBind(OnValue1, new MyHandlerData(...)));
4422 * handlers->SetInt32Handler(f2, UpbMakeHandler(OnValue2));
4423 * handlers->SetInt32Handler(f1, UpbMakeHandler(OnValue3));
4424 * handlers->SetInt32Handler(f2, UpbMakeHandler(&MyClosure::OnValue));
4457 * used to register all handlers. Users can Make() these directly but it's
4469 void AddCleanup(Handlers* h) const {
4477 friend class Handlers;
4618 * These follow the same handlers protocol for fields of a message. */
4631 /* Caller must ensure that "d" outlives the handlers.
4643 bool upb_handlers_freeze(upb_handlers *const *handlers, int n, upb_status *s);
4658 ** Inline definitions for handlers.h, which are particularly long and a bit
4903 * is non-const so we can free it when the handlers are destroyed. */
5198 * 1. void* for start handlers. If the closure parameter has a different type
5200 * 2. size_t for string buffer handlers.
5489 inline bool Handlers::SetValueHandler<vtype>( \
5491 const Handlers::utype ## Handler& handler) { \
5525 inline bool Handlers::Set##utype##Handler(const FieldDef *f, \
5594 * This is all nonsense for non START* handlers, but it doesn't matter because
5656 inline reffed_ptr<Handlers> Handlers::New(const MessageDef *m) {
5658 return reffed_ptr<Handlers>(h, &h);
5660 inline reffed_ptr<const Handlers> Handlers::NewFrozen(
5664 return reffed_ptr<const Handlers>(h, &h);
5666 inline const Status* Handlers::status() {
5669 inline void Handlers::ClearError() {
5672 inline bool Handlers::Freeze(Status *s) {
5673 upb::Handlers* h = this;
5676 inline bool Handlers::Freeze(Handlers *const *handlers, int n, Status *s) {
5677 return upb_handlers_freeze(handlers, n, s);
5679 inline bool Handlers::Freeze(const std::vector<Handlers*>& h, Status* status) {
5680 return upb_handlers_freeze((Handlers* const*)&h[0], h.size(), status);
5682 inline const MessageDef *Handlers::message_def() const {
5685 inline bool Handlers::AddCleanup(void *p, upb_handlerfree *func) {
5688 inline bool Handlers::SetStartMessageHandler(
5689 const Handlers::StartMessageHandler &handler) {
5695 inline bool Handlers::SetEndMessageHandler(
5696 const Handlers::EndMessageHandler &handler) {
5702 inline bool Handlers::SetStartStringHandler(const FieldDef *f,
5709 inline bool Handlers::SetEndStringHandler(const FieldDef *f,
5716 inline bool Handlers::SetStringHandler(const FieldDef *f,
5723 inline bool Handlers::SetStartSequenceHandler(
5730 inline bool Handlers::SetStartSubMessageHandler(
5737 inline bool Handlers::SetEndSubMessageHandler(const FieldDef *f,
5744 inline bool Handlers::SetEndSequenceHandler(const FieldDef *f,
5751 inline bool Handlers::SetSubHandlers(const FieldDef *f, const Handlers *sub) {
5754 inline const Handlers *Handlers::GetSubHandlers(const FieldDef *f) const {
5757 inline const Handlers *Handlers::GetSubHandlers(Handlers::Selector sel) const {
5760 inline bool Handlers::GetSelector(const FieldDef *f, Handlers::Type type,
5761 Handlers::Selector *s) {
5764 inline Handlers::Selector Handlers::GetEndSelector(Handlers::Selector start) {
5767 inline Handlers::GenericFunction *Handlers::GetHandler(
5768 Handlers::Selector selector) {
5771 inline const void *Handlers::GetHandlerData(Handlers::Selector selector) {
5835 /* A upb::Sink is an object that binds a upb::Handlers object to some runtime
5850 * pointer for any handler with handlers->GetHandler(selector), without having
5855 * Also to ponder: selectors right now are independent of a specific Handlers
5857 * that *could* be registered, without knowing anything about what handlers
5862 * Having another selector-like thing that is specific to a Handlers instance
5864 * ahead-of-time that can be bound to any Handlers instance at runtime. For
5866 * Handlers it will be bound to, so when it calls sink->StartString() what
5868 * independent of any particular upb::Handlers.
5870 * Is there a way then to allow Handlers table compaction? */
5876 /* Constructs a new sink for the given frozen handlers and closure.
5878 * TODO: once the Handlers know the expected closure type, verify that T
5880 template <class T> Sink(const Handlers* handlers, T* closure);
5883 template <class T> void Reset(const Handlers* handlers, T* closure);
5887 * TODO: once the Handlers know the expected closure type, verify that T
5896 * These may not be called from within one of the same sink's handlers (in
5897 * other words, handlers are not re-entrant). */
5913 bool PutInt32(Handlers::Selector s, int32_t val);
5914 bool PutInt64(Handlers::Selector s, int64_t val);
5915 bool PutUInt32(Handlers::Selector s, uint32_t val);
5916 bool PutUInt64(Handlers::Selector s, uint64_t val);
5917 bool PutFloat(Handlers::Selector s, float val);
5918 bool PutDouble(Handlers::Selector s, double val);
5919 bool PutBool(Handlers::Selector s, bool val);
5926 bool StartString(Handlers::Selector s, size_t size_hint, Sink* sub);
5927 size_t PutStringBuffer(Handlers::Selector s, const char *buf, size_t len,
5929 bool EndString(Handlers::Selector s);
5934 * "sub." The sub-sink must be used for any/all handlers called within the
5936 bool StartSubMessage(Handlers::Selector s, Sink* sub);
5937 bool EndSubMessage(Handlers::Selector s);
5943 * "sub." The sub-sink must be used for any/all handlers called within the
5945 bool StartSequence(Handlers::Selector s, Sink* sub);
5946 bool EndSequence(Handlers::Selector s);
5955 const upb_handlers *handlers;
5964 /* Constructs a new sink for the given frozen handlers and closure.
5966 * TODO(haberman): once the Handlers know the expected closure type, verify
6088 if (!s->handlers) return true; \
6089 func = (functype *)upb_handlers_gethandler(s->handlers, sel); \
6091 hd = upb_handlers_gethandlerdata(s->handlers, sel); \
6105 s->handlers = h;
6115 if (!s->handlers) return n;
6116 handler = (func *)upb_handlers_gethandler(s->handlers, sel);
6119 hd = upb_handlers_gethandlerdata(s->handlers, sel);
6127 if (!s->handlers) return true;
6128 startmsg = (func*)upb_handlers_gethandler(s->handlers, UPB_STARTMSG_SELECTOR);
6131 hd = upb_handlers_gethandlerdata(s->handlers, UPB_STARTMSG_SELECTOR);
6139 if (!s->handlers) return true;
6140 endmsg = (func *)upb_handlers_gethandler(s->handlers, UPB_ENDMSG_SELECTOR);
6143 hd = upb_handlers_gethandlerdata(s->handlers, UPB_ENDMSG_SELECTOR);
6153 sub->handlers = s->handlers;
6154 if (!s->handlers) return true;
6155 startseq = (func*)upb_handlers_gethandler(s->handlers, sel);
6158 hd = upb_handlers_gethandlerdata(s->handlers, sel);
6167 if (!s->handlers) return true;
6168 endseq = (func*)upb_handlers_gethandler(s->handlers, sel);
6171 hd = upb_handlers_gethandlerdata(s->handlers, sel);
6181 sub->handlers = s->handlers;
6182 if (!s->handlers) return true;
6183 startstr = (func*)upb_handlers_gethandler(s->handlers, sel);
6186 hd = upb_handlers_gethandlerdata(s->handlers, sel);
6195 if (!s->handlers) return true;
6196 endstr = (func*)upb_handlers_gethandler(s->handlers, sel);
6199 hd = upb_handlers_gethandlerdata(s->handlers, sel);
6209 if (!s->handlers) {
6210 sub->handlers = NULL;
6213 sub->handlers = upb_handlers_getsubhandlers_sel(s->handlers, sel);
6214 startsubmsg = (func*)upb_handlers_gethandler(s->handlers, sel);
6217 hd = upb_handlers_gethandlerdata(s->handlers, sel);
6226 if (!s->handlers) return true;
6227 endsubmsg = (func*)upb_handlers_gethandler(s->handlers, sel);
6230 hd = upb_handlers_gethandlerdata(s->handlers, sel);
6240 template <class T> Sink::Sink(const Handlers* handlers, T* closure) {
6241 upb_sink_reset(this, handlers, closure);
6244 inline void Sink::Reset(const Handlers* handlers, T* closure) {
6245 upb_sink_reset(this, handlers, closure);
6253 inline bool Sink::PutInt32(Handlers::Selector sel, int32_t val) {
6256 inline bool Sink::PutInt64(Handlers::Selector sel, int64_t val) {
6259 inline bool Sink::PutUInt32(Handlers::Selector sel, uint32_t val) {
6262 inline bool Sink::PutUInt64(Handlers::Selector sel, uint64_t val) {
6265 inline bool Sink::PutFloat(Handlers::Selector sel, float val) {
6268 inline bool Sink::PutDouble(Handlers::Selector sel, double val) {
6271 inline bool Sink::PutBool(Handlers::Selector sel, bool val) {
6274 inline bool Sink::StartString(Handlers::Selector sel, size_t size_hint,
6278 inline size_t Sink::PutStringBuffer(Handlers::Selector sel, const char *buf,
6282 inline bool Sink::EndString(Handlers::Selector sel) {
6285 inline bool Sink::StartSubMessage(Handlers::Selector sel, Sink* sub) {
6288 inline bool Sink::EndSubMessage(Handlers::Selector sel) {
6291 inline bool Sink::StartSequence(Handlers::Selector sel, Sink* sub) {
6294 inline bool Sink::EndSequence(Handlers::Selector sel) {
6328 ** For handlers that do very tiny, very simple operations, the function call
6330 ** user to define handlers that do something very simple like store the value
6332 ** handlers and emit specialized code for them instead of actually calling the
6358 static bool Set(Handlers *h, const FieldDef *f, size_t ofs, int32_t hasbit);
6362 static const Data* GetData(const Handlers* h, Handlers::Selector s,
6383 inline bool Shim::Set(Handlers* h, const FieldDef* f, size_t ofs,
6387 inline const Shim::Data* Shim::GetData(const Handlers* h, Handlers::Selector s,
6615 /* These handlers must have come from NewHandlers() and must outlive the
6618 * TODO: generate the handlers statically (like we do with the
6620 * to build/memory-manage the handlers at runtime at all). Unfortunately this
6621 * is a bit tricky to implement for Handlers, but necessary to simplify this
6623 static Reader* Create(Environment* env, const Handlers* handlers);
6632 /* Builds and returns handlers for the reader, owned by "owner." */
6633 static Handlers* NewHandlers(const void* owner);
6656 inline Reader* Reader::Create(Environment* e, const Handlers *h) {
7380 /* Parameter represents the destination handlers that this method will push
7382 explicit DecoderMethodOptions(const Handlers* dest_handlers);
7384 /* Should the decoder push submessages to lazy handlers for fields that have
7385 * them? The caller should set this iff the lazy handlers expect data that is
7391 const upb_handlers *handlers;
7398 * Handlers. */
7404 /* The destination handlers that are statically bound to this method.
7406 * handlers. */
7407 const Handlers* dest_handlers() const;
7409 /* The input handlers for this decoder method. */
7506 /* Returns a DecoderMethod that can push data to the given handlers.
7509 * Specifying the destination handlers here allows the DecoderMethod to be
7510 * statically bound to the destination handlers if possible, which can allow
7513 * push data to the given handlers. */
7595 inline DecoderMethodOptions::DecoderMethodOptions(const Handlers* h) {
7602 inline const Handlers* DecoderMethod::dest_handlers() const {
7814 /* The destination handlers this method is bound to. We own a ref. */
7878 /* Decoder entry points; used as handlers. */
8165 /* Creates a new encoder in the given environment. The Handlers must have
8167 static Encoder* Create(Environment* env, const Handlers* handlers,
8173 /* Creates a new set of handlers for this MessageDef. */
8174 static reffed_ptr<const Handlers> NewHandlers(const MessageDef* msg);
8198 inline Encoder* Encoder::Create(Environment* env, const Handlers* handlers,
8200 return upb_pb_encoder_create(env, handlers, output);
8205 inline reffed_ptr<const Handlers> Encoder::NewHandlers(
8207 const Handlers* h = upb_pb_encoder_newhandlers(md, &h);
8208 return reffed_ptr<const Handlers>(h, &h);
8290 ** Handlers for writing to protobuf text format.
8311 /* The given handlers must have come from NewHandlers(). It must outlive the
8313 static TextPrinter *Create(Environment *env, const upb::Handlers *handlers,
8322 static reffed_ptr<const Handlers> NewHandlers(const MessageDef* md);
8345 const upb::Handlers *handlers,
8347 return upb_textprinter_create(env, handlers, output);
8355 inline reffed_ptr<const Handlers> TextPrinter::NewHandlers(
8357 const Handlers* h = upb_textprinter_newhandlers(md, &h);
8358 return reffed_ptr<const Handlers>(h, &h);
8418 /* Returns handlers for parsing according to the specified schema. */
8421 /* The destination handlers that are statically bound to this method.
8423 * handlers. */
8424 const Handlers* dest_handlers() const;
8426 /* The input handlers for this decoder method. */
8466 inline const Handlers* ParserMethod::dest_handlers() const {
8489 ** Handlers that emit JSON according to a specific protobuf schema.
8516 static Printer* Create(Environment* env, const upb::Handlers* handlers,
8522 /* Returns handlers for printing according to the specified schema.
8526 static reffed_ptr<const Handlers> NewHandlers(const upb::MessageDef* md,
8553 inline Printer* Printer::Create(Environment* env, const upb::Handlers* handlers,
8555 return upb_json_printer_create(env, handlers, output);
8558 inline reffed_ptr<const Handlers> Printer::NewHandlers(
8560 const Handlers* h = upb_json_printer_newhandlers(
8562 return reffed_ptr<const Handlers>(h, &h);