diff --git a/subprojects/robotpy-hal/hal/src/hal.cpp b/subprojects/robotpy-hal/hal/src/hal.cpp index b5a3c83f..09a9ba1d 100644 --- a/subprojects/robotpy-hal/hal/src/hal.cpp +++ b/subprojects/robotpy-hal/hal/src/hal.cpp @@ -20,6 +20,44 @@ RPYBUILD_PYBIND11_MODULE(m) { .value("INT", HAL_Type::HAL_INT) .value("LONG", HAL_Type::HAL_LONG); + // Add this manually because it would be annoying to do otherwise + py::class_(m, "Value") + .def_readonly("type", &HAL_Value::type) + .def_property_readonly("value", + [](const HAL_Value &self) -> py::object { + switch (self.type) { + case HAL_BOOLEAN: + return py::bool_(self.data.v_boolean); + case HAL_DOUBLE: + return py::float_(self.data.v_double); + case HAL_ENUM: + return py::int_(self.data.v_enum); + case HAL_INT: + return py::int_(self.data.v_int); + case HAL_LONG: + return py::int_(self.data.v_long); + default: + return py::none(); + } + } + ) + .def("__repr__", [](const HAL_Value &self) -> py::str { + switch (self.type) { + case HAL_BOOLEAN: + return ""; + case HAL_DOUBLE: + return ""; + case HAL_ENUM: + return ""; + case HAL_INT: + return ""; + case HAL_LONG: + return ""; + default: + return ""; + } + }); + initWrapper(m); #ifdef __FRC_ROBORIO__