Split bindgen simplified IR from parse/export logic#16144
Split bindgen simplified IR from parse/export logic#16144raynelfss merged 1 commit intoQiskit:mainfrom
bindgen simplified IR from parse/export logic#16144Conversation
While starting to write a Rust/PyO3 raw-FFI backend for the C API via the Python package, I realised that a lot of the logic was about to be duplicated from the `ctypes` output. Had I realised this sooner, I'd have folded this commit into ae91986[^1] to avoid an immediate refactor. I've not attempted to de-duplicate _all_ logic that ever might occur (for example, lifting a `Function` is going to look _mostly_ similar but not identical), because there's enough little tweaks between the languages to make the abstraction awkward, and we're unlikely to have enough languages to really warrant it. For example, the `ctypes` binding needs to know that any custom "path" name of an `Enum` can't actually be exported to that name, because we use Python-space true `Enum` classes in the `ctypes` bindings for input. This restriction isn't present in other languages. [^1]: ae91986: Add auto-generated `ctypes` bindings to C API (Qiskitgh-16067)
|
One or more of the following people are relevant to this code:
|
Coverage Report for CI Build 25402523711Coverage decreased (-0.01%) to 87.575%Details
Uncovered Changes
Coverage Regressions26 previously-covered lines in 3 files lost coverage.
Coverage Stats
💛 - Coveralls |
|
This PR looks quite straightforward refactor to me. |
raynelfss
left a comment
There was a problem hiding this comment.
Ok, I took my sweet time going through the way this has been re-structured and it makes sense. It looks more clean than before (although one could argue that we now have an IR to the IR), but it looks like some of it might get replaced since Jake's PR to cbindgen has merged.
Since we need a more immediate solution, let's merge this now and update ReprType and co later.
|
Yeah, sorry about the churn Ray: I'd hoped to slip this PR into the previous one you reviewed, but you reviewed that faster than I could finish off what I was doing to be sure that this path was what I needed for #16145. |
While starting to write a Rust/PyO3 raw-FFI backend for the C API via the Python package, I realised that a lot of the logic was about to be duplicated from the
ctypesoutput. Had I realised this sooner, I'd have folded this commit into ae919861 to avoid an immediate refactor.I've not attempted to de-duplicate all logic that ever might occur (for example, lifting a
Functionis going to look mostly similar but not identical), because there's enough little tweaks between the languages to make the abstraction awkward, and we're unlikely to have enough languages to really warrant it. For example, thectypesbinding needs to know that any custom "path" name of anEnumcan't actually be exported to that name, because we use Python-space trueEnumclasses in thectypesbindings for input. This restriction isn't present in other languages.AI/LLM disclosure
Footnotes
ae91986: Add auto-generated
ctypesbindings to C API (Add auto-generatedctypesbindings to C API #16067) ↩