@@ -956,11 +956,13 @@ class module_ : public object {
956956#endif
957957 }
958958
959+ // clang-format off
959960 /* * \rst
960961 Create Python binding for a new function within the module scope. ``Func``
961962 can be a plain C++ function, a function pointer, or a lambda function. For
962963 details on the ``Extra&& ... extra`` argument, see section :ref:`extras`.
963964 \endrst */
965+ // clang-format on
964966 template <typename Func, typename ... Extra>
965967 module_ &def (const char *name_, Func &&f, const Extra& ... extra) {
966968 cpp_function func (std::forward<Func>(f), name (name_), scope (*this ),
@@ -971,6 +973,7 @@ class module_ : public object {
971973 return *this ;
972974 }
973975
976+ // clang-format off
974977 /* * \rst
975978 Create and return a new Python submodule with the given name and docstring.
976979 This also works recursively, i.e.
@@ -981,6 +984,7 @@ class module_ : public object {
981984 py::module_ m2 = m.def_submodule("sub", "A submodule of 'example'");
982985 py::module_ m3 = m2.def_submodule("subsub", "A submodule of 'example.sub'");
983986 \endrst */
987+ // clang-format on
984988 module_ def_submodule (const char *name, const char *doc = nullptr ) {
985989 std::string full_name = std::string (PyModule_GetName (m_ptr))
986990 + std::string (" ." ) + std::string (name);
@@ -1007,13 +1011,15 @@ class module_ : public object {
10071011 *this = reinterpret_steal<module_>(obj);
10081012 }
10091013
1014+ // clang-format off
10101015 /* * \rst
10111016 Adds an object to the module using the given name. Throws if an object with the given name
10121017 already exists.
10131018
10141019 ``overwrite`` should almost always be false: attempting to overwrite objects that pybind11 has
10151020 established will, in most cases, break things.
10161021 \endrst */
1022+ // clang-format on
10171023 PYBIND11_NOINLINE void add_object (const char *name, handle obj, bool overwrite = false ) {
10181024 if (!overwrite && hasattr (*this , name))
10191025 pybind11_fail (" Error during initialization: multiple incompatible definitions with name \" " +
@@ -1028,12 +1034,14 @@ class module_ : public object {
10281034 struct module_def {};
10291035#endif
10301036
1037+ // clang-format off
10311038 /* * \rst
10321039 Create a new top-level module that can be used as the main module of a C extension.
10331040
10341041 For Python 3, ``def`` should point to a statically allocated module_def.
10351042 For Python 2, ``def`` can be a nullptr and is completely ignored.
10361043 \endrst */
1044+ // clang-format on
10371045 static module_ create_extension_module (const char *name, const char *doc, module_def *def) {
10381046#if PY_MAJOR_VERSION >= 3
10391047 // module_def is PyModuleDef
@@ -2173,14 +2181,16 @@ inline function get_type_override(const void *this_ptr, const type_info *this_ty
21732181}
21742182PYBIND11_NAMESPACE_END (detail)
21752183
2184+ // clang-format off
21762185/* * \rst
21772186 Try to retrieve a python method by the provided name from the instance pointed to by the this_ptr.
21782187
21792188 :this_ptr: The pointer to the object the overridden method should be retrieved for. This should be
21802189 the first non-trampoline class encountered in the inheritance chain.
21812190 :name: The name of the overridden Python method to retrieve.
21822191 :return: The Python method by this name from the object or an empty function wrapper.
2183- \endrst */
2192+ \endrst */
2193+ // clang-format on
21842194template <class T > function get_override (const T *this_ptr, const char *name) {
21852195 auto tinfo = detail::get_type_info (typeid (T));
21862196 return tinfo ? detail::get_type_override (this_ptr, tinfo, name) : function ();
@@ -2200,6 +2210,7 @@ template <class T> function get_override(const T *this_ptr, const char *name) {
22002210 } \
22012211 } while (false )
22022212
2213+ // clang-format off
22032214/* * \rst
22042215 Macro to populate the virtual method in the trampoline class. This macro tries to look up a method named 'fn'
22052216 from the Python side, deals with the :ref:`gil` and necessary argument conversions to call this method and return
@@ -2217,22 +2228,26 @@ template <class T> function get_override(const T *this_ptr, const char *name) {
22172228 );
22182229 }
22192230\endrst */
2231+ // clang-format on
22202232#define PYBIND11_OVERRIDE_NAME (ret_type, cname, name, fn, ...) \
22212233 do { \
22222234 PYBIND11_OVERRIDE_IMPL (PYBIND11_TYPE (ret_type), PYBIND11_TYPE (cname), name, __VA_ARGS__); \
22232235 return cname::fn (__VA_ARGS__); \
22242236 } while (false )
22252237
2238+ // clang-format off
22262239/* * \rst
22272240 Macro for pure virtual functions, this function is identical to :c:macro:`PYBIND11_OVERRIDE_NAME`, except that it
22282241 throws if no override can be found.
22292242\endrst */
2243+ // clang-format on
22302244#define PYBIND11_OVERRIDE_PURE_NAME (ret_type, cname, name, fn, ...) \
22312245 do { \
22322246 PYBIND11_OVERRIDE_IMPL (PYBIND11_TYPE (ret_type), PYBIND11_TYPE (cname), name, __VA_ARGS__); \
22332247 pybind11::pybind11_fail (" Tried to call pure virtual function \" " PYBIND11_STRINGIFY (cname) " ::" name " \" " ); \
22342248 } while (false )
22352249
2250+ // clang-format off
22362251/* * \rst
22372252 Macro to populate the virtual method in the trampoline class. This macro tries to look up the method
22382253 from the Python side, deals with the :ref:`gil` and necessary argument conversions to call this method and return
@@ -2257,13 +2272,16 @@ template <class T> function get_override(const T *this_ptr, const char *name) {
22572272 }
22582273 };
22592274\endrst */
2275+ // clang-format on
22602276#define PYBIND11_OVERRIDE (ret_type, cname, fn, ...) \
22612277 PYBIND11_OVERRIDE_NAME (PYBIND11_TYPE (ret_type), PYBIND11_TYPE (cname), #fn, fn, __VA_ARGS__)
22622278
2279+ // clang-format off
22632280/* * \rst
22642281 Macro for pure virtual functions, this function is identical to :c:macro:`PYBIND11_OVERRIDE`, except that it throws
22652282 if no override can be found.
22662283\endrst */
2284+ // clang-format on
22672285#define PYBIND11_OVERRIDE_PURE (ret_type, cname, fn, ...) \
22682286 PYBIND11_OVERRIDE_PURE_NAME (PYBIND11_TYPE (ret_type), PYBIND11_TYPE (cname), #fn, fn, __VA_ARGS__)
22692287
0 commit comments