Closed GoogleCodeExporter closed 8 years ago
An `enum` in C++ is basically an `int` value so we can map it that way, along
with a `@Cast`. Mapping it to a Java `enum` isn't exactly straightforward, or
even desirable, because we lose the ability to use arbitrary `int`, as we can
from C++. If you have a good idea, though, I'm all ears!
There is a lot of `enum` samples in the Presets here:
https://code.google.com/p/javacpp/source/browse/?repo=presets
Do we really need more documentation for that?
Original comment by samuel.a...@gmail.com
on 22 Nov 2013 at 11:39
We now have documentation for this, in a way: The new `Parser` feature produces
the desired output by default. So, by following the steps detailed here, for
example:
https://github.com/bytedeco/javacpp-presets/wiki/Create-New-Presets
with a config file like this:
import org.bytedeco.javacpp.*;
import org.bytedeco.javacpp.annotation.*;
import org.bytedeco.javacpp.tools.*;
@Properties(value=@Platform(include="Stuff.h"), target="Stuff")
public class StuffConfig implements InfoMapper {
public void map(InfoMap infoMap) {
}
}
and a `Stuff.h` header file like this:
enum Stuff {
ONE, TWO, THREE
};
JavaCPP outputs the following interface:
import java.nio.*;
import org.bytedeco.javacpp.*;
import org.bytedeco.javacpp.annotation.*;
public class Stuff extends StuffConfig {
static { Loader.load(); }
// Parsed from Stuff.h
/** enum Stuff */
public static final int
ONE = 0, TWO = 1, THREE = 2;
}
BTW, if you have any other issues, please post about them on GitHub, if
possible. Thank you for reporting!
Original comment by samuel.a...@gmail.com
on 29 Dec 2014 at 3:32
Original issue reported on code.google.com by
proulxem...@gmail.com
on 18 Nov 2013 at 2:48