pub struct CMeta {
pub symbols: SymbolTable,
pub macros: MacroTable,
}Expand description
Names a parse should already know.
The parser does not follow #include, so a translation unit that
uses uint32_t has no way to learn that it is a typedef name, and
uint32_t x; would parse uint32_t as the DECLARED name. The
canonical plugin solves this by letting a caller build a cmeta and
bind the names into it before the parse; this is the same thing.
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = tabnas_c::make();
let mut meta = tabnas_c::CMeta::new();
meta.symbols.bind_typedef("uint32_t");
let value = tabnas_c::parse_with_meta(&parser, "uint32_t x;", &meta)?;
assert_eq!(value.to_json()["kind"], "translation_unit");
Ok(())
}Fields§
§symbols: SymbolTableThe typedef names, and anything else bound, that the parse starts with.
macros: MacroTableThe macro names the parse starts with.
Implementations§
Source§impl CMeta
impl CMeta
Sourcepub fn new() -> Self
pub fn new() -> Self
An empty table pair, as makeCMeta() returns in the canonical
plugin and MakeCMeta() in the Go port.
Sourcepub fn to_value(&self) -> Value
pub fn to_value(&self) -> Value
The engine meta value this builds.
A Value cannot hold a native handle, so the tables travel as
the NAMES they hold rather than as themselves; the parse rebuilds
its own tables from them at file scope. A binding made in an
inner scope of a hand-built table therefore arrives at file
scope, which is where a header’s names belong anyway.