I have this Java enum
that I need to interface with:
// Parameter.java
public enum Parameter {
ExampleParameter1(45920L, 3, 127, ValueFormat.BINARY, true),
ExampleParameter2(45703L, 6, 6, ValueFormat.NUMERIC, true),
ExampleParameter3(73L, 4, 4, ValueFormat.ALPHANUMERIC, true),
ExampleParameter3(4512L, 2, 11, ValueFormat.ALPHANUMERIC, true);
( . . . )
private ValueFormat a
private int b;
private long c;
private boolean d;
private Parameter(long tag, int param, int min, ValueFormat format, boolean boo)
{
this.a = format;
this.b = min;
this.c = tag;
this.d = boo;
}
}
I would like to generated a valid C++ <-> Java interface using Djinni, but since djinni
's enums generate public enum
in Java (correct in my case) and enum class
in C++ (with int
underlying type), it can't work.
Is this even possible? Or do I have to create a Djinni interface
with Java and C++ implementation with manually-made "bindings"?
Thanks in advance for any help.
This kind of enum
containing many fields is a pretty unique concept to Java, while Djinni exposes the concept which is common across all languages, which supports an enum which has only an int value. If what you want is an object which contains multiple fields of various types, in Djinni you'll want a record
. You can use an interface if you want to expose methods for custom behavior, but shouldn't need to for pure data.
In any case, Djinni generates its own types. It's not intended to directly expose existing types into other languages, so you'll need to write your own conversion function to turn your Parameter into a Djinni record, if you don't want to use the record directly.