Johnny Chen | fdc4a86 | 2011-07-19 22:41:47 +0000 | [diff] [blame] | 1 | //===-- SWIG Interface for SBFileSpec ---------------------------*- 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 | namespace lldb { |
| 11 | |
Johnny Chen | 5cb19e7 | 2011-07-20 01:06:37 +0000 | [diff] [blame] | 12 | %feature("docstring", |
Bruce Mitchener | d93c4a3 | 2014-07-01 21:22:11 +0000 | [diff] [blame] | 13 | "Represents a file specification that divides the path into a directory and |
Johnny Chen | 5cb19e7 | 2011-07-20 01:06:37 +0000 | [diff] [blame] | 14 | basename. The string values of the paths are put into uniqued string pools |
| 15 | for fast comparisons and efficient memory usage. |
| 16 | |
| 17 | For example, the following code |
| 18 | |
| 19 | lineEntry = context.GetLineEntry() |
| 20 | self.expect(lineEntry.GetFileSpec().GetDirectory(), 'The line entry should have the correct directory', |
| 21 | exe=False, |
| 22 | substrs = [self.mydir]) |
| 23 | self.expect(lineEntry.GetFileSpec().GetFilename(), 'The line entry should have the correct filename', |
| 24 | exe=False, |
| 25 | substrs = ['main.c']) |
| 26 | self.assertTrue(lineEntry.GetLine() == self.line, |
| 27 | 'The line entry's line number should match ') |
| 28 | |
| 29 | gets the line entry from the symbol context when a thread is stopped. |
| 30 | It gets the file spec corresponding to the line entry and checks that |
Bruce Mitchener | d93c4a3 | 2014-07-01 21:22:11 +0000 | [diff] [blame] | 31 | the filename and the directory matches what we expect. |
Johnny Chen | 5cb19e7 | 2011-07-20 01:06:37 +0000 | [diff] [blame] | 32 | ") SBFileSpec; |
Johnny Chen | fdc4a86 | 2011-07-19 22:41:47 +0000 | [diff] [blame] | 33 | class SBFileSpec |
| 34 | { |
| 35 | public: |
| 36 | SBFileSpec (); |
| 37 | |
| 38 | SBFileSpec (const lldb::SBFileSpec &rhs); |
| 39 | |
Bruce Mitchener | d93c4a3 | 2014-07-01 21:22:11 +0000 | [diff] [blame] | 40 | SBFileSpec (const char *path);// Deprecated, use SBFileSpec (const char *path, bool resolve) |
Johnny Chen | fdc4a86 | 2011-07-19 22:41:47 +0000 | [diff] [blame] | 41 | |
| 42 | SBFileSpec (const char *path, bool resolve); |
| 43 | |
| 44 | ~SBFileSpec (); |
| 45 | |
| 46 | bool |
| 47 | IsValid() const; |
| 48 | |
| 49 | bool |
| 50 | Exists () const; |
| 51 | |
| 52 | bool |
| 53 | ResolveExecutableLocation (); |
| 54 | |
| 55 | const char * |
| 56 | GetFilename() const; |
| 57 | |
| 58 | const char * |
| 59 | GetDirectory() const; |
| 60 | |
Greg Clayton | fbb7634 | 2013-11-20 21:07:01 +0000 | [diff] [blame] | 61 | void |
| 62 | SetFilename(const char *filename); |
| 63 | |
| 64 | void |
| 65 | SetDirectory(const char *directory); |
| 66 | |
Johnny Chen | fdc4a86 | 2011-07-19 22:41:47 +0000 | [diff] [blame] | 67 | uint32_t |
| 68 | GetPath (char *dst_path, size_t dst_len) const; |
| 69 | |
| 70 | static int |
| 71 | ResolvePath (const char *src_path, char *dst_path, size_t dst_len); |
| 72 | |
| 73 | bool |
| 74 | GetDescription (lldb::SBStream &description) const; |
Jason Molenda | 878ae01 | 2016-02-19 00:05:17 +0000 | [diff] [blame] | 75 | |
| 76 | void |
| 77 | AppendPathComponent (const char *file_or_directory); |
| 78 | |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 79 | %pythoncode %{ |
Greg Clayton | 6b2bd93 | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 80 | def __get_fullpath__(self): |
| 81 | spec_dir = self.GetDirectory() |
| 82 | spec_file = self.GetFilename() |
| 83 | if spec_dir and spec_file: |
| 84 | return '%s/%s' % (spec_dir, spec_file) |
| 85 | elif spec_dir: |
| 86 | return spec_dir |
| 87 | elif spec_file: |
| 88 | return spec_file |
| 89 | return None |
| 90 | |
| 91 | __swig_getmethods__["fullpath"] = __get_fullpath__ |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 92 | if _newclass: fullpath = property(__get_fullpath__, None, doc='''A read only property that returns the fullpath as a python string.''') |
Greg Clayton | 6b2bd93 | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 93 | |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 94 | __swig_getmethods__["basename"] = GetFilename |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 95 | if _newclass: basename = property(GetFilename, None, doc='''A read only property that returns the path basename as a python string.''') |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 96 | |
| 97 | __swig_getmethods__["dirname"] = GetDirectory |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 98 | if _newclass: dirname = property(GetDirectory, None, doc='''A read only property that returns the path directory name as a python string.''') |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 99 | |
| 100 | __swig_getmethods__["exists"] = Exists |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 101 | if _newclass: exists = property(Exists, None, doc='''A read only property that returns a boolean value that indicates if the file exists.''') |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 102 | %} |
| 103 | |
Johnny Chen | fdc4a86 | 2011-07-19 22:41:47 +0000 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | } // namespace lldb |