Commit Graph

11 Commits

Author SHA1 Message Date
Aleksander Morgado
ec6056e3ab glib-mkenums: allow optional 'since' tag
The glib-mkenums program allows generating code to handle enums/flags
with very different purposes. One of its purposes could be generating
per-enum/flag methods to be exposed in a library API, and while doing
that, it would be nice to have a way to specify in which API version
the enum/flag was introduced, so that the same version could be shown
in the generated API methods.

E.g. From the following code:

    /**
     * QmiWmsMessageProtocol:
     * @QMI_WMS_MESSAGE_PROTOCOL_CDMA: CDMA.
     * @QMI_WMS_MESSAGE_PROTOCOL_WCDMA: WCDMA.
     *
     * Type of message protocol.
     *
     * Since: 1.0
     */
    typedef enum { /*< since=1.0 >*/
        QMI_WMS_MESSAGE_PROTOCOL_CDMA  = 0x00,
        QMI_WMS_MESSAGE_PROTOCOL_WCDMA = 0x01
    } QmiWmsMessageProtocol;

The template would allow us to generate a method documented like this,
including the Since tag with the value given in the mkenums 'since' tag.

    /**
     * qmi_wms_message_protocol_get_string:
     * @val: a QmiWmsMessageProtocol.
     *
     * Gets the nickname string for the #QmiWmsMessageProtocol specified at @val.
     *
     * Returns: (transfer none): a string with the nickname, or %NULL if not found. Do not free the returned value.
     * Since: 1.0
     */
    const gchar *qmi_wms_message_protocol_get_string (QmiWmsMessageProtocol val);

Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
2020-05-14 17:00:54 +02:00
Chun-wei Fan
75e3f92cd0 GObject: Fix mkenums.py and genmarshal.py tests on Windows
The two test scripts actually assumed some *NIX paradigms, so we need
to adapt them so that they can work on Windows as well, the changes are
namely:

-Call the glib-mkenums and glib-genmarshal Python scripts with the
 Python interpreter, not just relying on shebang lines, on Windows.
 This is because the native Windows console (cmd.exe) does not support
 shebang lines, for subprocess.run().

-Use NamedTemporaryFile with delete=False, otherwise Windows cannot find
 the temp files we need when running the tests.

-Use universal_newlines=True for subprocess.run() so that we do not need
 to worry out line ending differences on different systems.

-Make sure we are not in the temp directories we create, where the tests
 are being run, upon cleanup.  Windows does not like deleting
 directories that we are currently in.
2019-06-25 00:04:48 +08:00
Chun-wei Fan
108a8d842f gobject/tests/mkenums.py: Fix _write_rspfile()
The 'return f.name' should be in the same level as the body of
'with tempfile.NamedTemporaryFile(...) as f:'
2019-06-25 00:03:09 +08:00
Philip Withnall
3f02660ea5 tests: Fix hard-coded install path in glib-mkenums test
While this was useful for local testing while developing the test, it’s
not widely applicable. Look the binary up in the current `${PATH}` if
it’s not specified using `G_TEST_BUILDDIR`.

This is needed to get the `mkenums.py` test working as an
installed-test.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-08 00:11:13 +01:00
Tomasz Miąsko
6b0ad94fb4 tests: s/assertEquals/assertEqual/
Assert assertEquals is deprecated alias of assertEqual.
2018-12-12 12:57:51 +01:00
Nirbheek Chauhan
17316b2c16 glib-mkenums: Support reading @rspfiles for arguments
This is needed on Windows where the argument list can exceed the
maximum command-line length when lots of sources are passed to
glib-mkenums.
2018-12-04 16:16:00 +05:30
Will Thompson
7928fee2a8
glib-mkenums: don't support @filename@/@basename@ in fhead/ftail
As discussed in
https://gitlab.gnome.org/GNOME/glib/merge_requests/135#note_253986 it
doesn't really make sense to support these outside the templates for any
particular header file. Leave them unsubstituted, with a warning.
2018-08-10 17:05:59 +01:00
Will Thompson
cbd335c8c9
tests: mkenums: placate flake8 2018-08-10 17:05:59 +01:00
Will Thompson
12a2a984f2
tests: refactor running glib-mkenums
Part of runMkenumsWithHeader() was duplicated in test_reproducible(),
and would otherwise need to be duplicated again in upcoming tests.  Many
places duplicated decoding stdout/stderr and checking the exit code.

Introduce a named tuple for the returned fields; and factor out writing
a template file to pass with --template.
2018-08-10 17:05:59 +01:00
Philip Withnall
76083b6530 tests: Add glib-mkenums test for missing nicks
This adds a test to verify the change from issue #1360.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/glib/issues/1360
2018-06-25 13:39:13 +01:00
Philip Withnall
e8d755eb8e tests: Add initial test framework for glib-mkenums
This allows running glib-mkenums with different C headers and checking
its output.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/glib/issues/1360
2018-06-25 13:39:13 +01:00