19 py::enum_<UnscopedEnum>(
m,
"UnscopedEnum", py::arithmetic(),
"An unscoped enumeration")
20 .
value(
"EOne", EOne,
"Docstring for EOne")
21 .value(
"ETwo", ETwo,
"Docstring for ETwo")
22 .value(
"EThree", EThree,
"Docstring for EThree")
26 enum class ScopedEnum {
30 py::enum_<ScopedEnum>(
m,
"ScopedEnum", py::arithmetic())
31 .
value(
"Two", ScopedEnum::Two)
32 .value(
"Three", ScopedEnum::Three);
34 m.def(
"test_scoped_enum", [](ScopedEnum
z) {
35 return "ScopedEnum::" + std::string(z == ScopedEnum::Two ?
"Two" :
"Three");
44 py::enum_<Flags>(
m,
"Flags", py::arithmetic())
45 .
value(
"Read", Flags::Read)
46 .value(
"Write", Flags::Write)
47 .value(
"Execute", Flags::Execute)
51 class ClassWithUnscopedEnum {
58 static EMode test_function(EMode mode) {
62 py::class_<ClassWithUnscopedEnum> exenum_class(m,
"ClassWithUnscopedEnum");
63 exenum_class.def_static(
"test_function", &ClassWithUnscopedEnum::test_function);
64 py::enum_<ClassWithUnscopedEnum::EMode>(exenum_class,
"EMode")
65 .
value(
"EFirstMode", ClassWithUnscopedEnum::EFirstMode)
66 .value(
"ESecondMode", ClassWithUnscopedEnum::ESecondMode)
70 m.def(
"test_enum_to_int", [](
int) { });
71 m.def(
"test_enum_to_uint", [](
uint32_t) { });
72 m.def(
"test_enum_to_long_long", [](
long long) { });
80 m.def(
"register_bad_enum", [m]() {
81 py::enum_<SimpleEnum>(
m,
"SimpleEnum")
82 .
value(
"ONE", SimpleEnum::ONE)
83 .value(
"ONE", SimpleEnum::TWO)
84 .value(
"ONE", SimpleEnum::THREE)