Skip to content

Commit 6bb7bec

Browse files
All copy constructors are copy + __copy__
1 parent 0f15ae1 commit 6bb7bec

20 files changed

Lines changed: 229 additions & 167 deletions

src/aho-corasick.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,17 @@ Construct an :any:`AhoCorasick` containing only the root that corresponds to
7474
the empty word :math:`\varepsilon`.)pbdoc");
7575

7676
thing.def(
77-
"__copy__",
78-
[](const AhoCorasick& that) { return AhoCorasick(that); },
77+
"copy",
78+
[](AhoCorasick const& self) { return AhoCorasick(self); },
7979
R"pbdoc(
80-
Default copy constructor.
80+
:sig=(self: AhoCorasick) -> AhoCorasick:
8181
82-
Default copy constructor)pbdoc");
82+
Copy a :any:`AhoCorasick` object.
83+
84+
:returns: A copy.
85+
:rtype: AhoCorasick)pbdoc");
86+
thing.def("__copy__",
87+
[](AhoCorasick const& self) { return AhoCorasick(self); });
8388

8489
thing.def("child",
8590
&AhoCorasick::child,

src/bmat8.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,6 @@ lists in ``rows``.
203203
R"pbdoc(
204204
Copy a BMat8.
205205
206-
:param other: the BMat8 to copy.
207-
:type other: BMat8
208-
209206
:returns: A copy of the argument.
210207
:rtype: BMat8
211208
)pbdoc");

src/dot.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ Default constructor that constructs an empty :any:`Dot` object with no nodes,
6464
edges, attributes, or subgraphs.
6565
)pbdoc");
6666
dot.def("__copy__", [](Dot const& d) { return Dot(d); });
67+
dot.def(
68+
"copy",
69+
[](Dot const& d) { return Dot(d); },
70+
R"pbdoc(
71+
:sig=(self: Dot) -> Dot:
72+
73+
Copy a :any:`Dot` object.
74+
75+
:returns: A copy.
76+
:rtype: Dot
77+
)pbdoc");
6778

6879
dot.def("add_node",
6980
&Dot::add_node<std::string const&>,

src/froidure-pin.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,8 @@ instance and ``False`` if it does not.
369369
370370
Copy and add a list of generators.
371371
372-
This function is equivalent to copy constructing a new :any:`FroidurePin`
373-
instance and then calling :any:`FroidurePin.add_generators` on the copy.
372+
This function is equivalent to copying a :any:`FroidurePin`
373+
instance and then calling :any:`FroidurePin.add_generators` on the copy.
374374
But this function avoids copying the parts of the initial instance that are
375375
immediately invalidated by :any:`FroidurePin.add_generators`.
376376
@@ -403,7 +403,7 @@ immediately invalidated by :any:`FroidurePin.add_generators`.
403403
404404
Copy and add non-redundant generators.
405405
406-
This function is equivalent to copy constructing a new :any:`FroidurePin`
406+
This function is equivalent to copying a :any:`FroidurePin`
407407
instance and then calling :any:`closure` on the copy. But this function
408408
avoids copying the parts of the initial :any:`FroidurePin` instance that are
409409
immediately discarded by :any:`closure`.

src/gabow.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ at most :math:`O(mn)` where ``m`` is :any:`WordGraph.number_of_nodes()` and
6868
thing.def("__repr__",
6969
[](Gabow_ const& g) { return to_human_readable_repr(g); });
7070
thing.def("__copy__", [](Gabow_ const& g) { return Gabow_(g); });
71+
thing.def(
72+
"copy",
73+
[](Gabow_ const& self) { return Gabow_(self); },
74+
R"pbdoc(
75+
:sig=(self: Gabow) -> Gabow:
76+
77+
Copy a :any:`Gabow` object.
78+
79+
:returns: A copy.
80+
:rtype: Gabow
81+
)pbdoc");
7182
thing.def(py::init<WordGraph<node_type> const&>(),
7283
py::arg("wg"),
7384
R"pbdoc(

src/knuth-bendix.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,20 @@ redundant in this way, then ``None`` is returned.
359359
return to_human_readable_repr(nfr);
360360
});
361361

362-
thing.def("__copy__", [](NormalFormRange const& nfr) {
363-
return NormalFormRange(nfr);
362+
thing.def("__copy__", [](NormalFormRange const& self) {
363+
return NormalFormRange(self);
364364
});
365+
thing.def(
366+
"copy",
367+
[](NormalFormRange const& self) { return NormalFormRange(self); },
368+
R"pbdoc(
369+
:sig=(self: NormalFormRange) -> NormalFormRange:
370+
371+
Copy a :any:`NormalFormRange` object.
372+
373+
:returns: A copy.
374+
:rtype: NormalFormRange
375+
)pbdoc");
365376
// __len__ is not allowed to return anything other than an int, hence
366377
// __len__ and count don't have the same behaviour.
367378
thing.def("__len__", [](NormalFormRange const& nfr) {

src/konieczny.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ the size, partial order of :math:`\mathscr{D}`-classes, and frames for each
6868
:sig=(self: Konieczny) -> Konieczny:
6969
Copy a Konieczny.
7070
71-
:param other: the Konieczny to copy.
72-
:type other: Konieczny
73-
7471
:returns: A copy of the argument.
7572
:rtype: Konieczny
7673
)pbdoc");

src/paths.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ paths in a :any:`WordGraph` from a given :any:`source` (to a possible
6666
thing1.def("__repr__",
6767
[](Paths_ const& p) { return to_human_readable_repr(p); });
6868
thing1.def("__copy__", [](Paths_ const& p) { return Paths_(p); });
69+
thing1.def(
70+
"copy",
71+
[](Paths_ const& self) { return Paths_(self); },
72+
R"pbdoc(
73+
:sig=(self: Paths) -> Paths:
74+
75+
Copy a :any:`Paths` object.
76+
77+
:returns: A copy.
78+
:rtype: Paths
79+
)pbdoc");
6980
thing1.def("__or__", [](Paths_ const& p, ToString const& to_str) {
7081
using rx::operator|;
7182
return p | to_str;

src/present.cpp

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,18 @@ Default constructor.
9191
9292
Constructs an empty presentation with no rules and no alphabet.)pbdoc");
9393
thing.def(
94-
"__copy__",
95-
[](const Presentation_& that) { return Presentation_(that); },
94+
"copy",
95+
[](Presentation_ const& self) { return Presentation_(self); },
9696
R"pbdoc(
97-
Default copy constructor.
97+
:sig=(self: Presentation) -> Presentation:
98+
99+
Copy a :any:`Presentation` object.
98100
99-
Default copy constructor)pbdoc");
101+
:returns: A copy.
102+
:rtype: Presentation
103+
)pbdoc");
104+
thing.def("__copy__",
105+
[](Presentation_ const& that) { return Presentation_(that); });
100106
thing.def(
101107
"alphabet",
102108
[](Presentation_ const& self) { return self.alphabet(); },
@@ -1289,14 +1295,22 @@ Default constructor.
12891295
Constructs an empty :any:`InversePresentation` with no rules, no alphabet and
12901296
no inverses.)pbdoc");
12911297
thing.def(
1292-
"__copy__",
1293-
[](const InversePresentation_& that) {
1294-
return InversePresentation_(that);
1298+
"copy",
1299+
[](InversePresentation_ const& self) {
1300+
return InversePresentation_(self);
12951301
},
12961302
R"pbdoc(
1297-
Default copy constructor.
1303+
:sig=(self: InversePresentation) -> InversePresentation:
1304+
1305+
Copy a :any:`InversePresentation` object.
1306+
1307+
:returns: A copy.
1308+
:rtype: InversePresentation
1309+
)pbdoc");
1310+
thing.def("__copy__", [](InversePresentation_ const& that) {
1311+
return InversePresentation_(that);
1312+
});
12981313

1299-
Default copy constructor)pbdoc");
13001314
thing.def("inverse",
13011315
&InversePresentation_::inverse,
13021316
py::arg("x"),

src/runner.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,18 @@ Default construct a :any:`Reporter` object such that the following hold:
7373
- :any:`last_report()` is now;
7474
- :any:`start_time()` is now.
7575
)pbdoc");
76-
thing.def(py::init<Reporter const&>(), R"pbdoc(
77-
Default copy constructor.
76+
thing.def(
77+
"copy",
78+
[](Reporter const& self) { return Reporter(self); },
79+
R"pbdoc(
80+
:sig=(self: Reporter) -> Reporter:
81+
82+
Copy a :any:`Reporter` object.
83+
84+
:returns: A copy.
85+
:rtype: Reporter
7886
)pbdoc");
87+
thing.def("__copy__", [](Reporter const& self) { return Reporter(self); });
7988
thing.def(
8089
"init",
8190
[](Reporter& r) -> Reporter& { return r.init(); },

0 commit comments

Comments
 (0)