[grilo] vala: new vapi generation machinery



commit 609fb9c50e56716b1e9f0d3ad2d760bfba3c79da
Author: Víctor Manuel Jáquez Leal <vjaquez igalia com>
Date:   Sun Jul 18 00:12:49 2010 +0200

    vala: new vapi generation machinery
    
    Following this scheme[1], the vapi generation now is fully
    automatic.
    
    Besides, for sake of a correct compilation, further changes
    were done:
    
    + As the vapi file is autogenerated with the uninstalled files, the
      vapi must be generated before the vala test is compiled.
    
    + Set the ellipsis property to grl_list_from_va()
    
    + Add more custom code into the vapi. This is a _bad_ symptom, because it
      means more diverging from the normal gobject code style.
    
    + Fix the vala test according to the new custom code.
    
    1. http://git.collabora.co.uk/?p=user/edward/gst-convenience.git;a=blob;f=vala/Makefile.am
    
    Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez igalia com>

 Makefile.am                                        |    2 +-
 bindings/vala/Makefile.am                          |   72 ++-
 bindings/vala/grilo-0.1-custom.vala                |  103 +++
 bindings/vala/{grilo-0.1 => }/grilo-0.1.metadata   |    1 +
 bindings/vala/grilo-0.1.vapi                       |  510 -----------
 bindings/vala/grilo-0.1/grilo-0.1-custom.vala      |   39 -
 bindings/vala/grilo-0.1/grilo-0.1.files            |    3 -
 bindings/vala/grilo-0.1/grilo-0.1.gi               |  932 --------------------
 bindings/vala/grilo-0.1/grilo-0.1.namespace        |    1 -
 ...grilo-0.1.defines => grilo-uninstalled.defines} |    0
 tools/vala/grilo-test.vala                         |    2 +-
 11 files changed, 174 insertions(+), 1491 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 7acc3d7..5cfd858 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -7,7 +7,7 @@
 
 ACLOCAL_AMFLAGS = -I m4
 
-SUBDIRS = src tools bindings
+SUBDIRS = src bindings tools
 
 if ENABLE_GTK_DOC
 SUBDIRS += doc
diff --git a/bindings/vala/Makefile.am b/bindings/vala/Makefile.am
index 80309aa..a3f55f0 100644
--- a/bindings/vala/Makefile.am
+++ b/bindings/vala/Makefile.am
@@ -1,6 +1,70 @@
-vapidir = $(datadir)/vala/vapi
+# This Makefile is a tad convoluted. I've tried to make it so that the vapi
+# can be built at the same time as the library in the hope that this will make
+# it easier to keep it up-to-date.
+#
+# The vapi is generated in 2 steps:
+#
+#   vala-gen-introspect looks at headers and libs and generates a gidl for the
+#   library. It takes a .files file containing paths to these. It also takes a
+#   .namespace file containing the Vala namespace corresponding to this
+#   library. Both these files are expected to be in the directory where you run
+#   vala-gen-introspect.
+#
+#   vapigen takes the gidl, a .deps file containing the list of libs needed
+#   to link this library, and a .metadata file containing annotations to the
+#   gidl (e.g. foo() is the free function for object X).
+#
+# vala-gen-introspect runs with the -uninstalled .pc file. The .files is
+# generated so that it has links to the headers and libraries from the source
+# and build trees. The .namespace file is generated, though it doesn't need
+# to be, so that it exists in the build tree where vala-gen-introspect is run
+# (because this may not be the same as the source tree). Since we're working
+# with the -uninstalled files, and vala-gen-introspect assumes filenames are
+# named as <package>.<extension>, all the associated file names have an
+# -uninstalled suffix.
+#
+# Running vapigen is simpler. It generates a the .vapi file using the gidl
+# file from vala-gen-introspect. Since we want the final files to be in the
+# form <libname>-<version>.*, we use the same convention for naming the files
+# associated with this step (contrast with the -uninstalled suffix for the
+# vala-gen-introspect step). The only file implicitly used by vapigen is the
+# .deps file, so to make the build independent of a split source/build tree,
+# I've put the deps on the vapigen command-line (it's redundant, but helps
+# with distcheck).
+#
 
-dist_vapi_DATA = \
-	grilo-0.1.vapi
+targets = grilo- GRL_MAJORMINOR@
+targets_u = $(foreach target,$(targets),$(subst @GRL_MAJORMINOR@,uninstalled,$(target)))
 
