Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- SBSourceManager.cpp -------------------------------------*- 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 | |
Eli Friedman | 7a62c8b | 2010-06-09 07:44:37 +0000 | [diff] [blame] | 11 | #include "lldb/API/SBSourceManager.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 12 | |
| 13 | #include "lldb/API/SBFileSpec.h" |
| 14 | #include "lldb/Core/Stream.h" |
| 15 | #include "lldb/Core/StreamFile.h" |
| 16 | #include "lldb/Core/SourceManager.h" |
| 17 | |
| 18 | |
| 19 | using namespace lldb; |
| 20 | using namespace lldb_private; |
| 21 | |
| 22 | |
Greg Clayton | 538eb82 | 2010-11-05 23:17:00 +0000 | [diff] [blame] | 23 | SBSourceManager::SBSourceManager (SourceManager* source_manager) : |
| 24 | m_opaque_ptr (source_manager) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 25 | { |
| 26 | } |
| 27 | |
| 28 | SBSourceManager::~SBSourceManager() |
| 29 | { |
| 30 | } |
| 31 | |
Greg Clayton | 538eb82 | 2010-11-05 23:17:00 +0000 | [diff] [blame] | 32 | SBSourceManager::SBSourceManager(const SBSourceManager &rhs) : |
| 33 | m_opaque_ptr (rhs.m_opaque_ptr) |
| 34 | { |
| 35 | } |
| 36 | |
| 37 | const SBSourceManager & |
| 38 | SBSourceManager::operator = (const SBSourceManager &rhs) |
| 39 | { |
| 40 | m_opaque_ptr = rhs.m_opaque_ptr; |
| 41 | return *this; |
| 42 | } |
| 43 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 44 | size_t |
| 45 | SBSourceManager::DisplaySourceLinesWithLineNumbers |
| 46 | ( |
| 47 | const SBFileSpec &file, |
| 48 | uint32_t line, |
| 49 | uint32_t context_before, |
| 50 | uint32_t context_after, |
| 51 | const char* current_line_cstr, |
| 52 | FILE *f |
| 53 | ) |
| 54 | { |
Greg Clayton | 538eb82 | 2010-11-05 23:17:00 +0000 | [diff] [blame] | 55 | if (m_opaque_ptr == NULL) |
| 56 | return 0; |
| 57 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 58 | if (f == NULL) |
| 59 | return 0; |
| 60 | |
| 61 | if (file.IsValid()) |
| 62 | { |
| 63 | StreamFile str (f); |
| 64 | |
| 65 | |
Greg Clayton | 538eb82 | 2010-11-05 23:17:00 +0000 | [diff] [blame] | 66 | return m_opaque_ptr->DisplaySourceLinesWithLineNumbers (*file, |
| 67 | line, |
| 68 | context_before, |
| 69 | context_after, |
| 70 | current_line_cstr, |
| 71 | &str); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 72 | } |
| 73 | return 0; |
| 74 | } |