Skip to content

Commit

Permalink
Adding a __iter__ method to skia.Iter
Browse files Browse the repository at this point in the history
See
python/cpython#128161
"Defining iterator in a separate class no longer works in 3.13"

We have iterator for SkTextBlob defined by SkTextBlob::Iter(textblob),
which is the c++/pybind11 equivalent of the same situation.
Following the suggestion:
python/cpython#128161 (comment)

Also see actions/runner-images#11241

Fixes kyamagu#295
  • Loading branch information
HinTak committed Dec 29, 2024
1 parent db7d7fc commit b87ed1e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/skia/TextBlob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ py::class_<SkTextBlob::Iter::Run>(iter, "Run")

iter
.def(py::init<const SkTextBlob&>())
.def("__iter__",
[] (SkTextBlob::Iter& it) {
return it;
})
.def("__next__",
[] (SkTextBlob::Iter& it) {
SkTextBlob::Iter::Run run;
Expand Down

0 comments on commit b87ed1e

Please sign in to comment.