I have a SWIG interface file that exposes some C functions (via JNI) to my Java application and these C structures are used as input into the C function (via SWIG/JNI). SWIG generates the structure as a Java class, but I'm unsure how to set the structures properties as the setters take a SWIG generated type. I need to set the structures properties before passing it as input into the C function from my Java class. example_location_id_t_ is the class I need to pass, but the setters for Id
and Phy_idx
take the below SWIG types. How do I populate the SWIGTYPE_p_unsigned_char
and SWIGTYPE_p_uint32_t
so that I can set the Id
and Phy_idx
properties of the SWIGTYPE_p_uint32_t
class?
setId(SWIGTYPE_p_unsigned_char value)
and setPhy_idx(SWIGTYPE_p_uint32_t value)
package com.test.jni;
public class SWIGTYPE_p_unsigned_char {
private long swigCPtr;
protected SWIGTYPE_p_unsigned_char(long cPtr, boolean futureUse) {
swigCPtr = cPtr;
}
protected SWIGTYPE_p_unsigned_char() {
swigCPtr = 0;
}
protected static long getCPtr(SWIGTYPE_p_unsigned_char obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
}
package com.test.jni;
public class SWIGTYPE_p_uint32_t {
private long swigCPtr;
protected SWIGTYPE_p_uint32_t(long cPtr, boolean futureUse) {
swigCPtr = cPtr;
}
protected SWIGTYPE_p_uint32_t() {
swigCPtr = 0;
}
protected static long getCPtr(SWIGTYPE_p_uint32_t obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
}
package com.test.jni;
public class example_location_id_t_ {
private long swigCPtr;
protected boolean swigCMemOwn;
public example_location_id_t_ (long cPtr, boolean cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
swigCPtr = cPtr;
}
public static long getCPtr(example_location_id_t_ obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
protected void finalize() {
delete();
}
public synchronized void delete() {
if (swigCPtr != 0) {
if (swigCMemOwn) {
swigCMemOwn = false;
ExampleJNI.delete_example_location_id_t_(swigCPtr);
}
swigCPtr = 0;
}
}
public void setId(SWIGTYPE_p_unsigned_char value) {
ExampleJNI.example_location_id_t__id_set(swigCPtr, this, SWIGTYPE_p_unsigned_char.getCPtr(value));
}
public SWIGTYPE_p_unsigned_char getId() {
long cPtr = ExampleJNI.example_location_id_t__id_get(swigCPtr, this);
return (cPtr == 0) ? null : new SWIGTYPE_p_unsigned_char(cPtr, false);
}
public void setPhy_idx(SWIGTYPE_p_uint32_t value) {
ExampleJNI.example_location_id_t__phy_idx_set(swigCPtr, this, SWIGTYPE_p_uint32_t.getCPtr(value));
}
public SWIGTYPE_p_uint32_t getPhy_idx() {
return new SWIGTYPE_p_uint32_t(ExampleJNI.example_location_id_t__phy_idx_get(swigCPtr, this), true);
}
public example_location_id_t_() {
this(ExampleJNI.new_example_location_id_t_(), true);
}
}