diff options
author | Minijackson <minijackson@riseup.net> | 2020-02-23 17:06:27 +0100 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2020-02-23 17:06:27 +0100 |
commit | 5d110cef951c5ef6c5d988c0d3a7431c4ea5de2e (patch) | |
tree | 4cb0686d0ec41bd49c58fdcbdae410e5d698f9cb /src/parser/clang | |
parent | 5b137e8bb767aa2b381e9d5a0710583c4edaa889 (diff) | |
download | poseidoc-5d110cef951c5ef6c5d988c0d3a7431c4ea5de2e.tar.gz poseidoc-5d110cef951c5ef6c5d988c0d3a7431c4ea5de2e.zip |
clang-parser: remove unused commented code
Diffstat (limited to 'src/parser/clang')
-rw-r--r-- | src/parser/clang/entities.rs | 137 |
1 files changed, 0 insertions, 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<T> { | |||
91 | type DescribedDynEntity = Described<DynEntity>; | 91 | type DescribedDynEntity = Described<DynEntity>; |
92 | 92 | ||
93 | impl<T: Entity> Described<T> { | 93 | impl<T: Entity> Described<T> { |
94 | /* | ||
95 | fn into_dyn(self) -> Described<DynEntity> { | ||
96 | Described { | ||
97 | description: self.description, | ||
98 | entity: self.entity.into_dyn(), | ||
99 | } | ||
100 | } | ||
101 | */ | ||
102 | |||
103 | fn to_dyn(&self) -> DescribedRef<DynEntityRef> { | 94 | fn to_dyn(&self) -> DescribedRef<DynEntityRef> { |
104 | DescribedRef { | 95 | DescribedRef { |
105 | description: &self.description, | 96 | description: &self.description, |
@@ -155,17 +146,6 @@ pub(super) struct DescribedRef<'a, T> { | |||
155 | 146 | ||
156 | type DescribedDynEntityRef<'d, 'e> = DescribedRef<'d, DynEntityRef<'e>>; | 147 | type DescribedDynEntityRef<'d, 'e> = DescribedRef<'d, DynEntityRef<'e>>; |
157 | 148 | ||
158 | /* | ||
159 | impl<'d, 'e, T: Entity> DescribedRef<'d, &'e T> { | ||
160 | fn from_dyn_ref(dyn_entity: DescribedDynEntityRef<'d, 'e>) -> Option<Self> { | ||
161 | Some(DescribedRef { | ||
162 | description: dyn_entity.description, | ||
163 | entity: Entity::from_dyn_ref(dyn_entity.entity)?, | ||
164 | }) | ||
165 | } | ||
166 | } | ||
167 | */ | ||
168 | |||
169 | #[derive(Debug, Clone)] | 149 | #[derive(Debug, Clone)] |
170 | pub(super) struct DescribedRefMut<'a, T> { | 150 | pub(super) struct DescribedRefMut<'a, T> { |
171 | pub description: &'a Description, | 151 | pub description: &'a Description, |
@@ -186,26 +166,6 @@ impl<'d, 'e, T: Entity> DescribedRefMut<'d, &'e mut T> { | |||
186 | pub(super) trait Entity: Traversable + KindName { | 166 | pub(super) trait Entity: Traversable + KindName { |
187 | const KIND: EntityKind; | 167 | const KIND: EntityKind; |
188 | 168 | ||
189 | /* | ||
190 | /// Transform a generic entity to a specific entity | ||
191 | fn try_into_specific<T: Entity>(self) -> Option<T> | ||
192 | where | ||
193 | Self: Sized, | ||
194 | { | ||
195 | T::from_dyn(self.into_dyn()) | ||
196 | } | ||
197 | |||
198 | /// Transform a generic entity to a specific entity | ||
199 | /// | ||
200 | /// Panics if not the right entity kind | ||
201 | fn into_specific<T: Entity>(self) -> T | ||
202 | where | ||
203 | Self: Sized, | ||
204 | { | ||
205 | self.try_into_specific().unwrap() | ||
206 | } | ||
207 | */ | ||
208 | |||
209 | fn from_dyn(dyn_entity: DynEntity) -> Option<Self> | 169 | fn from_dyn(dyn_entity: DynEntity) -> Option<Self> |
210 | where | 170 | where |
211 | Self: Sized; | 171 | Self: Sized; |
@@ -465,25 +425,6 @@ pub(super) enum TopLevelEntryError { | |||
465 | } | 425 | } |
466 | 426 | ||
467 | impl TopLevel { | 427 | impl TopLevel { |
468 | /* | ||
469 | pub(super) fn get_dyn(&self, path: clang::Entity) -> Option<DescribedDynEntityRef> { | ||
470 | if path.get_kind() == clang::EntityKind::TranslationUnit { | ||
471 | return Some(self.0.to_dyn()); | ||
472 | } | ||
473 | let usr = path.get_usr()?; | ||
474 | let parent_path = path | ||
475 | .get_semantic_parent() | ||
476 | .expect("get_semantic_parent() returned None"); | ||
477 | |||
478 | let kind = path.get_kind().try_into().ok()?; | ||
479 | self.get_dyn(parent_path).and_then(|parent| { | ||
480 | parent | ||
481 | .entity | ||
482 | .map(|parent| parent.get_child_from_kind(&usr, kind)) | ||
483 | }) | ||
484 | } | ||
485 | */ | ||
486 | |||
487 | pub(super) fn get_dyn_mut(&mut self, path: clang::Entity) -> Option<DescribedDynEntityRefMut> { | 428 | pub(super) fn get_dyn_mut(&mut self, path: clang::Entity) -> Option<DescribedDynEntityRefMut> { |
488 | if path.get_kind() == clang::EntityKind::TranslationUnit { | 429 | if path.get_kind() == clang::EntityKind::TranslationUnit { |
489 | return Some(self.0.to_dyn_mut()); | 430 | return Some(self.0.to_dyn_mut()); |
@@ -501,49 +442,6 @@ impl TopLevel { | |||
501 | }) | 442 | }) |
502 | } | 443 | } |
503 | 444 | ||
504 | /* | ||
505 | pub(super) fn get<T>(&self, path: clang::Entity) -> Option<DescribedRef<&T>> | ||
506 | where | ||
507 | T: Entity, | ||
508 | { | ||
509 | assert_eq!(path.get_kind().try_into(), Ok(T::KIND),); | ||
510 | self.get_dyn(path).and_then(DescribedRef::from_dyn_ref) | ||
511 | } | ||
512 | |||
513 | pub(super) fn get_mut<T>(&mut self, path: clang::Entity) -> Option<DescribedRefMut<&mut T>> | ||
514 | where | ||
515 | T: Entity, | ||
516 | { | ||
517 | assert_eq!(path.get_kind().try_into(), Ok(T::KIND),); | ||
518 | self.get_dyn_mut(path) | ||
519 | .and_then(DescribedRefMut::from_dyn_mut) | ||
520 | } | ||
521 | |||
522 | pub(super) fn insert_dyn( | ||
523 | &mut self, | ||
524 | path: clang::Entity, | ||
525 | entity: DescribedDynEntity, | ||
526 | ) -> Result<()> { | ||
527 | let usr = path.get_usr().ok_or_else(|| anyhow!("no usr"))?; | ||
528 | let parent_path = path | ||
529 | .get_semantic_parent() | ||
530 | .ok_or_else(|| anyhow!("Trying to insert the global namespace"))?; | ||
531 | |||
532 | self.get_dyn_mut(parent_path) | ||
533 | .map(|described_entity| described_entity.entity) | ||
534 | // TODO: Properly define an error | ||
535 | .ok_or_else(|| anyhow!("has parent: {:?} but no parent in tree", parent_path))? | ||
536 | .map(|parent| parent.insert(usr, entity)) | ||
537 | } | ||
538 | |||
539 | pub(super) fn insert<T>(&mut self, path: clang::Entity, entity: Described<T>) -> Result<()> | ||
540 | where | ||
541 | T: Entity, | ||
542 | { | ||
543 | self.insert_dyn(path, entity.into_dyn()) | ||
544 | } | ||
545 | */ | ||
546 | |||
547 | // TODO: does not check whether a vacant entry is allowed to be in parent. | 445 | // TODO: does not check whether a vacant entry is allowed to be in parent. |
548 | // For example, it can return a vacant EnumConstant inside a Struct. | 446 | // For example, it can return a vacant EnumConstant inside a Struct. |
549 | pub(super) fn entry_dyn( | 447 | pub(super) fn entry_dyn( |
@@ -590,22 +488,6 @@ impl TopLevel { | |||
590 | } | 488 | } |
591 | } | 489 | } |
592 | 490 | ||
593 | /* | ||
594 | pub(super) fn entry<T>( | ||
595 | &mut self, | ||
596 | path: clang::Entity, | ||
597 | ) -> Result<EntityEntry<&mut T>, TopLevelEntryError> | ||
598 | where | ||
599 | T: Entity, | ||
600 | { | ||
601 | Ok(match self.entry_dyn(path)? { | ||
602 | EntityEntry::Occupied { entity } => EntityEntry::Occupied { | ||
603 | entity: DescribedRefMut::from_dyn_mut(entity).unwrap(), | ||
604 | }, | ||
605 | EntityEntry::Vacant { parent } => EntityEntry::Vacant { parent }, | ||
606 | }) | ||
607 | } | ||
608 | */ | ||
609 | } | 491 | } |
610 | 492 | ||
611 | // TODO: all of the DynEntity business can probably be macro generated too | 493 | // TODO: all of the DynEntity business can probably be macro generated too |
@@ -632,25 +514,6 @@ pub(super) enum DynEntityRef<'a> { | |||
632 | TypeAlias(&'a TypeAlias), | 514 | TypeAlias(&'a TypeAlias), |
633 | } | 515 | } |
634 | 516 | ||
635 | /* | ||
636 | impl<'a> DynEntityRef<'a> { | ||
637 | fn map<U, F>(&self, f: F) -> U | ||
638 | where | ||
639 | F: FnOnce(&'a dyn Traversable) -> U, | ||
640 | { | ||
641 | match self { | ||
642 | DynEntityRef::Namespace(namespace) => f(*namespace), | ||
643 | DynEntityRef::Variable(variable) => f(*variable), | ||
644 | DynEntityRef::Struct(r#struct) => f(*r#struct), | ||
645 | DynEntityRef::Function(function) => f(*function), | ||
646 | DynEntityRef::Enum(Enum) => f(*Enum), | ||
647 | DynEntityRef::EnumConstant(enum_constant) => f(*enum_constant), | ||
648 | DynEntityRef::TypeAlias(type_alias) => f(*type_alias), | ||
649 | } | ||
650 | } | ||
651 | } | ||
652 | */ | ||
653 | |||
654 | #[derive(Debug)] | 517 | #[derive(Debug)] |
655 | pub(super) enum DynEntityRefMut<'a> { | 518 | pub(super) enum DynEntityRefMut<'a> { |
656 | Namespace(&'a mut Namespace), | 519 | Namespace(&'a mut Namespace), |