Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / grpc-cloned / deps / grpc / third_party / upb / upb / msgfactory.h
1
2 #include "upb/def.h"
3 #include "upb/msg.h"
4
5 #ifndef UPB_MSGFACTORY_H_
6 #define UPB_MSGFACTORY_H_
7
8 /** upb_msgfactory ************************************************************/
9
10 struct upb_msgfactory;
11 typedef struct upb_msgfactory upb_msgfactory;
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 /* A upb_msgfactory contains a cache of upb_msglayout, upb_handlers, and
18  * upb_visitorplan objects.  These are the objects necessary to represent,
19  * populate, and and visit upb_msg objects.
20  *
21  * These caches are all populated by upb_msgdef, and lazily created on demand.
22  */
23
24 /* Creates and destroys a msgfactory, respectively.  The messages for this
25  * msgfactory must come from |symtab| (which should outlive the msgfactory). */
26 upb_msgfactory *upb_msgfactory_new(const upb_symtab *symtab);
27 void upb_msgfactory_free(upb_msgfactory *f);
28
29 const upb_symtab *upb_msgfactory_symtab(const upb_msgfactory *f);
30
31 /* The functions to get cached objects, lazily creating them on demand.  These
32  * all require:
33  *
34  * - m is in upb_msgfactory_symtab(f)
35  * - upb_msgdef_mapentry(m) == false (since map messages can't have layouts).
36  *
37  * The returned objects will live for as long as the msgfactory does.
38  *
39  * TODO(haberman): consider making this thread-safe and take a const
40  * upb_msgfactory. */
41 const upb_msglayout *upb_msgfactory_getlayout(upb_msgfactory *f,
42                                               const upb_msgdef *m);
43
44 #ifdef __cplusplus
45 }  /* extern "C" */
46 #endif
47
48 #endif /* UPB_MSGFACTORY_H_ */