Skip to content
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

Initial support for CoreGraphics / Dispatch #632

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

not-jan
Copy link

@not-jan not-jan commented Jun 18, 2024

Hey, I've talked about it in #631, so here's my draft PR for adding CoreGraphics and I think I have it most of the way there but now I'm encountering a lot of these errors:

│ ├─ERROR tried to get library config from "__Unknown__"
│ ├─ WARN ItemIdentifier from unknown header, entity=Entity { kind: ObjCProtocolDecl, display_name: Some("OS_dispatch_queue"), location: Some(SourceLocation { file: Some(File { path: "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/dispatch/queue.h" }), line: 70, column: 1, offset: 2513 }) }
│ ├─ERROR tried to get library config from "__Unknown__"
│ ├─ WARN ItemIdentifier from unknown header, entity=Entity { kind: ObjCProtocolDecl, display_name: Some("OS_dispatch_object"), location: Some(SourceLocation { file: Some(File { path: "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/dispatch/object.h" }), line: 56, column: 37, offset: 1725 }) }
│ ├─ERROR tried to get library config from "__Unknown__"
│ ├─ WARN ItemIdentifier from unknown header, entity=Entity { kind: ObjCProtocolDecl, display_name: Some("OS_dispatch_queue"), location: Some(SourceLocation { file: Some(File { path: "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/dispatch/queue.h" }), line: 70, column: 1, offset: 2513 }) }
│ ├─ WARN ItemIdentifier from unknown header, entity=Entity { kind: ObjCProtocolDecl, display_name: Some("OS_dispatch_object"), location: Some(SourceLocation { file: Some(File { path: "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/dispatch/object.h" }), line: 56, column: 37, offset: 1725 }) }
│ ├─ERROR tried to get library config from "__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["IOKit", "IOTypes"] }, library="IOKit"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["IOKit", "IOTypes"] }, library="IOKit"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"
│ ├─ERROR failed getting crate name, location=Location { path_components: ["__Unknown__"] }, library="__Unknown__"

I've modified some of the error messages to actually trace down compilation errors and also implemented ObjC's version of #[must_use]. I'm hopeful that you can help me figure out the remaining issues.

@PaulDance
Copy link
Contributor

PaulDance commented Jul 5, 2024

Not sure if this could be of help, but I've encountered these errors before:

The first batch is regarding dispatch:

  • it bases itself on C and exposes a C, C++, Obj-C and Swift API, if I remember correctly;
  • item names are therefore often different between the languages: in C there is for example dispatch_queue_t, but in Obj-C it is NSObject<OS_dispatch_queue>;
  • the header translator sees OS_dispatch_queue and tries to find it in its watched headers, but does not find it since it is actually dispatch_queue_t that is only an alias to dispatch_object_s*, hence the errors.

This is currently "solved" by grafting any framework item that mentions anything of dispatch from its crate using the exclusions possible in the translation-config.toml: maybe try this first? I used a good old grep in the past to find all items that use it by searching for OS_dispatch or something like that in the framework's Headers directory.

Properly having support for dispatch will probably require modifying the translator in order to add the hacks necessary to connect the pipes correctly. It could also be easier to develop and review if it were done separately: much of the existing higher-level framework crates already need dispatch and can therefore serve as a test basis.

The second batch may be because some regular Obj-C types used in CoreGraphics depend on ones from other frameworks? You can also grep for #(include|import) <.*\.h> and then | sort -u in order to determine the dependencies of a framework from its header files. The dependencies need to have a generated objc2 framework crate before the dependent can be generated.

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