diff --git a/lib/autogenerate_bindings.py b/lib/autogenerate_bindings.py index 349cb5f4b..57eeccbfb 100644 --- a/lib/autogenerate_bindings.py +++ b/lib/autogenerate_bindings.py @@ -32,7 +32,7 @@ def my_litgen_options() -> litgen.LitgenOptions: # To prevent the generation of the default constructor with named parameters # for a specific struct, you can use the following option: options.struct_create_default_named_ctor__regex = r".*" # default - options.class_create_default_named_ctor__regex = r"" # default + options.class_create_default_named_ctor__regex = r".*" # /////////////////////////////////////////////////////////////////// # Exclude functions and/or parameters from the bindings @@ -55,9 +55,9 @@ def my_litgen_options() -> litgen.LitgenOptions: # Override virtual methods in python # //////////////////////////////////////////////////////////////////// # The virtual methods of this class can be overriden in python + options.class_template_options.add_specialization(r"WeightedConfig", ["espp::Vector2f"]) # NOTE: this doesn't seem to work options.class_template_options.add_specialization(r"Bezier", ["espp::Vector2f"]) options.class_template_options.add_specialization(r"Bezier::Config", ["espp::Vector2f"]) # NOTE: this doesn't seem to work - options.class_template_options.add_specialization(r"Bezier::WeightedConfig", ["espp::Vector2f"]) # NOTE: this doesn't seem to work options.class_template_options.add_specialization(r"RangeMapper", ["int", "float"]) options.class_template_options.add_specialization(r"RangeMapper::Config", ["int", "float"]) # NOTE: this doesn't seem to work options.class_template_options.add_specialization(r"Vector2d", ["int", "float"]) # NOTE: this still generates some bindings which are not specialized for some reason @@ -106,7 +106,6 @@ def autogenerate() -> None: include_dir = repository_dir + "/components/" header_files = [include_dir + "base_component/include/base_component.hpp", include_dir + "color/include/color.hpp", - include_dir + "csv/include/csv.hpp", include_dir + "event_manager/include/event_manager.hpp", # include_dir + "file_system/include/file_system.hpp", # can't deal with singleton that does not support constructor / destructor include_dir + "ftp/include/ftp_server.hpp", @@ -133,6 +132,9 @@ def autogenerate() -> None: # include_dir + "state_machine/include/state_base.hpp", # include_dir + "state_machine/include/magic_enum.hpp", + # csv (template header): + # include_dir + "csv/include/csv.hpp", + # tabulate (template header): # include_dir + "tabulate/include/tabulate.hpp", diff --git a/lib/python_bindings/espp/__init__.pyi b/lib/python_bindings/espp/__init__.pyi index 2744e099e..a5ffe123c 100644 --- a/lib/python_bindings/espp/__init__.pyi +++ b/lib/python_bindings/espp/__init__.pyi @@ -81,6 +81,7 @@ class BaseComponent: + class Rgb: """* * @brief Class representing a color using RGB color space. @@ -125,17 +126,18 @@ class Rgb: def __init__(self, hsv: Hsv) -> None: """* * @brief Construct an Rgb object from the provided Hsv object. - * @note This calls hsv.rgb() on the provided object, which means fthat - * invalid HSV data (not in the ranges [0,360], [0,1], and [0,1]) - * could lead to bad RGB data. The Rgb constructor will automatically - * convert the values to be in the proper range, but the perceived - * color will be changed. + * @note This calls hsv.rgb() on the provided object, which means that invalid + * HSV data (not in the ranges [0,360], [0,1], and [0,1]) could lead to + * bad RGB data. The Rgb constructor will automatically convert the + * values to be in the proper range, but the perceived color will be + * changed. * @param hsv Hsv object to copy. """ pass + def __add__(self, rhs: Rgb) -> Rgb: """* * @brief Perform additive color blending (averaging) @@ -217,6 +219,7 @@ class Hsv: def __ne__(self, rhs: Hsv) -> bool: pass + def rgb(self) -> Rgb: """* * @brief Get a RGB representation of this HSV color. @@ -225,39 +228,23 @@ class Hsv: """ pass -# namespace espp - -#################### #################### - - -#################### #################### - - - +@overload +def color_code(rgb: Rgb) -> Any: + """ + (C++ auto return type) + """ + pass +@overload +def color_code(hsv: Hsv) -> Any: + """ + (C++ auto return type) + """ + pass -class __csv_documentation__: - """* - * @brief Comma Separated Value (CSV) reader/writer convenience wrapper around - * p-ranav/csv2 which - * exposes csv2::Reader and csv2::Writer classes for managing efficient - * (lazy-loaded) parsing and serizaliztion of human-readable - * CSV-formatted data. - * - * @note This class does not really exist or do anything, but it's the only - * way I could figure out how to get this documentation built into the - * system :( - * - * \section csv_ex1 CSV Reader Example - * \snippet csv_example.cpp csv reader example - * \section csv_ex2 Complex CSV Writer Example - * \snippet csv_example.cpp csv writer example - """ - def __init__(self) -> None: - """Autogenerated default constructor""" - pass +# namespace espp -#################### #################### +#################### #################### #################### #################### @@ -555,7 +542,7 @@ class Logger: def __init__(self) -> None: - """Autogenerated default constructor""" + """Auto-generated default constructor""" pass #################### #################### @@ -626,7 +613,7 @@ class Bezier_espp_Vector2f: # Python specialization for Bezier pass def __init__(self) -> None: - """Autogenerated default constructor""" + """Auto-generated default constructor""" pass # # ------------------------------------------------------------------------ @@ -805,6 +792,9 @@ class Gaussian: #/< max output (alpha), 1 is more of a small wave around the max output (alpha). alpha: float = float(1.0) #/< Max amplitude of the gaussian output, defautls to 1.0. beta: float = float(0.5) #/< Beta value for the gaussian, default to be symmetric at 0.5 in range [0,1]. + + def __eq__(self, rhs: Gaussian.Config) -> bool: + pass def __init__( self, gamma: float = float(), @@ -830,8 +820,13 @@ class Gaussian: alpha: float #/ None: - """Autogenerated default constructor""" + def __init__( + self, + gamma: float = float(), + alpha: float = float(), + beta: float = float() + ) -> None: + """Auto-generated default constructor with named params""" pass #################### #################### @@ -1805,6 +1800,8 @@ class Vector2d_float: # Python specialization for Vector2d #################### #################### +# if we're on windows, we cannot include netinet/in.h and instead need to use +# winsock2.h @@ -1986,7 +1983,7 @@ class Socket: pass def __init__(self) -> None: - """Autogenerated default constructor""" + """Auto-generated default constructor""" pass # namespace espp @@ -1997,6 +1994,8 @@ class Socket: #################### #################### +# if we're on windows, we cannot include netinet/in.h and instead need to use +# winsock2.h class TcpSocket: @@ -2234,7 +2233,7 @@ class TcpSocket: pass def __init__(self) -> None: - """Autogenerated default constructor""" + """Auto-generated default constructor""" pass #################### #################### @@ -2403,7 +2402,7 @@ class UdpSocket: pass def __init__(self) -> None: - """Autogenerated default constructor""" + """Auto-generated default constructor""" pass #################### #################### @@ -2613,7 +2612,7 @@ class Task: def __init__(self) -> None: - """Autogenerated default constructor""" + """Auto-generated default constructor""" pass # namespace espp @@ -2747,7 +2746,7 @@ class Timer: pass def __init__(self) -> None: - """Autogenerated default constructor""" + """Auto-generated default constructor""" pass #################### #################### diff --git a/lib/python_bindings/pybind_espp.cpp b/lib/python_bindings/pybind_espp.cpp index 10c728700..1bccafea4 100644 --- a/lib/python_bindings/pybind_espp.cpp +++ b/lib/python_bindings/pybind_espp.cpp @@ -79,10 +79,10 @@ void py_init_module_espp(py::module &m) { "the values to copy.\n") .def(py::init(), py::arg("hsv"), "*\n * @brief Construct an Rgb object from the provided Hsv object.\n * @note " - "This calls hsv.rgb() on the provided object, which means fthat\n * invalid " - "HSV data (not in the ranges [0,360], [0,1], and [0,1])\n * could lead to " - "bad RGB data. The Rgb constructor will automatically\n * convert the " - "values to be in the proper range, but the perceived\n * color will be " + "This calls hsv.rgb() on the provided object, which means that invalid\n * " + "HSV data (not in the ranges [0,360], [0,1], and [0,1]) could lead to\n * " + "bad RGB data. The Rgb constructor will automatically convert the\n * " + "values to be in the proper range, but the perceived color will be\n * " "changed.\n * @param hsv Hsv object to copy.\n") .def("__add__", &espp::Rgb::operator+, py::arg("rhs"), "*\n * @brief Perform additive color blending (averaging)\n * @param rhs Other " @@ -121,24 +121,13 @@ void py_init_module_espp(py::module &m) { .def("rgb", &espp::Hsv::rgb, "*\n * @brief Get a RGB representation of this HSV color.\n * @return An RGB " "object containing the RGB representation.\n"); - //////////////////// //////////////////// - //////////////////// //////////////////// - auto pyClass__csv_documentation__ = - py::class_( - m, "__csv_documentation__", py::dynamic_attr(), - "*\n * @brief Comma Separated Value (CSV) reader/writer convenience wrapper around\n * " - " p-ranav/csv2 which\n * " - "exposes csv2::Reader and csv2::Writer classes for managing efficient\n * " - "(lazy-loaded) parsing and serizaliztion of human-readable\n * CSV-formatted " - "data.\n *\n * @note This class does not really exist or do anything, but it's the " - "only\n * way I could figure out how to get this documentation built into the\n * " - " system :(\n *\n * \\section csv_ex1 CSV Reader Example\n * \\snippet " - "csv_example.cpp csv reader example\n * \\section csv_ex2 Complex CSV Writer Example\n * " - "\\snippet csv_example.cpp csv writer example\n") - .def(py::init<>()) // implicit default constructor - ; - //////////////////// //////////////////// + m.def("color_code", py::overload_cast(espp::color_code), py::arg("rgb"), + "\n(C++ auto return type)"); + + m.def("color_code", py::overload_cast(espp::color_code), py::arg("hsv"), + "\n(C++ auto return type)"); + //////////////////// //////////////////// //////////////////// //////////////////// auto pyClassEventManager = @@ -349,11 +338,13 @@ void py_init_module_espp(py::module &m) { "/< Array of 4 weights, default is array of 1.0"); } // end of inner classes & enums of Bezier_espp_Vector2f - pyClassBezier_espp_Vector2f.def( - "__call__", &espp::Bezier::operator(), py::arg("t"), - "*\n * @brief Evaluate the bezier at \\p t.\n * @note Convienience wrapper around " - "the at() method.\n * @param t The evaluation parameter, [0, 1].\n * @return The " - "bezier evaluated at \\p t.\n"); + pyClassBezier_espp_Vector2f.def(py::init::Config &>()) + .def(py::init::WeightedConfig &>()) + .def("__call__", &espp::Bezier::operator(), py::arg("t"), + "*\n * @brief Evaluate the bezier at \\p t.\n * @note Convienience wrapper around " + "the " + "at() method.\n * @param t The evaluation parameter, [0, 1].\n * @return The bezier " + "evaluated at \\p t.\n"); //////////////////// //////////////////// //////////////////// //////////////////// @@ -457,10 +448,11 @@ void py_init_module_espp(py::module &m) { "/< Max amplitude of the gaussian output, defautls to 1.0.") .def_readwrite( "beta", &espp::Gaussian::Config::beta, - "/< Beta value for the gaussian, default to be symmetric at 0.5 in range [0,1]."); + "/< Beta value for the gaussian, default to be symmetric at 0.5 in range [0,1].") + .def("__eq__", &espp::Gaussian::Config::operator==, py::arg("rhs")); } // end of inner classes & enums of Gaussian - pyClassGaussian + pyClassGaussian.def(py::init()) .def("__call__", &espp::Gaussian::operator(), py::arg("t"), "*\n * @brief Evaluate the gaussian at \\p t.\n * @note Convienience wrapper around " "the at() method.\n * @param t The evaluation parameter, [0, 1].\n * @return The "