aboutsummaryrefslogtreecommitdiff
path: root/bindings/python/clang/cindex.py
diff options
context:
space:
mode:
authorTobias Grosser <grosser@fim.uni-passau.de>2011-10-31 00:07:19 +0000
committerTobias Grosser <grosser@fim.uni-passau.de>2011-10-31 00:07:19 +0000
commita9ea5df14abb807eb0173e2737c5a1d61e86975b (patch)
tree62701988e18bacf57dca147610376fb1731c2f5a /bindings/python/clang/cindex.py
parent7993e8a2a26bf408c2a6d45f24fffa12db336b2b (diff)
cindex.py: Add File.create_from_name()
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143321 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings/python/clang/cindex.py')
-rw-r--r--bindings/python/clang/cindex.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
index 1c4ab35e4a..c66e3563c9 100644
--- a/bindings/python/clang/cindex.py
+++ b/bindings/python/clang/cindex.py
@@ -1523,6 +1523,11 @@ class File(ClangObject):
translation unit.
"""
+ @staticmethod
+ def from_name(translation_unit, file_name):
+ """Retrieve a file handle within the given translation unit."""
+ return File(File_getFile(translation_unit, file_name))
+
@property
def name(self):
"""Return the complete file and path name of the file."""
@@ -1533,6 +1538,12 @@ class File(ClangObject):
"""Return the last modification time of the file."""
return File_time(self)
+ def __str__(self):
+ return self.name
+
+ def __repr__(self):
+ return "<File: %s>" % (self.name)
+
class FileInclusion(object):
"""
The FileInclusion class represents the inclusion of one source file by
@@ -1759,6 +1770,10 @@ TranslationUnit_includes.argtypes = [TranslationUnit,
py_object]
# File Functions
+File_getFile = lib.clang_getFile
+File_getFile.argtypes = [TranslationUnit, c_char_p]
+File_getFile.restype = c_object_p
+
File_name = lib.clang_getFileName
File_name.argtypes = [File]
File_name.restype = _CXString