-
Notifications
You must be signed in to change notification settings - Fork 156
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
Make templated C++ types useful #349
Comments
The LLVM C++ API defines a class called // Inside class MemoryBuffer
static ErrorOr<std::unique_ptr<MemoryBuffer>>
getFile(const Twine &Filename,
bool IsText = false,
bool RequiresNullTerminator = true,
bool IsVolatile = false); I read the documentation, but I couldn't figure out the recommended way to deal with this situation. @adetaylor, can you advise on how I should fix this issue in order to use these functions? |
Yeah, per this bug they're just opaque from Rust. The workaround is to define new C++ functions like this, to let you unpack the error. bool IsAnError(ErrorOr<std::unique_ptr<MemoryBuffer>>) {
// ...
}
std::unique_ptr<MemoryBuffer> UnpackSuccessValue(ErrorOr<std::unique_ptr<MemoryBuffer>>) {
// unpack and return the thing
} Ask autocxx to generate bindings for those. Whenever you call any function which gives you the pesky This is not ideal, of course. That's why this bug exists. |
It looks like, due to the issue of #[doc = "autocxx bindings couldn't be generated: This function or method uses a type where one of the template parameters was incomprehensible to bindgen/autocxx - probably because it uses template specialization."]
fn getFile(_uhoh: autocxx::BindingGenerationFailure) {} How should I convince |
Oh, I see. Unfortunately that's currently not possible. But, I just raised #1009 as a future enhancement to make that possible. I'll try to look into it sometime in the next few weeks (no promises at all.) |
Split off from #106. At the moment, a templated C++ type gets made into a completely opaque type called
AutocxxConcrete0
...n
. These types don't have constructors, accessors, or methods, so are useless except as an opaque token passed from C++, through Rust, back into C++.Options are:
cxx
accept templated types, as mentioned in Dependent qualified types don't work #106 (comment) and Functions and opaque types with type parameters dtolnay/cxx#767The text was updated successfully, but these errors were encountered: