Skip to content

Commit 6cc137d

Browse files
committed
Fix tests to use non-deprecated PYBIND11_OVERRIDE_* macros
1 parent ab80ad1 commit 6cc137d

File tree

5 files changed

+36
-36
lines changed

5 files changed

+36
-36
lines changed

tests/test_class.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ TEST_SUBMODULE(class_, m) {
291291

292292
class TrampolineB : public ProtectedB {
293293
public:
294-
int foo() const override { PYBIND11_OVERLOAD(int, ProtectedB, foo, ); }
294+
int foo() const override { PYBIND11_OVERRIDE(int, ProtectedB, foo, ); }
295295
};
296296

297297
class PublicistB : public ProtectedB {

tests/test_embed/test_interpreter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Widget {
3030
class PyWidget final : public Widget {
3131
using Widget::Widget;
3232

33-
int the_answer() const override { PYBIND11_OVERLOAD_PURE(int, Widget, the_answer); }
33+
int the_answer() const override { PYBIND11_OVERRIDE_PURE(int, Widget, the_answer); }
3434
};
3535

3636
PYBIND11_EMBEDDED_MODULE(widget_module, m) {

tests/test_factory_constructors.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class PyTF6 : public TestFactory6 {
8888
PyTF6(const PyTF6 &f) : TestFactory6(f) { print_copy_created(this); }
8989
PyTF6(std::string s) : TestFactory6((int) s.size()) { alias = true; print_created(this, s); }
9090
virtual ~PyTF6() { print_destroyed(this); }
91-
int get() override { PYBIND11_OVERLOAD(int, TestFactory6, get, /*no args*/); }
91+
int get() override { PYBIND11_OVERRIDE(int, TestFactory6, get, /*no args*/); }
9292
};
9393

9494
class TestFactory7 {
@@ -109,7 +109,7 @@ class PyTF7 : public TestFactory7 {
109109
PyTF7(PyTF7 &&f) : TestFactory7(std::move(f)) { print_move_created(this); }
110110
PyTF7(const PyTF7 &f) : TestFactory7(f) { print_copy_created(this); }
111111
virtual ~PyTF7() { print_destroyed(this); }
112-
int get() override { PYBIND11_OVERLOAD(int, TestFactory7, get, /*no args*/); }
112+
int get() override { PYBIND11_OVERRIDE(int, TestFactory7, get, /*no args*/); }
113113
};
114114

115115

tests/test_gil_scoped.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ class VirtClass {
2222

2323
class PyVirtClass : public VirtClass {
2424
void virtual_func() override {
25-
PYBIND11_OVERLOAD(void, VirtClass, virtual_func,);
25+
PYBIND11_OVERRIDE(void, VirtClass, virtual_func,);
2626
}
2727
void pure_virtual_func() override {
28-
PYBIND11_OVERLOAD_PURE(void, VirtClass, pure_virtual_func,);
28+
PYBIND11_OVERRIDE_PURE(void, VirtClass, pure_virtual_func,);
2929
}
3030
};
3131

tests/test_virtual_functions.cpp

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class PyExampleVirt : public ExampleVirt {
4747

4848
int run(int value) override {
4949
/* Generate wrapping code that enables native function overloading */
50-
PYBIND11_OVERLOAD(
50+
PYBIND11_OVERRIDE(
5151
int, /* Return type */
5252
ExampleVirt, /* Parent class */
5353
run, /* Name of function */
@@ -56,7 +56,7 @@ class PyExampleVirt : public ExampleVirt {
5656
}
5757

5858
bool run_bool() override {
59-
PYBIND11_OVERLOAD_PURE(
59+
PYBIND11_OVERRIDE_PURE(
6060
bool, /* Return type */
6161
ExampleVirt, /* Parent class */
6262
run_bool, /* Name of function */
@@ -66,7 +66,7 @@ class PyExampleVirt : public ExampleVirt {
6666
}
6767

6868
void pure_virtual() override {
69-
PYBIND11_OVERLOAD_PURE(
69+
PYBIND11_OVERRIDE_PURE(
7070
void, /* Return type */
7171
ExampleVirt, /* Parent class */
7272
pure_virtual, /* Name of function */
@@ -78,7 +78,7 @@ class PyExampleVirt : public ExampleVirt {
7878
// We can return reference types for compatibility with C++ virtual interfaces that do so, but
7979
// note they have some significant limitations (see the documentation).
8080
const std::string &get_string1() override {
81-
PYBIND11_OVERLOAD(
81+
PYBIND11_OVERRIDE(
8282
const std::string &, /* Return type */
8383
ExampleVirt, /* Parent class */
8484
get_string1, /* Name of function */
@@ -87,7 +87,7 @@ class PyExampleVirt : public ExampleVirt {
8787
}
8888

8989
const std::string *get_string2() override {
90-
PYBIND11_OVERLOAD(
90+
PYBIND11_OVERRIDE(
9191
const std::string *, /* Return type */
9292
ExampleVirt, /* Parent class */
9393
get_string2, /* Name of function */
@@ -141,11 +141,11 @@ class NCVirt {
141141
class NCVirtTrampoline : public NCVirt {
142142
#if !defined(__INTEL_COMPILER)
143143
NonCopyable get_noncopyable(int a, int b) override {
144-
PYBIND11_OVERLOAD(NonCopyable, NCVirt, get_noncopyable, a, b);
144+
PYBIND11_OVERRIDE(NonCopyable, NCVirt, get_noncopyable, a, b);
145145
}
146146
#endif
147147
Movable get_movable(int a, int b) override {
148-
PYBIND11_OVERLOAD_PURE(Movable, NCVirt, get_movable, a, b);
148+
PYBIND11_OVERRIDE_PURE(Movable, NCVirt, get_movable, a, b);
149149
}
150150
};
151151

@@ -159,7 +159,7 @@ struct Base {
159159

160160
struct DispatchIssue : Base {
161161
virtual std::string dispatch() const {
162-
PYBIND11_OVERLOAD_PURE(std::string, Base, dispatch, /* no arguments */);
162+
PYBIND11_OVERRIDE_PURE(std::string, Base, dispatch, /* no arguments */);
163163
}
164164
};
165165

@@ -240,7 +240,7 @@ TEST_SUBMODULE(virtual_functions, m) {
240240
py::print("PyA.f()");
241241
// This convolution just gives a `void`, but tests that PYBIND11_TYPE() works to protect
242242
// a type containing a ,
243-
PYBIND11_OVERLOAD(PYBIND11_TYPE(typename std::enable_if<true, void>::type), A, f);
243+
PYBIND11_OVERRIDE(PYBIND11_TYPE(typename std::enable_if<true, void>::type), A, f);
244244
}
245245
};
246246

@@ -265,7 +265,7 @@ TEST_SUBMODULE(virtual_functions, m) {
265265
~PyA2() { py::print("PyA2.~PyA2()"); }
266266
void f() override {
267267
py::print("PyA2.f()");
268-
PYBIND11_OVERLOAD(void, A2, f);
268+
PYBIND11_OVERRIDE(void, A2, f);
269269
}
270270
};
271271

@@ -304,19 +304,19 @@ TEST_SUBMODULE(virtual_functions, m) {
304304
class PyOverrideTest : public OverrideTest {
305305
public:
306306
using OverrideTest::OverrideTest;
307-
std::string str_value() override { PYBIND11_OVERLOAD(std::string, OverrideTest, str_value); }
307+
std::string str_value() override { PYBIND11_OVERRIDE(std::string, OverrideTest, str_value); }
308308
// Not allowed (uncommenting should hit a static_assert failure): we can't get a reference
309309
// to a python numeric value, since we only copy values in the numeric type caster:
310-
// std::string &str_ref() override { PYBIND11_OVERLOAD(std::string &, OverrideTest, str_ref); }
310+
// std::string &str_ref() override { PYBIND11_OVERRIDE(std::string &, OverrideTest, str_ref); }
311311
// But we can work around it like this:
312312
private:
313313
std::string _tmp;
314-
std::string str_ref_helper() { PYBIND11_OVERLOAD(std::string, OverrideTest, str_ref); }
314+
std::string str_ref_helper() { PYBIND11_OVERRIDE(std::string, OverrideTest, str_ref); }
315315
public:
316316
std::string &str_ref() override { return _tmp = str_ref_helper(); }
317317

318-
A A_value() override { PYBIND11_OVERLOAD(A, OverrideTest, A_value); }
319-
A &A_ref() override { PYBIND11_OVERLOAD(A &, OverrideTest, A_ref); }
318+
A A_value() override { PYBIND11_OVERRIDE(A, OverrideTest, A_value); }
319+
A &A_ref() override { PYBIND11_OVERRIDE(A &, OverrideTest, A_ref); }
320320
};
321321

322322
py::class_<OverrideTest::A>(m, "OverrideTest_A")
@@ -393,29 +393,29 @@ class D_Tpl : public C_Tpl { D_METHODS };
393393
class PyA_Repeat : public A_Repeat {
394394
public:
395395
using A_Repeat::A_Repeat;
396-
int unlucky_number() override { PYBIND11_OVERLOAD_PURE(int, A_Repeat, unlucky_number, ); }
397-
std::string say_something(unsigned times) override { PYBIND11_OVERLOAD(std::string, A_Repeat, say_something, times); }
396+
int unlucky_number() override { PYBIND11_OVERRIDE_PURE(int, A_Repeat, unlucky_number, ); }
397+
std::string say_something(unsigned times) override { PYBIND11_OVERRIDE(std::string, A_Repeat, say_something, times); }
398398
};
399399
class PyB_Repeat : public B_Repeat {
400400
public:
401401
using B_Repeat::B_Repeat;
402-
int unlucky_number() override { PYBIND11_OVERLOAD(int, B_Repeat, unlucky_number, ); }
403-
std::string say_something(unsigned times) override { PYBIND11_OVERLOAD(std::string, B_Repeat, say_something, times); }
404-
double lucky_number() override { PYBIND11_OVERLOAD(double, B_Repeat, lucky_number, ); }
402+
int unlucky_number() override { PYBIND11_OVERRIDE(int, B_Repeat, unlucky_number, ); }
403+
std::string say_something(unsigned times) override { PYBIND11_OVERRIDE(std::string, B_Repeat, say_something, times); }
404+
double lucky_number() override { PYBIND11_OVERRIDE(double, B_Repeat, lucky_number, ); }
405405
};
406406
class PyC_Repeat : public C_Repeat {
407407
public:
408408
using C_Repeat::C_Repeat;
409-
int unlucky_number() override { PYBIND11_OVERLOAD(int, C_Repeat, unlucky_number, ); }
410-
std::string say_something(unsigned times) override { PYBIND11_OVERLOAD(std::string, C_Repeat, say_something, times); }
411-
double lucky_number() override { PYBIND11_OVERLOAD(double, C_Repeat, lucky_number, ); }
409+
int unlucky_number() override { PYBIND11_OVERRIDE(int, C_Repeat, unlucky_number, ); }
410+
std::string say_something(unsigned times) override { PYBIND11_OVERRIDE(std::string, C_Repeat, say_something, times); }
411+
double lucky_number() override { PYBIND11_OVERRIDE(double, C_Repeat, lucky_number, ); }
412412
};
413413
class PyD_Repeat : public D_Repeat {
414414
public:
415415
using D_Repeat::D_Repeat;
416-
int unlucky_number() override { PYBIND11_OVERLOAD(int, D_Repeat, unlucky_number, ); }
417-
std::string say_something(unsigned times) override { PYBIND11_OVERLOAD(std::string, D_Repeat, say_something, times); }
418-
double lucky_number() override { PYBIND11_OVERLOAD(double, D_Repeat, lucky_number, ); }
416+
int unlucky_number() override { PYBIND11_OVERRIDE(int, D_Repeat, unlucky_number, ); }
417+
std::string say_something(unsigned times) override { PYBIND11_OVERRIDE(std::string, D_Repeat, say_something, times); }
418+
double lucky_number() override { PYBIND11_OVERRIDE(double, D_Repeat, lucky_number, ); }
419419
};
420420

421421
// Inheritance approach 2: templated trampoline classes.
@@ -436,15 +436,15 @@ template <class Base = A_Tpl>
436436
class PyA_Tpl : public Base {
437437
public:
438438
using Base::Base; // Inherit constructors
439-
int unlucky_number() override { PYBIND11_OVERLOAD_PURE(int, Base, unlucky_number, ); }
440-
std::string say_something(unsigned times) override { PYBIND11_OVERLOAD(std::string, Base, say_something, times); }
439+
int unlucky_number() override { PYBIND11_OVERRIDE_PURE(int, Base, unlucky_number, ); }
440+
std::string say_something(unsigned times) override { PYBIND11_OVERRIDE(std::string, Base, say_something, times); }
441441
};
442442
template <class Base = B_Tpl>
443443
class PyB_Tpl : public PyA_Tpl<Base> {
444444
public:
445445
using PyA_Tpl<Base>::PyA_Tpl; // Inherit constructors (via PyA_Tpl's inherited constructors)
446-
int unlucky_number() override { PYBIND11_OVERLOAD(int, Base, unlucky_number, ); }
447-
double lucky_number() override { PYBIND11_OVERLOAD(double, Base, lucky_number, ); }
446+
int unlucky_number() override { PYBIND11_OVERRIDE(int, Base, unlucky_number, ); }
447+
double lucky_number() override { PYBIND11_OVERRIDE(double, Base, lucky_number, ); }
448448
};
449449
// Since C_Tpl and D_Tpl don't declare any new virtual methods, we don't actually need these (we can
450450
// use PyB_Tpl<C_Tpl> and PyB_Tpl<D_Tpl> for the trampoline classes instead):

0 commit comments

Comments
 (0)