diff options
author | Joshua Haberman <joshua@reverberate.org> | 2009-07-22 19:49:53 -0700 |
---|---|---|
committer | Joshua Haberman <joshua@reverberate.org> | 2009-07-22 19:49:53 -0700 |
commit | ee1ed1ccb87effa403dc91603d452d4c98ed716f (patch) | |
tree | e1ee8c1b38d9351d4d3494c5e45b91b288f3a081 /src/upb.h | |
parent | e4e89247e5f7548b5ebdb9a667657cdcb3feb17f (diff) |
Compiler finally works (except string arrays). Untested. Holy crap that was a lot of work.
Diffstat (limited to 'src/upb.h')
-rw-r--r-- | src/upb.h | 23 |
1 files changed, 15 insertions, 8 deletions
@@ -12,6 +12,7 @@ #include <stdbool.h> #include <stdint.h> #include <stdio.h> /* for size_t. */ +#include "upb_string.h" #ifdef __cplusplus extern "C" { @@ -35,7 +36,6 @@ extern "C" { #define UPB_INDEX(base, i, m) (void*)((char*)(base) + ((i)*(m))) INLINE uint32_t max(uint32_t a, uint32_t b) { return a > b ? a : b; } -INLINE uint32_t min(uint32_t a, uint32_t b) { return a < b ? a : b; } /* Value type as defined in a .proto file. The values of this are defined by * google_protobuf_FieldDescriptorProto_Type (from descriptor.proto). @@ -43,20 +43,21 @@ INLINE uint32_t min(uint32_t a, uint32_t b) { return a < b ? a : b; } * 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; + struct upb_string ctype; }; /* Contains information for all .proto types. Indexed by upb_field_type_t. */ extern struct upb_type_info upb_type_info[]; +/* 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; + /* A pointer to a .proto value. The owner must have an out-of-band way of * knowing the type, so it knows which union member to use. */ union upb_value { @@ -67,8 +68,8 @@ union upb_value { uint32_t uint32; uint64_t uint64; bool _bool; - struct upb_string **string; - struct upb_array **array; + struct upb_string *str; + struct upb_array *arr; void *msg; }; @@ -86,6 +87,12 @@ union upb_value_ptr { void *_void; }; +INLINE union upb_value upb_deref(union upb_value_ptr ptr, upb_field_type_t t) { + union upb_value val; + memcpy(&val, ptr._void, upb_type_info[t].size); + return val; +} + union upb_symbol_ref { struct upb_msg *msg; struct upb_enum *_enum; |