/* @file pyreflect.cpp */ // note: need pyreflect/ here bc pyreflect.hpp is generated, located in build directory #include "pyreflect.hpp" #include "xo/reflect/TypeDescr.hpp" #include "xo/reflect/TaggedRcptr.hpp" #include "xo/reflect/SelfTagging.hpp" //#include "time/Time.hpp" //#include "xo/pyutil/pytime.hpp" #include "xo/pyutil/pyutil.hpp" //#include //#include //#include //#include namespace xo { using xo::time::utc_nanos; using xo::ref::unowned_ptr; using xo::ref::rp; namespace py = pybind11; namespace reflect { PYBIND11_MODULE(PYREFLECT_MODULE_NAME(), m) { /* note: possibly move this to pytime/ if/when we provide it */ //py::class_(m, "utc_nanos"); //py::class_(m, "TypeDescr"); py::class_>(m, "TypeDescr") .def_static("lookup_by_name", &TypeDescrBase::lookup_by_name) .def_static("print_reflected_types", [](){ TypeDescrBase::print_reflected_types(std::cout); }) .def_property_readonly("canonical_name", &TypeDescrBase::canonical_name) .def_property_readonly("short_name", &TypeDescrBase::short_name) .def_property_readonly("complete_flag", &TypeDescrBase::complete_flag) .def("__repr__", &TypeDescrBase::display_string); /* note: this means python will use * std::unique_ptr * when it encounters a TaggedRcptr instance. * Maintains refcount at cost of 2nd level of indirection. */ py::class_(m, "TaggedRcptr") .def_property_readonly("td", &TaggedPtr::td) .def("__repr__", &TaggedRcptr::display_string); py::class_>(m, "SelfTagging") .def("self_tp", &SelfTagging::self_tp); } /*pyreflect*/ } /*namespace reflect*/ } /*namespace xo*/ /* end pyreflect.cpp */