Using CFBooleanRef through JNA
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 ?
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);
}
}
精彩评论