summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--upb_context.h51
-rw-r--r--upb_msg.h7
2 files changed, 55 insertions, 3 deletions
diff --git a/upb_context.h b/upb_context.h
new file mode 100644
index 0000000..f2bb1df
--- /dev/null
+++ b/upb_context.h
@@ -0,0 +1,51 @@
+/*
+ * upb - a minimalist implementation of protocol buffers.
+ *
+ * A context represents a namespace of proto definitions, sort of like
+ * an interpreter's symbol table. It is empty when first constructed.
+ * Clients add definitions to the context by supplying serialized
+ * descriptors (as defined in descriptor.proto).
+ *
+ * Copyright (c) 2008 Joshua Haberman. See LICENSE for details.
+ */
+
+#ifndef UPB_PARSE_H_
+#define UPB_PARSE_H_
+
+#include "upb.h"
+#include "upb_table.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* High-level parsing interface. **********************************************/
+
+enum upb_symbol_type {
+ UPB_SYM_MESSAGE,
+ UPB_SYM_ENUM,
+ UPB_SYM_SERVICE,
+ UPB_SYM_EXTENSION
+};
+
+struct upb_symtab_entry {
+ struct upb_strtable_entry e;
+ enum upb_symbol_type type;
+ union {
+ struct upb_msg *msg;
+ struct upb_enum *_enum;
+ struct upb_svc *svc;
+ } p;
+}
+
+struct upb_context {
+ upb_strtable *symtab;
+};
+
+struct upb_symtab_entry *upb_context_findsym(struct upb_context *c, struct upb_string *s);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* UPB_PARSE_H_ */
diff --git a/upb_msg.h b/upb_msg.h
index c6a3766..4f06119 100644
--- a/upb_msg.h
+++ b/upb_msg.h
@@ -47,12 +47,11 @@ extern "C" {
/* Structure definition. ******************************************************/
-/* One single field of the struct. */
struct upb_msg_field {
uint32_t byte_offset; /* Where to find the data. */
uint16_t isset_byte_offset; /* The byte where the "set" bit lives. */
uint8_t isset_byte_mask;
- uint8_t type; /* Copied from the descriptor for cache-friendliness. */
+ upb_field_type_t type; /* Copied from descriptor for cache-friendliness. */
struct google_protobuf_FieldDescriptorProto *descriptor;
union {
struct upb_msg *msg;
@@ -60,7 +59,6 @@ struct upb_msg_field {
} ref;
};
-/* Definition of a complete struct. */
struct upb_msg {
struct google_protobuf_DescriptorProto *descriptor;
size_t size;
@@ -72,6 +70,9 @@ struct upb_msg {
struct upb_msg_field fields[];
};
+void upb_msg_init(struct upb_msg *m, struct google_protobuf_DescriptorProto *d);
+void upb_msg_free(struct upb_msg *m);
+
/* While these are written to be as fast as possible, it will still be faster
* to cache the results of this lookup if possible. These return NULL if no
* such field is found. */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback