Move C++-specific namespace code unused by the proc macro

This commit is contained in:
David Tolnay 2020-11-01 22:53:37 -08:00
parent 6edeaab3cb
commit 90b133b553
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
3 changed files with 15 additions and 13 deletions

View File

@ -9,6 +9,7 @@ mod file;
pub(super) mod fs;
mod ifndef;
pub(super) mod include;
mod namespace;
mod nested;
pub(super) mod out;
mod write;

14
gen/src/namespace.rs Normal file
View File

@ -0,0 +1,14 @@
use crate::syntax::namespace::Namespace;
use crate::syntax::Api;
impl Api {
pub fn namespace(&self) -> &Namespace {
match self {
Api::CxxFunction(efn) | Api::RustFunction(efn) => &efn.ident.cxx.namespace,
Api::CxxType(ety) | Api::RustType(ety) => &ety.ident.cxx.namespace,
Api::Enum(enm) => &enm.ident.cxx.namespace,
Api::Struct(strct) => &strct.ident.cxx.namespace,
Api::Impl(_) | Api::Include(_) | Api::TypeAlias(_) => Default::default(),
}
}
}

View File

@ -1,5 +1,4 @@
use crate::syntax::qualified::QualifiedName;
use crate::syntax::Api;
use quote::IdentFragment;
use std::fmt::{self, Display};
use std::iter::FromIterator;
@ -84,15 +83,3 @@ impl<'a> FromIterator<&'a Ident> for Namespace {
Namespace { segments }
}
}
impl Api {
pub fn namespace(&self) -> &Namespace {
match self {
Api::CxxFunction(efn) | Api::RustFunction(efn) => &efn.ident.cxx.namespace,
Api::CxxType(ety) | Api::RustType(ety) => &ety.ident.cxx.namespace,
Api::Enum(enm) => &enm.ident.cxx.namespace,
Api::Struct(strct) => &strct.ident.cxx.namespace,
Api::Impl(_) | Api::Include(_) | Api::TypeAlias(_) => Default::default(),
}
}
}