summaryrefslogtreecommitdiff
path: root/upb/msgfactory.h
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2018-08-22 23:15:12 -0700
committerJosh Haberman <jhaberman@gmail.com>2018-08-22 23:15:12 -0700
commite94ac4f75717f2bd1a617e5633cd502106748475 (patch)
treea010d942478fa846d35de106373a39076c15aace /upb/msgfactory.h
parent0a95f73d0d9874151c0d36d6035230a873fa1715 (diff)
Moved upb_msg parts that depend on def to a separate msgfactory.{c,h}.
Also got rid of the premature "v1" business that was attempting to create a binary compatibility story. Also added an in-progress CMakeLists.txt file.
Diffstat (limited to 'upb/msgfactory.h')
-rw-r--r--upb/msgfactory.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/upb/msgfactory.h b/upb/msgfactory.h
new file mode 100644
index 0000000..73a26ba
--- /dev/null
+++ b/upb/msgfactory.h
@@ -0,0 +1,40 @@
+
+#include "upb/def.h"
+#include "upb/msg.h"
+
+#ifndef UPB_MSGFACTORY_H_
+#define UPB_MSGFACTORY_H_
+
+UPB_DECLARE_TYPE(upb::MessageFactory, upb_msgfactory)
+
+/** upb_msgfactory ************************************************************/
+
+/* A upb_msgfactory contains a cache of upb_msglayout, upb_handlers, and
+ * upb_visitorplan objects. These are the objects necessary to represent,
+ * populate, and and visit upb_msg objects.
+ *
+ * These caches are all populated by upb_msgdef, and lazily created on demand.
+ */
+
+/* Creates and destroys a msgfactory, respectively. The messages for this
+ * msgfactory must come from |symtab| (which should outlive the msgfactory). */
+upb_msgfactory *upb_msgfactory_new(const upb_symtab *symtab);
+void upb_msgfactory_free(upb_msgfactory *f);
+
+const upb_symtab *upb_msgfactory_symtab(const upb_msgfactory *f);
+
+/* The functions to get cached objects, lazily creating them on demand. These
+ * all require:
+ *
+ * - m is in upb_msgfactory_symtab(f)
+ * - upb_msgdef_mapentry(m) == false (since map messages can't have layouts).
+ *
+ * The returned objects will live for as long as the msgfactory does.
+ *
+ * TODO(haberman): consider making this thread-safe and take a const
+ * upb_msgfactory. */
+const upb_msglayout *upb_msgfactory_getlayout(upb_msgfactory *f,
+ const upb_msgdef *m);
+
+
+#endif /* UPB_MSGFACTORY_H_ */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback