blob: 819f69f44990dddacbd741dab29d6b20028b8324 [file] [log] [blame]
Wenzel Jakob38bd7112015-07-05 20:05:44 +02001/*
2 example/example.cpp -- pybind example plugin
3
Wenzel Jakob8cb6cb32016-04-17 20:21:41 +02004 Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
Wenzel Jakob38bd7112015-07-05 20:05:44 +02005
6 All rights reserved. Use of this source code is governed by a
7 BSD-style license that can be found in the LICENSE file.
8*/
9
10#include "example.h"
Jason Rhinelander3f589372016-08-07 13:05:26 -040011#include "constructor-stats.h"
Wenzel Jakob38bd7112015-07-05 20:05:44 +020012
Jason Rhinelanderb3f3d792016-07-18 16:43:18 -040013void init_ex_methods_and_attributes(py::module &);
14void init_ex_python_types(py::module &);
15void init_ex_operator_overloading(py::module &);
16void init_ex_constants_and_functions(py::module &);
17void init_ex_callbacks(py::module &);
18void init_ex_sequences_and_iterators(py::module &);
19void init_ex_buffers(py::module &);
20void init_ex_smart_ptr(py::module &);
21void init_ex_modules(py::module &);
22void init_ex_numpy_vectorize(py::module &);
23void init_ex_arg_keywords_and_defaults(py::module &);
24void init_ex_virtual_functions(py::module &);
25void init_ex_keep_alive(py::module &);
26void init_ex_opaque_types(py::module &);
27void init_ex_pickling(py::module &);
28void init_ex_inheritance(py::module &);
29void init_ex_stl_binder_vector(py::module &);
30void init_ex_eval(py::module &);
31void init_ex_custom_exceptions(py::module &);
Ivan Smirnovbb4015d2016-06-19 15:50:31 +010032void init_ex20(py::module &);
Wenzel Jakob17cdb062016-03-10 13:24:10 +010033void init_issues(py::module &);
Wenzel Jakob38bd7112015-07-05 20:05:44 +020034
Wenzel Jakob9e0a0562016-05-05 20:33:54 +020035#if defined(PYBIND11_TEST_EIGEN)
36 void init_eigen(py::module &);
37#endif
38
Jason Rhinelander3f589372016-08-07 13:05:26 -040039void bind_ConstructorStats(py::module &m) {
40 py::class_<ConstructorStats>(m, "ConstructorStats")
41 .def("alive", &ConstructorStats::alive)
42 .def("values", &ConstructorStats::values)
43 .def_readwrite("default_constructions", &ConstructorStats::default_constructions)
44 .def_readwrite("copy_assignments", &ConstructorStats::copy_assignments)
45 .def_readwrite("move_assignments", &ConstructorStats::move_assignments)
46 .def_readwrite("copy_constructions", &ConstructorStats::copy_constructions)
47 .def_readwrite("move_constructions", &ConstructorStats::move_constructions)
48 .def_static("get", (ConstructorStats &(*)(py::object)) &ConstructorStats::get, py::return_value_policy::reference_internal)
49 ;
50}
51
Wenzel Jakobb1b71402015-10-18 16:48:30 +020052PYBIND11_PLUGIN(example) {
Wenzel Jakob38bd7112015-07-05 20:05:44 +020053 py::module m("example", "pybind example plugin");
54
Jason Rhinelander3f589372016-08-07 13:05:26 -040055 bind_ConstructorStats(m);
56
Jason Rhinelanderb3f3d792016-07-18 16:43:18 -040057 init_ex_methods_and_attributes(m);
58 init_ex_python_types(m);
59 init_ex_operator_overloading(m);
60 init_ex_constants_and_functions(m);
61 init_ex_callbacks(m);
62 init_ex_sequences_and_iterators(m);
63 init_ex_buffers(m);
64 init_ex_smart_ptr(m);
65 init_ex_modules(m);
66 init_ex_numpy_vectorize(m);
67 init_ex_arg_keywords_and_defaults(m);
68 init_ex_virtual_functions(m);
69 init_ex_keep_alive(m);
70 init_ex_opaque_types(m);
71 init_ex_pickling(m);
72 init_ex_inheritance(m);
73 init_ex_stl_binder_vector(m);
74 init_ex_eval(m);
75 init_ex_custom_exceptions(m);
Ivan Smirnovbb4015d2016-06-19 15:50:31 +010076 init_ex20(m);
Wenzel Jakob17cdb062016-03-10 13:24:10 +010077 init_issues(m);
Wenzel Jakob38bd7112015-07-05 20:05:44 +020078
Wenzel Jakob9e0a0562016-05-05 20:33:54 +020079 #if defined(PYBIND11_TEST_EIGEN)
80 init_eigen(m);
81 #endif
82
Wenzel Jakob38bd7112015-07-05 20:05:44 +020083 return m.ptr();
84}