通过 JNA 使用 CFBooleanRef

发布于 2024-08-14 07:39:45 字数 169 浏览 1 评论 0原文

我正在使用 JNA 调用 Carbon API。我想要调用的特定 API 调用需要 CFBooleanRef 作为参数。值 kCFBooleanTrue 和 kCFBooleanFalse 为 在头文件中声明为直接外部引用。

如何在 Java 端获取对这两个值的引用,以便我可以传递这些值 到 API 调用?

I'm using JNA to call Carbon APIs. The particular API call that I want to call takes
a CFBooleanRef as a parameter. The values, kCFBooleanTrue and kCFBooleanFalse, are
declared as direct extern references in the header files.

How can I get references to those two values on the Java side, so that I can pass the values
to the API call ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖伴 2024-08-21 07:39:45

好吧,由于这还没有得到任何答案,只是放下我想出的解决方案,以防其他人需要这样做:

我最终使用 Rococoa 来实现我自己的 NSNumber 版本,这样我就可以调用 numberWithBool 方法在其中,获取 NSBoolean 的实例。然后可以将其用作 CFBoolean。

public interface MyNSNumber extends NSObject {
    public static final _Class CLASS = Rococoa.createClass("NSNumber", _Class.class);

    public interface _Class extends NSClass {
        ID numberWithBool(boolean value);
    }
}

Well, as this hasn't gotten any answer, just putting down the solution I came up with, in case anyone else needs to do this:

I ended up using Rococoa to implement my own version of NSNumber, so that I could call numberWithBool method in it, to get an instance of a NSBoolean. Which can then be used as a CFBoolean.

public interface MyNSNumber extends NSObject {
    public static final _Class CLASS = Rococoa.createClass("NSNumber", _Class.class);

    public interface _Class extends NSClass {
        ID numberWithBool(boolean value);
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文