we now parse witx paths and the ctx type name in the macro invocation

This commit is contained in:
Pat Hickey
2020-01-30 16:38:16 -08:00
parent 0ba8e73184
commit 29c3ef9d09
5 changed files with 96 additions and 55 deletions

View File

@@ -3,14 +3,19 @@ use proc_macro2::{Ident, TokenStream};
use quote::{format_ident, quote};
use witx::{AtomType, BuiltinType, Id, TypeRef};
use crate::Config;
#[derive(Debug, Clone)]
pub struct Names {
// FIXME: overrides go in here, so we can map e.g. 2big => TooBig
config: Config,
}
impl Names {
pub fn new() -> Names {
Names {}
pub fn new(config: Config) -> Names {
Names { config }
}
pub fn ctx_type(&self) -> Ident {
self.config.ctx.name.clone()
}
pub fn type_(&self, id: &Id) -> TokenStream {
let ident = format_ident!("{}", id.as_str().to_camel_case());