Skip to content

Commit 1e646c9

Browse files
committed
Revert "Systematically change most py::class_ to py::classh under docs/"
This reverts commit ac9d31e.
1 parent ff7c087 commit 1e646c9

File tree

8 files changed

+141
-114
lines changed

8 files changed

+141
-114
lines changed

Diff for: docs/advanced/cast/eigen.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ example:
102102
};
103103
104104
// Later, in binding code:
105-
py::classh<MyClass>(m, "MyClass")
105+
py::class_<MyClass>(m, "MyClass")
106106
.def(py::init<>())
107107
.def("copy_matrix", &MyClass::getMatrix) // Makes a copy!
108108
.def("get_matrix", &MyClass::getMatrix, py::return_value_policy::reference_internal)
@@ -250,7 +250,7 @@ copying to take place:
250250
251251
// The associated binding code:
252252
using namespace pybind11::literals; // for "arg"_a
253-
py::classh<MyClass>(m, "MyClass")
253+
py::class_<MyClass>(m, "MyClass")
254254
// ... other class definitions
255255
.def("some_method", &MyClass::some_method, py::arg().noconvert());
256256

Diff for: docs/advanced/cast/overview.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ Overview
33

44
.. rubric:: 1. Native type in C++, wrapper in Python
55

6-
Exposing a custom C++ type using ``py::classh`` (or ``py::class_``) was
7-
covered in detail in the :doc:`/classes` section. There, the underlying
8-
data structure is always the original C++ class while the ``py::classh``
9-
wrapper provides a Python interface. Internally, when an object like this
10-
is sent from C++ to Python, pybind11 will just add the outer wrapper layer
11-
over the native C++ object. Getting it back from Python is just a matter of
12-
peeling off the wrapper.
6+
Exposing a custom C++ type using :class:`py::class_` was covered in detail
7+
in the :doc:`/classes` section. There, the underlying data structure is
8+
always the original C++ class while the :class:`py::class_` wrapper provides
9+
a Python interface. Internally, when an object like this is sent from C++ to
10+
Python, pybind11 will just add the outer wrapper layer over the native C++
11+
object. Getting it back from Python is just a matter of peeling off the
12+
wrapper.
1313

1414
.. rubric:: 2. Wrapper in C++, native type in Python
1515

Diff for: docs/advanced/cast/stl.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ functions:
135135
136136
/* ... binding code ... */
137137
138-
py::classh<MyClass>(m, "MyClass")
138+
py::class_<MyClass>(m, "MyClass")
139139
.def(py::init<>())
140140
.def_readwrite("contents", &MyClass::contents);
141141
@@ -169,12 +169,12 @@ macro must be specified at the top level (and outside of any namespaces), since
169169
it adds a template instantiation of ``type_caster``. If your binding code consists of
170170
multiple compilation units, it must be present in every file (typically via a
171171
common header) preceding any usage of ``std::vector<int>``. Opaque types must
172-
also have a corresponding ``py::classh`` declaration to associate them with a name
172+
also have a corresponding ``class_`` declaration to associate them with a name
173173
in Python, and to define a set of available operations, e.g.:
174174

175175
.. code-block:: cpp
176176
177-
py::classh<std::vector<int>>(m, "IntVector")
177+
py::class_<std::vector<int>>(m, "IntVector")
178178
.def(py::init<>())
179179
.def("clear", &std::vector<int>::clear)
180180
.def("pop_back", &std::vector<int>::pop_back)

0 commit comments

Comments
 (0)