[libvirt] [libvirt-glib] [PATCH 0/3] minor improvements towards Vala usage

Hi. I'm currently evaluating libvirt-glib using the Vala bindings. I found a few obstacles on the way. Here are some patches. Claudio Bley (3): Fix typo in gvir_config_init's comment Add "transfer none" annotation to argv parameter gvir_stream_receive: annotate buffer parameter with "element-type guint8" libvirt-gconfig/libvirt-gconfig-main.c | 6 +++--- libvirt-glib/libvirt-glib-main.c | 4 ++-- libvirt-gobject/libvirt-gobject-stream.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) -- 1.7.11.7

This broke the generated Vala API. Signed-off-by: Claudio Bley <cbley@av-test.de> --- libvirt-gconfig/libvirt-gconfig-main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvirt-gconfig/libvirt-gconfig-main.c b/libvirt-gconfig/libvirt-gconfig-main.c index fa1963c..32e5777 100644 --- a/libvirt-gconfig/libvirt-gconfig-main.c +++ b/libvirt-gconfig/libvirt-gconfig-main.c @@ -31,7 +31,7 @@ #include "libvirt-gconfig/libvirt-gconfig-compat.h" /** - * gvirt_config_init: + * gvir_config_init: * @argc: (inout): pointer to application's argc * @argv: (inout) (array length=argc) (allow-none): pointer to application's argv */ -- 1.7.11.7

