Add 'xo-pyprintjson/' from commit '36797a419a'
git-subtree-dir: xo-pyprintjson git-subtree-mainline:9aa938c58dgit-subtree-split:36797a419a
This commit is contained in:
commit
7c6114bf46
11 changed files with 428 additions and 0 deletions
49
xo-pyprintjson/src/pyprintjson/pyprintjson.cpp
Normal file
49
xo-pyprintjson/src/pyprintjson/pyprintjson.cpp
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/* @file pyprintjson.cpp */
|
||||
|
||||
// note: need pyreflect/ here bc pyreflect.hpp is generated, located in build directory
|
||||
#include "pyprintjson.hpp"
|
||||
#include "xo/pyreflect/pyreflect.hpp"
|
||||
|
||||
#include "xo/printjson/PrintJson.hpp"
|
||||
#include "xo/reflect/TaggedRcptr.hpp"
|
||||
//#include "reflect/SelfTagging.hpp"
|
||||
//#include "refcnt/Refcounted.hpp"
|
||||
//#include "refcnt/Unowned.hpp"
|
||||
#include "xo/pyutil/pyutil.hpp"
|
||||
//#include <pybind11/pybind11.h>
|
||||
//#include <pybind11/stl.h>
|
||||
//#include <pybind11/chrono.h>
|
||||
//#include <pybind11/operators.h>
|
||||
|
||||
namespace xo {
|
||||
namespace py = pybind11;
|
||||
|
||||
namespace json {
|
||||
using xo::reflect::SelfTagging;
|
||||
using xo::reflect::TaggedRcptr;
|
||||
using xo::ref::unowned_ptr;
|
||||
|
||||
PYBIND11_MODULE(PYPRINTJSON_MODULE_NAME(), m) {
|
||||
PYREFLECT_IMPORT_MODULE();
|
||||
|
||||
py::class_<PrintJson, rp<PrintJson>>(m, "PrintJson")
|
||||
.def_static("instance", &PrintJsonSingleton::instance)
|
||||
.def("print",
|
||||
[](PrintJson & pj, TaggedRcptr p)
|
||||
{
|
||||
pj.print_tp(p, &std::cout); std::cout << "\n";
|
||||
},
|
||||
py::arg("value"))
|
||||
.def("print",
|
||||
[](PrintJson & pj, rp<SelfTagging> const & p)
|
||||
{
|
||||
pj.print_obj(p, &std::cout); std::cout << "\n";
|
||||
},
|
||||
py::arg("value"));
|
||||
|
||||
//m.def("print_json", [](){ return PrintJsonSingleton::instance_ptr(); });
|
||||
} /*pyprintjson*/
|
||||
} /*namespace json*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end pyprintjson.cpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue