Skip to content

Commit 48adfcf

Browse files
committed
Fix up iterators, add introspection API.
1 parent b50beb7 commit 48adfcf

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

ext/BitmapPlusPlus-rb.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,17 +332,18 @@ void initialize()
332332
.define_iterator<std::vector<bmp::Pixel>::iterator(bmp::Bitmap::*)() noexcept>(
333333
&bmp::Bitmap::begin, &bmp::Bitmap::end, "each")
334334

335-
// Iterator accessors (less commonly used from Ruby)
336-
.define_method("cbegin", &bmp::Bitmap::cbegin)
337-
.define_method("cend", &bmp::Bitmap::cend)
335+
// Const iterator
336+
.define_iterator<std::vector<bmp::Pixel>::const_iterator(bmp::Bitmap::*)() const noexcept>(
337+
&bmp::Bitmap::cbegin, &bmp::Bitmap::cend, "each_const")
338338

339339
// Reverse iterator: bitmap.each_reverse { |pixel| ... }
340340
.define_iterator<std::vector<bmp::Pixel>::reverse_iterator(bmp::Bitmap::*)() noexcept>(
341341
&bmp::Bitmap::rbegin, &bmp::Bitmap::rend, "each_reverse")
342342

343-
.define_method("crbegin", &bmp::Bitmap::crbegin)
344-
.define_method("crend", &bmp::Bitmap::crend)
345-
343+
// Reverse const iterator: bitmap.each_reverse { |pixel| ... }
344+
.define_iterator<std::vector<bmp::Pixel>::const_reverse_iterator(bmp::Bitmap::*)() const noexcept>(
345+
&bmp::Bitmap::crbegin, &bmp::Bitmap::crend, "each_const_reverse")
346+
346347
// --------------------------------------------------------------------
347348
// MODIFIER METHODS
348349
// --------------------------------------------------------------------
@@ -410,6 +411,10 @@ void Init_bitmap_plus_plus_ruby()
410411
{
411412
Rice::detail::cpp_protect([]
412413
{
414+
// Setup Ruby bindings
413415
initialize();
416+
417+
// Setup introspection support to generate RBS signatures and documentation
418+
Init_Rice_Api();
414419
});
415420
}

0 commit comments

Comments
 (0)