# --- T2-COPYRIGHT-BEGIN --- # t2/package/*/mupdf/hotfix-libclang.patch # Copyright (C) 2026 The T2 SDE Project # SPDX-License-Identifier: GPL-2.0 # --- T2-COPYRIGHT-END --- Newer libclang returns the forward declaration of a struct and spells anonymous records "struct (unnamed at ...)", so the C++ wrapper generator found neither the members nor the .refs member of e.g. fz_pixmap, and not the u.t.first_line iterator of fz_stext_block. --- mupdf-1.28.6-source.orig/scripts/wrap/parse.py +++ mupdf-1.28.6-source/scripts/wrap/parse.py @@ -120,6 +120,9 @@ def get_members( type_or_cursor, include cursor2 = cursor.underlying_typedef_type.get_declaration() else: cursor2 = cursor + definition = cursor2.get_definition() + if definition: + cursor2 = definition if 0: # Diagnostics to show the difference between @@ -252,6 +255,10 @@ def has_refs( tu, type_): if verbose: jlib.log( 'There is a keep() fn for this type so it uses reference counting: {keep_name=}') base_type_cursor = get_base_type( type_).get_declaration() + # newer libclang returns a forward declaration here + definition = base_type_cursor.get_definition() + if definition: + base_type_cursor = definition if base_type_cursor.is_definition(): if verbose: jlib.log( 'Type definition is available so we look for .refs member: {key=} {type_.spelling=} {fileline(base_type_cursor)=}') --- mupdf-1.28.6-source.orig/scripts/wrap/state.py +++ mupdf-1.28.6-source/scripts/wrap/state.py @@ -24,6 +24,15 @@ except Exception as e: f'or (OpenBSD only) `pkg_add py3-llvm.`\n' ) clang = None +else: + # newer libclang spells anonymous records "struct (unnamed at ...)", the + # generator expects the empty spelling of older libclang + _cursor_spelling = clang.cindex.Cursor.spelling + def _anonymous_spelling(self): + if self.kind in (clang.cindex.CursorKind.STRUCT_DECL, clang.cindex.CursorKind.UNION_DECL) and self.is_anonymous(): + return '' + return _cursor_spelling.fget(self) + clang.cindex.Cursor.spelling = property(_anonymous_spelling) omit_fns = [ 'fz_open_file_w',