JNative Question
I just started on JNative and I have some questions on about it. I hope someone here can help me with some answers. Pardon me if I sound stupid, I just barely started less than 24 hours. Anyway I have a C structure here...
//C code struct
struct usb_bus{
struct usb_bus *next, *prev;
char dirname[LIBUSB_PATH_MAX];// LIBUSB_PATH_MAX 512
struct usb_device *devices;
unsignedlong location;
struct usb_device *root_dev;
};
and corresponding class I construct as follows
import org.xvolks.jnative.exceptions.NativeException;
import org.xvolks.jnative.misc.basicStructures.AbstractBasicData;
import org.xvolks.jnative.misc.basicStructures.LONG;
import org.xvolks.jnative.pointers.Pointer;
import org.xvolks.jnative.pointers.memory.MemoryBlockFactory;
publicclass USB_Busextends AbstractBasicData<USB_Bus>{
staticprivate Pointer next;
staticprivate Pointer prev;
privatechar dirname[] =newchar[CommonDefines.LIBUSB_PATH_MAX];
staticprivate Pointer devices;
private LONG location;
staticprivate Pointer root_dev;
static{
try{
next =new Pointer(MemoryBlockFactory.createMemoryBlock(2128));
}catch (NativeException e){
e.printStackTrace();
thrownew RuntimeException(e);
}
}
static{
try{
prev =new Pointer(MemoryBlockFactory.createMemoryBlock(2128));
}catch (NativeException e){
e.printStackTrace();
thrownew RuntimeException(e);
}
}
static{
try{
devices =new Pointer(MemoryBlockFactory.createMemoryBlock(4));
}catch (NativeException e){
e.printStackTrace();
thrownew RuntimeException(e);
}
}
static{
try{
root_dev =new Pointer(MemoryBlockFactory.createMemoryBlock(4));
}catch (NativeException e){
e.printStackTrace();
thrownew RuntimeException(e);
}
}
public USB_Bus(){
super(null);
}
public Pointer getDevices(){
return devices;
}
publicvoid setDevices(Pointer devices){
this.devices = devices;
}
publicchar[] getDirname(){
return dirname;
}
publicvoid setDirname(char[] dirname){
this.dirname = dirname;
}
public LONG getLocation(){
return location;
}
publicvoid setLocation(LONG location){
this.location = location;
}
public Pointer getNext(){
return next;
}
publicvoid setNext(Pointer next){
this.next = next;
}
public Pointer getPrev(){
return prev;
}
publicvoid setPrev(Pointer prev){
this.prev = prev;
}
public Pointer getRoot_dev(){
return root_dev;
}
publicvoid setRoot_dev(Pointer root_dev){
this.root_dev = root_dev;
}
public Pointer createPointer()throws NativeException{
pointer =new Pointer(MemoryBlockFactory.createMemoryBlock(getSizeOf()));
return pointer;
}
publicint getSizeOf(){
// TODO Auto-generated method stub
return 532;
}
public USB_Bus getValueFromPointer()throws NativeException{
next = ;
prev;
privatechar dirname[] =newchar[CommonDefines.LIBUSB_PATH_MAX];
staticprivate Pointer devices;
private LONG location;
staticprivate Pointer root_dev;
}
}
My question is
(1) next =new Pointer(MemoryBlockFactory.createMemoryBlock(2128));
Is this correct, I am assuming I am allocating memory to hold the values of the entire structure
(2) How do I declare it in JNative for the case struct usb_device **children
?

