gnome: add mkenums_simple() - #1800
Conversation
| static const G@Type@Value values[] = {''' % func_prefix | ||
|
|
||
| c_file_kwargs['vprod'] = \ | ||
| ' { C_@TYPE@(@VALUENAME@), "@VALUENAME@", "@valuenick@" },' |
There was a problem hiding this comment.
[flake8]
- [E128] continuation line under-indented for visual indent
a6301b3 to
f5eb5bb
Compare
|
So what is the reason this has to be a new API? |
|
Well, it doesn't have to be new API, but squeezing it into the existing How would you add this functionality to the existing |
|
Actually, I would probably argue that they are different things. |
|
Well just glancing at the docs you wrote like 80% of them overlap. I just think it reflects upon Meson poorly that our API is so bad we already have a duplicate entry with |
|
Well, we can't undo the past, can we? I think we should always be guided by providing the best usability for our users going forward, irrespective of how this may or may not reflect on meson :) |
|
I don't think our API is bad, it's just that mkenums API is extremely flexible and we chose to expose that first. Later, based on the most-common usage, we've distilled 90% of the use-cases into one |
| body_filename = args[0] + '.c' | ||
|
|
||
| # not really needed, just for sanity checking | ||
| forbidden_kwargs = ['c_template', 'h_template', 'eprod', 'fhead', |
There was a problem hiding this comment.
Maybe make this a whitelist instead of a blacklist? Similar to mkenums() itself.
There was a problem hiding this comment.
The main purpose of this was to catch old-api arguments from people who migrate from mkenums to mkenums_simple, to make sure there is no leakage. I can also remove this entirely. Our implementation calls the mkenums implementation in the end, so things will be checked there too.
There was a problem hiding this comment.
Actually, what I wrote makes no sense because I only copy over specific fields via a whitelist already, so there can be no leakage. Just unused args in meson.build file.
There was a problem hiding this comment.
Yes, but a whitelist will also protect against typos of kwargs that we do accept, that's all.
|
I don't think the code contains anything particularly technically challenging, since we re-use the existing mkenums implementation for all the important bits. |
|
Is there anything else we need to discuss or change here? |
|
It needs to be used and tested with various modules to make sure it fulfils their needs and does everything we want it to. I want to convert gst-plugins-base at least. I also tried to use it in pango but it caused some weird issue which I didn't have time to debug yet. |
|
@alessandrod has successfully converted various GStreamer modules over to this (base+bad), so should be alright. |
| install: true) | ||
| ``` | ||
|
|
||
| *Added 0.41.0* |
| Generates enum `.c` and `.h` files for GObject using the `glib-mkenums` tool | ||
| with the standard template used by most GObject-based C libraries. The first | ||
| argument is the base name of the output files. | ||
|
|
There was a problem hiding this comment.
In gnome.mkenums you should probably reference this function and explain why you might want to use this.
There was a problem hiding this comment.
Thanks for the review, updated.
f5eb5bb to
e4ee151
Compare
|
|
||
| Example: | ||
|
|
||
| ``` |
There was a problem hiding this comment.
Specify the meson language for syntax highlighting
|
|
||
| Returns an array of two elements which are: `[c_source, header_file]` | ||
|
|
||
| ### gnome.mkenums_simple() |
There was a problem hiding this comment.
Add notes about the new API in docs/markdown/Release-notes-for-0.42.0.md
| fhead += '#include "%s"\n' % hdr_filename | ||
| for hdr in sources: | ||
| fhead += '#include "%s"\n' % hdr | ||
| fhead += ''' |
There was a problem hiding this comment.
All these empty newlines show up in the generated file.
EDIT: Actually this specific newline is fine, but before the includes is 4 empty lines.
e4ee151 to
c7b0e06
Compare
Codecov Report
@@ Coverage Diff @@
## master #1800 +/- ##
==========================================
+ Coverage 56.47% 63.81% +7.33%
==========================================
Files 74 74
Lines 18192 18238 +46
Branches 3787 3796 +9
==========================================
+ Hits 10274 11638 +1364
+ Misses 6727 5416 -1311
+ Partials 1191 1184 -7
Continue to review full report at Codecov.
|
c7b0e06 to
1946a50
Compare
| # instead, but that seems like much more work, nice as it would be. | ||
| fhead = '' | ||
| if body_prefix != '': | ||
| fhead += '%s\n' % body_prefix |
There was a problem hiding this comment.
[flake8]
- [E111] indentation is not a multiple of four
1946a50 to
1d706b2
Compare
|
Thanks, updated. I believe the remaining three newlines at the beginning of the generated files are glib-mkenum's fault? |
It is possible; extra whitespace isn't a blocker but it would be nice to fix upstream. Anyway works well here 👍 |
|
Conflicts, and the windows build needs to be re-triggered; something went weird with the Cygwin build. |
1d706b2 to
ff0dea8
Compare
99% of all mkenums uses in C libraries use the same basic template, so add a mkenums_simple() function that takes care of everything for us based on that template. Features: - optional function declaration decorator such as GLIB_AVAILABLE - optional extra header prefix (e.g. for include needed for decorator) - optional extra body prefix (e.g. for additional includes) - optional function name prefix (e.g. to add leading underscores) Fixes issue mesonbuild#1384
ff0dea8 to
73e5047
Compare
|
Fixed conflicts, and then again :) |
|
Everyone happy with this now? |
99% of all mkenums uses in C libraries use the same basic template,
so add a mkenums_simple() function that takes care of everything for
us based on that template.
Features:
Fixes issue #1384