diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2017-04-09 12:02:43 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2017-04-09 12:06:55 +0300 |
commit | c7cc48b42e53489dbf94763bf721feb9a27080a6 (patch) | |
tree | a58fa5377b5efca22360b21b33893d3f609de7bf /libs/gst | |
parent | 519d64881fad234c9a637c0c1bcc3d8155e46b3f (diff) |
controller: Generate GLib enums automatically
Diffstat (limited to 'libs/gst')
-rw-r--r-- | libs/gst/controller/Makefile.am | 21 | ||||
-rwxr-xr-x | libs/gst/controller/controller_mkenum.py | 55 | ||||
-rw-r--r-- | libs/gst/controller/gstinterpolationcontrolsource.c | 22 | ||||
-rw-r--r-- | libs/gst/controller/gstinterpolationcontrolsource.h | 4 | ||||
-rw-r--r-- | libs/gst/controller/gstlfocontrolsource.c | 26 | ||||
-rw-r--r-- | libs/gst/controller/gstlfocontrolsource.h | 4 | ||||
-rw-r--r-- | libs/gst/controller/meson.build | 22 |
7 files changed, 98 insertions, 56 deletions
diff --git a/libs/gst/controller/Makefile.am b/libs/gst/controller/Makefile.am index b20a8e7d9..e62d9cff5 100644 --- a/libs/gst/controller/Makefile.am +++ b/libs/gst/controller/Makefile.am @@ -1,5 +1,17 @@ lib_LTLIBRARIES = libgstcontroller-@GST_API_VERSION@.la +glib_enum_headers= \ + gstinterpolationcontrolsource.h \ + gstlfocontrolsource.h + +glib_enum_define = GST_CONTROLLER +glib_gen_prefix = gst +glib_gen_basename = controller + +built_sources = controller-enumtypes.c +built_headers = controller-enumtypes.h +BUILT_SOURCES = $(built_sources) $(built_headers) + libgstcontroller_@GST_API_VERSION@_includedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/controller libgstcontroller_@GST_API_VERSION@_include_HEADERS = \ controller.h \ @@ -11,6 +23,9 @@ libgstcontroller_@GST_API_VERSION@_include_HEADERS = \ gsttriggercontrolsource.h \ gstlfocontrolsource.h +nodist_libgstcontroller_@GST_API_VERSION@_include_HEADERS = \ + controller-enumtypes.h + libgstcontroller_@GST_API_VERSION@_la_SOURCES = \ gstargbcontrolbinding.c \ gstdirectcontrolbinding.c \ @@ -20,17 +35,21 @@ libgstcontroller_@GST_API_VERSION@_la_SOURCES = \ gsttriggercontrolsource.c \ gstlfocontrolsource.c +nodist_libgstcontroller_@GST_API_VERSION@_la_SOURCES = $(BUILT_SOURCES) + libgstcontroller_@GST_API_VERSION@_la_CFLAGS = $(GST_OBJ_CFLAGS) libgstcontroller_@GST_API_VERSION@_la_LIBADD = $(GST_OBJ_LIBS) $(LIBM) libgstcontroller_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS) -CLEANFILES = *.gcno *.gcda *.gcov +CLEANFILES = *.gcno *.gcda *.gcov $(BUILT_SOURCES) %.c.gcov: .libs/libgstcontroller_@GST_API_VERSION@_la-%.gcda %.c $(GCOV) -b -f -o $^ > $@.out gcov: $(libgstcontroller_@GST_API_VERSION@_la_SOURCES:=.gcov) +include $(top_srcdir)/common/gst-glib-gen.mak + if HAVE_INTROSPECTION BUILT_GIRSOURCES = GstController-@GST_API_VERSION@.gir diff --git a/libs/gst/controller/controller_mkenum.py b/libs/gst/controller/controller_mkenum.py new file mode 100755 index 000000000..f7fbc2151 --- /dev/null +++ b/libs/gst/controller/controller_mkenum.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 + +# This is in its own file rather than inside meson.build +# because a) mixing the two is ugly and b) trying to +# make special characters such as \n go through all +# backends is a fool's errand. + +import sys, os, shutil, subprocess + +h_array = ['--fhead', + "#ifndef __GST_CONTROLLER_ENUM_TYPES_H__\n#define __GST_CONTROLLER_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n", + '--fprod', + "\n/* enumerations from \"@filename@\" */\n", + '--vhead', + 'GType @enum_name@_get_type (void);\n#define GST_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n', + '--ftail', + 'G_END_DECLS\n\n#endif /* __GST_CONTROLLER_ENUM_TYPES_H__ */', + ] + +c_array = ['--fhead', + "#include \"controller-enumtypes.h\"\n\n#include \"controller.h\" \n#include \"gstinterpolationcontrolsource.h\" \n#include \"gstlfocontrolsource.h\"", + '--fprod', + "\n/* enumerations from \"@filename@\" */", + '--vhead', + "GType\n@enum_name@_get_type (void)\n{\n static volatile gsize g_define_type_id__volatile = 0;\n if (g_once_init_enter (&g_define_type_id__volatile)) {\n static const G@Type@Value values[] = {", + '--vprod', + " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" },", + '--vtail', + " { 0, NULL, NULL }\n };\n GType g_define_type_id = g_@type@_register_static (\"@EnumName@\", values);\n g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);\n }\n return g_define_type_id__volatile;\n}\n", + ] + +cmd = [] +argn = 1 +# Find the full command needed to run glib-mkenums +# On UNIX-like, this is just the full path to glib-mkenums +# On Windows, this is the full path to interpreter + full path to glib-mkenums +for arg in sys.argv[1:]: + cmd.append(arg) + argn += 1 + if arg.endswith('glib-mkenums'): + break +ofilename = sys.argv[argn] +headers = sys.argv[argn + 1:] + +if ofilename.endswith('.h'): + arg_array = h_array +else: + arg_array = c_array + +cmd_array = cmd + arg_array + headers +pc = subprocess.Popen(cmd_array, stdout=subprocess.PIPE) +(stdo, _) = pc.communicate() +if pc.returncode != 0: + sys.exit(pc.returncode) +open(ofilename, 'wb').write(stdo) diff --git a/libs/gst/controller/gstinterpolationcontrolsource.c b/libs/gst/controller/gstinterpolationcontrolsource.c index ff8d8f700..d10bd2b05 100644 --- a/libs/gst/controller/gstinterpolationcontrolsource.c +++ b/libs/gst/controller/gstinterpolationcontrolsource.c @@ -621,28 +621,6 @@ enum PROP_MODE = 1 }; -GType -gst_interpolation_mode_get_type (void) -{ - static gsize gtype = 0; - static const GEnumValue values[] = { - {GST_INTERPOLATION_MODE_NONE, "GST_INTERPOLATION_MODE_NONE", "none"}, - {GST_INTERPOLATION_MODE_LINEAR, "GST_INTERPOLATION_MODE_LINEAR", "linear"}, - {GST_INTERPOLATION_MODE_CUBIC, "GST_INTERPOLATION_MODE_CUBIC", "cubic"}, - {GST_INTERPOLATION_MODE_CUBIC_MONOTONIC, - "GST_INTERPOLATION_MODE_CUBIC_MONOTONIC", "cubic-monotonic"}, - {0, NULL, NULL} - }; - - if (g_once_init_enter (>ype)) { - GType tmp = g_enum_register_static ("GstInterpolationMode", values); - g_once_init_leave (>ype, tmp); - } - - return (GType) gtype; -} - - #define _do_init \ GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "interpolation control source", 0, \ "timeline value interpolating control source") diff --git a/libs/gst/controller/gstinterpolationcontrolsource.h b/libs/gst/controller/gstinterpolationcontrolsource.h index d3a4d8512..3ce3193cd 100644 --- a/libs/gst/controller/gstinterpolationcontrolsource.h +++ b/libs/gst/controller/gstinterpolationcontrolsource.h @@ -28,6 +28,7 @@ #include <gst/gst.h> #include <gst/controller/gsttimedvaluecontrolsource.h> +#include <gst/controller/controller-enumtypes.h> G_BEGIN_DECLS @@ -44,8 +45,6 @@ G_BEGIN_DECLS #define GST_INTERPOLATION_CONTROL_SOURCE_GET_CLASS(inst) \ (G_TYPE_INSTANCE_GET_CLASS ((inst), GST_TYPE_INTERPOLATION_CONTROL_SOURCE, GstInterpolationControlSourceClass)) -#define GST_TYPE_INTERPOLATION_MODE (gst_interpolation_mode_get_type ()) - typedef struct _GstInterpolationControlSource GstInterpolationControlSource; typedef struct _GstInterpolationControlSourceClass GstInterpolationControlSourceClass; typedef struct _GstInterpolationControlSourcePrivate GstInterpolationControlSourcePrivate; @@ -91,7 +90,6 @@ struct _GstInterpolationControlSourceClass { }; GType gst_interpolation_control_source_get_type (void); -GType gst_interpolation_mode_get_type (void); /* Functions */ diff --git a/libs/gst/controller/gstlfocontrolsource.c b/libs/gst/controller/gstlfocontrolsource.c index e0adaafd9..36d2d0398 100644 --- a/libs/gst/controller/gstlfocontrolsource.c +++ b/libs/gst/controller/gstlfocontrolsource.c @@ -372,32 +372,6 @@ enum PROP_OFFSET }; -GType -gst_lfo_waveform_get_type (void) -{ - static gsize gtype = 0; - static const GEnumValue values[] = { - {GST_LFO_WAVEFORM_SINE, "GST_LFO_WAVEFORM_SINE", - "sine"}, - {GST_LFO_WAVEFORM_SQUARE, "GST_LFO_WAVEFORM_SQUARE", - "square"}, - {GST_LFO_WAVEFORM_SAW, "GST_LFO_WAVEFORM_SAW", - "saw"}, - {GST_LFO_WAVEFORM_REVERSE_SAW, "GST_LFO_WAVEFORM_REVERSE_SAW", - "reverse-saw"}, - {GST_LFO_WAVEFORM_TRIANGLE, "GST_LFO_WAVEFORM_TRIANGLE", - "triangle"}, - {0, NULL, NULL} - }; - - if (g_once_init_enter (>ype)) { - GType tmp = g_enum_register_static ("GstLFOWaveform", values); - g_once_init_leave (>ype, tmp); - } - - return (GType) gtype; -} - #define _do_init \ GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "lfo control source", 0, "low frequency oscillator control source") diff --git a/libs/gst/controller/gstlfocontrolsource.h b/libs/gst/controller/gstlfocontrolsource.h index 872422947..b192b5b3d 100644 --- a/libs/gst/controller/gstlfocontrolsource.h +++ b/libs/gst/controller/gstlfocontrolsource.h @@ -26,6 +26,7 @@ #include <glib-object.h> #include <gst/gst.h> +#include <gst/controller/controller-enumtypes.h> G_BEGIN_DECLS @@ -42,8 +43,6 @@ G_BEGIN_DECLS #define GST_LFO_CONTROL_SOURCE_GET_CLASS(inst) \ (G_TYPE_INSTANCE_GET_CLASS ((inst), GST_TYPE_LFO_CONTROL_SOURCE, GstLFOControlSourceClass)) -#define GST_TYPE_LFO_WAVEFORM (gst_lfo_waveform_get_type ()) - typedef struct _GstLFOControlSource GstLFOControlSource; typedef struct _GstLFOControlSourceClass GstLFOControlSourceClass; typedef struct _GstLFOControlSourcePrivate GstLFOControlSourcePrivate; @@ -89,7 +88,6 @@ struct _GstLFOControlSourceClass { }; GType gst_lfo_control_source_get_type (void); -GType gst_lfo_waveform_get_type (void); /* Functions */ diff --git a/libs/gst/controller/meson.build b/libs/gst/controller/meson.build index 48d19aef3..027845090 100644 --- a/libs/gst/controller/meson.build +++ b/libs/gst/controller/meson.build @@ -8,7 +8,12 @@ gst_controller_sources = [ 'gstlfocontrolsource.c', ] -gst_controller_headers = [ +controller_mkenum_headers = [ + 'gstinterpolationcontrolsource.h', + 'gstlfocontrolsource.h', +] + +gst_controller_headers = controller_mkenum_headers + [ 'gstargbcontrolbinding.h', 'gstdirectcontrolbinding.h', 'gsttimedvaluecontrolsource.h', @@ -20,6 +25,21 @@ gst_controller_headers = [ ] install_headers(gst_controller_headers, subdir : 'gstreamer-1.0/gst/controller/') +mkenums = find_program('controller_mkenum.py') +gstcontroller_h = custom_target('gstcontrollerenum_h', + output : 'controller-enumtypes.h', + input : controller_mkenum_headers, + install : true, + install_dir : 'include/gstreamer-1.0/gst/controller/', + command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@']) + +gstcontroller_c = custom_target('gstcontrollerenum_c', + output : 'controller-enumtypes.c', + input : controller_mkenum_headers, + depends : [gstcontroller_h], + command : [mkenums, glib_mkenums, '@OUTPUT@', '@INPUT@']) +controller_gen_sources = [gstcontroller_h] + if libtype != 'shared' gst_controller_static = static_library('gstcontroller-@0@'.format(apiversion), gst_controller_sources, |