Improve annotation processing for enums
Categories
(GeckoView :: General, task, P1)
Tracking
(firefox84 fixed)
Tracking | Status | |
---|---|---|
firefox84 | --- | fixed |
People
(Reporter: bugzilla, Assigned: bugzilla)
Details
(Whiteboard: [geckoview:m84])
Attachments
(2 files)
47 bytes,
text/x-phabricator-request
|
Details | Review | |
Bug 1674211: Part 2 - Explicitly mark GeckoProcessType.fromInt as WrapForJNI; r=#geckoview-reviewers
47 bytes,
text/x-phabricator-request
|
Details | Review |
Our annotation processing for enum
s kind of sucks.
The typical use case is that we want to generate wrappers for the values of the enum.
On the one hand, we can annotate each individual value with @WrapForJNI
which is noisy and error-prone.
On the other hand, we can mark the entire enum as @WrapForJNI
, which causes all stuff in the enum to get JNI wrappers, including private fields etc that we typically don't need to wrap, thus polluting the generated JNI wrapper with noise and making it harder to find the right information when inspecting the C++ header.
I'd like to modify the annotation processor to special case enums so that when we mark an entire enum as @WrapForJNI
, only the enumerated values will be wrapped. Any additional fields or methods that we want to wrap may then be annotated on a case-by-case basis.
This should give us cleaner Java and cleaner C++.
Assignee | ||
Comment 1•4 years ago
|
||
Our annotation processing for enum
s kind of sucks.
The typical use case is that we want to generate wrappers for the values of the
enum
.
On the one hand, we can annotate each individual enumerated value with
@WrapForJNI
which is noisy and error-prone.
On the other hand, we can mark the entire enum
as @WrapForJNI
, which causes
everything in the enum to get JNI wrappers, including private members that we
typically don't care about. This pollutes the generated JNI wrappers with noise
and makes it harder for somebody inspecting the generated C++ header to find
relevant information.
This patch modifies the annotation processor so that enum
s are treated as a
special case: when we mark an entire enum
as @WrapForJNI
, only the
enumerated values will be wrapped. Any additional fields or methods that we need
to wrap may then be annotated on a case-by-case basis.
This should give us both cleaner Java and cleaner generated C++.
Assignee | ||
Comment 2•4 years ago
|
||
As a result of part 1, we need to make this change, as this method needs to
be wrapped for the benefit of native code.
Not only does this patch fix the build error, but it also acts as an examplar
for how to explicitly annotate additional members of the enum
.
Depends on D95203
Pushed by aklotz@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/bd58283adf50 Part 1 - Modify the annotation processor for enums to only include enumerated values by default; r=geckoview-reviewers,agi https://hg.mozilla.org/integration/autoland/rev/581c733d3dab Part 2 - Explicitly mark GeckoProcessType.fromInt as WrapForJNI; r=geckoview-reviewers,agi
Comment 4•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/bd58283adf50
https://hg.mozilla.org/mozilla-central/rev/581c733d3dab
Description
•