From 5d110cef951c5ef6c5d988c0d3a7431c4ea5de2e Mon Sep 17 00:00:00 2001 From: Minijackson Date: Sun, 23 Feb 2020 17:06:27 +0100 Subject: clang-parser: remove unused commented code --- src/parser/clang/entities.rs | 137 ------------------------------------------- 1 file changed, 137 deletions(-) diff --git a/src/parser/clang/entities.rs b/src/parser/clang/entities.rs index b1689aa..7b98e88 100644 --- a/src/parser/clang/entities.rs +++ b/src/parser/clang/entities.rs @@ -91,15 +91,6 @@ pub(super) struct Described { type DescribedDynEntity = Described; impl Described { - /* - fn into_dyn(self) -> Described { - Described { - description: self.description, - entity: self.entity.into_dyn(), - } - } - */ - fn to_dyn(&self) -> DescribedRef { DescribedRef { description: &self.description, @@ -155,17 +146,6 @@ pub(super) struct DescribedRef<'a, T> { type DescribedDynEntityRef<'d, 'e> = DescribedRef<'d, DynEntityRef<'e>>; -/* -impl<'d, 'e, T: Entity> DescribedRef<'d, &'e T> { - fn from_dyn_ref(dyn_entity: DescribedDynEntityRef<'d, 'e>) -> Option { - Some(DescribedRef { - description: dyn_entity.description, - entity: Entity::from_dyn_ref(dyn_entity.entity)?, - }) - } -} -*/ - #[derive(Debug, Clone)] pub(super) struct DescribedRefMut<'a, T> { pub description: &'a Description, @@ -186,26 +166,6 @@ impl<'d, 'e, T: Entity> DescribedRefMut<'d, &'e mut T> { pub(super) trait Entity: Traversable + KindName { const KIND: EntityKind; - /* - /// Transform a generic entity to a specific entity - fn try_into_specific(self) -> Option - where - Self: Sized, - { - T::from_dyn(self.into_dyn()) - } - - /// Transform a generic entity to a specific entity - /// - /// Panics if not the right entity kind - fn into_specific(self) -> T - where - Self: Sized, - { - self.try_into_specific().unwrap() - } - */ - fn from_dyn(dyn_entity: DynEntity) -> Option where Self: Sized; @@ -465,25 +425,6 @@ pub(super) enum TopLevelEntryError { } impl TopLevel { - /* - pub(super) fn get_dyn(&self, path: clang::Entity) -> Option { - if path.get_kind() == clang::EntityKind::TranslationUnit { - return Some(self.0.to_dyn()); - } - let usr = path.get_usr()?; - let parent_path = path - .get_semantic_parent() - .expect("get_semantic_parent() returned None"); - - let kind = path.get_kind().try_into().ok()?; - self.get_dyn(parent_path).and_then(|parent| { - parent - .entity - .map(|parent| parent.get_child_from_kind(&usr, kind)) - }) - } - */ - pub(super) fn get_dyn_mut(&mut self, path: clang::Entity) -> Option { if path.get_kind() == clang::EntityKind::TranslationUnit { return Some(self.0.to_dyn_mut()); @@ -501,49 +442,6 @@ impl TopLevel { }) } - /* - pub(super) fn get(&self, path: clang::Entity) -> Option> - where - T: Entity, - { - assert_eq!(path.get_kind().try_into(), Ok(T::KIND),); - self.get_dyn(path).and_then(DescribedRef::from_dyn_ref) - } - - pub(super) fn get_mut(&mut self, path: clang::Entity) -> Option> - where - T: Entity, - { - assert_eq!(path.get_kind().try_into(), Ok(T::KIND),); - self.get_dyn_mut(path) - .and_then(DescribedRefMut::from_dyn_mut) - } - - pub(super) fn insert_dyn( - &mut self, - path: clang::Entity, - entity: DescribedDynEntity, - ) -> Result<()> { - let usr = path.get_usr().ok_or_else(|| anyhow!("no usr"))?; - let parent_path = path - .get_semantic_parent() - .ok_or_else(|| anyhow!("Trying to insert the global namespace"))?; - - self.get_dyn_mut(parent_path) - .map(|described_entity| described_entity.entity) - // TODO: Properly define an error - .ok_or_else(|| anyhow!("has parent: {:?} but no parent in tree", parent_path))? - .map(|parent| parent.insert(usr, entity)) - } - - pub(super) fn insert(&mut self, path: clang::Entity, entity: Described) -> Result<()> - where - T: Entity, - { - self.insert_dyn(path, entity.into_dyn()) - } - */ - // TODO: does not check whether a vacant entry is allowed to be in parent. // For example, it can return a vacant EnumConstant inside a Struct. pub(super) fn entry_dyn( @@ -590,22 +488,6 @@ impl TopLevel { } } - /* - pub(super) fn entry( - &mut self, - path: clang::Entity, - ) -> Result, TopLevelEntryError> - where - T: Entity, - { - Ok(match self.entry_dyn(path)? { - EntityEntry::Occupied { entity } => EntityEntry::Occupied { - entity: DescribedRefMut::from_dyn_mut(entity).unwrap(), - }, - EntityEntry::Vacant { parent } => EntityEntry::Vacant { parent }, - }) - } - */ } // TODO: all of the DynEntity business can probably be macro generated too @@ -632,25 +514,6 @@ pub(super) enum DynEntityRef<'a> { TypeAlias(&'a TypeAlias), } -/* -impl<'a> DynEntityRef<'a> { - fn map(&self, f: F) -> U - where - F: FnOnce(&'a dyn Traversable) -> U, - { - match self { - DynEntityRef::Namespace(namespace) => f(*namespace), - DynEntityRef::Variable(variable) => f(*variable), - DynEntityRef::Struct(r#struct) => f(*r#struct), - DynEntityRef::Function(function) => f(*function), - DynEntityRef::Enum(Enum) => f(*Enum), - DynEntityRef::EnumConstant(enum_constant) => f(*enum_constant), - DynEntityRef::TypeAlias(type_alias) => f(*type_alias), - } - } -} -*/ - #[derive(Debug)] pub(super) enum DynEntityRefMut<'a> { Namespace(&'a mut Namespace), -- cgit v1.2.3