webidl: move first pass logic to new module

I also updated it so that it is modeled in the same
extensible way as the WebidlParse trait.
This commit is contained in:
R. Andrew Ohana
2018-07-13 21:46:36 -07:00
parent 5b952f2081
commit d5fee8d5d1
4 changed files with 263 additions and 137 deletions

View File

@ -1,4 +1,3 @@
use std::collections::{BTreeMap, BTreeSet};
use std::iter::{self, FromIterator};
use backend;
@ -9,6 +8,8 @@ use syn;
use webidl;
use webidl::ast::ExtendedAttribute;
use first_pass::FirstPassRecord;
fn shared_ref(ty: syn::Type) -> syn::Type {
syn::TypeReference {
and_token: Default::default(),
@ -64,21 +65,7 @@ pub enum TypePosition {
Return,
}
#[derive(Default)]
pub struct FirstPass<'a> {
pub interfaces: BTreeSet<String>,
pub dictionaries: BTreeSet<String>,
pub enums: BTreeSet<String>,
pub mixins: BTreeMap<String, MixinData<'a>>,
}
#[derive(Default)]
pub struct MixinData<'a> {
pub non_partial: Option<&'a webidl::ast::NonPartialMixin>,
pub partials: Vec<&'a webidl::ast::PartialMixin>,
}
impl<'a> FirstPass<'a> {
impl<'a> FirstPassRecord<'a> {
pub fn webidl_ty_to_syn_ty(
&self,
ty: &webidl::ast::Type,