I don't know. Your code won't work if your enum values are not 0, 1, 2,
... Let me know if you figure out an efficient way, thanks
You can use @Name() as shown in the README.txt file to specify the
native function name, instead of having JavaCPP pick up the method name
in Java
--
You received this message because you are subscribed to a topic in the Google Groups "javacpp" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/javacpp-project/mSGTOFweVQU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to javacpp-proje...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
struct Struct_Simulation_Results {
Simulation_Flag Flag;
structTimeSeriesResults s_timeSeriesResults;
Vector_Double vd_Indicators;
};
Follow your example, this is the corresponding Javacpp code:enum Simulation_Flag {Simulation_OK = 0,Initialisation_Failed = 1,Simulation_Failed = 2};
struct structTimeSeriesResults {...}
I have the following structs:struct Struct_Simulation_Results {Simulation_Flag Flag;structTimeSeriesResults s_timeSeriesResults;Vector_Double vd_Indicators;};
Follow your example, this is the corresponding Javacpp code:enum Simulation_Flag {Simulation_OK = 0,Initialisation_Failed = 1,Simulation_Failed = 2};
struct structTimeSeriesResults {...}@Namespace("")public static class Struct_Simulation_Results extends Pointer {static { Loader.load(); }public Struct_Simulation_Results () { allocate(); }private native void allocate();public native Simulation_Flag Flag(); public native Struct_Simulation_Results Flag(Simulation_Flag Flag);
public native structTimeSeriesResults s_timeSeriesResults(); public native Struct_Simulation_Results s_timeSeriesResults(structTimeSeriesResults s_timeSeriesResults);public native @StdVector DoublePointer vd_Indicators(); public native Struct_Simulation_Results vd_Indicators(@StdVector DoublePointer vd_Indicators);}@Namespace("")public static enum Simulation_Flag {Simulation_OK(0), Initialisation_Failed(1), Simulation_Failed(2);private int value;private Simulation_Flag(int value) {this.value = value;}}
public MessageType getType() {
return MessageType.fromInt(nativeGetType());
}
private native @Name("getType") int nativeGetType();
public MessageType getType() {
return MessageType.fromInt(nativeGetType());
}
private native @Name("getType") int nativeGetType();
Thanks for your quick reply.Yes, i've made some errors.In fact, @Cast("Simulation_Flag") int! works well.So this is the modified javacpp code:public static class Struct_Simulation_Results extends Pointer {static { Loader.load(); }public Struct_Simulation_Results () { allocate(); }private native void allocate();public native Simulation_Flag Flag(); public native Struct_Simulation_Results Flag(@Cast("Simulation_Flag") int Flag);public native structTimeSeriesResults s_timeSeriesResults(); public native Struct_Simulation_Results s_timeSeriesResults(structTimeSeriesResults s_timeSeriesResults);public native @StdVector DoublePointer vd_Indicators(); public native Struct_Simulation_Results vd_Indicators(@StdVector DoublePointer vd_Indicators);}public static enum Simulation_Flag {Simulation_OK(0), Initialisation_Failed(1), Simulation_Failed(2);private int value;private Simulation_Flag(int value) {this.value = value;}}However, i don't really understand how Javacpp can map my java enum Simulation_Flag with my C++ enumeration Simulation_Flag in this case?
And your code concerning the getter:public MessageType getType() {
return MessageType.fromInt(nativeGetType());
}
private native @Name("getType") int nativeGetType();Why @Name("getType") here? What does this mean? and What is the relationship with the C++ header?
struct Struct_Simulation_Results {
Simulation_Flag Flag;
};
enum Simulation_Flag
{
Simulation_OK = 0,
Initialisation_Failed = 1,
Simulation_Failed = 2
};
public static class Struct_Simulation_Results extends Pointer {
static { Loader.load(); }
public Struct_Simulation_Results () { allocate(); }
private native void allocate();
@NoOffset public native Simulation_Flag Flag();
public native Struct_Simulation_Results Flag(@Cast("Simulation_Flag") int Flag);
}
public static enum Simulation_Flag {
Simulation_OK(0), Initialisation_Failed(1), Simulation_Failed(2);
private int value;
private Simulation_Flag(int value) {
this.value = value;
}
}
rptr = ptr->Flag
public native @Cast("Simulation_Flag") int Flag(); public native Struct_Simulation_Results Flag(@Cast("Simulation_Flag") int Flag);
private static native @MemberGetter @Const int TRANSPOSE(); | |
private static native @ValueGetter @Const int NO_TRANSPOSE(); | |
public enum Trans { | |
TRANSPOSE(TRANSPOSE()), NO_TRANSPOSE(NO_TRANSPOSE()); | |
private int value; | |
Trans(int value) { | |
this.value = value; | |
} | |
private int value() { | |
return value; | |
} | |
} |
enum NNNOTranspose { | |
TRANSPOSE = 0, | |
NO_TRANSPOSE = 1 | |
}; |
--
You received this message because you are subscribed to the Google Groups "javacpp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javacpp-proje...@googlegroups.com.