pocketsphinx_sys/
jsgf.rs

1use libc::{c_int, c_char};
2
3use super::hash_table::*;
4
5#[allow(non_camel_case_types)] pub enum jsgf_t {}
6#[allow(non_camel_case_types)] pub type jsgf_rule_iter_t = hash_iter_t;
7
8/// These definitions are extracted from implementation headers,
9/// they are not publicly available and thus are subject to change
10/// without notification. Use them at your own risk.
11pub mod internal {
12
13    use libc::{c_int, c_char};
14    use super::super::glist::glist_t;
15
16    #[repr(C)]
17    pub struct jsgf_rhs_t {
18        pub atoms: glist_t,
19        pub alt: *const jsgf_rhs_t,
20    }
21
22    #[repr(C)]
23    pub struct jsgf_atom_t {
24        pub name: *const c_char,
25        pub tags: glist_t,
26        pub weight: f32,
27    }
28
29    #[repr(C)]
30    pub struct jsgf_rule_s {
31        pub refcnt: c_int,
32        pub name: *const c_char,
33        pub is_public: c_int,
34        pub rhs: *const jsgf_rhs_t,
35    }
36
37}
38
39#[allow(non_camel_case_types)] pub enum jsgf_rule_t {}
40#[allow(non_camel_case_types)] pub enum jsfg_rule_iter_t {}
41
42#[link(name="pocketsphinx")]
43extern {
44
45    pub fn jsgf_grammar_new(parent: *const jsgf_t) -> *mut jsgf_t;
46    pub fn jsgf_parse_file(filename: *const c_char, parent: *const jsgf_t) -> *mut jsgf_t;
47    pub fn jsgf_parse_string(s: *const c_char, parent: *const jsgf_t) -> *mut jsgf_t;
48    pub fn jsgf_grammar_name(jsgf: *const jsgf_t) -> *const c_char;
49    pub fn jsgf_grammar_free(jsgf: *mut jsgf_t);
50    pub fn jsgf_rule_iter(grammar: *const jsgf_t) -> *mut jsgf_rule_iter_t;
51    pub fn jsgf_get_rule(grammar: *const jsgf_t, name: *const c_char) -> *const jsgf_rule_t;
52    pub fn jsgf_get_public_rule(grammar: *const jsgf_t) -> *const jsgf_rule_t;
53    pub fn jsgf_rule_name(rule: *const jsgf_rule_t) -> *const c_char;
54    pub fn jsgf_rule_public(rule: *const jsgf_rule_t) -> c_int;
55    //pub fn jsgf_build_fsg(grammar: *const jsgf_t, rule: *const jsgf_rule_t, lmath: *const logmath_t, lw: f32) -> *mut fsg_model_t;
56    //pub fn jsgf_build_fsg_raw(grammar: *const jsgf_t, rule: *const jsgf_rule_t, lmath: *const logmath_t, lw: f32) -> *mut fsg_model_t;
57    //pub fn jsgf_read_file(file: *const c_char, lmath: *const logmath_t, lw: f32) -> *mut fsg_model_t;
58    //pub fn jsgf_read_string(s: *const c_char, lmath: *const logmath_t, lw: f32) -> *mut fsg_model_t;
59    //pub fn jsgf_write_fsg(grammar: *const jsgf_t, rule: *const jsgf_rule_t, outfh: *mut libc::FILE) -> c_int;
60
61}
62
63// Following functions are Rust implementation of C macros
64pub unsafe fn jsgf_rule_iter_next(it: *const jsgf_rule_iter_t) -> *const jsgf_rule_iter_t {
65    hash_table_iter_next(it)
66}
67pub unsafe fn jsgf_rule_iter_rule(it: *const jsgf_rule_iter_t) -> *const jsgf_rule_t {
68    hash_entry_val((*it).ent) as *const jsgf_rule_t
69}
70pub unsafe fn jsgf_rule_iter_free(it: *const jsgf_rule_iter_t) {
71    hash_table_iter_free(it);
72}