Zachary Turner | 679aead | 2018-03-13 17:46:06 +0000 | [diff] [blame] | 1 | //==- DIAEnumSourceFiles.cpp - DIA Source File Enumerator impl ---*- C++ -*-==// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "llvm/DebugInfo/PDB/DIA/DIAEnumInjectedSources.h" |
| 11 | #include "llvm/DebugInfo/PDB/DIA/DIAInjectedSource.h" |
| 12 | #include "llvm/DebugInfo/PDB/PDBSymbol.h" |
| 13 | |
| 14 | using namespace llvm; |
| 15 | using namespace llvm::pdb; |
| 16 | |
| 17 | DIAEnumInjectedSources::DIAEnumInjectedSources( |
| 18 | const DIASession &PDBSession, |
| 19 | CComPtr<IDiaEnumInjectedSources> DiaEnumerator) |
| 20 | : Session(PDBSession), Enumerator(DiaEnumerator) {} |
| 21 | |
| 22 | uint32_t DIAEnumInjectedSources::getChildCount() const { |
| 23 | LONG Count = 0; |
| 24 | return (S_OK == Enumerator->get_Count(&Count)) ? Count : 0; |
| 25 | } |
| 26 | |
| 27 | std::unique_ptr<IPDBInjectedSource> |
| 28 | DIAEnumInjectedSources::getChildAtIndex(uint32_t Index) const { |
| 29 | CComPtr<IDiaInjectedSource> Item; |
| 30 | if (S_OK != Enumerator->Item(Index, &Item)) |
| 31 | return nullptr; |
| 32 | |
Reid Kleckner | 8562c1a | 2018-03-21 21:47:26 +0000 | [diff] [blame] | 33 | return std::unique_ptr<IPDBInjectedSource>(new DIAInjectedSource(Item)); |
Zachary Turner | 679aead | 2018-03-13 17:46:06 +0000 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | std::unique_ptr<IPDBInjectedSource> DIAEnumInjectedSources::getNext() { |
| 37 | CComPtr<IDiaInjectedSource> Item; |
| 38 | ULONG NumFetched = 0; |
| 39 | if (S_OK != Enumerator->Next(1, &Item, &NumFetched)) |
| 40 | return nullptr; |
| 41 | |
Reid Kleckner | 8562c1a | 2018-03-21 21:47:26 +0000 | [diff] [blame] | 42 | return std::unique_ptr<IPDBInjectedSource>(new DIAInjectedSource(Item)); |
Zachary Turner | 679aead | 2018-03-13 17:46:06 +0000 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | void DIAEnumInjectedSources::reset() { Enumerator->Reset(); } |
| 46 | |
| 47 | DIAEnumInjectedSources *DIAEnumInjectedSources::clone() const { |
| 48 | CComPtr<IDiaEnumInjectedSources> EnumeratorClone; |
| 49 | if (S_OK != Enumerator->Clone(&EnumeratorClone)) |
| 50 | return nullptr; |
| 51 | return new DIAEnumInjectedSources(Session, EnumeratorClone); |
| 52 | } |