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

Symbols with pid_t missing from header-translator generated files #331

Closed
skirsdeda opened this issue Jan 10, 2023 · 11 comments
Closed

Symbols with pid_t missing from header-translator generated files #331

skirsdeda opened this issue Jan 10, 2023 · 11 comments
Labels
A-framework Affects the framework crates and the translator for them bug Something isn't working

Comments

@skirsdeda
Copy link

For example NSRunningApplication::processIdentifier in AppKit. I guess this has smth to do with the fact that pid_t is typedef'ed.
Any way to fix this or should it be patched on case-by-case basis in icrate crates?

@skirsdeda skirsdeda changed the title Symbols with pid_t missing from header-translator generated files Symbols with pid_t missing from header-translator generated files Jan 10, 2023
@skirsdeda skirsdeda changed the title Symbols with pid_t missing from header-translator generated files Symbols with pid_t missing from header-translator generated files Jan 10, 2023
@skirsdeda
Copy link
Author

@madsmtm madsmtm added A-framework Affects the framework crates and the translator for them bug Something isn't working labels Jan 10, 2023
@madsmtm
Copy link
Owner

madsmtm commented Jan 10, 2023

The reason these are currently missing is that I'd rather use libc::pid_t - and that in turn has to be hidden behind a feature flag.

I am working on resolving this though.

@skirsdeda
Copy link
Author

Makes sense, thanks.

@madsmtm madsmtm added this to the icrate v0.2.0 milestone Jan 27, 2023
@ehuff700
Copy link

@madsmtm are you still tracking this? this is blocking one of my projects. (Thanks for this crate btw, absolutely phenomenal work here).

@madsmtm
Copy link
Owner

madsmtm commented Sep 19, 2023

Not working on it right now, no, but I still intend to get it working at some point, probably as part of / after #345.

In the meantime you can do the following workaround yourself:

use icrate::AppKit::NSRunningApplication;
use objc2::msg_send;
use libc::pid_t;

fn application_process_identifier(app: &NSRunningApplication) -> pid_t {
    unsafe { msg_send![app, processIdentifier] }
}

@blu3gui7ar
Copy link

Not working on it right now, no, but I still intend to get it working at some point, probably as part of / after #345.

In the meantime you can do the following workaround yourself:

use icrate::AppKit::NSRunningApplication;
use objc2::msg_send;
use libc::pid_t;

fn application_process_identifier(app: &NSRunningApplication) -> pid_t {
    unsafe { msg_send![app, processIdentifier] }
}

I am trying exact the same code, but got error about NSRunningApplication.
Anything I am doing wrong?

the trait bound `&NSRunningApplication: objc2::Message` is not satisfied
the following other types implement trait `objc2::Message`:
  objc2::exception::Exception
  objc2::rc::__RcTestObject
  objc2::runtime::AnyObject
  objc2::runtime::NSObject
  objc2::runtime::ProtocolObject<P>
  objc2::runtime::__NSProxy
required for `&&NSRunningApplication` to implement `objc2::runtime::MessageReceiver`
required for `&&NSRunningApplication` to implement `MsgSend`rustc[Click for full compiler diagnostic]

@madsmtm
Copy link
Owner

madsmtm commented Dec 11, 2023

Hmm, are you sure it's the same code? The error seems to indicate that you may have written msg_send![&app, processIdentifier] instead (notice the extra &).

@blu3gui7ar
Copy link

Hmm, are you sure it's the same code? The error seems to indicate that you may have written msg_send![&app, processIdentifier] instead (notice the extra &).

Errr, sorry for the confusion. Actually I tried both with no luck.

image

@skirsdeda
Copy link
Author

Definitely works for me, but then I'm using a bit outdated versions:

objc2 = "=0.3.0-beta.4"
icrate = { version = "0.0.1", features = ["AppKit", "Foundation"] }

@blu3gui7ar
Copy link

Definitely works for me, but then I'm using a bit outdated versions:

objc2 = "=0.3.0-beta.4"
icrate = { version = "0.0.1", features = ["AppKit", "Foundation"] }

I found the problem. I used objc2 0.5.0. When I use reexport from icrate instead, which seems to be 0.4.1, it works.

use icrate::objc2::msg_send;

@madsmtm
Copy link
Owner

madsmtm commented Dec 11, 2023

Ah yeah, I haven't released a new version of icrate that matches the new objc2 version yet, see #537.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-framework Affects the framework crates and the translator for them bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants