3 # This is in its own file rather than inside meson.build
4 # because a) mixing the two is ugly and b) trying to
5 # make special characters such as \n go through all
6 # backends is a fool's errand.
8 import sys, os, shutil, subprocess
11 "#ifndef __GST_ENUM_TYPES_H__\n#define __GST_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n",
13 "\n/* enumerations from \"@filename@\" */\n",
15 "GType @enum_name@_get_type (void);\n#define GST_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n",
17 "G_END_DECLS\n\n#endif /* __GST_ENUM_TYPES_H__ */"]
21 "#include \"gst_private.h\"\n#include <gst/gst.h>\n#define C_ENUM(v) ((gint) v)\n#define C_FLAGS(v) ((guint) v)\n ",
23 "\n/* enumerations from \"@filename@\" */",
25 "GType\n@enum_name@_get_type (void)\n{\n static gsize id = 0;\n static const G@Type@Value values[] = {",
27 " { C_@TYPE@(@VALUENAME@), \"@VALUENAME@\", \"@valuenick@\" },",
29 " { 0, NULL, NULL }\n };\n\n if (g_once_init_enter (&id)) {\n GType tmp = g_@type@_register_static (\"@EnumName@\", values);\n g_once_init_leave (&id, tmp);\n }\n\n return (GType) id;\n}"
34 # Find the full command needed to run glib-mkenums
35 # On UNIX-like, this is just the full path to glib-mkenums
36 # On Windows, this is the full path to interpreter + full path to glib-mkenums
37 for arg in sys.argv[1:]:
40 if arg.endswith('glib-mkenums'):
42 ofilename = sys.argv[argn]
43 headers = sys.argv[argn + 1:]
45 if ofilename.endswith('.h'):
50 pc = subprocess.Popen(cmd + arg_array + headers, stdout=subprocess.PIPE)
51 (stdo, _) = pc.communicate()
52 if pc.returncode != 0:
53 sys.exit(pc.returncode)
54 open(ofilename, 'wb').write(stdo)