summaryrefslogtreecommitdiff
path: root/upb/pb
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2018-09-11 10:59:08 -0700
committerJosh Haberman <jhaberman@gmail.com>2018-09-11 10:59:08 -0700
commitb79fd65a83e6563393807efbc44be3e2bdb16537 (patch)
tree257b56a8c38292e3f78a7793e4f362f9d66013f5 /upb/pb
parentb2a388212a208095300f1ff2f767af82dd9e59b2 (diff)
WIP.
Diffstat (limited to 'upb/pb')
-rw-r--r--upb/pb/decoder.int.h1
-rw-r--r--upb/pb/glue.c54
-rw-r--r--upb/pb/glue.h72
3 files changed, 0 insertions, 127 deletions
diff --git a/upb/pb/decoder.int.h b/upb/pb/decoder.int.h
index 4032570..f02bdd5 100644
--- a/upb/pb/decoder.int.h
+++ b/upb/pb/decoder.int.h
@@ -9,7 +9,6 @@
#include "upb/handlers.h"
#include "upb/pb/decoder.h"
#include "upb/sink.h"
-#include "upb/structdefs.int.h"
#include "upb/table.int.h"
/* C++ names are not actually used since this type isn't exposed to users. */
diff --git a/upb/pb/glue.c b/upb/pb/glue.c
deleted file mode 100644
index fb2b769..0000000
--- a/upb/pb/glue.c
+++ /dev/null
@@ -1,54 +0,0 @@
-
-#include "upb/pb/glue.h"
-
-#include "upb/descriptor/reader.h"
-#include "upb/pb/decoder.h"
-
-upb_filedef **upb_loaddescriptor(const char *buf, size_t n, const void *owner,
- upb_status *status) {
- /* Create handlers. */
- const upb_pbdecodermethod *decoder_m;
- const upb_handlers *reader_h = upb_descreader_newhandlers(&reader_h);
- upb_env env;
- upb_pbdecodermethodopts opts;
- upb_pbdecoder *decoder;
- upb_descreader *reader;
- bool ok;
- size_t i;
- upb_filedef **ret = NULL;
-
- upb_pbdecodermethodopts_init(&opts, reader_h);
- decoder_m = upb_pbdecodermethod_new(&opts, &decoder_m);
-
- upb_env_init(&env);
- upb_env_reporterrorsto(&env, status);
-
- reader = upb_descreader_create(&env, reader_h);
- decoder = upb_pbdecoder_create(&env, decoder_m, upb_descreader_input(reader));
-
- /* Push input data. */
- ok = upb_bufsrc_putbuf(buf, n, upb_pbdecoder_input(decoder));
-
- if (!ok) {
- goto cleanup;
- }
-
- ret = upb_gmalloc(sizeof (*ret) * (upb_descreader_filecount(reader) + 1));
-
- if (!ret) {
- goto cleanup;
- }
-
- for (i = 0; i < upb_descreader_filecount(reader); i++) {
- ret[i] = upb_descreader_file(reader, i);
- upb_filedef_ref(ret[i], owner);
- }
-
- ret[i] = NULL;
-
-cleanup:
- upb_env_uninit(&env);
- upb_handlers_unref(reader_h, &reader_h);
- upb_pbdecodermethod_unref(decoder_m, &decoder_m);
- return ret;
-}
diff --git a/upb/pb/glue.h b/upb/pb/glue.h
deleted file mode 100644
index 716fc0e..0000000
--- a/upb/pb/glue.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
-** upb's core components like upb_decoder and upb_msg are carefully designed to
-** avoid depending on each other for maximum orthogonality. In other words,
-** you can use a upb_decoder to decode into *any* kind of structure; upb_msg is
-** just one such structure. A upb_msg can be serialized/deserialized into any
-** format, protobuf binary format is just one such format.
-**
-** However, for convenience we provide functions here for doing common
-** operations like deserializing protobuf binary format into a upb_msg. The
-** compromise is that this file drags in almost all of upb as a dependency,
-** which could be undesirable if you're trying to use a trimmed-down build of
-** upb.
-**
-** While these routines are convenient, they do not reuse any encoding/decoding
-** state. For example, if a decoder is JIT-based, it will be re-JITted every
-** time these functions are called. For this reason, if you are parsing lots
-** of data and efficiency is an issue, these may not be the best functions to
-** use (though they are useful for prototyping, before optimizing).
-*/
-
-#ifndef UPB_GLUE_H
-#define UPB_GLUE_H
-
-#include <stdbool.h>
-#include "upb/def.h"
-
-#ifdef __cplusplus
-#include <vector>
-
-extern "C" {
-#endif
-
-/* Loads a binary descriptor and returns a NULL-terminated array of unfrozen
- * filedefs. The caller owns the returned array, which must be freed with
- * upb_gfree(). */
-upb_filedef **upb_loaddescriptor(const char *buf, size_t n, const void *owner,
- upb_status *status);
-
-#ifdef __cplusplus
-} /* extern "C" */
-
-namespace upb {
-
-inline bool LoadDescriptor(const char* buf, size_t n, Status* status,
- std::vector<reffed_ptr<FileDef> >* files) {
- FileDef** parsed_files = upb_loaddescriptor(buf, n, &parsed_files, status);
-
- if (parsed_files) {
- FileDef** p = parsed_files;
- while (*p) {
- files->push_back(reffed_ptr<FileDef>(*p, &parsed_files));
- ++p;
- }
- free(parsed_files);
- return true;
- } else {
- return false;
- }
-}
-
-/* Templated so it can accept both string and std::string. */
-template <typename T>
-bool LoadDescriptor(const T& desc, Status* status,
- std::vector<reffed_ptr<FileDef> >* files) {
- return LoadDescriptor(desc.c_str(), desc.size(), status, files);
-}
-
-} /* namespace upb */
-
-#endif
-
-#endif /* UPB_GLUE_H */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback