45 lines
1.5 KiB
Diff
45 lines
1.5 KiB
Diff
diff --git a/scripts/wrap/parse.py b/scripts/wrap/parse.py
|
|
index 1954101af..7079c8170 100644
|
|
--- a/scripts/wrap/parse.py
|
|
+++ b/scripts/wrap/parse.py
|
|
@@ -2,6 +2,7 @@
|
|
Support for accessing parse tree for MuPDF headers.
|
|
'''
|
|
|
|
+import collections
|
|
import os
|
|
import sys
|
|
import time
|
|
@@ -9,7 +10,7 @@ import time
|
|
import jlib
|
|
|
|
try:
|
|
- import clang
|
|
+ import clang.cindex
|
|
except ImportError as e:
|
|
jlib.log( 'Warning, could not import clang: {e}')
|
|
clang = None
|
|
@@ -487,6 +488,10 @@ class Arg:
|
|
|
|
get_args_cache = dict()
|
|
|
|
+# get_args() needs to know how to get something hashable from a clang.cindex.Cursor.
|
|
+if clang:
|
|
+ g_cursor_is_hashable = issubclass(clang.cindex.Cursor, collections.abc.Hashable)
|
|
+
|
|
def get_args( tu, cursor, include_fz_context=False, skip_first_alt=False, verbose=False):
|
|
'''
|
|
Yields Arg instance for each arg of the function at <cursor>.
|
|
@@ -509,7 +514,10 @@ def get_args( tu, cursor, include_fz_context=False, skip_first_alt=False, verbos
|
|
#
|
|
if verbose:
|
|
jlib.log( '## Looking at args of {cursor.spelling=}')
|
|
- key = tu, cursor.location.file, cursor.location.line, include_fz_context, skip_first_alt
|
|
+ if g_cursor_is_hashable:
|
|
+ key = tu, cursor, include_fz_context, skip_first_alt
|
|
+ else:
|
|
+ key = tu, cursor.location.file, cursor.location.line, include_fz_context, skip_first_alt
|
|
ret = get_args_cache.get( key)
|
|
if not verbose and state.state_.show_details(cursor.spelling):
|
|
verbose = True
|