Lines Matching defs:plib

137 protolib_init(struct protolib *plib)
139 DICT_INIT(&plib->prototypes, char *, struct prototype,
142 DICT_INIT(&plib->named_types, char *, struct named_type,
145 VECT_INIT(&plib->imports, struct protolib *);
147 plib->refs = 0;
163 protolib_destroy(struct protolib *plib)
165 assert(plib->refs == 0);
167 VECT_DESTROY(&plib->imports, struct prototype *, NULL, NULL);
169 DICT_DESTROY(&plib->prototypes, const char *, struct prototype,
172 DICT_DESTROY(&plib->named_types, const char *, struct named_type,
177 each_import(struct protolib *plib, struct protolib **start_after,
180 assert(plib != NULL);
181 return VECT_EACH(&plib->imports, struct protolib *,
199 protolib_add_import(struct protolib *plib, struct protolib *import)
201 assert(plib != NULL);
203 if (is_or_imports(&import, plib) == CBS_STOP) {
208 return VECT_PUSHBACK(&plib->imports, &import) < 0 ? -1 : 0;
222 protolib_add_prototype(struct protolib *plib, const char *name, int own_name,
225 assert(plib != NULL);
228 if (DICT_INSERT(&plib->prototypes, &name, proto) < 0)
234 protolib_add_named_type(struct protolib *plib, const char *name, int own_name,
237 assert(plib != NULL);
240 if (DICT_INSERT(&plib->named_types, &name, named) < 0)
247 struct dict *(*getter)(struct protolib *plib);
253 get_prototypes(struct protolib *plib)
255 assert(plib != NULL);
256 return &plib->prototypes;
260 get_named_types(struct protolib *plib)
262 assert(plib != NULL);
263 return &plib->named_types;
288 protolib_lookup(struct protolib *plib, const char *name,
292 assert(plib != NULL);
294 if (protolib_lookup_rec(&plib, &lookup) == CBS_STOP)
302 protolib_lookup_prototype(struct protolib *plib, const char *name, bool imports)
304 assert(plib != NULL);
305 return protolib_lookup(plib, name, &get_prototypes, imports);
309 protolib_lookup_type(struct protolib *plib, const char *name, bool imports)
311 assert(plib != NULL);
312 return protolib_lookup(plib, name, &get_named_types, imports);
392 struct protolib *plib = consider_config_dir(cache, *dirs, key);
393 if (plib != NULL) {
394 *retp = plib;
406 struct protolib *plib = protolib_cache_file(cache, *fnp, 1);
407 if (plib != NULL) {
410 if (protolib_add_import(&cache->imports, plib) < 0)
490 struct protolib *plib = data;
491 if (protolib_add_import(plib, *importp) < 0)
531 const char *key, struct protolib *plib)
533 if (protolib_cache_protolib(cache, key, 1, plib) == 0
534 || plib == NULL)
586 struct protolib *plib;
588 allow_private, &plib) < 0)
591 if (plib == NULL)
592 plib = protolib_cache_default(cache, key, own_key);
594 return plib;
607 struct protolib *plib = build_default_config(cache, key);
611 attempt_to_cache(cache, key, plib);
613 return plib;
621 struct protolib *plib;
622 if (DICT_FIND_VAL(&cache->protolibs, &filename, &plib) == 0)
623 return plib;
658 struct protolib *plib)
666 int rc = DICT_INSERT(&cache->protolibs, &filename, &plib);
669 if (rc == 0 && plib != NULL)
670 plib->refs++;