Skip to content
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

Fix template iterator #675

Closed
wants to merge 10 commits into from

Conversation

HGuillemet
Copy link
Contributor

To generate Java classes for different sets of template arguments, the Parser, in declarations(), makes a first pass without argument values during which it fills an infoList (in DeclarationsList) with the infos targeting instances of the template, then makes additional passes for each element in infoList, filling templateMap with template arguments founds in each info.

To pick these infos, it calls infoMap.get(name) which may return infos with several cpp names.
For instance for ptr<X> it could return an info with the following cppNames:
["ArrayRef<ptr<X> >", "ptr<X>"].

Then when filling templateMap, only cppNames[0] is checked, and its Type.arguments are used to fill the templateMap values. In the example above, we will end up trying to instantiate ptr<ptr<X> >.

I came across this problem when trying to understand a concurrent modification exception thrown by the parser when the infoList was modified when using its iterator.

This PR proposes to replace the infoIterator with a string iterator containing cpp names founds in info, but only those that match the name of the declaration being parsed (in normalized form).

Checked on existing presets, nothing changed in parsing results.

Only the first matching cppName in each info is considered. I think returning all matching names would be better, but this would require modifications in existing presets.

@saudet
Copy link
Member

saudet commented Apr 21, 2023

I came across this problem when trying to understand a concurrent modification exception thrown by the parser when the infoList was modified when using its iterator.

Could you provide an example of that?

@HGuillemet HGuillemet closed this Jan 1, 2024
@HGuillemet HGuillemet deleted the fix_template_iterator branch January 1, 2024 23:51
@HGuillemet HGuillemet restored the fix_template_iterator branch January 1, 2024 23:51
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.

None yet

2 participants