----- Original Message -----

> From: Olivier Duchateau <duchateau.oliv...@gmail.com>
> Sent: Friday, 30 December 2016, 14:24
> Subject: [Vala] Iterate in VAPI bindings


> I'm trying to write Vala bindings for pkg(8), FreeBSD's packages manager. 

> But I encounter weird behaviour in while loop.
> Currently I try to display name of repositories (FreeBSD and Xfce).


> My simple C program [1] works fine (expected result). If I use same
> while loop in my Vala program, I get an infinite loop. So I use for loop [2], 

> but it's only FreeBSD which is displayed. I wonder how to iterate in loop.

The signature from 
https://github.com/freebsd/pkg/blob/1.9.4/libpkg/pkg.h.in#L1503 is:
int pkg_repos(struct pkg_repo **);

So I was going to suggest an array, but looking at the Python bindings 

( https://github.com/dnaeon/py-pkg/blob/master/src/pkg-repo.pxi ) it looks as 
though
you need to bind it as an iterator. The Vala binding will look fairly similar
to the Python one in that you create an iterator object and a next_value method.

By the way, enums in a VAPI shouldn't have values assigned to them.

All the best,

Al
_______________________________________________
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to