diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2013-08-16 12:54:16 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2013-08-16 12:54:16 +0000 |
| commit | 662a35bbb3724edab3647937411a079f52bd59c6 (patch) | |
| tree | 9eb57d63e20a63c975d3217b130b69d1d27d8b94 /src/runtime/c | |
| parent | 1e44fdb3d3413709ae635f0fae91ffa4a93a2d9d (diff) | |
provide API to access the language code for the concrete language
Diffstat (limited to 'src/runtime/c')
| -rw-r--r-- | src/runtime/c/pgf/pgf.c | 23 | ||||
| -rw-r--r-- | src/runtime/c/pgf/pgf.h | 3 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/runtime/c/pgf/pgf.c b/src/runtime/c/pgf/pgf.c index dc2ed7290..a03759314 100644 --- a/src/runtime/c/pgf/pgf.c +++ b/src/runtime/c/pgf/pgf.c @@ -145,6 +145,29 @@ pgf_start_cat(PgfPGF* pgf, GuPool* pool) return gu_str_string("S", pool); } +GuString +pgf_language_code(PgfConcr* concr) +{ + GuPool* tmp_pool = gu_local_pool(); + + GuString s = gu_str_string("language", tmp_pool); + PgfLiteral lit = + gu_map_get(concr->cflags, &s, PgfLiteral); + + if (gu_variant_is_null(lit)) + return gu_empty_string; + + GuVariantInfo i = gu_variant_open(lit); + switch (i.tag) { + case PGF_LITERAL_STR: { + PgfLiteralStr *lstr = (PgfLiteralStr *) i.data; + return lstr->val; + } + } + + return gu_empty_string; +} + void pgf_iter_functions(PgfPGF* pgf, GuMapItor* fn, GuExn* err) { diff --git a/src/runtime/c/pgf/pgf.h b/src/runtime/c/pgf/pgf.h index fe86373cf..a575a5188 100644 --- a/src/runtime/c/pgf/pgf.h +++ b/src/runtime/c/pgf/pgf.h @@ -95,6 +95,9 @@ pgf_get_language(PgfPGF*, PgfCId lang); GuString pgf_concrete_name(PgfConcr*); +GuString +pgf_language_code(PgfConcr* concr); + void pgf_iter_categories(PgfPGF* pgf, GuMapItor* fn, GuExn* err); |
