- Notifications
You must be signed in to change notification settings - Fork 15.3k
Closed
Labels
clang:as-a-librarylibclang and C++ APIlibclang and C++ API
Description
In the libclang/python bindings, we currently have 43 library library functions registered as ctypes functions returning bool. None of the libclang functions on C-side seem to return booleans, instead they return unsigned (and sometimes signed) ints.
The ctypes module seems to automatically cast the actual unsigned return values to a value of the registered bool type, which works as expected: a return of 0 is interpreted as false, all other returns are interpreted as true.
However, this makes the code confusing to read as it obfuscates the real return type of these library functions in the bindings code. The library functions should be registered with return types matching their declaration, e.g. c_uint.
This means
- checking all
boolreturn types in theFUNCTION_LISTand adapting their return types toc_uintorc_intrespectively - adding a
boolcast to the return of all functions directly returning the results of these library functions - removing
type: ignore [no-any-return]annotations where such a cast is applied
Endilll
Metadata
Metadata
Assignees
Labels
clang:as-a-librarylibclang and C++ APIlibclang and C++ API