summaryrefslogtreecommitdiff
path: root/upb/pb
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2015-07-07 18:46:14 -0700
committerJosh Haberman <jhaberman@gmail.com>2015-07-07 18:46:14 -0700
commit49dab06e03c16691c4dab1ba012fe8488089a590 (patch)
tree209f0749cbba6db8c9f0bf1094e6b5b5cd5190a0 /upb/pb
parent6d9a9c727fd966acec7340aeabd5bf4039c6d929 (diff)
Brought into compliance with Google open-source policies.
- removed myself from Author headers in source files. - removed copyright notices from source file headers. - added CONTRIBUTING.md
Diffstat (limited to 'upb/pb')
-rw-r--r--upb/pb/compile_decoder.c27
-rw-r--r--upb/pb/compile_decoder_x64.c9
-rw-r--r--upb/pb/decoder.c31
-rw-r--r--upb/pb/decoder.h27
-rw-r--r--upb/pb/decoder.int.h9
-rw-r--r--upb/pb/encoder.c111
-rw-r--r--upb/pb/encoder.h21
-rw-r--r--upb/pb/glue.c6
-rw-r--r--upb/pb/glue.h41
-rw-r--r--upb/pb/textprinter.c5
-rw-r--r--upb/pb/textprinter.h9
-rw-r--r--upb/pb/varint.c6
-rw-r--r--upb/pb/varint.int.h11
13 files changed, 130 insertions, 183 deletions
diff --git a/upb/pb/compile_decoder.c b/upb/pb/compile_decoder.c
index 83c914b..2828247 100644
--- a/upb/pb/compile_decoder.c
+++ b/upb/pb/compile_decoder.c
@@ -1,19 +1,16 @@
/*
- * upb - a minimalist implementation of protocol buffers.
- *
- * Copyright (c) 2013 Google Inc. See LICENSE for details.
- * Author: Josh Haberman <jhaberman@gmail.com>
- *
- * Code to compile a upb::Handlers into bytecode for decoding a protobuf
- * according to that specific schema and destination handlers.
- *
- * Compiling to bytecode is always the first step. If we are using the
- * interpreted decoder we leave it as bytecode and interpret that. If we are
- * using a JIT decoder we use a code generator to turn the bytecode into native
- * code, LLVM IR, etc.
- *
- * Bytecode definition is in decoder.int.h.
- */
+** protobuf decoder bytecode compiler
+**
+** Code to compile a upb::Handlers into bytecode for decoding a protobuf
+** according to that specific schema and destination handlers.
+**
+** Compiling to bytecode is always the first step. If we are using the
+** interpreted decoder we leave it as bytecode and interpret that. If we are
+** using a JIT decoder we use a code generator to turn the bytecode into native
+** code, LLVM IR, etc.
+**
+** Bytecode definition is in decoder.int.h.
+*/
#include <stdarg.h>
#include "upb/pb/decoder.int.h"
diff --git a/upb/pb/compile_decoder_x64.c b/upb/pb/compile_decoder_x64.c
index 9b78c65..88561d6 100644
--- a/upb/pb/compile_decoder_x64.c
+++ b/upb/pb/compile_decoder_x64.c
@@ -1,11 +1,6 @@
/*
- * upb - a minimalist implementation of protocol buffers.
- *
- * Copyright (c) 2013 Google Inc. See LICENSE for details.
- * Author: Josh Haberman <jhaberman@gmail.com>
- *
- * Driver code for the x64 JIT compiler.
- */
+** Driver code for the x64 JIT compiler.
+*/
/* Needed to ensure we get defines like MAP_ANON. */
#define _GNU_SOURCE
diff --git a/upb/pb/decoder.c b/upb/pb/decoder.c
index a6240ce..905fdd1 100644
--- a/upb/pb/decoder.c
+++ b/upb/pb/decoder.c
@@ -1,22 +1,17 @@
/*
- * upb - a minimalist implementation of protocol buffers.
- *
- * Copyright (c) 2008-2013 Google Inc. See LICENSE for details.
- * Author: Josh Haberman <jhaberman@gmail.com>
- *
- * This file implements a VM for the interpreted (bytecode) decoder.
- *
- * Bytecode must previously have been generated using the bytecode compiler in
- * compile_decoder.c. This decoder then walks through the bytecode op-by-op to
- * parse the input.
- *
- * Decoding is fully resumable; we just keep a pointer to the current bytecode
- * instruction and resume from there. A fair amount of the logic here is to
- * handle the fact that values can span buffer seams and we have to be able to
- * be capable of suspending/resuming from any byte in the stream. This
- * sometimes requires keeping a few trailing bytes from the last buffer around
- * in the "residual" buffer.
- */
+** upb::Decoder (Bytecode Decoder VM)
+**
+** Bytecode must previously have been generated using the bytecode compiler in
+** compile_decoder.c. This decoder then walks through the bytecode op-by-op to
+** parse the input.
+**
+** Decoding is fully resumable; we just keep a pointer to the current bytecode
+** instruction and resume from there. A fair amount of the logic here is to
+** handle the fact that values can span buffer seams and we have to be able to
+** be capable of suspending/resuming from any byte in the stream. This
+** sometimes requires keeping a few trailing bytes from the last buffer around
+** in the "residual" buffer.
+*/
#include <inttypes.h>
#include <stddef.h>
diff --git a/upb/pb/decoder.h b/upb/pb/decoder.h
index 6a9e1d4..f28e5e6 100644
--- a/upb/pb/decoder.h
+++ b/upb/pb/decoder.h
@@ -1,19 +1,16 @@
/*
- * upb - a minimalist implementation of protocol buffers.
- *
- * Copyright (c) 2009-2014 Google Inc. See LICENSE for details.
- * Author: Josh Haberman <jhaberman@gmail.com>
- *
- * upb::pb::Decoder implements a high performance, streaming, resumable decoder
- * for the binary protobuf format.
- *
- * This interface works the same regardless of what decoder backend is being
- * used. A client of this class does not need to know whether decoding is using
- * a JITted decoder (DynASM, LLVM, etc) or an interpreted decoder. By default,
- * it will always use the fastest available decoder. However, you can call
- * set_allow_jit(false) to disable any JIT decoder that might be available.
- * This is primarily useful for testing purposes.
- */
+** upb::pb::Decoder
+**
+** A high performance, streaming, resumable decoder for the binary protobuf
+** format.
+**
+** This interface works the same regardless of what decoder backend is being
+** used. A client of this class does not need to know whether decoding is using
+** a JITted decoder (DynASM, LLVM, etc) or an interpreted decoder. By default,
+** it will always use the fastest available decoder. However, you can call
+** set_allow_jit(false) to disable any JIT decoder that might be available.
+** This is primarily useful for testing purposes.
+*/
#ifndef UPB_DECODER_H_
#define UPB_DECODER_H_
diff --git a/upb/pb/decoder.int.h b/upb/pb/decoder.int.h
index ba18771..2d4485a 100644
--- a/upb/pb/decoder.int.h
+++ b/upb/pb/decoder.int.h
@@ -1,11 +1,6 @@
/*
- * upb - a minimalist implementation of protocol buffers.
- *
- * Copyright (c) 2009-2014 Google Inc. See LICENSE for details.
- * Author: Josh Haberman <jhaberman@gmail.com>
- *
- * Internal-only definitions for the decoder.
- */
+** Internal-only definitions for the decoder.
+*/
#ifndef UPB_DECODER_INT_H_
#define UPB_DECODER_INT_H_
diff --git a/upb/pb/encoder.c b/upb/pb/encoder.c
index e704bbd..cf4df9e 100644
--- a/upb/pb/encoder.c
+++ b/upb/pb/encoder.c
@@ -1,61 +1,58 @@
/*
- * upb - a minimalist implementation of protocol buffers.
- *
- * Copyright (c) 2014 Google Inc. See LICENSE for details.
- * Author: Josh Haberman <jhaberman@gmail.com>
- *
- * Since we are implementing pure handlers (ie. without any out-of-band access
- * to pre-computed lengths), we have to buffer all submessages before we can
- * emit even their first byte.
- *
- * Not knowing the size of submessages also means we can't write a perfect
- * zero-copy implementation, even with buffering. Lengths are stored as
- * varints, which means that we don't know how many bytes to reserve for the
- * length until we know what the length is.
- *
- * This leaves us with three main choices:
- *
- * 1. buffer all submessage data in a temporary buffer, then copy it exactly
- * once into the output buffer.
- *
- * 2. attempt to buffer data directly into the output buffer, estimating how
- * many bytes each length will take. When our guesses are wrong, use
- * memmove() to grow or shrink the allotted space.
- *
- * 3. buffer directly into the output buffer, allocating a max length
- * ahead-of-time for each submessage length. If we overallocated, we waste
- * space, but no memcpy() or memmove() is required. This approach requires
- * defining a maximum size for submessages and rejecting submessages that
- * exceed that size.
- *
- * (2) and (3) have the potential to have better performance, but they are more
- * complicated and subtle to implement:
- *
- * (3) requires making an arbitrary choice of the maximum message size; it
- * wastes space when submessages are shorter than this and fails
- * completely when they are longer. This makes it more finicky and
- * requires configuration based on the input. It also makes it impossible
- * to perfectly match the output of reference encoders that always use the
- * optimal amount of space for each length.
- *
- * (2) requires guessing the the size upfront, and if multiple lengths are
- * guessed wrong the minimum required number of memmove() operations may
- * be complicated to compute correctly. Implemented properly, it may have
- * a useful amortized or average cost, but more investigation is required
- * to determine this and what the optimal algorithm is to achieve it.
- *
- * (1) makes you always pay for exactly one copy, but its implementation is
- * the simplest and its performance is predictable.
- *
- * So for now, we implement (1) only. If we wish to optimize later, we should
- * be able to do it without affecting users.
- *
- * The strategy is to buffer the segments of data that do *not* depend on
- * unknown lengths in one buffer, and keep a separate buffer of segment pointers
- * and lengths. When the top-level submessage ends, we can go beginning to end,
- * alternating the writing of lengths with memcpy() of the rest of the data.
- * At the top level though, no buffering is required.
- */
+** upb::Encoder
+**
+** Since we are implementing pure handlers (ie. without any out-of-band access
+** to pre-computed lengths), we have to buffer all submessages before we can
+** emit even their first byte.
+**
+** Not knowing the size of submessages also means we can't write a perfect
+** zero-copy implementation, even with buffering. Lengths are stored as
+** varints, which means that we don't know how many bytes to reserve for the
+** length until we know what the length is.
+**
+** This leaves us with three main choices:
+**
+** 1. buffer all submessage data in a temporary buffer, then copy it exactly
+** once into the output buffer.
+**
+** 2. attempt to buffer data directly into the output buffer, estimating how
+** many bytes each length will take. When our guesses are wrong, use
+** memmove() to grow or shrink the allotted space.
+**
+** 3. buffer directly into the output buffer, allocating a max length
+** ahead-of-time for each submessage length. If we overallocated, we waste
+** space, but no memcpy() or memmove() is required. This approach requires
+** defining a maximum size for submessages and rejecting submessages that
+** exceed that size.
+**
+** (2) and (3) have the potential to have better performance, but they are more
+** complicated and subtle to implement:
+**
+** (3) requires making an arbitrary choice of the maximum message size; it
+** wastes space when submessages are shorter than this and fails
+** completely when they are longer. This makes it more finicky and
+** requires configuration based on the input. It also makes it impossible
+** to perfectly match the output of reference encoders that always use the
+** optimal amount of space for each length.
+**
+** (2) requires guessing the the size upfront, and if multiple lengths are
+** guessed wrong the minimum required number of memmove() operations may
+** be complicated to compute correctly. Implemented properly, it may have
+** a useful amortized or average cost, but more investigation is required
+** to determine this and what the optimal algorithm is to achieve it.
+**
+** (1) makes you always pay for exactly one copy, but its implementation is
+** the simplest and its performance is predictable.
+**
+** So for now, we implement (1) only. If we wish to optimize later, we should
+** be able to do it without affecting users.
+**
+** The strategy is to buffer the segments of data that do *not* depend on
+** unknown lengths in one buffer, and keep a separate buffer of segment pointers
+** and lengths. When the top-level submessage ends, we can go beginning to end,
+** alternating the writing of lengths with memcpy() of the rest of the data.
+** At the top level though, no buffering is required.
+*/
#include "upb/pb/encoder.h"
#include "upb/pb/varint.int.h"
diff --git a/upb/pb/encoder.h b/upb/pb/encoder.h
index cb5c79f..e8f7425 100644
--- a/upb/pb/encoder.h
+++ b/upb/pb/encoder.h
@@ -1,16 +1,13 @@
/*
- * upb - a minimalist implementation of protocol buffers.
- *
- * Copyright (c) 2009-2010 Google Inc. See LICENSE for details.
- * Author: Josh Haberman <jhaberman@gmail.com>
- *
- * Implements a set of upb_handlers that write protobuf data to the binary wire
- * format.
- *
- * This encoder implementation does not have any access to any out-of-band or
- * precomputed lengths for submessages, so it must buffer submessages internally
- * before it can emit the first byte.
- */
+** upb::pb::Encoder (upb_pb_encoder)
+**
+** Implements a set of upb_handlers that write protobuf data to the binary wire
+** format.
+**
+** This encoder implementation does not have any access to any out-of-band or
+** precomputed lengths for submessages, so it must buffer submessages internally
+** before it can emit the first byte.
+*/
#ifndef UPB_ENCODER_H_
#define UPB_ENCODER_H_
diff --git a/upb/pb/glue.c b/upb/pb/glue.c
index 76c8356..d6faeff 100644
--- a/upb/pb/glue.c
+++ b/upb/pb/glue.c
@@ -1,9 +1,3 @@
-/*
- * upb - a minimalist implementation of protocol buffers.
- *
- * Copyright (c) 2010-2012 Google Inc. See LICENSE for details.
- * Author: Josh Haberman <jhaberman@gmail.com>
- */
#include "upb/pb/glue.h"
diff --git a/upb/pb/glue.h b/upb/pb/glue.h
index 5073968..f65753c 100644
--- a/upb/pb/glue.h
+++ b/upb/pb/glue.h
@@ -1,27 +1,22 @@
/*
- * upb - a minimalist implementation of protocol buffers.
- *
- * Copyright (c) 2011-2012 Google Inc. See LICENSE for details.
- * Author: Josh Haberman <jhaberman@gmail.com>
- *
- * 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).
- */
+** 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
diff --git a/upb/pb/textprinter.c b/upb/pb/textprinter.c
index 4932468..3785d83 100644
--- a/upb/pb/textprinter.c
+++ b/upb/pb/textprinter.c
@@ -1,8 +1,5 @@
/*
- * upb - a minimalist implementation of protocol buffers.
- *
- * Copyright (c) 2009 Google Inc. See LICENSE for details.
- * Author: Josh Haberman <jhaberman@gmail.com>
+ * upb::pb::TextPrinter
*
* OPT: This is not optimized at all. It uses printf() which parses the format
* string every time, and it allocates memory for every put.
diff --git a/upb/pb/textprinter.h b/upb/pb/textprinter.h
index 4b0050f..b6ad9c5 100644
--- a/upb/pb/textprinter.h
+++ b/upb/pb/textprinter.h
@@ -1,9 +1,8 @@
/*
- * upb - a minimalist implementation of protocol buffers.
- *
- * Copyright (c) 2009 Google Inc. See LICENSE for details.
- * Author: Josh Haberman <jhaberman@gmail.com>
- */
+** upb::pb::TextPrinter (upb_textprinter)
+**
+** Handlers for writing to protobuf text format.
+*/
#ifndef UPB_TEXT_H_
#define UPB_TEXT_H_
diff --git a/upb/pb/varint.c b/upb/pb/varint.c
index 04767eb..25cdd81 100644
--- a/upb/pb/varint.c
+++ b/upb/pb/varint.c
@@ -1,9 +1,3 @@
-/*
- * upb - a minimalist implementation of protocol buffers.
- *
- * Copyright (c) 2011 Google Inc. See LICENSE for details.
- * Author: Josh Haberman <jhaberman@gmail.com>
- */
#include "upb/pb/varint.int.h"
diff --git a/upb/pb/varint.int.h b/upb/pb/varint.int.h
index a394a75..735bcbe 100644
--- a/upb/pb/varint.int.h
+++ b/upb/pb/varint.int.h
@@ -1,12 +1,7 @@
/*
- * upb - a minimalist implementation of protocol buffers.
- *
- * Copyright (c) 2011 Google Inc. See LICENSE for details.
- * Author: Josh Haberman <jhaberman@gmail.com>
- *
- * A number of routines for varint manipulation (we keep them all around to
- * have multiple approaches available for benchmarking).
- */
+** A number of routines for varint manipulation (we keep them all around to
+** have multiple approaches available for benchmarking).
+*/
#ifndef UPB_VARINT_DECODER_H_
#define UPB_VARINT_DECODER_H_
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback