Skip to content

Commit cbbf839

Browse files
committed
Removing PYBIND11_NOINLINE_FWD macro (after learning that it makes no sense).
1 parent 291d166 commit cbbf839

File tree

10 files changed

+51
-52
lines changed

10 files changed

+51
-52
lines changed

docs/Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ WARNINGS = YES
2020
WARN_IF_UNDOCUMENTED = NO
2121
PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS \
2222
PY_MAJOR_VERSION=3 \
23-
PYBIND11_NOINLINE_DCL
23+
PYBIND11_NOINLINE

include/pybind11/attr.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ enum op_id : int;
129129
enum op_type : int;
130130
struct undefined_t;
131131
template <op_id id, op_type ot, typename L = undefined_t, typename R = undefined_t> struct op_;
132-
PYBIND11_NOINLINE_FWD void keep_alive_impl(size_t Nurse, size_t Patient, function_call &call, handle ret);
132+
void keep_alive_impl(size_t Nurse, size_t Patient, function_call &call, handle ret);
133133

134134
/// Internal data structure which holds metadata about a keyword argument
135135
struct argument_record {
@@ -225,7 +225,7 @@ struct function_record {
225225

226226
/// Special data structure which (temporarily) holds metadata about a bound class
227227
struct type_record {
228-
PYBIND11_NOINLINE_DCL type_record()
228+
PYBIND11_NOINLINE type_record()
229229
: multiple_inheritance(false), dynamic_attr(false), buffer_protocol(false),
230230
default_holder(true), module_local(false), is_final(false) { }
231231

@@ -283,7 +283,7 @@ struct type_record {
283283
/// Is the class inheritable from python classes?
284284
bool is_final : 1;
285285

286-
PYBIND11_NOINLINE_DCL void add_base(const std::type_info &base, void *(*caster)(void *)) {
286+
PYBIND11_NOINLINE void add_base(const std::type_info &base, void *(*caster)(void *)) {
287287
auto base_info = detail::get_type_info(base, false);
288288
if (!base_info) {
289289
std::string tname(base.name());

include/pybind11/detail/common.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,14 @@
109109
# define PYBIND11_NOINLINE_DISABLED
110110
#endif
111111

112+
// Note: Forward declaration should never be `inline`:
113+
// https://stackoverflow.com/questions/9317473/forward-declaration-of-inline-functions
112114
#if defined(PYBIND11_NOINLINE_DISABLED)
113-
# define PYBIND11_NOINLINE_DCL inline
114-
# define PYBIND11_NOINLINE_FWD inline
115+
# define PYBIND11_NOINLINE inline
115116
#elif defined(_MSC_VER)
116-
# define PYBIND11_NOINLINE_DCL __declspec(noinline) inline
117-
# define PYBIND11_NOINLINE_FWD
117+
# define PYBIND11_NOINLINE __declspec(noinline) inline
118118
#else
119-
# define PYBIND11_NOINLINE_DCL __attribute__ ((noinline)) inline
120-
# define PYBIND11_NOINLINE_FWD
119+
# define PYBIND11_NOINLINE __attribute__ ((noinline)) inline
121120
#endif
122121

123122
// DECISION TO BE MADE before this PR is merged:
@@ -813,8 +812,8 @@ PYBIND11_RUNTIME_EXCEPTION(import_error, PyExc_ImportError)
813812
PYBIND11_RUNTIME_EXCEPTION(cast_error, PyExc_RuntimeError) /// Thrown when pybind11::cast or handle::call fail due to a type casting error
814813
PYBIND11_RUNTIME_EXCEPTION(reference_cast_error, PyExc_RuntimeError) /// Used internally
815814

816-
[[noreturn]] PYBIND11_NOINLINE_DCL void pybind11_fail(const char *reason) { throw std::runtime_error(reason); }
817-
[[noreturn]] PYBIND11_NOINLINE_DCL void pybind11_fail(const std::string &reason) { throw std::runtime_error(reason); }
815+
[[noreturn]] PYBIND11_NOINLINE void pybind11_fail(const char *reason) { throw std::runtime_error(reason); }
816+
[[noreturn]] PYBIND11_NOINLINE void pybind11_fail(const std::string &reason) { throw std::runtime_error(reason); }
818817

819818
template <typename T, typename SFINAE = void> struct format_descriptor { };
820819

include/pybind11/detail/internals.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ inline void translate_local_exception(std::exception_ptr p) {
262262
#endif
263263

264264
/// Return a reference to the current `internals` data
265-
PYBIND11_NOINLINE_DCL internals &get_internals() {
265+
PYBIND11_NOINLINE internals &get_internals() {
266266
auto **&internals_pp = get_internals_pp();
267267
if (internals_pp && *internals_pp)
268268
return **internals_pp;
@@ -357,14 +357,14 @@ PYBIND11_NAMESPACE_END(detail)
357357
/// Returns a named pointer that is shared among all extension modules (using the same
358358
/// pybind11 version) running in the current interpreter. Names starting with underscores
359359
/// are reserved for internal usage. Returns `nullptr` if no matching entry was found.
360-
PYBIND11_NOINLINE_DCL void *get_shared_data(const std::string &name) {
360+
PYBIND11_NOINLINE void *get_shared_data(const std::string &name) {
361361
auto &internals = detail::get_internals();
362362
auto it = internals.shared_data.find(name);
363363
return it != internals.shared_data.end() ? it->second : nullptr;
364364
}
365365

366366
/// Set the shared data that can be later recovered by `get_shared_data()`.
367-
PYBIND11_NOINLINE_DCL void *set_shared_data(const std::string &name, void *data) {
367+
PYBIND11_NOINLINE void *set_shared_data(const std::string &name, void *data) {
368368
detail::get_internals().shared_data[name] = data;
369369
return data;
370370
}

include/pybind11/detail/type_caster_base.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class loader_life_support {
5959

6060
/// This can only be used inside a pybind11-bound function, either by `argument_loader`
6161
/// at argument preparation time or by `py::cast()` at execution time.
62-
PYBIND11_NOINLINE_DCL static void add_patient(handle h) {
62+
PYBIND11_NOINLINE static void add_patient(handle h) {
6363
auto &stack = get_internals().loader_patient_stack;
6464
if (stack.empty())
6565
throw cast_error("When called outside a bound function, py::cast() cannot "
@@ -86,7 +86,7 @@ class loader_life_support {
8686
inline std::pair<decltype(internals::registered_types_py)::iterator, bool> all_type_info_get_cache(PyTypeObject *type);
8787

8888
// Populates a just-created cache entry.
89-
PYBIND11_NOINLINE_DCL void all_type_info_populate(PyTypeObject *t, std::vector<type_info *> &bases) {
89+
PYBIND11_NOINLINE void all_type_info_populate(PyTypeObject *t, std::vector<type_info *> &bases) {
9090
std::vector<PyTypeObject *> check;
9191
for (handle parent : reinterpret_borrow<tuple>(t->tp_bases))
9292
check.push_back((PyTypeObject *) parent.ptr());
@@ -155,7 +155,7 @@ inline const std::vector<detail::type_info *> &all_type_info(PyTypeObject *type)
155155
* ancestors are pybind11-registered. Throws an exception if there are multiple bases--use
156156
* `all_type_info` instead if you want to support multiple bases.
157157
*/
158-
PYBIND11_NOINLINE_DCL detail::type_info* get_type_info(PyTypeObject *type) {
158+
PYBIND11_NOINLINE detail::type_info* get_type_info(PyTypeObject *type) {
159159
auto &bases = all_type_info(type);
160160
if (bases.empty())
161161
return nullptr;
@@ -181,7 +181,7 @@ inline detail::type_info *get_global_type_info(const std::type_index &tp) {
181181
}
182182

183183
/// Return the type info for a given C++ type; on lookup failure can either throw or return nullptr.
184-
PYBIND11_NOINLINE_DCL detail::type_info *get_type_info(const std::type_index &tp,
184+
PYBIND11_NOINLINE detail::type_info *get_type_info(const std::type_index &tp,
185185
bool throw_if_missing = false) {
186186
if (auto ltype = get_local_type_info(tp))
187187
return ltype;
@@ -196,13 +196,13 @@ PYBIND11_NOINLINE_DCL detail::type_info *get_type_info(const std::type_index &tp
196196
return nullptr;
197197
}
198198

199-
PYBIND11_NOINLINE_DCL handle get_type_handle(const std::type_info &tp, bool throw_if_missing) {
199+
PYBIND11_NOINLINE handle get_type_handle(const std::type_info &tp, bool throw_if_missing) {
200200
detail::type_info *type_info = get_type_info(tp, throw_if_missing);
201201
return handle(type_info ? ((PyObject *) type_info->type) : nullptr);
202202
}
203203

204204
// Searches the inheritance graph for a registered Python instance, using all_type_info().
205-
PYBIND11_NOINLINE_DCL handle find_registered_python_instance(void *src,
205+
PYBIND11_NOINLINE handle find_registered_python_instance(void *src,
206206
const detail::type_info *tinfo) {
207207
auto it_instances = get_internals().registered_instances.equal_range(src);
208208
for (auto it_i = it_instances.first; it_i != it_instances.second; ++it_i) {
@@ -330,7 +330,7 @@ struct values_and_holders {
330330
* The returned object should be short-lived: in particular, it must not outlive the called-upon
331331
* instance.
332332
*/
333-
PYBIND11_NOINLINE_DCL 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*/) {
333+
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*/) {
334334
// Optimize common case:
335335
if (!find_type || Py_TYPE(this) == find_type->type)
336336
return value_and_holder(this, find_type, 0, 0);
@@ -354,7 +354,7 @@ PYBIND11_NOINLINE_DCL value_and_holder instance::get_value_and_holder(const type
354354
#endif
355355
}
356356

357-
PYBIND11_NOINLINE_DCL void instance::allocate_layout() {
357+
PYBIND11_NOINLINE void instance::allocate_layout() {
358358
auto &tinfo = all_type_info(Py_TYPE(this));
359359

360360
const size_t n_types = tinfo.size();
@@ -402,19 +402,19 @@ PYBIND11_NOINLINE_DCL void instance::allocate_layout() {
402402
owned = true;
403403
}
404404

405-
PYBIND11_NOINLINE_DCL void instance::deallocate_layout() const {
405+
PYBIND11_NOINLINE void instance::deallocate_layout() const {
406406
if (!simple_layout)
407407
PyMem_Free(nonsimple.values_and_holders);
408408
}
409409

410-
PYBIND11_NOINLINE_DCL bool isinstance_generic(handle obj, const std::type_info &tp) {
410+
PYBIND11_NOINLINE bool isinstance_generic(handle obj, const std::type_info &tp) {
411411
handle type = detail::get_type_handle(tp, false);
412412
if (!type)
413413
return false;
414414
return isinstance(obj, type);
415415
}
416416

417-
PYBIND11_NOINLINE_DCL std::string error_string() {
417+
PYBIND11_NOINLINE std::string error_string() {
418418
if (!PyErr_Occurred()) {
419419
PyErr_SetString(PyExc_RuntimeError, "Unknown internal error occurred");
420420
return "Unknown internal error occurred";
@@ -461,7 +461,7 @@ PYBIND11_NOINLINE_DCL std::string error_string() {
461461
return errorString;
462462
}
463463

464-
PYBIND11_NOINLINE_DCL handle get_object_handle(const void *ptr, const detail::type_info *type ) {
464+
PYBIND11_NOINLINE handle get_object_handle(const void *ptr, const detail::type_info *type ) {
465465
auto &instances = get_internals().registered_instances;
466466
auto range = instances.equal_range(ptr);
467467
for (auto it = range.first; it != range.second; ++it) {
@@ -488,12 +488,12 @@ inline PyThreadState *get_thread_state_unchecked() {
488488
}
489489

490490
// Forward declarations
491-
PYBIND11_NOINLINE_FWD void keep_alive_impl(handle nurse, handle patient);
491+
void keep_alive_impl(handle nurse, handle patient);
492492
inline PyObject *make_new_instance(PyTypeObject *type);
493493

494494
class type_caster_generic {
495495
public:
496-
PYBIND11_NOINLINE_DCL type_caster_generic(const std::type_info &type_info)
496+
PYBIND11_NOINLINE type_caster_generic(const std::type_info &type_info)
497497
: typeinfo(get_type_info(type_info)), cpptype(&type_info) { }
498498

499499
type_caster_generic(const type_info *typeinfo)
@@ -503,7 +503,7 @@ class type_caster_generic {
503503
return load_impl<type_caster_generic>(src, convert);
504504
}
505505

506-
PYBIND11_NOINLINE_DCL static handle cast(const void *_src, return_value_policy policy, handle parent,
506+
PYBIND11_NOINLINE static handle cast(const void *_src, return_value_policy policy, handle parent,
507507
const detail::type_info *tinfo,
508508
void *(*copy_constructor)(const void *),
509509
void *(*move_constructor)(const void *),
@@ -627,7 +627,7 @@ class type_caster_generic {
627627
}
628628
void check_holder_compat() {}
629629

630-
PYBIND11_NOINLINE_DCL static void *local_load(PyObject *src, const type_info *ti) {
630+
PYBIND11_NOINLINE static void *local_load(PyObject *src, const type_info *ti) {
631631
auto caster = type_caster_generic(ti);
632632
if (caster.load(src, false))
633633
return caster.value;
@@ -636,7 +636,7 @@ class type_caster_generic {
636636

637637
/// Try to load with foreign typeinfo, if available. Used when there is no
638638
/// native typeinfo, or when the native one wasn't able to produce a value.
639-
PYBIND11_NOINLINE_DCL bool try_load_foreign_module_local(handle src) {
639+
PYBIND11_NOINLINE bool try_load_foreign_module_local(handle src) {
640640
constexpr auto *local_key = PYBIND11_MODULE_LOCAL_ID;
641641
const auto pytype = type::handle_of(src);
642642
if (!hasattr(pytype, local_key))
@@ -659,7 +659,7 @@ class type_caster_generic {
659659
// bits of code between here and copyable_holder_caster where the two classes need different
660660
// logic (without having to resort to virtual inheritance).
661661
template <typename ThisT>
662-
PYBIND11_NOINLINE_DCL bool load_impl(handle src, bool convert) {
662+
PYBIND11_NOINLINE bool load_impl(handle src, bool convert) {
663663
if (!src) return false;
664664
if (!typeinfo) return try_load_foreign_module_local(src);
665665

@@ -749,7 +749,7 @@ class type_caster_generic {
749749
// Called to do type lookup and wrap the pointer and type in a pair when a dynamic_cast
750750
// isn't needed or can't be used. If the type is unknown, sets the error and returns a pair
751751
// with .second = nullptr. (p.first = nullptr is not an error: it becomes None).
752-
PYBIND11_NOINLINE_DCL static std::pair<const void *, const type_info *> src_and_type(
752+
PYBIND11_NOINLINE static std::pair<const void *, const type_info *> src_and_type(
753753
const void *src, const std::type_info &cast_type, const std::type_info *rtti_type = nullptr) {
754754
if (auto *tpi = get_type_info(cast_type))
755755
return {src, const_cast<const type_info *>(tpi)};

include/pybind11/detail/typeid.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ inline void erase_all(std::string &string, const std::string &search) {
3434
}
3535
}
3636

37-
PYBIND11_NOINLINE_DCL void clean_type_id(std::string &name) {
37+
PYBIND11_NOINLINE void clean_type_id(std::string &name) {
3838
#if defined(__GNUG__)
3939
int status = 0;
4040
std::unique_ptr<char, void (*)(void *)> res {

include/pybind11/gil.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ PYBIND11_NAMESPACE_END(detail)
5353

5454
class gil_scoped_acquire {
5555
public:
56-
PYBIND11_NOINLINE_DCL gil_scoped_acquire() {
56+
PYBIND11_NOINLINE gil_scoped_acquire() {
5757
auto const &internals = detail::get_internals();
5858
tstate = (PyThreadState *) PYBIND11_TLS_GET_VALUE(internals.tstate);
5959

@@ -89,7 +89,7 @@ class gil_scoped_acquire {
8989
++tstate->gilstate_counter;
9090
}
9191

92-
PYBIND11_NOINLINE_DCL void dec_ref() {
92+
PYBIND11_NOINLINE void dec_ref() {
9393
--tstate->gilstate_counter;
9494
#if !defined(NDEBUG)
9595
if (detail::get_thread_state_unchecked() != tstate)
@@ -115,11 +115,11 @@ class gil_scoped_acquire {
115115
/// could be shutting down when this is called, as thread deletion is not
116116
/// allowed during shutdown. Check _Py_IsFinalizing() on Python 3.7+, and
117117
/// protect subsequent code.
118-
PYBIND11_NOINLINE_DCL void disarm() {
118+
PYBIND11_NOINLINE void disarm() {
119119
active = false;
120120
}
121121

122-
PYBIND11_NOINLINE_DCL ~gil_scoped_acquire() {
122+
PYBIND11_NOINLINE ~gil_scoped_acquire() {
123123
dec_ref();
124124
if (release)
125125
PyEval_SaveThread();
@@ -149,7 +149,7 @@ class gil_scoped_release {
149149
/// could be shutting down when this is called, as thread deletion is not
150150
/// allowed during shutdown. Check _Py_IsFinalizing() on Python 3.7+, and
151151
/// protect subsequent code.
152-
PYBIND11_NOINLINE_DCL void disarm() {
152+
PYBIND11_NOINLINE void disarm() {
153153
active = false;
154154
}
155155

include/pybind11/numpy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ struct numpy_internals {
109109
}
110110
};
111111

112-
PYBIND11_NOINLINE_DCL void load_numpy_internals(numpy_internals* &ptr) {
112+
PYBIND11_NOINLINE void load_numpy_internals(numpy_internals* &ptr) {
113113
ptr = &get_or_create_shared_data<numpy_internals>("_numpy_internals");
114114
}
115115

@@ -1115,7 +1115,7 @@ struct field_descriptor {
11151115
dtype descr;
11161116
};
11171117

1118-
PYBIND11_NOINLINE_DCL void register_structured_dtype(
1118+
PYBIND11_NOINLINE void register_structured_dtype(
11191119
any_container<field_descriptor> fields,
11201120
const std::type_info& tinfo, ssize_t itemsize,
11211121
bool (*direct_converter)(PyObject *, void *&)) {

include/pybind11/pybind11.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class cpp_function : public function {
151151
using unique_function_record = std::unique_ptr<detail::function_record, InitializingFunctionRecordDeleter>;
152152

153153
/// Space optimization: don't inline this frequently instantiated fragment
154-
PYBIND11_NOINLINE_DCL unique_function_record make_function_record() {
154+
PYBIND11_NOINLINE unique_function_record make_function_record() {
155155
return unique_function_record(new detail::function_record());
156156
}
157157

@@ -1061,7 +1061,7 @@ class module_ : public object {
10611061
``overwrite`` should almost always be false: attempting to overwrite objects that pybind11 has
10621062
established will, in most cases, break things.
10631063
\endrst */
1064-
PYBIND11_NOINLINE_DCL void add_object(const char *name, handle obj, bool overwrite = false) {
1064+
PYBIND11_NOINLINE void add_object(const char *name, handle obj, bool overwrite = false) {
10651065
if (!overwrite && hasattr(*this, name))
10661066
pybind11_fail("Error during initialization: multiple incompatible definitions with name \"" +
10671067
std::string(name) + "\"");
@@ -1676,7 +1676,7 @@ inline str enum_name(handle arg) {
16761676
struct enum_base {
16771677
enum_base(handle base, handle parent) : m_base(base), m_parent(parent) { }
16781678

1679-
PYBIND11_NOINLINE_DCL void init(bool is_arithmetic, bool is_convertible) {
1679+
PYBIND11_NOINLINE void init(bool is_arithmetic, bool is_convertible) {
16801680
m_base.attr("__entries") = dict();
16811681
auto property = handle((PyObject *) &PyProperty_Type);
16821682
auto static_property = handle((PyObject *) get_internals().static_property_type);
@@ -1802,7 +1802,7 @@ struct enum_base {
18021802
[](const object &arg) { return int_(arg); }, name("__hash__"), is_method(m_base));
18031803
}
18041804

1805-
PYBIND11_NOINLINE_DCL void value(char const* name_, object value, const char *doc = nullptr) {
1805+
PYBIND11_NOINLINE void value(char const* name_, object value, const char *doc = nullptr) {
18061806
dict entries = m_base.attr("__entries");
18071807
str name(name_);
18081808
if (entries.contains(name)) {
@@ -1814,7 +1814,7 @@ struct enum_base {
18141814
m_base.attr(name) = value;
18151815
}
18161816

1817-
PYBIND11_NOINLINE_DCL void export_values() {
1817+
PYBIND11_NOINLINE void export_values() {
18181818
dict entries = m_base.attr("__entries");
18191819
for (auto kv : entries)
18201820
m_parent.attr(kv.first) = kv.second[int_(0)];
@@ -1879,7 +1879,7 @@ template <typename Type> class enum_ : public class_<Type> {
18791879

18801880
PYBIND11_NAMESPACE_BEGIN(detail)
18811881

1882-
PYBIND11_NOINLINE_DCL void keep_alive_impl(handle nurse, handle patient) {
1882+
PYBIND11_NOINLINE void keep_alive_impl(handle nurse, handle patient) {
18831883
if (!nurse || !patient)
18841884
pybind11_fail("Could not activate keep_alive!");
18851885

@@ -1906,7 +1906,7 @@ PYBIND11_NOINLINE_DCL void keep_alive_impl(handle nurse, handle patient) {
19061906
}
19071907
}
19081908

1909-
PYBIND11_NOINLINE_DCL void keep_alive_impl(size_t Nurse, size_t Patient, function_call &call, handle ret) {
1909+
PYBIND11_NOINLINE void keep_alive_impl(size_t Nurse, size_t Patient, function_call &call, handle ret) {
19101910
auto get_arg = [&](size_t n) {
19111911
if (n == 0)
19121912
return ret;
@@ -2156,7 +2156,7 @@ exception<CppException> &register_local_exception(handle scope,
21562156
}
21572157

21582158
PYBIND11_NAMESPACE_BEGIN(detail)
2159-
PYBIND11_NOINLINE_DCL void print(const tuple &args, const dict &kwargs) {
2159+
PYBIND11_NOINLINE void print(const tuple &args, const dict &kwargs) {
21602160
auto strings = tuple(args.size());
21612161
for (size_t i = 0; i < args.size(); ++i) {
21622162
strings[i] = str(args[i]);

0 commit comments

Comments
 (0)