From 6f7b10fe9f3b467652bf525aec50d36469cec722 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sat, 23 Jan 2021 23:16:51 -0800 Subject: [PATCH] Removing debugging comments (GET_STACK, GET_INT_STACK). cast.h is identical to current master again, pybind11.h only has the generic_type::initialize(..., &type_caster_generic::local_load) change. --- include/pybind11/cast.h | 4 ++-- include/pybind11/pybind11.h | 18 ++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 3f6f1c6bd..395ab732e 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -2030,7 +2030,7 @@ public: template enable_if_t::value, Return> call(Func &&f) && { - return std::move(*this).template call_impl(std::forward(f), indices{}, Guard{}); // GET_INT_STACK -3 + return std::move(*this).template call_impl(std::forward(f), indices{}, Guard{}); } template @@ -2058,7 +2058,7 @@ private: template Return call_impl(Func &&f, index_sequence, Guard &&) && { - return std::forward(f)(cast_op(std::move(std::get(argcasters)))...); // GET_INT_STACK -2 + return std::forward(f)(cast_op(std::move(std::get(argcasters)))...); } std::tuple...> argcasters; diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index fd0bcbd73..d60157d89 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -56,8 +56,6 @@ # include #endif -#define TRIGGER_SEGSEV { unsigned long *bad = nullptr; *bad = -1; } - PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) /// Wraps an arbitrary C++ function/method/lambda function/.. into a callable Python object @@ -99,7 +97,7 @@ public: /// Construct a cpp_function from a class method (const, no ref-qualifier) template cpp_function(Return (Class::*f)(Arg...) const, const Extra&... extra) { - initialize([f](const Class *c, Arg... args) -> Return { return (c->*f)(std::forward(args)...); }, // GET_INT_STACK -1 + initialize([f](const Class *c, Arg... args) -> Return { return (c->*f)(std::forward(args)...); }, (Return (*)(const Class *, Arg ...)) nullptr, extra...); } @@ -169,7 +167,7 @@ protected: "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 = [](function_call &call) -> handle { // GET_INT_STACK -5 + rec->impl = [](function_call &call) -> handle { cast_in args_converter; /* Try to cast the function arguments into the C++ domain */ @@ -192,7 +190,7 @@ protected: /* Perform the function call */ handle result = cast_out::cast( - std::move(args_converter).template call(cap->f), policy, call.parent); // GET_INT_STACK -4 + std::move(args_converter).template call(cap->f), policy, call.parent); /* Invoke call policy post-call hook */ process_attributes::postcall(call, result); @@ -554,7 +552,7 @@ protected: handle parent = n_args_in > 0 ? PyTuple_GET_ITEM(args_in, 0) : nullptr, result = PYBIND11_TRY_NEXT_OVERLOAD; - auto self_value_and_holder = value_and_holder(); // cast.h + auto self_value_and_holder = value_and_holder(); if (overloads->is_constructor) { if (!PyObject_TypeCheck(parent.ptr(), (PyTypeObject *) overloads->scope.ptr())) { PyErr_SetString(PyExc_TypeError, "__init__(self, ...) called with invalid `self` argument"); @@ -766,7 +764,7 @@ protected: // 6. Call the function. try { loader_life_support guard{}; - result = func.impl(call); // GET_INT_STACK -6 + result = func.impl(call); } catch (reference_cast_error &) { result = PYBIND11_TRY_NEXT_OVERLOAD; } @@ -932,7 +930,7 @@ protected: } else { if (overloads->is_constructor && !self_value_and_holder.holder_constructed()) { auto *pi = reinterpret_cast(parent.ptr()); - self_value_and_holder.type->init_instance(pi, nullptr); // GET_STACK -4 + self_value_and_holder.type->init_instance(pi, nullptr); } return result.ptr(); } @@ -1540,7 +1538,7 @@ private: init_holder_from_existing(v_h, holder_ptr, std::is_copy_constructible()); v_h.set_holder_constructed(); } else if (inst->owned || detail::always_construct_holder::value) { - new (std::addressof(v_h.holder())) holder_type(v_h.value_ptr()); // GET_STACK -2 + new (std::addressof(v_h.holder())) holder_type(v_h.value_ptr()); v_h.set_holder_constructed(); } } @@ -1555,7 +1553,7 @@ private: register_instance(inst, v_h.value_ptr(), v_h.type); v_h.set_instance_registered(); } - init_holder(inst, v_h, (const holder_type *) holder_ptr, v_h.value_ptr()); // GET_STACK -3 + init_holder(inst, v_h, (const holder_type *) holder_ptr, v_h.value_ptr()); } /// Deallocates an instance; via holder, if constructed; otherwise via operator delete.