vala: Add custom overrides for e_contact_[get|get_const|set]()
authorPhilip Withnall <philip@tecnocode.co.uk>
Mon, 25 Jun 2012 20:43:35 +0000 (21:43 +0100)
committerPhilip Withnall <philip@tecnocode.co.uk>
Mon, 25 Jun 2012 20:43:35 +0000 (21:43 +0100)
They were using void* in Vala, which is generally a bad idea. In this case,
it was resulting in unavoidable memory leaks in libfolks (bug #678781).

This changes the functions to be simple generics instead.

vala/EBook-1.2.metadata
vala/Makefile.am
vala/libebook-1.2-custom.vala [new file with mode: 0644]

index 0a46e29..a1ec350 100644 (file)
@@ -4,6 +4,9 @@ BookView.contacts_changed#signal.object type="GLib.List<weak void*>"
 BookClientView.objects_added#signal.object type="GLib.List<weak void*>"
 BookClientView.objects_removed#signal.object type="GLib.List<weak void*>"
 BookClientView.objects_modified#signal.object type="GLib.List<weak void*>"
+Contact.get skip
+Contact.get_const skip
+Contact.set skip
 ContactName.family unowned=false
 ContactName.given unowned=false
 ContactName.additional unowned=false
index 3c35ede..33928f4 100644 (file)
@@ -11,6 +11,7 @@ dist_vapi_DATA = \
 
 EXTRA_DIST = \
        EBook-1.2.metadata \
+       libebook-1.2-custom.vala \
        ECalendar-1.2.metadata \
        EDataServer-1.2.metadata \
        $(NULL)
@@ -48,7 +49,7 @@ libecalendar-1.2.vapi: $(top_builddir)/calendar/libecal/ECalendar-1.2.gir libeda
                $< \
                $(NULL)
 
-libebook-1.2.vapi: $(top_builddir)/addressbook/libebook/EBook-1.2.gir libedataserver-1.2.vapi
+libebook-1.2.vapi: $(top_builddir)/addressbook/libebook/EBook-1.2.gir libedataserver-1.2.vapi libebook-1.2-custom.vala
        $(VAPIGEN_V)$(VAPIGEN) \
                --vapidir=. \
                --girdir=$(top_builddir)/libedataserver \
@@ -57,6 +58,7 @@ libebook-1.2.vapi: $(top_builddir)/addressbook/libebook/EBook-1.2.gir libedatase
                --library libebook-1.2 \
                --metadatadir=$(srcdir) \
                $< \
+               libebook-1.2-custom.vala \
                $(NULL)
 
 CLEANFILES = \
diff --git a/vala/libebook-1.2-custom.vala b/vala/libebook-1.2-custom.vala
new file mode 100644 (file)
index 0000000..8e6937f
--- /dev/null
@@ -0,0 +1,12 @@
+/* Custom vapi needed because bgo#666797 prevents generics being exposed in the .metadata file. */
+namespace E {
+       [CCode (type_id = "e_contact_get_type ()")]
+       public class Contact : E.VCard {
+               [CCode (simple_generics = true)]
+               public T? @get<T> (E.ContactField field_id);
+               [CCode (simple_generics = true)]
+               public unowned T? get_const<T> (E.ContactField field_id);
+               [CCode (simple_generics = true)]
+               public void @set<T> (E.ContactField field_id, T value);
+       }
+}