mirror of
https://github.com/pybind/pybind11.git
synced 2025-01-19 17:32:37 +00:00
define PYBIND11_DETAIL_ODR_GUARD_IMPL_THROW_DISABLED true in test_odr_guard_1,2.cpp
This commit is contained in:
parent
a34771aeda
commit
6a6eb6cac8
@ -25,11 +25,8 @@
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <typeindex>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@ -60,7 +57,8 @@ struct type_caster_odr_guard : type_caster<IntrinsicType> {
|
||||
template <typename IntrinsicType>
|
||||
int type_caster_odr_guard<IntrinsicType>::translation_unit_local = []() {
|
||||
odr_guard_impl<IntrinsicType>(std::type_index(typeid(IntrinsicType)),
|
||||
type_caster<IntrinsicType>::source_file_line.text);
|
||||
type_caster<IntrinsicType>::source_file_line.text,
|
||||
PYBIND11_DETAIL_ODR_GUARD_IMPL_THROW_DISABLED);
|
||||
return 0;
|
||||
}();
|
||||
|
||||
|
@ -302,7 +302,6 @@
|
||||
#define PYBIND11_TRY_NEXT_OVERLOAD ((PyObject *) 1) // special failure return code
|
||||
#define PYBIND11_STRINGIFY(x) #x
|
||||
#define PYBIND11_TOSTRING(x) PYBIND11_STRINGIFY(x)
|
||||
#define PYBIND11_SOURCE_FILE_LINE __FILE__ ":" PYBIND11_TOSTRING(__LINE__)
|
||||
#define PYBIND11_CONCAT(first, second) first##second
|
||||
#define PYBIND11_ENSURE_INTERNALS_READY pybind11::detail::get_internals();
|
||||
|
||||
|
@ -55,8 +55,14 @@ inline const char *source_file_line_basename(const char *sfl) {
|
||||
return sfl + i_base;
|
||||
}
|
||||
|
||||
# ifndef PYBIND11_DETAIL_ODR_GUARD_IMPL_THROW_DISABLED
|
||||
# define PYBIND11_DETAIL_ODR_GUARD_IMPL_THROW_DISABLED false
|
||||
# endif
|
||||
|
||||
template <typename IntrinsicType>
|
||||
bool odr_guard_impl(const std::type_index &it_ti, const char *source_file_line) {
|
||||
void odr_guard_impl(const std::type_index &it_ti,
|
||||
const char *source_file_line,
|
||||
bool throw_disabled) {
|
||||
// std::cout cannot be used here: static initialization could be incomplete.
|
||||
# define PYBIND11_DETAIL_ODR_GUARD_IMPL_PRINTF_OFF
|
||||
# ifdef PYBIND11_DETAIL_ODR_GUARD_IMPL_PRINTF_ON
|
||||
@ -77,15 +83,13 @@ bool odr_guard_impl(const std::type_index &it_ti, const char *source_file_line)
|
||||
+ type_id<IntrinsicType>() + ">: SourceLocation1=\""
|
||||
+ reg_iter->second + "\", SourceLocation2=\"" + source_file_line
|
||||
+ "\"");
|
||||
# define PYBIND11_TYPE_CASTER_ODR_GUARD_THROW_OFF
|
||||
# ifdef PYBIND11_TYPE_CASTER_ODR_GUARD_THROW_ON
|
||||
throw err;
|
||||
# else
|
||||
fprintf(stderr, "\nDISABLED std::system_error: %s\n", err.what());
|
||||
fflush(stderr);
|
||||
# endif
|
||||
if (throw_disabled) {
|
||||
fprintf(stderr, "\nDISABLED std::system_error: %s\n", err.what());
|
||||
fflush(stderr);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -1,3 +1,4 @@
|
||||
#define PYBIND11_DETAIL_ODR_GUARD_IMPL_THROW_DISABLED true
|
||||
#include "pybind11_tests.h"
|
||||
|
||||
namespace mrc_ns { // minimal real caster
|
||||
|
@ -1,3 +1,4 @@
|
||||
#define PYBIND11_DETAIL_ODR_GUARD_IMPL_THROW_DISABLED true
|
||||
#include "pybind11_tests.h"
|
||||
|
||||
namespace mrc_ns { // minimal real caster
|
||||
|
Loading…
Reference in New Issue
Block a user