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

Use glib-mkenums to create the GType of all the available enums #284

Merged
merged 1 commit into from Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -48,6 +48,7 @@ extern "C" {
#include <as-launchable.h>
#include <as-relation.h>
#include <as-issue.h>
#include <as-enums-types.h>

#include <as-validator.h>
#include <as-validator-issue.h>
@@ -155,43 +155,6 @@ enum {
AS_COMPONENT_SCREENSHOTS
};

/**
* as_component_kind_get_type:
*
* Defines registered component types.
*/
GType
as_component_kind_get_type (void)
{
static volatile gsize as_component_kind_type_id__volatile = 0;
if (g_once_init_enter (&as_component_kind_type_id__volatile)) {
static const GEnumValue values[] = {
{AS_COMPONENT_KIND_UNKNOWN, "AS_COMPONENT_KIND_UNKNOWN", "unknown"},
{AS_COMPONENT_KIND_GENERIC, "AS_COMPONENT_KIND_GENERIC", "generic"},
{AS_COMPONENT_KIND_DESKTOP_APP, "AS_COMPONENT_KIND_DESKTOP_APP", "desktop-app"},
{AS_COMPONENT_KIND_CONSOLE_APP, "AS_COMPONENT_KIND_CONSOLE_APP", "console-app"},
{AS_COMPONENT_KIND_WEB_APP, "AS_COMPONENT_KIND_WEB_APP", "web-app"},
{AS_COMPONENT_KIND_ADDON, "AS_COMPONENT_KIND_ADDON", "addon"},
{AS_COMPONENT_KIND_FONT, "AS_COMPONENT_KIND_FONT", "font"},
{AS_COMPONENT_KIND_CODEC, "AS_COMPONENT_KIND_CODEC", "codec"},
{AS_COMPONENT_KIND_INPUTMETHOD, "AS_COMPONENT_KIND_INPUTMETHOD", "inputmethod"},
{AS_COMPONENT_KIND_FIRMWARE, "AS_COMPONENT_KIND_FIRMWARE", "firmware"},
{AS_COMPONENT_KIND_DRIVER, "AS_COMPONENT_KIND_DRIVER", "driver"},
{AS_COMPONENT_KIND_LOCALIZATION, "AS_COMPONENT_KIND_LOCALIZATION", "localization"},
{AS_COMPONENT_KIND_SERVICE, "AS_COMPONENT_KIND_SERVICE", "service"},
{AS_COMPONENT_KIND_REPOSITORY, "AS_COMPONENT_KIND_REPOSITORY", "repository"},
{AS_COMPONENT_KIND_OPERATING_SYSTEM, "AS_COMPONENT_KIND_OPERATING_SYSTEM", "operating-system"},
{AS_COMPONENT_KIND_ICON_THEME, "AS_COMPONENT_KIND_ICON_THEME", "icon-theme"},
{AS_COMPONENT_KIND_RUNTIME, "AS_COMPONENT_KIND_RUNTIME", "runtime"},
{0, NULL, NULL}
};
GType as_component_type_type_id;
as_component_type_type_id = g_enum_register_static ("AsComponentKind", values);
g_once_init_leave (&as_component_kind_type_id__volatile, as_component_type_type_id);
}
return as_component_kind_type_id__volatile;
}

/**
* as_component_kind_to_string:
* @kind: the #AsComponentKind.
@@ -28,6 +28,7 @@
#include <glib-object.h>
#include "as-context.h"
#include "as-enums.h"
#include "as-enums-types.h"
#include "as-provided.h"
#include "as-icon.h"
#include "as-screenshot.h"
@@ -102,8 +103,6 @@ typedef enum {
AS_COMPONENT_KIND_LAST
} AsComponentKind;

#define AS_TYPE_COMPONENT_KIND (as_component_kind_get_type ())
GType as_component_kind_get_type (void) G_GNUC_CONST;
const gchar *as_component_kind_to_string (AsComponentKind kind);
AsComponentKind as_component_kind_from_string (const gchar *kind_str);

@@ -75,6 +75,12 @@ aslib_pub_headers = [
'as-issue.h'
]

aslib_pub_enums = glib.mkenums_simple('as-enums-types',
sources : aslib_pub_headers,
install_header: true,
install_dir: 'appstream'
)

aslib_priv_headers = [
'as-utils-private.h',
'as-tag.h',
@@ -154,7 +160,8 @@ appstream_lib = library ('appstream',
[aslib_src,
aslib_pub_headers,
aslib_priv_headers,
aslib_res],
aslib_res,
aslib_pub_enums],
soversion: as_api_level,
version: as_version,
dependencies: [aslib_deps],
@@ -163,6 +170,18 @@ appstream_lib = library ('appstream',
install: true
)

appstream_dep = declare_dependency(
link_with: appstream_lib,
sources: [
aslib_pub_headers,
aslib_pub_enums
],
dependencies: [glib_dep,
gobject_dep],
include_directories: [appstream_lib_inc,
include_directories ('..')]
)

pkgc.generate (
version: as_version,
libraries: appstream_lib,
@@ -189,7 +208,7 @@ install_headers(aslib_pub_headers, subdir: 'appstream')
if get_option ('gir')
as_gir_typelib = glib.generate_gir (
appstream_lib,
sources: aslib_src + aslib_pub_headers,
sources: aslib_src + aslib_pub_headers + aslib_pub_enums,
nsversion: '1.0',
namespace: 'AppStream',
symbol_prefix: 'as',
@@ -21,13 +21,9 @@ as_test_common_src = [
as_test_basic_exe = executable ('as-test_basic',
['test-basics.c',
as_test_common_src],
include_directories: [appstream_lib_inc,
include_directories('..')],
dependencies: [glib_dep,
gobject_dep,
dependencies: [appstream_dep,
gio_dep,
xml2_dep],
link_with: [appstream_lib],
)
test ('as-test_basic',
as_test_basic_exe,
@@ -39,13 +35,9 @@ test ('as-test_basic',
as_test_xml_exe = executable ('as-test_xml',
['test-xmldata.c',
as_test_common_src],
include_directories: [appstream_lib_inc,
include_directories('..')],
dependencies: [glib_dep,
gobject_dep,
dependencies: [appstream_dep,
gio_dep,
xml2_dep],
link_with: [appstream_lib],
)
test ('as-test_xml',
as_test_xml_exe,
@@ -57,13 +49,9 @@ test ('as-test_xml',
as_test_yaml_exe = executable ('as-test_yaml',
['test-yamldata.c',
as_test_common_src],
include_directories: [appstream_lib_inc,
include_directories('..')],
dependencies: [glib_dep,
gobject_dep,
dependencies: [appstream_dep,
gio_dep,
xml2_dep],
link_with: [appstream_lib],
)
test ('as-test_yaml',
as_test_yaml_exe,
@@ -75,13 +63,9 @@ test ('as-test_yaml',
as_test_pool_exe = executable ('as-test_pool',
['test-pool.c',
as_test_common_src],
include_directories: [appstream_lib_inc,
include_directories('..')],
dependencies: [glib_dep,
gobject_dep,
dependencies: [appstream_dep,
gio_dep,
xml2_dep],
link_with: [appstream_lib],
)
test ('as-test_pool',
as_test_pool_exe,
@@ -93,13 +77,9 @@ test ('as-test_pool',
as_test_validate_exe = executable ('as-test_validate',
['test-validate.c',
as_test_common_src],
include_directories: [appstream_lib_inc,
include_directories('..')],
dependencies: [glib_dep,
gobject_dep,
dependencies: [appstream_dep,
gio_dep,
xml2_dep],
link_with: [appstream_lib],
)
test ('as-test_validate',
as_test_validate_exe,
@@ -111,13 +91,9 @@ test ('as-test_validate',
as_test_perf_exe = executable ('as-test_perf',
['test-performance.c',
as_test_common_src],
include_directories: [appstream_lib_inc,
include_directories('..')],
dependencies: [glib_dep,
gobject_dep,
dependencies: [appstream_dep,
gio_dep,
xml2_dep],
link_with: [appstream_lib],
)
test ('as-test_perf',
as_test_perf_exe,
@@ -129,13 +105,9 @@ test ('as-test_perf',
as_test_misc_exe = executable ('as-test_misc',
['test-misc.c',
as_test_common_src],
include_directories: [appstream_lib_inc,
include_directories('..')],
dependencies: [glib_dep,
gobject_dep,
dependencies: [appstream_dep,
gio_dep,
xml2_dep],
link_with: [appstream_lib],
)
test ('as-test_misc',
as_test_misc_exe,
@@ -11,11 +11,7 @@ ascli_src = [

ascli_exe = executable('appstreamcli',
[ascli_src],
dependencies: [glib_dep,
gobject_dep,
dependencies: [appstream_dep,
gio_dep],
link_with: [appstream_lib],
include_directories: [appstream_lib_inc,
include_directories ('..')],
install: true
)