Open ochafik opened 9 years ago
Hi tulskiy,
This is definitely something planned, but most of the work it requires has to be done in dyncall (http://dyncall.org/). Work on it has begun, even though it will take some time : http://dyncall.org/svn/dyncall/trunk/dyncall/dyncall/dyncall_struct.c
Cheers
From @finson on January 3, 2012 0:25
Olivier: I believe that my situation supports this request. Here is a brief description, just for your reference.
I am wrapping a 3rd party library (libcec from Pulse8). There are three methods that cause errors.
extern DECLSPEC cec_logical_addresses cec_get_active_devices(void);
extern DECLSPEC cec_osd_name cec_get_device_osd_name(cec_logical_address iAddress);
I have hidden these three prototypes and I am now able to load and address the library. I don't absolutely need these methods, but they would be handy to have. It happens that libcec is open source and I could modify the library code if need be, but I'd rather not, and in many cases that won't be an option. So, I second Denis' suggestion that struct call by value would be nice to have. I ALSO second his comment that this is a great library. Seeing C code actually execute when called from Java in a semi-normal looking way is very empowering!
The associated JNAerator-produced classes are shown below.
I'm using a build-it-myself-with-maven BridJ 0.7 snapshot and JNAerator 0.9.9 snapshot.
Thanks. Doug Johnson (finson)
public class cec_device_type_list extends StructObject {
public cec_device_type_list() {
super();
}
public cec_device_type_list(Pointer pointer) {
super(pointer);
}
/// C type : cec_device_type[5]
@Array({5})
@Field(0)
public Pointer<ValuedEnum<cec_device_type > > types() {
return this.io.getPointerField(this, 0);
}
}
public class cec_logical_addresses extends StructObject {
public cec_logical_addresses() {
super();
}
public cec_logical_addresses(Pointer pointer) {
super(pointer);
}
/// C type : cec_logical_address
@Field(0)
public ValuedEnum<cec_logical_address > primary() {
return this.io.getEnumField(this, 0);
}
/// C type : cec_logical_address
@Field(0)
public cec_logical_addresses primary(ValuedEnum<cec_logical_address > primary) {
this.io.setEnumField(this, 0, primary);
return this;
}
/// C type : int[16]
@Array({16})
@Field(1)
public Pointer<Integer > addresses() {
return this.io.getPointerField(this, 1);
}
}
public class cec_osd_name extends StructObject {
public cec_osd_name() {
super();
}
public cec_osd_name(Pointer pointer) {
super(pointer);
}
/// C type : char[14]
@Array({14})
@Field(0)
public Pointer<Byte > name() {
return this.io.getPointerField(this, 0);
}
/// C type : cec_logical_address
@Field(1)
public ValuedEnum<cec_logical_address > device() {
return this.io.getEnumField(this, 1);
}
/// C type : cec_logical_address
@Field(1)
public cec_osd_name device(ValuedEnum<cec_logical_address > device) {
this.io.setEnumField(this, 1, device);
return this;
}
}
From @reuben on February 16, 2012 15:29
Sorry to bump bugs, but what is the progress on this?
From @tulskiy on September 1, 2011 5:42
Hi,
I know it is a known limitation that BridJ does not support passing struct by value. I just wanted to leave it here as an issue to be notified in case this feature is ever implemented. Feel free to close the issue if you don't plan on adding it.
Thanks for this great library.
Copied from original issue: ochafik/nativelibs4java#1