From b51abe9b5f76e5d06d348c8ef2d0a7cd9d797b58 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sat, 13 Feb 2010 18:33:03 +0000 Subject: [PATCH] cindex/Python: Update for clang_getDiagnosticRange... API changes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96105 91177308-0d34-0410-b5e6-96231b3b80d8 --- bindings/python/clang/cindex.py | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py index 45a75b44c4..b6383fb228 100644 --- a/bindings/python/clang/cindex.py +++ b/bindings/python/clang/cindex.py @@ -555,15 +555,13 @@ _clang_getDiagnosticSpelling.argtypes = [c_object_p] _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_getDiagnosticNumRanges = lib.clang_getDiagnosticNumRanges +_clang_getDiagnosticNumRanges.argtypes = [c_object_p] +_clang_getDiagnosticNumRanges.restype = c_uint -_clang_disposeDiagnosticRanges = lib.clang_disposeDiagnosticRanges -_clang_disposeDiagnosticRanges.argtypes = [POINTER(SourceRange), c_uint] -_clang_disposeDiagnosticRanges.restype = None +_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 @@ def _convert_diag(diag_ptr, diag_list): 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))] -- 2.40.0