summaryrefslogtreecommitdiff
path: root/upb.h
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2009-07-01 18:02:30 -0700
committerJoshua Haberman <joshua@reverberate.org>2009-07-01 18:02:30 -0700
commitc21ad57da6f25cf5d004a0f841c2a2d8f9786315 (patch)
treee07927af7af74e357ed77457513e084bf68e1b53 /upb.h
parentf813688f3ed0880e4db168c6b1baf9039d39eeee (diff)
More work to msg and parse. Getting close!
Diffstat (limited to 'upb.h')
-rw-r--r--upb.h34
1 files changed, 28 insertions, 6 deletions
diff --git a/upb.h b/upb.h
index 39ca0de..f5f19d3 100644
--- a/upb.h
+++ b/upb.h
@@ -38,13 +38,18 @@ extern "C" {
struct upb_string {
/* We expect the data to be 8-bit clean (uint8_t), but char* is such an
* ingrained convention that we follow it. */
- char *data;
+ char *ptr;
uint32_t byte_len;
};
-INLINE bool upb_string_eql(struct upb_string *s1, struct upb_string *s2) {
+INLINE bool upb_streql(struct upb_string *s1, struct upb_string *s2) {
return s1->byte_len == s2->byte_len &&
- memcmp(s1->data, s2->data, s1->byte_len) == 0;
+ memcmp(s1->ptr, s2->ptr, s1->byte_len) == 0;
+}
+
+INLINE void upb_strcpy(struct upb_string *dest, struct upb_string *src) {
+ memcpy(dest->ptr, src->ptr, dest->byte_len);
+ dest->byte_len = src->byte_len;
}
/* A list of types as they are encoded on-the-wire. */
@@ -72,16 +77,21 @@ union upb_wire_value {
* represent exceptional circumstances. */
typedef uint8_t upb_field_type_t;
+/* Label (optional, repeated, required) as defined in a .proto file. The values
+ * of this are defined by google.protobuf.FieldDescriptorProto.Label (from
+ * descriptor.proto). */
+typedef uint8_t upb_label_t;
+
struct upb_type_info {
uint8_t align;
uint8_t size;
uint8_t expected_wire_type;
};
+/* This array is indexed by upb_field_type_t. */
extern struct upb_type_info upb_type_info[];
-/* A value as described in a .proto file, except delimited, which is handled
- * separately. */
+/* A scalar value as described in a .proto file */
union upb_value {
double _double;
float _float;
@@ -90,7 +100,19 @@ union upb_value {
uint32_t uint32;
uint64_t uint64;
bool _bool;
- uint32_t delim_len;
+};
+
+union upb_value_ptr {
+ double *_double;
+ float *_float;
+ int32_t *int32;
+ int64_t *int64;
+ uint32_t *uint32;
+ uint64_t *uint64;
+ bool *_bool;
+ struct upb_string **string;
+ struct upb_array **array;
+ void *_void;
};
/* The number of a field, eg. "optional string foo = 3". */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback