Re: [Vala] evangelise talloc for vala memory management

2008-07-15 Thread Sam Liddicott
I've re-read the vala docs on weak references and ownership transfer:
http://live.gnome.org/Vala/Tutorial#head-e667accbcd04f19dd6a2c14a68e22b3cc2179e58

The reference counting that vala supports is only for gobject; which
is fine, but the glib vapi file shows that this is done by the vapi file
and not by vala as such.

[CCode (ref_function = g_object_ref, unref_function =
g_object_unref, marshaller_type_name = OBJECT, get_value_function =
g_value_get_object, set_value_function = g_value_set_object,
cheader_filename = glib-object.h)]

I'll want to introduce a new object base for Samba4 that uses talloc
functions to do this, and it looks like I can; and so I plan to, but I
invite wiser folk to comment first:

1. are these CCode attributes inherited to subclasses?
2. are their any secrets pertaining to the C code generated by '#' and
'weak' and the CCode attributes above that would be helpful for me to know?
3. what does get_value_function do, and what Vala code makes use of it?
4. do I need to worry about *marshaller_type_name*?

Thanks

Sam
___
Vala-list mailing list
Vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] evangelise talloc for vala memory management

2008-07-15 Thread Jürg Billeter
On Tue, 2008-07-15 at 11:05 +0100, Sam Liddicott wrote:
 The reference counting that vala supports is only for gobject; which
 is fine, but the glib vapi file shows that this is done by the vapi
 file and not by vala as such.
 
 [CCode (ref_function = g_object_ref, unref_function =
 g_object_unref, marshaller_type_name = OBJECT, get_value_function
 = g_value_get_object, set_value_function = g_value_set_object,
 cheader_filename = glib-object.h)]
 
 I'll want to introduce a new object base for Samba4 that uses talloc
 functions to do this, and it looks like I can; and so I plan to, but I
 invite wiser folk to comment first:
 
 1. are these CCode attributes inherited to subclasses?

Yes, memory management functions are inherited.

 2. are their any secrets pertaining to the C code generated by '#' and
 'weak' and the CCode attributes above that would be helpful for me to
 know?

In general, `weak` and `#` is not visible in the generated C code,
except for the actual memory management calls, of course.

 3. what does get_value_function do, and what Vala code makes use of
 it?

That's used if you want to use instances of the class as a GValue, e.g.
that's needed for GObject properties. Can usually be avoided in
non-GObject bindings.

 4. do I need to worry about marshaller_type_name?

That's mainly used for signals parameters. If you don't want to use your
objects as signal arguments, you don't need that.

Juerg

___
Vala-list mailing list
Vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list