Repository: nifi-minifi-cpp Updated Branches: refs/heads/master d5e5a4fea -> 1a3136b71
http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/1a3136b7/thirdparty/pybind11/include/pybind11/pybind11.h ---------------------------------------------------------------------- diff --git a/thirdparty/pybind11/include/pybind11/pybind11.h b/thirdparty/pybind11/include/pybind11/pybind11.h index 613135a..e986d00 100644 --- a/thirdparty/pybind11/include/pybind11/pybind11.h +++ b/thirdparty/pybind11/include/pybind11/pybind11.h @@ -51,6 +51,7 @@ NAMESPACE_BEGIN(PYBIND11_NAMESPACE) class cpp_function : public function { public: cpp_function() { } + cpp_function(std::nullptr_t) { } /// Construct a cpp_function from a vanilla function pointer template <typename Return, typename... Args, typename... Extra> @@ -92,8 +93,8 @@ protected: /// Special internal constructor for functors, lambda functions, etc. template <typename Func, typename Return, typename... Args, typename... Extra> void initialize(Func &&f, Return (*)(Args...), const Extra&... extra) { - - struct capture { detail::remove_reference_t<Func> f; }; + using namespace detail; + struct capture { remove_reference_t<Func> f; }; /* Store the function including any extra state it might have (e.g. a lambda capture object) */ auto rec = make_function_record(); @@ -112,23 +113,23 @@ protected: # pragma GCC diagnostic pop #endif if (!std::is_trivially_destructible<Func>::value) - rec->free_data = [](detail::function_record *r) { ((capture *) &r->data)->~capture(); }; + rec->free_data = [](function_record *r) { ((capture *) &r->data)->~capture(); }; } else { rec->data[0] = new capture { std::forward<Func>(f) }; - rec->free_data = [](detail::function_record *r) { delete ((capture *) r->data[0]); }; + rec->free_data = [](function_record *r) { delete ((capture *) r->data[0]); }; } /* Type casters for the function arguments and return value */ - using cast_in = detail::argument_loader<Args...>; - using cast_out = detail::make_caster< - detail::conditional_t<std::is_void<Return>::value, detail::void_type, Return> + using cast_in = argument_loader<Args...>; + using cast_out = make_caster< + conditional_t<std::is_void<Return>::value, void_type, Return> >; - static_assert(detail::expected_num_args<Extra...>(sizeof...(Args), cast_in::has_args, cast_in::has_kwargs), + static_assert(expected_num_args<Extra...>(sizeof...(Args), cast_in::has_args, cast_in::has_kwargs), "The number of argument annotations does not match the number of function arguments"); /* Dispatch code which converts function arguments and performs the actual function call */ - rec->impl = [](detail::function_call &call) -> handle { + rec->impl = [](function_call &call) -> handle { cast_in args_converter; /* Try to cast the function arguments into the C++ domain */ @@ -136,7 +137,7 @@ protected: return PYBIND11_TRY_NEXT_OVERLOAD; /* Invoke call policy pre-call hook */ - detail::process_attributes<Extra...>::precall(call); + process_attributes<Extra...>::precall(call); /* Get a pointer to the capture object */ auto data = (sizeof(capture) <= sizeof(call.func.data) @@ -144,30 +145,30 @@ protected: capture *cap = const_cast<capture *>(reinterpret_cast<const capture *>(data)); /* Override policy for rvalues -- usually to enforce rvp::move on an rvalue */ - const auto policy = detail::return_value_policy_override<Return>::policy(call.func.policy); + return_value_policy policy = return_value_policy_override<Return>::policy(call.func.policy); /* Function scope guard -- defaults to the compile-to-nothing `void_type` */ - using Guard = detail::extract_guard_t<Extra...>; + using Guard = extract_guard_t<Extra...>; /* Perform the function call */ handle result = cast_out::cast( std::move(args_converter).template call<Return, Guard>(cap->f), policy, call.parent); /* Invoke call policy post-call hook */ - detail::process_attributes<Extra...>::postcall(call, result); + process_attributes<Extra...>::postcall(call, result); return result; }; /* Process any user-provided function attributes */ - detail::process_attributes<Extra...>::init(extra..., rec); + process_attributes<Extra...>::init(extra..., rec); /* Generate a readable signature describing the function's arguments and return value types */ - using detail::descr; using detail::_; - PYBIND11_DESCR signature = _("(") + cast_in::arg_names() + _(") -> ") + cast_out::name(); + static constexpr auto signature = _("(") + cast_in::arg_names + _(") -> ") + cast_out::name; + PYBIND11_DESCR_CONSTEXPR auto types = decltype(signature)::types(); /* Register the function with Python from generic (non-templated) code */ - initialize_generic(rec, signature.text(), signature.types(), sizeof...(Args)); + initialize_generic(rec, signature.text, types.data(), sizeof...(Args)); if (cast_in::has_args) rec->has_args = true; if (cast_in::has_kwargs) rec->has_kwargs = true; @@ -217,52 +218,45 @@ protected: /* Generate a proper function signature */ std::string signature; - size_t type_depth = 0, char_index = 0, type_index = 0, arg_index = 0; - while (true) { - char c = text[char_index++]; - if (c == '\0') - break; + size_t type_index = 0, arg_index = 0; + for (auto *pc = text; *pc != '\0'; ++pc) { + const auto c = *pc; if (c == '{') { - // Write arg name for everything except *args, **kwargs and return type. - if (type_depth == 0 && text[char_index] != '*' && arg_index < args) { - if (!rec->args.empty() && rec->args[arg_index].name) { - signature += rec->args[arg_index].name; - } else if (arg_index == 0 && rec->is_method) { - signature += "self"; - } else { - signature += "arg" + std::to_string(arg_index - (rec->is_method ? 1 : 0)); - } - signature += ": "; + // Write arg name for everything except *args and **kwargs. + if (*(pc + 1) == '*') + continue; + + if (arg_index < rec->args.size() && rec->args[arg_index].name) { + signature += rec->args[arg_index].name; + } else if (arg_index == 0 && rec->is_method) { + signature += "self"; + } else { + signature += "arg" + std::to_string(arg_index - (rec->is_method ? 1 : 0)); } - ++type_depth; + signature += ": "; } else if (c == '}') { - --type_depth; - if (type_depth == 0) { - if (arg_index < rec->args.size() && rec->args[arg_index].descr) { - signature += "="; - signature += rec->args[arg_index].descr; - } - arg_index++; + // Write default value if available. + if (arg_index < rec->args.size() && rec->args[arg_index].descr) { + signature += " = "; + signature += rec->args[arg_index].descr; } + arg_index++; } else if (c == '%') { const std::type_info *t = types[type_index++]; if (!t) pybind11_fail("Internal error while parsing type signature (1)"); if (auto tinfo = detail::get_type_info(*t)) { -#if defined(PYPY_VERSION) - signature += handle((PyObject *) tinfo->type) - .attr("__module__") - .cast<std::string>() + "."; -#endif - signature += tinfo->type->tp_name; + handle th((PyObject *) tinfo->type); + signature += + th.attr("__module__").cast<std::string>() + "." + + th.attr("__qualname__").cast<std::string>(); // Python 3.3+, but we backport it to earlier versions } else if (rec->is_new_style_constructor && arg_index == 0) { // A new-style `__init__` takes `self` as `value_and_holder`. // Rewrite it to the proper class type. -#if defined(PYPY_VERSION) - signature += rec->scope.attr("__module__").cast<std::string>() + "."; -#endif - signature += ((PyTypeObject *) rec->scope.ptr())->tp_name; + signature += + rec->scope.attr("__module__").cast<std::string>() + "." + + rec->scope.attr("__qualname__").cast<std::string>(); } else { std::string tname(t->name()); detail::clean_type_id(tname); @@ -272,14 +266,9 @@ protected: signature += c; } } - if (type_depth != 0 || types[type_index] != nullptr) + if (arg_index != args || types[type_index] != nullptr) pybind11_fail("Internal error while parsing type signature (2)"); - #if !defined(PYBIND11_CONSTEXPR_DESCR) - delete[] types; - delete[] text; - #endif - #if PY_MAJOR_VERSION < 3 if (strcmp(rec->name, "__next__") == 0) { std::free(rec->name); @@ -317,7 +306,7 @@ protected: rec->def = new PyMethodDef(); std::memset(rec->def, 0, sizeof(PyMethodDef)); rec->def->ml_name = rec->name; - rec->def->ml_meth = reinterpret_cast<PyCFunction>(*dispatcher); + rec->def->ml_meth = reinterpret_cast<PyCFunction>(reinterpret_cast<void (*) (void)>(*dispatcher)); rec->def->ml_flags = METH_VARARGS | METH_KEYWORDS; capsule rec_capsule(rec, [](void *ptr) { @@ -579,8 +568,8 @@ protected: continue; // Unconsumed kwargs, but no py::kwargs argument to accept them // 4a. If we have a py::args argument, create a new tuple with leftovers - tuple extra_args; if (func.has_args) { + tuple extra_args; if (args_to_copy == 0) { // We didn't copy out any position arguments from the args_in tuple, so we // can reuse it directly without copying: @@ -591,12 +580,12 @@ protected: size_t args_size = n_args_in - args_copied; extra_args = tuple(args_size); for (size_t i = 0; i < args_size; ++i) { - handle item = PyTuple_GET_ITEM(args_in, args_copied + i); - extra_args[i] = item.inc_ref().ptr(); + extra_args[i] = PyTuple_GET_ITEM(args_in, args_copied + i); } } call.args.push_back(extra_args); call.args_convert.push_back(false); + call.args_ref = std::move(extra_args); } // 4b. If we have a py::kwargs, pass on any remaining kwargs @@ -605,6 +594,7 @@ protected: kwargs = dict(); // If we didn't get one, send an empty one call.args.push_back(kwargs); call.args_convert.push_back(false); + call.kwargs_ref = std::move(kwargs); } // 5. Put everything in a vector. Not technically step 5, we've been building it @@ -963,18 +953,18 @@ protected: tinfo->get_buffer_data = get_buffer_data; } + // rec_func must be set for either fget or fset. void def_property_static_impl(const char *name, handle fget, handle fset, - detail::function_record *rec_fget) { - const auto is_static = !(rec_fget->is_method && rec_fget->scope); - const auto has_doc = rec_fget->doc && pybind11::options::show_user_defined_docstrings(); - + detail::function_record *rec_func) { + const auto is_static = rec_func && !(rec_func->is_method && rec_func->scope); + const auto has_doc = rec_func && rec_func->doc && pybind11::options::show_user_defined_docstrings(); auto property = handle((PyObject *) (is_static ? get_internals().static_property_type : &PyProperty_Type)); attr(name) = property(fget.ptr() ? fget : none(), fset.ptr() ? fset : none(), /*deleter*/none(), - pybind11::str(has_doc ? rec_fget->doc : "")); + pybind11::str(has_doc ? rec_func->doc : "")); } }; @@ -1006,10 +996,18 @@ template <typename /*Derived*/, typename F> auto method_adaptor(F &&f) -> decltype(std::forward<F>(f)) { return std::forward<F>(f); } template <typename Derived, typename Return, typename Class, typename... Args> -auto method_adaptor(Return (Class::*pmf)(Args...)) -> Return (Derived::*)(Args...) { return pmf; } +auto method_adaptor(Return (Class::*pmf)(Args...)) -> Return (Derived::*)(Args...) { + static_assert(detail::is_accessible_base_of<Class, Derived>::value, + "Cannot bind an inaccessible base class method; use a lambda definition instead"); + return pmf; +} template <typename Derived, typename Return, typename Class, typename... Args> -auto method_adaptor(Return (Class::*pmf)(Args...) const) -> Return (Derived::*)(Args...) const { return pmf; } +auto method_adaptor(Return (Class::*pmf)(Args...) const) -> Return (Derived::*)(Args...) const { + static_assert(detail::is_accessible_base_of<Class, Derived>::value, + "Cannot bind an inaccessible base class method; use a lambda definition instead"); + return pmf; +} template <typename type_, typename... options> class class_ : public detail::generic_type { @@ -1200,7 +1198,7 @@ public: /// Uses cpp_function's return_value_policy by default template <typename... Extra> class_ &def_property_readonly(const char *name, const cpp_function &fget, const Extra& ...extra) { - return def_property(name, fget, cpp_function(), extra...); + return def_property(name, fget, nullptr, extra...); } /// Uses return_value_policy::reference by default @@ -1212,7 +1210,7 @@ public: /// Uses cpp_function's return_value_policy by default template <typename... Extra> class_ &def_property_readonly_static(const char *name, const cpp_function &fget, const Extra& ...extra) { - return def_property_static(name, fget, cpp_function(), extra...); + return def_property_static(name, fget, nullptr, extra...); } /// Uses return_value_policy::reference_internal by default @@ -1242,21 +1240,25 @@ public: template <typename... Extra> class_ &def_property_static(const char *name, const cpp_function &fget, const cpp_function &fset, const Extra& ...extra) { auto rec_fget = get_function_record(fget), rec_fset = get_function_record(fset); - char *doc_prev = rec_fget->doc; /* 'extra' field may include a property-specific documentation string */ - detail::process_attributes<Extra...>::init(extra..., rec_fget); - if (rec_fget->doc && rec_fget->doc != doc_prev) { - free(doc_prev); - rec_fget->doc = strdup(rec_fget->doc); + auto *rec_active = rec_fget; + if (rec_fget) { + char *doc_prev = rec_fget->doc; /* 'extra' field may include a property-specific documentation string */ + detail::process_attributes<Extra...>::init(extra..., rec_fget); + if (rec_fget->doc && rec_fget->doc != doc_prev) { + free(doc_prev); + rec_fget->doc = strdup(rec_fget->doc); + } } if (rec_fset) { - doc_prev = rec_fset->doc; + char *doc_prev = rec_fset->doc; detail::process_attributes<Extra...>::init(extra..., rec_fset); if (rec_fset->doc && rec_fset->doc != doc_prev) { free(doc_prev); rec_fset->doc = strdup(rec_fset->doc); } + if (! rec_active) rec_active = rec_fset; } - def_property_static_impl(name, fget, fset, rec_fget); + def_property_static_impl(name, fget, fset, rec_active); return *this; } @@ -1269,25 +1271,25 @@ private: auto sh = std::dynamic_pointer_cast<typename holder_type::element_type>( v_h.value_ptr<type>()->shared_from_this()); if (sh) { - new (&v_h.holder<holder_type>()) holder_type(std::move(sh)); + new (std::addressof(v_h.holder<holder_type>())) holder_type(std::move(sh)); v_h.set_holder_constructed(); } } catch (const std::bad_weak_ptr &) {} if (!v_h.holder_constructed() && inst->owned) { - new (&v_h.holder<holder_type>()) holder_type(v_h.value_ptr<type>()); + new (std::addressof(v_h.holder<holder_type>())) holder_type(v_h.value_ptr<type>()); v_h.set_holder_constructed(); } } static void init_holder_from_existing(const detail::value_and_holder &v_h, const holder_type *holder_ptr, std::true_type /*is_copy_constructible*/) { - new (&v_h.holder<holder_type>()) holder_type(*reinterpret_cast<const holder_type *>(holder_ptr)); + new (std::addressof(v_h.holder<holder_type>())) holder_type(*reinterpret_cast<const holder_type *>(holder_ptr)); } static void init_holder_from_existing(const detail::value_and_holder &v_h, const holder_type *holder_ptr, std::false_type /*is_copy_constructible*/) { - new (&v_h.holder<holder_type>()) holder_type(std::move(*const_cast<holder_type *>(holder_ptr))); + new (std::addressof(v_h.holder<holder_type>())) holder_type(std::move(*const_cast<holder_type *>(holder_ptr))); } /// Initialize holder object, variant 2: try to construct from existing holder object, if possible @@ -1297,7 +1299,7 @@ private: init_holder_from_existing(v_h, holder_ptr, std::is_copy_constructible<holder_type>()); v_h.set_holder_constructed(); } else if (inst->owned || detail::always_construct_holder<holder_type>::value) { - new (&v_h.holder<holder_type>()) holder_type(v_h.value_ptr<type>()); + new (std::addressof(v_h.holder<holder_type>())) holder_type(v_h.value_ptr<type>()); v_h.set_holder_constructed(); } } @@ -1362,6 +1364,7 @@ detail::initimpl::pickle_factory<GetState, SetState> pickle(GetState &&g, SetSta template <typename Type> class enum_ : public class_<Type> { public: using class_<Type>::def; + using class_<Type>::def_property_readonly; using class_<Type>::def_property_readonly_static; using Scalar = typename std::underlying_type<Type>::type; @@ -1374,15 +1377,37 @@ public: auto m_entries_ptr = m_entries.inc_ref().ptr(); def("__repr__", [name, m_entries_ptr](Type value) -> pybind11::str { for (const auto &kv : reinterpret_borrow<dict>(m_entries_ptr)) { - if (pybind11::cast<Type>(kv.second) == value) + if (pybind11::cast<Type>(kv.second[int_(0)]) == value) return pybind11::str("{}.{}").format(name, kv.first); } return pybind11::str("{}.???").format(name); }); - def_property_readonly_static("__members__", [m_entries_ptr](object /* self */) { + def_property_readonly("name", [m_entries_ptr](Type value) -> pybind11::str { + for (const auto &kv : reinterpret_borrow<dict>(m_entries_ptr)) { + if (pybind11::cast<Type>(kv.second[int_(0)]) == value) + return pybind11::str(kv.first); + } + return pybind11::str("???"); + }); + def_property_readonly_static("__doc__", [m_entries_ptr](handle self_) { + std::string docstring; + const char *tp_doc = ((PyTypeObject *) self_.ptr())->tp_doc; + if (tp_doc) + docstring += std::string(tp_doc) + "\n\n"; + docstring += "Members:"; + for (const auto &kv : reinterpret_borrow<dict>(m_entries_ptr)) { + auto key = std::string(pybind11::str(kv.first)); + auto comment = kv.second[int_(1)]; + docstring += "\n\n " + key; + if (!comment.is_none()) + docstring += " : " + (std::string) pybind11::str(comment); + } + return docstring; + }); + def_property_readonly_static("__members__", [m_entries_ptr](handle /* self_ */) { dict m; for (const auto &kv : reinterpret_borrow<dict>(m_entries_ptr)) - m[kv.first] = kv.second; + m[kv.first] = kv.second[int_(0)]; return m; }, return_value_policy::copy); def(init([](Scalar i) { return static_cast<Type>(i); })); @@ -1430,15 +1455,15 @@ public: /// Export enumeration entries into the parent scope enum_& export_values() { for (const auto &kv : m_entries) - m_parent.attr(kv.first) = kv.second; + m_parent.attr(kv.first) = kv.second[int_(0)]; return *this; } /// Add an enumeration entry - enum_& value(char const* name, Type value) { + enum_& value(char const* name, Type value, const char *doc = nullptr) { auto v = pybind11::cast(value, return_value_policy::copy); this->attr(name) = v; - m_entries[pybind11::str(name)] = v; + m_entries[pybind11::str(name)] = std::make_pair(v, doc); return *this; } @@ -1633,6 +1658,7 @@ void register_exception_translator(ExceptionTranslator&& translator) { template <typename type> class exception : public object { public: + exception() = default; exception(handle scope, const char *name, PyObject *base = PyExc_Exception) { std::string full_name = scope.attr("__name__").cast<std::string>() + std::string(".") + name; @@ -1649,6 +1675,14 @@ public: } }; +NAMESPACE_BEGIN(detail) +// Returns a reference to a function-local static exception object used in the simple +// register_exception approach below. (It would be simpler to have the static local variable +// directly in register_exception, but that makes clang <3.5 segfault - issue #1349). +template <typename CppException> +exception<CppException> &get_exception_object() { static exception<CppException> ex; return ex; } +NAMESPACE_END(detail) + /** * Registers a Python exception in `m` of the given `name` and installs an exception translator to * translate the C++ exception to the created Python exception using the exceptions what() method. @@ -1659,13 +1693,15 @@ template <typename CppException> exception<CppException> ®ister_exception(handle scope, const char *name, PyObject *base = PyExc_Exception) { - static exception<CppException> ex(scope, name, base); + auto &ex = detail::get_exception_object<CppException>(); + if (!ex) ex = exception<CppException>(scope, name, base); + register_exception_translator([](std::exception_ptr p) { if (!p) return; try { std::rethrow_exception(p); } catch (const CppException &e) { - ex(e.what()); + detail::get_exception_object<CppException>()(e.what()); } }); return ex; @@ -1738,7 +1774,7 @@ class gil_scoped_acquire { public: PYBIND11_NOINLINE gil_scoped_acquire() { auto const &internals = detail::get_internals(); - tstate = (PyThreadState *) PyThread_get_key_value(internals.tstate); + tstate = (PyThreadState *) PYBIND11_TLS_GET_VALUE(internals.tstate); if (!tstate) { tstate = PyThreadState_New(internals.istate); @@ -1747,10 +1783,7 @@ public: pybind11_fail("scoped_acquire: could not create thread state!"); #endif tstate->gilstate_counter = 0; - #if PY_MAJOR_VERSION < 3 - PyThread_delete_key_value(internals.tstate); - #endif - PyThread_set_key_value(internals.tstate, tstate); + PYBIND11_TLS_REPLACE_VALUE(internals.tstate, tstate); } else { release = detail::get_thread_state_unchecked() != tstate; } @@ -1789,7 +1822,7 @@ public: #endif PyThreadState_Clear(tstate); PyThreadState_DeleteCurrent(); - PyThread_delete_key_value(detail::get_internals().tstate); + PYBIND11_TLS_DELETE_VALUE(detail::get_internals().tstate); release = false; } } @@ -1814,11 +1847,7 @@ public: tstate = PyEval_SaveThread(); if (disassoc) { auto key = internals.tstate; - #if PY_MAJOR_VERSION < 3 - PyThread_delete_key_value(key); - #else - PyThread_set_key_value(key, nullptr); - #endif + PYBIND11_TLS_DELETE_VALUE(key); } } ~gil_scoped_release() { @@ -1827,10 +1856,7 @@ public: PyEval_RestoreThread(tstate); if (disassoc) { auto key = detail::get_internals().tstate; - #if PY_MAJOR_VERSION < 3 - PyThread_delete_key_value(key); - #endif - PyThread_set_key_value(key, tstate); + PYBIND11_TLS_REPLACE_VALUE(key, tstate); } } private: @@ -1858,6 +1884,7 @@ class gil_scoped_release { }; error_already_set::~error_already_set() { if (type) { + error_scope scope; gil_scoped_acquire gil; type.release().dec_ref(); value.release().dec_ref(); @@ -1941,18 +1968,18 @@ template <class T> function get_overload(const T *this_ptr, const char *name) { } #define PYBIND11_OVERLOAD_NAME(ret_type, cname, name, fn, ...) \ - PYBIND11_OVERLOAD_INT(ret_type, cname, name, __VA_ARGS__) \ + PYBIND11_OVERLOAD_INT(PYBIND11_TYPE(ret_type), PYBIND11_TYPE(cname), name, __VA_ARGS__) \ return cname::fn(__VA_ARGS__) #define PYBIND11_OVERLOAD_PURE_NAME(ret_type, cname, name, fn, ...) \ - PYBIND11_OVERLOAD_INT(ret_type, cname, name, __VA_ARGS__) \ - pybind11::pybind11_fail("Tried to call pure virtual function \"" #cname "::" name "\""); + PYBIND11_OVERLOAD_INT(PYBIND11_TYPE(ret_type), PYBIND11_TYPE(cname), name, __VA_ARGS__) \ + pybind11::pybind11_fail("Tried to call pure virtual function \"" PYBIND11_STRINGIFY(cname) "::" name "\""); #define PYBIND11_OVERLOAD(ret_type, cname, fn, ...) \ - PYBIND11_OVERLOAD_NAME(ret_type, cname, #fn, fn, __VA_ARGS__) + PYBIND11_OVERLOAD_NAME(PYBIND11_TYPE(ret_type), PYBIND11_TYPE(cname), #fn, fn, __VA_ARGS__) #define PYBIND11_OVERLOAD_PURE(ret_type, cname, fn, ...) \ - PYBIND11_OVERLOAD_PURE_NAME(ret_type, cname, #fn, fn, __VA_ARGS__) + PYBIND11_OVERLOAD_PURE_NAME(PYBIND11_TYPE(ret_type), PYBIND11_TYPE(cname), #fn, fn, __VA_ARGS__) NAMESPACE_END(PYBIND11_NAMESPACE) http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/1a3136b7/thirdparty/pybind11/include/pybind11/pytypes.h ---------------------------------------------------------------------- diff --git a/thirdparty/pybind11/include/pybind11/pytypes.h b/thirdparty/pybind11/include/pybind11/pytypes.h index d7fa177..bcee8b5 100644 --- a/thirdparty/pybind11/include/pybind11/pytypes.h +++ b/thirdparty/pybind11/include/pybind11/pytypes.h @@ -295,6 +295,9 @@ public: PyErr_Fetch(&type.ptr(), &value.ptr(), &trace.ptr()); } + error_already_set(const error_already_set &) = default; + error_already_set(error_already_set &&) = default; + inline ~error_already_set(); /// Give the currently-held error back to Python, if any. If there is currently a Python error http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/1a3136b7/thirdparty/pybind11/include/pybind11/stl.h ---------------------------------------------------------------------- diff --git a/thirdparty/pybind11/include/pybind11/stl.h b/thirdparty/pybind11/include/pybind11/stl.h index db900e6..faa7087 100644 --- a/thirdparty/pybind11/include/pybind11/stl.h +++ b/thirdparty/pybind11/include/pybind11/stl.h @@ -30,7 +30,8 @@ # define PYBIND11_HAS_OPTIONAL 1 # endif // std::experimental::optional (but not allowed in c++11 mode) -# if defined(PYBIND11_CPP14) && __has_include(<experimental/optional>) +# if defined(PYBIND11_CPP14) && (__has_include(<experimental/optional>) && \ + !__has_include(<optional>)) # include <experimental/optional> # define PYBIND11_HAS_EXP_OPTIONAL 1 # endif @@ -82,6 +83,7 @@ template <typename Type, typename Key> struct set_caster { template <typename T> static handle cast(T &&src, return_value_policy policy, handle parent) { + policy = return_value_policy_override<Key>::policy(policy); pybind11::set s; for (auto &&value : src) { auto value_ = reinterpret_steal<object>(key_conv::cast(forward_like<T>(value), policy, parent)); @@ -91,7 +93,7 @@ template <typename Type, typename Key> struct set_caster { return s.release(); } - PYBIND11_TYPE_CASTER(type, _("Set[") + key_conv::name() + _("]")); + PYBIND11_TYPE_CASTER(type, _("Set[") + key_conv::name + _("]")); }; template <typename Type, typename Key, typename Value> struct map_caster { @@ -117,9 +119,11 @@ template <typename Type, typename Key, typename Value> struct map_caster { template <typename T> static handle cast(T &&src, return_value_policy policy, handle parent) { dict d; + return_value_policy policy_key = return_value_policy_override<Key>::policy(policy); + return_value_policy policy_value = return_value_policy_override<Value>::policy(policy); for (auto &&kv : src) { - auto key = reinterpret_steal<object>(key_conv::cast(forward_like<T>(kv.first), policy, parent)); - auto value = reinterpret_steal<object>(value_conv::cast(forward_like<T>(kv.second), policy, parent)); + auto key = reinterpret_steal<object>(key_conv::cast(forward_like<T>(kv.first), policy_key, parent)); + auto value = reinterpret_steal<object>(value_conv::cast(forward_like<T>(kv.second), policy_value, parent)); if (!key || !value) return handle(); d[key] = value; @@ -127,7 +131,7 @@ template <typename Type, typename Key, typename Value> struct map_caster { return d.release(); } - PYBIND11_TYPE_CASTER(Type, _("Dict[") + key_conv::name() + _(", ") + value_conv::name() + _("]")); + PYBIND11_TYPE_CASTER(Type, _("Dict[") + key_conv::name + _(", ") + value_conv::name + _("]")); }; template <typename Type, typename Value> struct list_caster { @@ -157,6 +161,7 @@ private: public: template <typename T> static handle cast(T &&src, return_value_policy policy, handle parent) { + policy = return_value_policy_override<Value>::policy(policy); list l(src.size()); size_t index = 0; for (auto &&value : src) { @@ -168,7 +173,7 @@ public: return l.release(); } - PYBIND11_TYPE_CASTER(Type, _("List[") + value_conv::name() + _("]")); + PYBIND11_TYPE_CASTER(Type, _("List[") + value_conv::name + _("]")); }; template <typename Type, typename Alloc> struct type_caster<std::vector<Type, Alloc>> @@ -222,7 +227,7 @@ public: return l.release(); } - PYBIND11_TYPE_CASTER(ArrayType, _("List[") + value_conv::name() + _<Resizable>(_(""), _("[") + _<Size>() + _("]")) + _("]")); + PYBIND11_TYPE_CASTER(ArrayType, _("List[") + value_conv::name + _<Resizable>(_(""), _("[") + _<Size>() + _("]")) + _("]")); }; template <typename Type, size_t Size> struct type_caster<std::array<Type, Size>> @@ -251,6 +256,7 @@ template<typename T> struct optional_caster { static handle cast(T_ &&src, return_value_policy policy, handle parent) { if (!src) return none().inc_ref(); + policy = return_value_policy_override<typename T::value_type>::policy(policy); return value_conv::cast(*std::forward<T_>(src), policy, parent); } @@ -268,7 +274,7 @@ template<typename T> struct optional_caster { return true; } - PYBIND11_TYPE_CASTER(T, _("Optional[") + value_conv::name() + _("]")); + PYBIND11_TYPE_CASTER(T, _("Optional[") + value_conv::name + _("]")); }; #if PYBIND11_HAS_OPTIONAL @@ -348,13 +354,14 @@ struct variant_caster<V<Ts...>> { } using Type = V<Ts...>; - PYBIND11_TYPE_CASTER(Type, _("Union[") + detail::concat(make_caster<Ts>::name()...) + _("]")); + PYBIND11_TYPE_CASTER(Type, _("Union[") + detail::concat(make_caster<Ts>::name...) + _("]")); }; #if PYBIND11_HAS_VARIANT template <typename... Ts> struct type_caster<std::variant<Ts...>> : variant_caster<std::variant<Ts...>> { }; #endif + NAMESPACE_END(detail) inline std::ostream &operator<<(std::ostream &os, const handle &obj) { http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/1a3136b7/thirdparty/pybind11/include/pybind11/stl_bind.h ---------------------------------------------------------------------- diff --git a/thirdparty/pybind11/include/pybind11/stl_bind.h b/thirdparty/pybind11/include/pybind11/stl_bind.h index 7ef6878..38dd68f 100644 --- a/thirdparty/pybind11/include/pybind11/stl_bind.h +++ b/thirdparty/pybind11/include/pybind11/stl_bind.h @@ -587,7 +587,7 @@ class_<Map, holder_type> bind_map(handle scope, const std::string &name, Args&&. auto it = m.find(k); if (it == m.end()) throw key_error(); - return m.erase(it); + m.erase(it); } );
