-
-
Notifications
You must be signed in to change notification settings - Fork 422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a PluginIterator methodmap #1779
Conversation
Haha, copy-paste go brr I concur that a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, will let this cool before I merge
Meh, this is weird, since this iterator behaves differently from other iterator methodmaps like This one advances the iterator when reading a property and only returns if there are more in the See #819 |
I thought that MorePlugins advanced the iterator, huh I should have something better ready by tonight |
I think this looks sane |
Thank you! This looks better, but the usage pattern of a PluginIterator it = new PluginIterator();
while (it.Next()) {
char pluginName[128];
GetPluginFilename(it.Plugin, pluginName, size of(pluginName));
PrintToServer("%s", pluginName);
}
delete it; |
Interesting, I'll have to think on that as I don't think changing core interface behavior would be advised I was in the mindset of |
The change would be able to be made for only the methodmap version, to be consistent with the other methodmap iterators, while keeping the non-methodmap behavior as-is so to not break existing plugins. |
9b84cb1
to
b817d09
Compare
Sanity check |
plugins/include/sourcemod.inc
Outdated
/** | ||
* Returns an iterator that can be used to search through plugins. | ||
* | ||
* @return Handle to iterate with. Must be closed via | ||
* CloseHandle(). | ||
* @error Invalid Handle. | ||
*/ | ||
native Handle GetPluginIterator(); | ||
native PluginIterator GetPluginIterator(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The non-methodmap API is now incompatible with the methodmap api. An iterator created with GetPluginIterator
still skips the first entry if you use the methodmap api afterwards.
Maybe it's better to change the non-methodmap implementation to use the new iterator class as well to be consistent. Otherwise we'd need to create a new handle type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah, I missed this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, this looks solid now!
GetPluginIterator
returns an handle of the same handletype as PluginIterator()
, so it could potentially be used with the methodmap api after view_as<PluginIterator>
, but that is such an obviously unnecessary pattern that I'm fine to blame the user in this case :D
We can switch GetPluginIterator
to use the new iterator and return a PluginIterator
in a follow up patch if needed.
👍 |
This follows the behavior of OOP
Full disclosure, I wrote this a month ago and forgot
BONUS: Fix a stray space...