Wenzel Jakob | 38bd711 | 2015-07-05 20:05:44 +0200 | [diff] [blame] | 1 | /* |
| 2 | example/example.cpp -- pybind example plugin |
| 3 | |
Wenzel Jakob | 8cb6cb3 | 2016-04-17 20:21:41 +0200 | [diff] [blame] | 4 | Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch> |
Wenzel Jakob | 38bd711 | 2015-07-05 20:05:44 +0200 | [diff] [blame] | 5 | |
| 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 Rhinelander | 3f58937 | 2016-08-07 13:05:26 -0400 | [diff] [blame] | 11 | #include "constructor-stats.h" |
Wenzel Jakob | 38bd711 | 2015-07-05 20:05:44 +0200 | [diff] [blame] | 12 | |
Jason Rhinelander | b3f3d79 | 2016-07-18 16:43:18 -0400 | [diff] [blame] | 13 | void init_ex_methods_and_attributes(py::module &); |
| 14 | void init_ex_python_types(py::module &); |
| 15 | void init_ex_operator_overloading(py::module &); |
| 16 | void init_ex_constants_and_functions(py::module &); |
| 17 | void init_ex_callbacks(py::module &); |
| 18 | void init_ex_sequences_and_iterators(py::module &); |
| 19 | void init_ex_buffers(py::module &); |
| 20 | void init_ex_smart_ptr(py::module &); |
| 21 | void init_ex_modules(py::module &); |
| 22 | void init_ex_numpy_vectorize(py::module &); |
| 23 | void init_ex_arg_keywords_and_defaults(py::module &); |
| 24 | void init_ex_virtual_functions(py::module &); |
| 25 | void init_ex_keep_alive(py::module &); |
| 26 | void init_ex_opaque_types(py::module &); |
| 27 | void init_ex_pickling(py::module &); |
| 28 | void init_ex_inheritance(py::module &); |
| 29 | void init_ex_stl_binder_vector(py::module &); |
| 30 | void init_ex_eval(py::module &); |
| 31 | void init_ex_custom_exceptions(py::module &); |
Ivan Smirnov | bb4015d | 2016-06-19 15:50:31 +0100 | [diff] [blame] | 32 | void init_ex20(py::module &); |
Wenzel Jakob | 17cdb06 | 2016-03-10 13:24:10 +0100 | [diff] [blame] | 33 | void init_issues(py::module &); |
Wenzel Jakob | 38bd711 | 2015-07-05 20:05:44 +0200 | [diff] [blame] | 34 | |
Wenzel Jakob | 9e0a056 | 2016-05-05 20:33:54 +0200 | [diff] [blame] | 35 | #if defined(PYBIND11_TEST_EIGEN) |
| 36 | void init_eigen(py::module &); |
| 37 | #endif |
| 38 | |
Jason Rhinelander | 3f58937 | 2016-08-07 13:05:26 -0400 | [diff] [blame] | 39 | void 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 Jakob | b1b7140 | 2015-10-18 16:48:30 +0200 | [diff] [blame] | 52 | PYBIND11_PLUGIN(example) { |
Wenzel Jakob | 38bd711 | 2015-07-05 20:05:44 +0200 | [diff] [blame] | 53 | py::module m("example", "pybind example plugin"); |
| 54 | |
Jason Rhinelander | 3f58937 | 2016-08-07 13:05:26 -0400 | [diff] [blame] | 55 | bind_ConstructorStats(m); |
| 56 | |
Jason Rhinelander | b3f3d79 | 2016-07-18 16:43:18 -0400 | [diff] [blame] | 57 | 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 Smirnov | bb4015d | 2016-06-19 15:50:31 +0100 | [diff] [blame] | 76 | init_ex20(m); |
Wenzel Jakob | 17cdb06 | 2016-03-10 13:24:10 +0100 | [diff] [blame] | 77 | init_issues(m); |
Wenzel Jakob | 38bd711 | 2015-07-05 20:05:44 +0200 | [diff] [blame] | 78 | |
Wenzel Jakob | 9e0a056 | 2016-05-05 20:33:54 +0200 | [diff] [blame] | 79 | #if defined(PYBIND11_TEST_EIGEN) |
| 80 | init_eigen(m); |
| 81 | #endif |
| 82 | |
Wenzel Jakob | 38bd711 | 2015-07-05 20:05:44 +0200 | [diff] [blame] | 83 | return m.ptr(); |
| 84 | } |