API_Py  0.0.2
API_Py exporte le projet API vers un module python dans l’environnement python choisi. Le module python se nomme wxcpppy.
Vector.cpp
Aller à la documentation de ce fichier.
1 
8 #include "API_Py/Vector.h"
9 
10 #include <pybind11/operators.h>
11 #include "API/API.h"
12 #include <sstream>
13 
14 using namespace pybind11::literals;
15 
16 void API_Py::Vector::SetModule(py::module &inModule)
17 {
18  using Vector3 = API::Math::Vector3<float>;
19 
20  // https://pybind11.readthedocs.io/en/master/advanced/classes.html#operator-overloading
21 
22  auto pyVector3 = py::class_<Vector3>(inModule, "Vector3")
23  .def(py::init<>())
24  .def(py::init<Vector3::component_type, Vector3::component_type, Vector3::component_type>())
25  .def(py::init<const Vector3 &>())
26  .def(py::init<const Vector3::component_type>())
27  .def_readwrite("x", &Vector3::x)
28  .def_readwrite("y", &Vector3::y)
29  .def_readwrite("z", &Vector3::z)
30  .def("swap", &Vector3::swap, R"pbdoc(
31  Exchange the contents of this vector with another.
32  )pbdoc")
33  .def("__repr__",
34  [](const Vector3 &value) {
35  std::stringstream ss;
36  ss << value;
37  return std::string("<wxCppPy.Vector3<float>( '") + ss.str() + std::string("' )>");
38  }
39  );
40  /*.def(py::self = py::self)
41  .def(py::self = Vector3::component_type, R"pbdoc(
42  Assigns the value of the other vector.
43  :param inVector: inVector The other vector
44  :return: a reference of this vector.
45  :rtype: Vector3
46  )pbdoc")*/;
47 }
48