mirror of
https://github.com/pybind/pybind11.git
synced 2025-02-07 17:32:00 +00:00
Automatic part of merging branch 'master' into sh_merge_master.
The only manual intervention was to remove the merge conflict markers in pybind11.h. TODO in separate commit: complete removal of the obsolete detail/pragma_warning_block.h.
This commit is contained in:
commit
8865d28317
@ -1,6 +1,7 @@
|
|||||||
FormatStyle: file
|
FormatStyle: file
|
||||||
|
|
||||||
Checks: '
|
Checks: '
|
||||||
|
*bugprone*,
|
||||||
cppcoreguidelines-init-variables,
|
cppcoreguidelines-init-variables,
|
||||||
clang-analyzer-optin.cplusplus.VirtualCall,
|
clang-analyzer-optin.cplusplus.VirtualCall,
|
||||||
llvm-namespace-comment,
|
llvm-namespace-comment,
|
||||||
@ -43,6 +44,9 @@ readability-static-accessed-through-instance,
|
|||||||
readability-static-definition-in-anonymous-namespace,
|
readability-static-definition-in-anonymous-namespace,
|
||||||
readability-string-compare,
|
readability-string-compare,
|
||||||
readability-uniqueptr-delete-release,
|
readability-uniqueptr-delete-release,
|
||||||
|
-bugprone-exception-escape,
|
||||||
|
-bugprone-reserved-identifier,
|
||||||
|
-bugprone-unused-raii,
|
||||||
'
|
'
|
||||||
|
|
||||||
CheckOptions:
|
CheckOptions:
|
||||||
|
22
.github/workflows/ci.yml
vendored
22
.github/workflows/ci.yml
vendored
@ -76,7 +76,7 @@ jobs:
|
|||||||
run: brew install boost
|
run: brew install boost
|
||||||
|
|
||||||
- name: Update CMake
|
- name: Update CMake
|
||||||
uses: jwlawson/actions-setup-cmake@v1.9
|
uses: jwlawson/actions-setup-cmake@v1.10
|
||||||
|
|
||||||
- name: Cache wheels
|
- name: Cache wheels
|
||||||
if: runner.os == 'macOS'
|
if: runner.os == 'macOS'
|
||||||
@ -194,7 +194,7 @@ jobs:
|
|||||||
debug: ${{ matrix.python-debug }}
|
debug: ${{ matrix.python-debug }}
|
||||||
|
|
||||||
- name: Update CMake
|
- name: Update CMake
|
||||||
uses: jwlawson/actions-setup-cmake@v1.9
|
uses: jwlawson/actions-setup-cmake@v1.10
|
||||||
|
|
||||||
- name: Valgrind cache
|
- name: Valgrind cache
|
||||||
if: matrix.valgrind
|
if: matrix.valgrind
|
||||||
@ -446,7 +446,7 @@ jobs:
|
|||||||
run: python3 -m pip install --upgrade pip
|
run: python3 -m pip install --upgrade pip
|
||||||
|
|
||||||
- name: Update CMake
|
- name: Update CMake
|
||||||
uses: jwlawson/actions-setup-cmake@v1.9
|
uses: jwlawson/actions-setup-cmake@v1.10
|
||||||
|
|
||||||
- name: Configure
|
- name: Configure
|
||||||
shell: bash
|
shell: bash
|
||||||
@ -595,13 +595,13 @@ jobs:
|
|||||||
|
|
||||||
- name: VAR_BUILD_TYPE 7
|
- name: VAR_BUILD_TYPE 7
|
||||||
if: matrix.centos == 7
|
if: matrix.centos == 7
|
||||||
run: echo Release > VAR_BUILD_TYPE
|
run: echo MinSizeRel > VAR_BUILD_TYPE
|
||||||
|
|
||||||
# Using Debug to avoid segfault that appeared around 2021-06-04,
|
# Using Release to avoid segfault that appeared around 2021-06-04,
|
||||||
# apparently when the gcc version changed from 8.3 to 8.4.
|
# apparently when the gcc version changed from 8.3 to 8.4.
|
||||||
- name: VAR_BUILD_TYPE 8
|
- name: VAR_BUILD_TYPE 8
|
||||||
if: matrix.centos == 8
|
if: matrix.centos == 8
|
||||||
run: echo Debug > VAR_BUILD_TYPE
|
run: echo Release > VAR_BUILD_TYPE
|
||||||
|
|
||||||
- name: Configure
|
- name: Configure
|
||||||
shell: bash
|
shell: bash
|
||||||
@ -665,7 +665,7 @@ jobs:
|
|||||||
-DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)")
|
-DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)")
|
||||||
working-directory: /build-tests
|
working-directory: /build-tests
|
||||||
|
|
||||||
- name: Run tests
|
- name: Python tests
|
||||||
run: make pytest -j 2
|
run: make pytest -j 2
|
||||||
working-directory: /build-tests
|
working-directory: /build-tests
|
||||||
|
|
||||||
@ -739,7 +739,7 @@ jobs:
|
|||||||
architecture: x86
|
architecture: x86
|
||||||
|
|
||||||
- name: Update CMake
|
- name: Update CMake
|
||||||
uses: jwlawson/actions-setup-cmake@v1.9
|
uses: jwlawson/actions-setup-cmake@v1.10
|
||||||
|
|
||||||
- name: Prepare MSVC
|
- name: Prepare MSVC
|
||||||
uses: ilammy/msvc-dev-cmd@v1.9.0
|
uses: ilammy/msvc-dev-cmd@v1.9.0
|
||||||
@ -761,7 +761,7 @@ jobs:
|
|||||||
- name: Build C++11
|
- name: Build C++11
|
||||||
run: cmake --build build -j 2
|
run: cmake --build build -j 2
|
||||||
|
|
||||||
- name: Run tests
|
- name: Python tests
|
||||||
run: cmake --build build -t pytest
|
run: cmake --build build -t pytest
|
||||||
|
|
||||||
win32-msvc2015:
|
win32-msvc2015:
|
||||||
@ -785,7 +785,7 @@ jobs:
|
|||||||
python-version: ${{ matrix.python }}
|
python-version: ${{ matrix.python }}
|
||||||
|
|
||||||
- name: Update CMake
|
- name: Update CMake
|
||||||
uses: jwlawson/actions-setup-cmake@v1.9
|
uses: jwlawson/actions-setup-cmake@v1.10
|
||||||
|
|
||||||
- name: Prepare MSVC
|
- name: Prepare MSVC
|
||||||
uses: ilammy/msvc-dev-cmd@v1.9.0
|
uses: ilammy/msvc-dev-cmd@v1.9.0
|
||||||
@ -839,7 +839,7 @@ jobs:
|
|||||||
python-version: ${{ matrix.python }}
|
python-version: ${{ matrix.python }}
|
||||||
|
|
||||||
- name: Update CMake
|
- name: Update CMake
|
||||||
uses: jwlawson/actions-setup-cmake@v1.9
|
uses: jwlawson/actions-setup-cmake@v1.10
|
||||||
|
|
||||||
- name: Prepare env
|
- name: Prepare env
|
||||||
run: python -m pip install -r tests/requirements.txt --prefer-binary
|
run: python -m pip install -r tests/requirements.txt --prefer-binary
|
||||||
|
2
.github/workflows/configure.yml
vendored
2
.github/workflows/configure.yml
vendored
@ -56,7 +56,7 @@ jobs:
|
|||||||
# An action for adding a specific version of CMake:
|
# An action for adding a specific version of CMake:
|
||||||
# https://github.com/jwlawson/actions-setup-cmake
|
# https://github.com/jwlawson/actions-setup-cmake
|
||||||
- name: Setup CMake ${{ matrix.cmake }}
|
- name: Setup CMake ${{ matrix.cmake }}
|
||||||
uses: jwlawson/actions-setup-cmake@v1.9
|
uses: jwlawson/actions-setup-cmake@v1.10
|
||||||
with:
|
with:
|
||||||
cmake-version: ${{ matrix.cmake }}
|
cmake-version: ${{ matrix.cmake }}
|
||||||
|
|
||||||
|
@ -32,10 +32,15 @@ repos:
|
|||||||
exclude: ^noxfile.py$
|
exclude: ^noxfile.py$
|
||||||
|
|
||||||
- repo: https://github.com/asottile/pyupgrade
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
rev: v2.23.0
|
rev: v2.23.3
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyupgrade
|
- id: pyupgrade
|
||||||
|
|
||||||
|
- repo: https://github.com/PyCQA/isort
|
||||||
|
rev: 5.9.3
|
||||||
|
hooks:
|
||||||
|
- id: isort
|
||||||
|
|
||||||
# Black, the code formatter, natively supports pre-commit
|
# Black, the code formatter, natively supports pre-commit
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 21.7b0
|
rev: 21.7b0
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import random
|
|
||||||
import os
|
|
||||||
import time
|
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
|
import os
|
||||||
|
import random
|
||||||
|
import time
|
||||||
|
|
||||||
nfns = 4 # Functions per class
|
nfns = 4 # Functions per class
|
||||||
nargs = 4 # Arguments per function
|
nargs = 4 # Arguments per function
|
||||||
|
@ -6,9 +6,54 @@ Changelog
|
|||||||
Starting with version 1.8.0, pybind11 releases use a `semantic versioning
|
Starting with version 1.8.0, pybind11 releases use a `semantic versioning
|
||||||
<http://semver.org>`_ policy.
|
<http://semver.org>`_ policy.
|
||||||
|
|
||||||
Next version (WIP)
|
v2.8.0 (WIP)
|
||||||
------------------
|
------------
|
||||||
|
|
||||||
|
* Allow exception translators to be optionally registered local to a module
|
||||||
|
instead of applying globally across all pybind11 modules. Use
|
||||||
|
``register_local_exception_translator(ExceptionTranslator&& translator)``
|
||||||
|
instead of ``register_exception_translator(ExceptionTranslator&&
|
||||||
|
translator)`` to keep your exception remapping code local to the module.
|
||||||
|
`#2650 <https://github.com/pybind/pybind11/pull/2650>`_
|
||||||
|
|
||||||
|
v2.7.1 (Aug 3, 2021)
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
Minor missing functionality added:
|
||||||
|
|
||||||
|
* Allow Python builtins to be used as callbacks in CPython.
|
||||||
|
`#1413 <https://github.com/pybind/pybind11/pull/1413>`_
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
|
* Fix regression in CMake Python package config: improper use of absolute path.
|
||||||
|
`#3144 <https://github.com/pybind/pybind11/pull/3144>`_
|
||||||
|
|
||||||
|
* Fix Mingw64 and add to the CI testing matrix.
|
||||||
|
`#3132 <https://github.com/pybind/pybind11/pull/3132>`_
|
||||||
|
|
||||||
|
* Specified UTF8-encoding in setup.py calls of open().
|
||||||
|
`#3137 <https://github.com/pybind/pybind11/pull/3137>`_
|
||||||
|
|
||||||
|
* Add clang-tidy-readability rules to make boolean casts explicit improving
|
||||||
|
code readability. Also enabled other misc and readability clang-tidy checks.
|
||||||
|
`#3148 <https://github.com/pybind/pybind11/pull/3148>`_
|
||||||
|
|
||||||
|
* Move object in ``.pop()`` for list.
|
||||||
|
`#3116 <https://github.com/pybind/pybind11/pull/3116>`_
|
||||||
|
|
||||||
|
Backend and tidying up:
|
||||||
|
|
||||||
|
* Removed and fixed warning suppressions.
|
||||||
|
`#3127 <https://github.com/pybind/pybind11/pull/3127>`_
|
||||||
|
`#3129 <https://github.com/pybind/pybind11/pull/3129>`_
|
||||||
|
`#3135 <https://github.com/pybind/pybind11/pull/3135>`_
|
||||||
|
`#3141 <https://github.com/pybind/pybind11/pull/3141>`_
|
||||||
|
`#3142 <https://github.com/pybind/pybind11/pull/3142>`_
|
||||||
|
`#3150 <https://github.com/pybind/pybind11/pull/3150>`_
|
||||||
|
`#3152 <https://github.com/pybind/pybind11/pull/3152>`_
|
||||||
|
`#3160 <https://github.com/pybind/pybind11/pull/3160>`_
|
||||||
|
`#3161 <https://github.com/pybind/pybind11/pull/3161>`_
|
||||||
|
|
||||||
|
|
||||||
v2.7.0 (Jul 16, 2021)
|
v2.7.0 (Jul 16, 2021)
|
||||||
|
@ -13,12 +13,12 @@
|
|||||||
# All configuration values have a default; values that are commented out
|
# All configuration values have a default; values that are commented out
|
||||||
# serve to show the default.
|
# serve to show the default.
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import shlex
|
import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import re
|
|
||||||
|
|
||||||
DIR = Path(__file__).parent.resolve()
|
DIR = Path(__file__).parent.resolve()
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ enum op_id : int;
|
|||||||
enum op_type : int;
|
enum op_type : int;
|
||||||
struct undefined_t;
|
struct undefined_t;
|
||||||
template <op_id id, op_type ot, typename L = undefined_t, typename R = undefined_t> struct op_;
|
template <op_id id, op_type ot, typename L = undefined_t, typename R = undefined_t> struct op_;
|
||||||
inline void keep_alive_impl(size_t Nurse, size_t Patient, function_call &call, handle ret);
|
void keep_alive_impl(size_t Nurse, size_t Patient, function_call &call, handle ret);
|
||||||
|
|
||||||
/// Internal data structure which holds metadata about a keyword argument
|
/// Internal data structure which holds metadata about a keyword argument
|
||||||
struct argument_record {
|
struct argument_record {
|
||||||
@ -517,23 +517,30 @@ template <size_t Nurse, size_t Patient> struct process_attribute<keep_alive<Nurs
|
|||||||
template <typename... Args> struct process_attributes {
|
template <typename... Args> struct process_attributes {
|
||||||
static void init(const Args&... args, function_record *r) {
|
static void init(const Args&... args, function_record *r) {
|
||||||
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(r);
|
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(r);
|
||||||
int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::init(args, r), 0) ... };
|
PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(r);
|
||||||
ignore_unused(unused);
|
using expander = int[];
|
||||||
|
(void) expander{
|
||||||
|
0, ((void) process_attribute<typename std::decay<Args>::type>::init(args, r), 0)...};
|
||||||
}
|
}
|
||||||
static void init(const Args&... args, type_record *r) {
|
static void init(const Args&... args, type_record *r) {
|
||||||
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(r);
|
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(r);
|
||||||
int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::init(args, r), 0) ... };
|
PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(r);
|
||||||
ignore_unused(unused);
|
using expander = int[];
|
||||||
|
(void) expander{0,
|
||||||
|
(process_attribute<typename std::decay<Args>::type>::init(args, r), 0)...};
|
||||||
}
|
}
|
||||||
static void precall(function_call &call) {
|
static void precall(function_call &call) {
|
||||||
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(call);
|
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(call);
|
||||||
int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::precall(call), 0) ... };
|
using expander = int[];
|
||||||
ignore_unused(unused);
|
(void) expander{0,
|
||||||
|
(process_attribute<typename std::decay<Args>::type>::precall(call), 0)...};
|
||||||
}
|
}
|
||||||
static void postcall(function_call &call, handle fn_ret) {
|
static void postcall(function_call &call, handle fn_ret) {
|
||||||
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(call, fn_ret);
|
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(call, fn_ret);
|
||||||
int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::postcall(call, fn_ret), 0) ... };
|
PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(fn_ret);
|
||||||
ignore_unused(unused);
|
using expander = int[];
|
||||||
|
(void) expander{
|
||||||
|
0, (process_attribute<typename std::decay<Args>::type>::postcall(call, fn_ret), 0)...};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -124,9 +124,9 @@ public:
|
|||||||
} \
|
} \
|
||||||
return cast(*src, policy, parent); \
|
return cast(*src, policy, parent); \
|
||||||
} \
|
} \
|
||||||
operator type *() { return &value; } \
|
operator type *() { return &value; } /* NOLINT(bugprone-macro-parentheses) */ \
|
||||||
operator type &() { return value; } \
|
operator type &() { return value; } /* NOLINT(bugprone-macro-parentheses) */ \
|
||||||
operator type &&() && { return std::move(value); } \
|
operator type &&() && { return std::move(value); } /* NOLINT(bugprone-macro-parentheses) */ \
|
||||||
template <typename T_> \
|
template <typename T_> \
|
||||||
using cast_op_type = pybind11::detail::movable_cast_op_type<T_>
|
using cast_op_type = pybind11::detail::movable_cast_op_type<T_>
|
||||||
|
|
||||||
@ -167,9 +167,8 @@ public:
|
|||||||
py_value = (py_type) PyFloat_AsDouble(src.ptr());
|
py_value = (py_type) PyFloat_AsDouble(src.ptr());
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
} else if (PyFloat_Check(src.ptr())) {
|
} else if (PyFloat_Check(src.ptr())
|
||||||
return false;
|
|| (!convert && !PYBIND11_LONG_CHECK(src.ptr()) && !index_check(src.ptr()))) {
|
||||||
} else if (!convert && !PYBIND11_LONG_CHECK(src.ptr()) && !index_check(src.ptr())) {
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
handle src_or_index = src;
|
handle src_or_index = src;
|
||||||
@ -632,6 +631,7 @@ protected:
|
|||||||
template <typename T, size_t... Is>
|
template <typename T, size_t... Is>
|
||||||
static handle cast_impl(T &&src, return_value_policy policy, handle parent, index_sequence<Is...>) {
|
static handle cast_impl(T &&src, return_value_policy policy, handle parent, index_sequence<Is...>) {
|
||||||
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(src, policy, parent);
|
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(src, policy, parent);
|
||||||
|
PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(policy, parent);
|
||||||
std::array<object, size> entries{{
|
std::array<object, size> entries{{
|
||||||
reinterpret_steal<object>(make_caster<Ts>::cast(std::get<Is>(std::forward<T>(src)), policy, parent))...
|
reinterpret_steal<object>(make_caster<Ts>::cast(std::get<Is>(std::forward<T>(src)), policy, parent))...
|
||||||
}};
|
}};
|
||||||
@ -1263,8 +1263,8 @@ public:
|
|||||||
// Tuples aren't (easily) resizable so a list is needed for collection,
|
// Tuples aren't (easily) resizable so a list is needed for collection,
|
||||||
// but the actual function call strictly requires a tuple.
|
// but the actual function call strictly requires a tuple.
|
||||||
auto args_list = list();
|
auto args_list = list();
|
||||||
int _[] = { 0, (process(args_list, std::forward<Ts>(values)), 0)... };
|
using expander = int[];
|
||||||
ignore_unused(_);
|
(void) expander{0, (process(args_list, std::forward<Ts>(values)), 0)...};
|
||||||
|
|
||||||
m_args = std::move(args_list);
|
m_args = std::move(args_list);
|
||||||
}
|
}
|
||||||
|
@ -10,12 +10,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define PYBIND11_VERSION_MAJOR 2
|
#define PYBIND11_VERSION_MAJOR 2
|
||||||
#define PYBIND11_VERSION_MINOR 7
|
#define PYBIND11_VERSION_MINOR 8
|
||||||
#define PYBIND11_VERSION_PATCH 1.dev1
|
#define PYBIND11_VERSION_PATCH 0.dev1
|
||||||
|
|
||||||
// Similar to Python's convention: https://docs.python.org/3/c-api/apiabiversion.html
|
// Similar to Python's convention: https://docs.python.org/3/c-api/apiabiversion.html
|
||||||
// Additional convention: 0xD = dev
|
// Additional convention: 0xD = dev
|
||||||
#define PYBIND11_VERSION_HEX 0x020701D1
|
#define PYBIND11_VERSION_HEX 0x020800D1
|
||||||
|
|
||||||
#define PYBIND11_NAMESPACE_BEGIN(name) namespace name {
|
#define PYBIND11_NAMESPACE_BEGIN(name) namespace name {
|
||||||
#define PYBIND11_NAMESPACE_END(name) }
|
#define PYBIND11_NAMESPACE_END(name) }
|
||||||
@ -99,10 +99,26 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
// For CUDA, GCC7, GCC8:
|
||||||
# define PYBIND11_NOINLINE __declspec(noinline)
|
// PYBIND11_NOINLINE_FORCED is incompatible with `-Wattributes -Werror`.
|
||||||
|
// When defining PYBIND11_NOINLINE_FORCED, it is best to also use `-Wno-attributes`.
|
||||||
|
// However, the measured shared-library size saving when using noinline are only
|
||||||
|
// 1.7% for CUDA, -0.2% for GCC7, and 0.0% for GCC8 (using -DCMAKE_BUILD_TYPE=MinSizeRel,
|
||||||
|
// the default under pybind11/tests).
|
||||||
|
#if !defined(PYBIND11_NOINLINE_FORCED) && \
|
||||||
|
(defined(__CUDACC__) || (defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8)))
|
||||||
|
# define PYBIND11_NOINLINE_DISABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// The PYBIND11_NOINLINE macro is for function DEFINITIONS.
|
||||||
|
// In contrast, FORWARD DECLARATIONS should never use this macro:
|
||||||
|
// https://stackoverflow.com/questions/9317473/forward-declaration-of-inline-functions
|
||||||
|
#if defined(PYBIND11_NOINLINE_DISABLED) // Option for maximum portability and experimentation.
|
||||||
|
# define PYBIND11_NOINLINE inline
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
# define PYBIND11_NOINLINE __declspec(noinline) inline
|
||||||
#else
|
#else
|
||||||
# define PYBIND11_NOINLINE __attribute__ ((noinline))
|
# define PYBIND11_NOINLINE __attribute__ ((noinline)) inline
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__MINGW32__)
|
#if defined(__MINGW32__)
|
||||||
@ -220,8 +236,8 @@
|
|||||||
#define PYBIND11_BYTES_SIZE PyBytes_Size
|
#define PYBIND11_BYTES_SIZE PyBytes_Size
|
||||||
#define PYBIND11_LONG_CHECK(o) PyLong_Check(o)
|
#define PYBIND11_LONG_CHECK(o) PyLong_Check(o)
|
||||||
#define PYBIND11_LONG_AS_LONGLONG(o) PyLong_AsLongLong(o)
|
#define PYBIND11_LONG_AS_LONGLONG(o) PyLong_AsLongLong(o)
|
||||||
#define PYBIND11_LONG_FROM_SIGNED(o) PyLong_FromSsize_t((ssize_t) o)
|
#define PYBIND11_LONG_FROM_SIGNED(o) PyLong_FromSsize_t((ssize_t) (o))
|
||||||
#define PYBIND11_LONG_FROM_UNSIGNED(o) PyLong_FromSize_t((size_t) o)
|
#define PYBIND11_LONG_FROM_UNSIGNED(o) PyLong_FromSize_t((size_t) (o))
|
||||||
#define PYBIND11_BYTES_NAME "bytes"
|
#define PYBIND11_BYTES_NAME "bytes"
|
||||||
#define PYBIND11_STRING_NAME "str"
|
#define PYBIND11_STRING_NAME "str"
|
||||||
#define PYBIND11_SLICE_OBJECT PyObject
|
#define PYBIND11_SLICE_OBJECT PyObject
|
||||||
@ -356,24 +372,23 @@ extern "C" {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
\endrst */
|
\endrst */
|
||||||
#define PYBIND11_MODULE(name, variable) \
|
#define PYBIND11_MODULE(name, variable) \
|
||||||
static ::pybind11::module_::module_def \
|
static ::pybind11::module_::module_def PYBIND11_CONCAT(pybind11_module_def_, name) \
|
||||||
PYBIND11_CONCAT(pybind11_module_def_, name) PYBIND11_MAYBE_UNUSED; \
|
PYBIND11_MAYBE_UNUSED; \
|
||||||
PYBIND11_MAYBE_UNUSED \
|
PYBIND11_MAYBE_UNUSED \
|
||||||
static void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ &); \
|
static void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ &); \
|
||||||
PYBIND11_PLUGIN_IMPL(name) { \
|
PYBIND11_PLUGIN_IMPL(name) { \
|
||||||
PYBIND11_CHECK_PYTHON_VERSION \
|
PYBIND11_CHECK_PYTHON_VERSION \
|
||||||
PYBIND11_ENSURE_INTERNALS_READY \
|
PYBIND11_ENSURE_INTERNALS_READY \
|
||||||
auto m = ::pybind11::module_::create_extension_module( \
|
auto m = ::pybind11::module_::create_extension_module( \
|
||||||
PYBIND11_TOSTRING(name), nullptr, \
|
PYBIND11_TOSTRING(name), nullptr, &PYBIND11_CONCAT(pybind11_module_def_, name)); \
|
||||||
&PYBIND11_CONCAT(pybind11_module_def_, name)); \
|
try { \
|
||||||
try { \
|
PYBIND11_CONCAT(pybind11_init_, name)(m); \
|
||||||
PYBIND11_CONCAT(pybind11_init_, name)(m); \
|
return m.ptr(); \
|
||||||
return m.ptr(); \
|
} \
|
||||||
} PYBIND11_CATCH_INIT_EXCEPTIONS \
|
PYBIND11_CATCH_INIT_EXCEPTIONS \
|
||||||
} \
|
} \
|
||||||
void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ &variable)
|
void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ & (variable))
|
||||||
|
|
||||||
|
|
||||||
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
||||||
|
|
||||||
@ -735,9 +750,6 @@ using function_signature_t = conditional_t<
|
|||||||
template <typename T> using is_lambda = satisfies_none_of<remove_reference_t<T>,
|
template <typename T> using is_lambda = satisfies_none_of<remove_reference_t<T>,
|
||||||
std::is_function, std::is_pointer, std::is_member_pointer>;
|
std::is_function, std::is_pointer, std::is_member_pointer>;
|
||||||
|
|
||||||
/// Ignore that a variable is unused in compiler warnings
|
|
||||||
inline void ignore_unused(const int *) { }
|
|
||||||
|
|
||||||
// [workaround(intel)] Internal error on fold expression
|
// [workaround(intel)] Internal error on fold expression
|
||||||
/// Apply a function over each element of a parameter pack
|
/// Apply a function over each element of a parameter pack
|
||||||
#if defined(__cpp_fold_expressions) && !defined(__INTEL_COMPILER)
|
#if defined(__cpp_fold_expressions) && !defined(__INTEL_COMPILER)
|
||||||
@ -782,8 +794,8 @@ PYBIND11_RUNTIME_EXCEPTION(import_error, PyExc_ImportError)
|
|||||||
PYBIND11_RUNTIME_EXCEPTION(cast_error, PyExc_RuntimeError) /// Thrown when pybind11::cast or handle::call fail due to a type casting error
|
PYBIND11_RUNTIME_EXCEPTION(cast_error, PyExc_RuntimeError) /// Thrown when pybind11::cast or handle::call fail due to a type casting error
|
||||||
PYBIND11_RUNTIME_EXCEPTION(reference_cast_error, PyExc_RuntimeError) /// Used internally
|
PYBIND11_RUNTIME_EXCEPTION(reference_cast_error, PyExc_RuntimeError) /// Used internally
|
||||||
|
|
||||||
[[noreturn]] PYBIND11_NOINLINE inline void pybind11_fail(const char *reason) { throw std::runtime_error(reason); }
|
[[noreturn]] PYBIND11_NOINLINE void pybind11_fail(const char *reason) { throw std::runtime_error(reason); }
|
||||||
[[noreturn]] PYBIND11_NOINLINE inline void pybind11_fail(const std::string &reason) { throw std::runtime_error(reason); }
|
[[noreturn]] PYBIND11_NOINLINE void pybind11_fail(const std::string &reason) { throw std::runtime_error(reason); }
|
||||||
|
|
||||||
template <typename T, typename SFINAE = void> struct format_descriptor { };
|
template <typename T, typename SFINAE = void> struct format_descriptor { };
|
||||||
|
|
||||||
@ -928,19 +940,29 @@ inline static std::shared_ptr<T> try_get_shared_from_this(std::enable_shared_fro
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1916
|
// For silencing "unused" compiler warnings in special situations.
|
||||||
|
|
||||||
// warning C4100: Unreferenced formal parameter
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
inline constexpr void workaround_incorrect_msvc_c4100(Args &&...) {}
|
#if defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER < 1920 // MSVC 2017
|
||||||
|
constexpr
|
||||||
|
#endif
|
||||||
|
inline void silence_unused_warnings(Args &&...) {}
|
||||||
|
|
||||||
|
// MSVC warning C4100: Unreferenced formal parameter
|
||||||
|
#if defined(_MSC_VER) && _MSC_VER <= 1916
|
||||||
# define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...) \
|
# define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...) \
|
||||||
detail::workaround_incorrect_msvc_c4100(__VA_ARGS__)
|
detail::silence_unused_warnings(__VA_ARGS__)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
# define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...)
|
# define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// GCC -Wunused-but-set-parameter All GCC versions (as of July 2021).
|
||||||
|
#if defined(__GNUG__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
|
||||||
|
# define PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(...) \
|
||||||
|
detail::silence_unused_warnings(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
# define PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER) // All versions (as of July 2021).
|
#if defined(_MSC_VER) // All versions (as of July 2021).
|
||||||
|
|
||||||
// warning C4127: Conditional expression is constant
|
// warning C4127: Conditional expression is constant
|
||||||
|
@ -264,7 +264,7 @@ inline void translate_local_exception(std::exception_ptr p) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// Return a reference to the current `internals` data
|
/// Return a reference to the current `internals` data
|
||||||
PYBIND11_NOINLINE inline internals &get_internals() {
|
PYBIND11_NOINLINE internals &get_internals() {
|
||||||
auto **&internals_pp = get_internals_pp();
|
auto **&internals_pp = get_internals_pp();
|
||||||
if (internals_pp && *internals_pp)
|
if (internals_pp && *internals_pp)
|
||||||
return **internals_pp;
|
return **internals_pp;
|
||||||
@ -359,14 +359,14 @@ PYBIND11_NAMESPACE_END(detail)
|
|||||||
/// Returns a named pointer that is shared among all extension modules (using the same
|
/// Returns a named pointer that is shared among all extension modules (using the same
|
||||||
/// pybind11 version) running in the current interpreter. Names starting with underscores
|
/// pybind11 version) running in the current interpreter. Names starting with underscores
|
||||||
/// are reserved for internal usage. Returns `nullptr` if no matching entry was found.
|
/// are reserved for internal usage. Returns `nullptr` if no matching entry was found.
|
||||||
inline PYBIND11_NOINLINE void *get_shared_data(const std::string &name) {
|
PYBIND11_NOINLINE void *get_shared_data(const std::string &name) {
|
||||||
auto &internals = detail::get_internals();
|
auto &internals = detail::get_internals();
|
||||||
auto it = internals.shared_data.find(name);
|
auto it = internals.shared_data.find(name);
|
||||||
return it != internals.shared_data.end() ? it->second : nullptr;
|
return it != internals.shared_data.end() ? it->second : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the shared data that can be later recovered by `get_shared_data()`.
|
/// Set the shared data that can be later recovered by `get_shared_data()`.
|
||||||
inline PYBIND11_NOINLINE void *set_shared_data(const std::string &name, void *data) {
|
PYBIND11_NOINLINE void *set_shared_data(const std::string &name, void *data) {
|
||||||
detail::get_internals().shared_data[name] = data;
|
detail::get_internals().shared_data[name] = data;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ public:
|
|||||||
inline std::pair<decltype(internals::registered_types_py)::iterator, bool> all_type_info_get_cache(PyTypeObject *type);
|
inline std::pair<decltype(internals::registered_types_py)::iterator, bool> all_type_info_get_cache(PyTypeObject *type);
|
||||||
|
|
||||||
// Populates a just-created cache entry.
|
// Populates a just-created cache entry.
|
||||||
PYBIND11_NOINLINE inline void all_type_info_populate(PyTypeObject *t, std::vector<type_info *> &bases) {
|
PYBIND11_NOINLINE void all_type_info_populate(PyTypeObject *t, std::vector<type_info *> &bases) {
|
||||||
std::vector<PyTypeObject *> check;
|
std::vector<PyTypeObject *> check;
|
||||||
for (handle parent : reinterpret_borrow<tuple>(t->tp_bases))
|
for (handle parent : reinterpret_borrow<tuple>(t->tp_bases))
|
||||||
check.push_back((PyTypeObject *) parent.ptr());
|
check.push_back((PyTypeObject *) parent.ptr());
|
||||||
@ -150,7 +150,7 @@ inline const std::vector<detail::type_info *> &all_type_info(PyTypeObject *type)
|
|||||||
* ancestors are pybind11-registered. Throws an exception if there are multiple bases--use
|
* ancestors are pybind11-registered. Throws an exception if there are multiple bases--use
|
||||||
* `all_type_info` instead if you want to support multiple bases.
|
* `all_type_info` instead if you want to support multiple bases.
|
||||||
*/
|
*/
|
||||||
PYBIND11_NOINLINE inline detail::type_info* get_type_info(PyTypeObject *type) {
|
PYBIND11_NOINLINE detail::type_info* get_type_info(PyTypeObject *type) {
|
||||||
auto &bases = all_type_info(type);
|
auto &bases = all_type_info(type);
|
||||||
if (bases.empty())
|
if (bases.empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -176,7 +176,7 @@ inline detail::type_info *get_global_type_info(const std::type_index &tp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Return the type info for a given C++ type; on lookup failure can either throw or return nullptr.
|
/// Return the type info for a given C++ type; on lookup failure can either throw or return nullptr.
|
||||||
PYBIND11_NOINLINE inline detail::type_info *get_type_info(const std::type_index &tp,
|
PYBIND11_NOINLINE detail::type_info *get_type_info(const std::type_index &tp,
|
||||||
bool throw_if_missing = false) {
|
bool throw_if_missing = false) {
|
||||||
if (auto ltype = get_local_type_info(tp))
|
if (auto ltype = get_local_type_info(tp))
|
||||||
return ltype;
|
return ltype;
|
||||||
@ -191,13 +191,13 @@ PYBIND11_NOINLINE inline detail::type_info *get_type_info(const std::type_index
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
PYBIND11_NOINLINE inline handle get_type_handle(const std::type_info &tp, bool throw_if_missing) {
|
PYBIND11_NOINLINE handle get_type_handle(const std::type_info &tp, bool throw_if_missing) {
|
||||||
detail::type_info *type_info = get_type_info(tp, throw_if_missing);
|
detail::type_info *type_info = get_type_info(tp, throw_if_missing);
|
||||||
return handle(type_info ? ((PyObject *) type_info->type) : nullptr);
|
return handle(type_info ? ((PyObject *) type_info->type) : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Searches the inheritance graph for a registered Python instance, using all_type_info().
|
// Searches the inheritance graph for a registered Python instance, using all_type_info().
|
||||||
PYBIND11_NOINLINE inline handle find_registered_python_instance(void *src,
|
PYBIND11_NOINLINE handle find_registered_python_instance(void *src,
|
||||||
const detail::type_info *tinfo) {
|
const detail::type_info *tinfo) {
|
||||||
auto it_instances = get_internals().registered_instances.equal_range(src);
|
auto it_instances = get_internals().registered_instances.equal_range(src);
|
||||||
for (auto it_i = it_instances.first; it_i != it_instances.second; ++it_i) {
|
for (auto it_i = it_instances.first; it_i != it_instances.second; ++it_i) {
|
||||||
@ -325,7 +325,7 @@ public:
|
|||||||
* The returned object should be short-lived: in particular, it must not outlive the called-upon
|
* The returned object should be short-lived: in particular, it must not outlive the called-upon
|
||||||
* instance.
|
* instance.
|
||||||
*/
|
*/
|
||||||
PYBIND11_NOINLINE inline value_and_holder instance::get_value_and_holder(const type_info *find_type /*= nullptr default in common.h*/, bool throw_if_missing /*= true in common.h*/) {
|
PYBIND11_NOINLINE value_and_holder instance::get_value_and_holder(const type_info *find_type /*= nullptr default in common.h*/, bool throw_if_missing /*= true in common.h*/) {
|
||||||
// Optimize common case:
|
// Optimize common case:
|
||||||
if (!find_type || Py_TYPE(this) == find_type->type)
|
if (!find_type || Py_TYPE(this) == find_type->type)
|
||||||
return value_and_holder(this, find_type, 0, 0);
|
return value_and_holder(this, find_type, 0, 0);
|
||||||
@ -349,7 +349,7 @@ PYBIND11_NOINLINE inline value_and_holder instance::get_value_and_holder(const t
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
PYBIND11_NOINLINE inline void instance::allocate_layout() {
|
PYBIND11_NOINLINE void instance::allocate_layout() {
|
||||||
auto &tinfo = all_type_info(Py_TYPE(this));
|
auto &tinfo = all_type_info(Py_TYPE(this));
|
||||||
|
|
||||||
const size_t n_types = tinfo.size();
|
const size_t n_types = tinfo.size();
|
||||||
@ -397,19 +397,19 @@ PYBIND11_NOINLINE inline void instance::allocate_layout() {
|
|||||||
owned = true;
|
owned = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PYBIND11_NOINLINE inline void instance::deallocate_layout() const {
|
PYBIND11_NOINLINE void instance::deallocate_layout() const {
|
||||||
if (!simple_layout)
|
if (!simple_layout)
|
||||||
PyMem_Free(nonsimple.values_and_holders);
|
PyMem_Free(nonsimple.values_and_holders);
|
||||||
}
|
}
|
||||||
|
|
||||||
PYBIND11_NOINLINE inline bool isinstance_generic(handle obj, const std::type_info &tp) {
|
PYBIND11_NOINLINE bool isinstance_generic(handle obj, const std::type_info &tp) {
|
||||||
handle type = detail::get_type_handle(tp, false);
|
handle type = detail::get_type_handle(tp, false);
|
||||||
if (!type)
|
if (!type)
|
||||||
return false;
|
return false;
|
||||||
return isinstance(obj, type);
|
return isinstance(obj, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
PYBIND11_NOINLINE inline std::string error_string() {
|
PYBIND11_NOINLINE std::string error_string() {
|
||||||
if (!PyErr_Occurred()) {
|
if (!PyErr_Occurred()) {
|
||||||
PyErr_SetString(PyExc_RuntimeError, "Unknown internal error occurred");
|
PyErr_SetString(PyExc_RuntimeError, "Unknown internal error occurred");
|
||||||
return "Unknown internal error occurred";
|
return "Unknown internal error occurred";
|
||||||
@ -456,7 +456,7 @@ PYBIND11_NOINLINE inline std::string error_string() {
|
|||||||
return errorString;
|
return errorString;
|
||||||
}
|
}
|
||||||
|
|
||||||
PYBIND11_NOINLINE inline handle get_object_handle(const void *ptr, const detail::type_info *type ) {
|
PYBIND11_NOINLINE handle get_object_handle(const void *ptr, const detail::type_info *type ) {
|
||||||
auto &instances = get_internals().registered_instances;
|
auto &instances = get_internals().registered_instances;
|
||||||
auto range = instances.equal_range(ptr);
|
auto range = instances.equal_range(ptr);
|
||||||
for (auto it = range.first; it != range.second; ++it) {
|
for (auto it = range.first; it != range.second; ++it) {
|
||||||
@ -483,7 +483,7 @@ inline PyThreadState *get_thread_state_unchecked() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Forward declarations
|
// Forward declarations
|
||||||
inline void keep_alive_impl(handle nurse, handle patient);
|
void keep_alive_impl(handle nurse, handle patient);
|
||||||
inline PyObject *make_new_instance(PyTypeObject *type);
|
inline PyObject *make_new_instance(PyTypeObject *type);
|
||||||
|
|
||||||
class type_caster_generic {
|
class type_caster_generic {
|
||||||
@ -927,18 +927,17 @@ protected:
|
|||||||
using Constructor = void *(*)(const void *);
|
using Constructor = void *(*)(const void *);
|
||||||
|
|
||||||
/* Only enabled when the types are {copy,move}-constructible *and* when the type
|
/* Only enabled when the types are {copy,move}-constructible *and* when the type
|
||||||
does not have a private operator new implementation. */
|
does not have a private operator new implementation. A comma operator is used in the decltype
|
||||||
|
argument to apply SFINAE to the public copy/move constructors.*/
|
||||||
template <typename T, typename = enable_if_t<is_copy_constructible<T>::value>>
|
template <typename T, typename = enable_if_t<is_copy_constructible<T>::value>>
|
||||||
static auto make_copy_constructor(const T *x) -> decltype(new T(*x), Constructor{}) {
|
static auto make_copy_constructor(const T *) -> decltype(new T(std::declval<const T>()), Constructor{}) {
|
||||||
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(x);
|
|
||||||
return [](const void *arg) -> void * {
|
return [](const void *arg) -> void * {
|
||||||
return new T(*reinterpret_cast<const T *>(arg));
|
return new T(*reinterpret_cast<const T *>(arg));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename = enable_if_t<std::is_move_constructible<T>::value>>
|
template <typename T, typename = enable_if_t<std::is_move_constructible<T>::value>>
|
||||||
static auto make_move_constructor(const T *x) -> decltype(new T(std::move(*const_cast<T *>(x))), Constructor{}) {
|
static auto make_move_constructor(const T *) -> decltype(new T(std::declval<T&&>()), Constructor{}) {
|
||||||
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(x);
|
|
||||||
return [](const void *arg) -> void * {
|
return [](const void *arg) -> void * {
|
||||||
return new T(std::move(*const_cast<T *>(reinterpret_cast<const T *>(arg))));
|
return new T(std::move(*const_cast<T *>(reinterpret_cast<const T *>(arg))));
|
||||||
};
|
};
|
||||||
|
@ -29,7 +29,7 @@ inline void erase_all(std::string &string, const std::string &search) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PYBIND11_NOINLINE inline void clean_type_id(std::string &name) {
|
PYBIND11_NOINLINE void clean_type_id(std::string &name) {
|
||||||
#if defined(__GNUG__)
|
#if defined(__GNUG__)
|
||||||
int status = 0;
|
int status = 0;
|
||||||
std::unique_ptr<char, void (*)(void *)> res {
|
std::unique_ptr<char, void (*)(void *)> res {
|
||||||
|
@ -45,25 +45,23 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
\endrst */
|
\endrst */
|
||||||
#define PYBIND11_EMBEDDED_MODULE(name, variable) \
|
#define PYBIND11_EMBEDDED_MODULE(name, variable) \
|
||||||
static ::pybind11::module_::module_def \
|
static ::pybind11::module_::module_def PYBIND11_CONCAT(pybind11_module_def_, name); \
|
||||||
PYBIND11_CONCAT(pybind11_module_def_, name); \
|
static void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ &); \
|
||||||
static void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ &); \
|
static PyObject PYBIND11_CONCAT(*pybind11_init_wrapper_, name)() { \
|
||||||
static PyObject PYBIND11_CONCAT(*pybind11_init_wrapper_, name)() { \
|
auto m = ::pybind11::module_::create_extension_module( \
|
||||||
auto m = ::pybind11::module_::create_extension_module( \
|
PYBIND11_TOSTRING(name), nullptr, &PYBIND11_CONCAT(pybind11_module_def_, name)); \
|
||||||
PYBIND11_TOSTRING(name), nullptr, \
|
try { \
|
||||||
&PYBIND11_CONCAT(pybind11_module_def_, name)); \
|
PYBIND11_CONCAT(pybind11_init_, name)(m); \
|
||||||
try { \
|
return m.ptr(); \
|
||||||
PYBIND11_CONCAT(pybind11_init_, name)(m); \
|
} \
|
||||||
return m.ptr(); \
|
PYBIND11_CATCH_INIT_EXCEPTIONS \
|
||||||
} PYBIND11_CATCH_INIT_EXCEPTIONS \
|
} \
|
||||||
} \
|
PYBIND11_EMBEDDED_MODULE_IMPL(name) \
|
||||||
PYBIND11_EMBEDDED_MODULE_IMPL(name) \
|
::pybind11::detail::embedded_module PYBIND11_CONCAT(pybind11_module_, name)( \
|
||||||
::pybind11::detail::embedded_module PYBIND11_CONCAT(pybind11_module_, name) \
|
PYBIND11_TOSTRING(name), PYBIND11_CONCAT(pybind11_init_impl_, name)); \
|
||||||
(PYBIND11_TOSTRING(name), \
|
void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ \
|
||||||
PYBIND11_CONCAT(pybind11_init_impl_, name)); \
|
& variable) // NOLINT(bugprone-macro-parentheses)
|
||||||
void PYBIND11_CONCAT(pybind11_init_, name)(::pybind11::module_ &variable)
|
|
||||||
|
|
||||||
|
|
||||||
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
||||||
PYBIND11_NAMESPACE_BEGIN(detail)
|
PYBIND11_NAMESPACE_BEGIN(detail)
|
||||||
|
@ -70,9 +70,11 @@ public:
|
|||||||
struct func_handle {
|
struct func_handle {
|
||||||
function f;
|
function f;
|
||||||
func_handle(function &&f_) noexcept : f(std::move(f_)) {}
|
func_handle(function &&f_) noexcept : f(std::move(f_)) {}
|
||||||
func_handle(const func_handle& f_) {
|
func_handle(const func_handle &f_) { operator=(f_); }
|
||||||
|
func_handle &operator=(const func_handle &f_) {
|
||||||
gil_scoped_acquire acq;
|
gil_scoped_acquire acq;
|
||||||
f = f_.f;
|
f = f_.f;
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
~func_handle() {
|
~func_handle() {
|
||||||
gil_scoped_acquire acq;
|
gil_scoped_acquire acq;
|
||||||
|
@ -104,7 +104,7 @@ struct numpy_internals {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline PYBIND11_NOINLINE void load_numpy_internals(numpy_internals* &ptr) {
|
PYBIND11_NOINLINE void load_numpy_internals(numpy_internals* &ptr) {
|
||||||
ptr = &get_or_create_shared_data<numpy_internals>("_numpy_internals");
|
ptr = &get_or_create_shared_data<numpy_internals>("_numpy_internals");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,11 +478,11 @@ public:
|
|||||||
|
|
||||||
dtype(list names, list formats, list offsets, ssize_t itemsize) {
|
dtype(list names, list formats, list offsets, ssize_t itemsize) {
|
||||||
dict args;
|
dict args;
|
||||||
args["names"] = names;
|
args["names"] = std::move(names);
|
||||||
args["formats"] = formats;
|
args["formats"] = std::move(formats);
|
||||||
args["offsets"] = offsets;
|
args["offsets"] = std::move(offsets);
|
||||||
args["itemsize"] = pybind11::int_(itemsize);
|
args["itemsize"] = pybind11::int_(itemsize);
|
||||||
m_ptr = from_args(args).release().ptr();
|
m_ptr = from_args(std::move(args)).release().ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is essentially the same as calling numpy.dtype(args) in Python.
|
/// This is essentially the same as calling numpy.dtype(args) in Python.
|
||||||
@ -560,7 +560,7 @@ private:
|
|||||||
formats.append(descr.format);
|
formats.append(descr.format);
|
||||||
offsets.append(descr.offset);
|
offsets.append(descr.offset);
|
||||||
}
|
}
|
||||||
return dtype(names, formats, offsets, itemsize);
|
return dtype(std::move(names), std::move(formats), std::move(offsets), itemsize);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1110,7 +1110,7 @@ struct field_descriptor {
|
|||||||
dtype descr;
|
dtype descr;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline PYBIND11_NOINLINE void register_structured_dtype(
|
PYBIND11_NOINLINE void register_structured_dtype(
|
||||||
any_container<field_descriptor> fields,
|
any_container<field_descriptor> fields,
|
||||||
const std::type_info& tinfo, ssize_t itemsize,
|
const std::type_info& tinfo, ssize_t itemsize,
|
||||||
bool (*direct_converter)(PyObject *, void *&)) {
|
bool (*direct_converter)(PyObject *, void *&)) {
|
||||||
@ -1134,7 +1134,10 @@ inline PYBIND11_NOINLINE void register_structured_dtype(
|
|||||||
formats.append(field.descr);
|
formats.append(field.descr);
|
||||||
offsets.append(pybind11::int_(field.offset));
|
offsets.append(pybind11::int_(field.offset));
|
||||||
}
|
}
|
||||||
auto dtype_ptr = pybind11::dtype(names, formats, offsets, itemsize).release().ptr();
|
auto dtype_ptr
|
||||||
|
= pybind11::dtype(std::move(names), std::move(formats), std::move(offsets), itemsize)
|
||||||
|
.release()
|
||||||
|
.ptr();
|
||||||
|
|
||||||
// There is an existing bug in NumPy (as of v1.11): trailing bytes are
|
// There is an existing bug in NumPy (as of v1.11): trailing bytes are
|
||||||
// not encoded explicitly into the format string. This will supposedly
|
// not encoded explicitly into the format string. This will supposedly
|
||||||
@ -1551,8 +1554,11 @@ private:
|
|||||||
"pybind11::vectorize(...) requires a function with at least one vectorizable argument");
|
"pybind11::vectorize(...) requires a function with at least one vectorizable argument");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template <typename T>
|
template <typename T,
|
||||||
explicit vectorize_helper(T &&f) : f(std::forward<T>(f)) { }
|
// SFINAE to prevent shadowing the copy constructor.
|
||||||
|
typename = detail::enable_if_t<
|
||||||
|
!std::is_same<vectorize_helper, typename std::decay<T>::type>::value>>
|
||||||
|
explicit vectorize_helper(T &&f) : f(std::forward<T>(f)) {}
|
||||||
|
|
||||||
object operator()(typename vectorize_arg<Args>::type... args) {
|
object operator()(typename vectorize_arg<Args>::type... args) {
|
||||||
return run(args...,
|
return run(args...,
|
||||||
|
@ -11,10 +11,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// Legacy pragma warning block moved to separate file, to enable iwyu cleanup of newly developed
|
|
||||||
// code, without having to open up this can of worms. #HelpAppreciated cleaning this up.
|
|
||||||
#include "detail/pragma_warning_block.h"
|
|
||||||
|
|
||||||
#include "attr.h"
|
#include "attr.h"
|
||||||
#include "gil.h"
|
#include "gil.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
@ -1838,7 +1834,7 @@ struct enum_base {
|
|||||||
m_base.attr(op) = cpp_function( \
|
m_base.attr(op) = cpp_function( \
|
||||||
[](const object &a, const object &b) { \
|
[](const object &a, const object &b) { \
|
||||||
if (!type::handle_of(a).is(type::handle_of(b))) \
|
if (!type::handle_of(a).is(type::handle_of(b))) \
|
||||||
strict_behavior; \
|
strict_behavior; /* NOLINT(bugprone-macro-parentheses) */ \
|
||||||
return expr; \
|
return expr; \
|
||||||
}, \
|
}, \
|
||||||
name(op), \
|
name(op), \
|
||||||
@ -1988,7 +1984,7 @@ private:
|
|||||||
PYBIND11_NAMESPACE_BEGIN(detail)
|
PYBIND11_NAMESPACE_BEGIN(detail)
|
||||||
|
|
||||||
|
|
||||||
inline void keep_alive_impl(handle nurse, handle patient) {
|
PYBIND11_NOINLINE void keep_alive_impl(handle nurse, handle patient) {
|
||||||
if (!nurse || !patient)
|
if (!nurse || !patient)
|
||||||
pybind11_fail("Could not activate keep_alive!");
|
pybind11_fail("Could not activate keep_alive!");
|
||||||
|
|
||||||
@ -2015,7 +2011,7 @@ inline void keep_alive_impl(handle nurse, handle patient) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PYBIND11_NOINLINE inline void keep_alive_impl(size_t Nurse, size_t Patient, function_call &call, handle ret) {
|
PYBIND11_NOINLINE void keep_alive_impl(size_t Nurse, size_t Patient, function_call &call, handle ret) {
|
||||||
auto get_arg = [&](size_t n) {
|
auto get_arg = [&](size_t n) {
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return ret;
|
return ret;
|
||||||
@ -2265,7 +2261,7 @@ exception<CppException> ®ister_local_exception(handle scope,
|
|||||||
}
|
}
|
||||||
|
|
||||||
PYBIND11_NAMESPACE_BEGIN(detail)
|
PYBIND11_NAMESPACE_BEGIN(detail)
|
||||||
PYBIND11_NOINLINE inline void print(const tuple &args, const dict &kwargs) {
|
PYBIND11_NOINLINE void print(const tuple &args, const dict &kwargs) {
|
||||||
auto strings = tuple(args.size());
|
auto strings = tuple(args.size());
|
||||||
for (size_t i = 0; i < args.size(); ++i) {
|
for (size_t i = 0; i < args.size(); ++i) {
|
||||||
strings[i] = str(args[i]);
|
strings[i] = str(args[i]);
|
||||||
@ -2496,7 +2492,3 @@ PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
|||||||
#if defined(__GNUC__) && __GNUC__ == 7
|
#if defined(__GNUC__) && __GNUC__ == 7
|
||||||
# pragma GCC diagnostic pop // -Wnoexcept-type
|
# pragma GCC diagnostic pop // -Wnoexcept-type
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__GNUG__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
|
|
||||||
# pragma GCC diagnostic pop
|
|
||||||
#endif
|
|
||||||
|
@ -24,7 +24,7 @@ struct arg; struct arg_v;
|
|||||||
|
|
||||||
PYBIND11_NAMESPACE_BEGIN(detail)
|
PYBIND11_NAMESPACE_BEGIN(detail)
|
||||||
class args_proxy;
|
class args_proxy;
|
||||||
inline bool isinstance_generic(handle obj, const std::type_info &tp);
|
bool isinstance_generic(handle obj, const std::type_info &tp);
|
||||||
|
|
||||||
// Accessor forward declarations
|
// Accessor forward declarations
|
||||||
template <typename Policy> class accessor;
|
template <typename Policy> class accessor;
|
||||||
@ -316,7 +316,7 @@ template <typename T> T reinterpret_borrow(handle h) { return {h, object::borrow
|
|||||||
template <typename T> T reinterpret_steal(handle h) { return {h, object::stolen_t{}}; }
|
template <typename T> T reinterpret_steal(handle h) { return {h, object::stolen_t{}}; }
|
||||||
|
|
||||||
PYBIND11_NAMESPACE_BEGIN(detail)
|
PYBIND11_NAMESPACE_BEGIN(detail)
|
||||||
inline std::string error_string();
|
std::string error_string();
|
||||||
PYBIND11_NAMESPACE_END(detail)
|
PYBIND11_NAMESPACE_END(detail)
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import nox
|
import nox
|
||||||
|
|
||||||
|
|
||||||
nox.options.sessions = ["lint", "tests", "tests_packaging"]
|
nox.options.sessions = ["lint", "tests", "tests_packaging"]
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from ._version import version_info, __version__
|
from ._version import __version__, version_info
|
||||||
from .commands import get_include, get_cmake_dir
|
from .commands import get_cmake_dir, get_include
|
||||||
|
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
"version_info",
|
"version_info",
|
||||||
|
@ -5,7 +5,7 @@ import argparse
|
|||||||
import sys
|
import sys
|
||||||
import sysconfig
|
import sysconfig
|
||||||
|
|
||||||
from .commands import get_include, get_cmake_dir
|
from .commands import get_cmake_dir, get_include
|
||||||
|
|
||||||
|
|
||||||
def print_includes():
|
def print_includes():
|
||||||
|
@ -8,5 +8,5 @@ def _to_int(s):
|
|||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
__version__ = "2.7.1.dev1"
|
__version__ = "2.8.0.dev1"
|
||||||
version_info = tuple(_to_int(s) for s in __version__.split("."))
|
version_info = tuple(_to_int(s) for s in __version__.split("."))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from typing import Union, Tuple
|
from typing import Tuple, Union
|
||||||
|
|
||||||
def _to_int(s: str) -> Union[int, str]: ...
|
def _to_int(s: str) -> Union[int, str]: ...
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
DIR = os.path.abspath(os.path.dirname(__file__))
|
DIR = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,23 +41,23 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
import os
|
import os
|
||||||
|
import platform
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
import sysconfig
|
||||||
import tempfile
|
import tempfile
|
||||||
import threading
|
import threading
|
||||||
import platform
|
|
||||||
import warnings
|
import warnings
|
||||||
import sysconfig
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from setuptools.command.build_ext import build_ext as _build_ext
|
|
||||||
from setuptools import Extension as _Extension
|
from setuptools import Extension as _Extension
|
||||||
|
from setuptools.command.build_ext import build_ext as _build_ext
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from distutils.command.build_ext import build_ext as _build_ext
|
from distutils.command.build_ext import build_ext as _build_ext
|
||||||
from distutils.extension import Extension as _Extension
|
from distutils.extension import Extension as _Extension
|
||||||
|
|
||||||
import distutils.errors
|
|
||||||
import distutils.ccompiler
|
import distutils.ccompiler
|
||||||
|
import distutils.errors
|
||||||
|
|
||||||
WIN = sys.platform.startswith("win32") and "mingw" not in sysconfig.get_platform()
|
WIN = sys.platform.startswith("win32") and "mingw" not in sysconfig.get_platform()
|
||||||
PY2 = sys.version_info[0] < 3
|
PY2 = sys.version_info[0] < 3
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
# IMPORTANT: Should stay in sync with setup_helpers.py (mostly checked by CI /
|
# IMPORTANT: Should stay in sync with setup_helpers.py (mostly checked by CI /
|
||||||
# pre-commit).
|
# pre-commit).
|
||||||
|
|
||||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Type, TypeVar, Union
|
import contextlib
|
||||||
from types import TracebackType
|
import distutils.ccompiler
|
||||||
|
|
||||||
from distutils.command.build_ext import build_ext as _build_ext # type: ignore
|
from distutils.command.build_ext import build_ext as _build_ext # type: ignore
|
||||||
from distutils.extension import Extension as _Extension
|
from distutils.extension import Extension as _Extension
|
||||||
import distutils.ccompiler
|
from types import TracebackType
|
||||||
import contextlib
|
from typing import Any, Callable, Dict, Iterator, List, Optional, Type, TypeVar, Union
|
||||||
|
|
||||||
WIN: bool
|
WIN: bool
|
||||||
PY2: bool
|
PY2: bool
|
||||||
|
@ -15,6 +15,12 @@ ignore = [
|
|||||||
"noxfile.py",
|
"noxfile.py",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[tool.isort]
|
||||||
|
# Needs the compiled .so modules and env.py from tests
|
||||||
|
known_first_party = "env,pybind11_cross_module_tests,pybind11_tests,"
|
||||||
|
# For black compatibility
|
||||||
|
profile = "black"
|
||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
files = "pybind11"
|
files = "pybind11"
|
||||||
python_version = "2.7"
|
python_version = "2.7"
|
||||||
|
@ -20,6 +20,7 @@ classifiers =
|
|||||||
Programming Language :: Python :: 3.7
|
Programming Language :: Python :: 3.7
|
||||||
Programming Language :: Python :: 3.8
|
Programming Language :: Python :: 3.8
|
||||||
Programming Language :: Python :: 3.9
|
Programming Language :: Python :: 3.9
|
||||||
|
Programming Language :: Python :: 3.10
|
||||||
License :: OSI Approved :: BSD License
|
License :: OSI Approved :: BSD License
|
||||||
Programming Language :: Python :: Implementation :: PyPy
|
Programming Language :: Python :: Implementation :: PyPy
|
||||||
Programming Language :: Python :: Implementation :: CPython
|
Programming Language :: Python :: Implementation :: CPython
|
||||||
|
2
setup.py
2
setup.py
@ -4,6 +4,7 @@
|
|||||||
# Setup script for PyPI; use CMakeFile.txt to build extension modules
|
# Setup script for PyPI; use CMakeFile.txt to build extension modules
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
@ -11,7 +12,6 @@ import string
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import io
|
|
||||||
|
|
||||||
import setuptools.command.sdist
|
import setuptools.command.sdist
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -110,7 +110,11 @@ public:
|
|||||||
|
|
||||||
/// Overwrite this reference with another reference
|
/// Overwrite this reference with another reference
|
||||||
ref& operator=(const ref& r) {
|
ref& operator=(const ref& r) {
|
||||||
print_copy_assigned(this, "pointer", r.m_ptr); track_copy_assigned((ref_tag*) this);
|
if (this == &r) {
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
print_copy_assigned(this, "pointer", r.m_ptr);
|
||||||
|
track_copy_assigned((ref_tag *) this);
|
||||||
|
|
||||||
if (m_ptr == r.m_ptr)
|
if (m_ptr == r.m_ptr)
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -23,11 +23,10 @@ public:
|
|||||||
test_initializer(const char *submodule_name, Initializer init);
|
test_initializer(const char *submodule_name, Initializer init);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TEST_SUBMODULE(name, variable) \
|
#define TEST_SUBMODULE(name, variable) \
|
||||||
void test_submodule_##name(py::module_ &); \
|
void test_submodule_##name(py::module_ &); \
|
||||||
test_initializer name(#name, test_submodule_##name); \
|
test_initializer name(#name, test_submodule_##name); \
|
||||||
void test_submodule_##name(py::module_ &variable)
|
void test_submodule_##name(py::module_ &(variable))
|
||||||
|
|
||||||
|
|
||||||
/// Dummy type which is not exported anywhere -- something to trigger a conversion error
|
/// Dummy type which is not exported anywhere -- something to trigger a conversion error
|
||||||
struct UnregisteredType { };
|
struct UnregisteredType { };
|
||||||
|
@ -40,7 +40,11 @@ TEST_SUBMODULE(buffers, m) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Matrix &operator=(const Matrix &s) {
|
Matrix &operator=(const Matrix &s) {
|
||||||
print_copy_assigned(this, std::to_string(m_rows) + "x" + std::to_string(m_cols) + " matrix");
|
if (this == &s) {
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
print_copy_assigned(this,
|
||||||
|
std::to_string(m_rows) + "x" + std::to_string(m_cols) + " matrix");
|
||||||
delete[] m_data;
|
delete[] m_data;
|
||||||
m_rows = s.m_rows;
|
m_rows = s.m_rows;
|
||||||
m_cols = s.m_cols;
|
m_cols = s.m_cols;
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import ctypes
|
||||||
import io
|
import io
|
||||||
import struct
|
import struct
|
||||||
import ctypes
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import env # noqa: F401
|
import env # noqa: F401
|
||||||
|
|
||||||
from pybind11_tests import buffers as m
|
|
||||||
from pybind11_tests import ConstructorStats
|
from pybind11_tests import ConstructorStats
|
||||||
|
from pybind11_tests import buffers as m
|
||||||
|
|
||||||
np = pytest.importorskip("numpy")
|
np = pytest.importorskip("numpy")
|
||||||
|
|
||||||
|
@ -2,9 +2,8 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import env # noqa: F401
|
import env # noqa: F401
|
||||||
|
from pybind11_tests import IncType, UserType
|
||||||
from pybind11_tests import builtin_casters as m
|
from pybind11_tests import builtin_casters as m
|
||||||
from pybind11_tests import UserType, IncType
|
|
||||||
|
|
||||||
|
|
||||||
def test_simple_string():
|
def test_simple_string():
|
||||||
|
@ -2,9 +2,8 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import env # noqa: F401
|
import env # noqa: F401
|
||||||
|
|
||||||
from pybind11_tests import call_policies as m
|
|
||||||
from pybind11_tests import ConstructorStats
|
from pybind11_tests import ConstructorStats
|
||||||
|
from pybind11_tests import call_policies as m
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail("env.PYPY", reason="sometimes comes out 1 off on PyPy", strict=False)
|
@pytest.mark.xfail("env.PYPY", reason="sometimes comes out 1 off on PyPy", strict=False)
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
|
||||||
from pybind11_tests import callbacks as m
|
|
||||||
from threading import Thread
|
|
||||||
import time
|
import time
|
||||||
|
from threading import Thread
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
import env # NOQA: F401
|
import env # NOQA: F401
|
||||||
|
from pybind11_tests import callbacks as m
|
||||||
|
|
||||||
|
|
||||||
def test_callbacks():
|
def test_callbacks():
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from pybind11_tests import chrono as m
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import env # noqa: F401
|
import env # noqa: F401
|
||||||
|
from pybind11_tests import chrono as m
|
||||||
|
|
||||||
|
|
||||||
def test_chrono_system_clock():
|
def test_chrono_system_clock():
|
||||||
|
@ -505,15 +505,15 @@ using DoesntBreak5 = py::class_<BreaksBase<5>>;
|
|||||||
using DoesntBreak6 = py::class_<BreaksBase<6>, std::shared_ptr<BreaksBase<6>>, BreaksTramp<6>>;
|
using DoesntBreak6 = py::class_<BreaksBase<6>, std::shared_ptr<BreaksBase<6>>, BreaksTramp<6>>;
|
||||||
using DoesntBreak7 = py::class_<BreaksBase<7>, BreaksTramp<7>, std::shared_ptr<BreaksBase<7>>>;
|
using DoesntBreak7 = py::class_<BreaksBase<7>, BreaksTramp<7>, std::shared_ptr<BreaksBase<7>>>;
|
||||||
using DoesntBreak8 = py::class_<BreaksBase<8>, std::shared_ptr<BreaksBase<8>>>;
|
using DoesntBreak8 = py::class_<BreaksBase<8>, std::shared_ptr<BreaksBase<8>>>;
|
||||||
#define CHECK_BASE(N) static_assert(std::is_same<typename DoesntBreak##N::type, BreaksBase<N>>::value, \
|
#define CHECK_BASE(N) static_assert(std::is_same<typename DoesntBreak##N::type, BreaksBase<(N)>>::value, \
|
||||||
"DoesntBreak" #N " has wrong type!")
|
"DoesntBreak" #N " has wrong type!")
|
||||||
CHECK_BASE(1); CHECK_BASE(2); CHECK_BASE(3); CHECK_BASE(4); CHECK_BASE(5); CHECK_BASE(6); CHECK_BASE(7); CHECK_BASE(8);
|
CHECK_BASE(1); CHECK_BASE(2); CHECK_BASE(3); CHECK_BASE(4); CHECK_BASE(5); CHECK_BASE(6); CHECK_BASE(7); CHECK_BASE(8);
|
||||||
#define CHECK_ALIAS(N) static_assert(DoesntBreak##N::has_alias && std::is_same<typename DoesntBreak##N::type_alias, BreaksTramp<N>>::value, \
|
#define CHECK_ALIAS(N) static_assert(DoesntBreak##N::has_alias && std::is_same<typename DoesntBreak##N::type_alias, BreaksTramp<(N)>>::value, \
|
||||||
"DoesntBreak" #N " has wrong type_alias!")
|
"DoesntBreak" #N " has wrong type_alias!")
|
||||||
#define CHECK_NOALIAS(N) static_assert(!DoesntBreak##N::has_alias && std::is_void<typename DoesntBreak##N::type_alias>::value, \
|
#define CHECK_NOALIAS(N) static_assert(!DoesntBreak##N::has_alias && std::is_void<typename DoesntBreak##N::type_alias>::value, \
|
||||||
"DoesntBreak" #N " has type alias, but shouldn't!")
|
"DoesntBreak" #N " has type alias, but shouldn't!")
|
||||||
CHECK_ALIAS(1); CHECK_ALIAS(2); CHECK_NOALIAS(3); CHECK_ALIAS(4); CHECK_NOALIAS(5); CHECK_ALIAS(6); CHECK_ALIAS(7); CHECK_NOALIAS(8);
|
CHECK_ALIAS(1); CHECK_ALIAS(2); CHECK_NOALIAS(3); CHECK_ALIAS(4); CHECK_NOALIAS(5); CHECK_ALIAS(6); CHECK_ALIAS(7); CHECK_NOALIAS(8);
|
||||||
#define CHECK_HOLDER(N, TYPE) static_assert(std::is_same<typename DoesntBreak##N::holder_type, std::TYPE##_ptr<BreaksBase<N>>>::value, \
|
#define CHECK_HOLDER(N, TYPE) static_assert(std::is_same<typename DoesntBreak##N::holder_type, std::TYPE##_ptr<BreaksBase<(N)>>>::value, \
|
||||||
"DoesntBreak" #N " has wrong holder_type!")
|
"DoesntBreak" #N " has wrong holder_type!")
|
||||||
#define CHECK_SMART_HOLDER(N) static_assert(std::is_same<typename DoesntBreak##N::holder_type, py::smart_holder>::value, \
|
#define CHECK_SMART_HOLDER(N) static_assert(std::is_same<typename DoesntBreak##N::holder_type, py::smart_holder>::value, \
|
||||||
"DoesntBreak" #N " has wrong holder_type!")
|
"DoesntBreak" #N " has wrong holder_type!")
|
||||||
@ -530,7 +530,7 @@ CHECK_HOLDER(6, shared); CHECK_HOLDER(7, shared); CHECK_HOLDER(8, shared);
|
|||||||
// failures occurs).
|
// failures occurs).
|
||||||
|
|
||||||
// We have to actually look into the type: the typedef alone isn't enough to instantiate the type:
|
// We have to actually look into the type: the typedef alone isn't enough to instantiate the type:
|
||||||
#define CHECK_BROKEN(N) static_assert(std::is_same<typename Breaks##N::type, BreaksBase<-N>>::value, \
|
#define CHECK_BROKEN(N) static_assert(std::is_same<typename Breaks##N::type, BreaksBase<-(N)>>::value, \
|
||||||
"Breaks1 has wrong type!");
|
"Breaks1 has wrong type!");
|
||||||
|
|
||||||
//// Two holder classes:
|
//// Two holder classes:
|
||||||
|
@ -2,9 +2,8 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import env # noqa: F401
|
import env # noqa: F401
|
||||||
|
from pybind11_tests import ConstructorStats, UserType
|
||||||
from pybind11_tests import class_ as m
|
from pybind11_tests import class_ as m
|
||||||
from pybind11_tests import UserType, ConstructorStats
|
|
||||||
|
|
||||||
|
|
||||||
def test_repr():
|
def test_repr():
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import test_cmake_build
|
import test_cmake_build
|
||||||
|
|
||||||
assert test_cmake_build.add(1, 2) == 3
|
assert test_cmake_build.add(1, 2) == 3
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from pybind11_tests import copy_move_policies as m
|
from pybind11_tests import copy_move_policies as m
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from pybind11_tests import custom_type_casters as m
|
from pybind11_tests import custom_type_casters as m
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from pybind11_tests import ConstructorStats
|
from pybind11_tests import ConstructorStats
|
||||||
|
|
||||||
np = pytest.importorskip("numpy")
|
np = pytest.importorskip("numpy")
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from pybind11_tests import enums as m
|
from pybind11_tests import enums as m
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,4 +98,22 @@ TEST_SUBMODULE(eval_, m) {
|
|||||||
auto int_class = py::eval("isinstance(42, int)", global);
|
auto int_class = py::eval("isinstance(42, int)", global);
|
||||||
return global;
|
return global;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// test_eval_closure
|
||||||
|
m.def("test_eval_closure", []() {
|
||||||
|
py::dict global;
|
||||||
|
global["closure_value"] = 42;
|
||||||
|
py::dict local;
|
||||||
|
local["closure_value"] = 0;
|
||||||
|
py::exec(R"(
|
||||||
|
local_value = closure_value
|
||||||
|
|
||||||
|
def func_global():
|
||||||
|
return closure_value
|
||||||
|
|
||||||
|
def func_local():
|
||||||
|
return local_value
|
||||||
|
)", global, local);
|
||||||
|
return std::make_pair(global, local);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import os
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import env # noqa: F401
|
import env # noqa: F401
|
||||||
|
|
||||||
from pybind11_tests import eval_ as m
|
from pybind11_tests import eval_ as m
|
||||||
|
|
||||||
|
|
||||||
@ -33,3 +32,20 @@ def test_eval_empty_globals():
|
|||||||
g = {}
|
g = {}
|
||||||
assert "__builtins__" in m.eval_empty_globals(g)
|
assert "__builtins__" in m.eval_empty_globals(g)
|
||||||
assert "__builtins__" in g
|
assert "__builtins__" in g
|
||||||
|
|
||||||
|
|
||||||
|
def test_eval_closure():
|
||||||
|
global_, local = m.test_eval_closure()
|
||||||
|
|
||||||
|
assert global_["closure_value"] == 42
|
||||||
|
assert local["closure_value"] == 0
|
||||||
|
|
||||||
|
assert "local_value" not in global_
|
||||||
|
assert local["local_value"] == 0
|
||||||
|
|
||||||
|
assert "func_global" not in global_
|
||||||
|
assert local["func_global"]() == 42
|
||||||
|
|
||||||
|
assert "func_local" not in global_
|
||||||
|
with pytest.raises(NameError):
|
||||||
|
local["func_local"]()
|
||||||
|
@ -4,9 +4,8 @@ import sys
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import env # noqa: F401
|
import env # noqa: F401
|
||||||
|
|
||||||
from pybind11_tests import exceptions as m
|
|
||||||
import pybind11_cross_module_tests as cm
|
import pybind11_cross_module_tests as cm
|
||||||
|
from pybind11_tests import exceptions as m
|
||||||
|
|
||||||
|
|
||||||
def test_std_exception(msg):
|
def test_std_exception(msg):
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import env # noqa: F401
|
import pytest
|
||||||
|
|
||||||
|
import env # noqa: F401
|
||||||
|
from pybind11_tests import ConstructorStats
|
||||||
from pybind11_tests import factory_constructors as m
|
from pybind11_tests import factory_constructors as m
|
||||||
from pybind11_tests.factory_constructors import tag
|
from pybind11_tests.factory_constructors import tag
|
||||||
from pybind11_tests import ConstructorStats
|
|
||||||
|
|
||||||
|
|
||||||
def test_init_factory_basic():
|
def test_init_factory_basic():
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from pybind11_tests import iostream as m
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
||||||
|
from pybind11_tests import iostream as m
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Python 3
|
# Python 3
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import env # noqa: F401
|
import env # noqa: F401
|
||||||
|
|
||||||
from pybind11_tests import kwargs_and_defaults as m
|
from pybind11_tests import kwargs_and_defaults as m
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import env # noqa: F401
|
import env # noqa: F401
|
||||||
|
|
||||||
from pybind11_tests import local_bindings as m
|
from pybind11_tests import local_bindings as m
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,9 +2,8 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import env # noqa: F401
|
import env # noqa: F401
|
||||||
|
|
||||||
from pybind11_tests import methods_and_attributes as m
|
|
||||||
from pybind11_tests import ConstructorStats
|
from pybind11_tests import ConstructorStats
|
||||||
|
from pybind11_tests import methods_and_attributes as m
|
||||||
|
|
||||||
|
|
||||||
def test_methods_and_attributes():
|
def test_methods_and_attributes():
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from pybind11_tests import ConstructorStats
|
||||||
from pybind11_tests import modules as m
|
from pybind11_tests import modules as m
|
||||||
from pybind11_tests.modules import subsubmodule as ms
|
from pybind11_tests.modules import subsubmodule as ms
|
||||||
from pybind11_tests import ConstructorStats
|
|
||||||
|
|
||||||
|
|
||||||
def test_nested_modules():
|
def test_nested_modules():
|
||||||
@ -54,18 +54,20 @@ def test_reference_internal():
|
|||||||
|
|
||||||
|
|
||||||
def test_importing():
|
def test_importing():
|
||||||
from pybind11_tests.modules import OD
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
|
from pybind11_tests.modules import OD
|
||||||
|
|
||||||
assert OD is OrderedDict
|
assert OD is OrderedDict
|
||||||
assert str(OD([(1, "a"), (2, "b")])) == "OrderedDict([(1, 'a'), (2, 'b')])"
|
assert str(OD([(1, "a"), (2, "b")])) == "OrderedDict([(1, 'a'), (2, 'b')])"
|
||||||
|
|
||||||
|
|
||||||
def test_pydoc():
|
def test_pydoc():
|
||||||
"""Pydoc needs to be able to provide help() for everything inside a pybind11 module"""
|
"""Pydoc needs to be able to provide help() for everything inside a pybind11 module"""
|
||||||
import pybind11_tests
|
|
||||||
import pydoc
|
import pydoc
|
||||||
|
|
||||||
|
import pybind11_tests
|
||||||
|
|
||||||
assert pybind11_tests.__name__ == "pybind11_tests"
|
assert pybind11_tests.__name__ == "pybind11_tests"
|
||||||
assert pybind11_tests.__doc__ == "pybind11 test module"
|
assert pybind11_tests.__doc__ == "pybind11 test module"
|
||||||
assert pydoc.text.docmodule(pybind11_tests)
|
assert pydoc.text.docmodule(pybind11_tests)
|
||||||
|
@ -108,7 +108,10 @@ TEST_SUBMODULE(multiple_inheritance, m) {
|
|||||||
|
|
||||||
|
|
||||||
// test_multiple_inheritance_python_many_bases
|
// test_multiple_inheritance_python_many_bases
|
||||||
#define PYBIND11_BASEN(N) py::class_<BaseN<N>>(m, "BaseN" #N).def(py::init<int>()).def("f" #N, [](BaseN<N> &b) { return b.i + N; })
|
#define PYBIND11_BASEN(N) \
|
||||||
|
py::class_<BaseN<(N)>>(m, "BaseN" #N).def(py::init<int>()).def("f" #N, [](BaseN<N> &b) { \
|
||||||
|
return b.i + (N); \
|
||||||
|
})
|
||||||
PYBIND11_BASEN( 1); PYBIND11_BASEN( 2); PYBIND11_BASEN( 3); PYBIND11_BASEN( 4);
|
PYBIND11_BASEN( 1); PYBIND11_BASEN( 2); PYBIND11_BASEN( 3); PYBIND11_BASEN( 4);
|
||||||
PYBIND11_BASEN( 5); PYBIND11_BASEN( 6); PYBIND11_BASEN( 7); PYBIND11_BASEN( 8);
|
PYBIND11_BASEN( 5); PYBIND11_BASEN( 6); PYBIND11_BASEN( 7); PYBIND11_BASEN( 8);
|
||||||
PYBIND11_BASEN( 9); PYBIND11_BASEN(10); PYBIND11_BASEN(11); PYBIND11_BASEN(12);
|
PYBIND11_BASEN( 9); PYBIND11_BASEN(10); PYBIND11_BASEN(11); PYBIND11_BASEN(12);
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import env # noqa: F401
|
import env # noqa: F401
|
||||||
|
|
||||||
from pybind11_tests import ConstructorStats
|
from pybind11_tests import ConstructorStats
|
||||||
from pybind11_tests import multiple_inheritance as m
|
from pybind11_tests import multiple_inheritance as m
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import env # noqa: F401
|
import env # noqa: F401
|
||||||
|
|
||||||
from pybind11_tests import numpy_array as m
|
from pybind11_tests import numpy_array as m
|
||||||
|
|
||||||
np = pytest.importorskip("numpy")
|
np = pytest.importorskip("numpy")
|
||||||
|
@ -148,11 +148,13 @@ py::array mkarray_via_buffer(size_t n) {
|
|||||||
1, { n }, { sizeof(T) }));
|
1, { n }, { sizeof(T) }));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SET_TEST_VALS(s, i) do { \
|
#define SET_TEST_VALS(s, i) \
|
||||||
s.bool_ = (i) % 2 != 0; \
|
do { \
|
||||||
s.uint_ = (uint32_t) (i); \
|
(s).bool_ = (i) % 2 != 0; \
|
||||||
s.float_ = (float) (i) * 1.5f; \
|
(s).uint_ = (uint32_t) (i); \
|
||||||
s.ldbl_ = (long double) (i) * -2.5L; } while (0)
|
(s).float_ = (float) (i) *1.5f; \
|
||||||
|
(s).ldbl_ = (long double) (i) * -2.5L; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
template <typename S>
|
template <typename S>
|
||||||
py::array_t<S, 0> create_recarray(size_t n) {
|
py::array_t<S, 0> create_recarray(size_t n) {
|
||||||
|
@ -4,7 +4,6 @@ import re
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import env # noqa: F401
|
import env # noqa: F401
|
||||||
|
|
||||||
from pybind11_tests import numpy_dtypes as m
|
from pybind11_tests import numpy_dtypes as m
|
||||||
|
|
||||||
np = pytest.importorskip("numpy")
|
np = pytest.importorskip("numpy")
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from pybind11_tests import numpy_vectorize as m
|
from pybind11_tests import numpy_vectorize as m
|
||||||
|
|
||||||
np = pytest.importorskip("numpy")
|
np = pytest.importorskip("numpy")
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
from pybind11_tests import opaque_types as m
|
|
||||||
from pybind11_tests import ConstructorStats, UserType
|
from pybind11_tests import ConstructorStats, UserType
|
||||||
|
from pybind11_tests import opaque_types as m
|
||||||
|
|
||||||
|
|
||||||
def test_string_list():
|
def test_string_list():
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
from pybind11_tests import operators as m
|
|
||||||
from pybind11_tests import ConstructorStats
|
from pybind11_tests import ConstructorStats
|
||||||
|
from pybind11_tests import operators as m
|
||||||
|
|
||||||
|
|
||||||
def test_operator_overloading():
|
def test_operator_overloading():
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import env # noqa: F401
|
import env # noqa: F401
|
||||||
|
|
||||||
from pybind11_tests import pickling as m
|
from pybind11_tests import pickling as m
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import division
|
from __future__ import division
|
||||||
import pytest
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import env # noqa: F401
|
import pytest
|
||||||
|
|
||||||
from pybind11_tests import pytypes as m
|
import env # noqa: F401
|
||||||
from pybind11_tests import debug_enabled
|
from pybind11_tests import debug_enabled
|
||||||
|
from pybind11_tests import pytypes as m
|
||||||
|
|
||||||
|
|
||||||
def test_int(doc):
|
def test_int(doc):
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
from pybind11_tests import sequences_and_iterators as m
|
|
||||||
from pybind11_tests import ConstructorStats
|
from pybind11_tests import ConstructorStats
|
||||||
|
from pybind11_tests import sequences_and_iterators as m
|
||||||
|
|
||||||
|
|
||||||
def isclose(a, b, rel_tol=1e-05, abs_tol=0.0):
|
def isclose(a, b, rel_tol=1e-05, abs_tol=0.0):
|
||||||
|
@ -182,6 +182,7 @@ struct SharedPtrRef {
|
|||||||
struct SharedFromThisRef {
|
struct SharedFromThisRef {
|
||||||
struct B : std::enable_shared_from_this<B> {
|
struct B : std::enable_shared_from_this<B> {
|
||||||
B() { print_created(this); }
|
B() { print_created(this); }
|
||||||
|
// NOLINTNEXTLINE(bugprone-copy-constructor-init)
|
||||||
B(const B &) : std::enable_shared_from_this<B>() { print_copy_created(this); }
|
B(const B &) : std::enable_shared_from_this<B>() { print_copy_created(this); }
|
||||||
B(B &&) noexcept : std::enable_shared_from_this<B>() { print_move_created(this); }
|
B(B &&) noexcept : std::enable_shared_from_this<B>() { print_move_created(this); }
|
||||||
~B() { print_destroyed(this); }
|
~B() { print_destroyed(this); }
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from pybind11_tests import ConstructorStats, UserType
|
||||||
from pybind11_tests import stl as m
|
from pybind11_tests import stl as m
|
||||||
from pybind11_tests import UserType
|
|
||||||
from pybind11_tests import ConstructorStats
|
|
||||||
|
|
||||||
|
|
||||||
def test_vector(doc):
|
def test_vector(doc):
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import env # noqa: F401
|
import env # noqa: F401
|
||||||
|
|
||||||
from pybind11_tests import stl_binders as m
|
from pybind11_tests import stl_binders as m
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,13 +86,13 @@ std::vector<std::unique_ptr<Animal>> create_zoo()
|
|||||||
const std::type_info* Animal::type_of_kind(Kind kind)
|
const std::type_info* Animal::type_of_kind(Kind kind)
|
||||||
{
|
{
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case Kind::Unknown: break;
|
case Kind::Unknown:
|
||||||
|
|
||||||
case Kind::Dog: break;
|
case Kind::Dog: break;
|
||||||
|
|
||||||
case Kind::Labrador: return &typeid(Labrador);
|
case Kind::Labrador: return &typeid(Labrador);
|
||||||
case Kind::Chihuahua: return &typeid(Chihuahua);
|
case Kind::Chihuahua: return &typeid(Chihuahua);
|
||||||
case Kind::LastDog: break;
|
|
||||||
|
|
||||||
|
case Kind::LastDog:
|
||||||
case Kind::Cat: break;
|
case Kind::Cat: break;
|
||||||
case Kind::Panther: return &typeid(Panther);
|
case Kind::Panther: return &typeid(Panther);
|
||||||
case Kind::LastCat: break;
|
case Kind::LastCat: break;
|
||||||
|
@ -454,6 +454,7 @@ template <class Base = B_Tpl>
|
|||||||
class PyB_Tpl : public PyA_Tpl<Base> {
|
class PyB_Tpl : public PyA_Tpl<Base> {
|
||||||
public:
|
public:
|
||||||
using PyA_Tpl<Base>::PyA_Tpl; // Inherit constructors (via PyA_Tpl's inherited constructors)
|
using PyA_Tpl<Base>::PyA_Tpl; // Inherit constructors (via PyA_Tpl's inherited constructors)
|
||||||
|
// NOLINTNEXTLINE(bugprone-parent-virtual-call)
|
||||||
int unlucky_number() override { PYBIND11_OVERRIDE(int, Base, unlucky_number, ); }
|
int unlucky_number() override { PYBIND11_OVERRIDE(int, Base, unlucky_number, ); }
|
||||||
double lucky_number() override { PYBIND11_OVERRIDE(double, Base, lucky_number, ); }
|
double lucky_number() override { PYBIND11_OVERRIDE(double, Base, lucky_number, ); }
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import print_function, division
|
from __future__ import division, print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -4,11 +4,9 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
import ghapi.all
|
import ghapi.all
|
||||||
|
|
||||||
from rich import print
|
from rich import print
|
||||||
from rich.syntax import Syntax
|
from rich.syntax import Syntax
|
||||||
|
|
||||||
|
|
||||||
ENTRY = re.compile(
|
ENTRY = re.compile(
|
||||||
r"""
|
r"""
|
||||||
Suggested \s changelog \s entry:
|
Suggested \s changelog \s entry:
|
||||||
|
@ -147,7 +147,7 @@ Add a module and setup all helpers. You can select the type of the library; the
|
|||||||
default is ``MODULE``. There are several options:
|
default is ``MODULE``. There are several options:
|
||||||
|
|
||||||
``OPT_SIZE``
|
``OPT_SIZE``
|
||||||
Optimize for size, even if the ``CMAKE_BUILD_TYPE`` is not ``RelSize``.
|
Optimize for size, even if the ``CMAKE_BUILD_TYPE`` is not ``MinSizeRel``.
|
||||||
``THIN_LTO``
|
``THIN_LTO``
|
||||||
Use thin TLO instead of regular if there's a choice (pybind11's selection
|
Use thin TLO instead of regular if there's a choice (pybind11's selection
|
||||||
is disabled if ``CMAKE_INTERPROCEDURAL_OPTIMIZATIONS`` is set).
|
is disabled if ``CMAKE_INTERPROCEDURAL_OPTIMIZATIONS`` is set).
|
||||||
|
Loading…
Reference in New Issue
Block a user