Skip to content

Add RzIterator support to the bindgen and linter - #121

Open
notxvilka wants to merge 1 commit into
devfrom
iterator-support
Open

Add RzIterator support to the bindgen and linter#121
notxvilka wants to merge 1 commit into
devfrom
iterator-support

Conversation

@notxvilka

Copy link
Copy Markdown
Contributor

Bindgen:

  • Bind RzIterator as a class. rz_iterator_next is exposed as next()
    and rz_iterator_free as the destructor. Since RzIterator is
    type-erased in C (rz_iterator_next returns a borrowed void *),
    elements are yielded as opaque pointers. A new RzIteratorIterator
    python helper implements the iterator protocol on top of next(), so
    every RzIterator * return value works directly in a for loop. On
    exhaustion it hands ownership to SWIG via thisown so the idiomatic
    for x in coll.as_iter(): ... frees the iterator deterministically.
  • Add as_iter / as_iter_keys / as_iter_mut to every hashtable type
    (HtPP, HtPU, HtUP, HtUU, HtSP, HtSS, HtSU). RzSetS / RzSetU are typedef
    aliases of HtSP / HtUP, so this covers sets transitively.
  • Support add_python_method on Class (it previously only existed on
    Generic), used for RzIterator.__iter__.

Linter:

  • Recognize and validate RzIterator type comments. The element type is
    often not known statically, so RzIterator is kept out of generic_types
    (the comment stays optional); when present it must name exactly one type,
    unlike the two-parameter RzGraph / HtPP form.
  • Normalize surrounding whitespace in type comments so the space-padded
    /* <T> */ style used by the RzIterator helpers is accepted alongside
    the existing compact /*<T>*/ style. Existing annotations have no
    padding, so this is a no-op for them.

Closes #67

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add iterators support

2 participants