From b11730f2ed3b37af925a26b42b25689fd4769eef Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 23 Jun 2009 09:55:56 -0700 Subject: Added a upb_context object, which is like an interpreter context. --- upb_context.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 upb_context.h (limited to 'upb_context.h') 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_ */ -- cgit v1.2.3