This makes the parameter to be passed "unowned" in Vala. Signed-off-by: Claudio Bley <cbley@av-test.de> --- libvirt-gconfig/libvirt-gconfig-main.c | 4 ++-- libvirt-glib/libvirt-glib-main.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-main.c b/libvirt-gconfig/libvirt-gconfig-main.c index 32e5777..043a402 100644 --- a/libvirt-gconfig/libvirt-gconfig-main.c +++ b/libvirt-gconfig/libvirt-gconfig-main.c @@ -33,7 +33,7 @@ /** * gvir_config_init: * @argc: (inout): pointer to application's argc - * @argv: (inout) (array length=argc) (allow-none): pointer to application's argv + * @argv: (inout) (array length=argc) (allow-none) (transfer none): pointer to application's argv */ void gvir_config_init(int *argc, char ***argv) @@ -58,7 +58,7 @@ static void gvir_log_handler(const gchar *log_domain G_GNUC_UNUSED, /** * gvir_config_init_check: * @argc: (inout): pointer to application's argc - * @argv: (inout) (array length=argc) (allow-none): pointer to application's argv + * @argv: (inout) (array length=argc) (allow-none) (transfer none): pointer to application's argv * @err: pointer to a #GError to which a message will be posted on error */ gboolean gvir_config_init_check(int *argc G_GNUC_UNUSED, diff --git a/libvirt-glib/libvirt-glib-main.c b/libvirt-glib/libvirt-glib-main.c index 3389de9..f33ee4a 100644 --- a/libvirt-glib/libvirt-glib-main.c +++ b/libvirt-glib/libvirt-glib-main.c @@ -72,7 +72,7 @@ gvir_error_func(gpointer opaque G_GNUC_UNUSED, * gvir_init: * @argc: (inout): Address of the argc parameter of your main() function (or 0 * if argv is NULL). This will be changed if any arguments were handled. - * @argv: (array length=argc) (inout) (allow-none): Address of the + * @argv: (array length=argc) (inout) (allow-none) (transfer none): Address of the * <parameter>argv</parameter> parameter of main(), or %NULL. Any options * understood by GTK+ are stripped before return. * @@ -119,7 +119,7 @@ static void gvir_log_handler(const gchar *log_domain G_GNUC_UNUSED, * gvir_init_check: * @argc: (inout): Address of the argc parameter of your main() function (or 0 * if argv is NULL). This will be changed if any arguments were handled. - * @argv: (array length=argc) (inout) (allow-none): Address of the + * @argv: (array length=argc) (inout) (allow-none) (transfer none): Address of the * <parameter>argv</parameter> parameter of main(), or %NULL. Any options * understood by GTK+ are stripped before return. * @err: filled with the error information if initialized failed. -- 1.7.11.7

Vala automatically regards parameters as strings when an array of char is used. We need to prevent this as the data given is an array of octets ie. arbitrary data, not chars. Signed-off-by: Claudio Bley <cbley@av-test.de> --- libvirt-gobject/libvirt-gobject-stream.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-stream.c b/libvirt-gobject/libvirt-gobject-stream.c index 2cb8967..4b3749b 100644 --- a/libvirt-gobject/libvirt-gobject-stream.c +++ b/libvirt-gobject/libvirt-gobject-stream.c @@ -283,8 +283,8 @@ G_DEFINE_BOXED_TYPE(GVirStreamHandle, gvir_stream_handle, /** * gvir_stream_receive: * @stream: the stream - * @buffer: a buffer to read data into (which should be at least @size - * bytes long). + * @buffer: (array length=size) (element-type guint8): a buffer + * to read data into (which should be at least @size bytes long). * @size: the number of bytes you want to read from the stream * @cancellable: (allow-none): a %GCancellable or %NULL * @error: #GError for error reporting, or %NULL to ignore. -- 1.7.11.7

On Wed, Feb 06, 2013 at 04:53:15PM +0100, Claudio Bley wrote:
Hi.
I'm currently evaluating libvirt-glib using the Vala bindings.
I found a few obstacles on the way. Here are some patches.
Claudio Bley (3): Fix typo in gvir_config_init's comment Add "transfer none" annotation to argv parameter gvir_stream_receive: annotate buffer parameter with "element-type guint8"
libvirt-gconfig/libvirt-gconfig-main.c | 6 +++--- libvirt-glib/libvirt-glib-main.c | 4 ++-- libvirt-gobject/libvirt-gobject-stream.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-)
ACK to all 3 Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

At Wed, 6 Feb 2013 16:11:56 +0000, Daniel P. Berrange wrote:
On Wed, Feb 06, 2013 at 04:53:15PM +0100, Claudio Bley wrote:
Hi.
I'm currently evaluating libvirt-glib using the Vala bindings.
I found a few obstacles on the way. Here are some patches.
Claudio Bley (3): Fix typo in gvir_config_init's comment Add "transfer none" annotation to argv parameter gvir_stream_receive: annotate buffer parameter with "element-type guint8"
libvirt-gconfig/libvirt-gconfig-main.c | 6 +++--- libvirt-glib/libvirt-glib-main.c | 4 ++-- libvirt-gobject/libvirt-gobject-stream.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-)
ACK to all 3
Thanks, pushed. Should I add myself to the AUTHORS file? You don't keep the patches-received-by list sorted, do you? -- AV-Test GmbH, Henricistraße 20, 04155 Leipzig, Germany Phone: +49 341 265 310 19 Web:<http://www.av-test.org> Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076) Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern

On Thu, Feb 07, 2013 at 04:28:54PM +0100, Claudio Bley wrote:
At Wed, 6 Feb 2013 16:11:56 +0000, Daniel P. Berrange wrote:
On Wed, Feb 06, 2013 at 04:53:15PM +0100, Claudio Bley wrote:
Hi.
I'm currently evaluating libvirt-glib using the Vala bindings.
I found a few obstacles on the way. Here are some patches.
Claudio Bley (3): Fix typo in gvir_config_init's comment Add "transfer none" annotation to argv parameter gvir_stream_receive: annotate buffer parameter with "element-type guint8"
libvirt-gconfig/libvirt-gconfig-main.c | 6 +++--- libvirt-glib/libvirt-glib-main.c | 4 ++-- libvirt-gobject/libvirt-gobject-stream.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-)
ACK to all 3
Thanks, pushed.
Should I add myself to the AUTHORS file? You don't keep the patches-received-by list sorted, do you?
In theory it should be sorted, but don't worry. It is on my todo list to make AUTHORS file auto-generated as with libvirt Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (2)
-
Claudio Bley
-
Daniel P. Berrange