[foreign] RFR: jextract generates duplicate macros

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Tue Jun 19 10:43:31 UTC 2018


Hi,
the new macro parsing code has a bug, as sometimes the same macro 
constant can be added twice. This is due to a behavior that's there by 
design: macros are now collected within a given jextract context, since 
constants in header file A might depend on header file B, and so forth. 
This patch simply adds some filtering capabilities to the 
Context::macros method, to make sure that only macros that are relevant 
to a given file are returned.

I also tweaked the code in HeaderFile::processCursor, to always process 
the contents of a macro, regardless of whether the file in question has 
an associated code factory or not. Note that the process by which we 
generate macros has two steps: first we collect all macros, then in a 
second step, the code factory asks the contexts all the macro relevant 
to that file and emits them. So, in the collection phase, we wanna make 
sure we collect every possible macro that could define a constant we 
might need to depend on later.

Webrev:

http://cr.openjdk.java.net/~mcimadamore/panama/duplicate_macros/

Maurizio



More information about the panama-dev mailing list