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 #1384pull/2190/head
parent
c69a4aee1e
commit
4e476c82f3
7 changed files with 240 additions and 2 deletions
@ -0,0 +1,35 @@ |
|||||||
|
#include <stdio.h> |
||||||
|
#include <string.h> |
||||||
|
#include <glib-object.h> |
||||||
|
#include "enums4.h" |
||||||
|
#include "meson-sample.h" |
||||||
|
|
||||||
|
int main(int argc, char **argv) { |
||||||
|
GEnumClass *xenum = g_type_class_ref(MESON_TYPE_THE_XENUM); |
||||||
|
GFlagsClass *flags_enum = g_type_class_ref(MESON_TYPE_THE_FLAGS_ENUM); |
||||||
|
if (g_enum_get_value_by_name(xenum, "MESON_THE_XVALUE")->value != MESON_THE_XVALUE) { |
||||||
|
fprintf(stderr, "Get MESON_THE_XVALUE by name failed.\n"); |
||||||
|
return 1; |
||||||
|
} |
||||||
|
if (g_enum_get_value_by_nick(xenum, "the-xvalue")->value != MESON_THE_XVALUE) { |
||||||
|
fprintf(stderr, "Get MESON_THE_XVALUE by nick failed.\n"); |
||||||
|
return 2; |
||||||
|
} |
||||||
|
if (g_flags_get_value_by_name(flags_enum, "MESON_THE_FIRST_VALUE")->value != MESON_THE_FIRST_VALUE) { |
||||||
|
fprintf(stderr, "Get MESON_THE_FIRST_VALUE by name failed.\n"); |
||||||
|
return 3; |
||||||
|
} |
||||||
|
if (g_flags_get_value_by_nick(flags_enum, "the-first-value")->value != MESON_THE_FIRST_VALUE) { |
||||||
|
fprintf(stderr, "Get MESON_THE_FIRST_VALUE by nick failed.\n"); |
||||||
|
return 4; |
||||||
|
} |
||||||
|
|
||||||
|
/* Make sure that funcs are generated with leading underscore as requested */ |
||||||
|
if (!_meson_the_xenum_get_type()) |
||||||
|
g_error ("Bad!"); |
||||||
|
|
||||||
|
g_type_class_unref(xenum); |
||||||
|
g_type_class_unref(flags_enum); |
||||||
|
fprintf(stderr, "All ok.\n"); |
||||||
|
return 0; |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
#include <stdio.h> |
||||||
|
#include <string.h> |
||||||
|
#include <glib-object.h> |
||||||
|
#include "enums5.h" |
||||||
|
#include "meson-sample.h" |
||||||
|
|
||||||
|
int main(int argc, char **argv) { |
||||||
|
GEnumClass *xenum = g_type_class_ref(MESON_TYPE_THE_XENUM); |
||||||
|
GFlagsClass *flags_enum = g_type_class_ref(MESON_TYPE_THE_FLAGS_ENUM); |
||||||
|
if (g_enum_get_value_by_name(xenum, "MESON_THE_XVALUE")->value != MESON_THE_XVALUE) { |
||||||
|
fprintf(stderr, "Get MESON_THE_XVALUE by name failed.\n"); |
||||||
|
return 1; |
||||||
|
} |
||||||
|
if (g_enum_get_value_by_nick(xenum, "the-xvalue")->value != MESON_THE_XVALUE) { |
||||||
|
fprintf(stderr, "Get MESON_THE_XVALUE by nick failed.\n"); |
||||||
|
return 2; |
||||||
|
} |
||||||
|
if (g_flags_get_value_by_name(flags_enum, "MESON_THE_FIRST_VALUE")->value != MESON_THE_FIRST_VALUE) { |
||||||
|
fprintf(stderr, "Get MESON_THE_FIRST_VALUE by name failed.\n"); |
||||||
|
return 3; |
||||||
|
} |
||||||
|
if (g_flags_get_value_by_nick(flags_enum, "the-first-value")->value != MESON_THE_FIRST_VALUE) { |
||||||
|
fprintf(stderr, "Get MESON_THE_FIRST_VALUE by nick failed.\n"); |
||||||
|
return 4; |
||||||
|
} |
||||||
|
|
||||||
|
/* Make sure that funcs do not have any extra prefix */ |
||||||
|
if (!meson_the_xenum_get_type()) |
||||||
|
g_error ("Bad!"); |
||||||
|
|
||||||
|
g_type_class_unref(xenum); |
||||||
|
g_type_class_unref(flags_enum); |
||||||
|
fprintf(stderr, "All ok.\n"); |
||||||
|
return 0; |
||||||
|
} |
@ -0,0 +1,2 @@ |
|||||||
|
#pragma once |
||||||
|
#define MESON_EXPORT extern |
Loading…
Reference in new issue