[cfe-commits] r96105 - /cfe/trunk/bindings/python/clang/cindex.py

Daniel Dunbar daniel at zuster.org
Sat Feb 13 10:33:03 PST 2010


Author: ddunbar
Date: Sat Feb 13 12:33:03 2010
New Revision: 96105

URL: http://llvm.org/viewvc/llvm-project?rev=96105&view=rev
Log:
cindex/Python: Update for clang_getDiagnosticRange... API changes.

Modified:
    cfe/trunk/bindings/python/clang/cindex.py

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=96105&r1=96104&r2=96105&view=diff

==============================================================================
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Sat Feb 13 12:33:03 2010
@@ -555,15 +555,13 @@
 _clang_getDiagnosticSpelling.restype = _CXString
 _clang_getDiagnosticSpelling.errcheck = _CXString.from_result
 
-_clang_getDiagnosticRanges = lib.clang_getDiagnosticRanges
-_clang_getDiagnosticRanges.argtypes = [c_object_p,
-                                       POINTER(POINTER(SourceRange)),
-                                       POINTER(c_uint)]
-_clang_getDiagnosticRanges.restype = None
-
-_clang_disposeDiagnosticRanges = lib.clang_disposeDiagnosticRanges
-_clang_disposeDiagnosticRanges.argtypes = [POINTER(SourceRange), c_uint]
-_clang_disposeDiagnosticRanges.restype = None
+_clang_getDiagnosticNumRanges = lib.clang_getDiagnosticNumRanges
+_clang_getDiagnosticNumRanges.argtypes = [c_object_p]
+_clang_getDiagnosticNumRanges.restype = c_uint
+
+_clang_getDiagnosticRange = lib.clang_getDiagnosticRange
+_clang_getDiagnosticRange.argtypes = [c_object_p, c_uint]
+_clang_getDiagnosticRange.restype = SourceRange
 
 _clang_getDiagnosticNumFixIts = lib.clang_getDiagnosticNumFixIts
 _clang_getDiagnosticNumFixIts.argtypes = [c_object_p]
@@ -622,16 +620,9 @@
     spelling = _clang_getDiagnosticSpelling(diag_ptr)
 
     # Diagnostic ranges.
-    #
-    # FIXME: Use getNum... based API?
-    num_ranges = c_uint()
-    ranges_array = POINTER(SourceRange)()
-    _clang_getDiagnosticRanges(diag_ptr, byref(ranges_array), byref(num_ranges))
-
-    # Copy the ranges array so we can dispose the original.
-    ranges = [SourceRange.from_buffer_copy(ranges_array[i])
-              for i in range(num_ranges.value)]
-    _clang_disposeDiagnosticRanges(ranges_array, num_ranges)
+    num_ranges = _clang_getDiagnosticNumRanges(diag_ptr)
+    ranges = [_clang_getDiagnosticRange(diag_ptr, i)
+              for i in range(num_ranges)]
 
     fixits = [_convert_fixit(diag_ptr, i)
               for i in range(_clang_getDiagnosticNumFixIts(diag_ptr))]





More information about the cfe-commits mailing list