Commit bf248cb3 authored by Inigo Martínez's avatar Inigo Martínez Committed by Ray Strode

build: Use template files for enums generation

The data contents for the enum related files are stored in the
build files.

This patch moves this information to template files to be used
along with glib-mkenums.
parent e9e4aaee
Pipeline #4883 failed with stage
in 1 minute and 59 seconds
/*** BEGIN file-header ***/
#include "act-user-enum-types.h"
#include <glib-object.h>
/*** END file-header ***/
/*** BEGIN file-production ***/
/* enumerations from "@basename@" */
#include "@basename@"
/*** END file-production ***/
/*** BEGIN value-header ***/
GType
@enum_name@_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
static const G@Type@Value values[] = {
/*** END value-header ***/
/*** BEGIN value-production ***/
{ @VALUENAME@, "@VALUENAME@", "@valuenick@" },
/*** END value-production ***/
/*** BEGIN value-tail ***/
{ 0, NULL, NULL }
};
etype = g_@type@_register_static ("@EnumName@", values);
}
return etype;
}
/*** END value-tail ***/
/*** BEGIN file-tail ***/
/*** END file-tail ***/
/*** BEGIN file-header ***/
#ifndef __ACT_USER_ENUM_TYPES_H__
#define __ACT_USER_ENUM_TYPES_H__
#include <glib-object.h>
G_BEGIN_DECLS
/*** END file-header ***/
/*** BEGIN file-production ***/
/* enumerations from "@basename@" */
/*** END file-production ***/
/*** BEGIN value-header ***/
GType @enum_name@_get_type (void) G_GNUC_CONST;
#define ACT_USER_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
/*** END value-header ***/
/*** BEGIN file-tail ***/
G_END_DECLS
#endif /* __ACT_USER_ENUM_TYPES_H__ */
/*** END file-tail ***/
......@@ -17,26 +17,13 @@ sources = files(
'act-user-manager.c',
)
enum_sources = []
enum_types = 'act-user-enum-types'
enum_sources += gnome.mkenums(
enum_types + '.c',
enum_sources = gnome.mkenums(
enum_types,
sources: headers,
fhead: '#include "act-user.h"\n#include "act-user-manager.h"\n#include "act-user-enum-types.h"\n#include <glib-object.h>\n\n',
fprod: '\n/* enumerations from "@filename@" */',
vhead: 'GType\n@enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G@Type@Value values[] = {',
vprod: ' { @VALUENAME@, "@VALUENAME@", "@valuenick@" },',
vtail: ' { 0, NULL, NULL }\n };\n etype = g_@type@_register_static ("@EnumName@", values);\n }\n return etype;\n}\n',
)
enum_sources += gnome.mkenums(
enum_types + '.h',
sources: headers,
fhead: '#ifndef __ACT_USER_ENUM_TYPES_H__\n#define __ACT_USER_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n',
fprod: '/* enumerations from "@filename@" */\n',
vhead: 'GType @enum_name@_get_type (void);\n#define ACT_USER_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n',
ftail: 'G_END_DECLS\n\n#endif /* __ACT_USER_ENUM_TYPES_H__ */',
c_template: enum_types + '.c.template',
h_template: enum_types + '.h.template',
install_header: true,
install_dir: join_paths(act_pkgincludedir, subdir),
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment