implemented categoryContext

This commit is contained in:
krangelov
2021-08-12 10:42:02 +02:00
parent c97b736a5b
commit f2da618e5d
7 changed files with 69 additions and 3 deletions

View File

@@ -167,6 +167,30 @@ void pgf_iter_categories(PgfPGF* pgf, PgfItor* itor)
namespace_iter(pgf->get_root<PgfPGFRoot>()->abstract.cats, itor);
}
PGF_API PgfTypeHypo*
pgf_category_context(PgfPGF *pgf, PgfText *catname, size_t *n_hypos)
{
DB_scope scope(pgf, READER_SCOPE);
ref<PgfAbsCat> abscat =
namespace_lookup(pgf->get_root<PgfPGFRoot>()->abstract.cats, catname);
if (abscat == 0) {
*n_hypos = 0;
return NULL;
}
PgfTypeHypo *hypos = (PgfTypeHypo *)
malloc(abscat->context->len * sizeof(PgfTypeHypo));
for (size_t i = 0; i < abscat->context->len; i++) {
hypos[i].bind_type = abscat->context->data[i].bind_type;
hypos[i].cid = textdup(abscat->context->data[i].cid);
hypos[i].type = pgf_unmarshall_type(pgf->u, abscat->context->data[i].type);
}
*n_hypos = abscat->context->len;
return hypos;
}
PGF_API
void pgf_iter_functions(PgfPGF* pgf, PgfItor* itor)
{

View File

@@ -160,6 +160,9 @@ PgfText *pgf_abstract_name(PgfPGF* pgf);
PGF_API_DECL
void pgf_iter_categories(PgfPGF* pgf, PgfItor* itor);
PGF_API_DECL PgfTypeHypo*
pgf_category_context(PgfPGF *pgf, PgfText *catname, size_t *n_hypos);
PGF_API_DECL
void pgf_iter_functions(PgfPGF* pgf, PgfItor* itor);