-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Experience: generating bindings for nextpnr #1167
Comments
Thanks very much for the report!
I'm going to close this but please do raise new issues for those noted above. Thanks again! |
adetaylor
added a commit
that referenced
this issue
Oct 20, 2022
Previously extern_rust_function support was highly basic and didn't usually work at all. This change improevs matters: * it allows us to emit errors with miette diagnostics from this part of the codebase, giving spans in case of trouble * it validates that the parameters to such a function are valid to be used by cxx, as is the return type * it detects types used as parameters and return type and ensures they are not garbage collected elsewhere in autocxx * it adds a code example. * we remove a field from RustFun which we didn't actually need and replace it with a simple Boolean. Builds on test case from #1166 (thanks!) and there's a bit of discussion in #1167.
adetaylor
added a commit
that referenced
this issue
Oct 20, 2022
Previously extern_rust_function support was highly basic and didn't usually work at all. This change improevs matters: * it allows us to emit errors with miette diagnostics from this part of the codebase, giving spans in case of trouble * it validates that the parameters to such a function are valid to be used by cxx, as is the return type * it detects types used as parameters and return type and ensures they are not garbage collected elsewhere in autocxx * it adds a code example. * we remove a field from RustFun which we didn't actually need and replace it with a simple Boolean. Builds on test case from #1166 (thanks!) and there's a bit of discussion in #1167.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is in the spirit of #1073, except it's for nextpnr instead; internally nextpnr has an API that uses a number of more specifically-C++ idioms, without being designed with FFI in mind. So, I knew I was getting in for some trouble, but maybe it would be useful for me to describe what the issues I've ran into were.
#[extern_rust_function]
producing code not accepted bycxx
, which I filed as Add failing test for extern_rust_function #1166.block!("GraphicElement")
due to getting errors that look like this:I would like to file an issue about this, but unfortunately I don't have the hardware to reduce this in a sensible amount of time; would the repro.json be enough by itself to create the problem, or would this need the repo itself uploading?
Context
, which inherits from anArch
backend, which (usually) inherits from aBaseArch<R>
(whereR
is something that inherits fromArchRanges
), which inherits fromArchAPI<R>
, which inherits fromBaseCtx
.autocxx
generates a doc comment aboutBaseArch
/ArchAPI
being incomprehensible due to specialisation, which means that functions fromBaseCtx
(which are generated) are not reachable from aContext
. This is something that can be worked around using some FFI shimming, but it's a bit inconvenient. Is this worth filing a bug for, or is this considered abindgen
issue?AsRef
for casting to superclasses #592, a big issue here is the lack of being able to convert&mut
of a class into an&mut
of its base class; since a lot of the important nextpnr API is inArch
rather thanContext
, this has the side effect of making much of the internal state read-only.ForwardIterator
interface that involvesoperator++
andoperator*
. These functions don't get produced in theautocxx
bindings, making it impossible to iterate over C++ items. Again, fixable with some FFI shimming, but inconvenient. I'd file a bug here, except I don't specifically know what these functions would actually get called in Rust-land, so writing a test case is difficult.The text was updated successfully, but these errors were encountered: