synacktiv / bip

BSD 3-Clause "New" or "Revised" License
189 stars 19 forks source link

Add support for get_by_prefix and get_by_regex in BipElt #21

Closed assafcarlsbad closed 3 years ago

assafcarlsbad commented 3 years ago

Hi again,

Is it possible to add the class methods get_by_prefix and get_by_regex to BipElt as well? I have a script in which I rename some global variables according to some naming convention and I want to be able to iterate over them in a concise manner.

If needed, I can open a PR for this myself.

Thanks 🙏

BrunoPujos commented 3 years ago

Hello again,

Funny you should ask, I had the same problem a few months back but apparently never finished writing all the code. Anyway this is now done in PR #22. You should be able to apply directly the commits if you want to stay in stable and will be pushed in the next stable version.

For your case where you are renaming globals you will probably want to use the class iterator for the BipData object (which inherit from BipElt), if not you may find yourself with BipInstr objects in your result and it should be a little faster (maybe).

As a general rule, PR are welcome (I even wrote a doc. on how to make one here: https://synacktiv.github.io/bip/build/html/general/contribution.html#pull-request :). This will mainly allow you to have faster implementation of such features, but for small requests like this (and as long as we are only something like 5 to use Bip), it does not take me a lot of time to implement them so fill free to create an issue. If a feature request will take me too much time to implement quickly, I will answer the issue by saying that it will take time and that a PR is welcome.

Same as always I am closing this but reopen if that did not resolve the problem (or if you find bugs because I just added that code).