Skip to content

Use a single generator for the core and plugin Python bindings - #8593

Merged
bdash merged 1 commit into
devfrom
test_unified_python_generator
Oct 9, 2026
Merged

bdash merged 1 commit into
devfrom
test_unified_python_generator

Conversation

@bdash

@bdash bdash commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

WARP, shared cache and kernel cache each had their own fork of generator.cpp. The forks had missed the core generator's later fixes, including correctly sized enums, and each worked around core types differently, down to duplicating core enums in the plugin headers.

Now every binding uses the core generator. A plugin passes CORE_HEADER, and types declared there are imported from the core bindings rather than redefined.

@bdash
bdash requested a review from fuzyll October 8, 2026 15:58
@fuzyll fuzyll added this to the Langara milestone Oct 8, 2026

@fuzyll fuzyll left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I built and tested this and the only issue I could find was a mismatch in WarpProcessor. You can do this to repro:

bnpython3 -c 'from binaryninja.warp import WarpProcessor; WarpProcessor()'
  File ".../binaryninja/warp/warp.py", line 625, in __init__
    self.handle = warpcore.BNWARPNewProcessor(ctypes.c_int(included_data), ctypes.c_int(included_functions), worker_count)
  File ".../binaryninja/warp/_warpcore.py", line 1768, in BNWARPNewProcessor
    result = _BNWARPNewProcessor(includedData, includedFunctions, workerCount)
ctypes.ArgumentError: argument 1: TypeError: 'c_int' object cannot be interpreted as an integer

The new bindings correctly require 8-bit enum arguments, but the constructor still supplies ctypes.c_int. Otherwise, this looks good to me.

I don't know if the right move is to merge this and have someone else handle that edge case, or if we can just include a quick fix and then merge. So, consider this comment "conditional acceptance", and let me know if I should just file an issue.

@bdash

bdash commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Good catch. The fix for that is to remove the two ctypes.c_int calls from WarpProcessor.__init__. I'll squash it into this change.

I audited the rest of the various Python bindings and didn't see anywhere else with the same issue.

@bdash
bdash force-pushed the test_unified_python_generator branch from 95b7ae2 to b33757d Compare October 8, 2026 22:54
@bdash
bdash requested a review from fuzyll October 8, 2026 22:54
WARP, shared cache and kernel cache each had their own fork of
generator.cpp. The forks had missed the core generator's later fixes,
including correctly sized enums, and each worked around core types
differently, down to duplicating core enums in the plugin headers.

Now every binding uses the core generator. A plugin passes
`CORE_HEADER`, and types declared there are imported from the core
bindings rather than redefined.
@bdash
bdash force-pushed the test_unified_python_generator branch from b33757d to ff711ea Compare October 9, 2026 01:50
@bdash
bdash merged commit ff711ea into dev Oct 9, 2026
5 checks passed
@bdash
bdash deleted the test_unified_python_generator branch October 9, 2026 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants