diff --git a/src/python/const/bindings.cpp b/src/python/const/bindings.cpp index c606e76..8fd5822 100644 --- a/src/python/const/bindings.cpp +++ b/src/python/const/bindings.cpp @@ -24,16 +24,31 @@ void register_const_bindings(pybind11::module &const_submodule) { py::class_(const_submodule, "Constants") .def_property_readonly("loaded", &Constants::isLoaded) - .def("get", &Constants::get, py::arg("name"), "Get a constant by name. Returns None if not found.") - .def("__getitem__", &Constants::get, py::arg("name")) - .def("has", &Constants::has, py::arg("name"), "Check if a constant exists by name.") - .def("keys", &Constants::keys, "Get a list of all constant names.") - .def(py::init([]() { - return &Constants::getInstance(); - }), - // Tell pybind11 Python doesn't own this memory. - py::return_value_policy::reference, - "Get the singleton instance of Constants." - ); + .def_static("get", + [](const std::string &name) { + return py::cast( + Constants::getInstance().get(name) + ); + }, + "Get a constant by name. Returns None if not found." + ) + .def_static("has", + [](const std::string &name) { + return Constants::getInstance().has(name); + }, + "Check if a constant exists by name.") + .def_static("keys", + []() { + return py::cast( + Constants::getInstance().keys() + ); + }, + "Get a list of all constant names.") + .def_static("__class_getitem__", + [](const std::string &name) { + return py::cast( + Constants::getInstance().get(name) + ); + }); }