-MAINTAINERCLEANFILES = Makefile.in
+# "source" files for vala-gen-introspect
+filesfiles_src = $(foreach target,$(targets_u),$(target).files.in)
+filesfiles = $(foreach target,$(targets_u),$(target).files)
+nsfiles_src = $(foreach target,$(targets_u),$(target).namespace.in)
+nsfiles = $(foreach target,$(targets_u),$(target).namespace)
+
+# "source" files for vapigen
+gifiles = $(foreach target,$(targets),$(target).gi)
+metadatafiles = $(foreach target,$(targets),$(target).metadata)
+
+vapidir = $(VAPIDIR)
+
+if HAVE_VALA
+vapifiles = $(foreach target,$(targets),$(target).vapi)
+vapi_DATA = $(depsfiles) $(vapifiles)
+endif
+
+%- GRL_MAJORMINOR@.gi: %-uninstalled.files %-uninstalled.namespace
+	PKG_CONFIG_PATH=$(top_builddir)/:${PKG_CONFIG_PATH} \
+		$(VALA_GEN_INTROSPECT) $*-uninstalled .
+	@mv $*-uninstalled.gi $*- GRL_MAJORMINOR@.gi
+
+%.vapi: %.gi %.metadata %-custom.vala
+	$(VAPIGEN) --library $* \
+		--metadata $(top_srcdir)/bindings/vala/$*.metadata $*.gi \
+		$*-custom.vala
+
+all: $(vapifiles)
+
+EXTRA_DIST = $(depsfiles) $(filesfiles_src) $(nsfiles_src) $(metadatafiles) $(vapifiles)
+CLEANFILES = $(gifiles)
+DISTCLEANFILES = $(vapifiles) $(filesfiles) $(nsfiles)
diff --git a/bindings/vala/grilo-0.1-custom.vala b/bindings/vala/grilo-0.1-custom.vala
new file mode 100644
index 0000000..c43bbb1
--- /dev/null
+++ b/bindings/vala/grilo-0.1-custom.vala
@@ -0,0 +1,103 @@
+namespace Grl {
+	public class Media {
+		public unowned string get_id ();
+		public unowned string get_url ();
+		public unowned string get_author ();
+		public unowned string get_title ();
+		public unowned string get_description ();
+		public unowned string get_source ();
+		public unowned string get_thumbnail ();
+		public unowned string get_site ();
+		public unowned string get_date ();
+		public unowned string get_mime ();
+		public unowned string get_rating ();
+		public int get_duration ();
+
+		public void set_id (string id);
+		public void set_url (string url);
+		public void set_author (string url);
+		public void set_title (string title);
+		public void set_description (string description);
+		public void set_source (string source);
+		public void set_thumbnail (string thumbnail);
+		public void set_site (string site);
+		public void set_duration (int duration);
+		public void set_date (string date);
+		public void set_mime (string mime);
+	}
+
+	[CCode (instance_pos = 2.1)]
+	public delegate void MediaSourceMetadataCb (MediaSource source, Media? media, GLib.Error error);
+	[CCode (instance_pos = 2.1)]
+	public delegate void MediaSourceRemoveCb (MediaSource source, Media? media, GLib.Error error);
+	[CCode (instance_pos = 4.1)]
+	public delegate void MediaSourceResultCb (MediaSource source, uint browse_id, Media? media, uint remaining, GLib.Error? error);
+	[CCode (instance_pos = 4.1)]
+	public delegate void MediaSourceStoreCb (MediaSource source, MediaBox? parent, Media? media, GLib.Error? error);
+	[CCode (instance_pos = 2.1)]
+	public delegate void MetadataSourceResolveCb (MetadataSource source, Media? media, GLib.Error? error);
+
+	[Compact]
+	public class MetadataKey {
+		[CCode (cname ="GRL_METADATA_KEY_ALBUM")]
+		public GLib.ParamSpec ALBUM;
+		[CCode (cname ="GRL_METADATA_KEY_ARTIST")]
+		public GLib.ParamSpec ARTIST;
+		[CCode (cname ="GRL_METADATA_KEY_AUTHOR")]
+		public GLib.ParamSpec AUTHOR;
+		[CCode (cname ="GRL_METADATA_KEY_BITRATE")]
+		public GLib.ParamSpec BITRATE;
+		[CCode (cname ="GRL_METADATA_KEY_CERTIFICATE")]
+		public GLib.ParamSpec CERTIFICATE;
+		[CCode (cname ="GRL_METADATA_KEY_CHILDCOUNT")]
+		public GLib.ParamSpec CHILDCOUNT;
+		[CCode (cname ="GRL_METADATA_KEY_DATE")]
+		public GLib.ParamSpec DATE;
+		[CCode (cname ="GRL_METADATA_KEY_DESCRIPTION")]
+		public GLib.ParamSpec DESCRIPTION;
+		[CCode (cname ="GRL_METADATA_KEY_DURATION")]
+		public GLib.ParamSpec DURATION;
+		[CCode (cname ="GRL_METADATA_KEY_EXTERNAL_PLAYER")]
+		public GLib.ParamSpec EXTERNAL_PLAYER;
+		[CCode (cname ="GRL_METADATA_KEY_EXTERNAL_URL")]
+		public GLib.ParamSpec EXTERNAL_URL;
+		[CCode (cname ="GRL_METADATA_KEY_FRAMERATE")]
+		public GLib.ParamSpec FRAMERATE;
+		[CCode (cname ="GRL_METADATA_KEY_GENRE")]
+		public GLib.ParamSpec GENRE;
+		[CCode (cname ="GRL_METADATA_KEY_HEIGHT")]
+		public GLib.ParamSpec HEIGHT;
+		[CCode (cname ="GRL_METADATA_KEY_ID")]
+		public static GLib.ParamSpec ID;
+		[CCode (cname ="GRL_METADATA_KEY_LAST_PLAYED")]
+		public GLib.ParamSpec LAST_PLAYED;
+		[CCode (cname ="GRL_METADATA_KEY_LAST_POSITION")]
+		public GLib.ParamSpec LAST_POSITION;
+		[CCode (cname ="GRL_METADATA_KEY_LICENSE")]
+		public GLib.ParamSpec LICENSE;
+		[CCode (cname ="GRL_METADATA_KEY_LYRICS")]
+		public GLib.ParamSpec LYRICS;
+		[CCode (cname ="GRL_METADATA_KEY_MIME")]
+		public GLib.ParamSpec MIME;
+		[CCode (cname ="GRL_METADATA_KEY_PLAY_COUNT")]
+		public GLib.ParamSpec PLAY_COUNT;
+		[CCode (cname ="GRL_METADATA_KEY_RATING")]
+		public GLib.ParamSpec RATING;
+		[CCode (cname ="GRL_METADATA_KEY_SITE")]
+		public GLib.ParamSpec SITE;
+		[CCode (cname ="GRL_METADATA_KEY_SOURCE")]
+		public GLib.ParamSpec SOURCE;
+		[CCode (cname ="GRL_METADATA_KEY_STUDIO")]
+		public GLib.ParamSpec STUDIO;
+		[CCode (cname ="GRL_METADATA_KEY_THUMBNAIL")]
+		public GLib.ParamSpec THUMBNAIL;
+		[CCode (cname ="GRL_METADATA_KEY_TITLE")]
+		public static GLib.ParamSpec TITLE;
+		[CCode (cname ="GRL_METADATA_KEY_URL")]
+		public static GLib.ParamSpec URL;
+		[CCode (cname ="GRL_METADATA_KEY_WIDTH")]
+		public GLib.ParamSpec WIDTH;
+
+		public static unowned GLib.List list_new (GLib.ParamSpec p, ...);
+	}
+}
diff --git a/bindings/vala/grilo-0.1/grilo-0.1.metadata b/bindings/vala/grilo-0.1.metadata
similarity index 91%
rename from bindings/vala/grilo-0.1/grilo-0.1.metadata
rename to bindings/vala/grilo-0.1.metadata
index 75c8a56..8f75940 100644
--- a/bindings/vala/grilo-0.1/grilo-0.1.metadata
+++ b/bindings/vala/grilo-0.1.metadata
@@ -6,3 +6,4 @@ GrlMediaSourceRemoveCb hidden="1"
 GrlMediaSourceResultCb hidden="1"
 GrlMediaSourceStoreCb hidden="1"
 GrlMetadataSourceResolveCb hidden="1"
+grl_list_from_va ellipsis="1"
diff --git a/bindings/vala/grilo-0.1/grilo-0.1.defines b/bindings/vala/grilo-uninstalled.defines
similarity index 100%
rename from bindings/vala/grilo-0.1/grilo-0.1.defines
rename to bindings/vala/grilo-uninstalled.defines
diff --git a/tools/vala/grilo-test.vala b/tools/vala/grilo-test.vala
index 6e0bc7f..e5b1f11 100644
--- a/tools/vala/grilo-test.vala
+++ b/tools/vala/grilo-test.vala
@@ -64,7 +64,7 @@ public class SimplePlaylist : Object {
 	}
 
 	public void search (string q) {
-		unowned GLib.List keys = Grl.MetadataKey.list_new (Grl.METADATA_KEY_ID, Grl.METADATA_KEY_TITLE, Grl.METADATA_KEY_URL);
+		unowned GLib.List keys = Grl.MetadataKey.list_new (Grl.MetadataKey.ID, Grl.MetadataKey.TITLE, Grl.MetadataKey.URL);
 
 		foreach (MediaSource source in source_list) {
 			debug ("%s - %s", source.get_name (), q);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]