Repository navigation
Conversation
class!() was given the source name, but a class declared with
objc_runtime_name("X") is registered as X at runtime, so alloc, class
methods and the TryFrom downcast looked up a class that doesn't exist.
libclang exposes the attribute only as an unexposed attr, so read it from
the attribute's tokens. The Rust type keeps the source name.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3476
For an interface with
__attribute__((objc_runtime_name("RuntimeFoo"))), bindgen generatedclass!(Foo)(the source name) foralloc(), class methods and theTryFromdowncast. At runtime the class is registered asRuntimeFoo, so the lookup fails.libclang has no cursor kind for this attribute, so
ObjCInterface::from_tynow reads it from the tokens of theCXCursor_UnexposedAttrchild (objc_runtime_name ( "Name" )) and stores it asruntime_name. Codegen usesruntime_name()for everyclass!()call; the Rust struct and trait keep the source name. Without the attribute nothing changes.Test: added
objc_runtime_name.hwith expectations (an interface with the attribute, one without).cargo test -p bindgen-testspasses exceptheader_objc_template_h, which also fails on unmodified main.cargo +nightly fmt --checkis clean.