Re: [Vala] Quick Question about parameter handling





On 3/10/07, Jürg Billeter <j bitron ch> wrote:
On Sam, 2007-03-10 at 15:49 +0100, Zsombor wrote:
>  I'm trying to create a vapi file for gnome-keyring, mapping most of
> the functions are easy, but unfortunately there is a lots of methods,
> which expects some 'out' parameters, and i can't figure out, how to do
> that:

It's in general similar to C#, use 'ref' for value types like int and
'out' for reference types.

> For example:
> GnomeKeyringResult gnome_keyring_get_default_keyring_sync (char
> **keyring);

KeyringResult get_default_keyring_sync (out string keyring);

> or
> GnomeKeyringResult gnome_keyring_list_keyring_names_sync  (GList
> **keyrings);

KeyringResult list_keyring_names_sync (out List<...> keyrings);

Jürg


This is what I've tried, but it doesn't works with the 0.0.7 version.
From this:

string defKeyring = null;
Gnome.Keyring.get_default_keyring_sync (defKeyring);
stdout.printf("default keyring is %s\n",defKeyring);

It compiled to:

char* defKeyring = NULL;
gnome_keyring_get_default_keyring_sync (defKeyring);
fprintf (stdout, "default keyring is %s\n", defKeyring);

Instead of :
char* defKeyring = NULL;
gnome_keyring_get_default_keyring_sync (&defKeyring);
fprintf (stdout, "default keyring is %s\n", defKeyring);

Similar thing happens with the  list_keyring_names_sync (out List<string> keyrings) method.
I've attached the keyring.vapi file and the test code.

BR,
  Zsombor



Attachment: keyring.vala
Description: Binary data

Attachment: keyring-test.vala
Description: Binary data



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