From 993a871767cee5204e5c8a23760dea052b60db66 Mon Sep 17 00:00:00 2001 From: Juerg Billeter Date: Fri, 31 Aug 2007 09:44:28 +0000 Subject: [PATCH] use G_TYPE_POINTER for not registered classes, add has_type_id attribute 2007-08-31 Juerg Billeter * vala/valaclass.vala, vala/valastruct.vala: use G_TYPE_POINTER for not registered classes, add has_type_id attribute * vapigen/valagidlparser.vala: use GLib.Boxed as base type of boxed types * vapi/glib-2.0.vala: use has_type_id attribute and GLib.Boxed * vapi/gconf-2.0.vala, vapi/gdk-2.0.vala, vapi/gnome-desktop-2.0.vala, vapi/gnome-vfs-2.0.vala, vapi/gstreamer-0.10.vala, vapi/gtk+-2.0.vala, vapi/libglade-2.0.vala, vapi/libgnome-2.0.vala, vapi/libsoup-2.2.vala, vapi/pango.vala, vapi/poppler-glib.vala: regenerated svn path=/trunk/; revision=550 --- ChangeLog | 15 +++++++++++++++ vala/valaclass.vala | 14 +++++++++++++- vala/valastruct.vala | 6 +----- vapi/gconf-2.0.vala | 6 +++--- vapi/gdk-2.0.vala | 9 ++++----- vapi/glib-2.0.vala | 27 +++++++++++++-------------- vapi/gnome-desktop-2.0.vala | 2 +- vapi/gnome-vfs-2.0.vala | 14 +++++--------- vapi/gstreamer-0.10.vala | 19 +++++++++---------- vapi/gtk+-2.0.vala | 34 +++++++++++++++++----------------- vapi/libglade-2.0.vala | 3 +-- vapi/libgnome-2.0.vala | 2 +- vapi/libsoup-2.2.vala | 5 ++--- vapi/pango.vala | 32 +++++++++++++++----------------- vapi/poppler-glib.vala | 16 ++++++++-------- vapigen/valagidlparser.vala | 25 ++++++++++++++++++++++--- 16 files changed, 130 insertions(+), 99 deletions(-) diff --git a/ChangeLog b/ChangeLog index 686f01e..f61bc8f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2007-08-31 Jürg Billeter + + * vala/valaclass.vala, vala/valastruct.vala: use G_TYPE_POINTER for + not registered classes, add has_type_id attribute + + * vapigen/valagidlparser.vala: use GLib.Boxed as base type of boxed + types + + * vapi/glib-2.0.vala: use has_type_id attribute and GLib.Boxed + + * vapi/gconf-2.0.vala, vapi/gdk-2.0.vala, vapi/gnome-desktop-2.0.vala, + vapi/gnome-vfs-2.0.vala, vapi/gstreamer-0.10.vala, vapi/gtk+-2.0.vala, + vapi/libglade-2.0.vala, vapi/libgnome-2.0.vala, vapi/libsoup-2.2.vala, + vapi/pango.vala, vapi/poppler-glib.vala: regenerated + 2007-08-30 Mathias Hasselmann * vapi/packages/gtksourceview-2.0/gtksourceview-2.0.metadata: diff --git a/vala/valaclass.vala b/vala/valaclass.vala index 1f128a8..627aebc 100644 --- a/vala/valaclass.vala +++ b/vala/valaclass.vala @@ -57,6 +57,7 @@ public class Vala.Class : DataType { private string const_cname; private string lower_case_cprefix; private string lower_case_csuffix; + private bool has_type_id; private string type_id; private string ref_function; private string unref_function; @@ -397,6 +398,9 @@ public class Vala.Class : DataType { if (a.has_argument ("free_function")) { set_free_function (a.get_string ("free_function")); } + if (a.has_argument ("has_type_id")) { + has_type_id = a.get_bool ("has_type_id"); + } if (a.has_argument ("type_id")) { type_id = a.get_string ("type_id"); } @@ -441,9 +445,17 @@ public class Vala.Class : DataType { } } + private bool get_has_type_id () { + return has_type_id || (base_class != null && base_class.get_has_type_id ()); + } + public override string get_type_id () { if (type_id == null) { - type_id = get_upper_case_cname ("TYPE_"); + if (get_has_type_id ()) { + type_id = get_upper_case_cname ("TYPE_"); + } else { + type_id = "G_TYPE_POINTER"; + } } return type_id; diff --git a/vala/valastruct.vala b/vala/valastruct.vala index 7c9a851..b6458fc 100644 --- a/vala/valastruct.vala +++ b/vala/valastruct.vala @@ -291,11 +291,7 @@ public class Vala.Struct : DataType { public override string get_type_id () { if (type_id == null) { - if (is_reference_type ()) { - type_id = "G_TYPE_POINTER"; - } else { - Report.error (source_reference, "The type `%s` doesn't declare a type id".printf (get_full_name ())); - } + Report.error (source_reference, "The type `%s` doesn't declare a type id".printf (get_full_name ())); } return type_id; } diff --git a/vapi/gconf-2.0.vala b/vapi/gconf-2.0.vala index 5b1af22..f1b3921 100644 --- a/vapi/gconf-2.0.vala +++ b/vapi/gconf-2.0.vala @@ -121,7 +121,7 @@ namespace GConf { public ulong vtable_size; } [CCode (ref_function = "gconf_change_set_ref", unref_function = "gconf_change_set_unref", cheader_filename = "gconf/gconf.h")] - public class ChangeSet { + public class ChangeSet : GLib.Boxed { public bool check_value (string key, GConf.Value value_retloc); public void clear (); public void @foreach (GConf.ChangeSetForeachFunc func, pointer user_data); @@ -247,7 +247,7 @@ namespace GConf { public void set_mod_user (string mod_user); public void set_schema (string schema_name); } - [CCode (cheader_filename = "gconf/gconf.h")] + [CCode (copy_function = "gconf_schema_copy", cheader_filename = "gconf/gconf.h")] public class Schema { public weak GConf.Schema copy (); public GConf.ValueType get_car_type (); @@ -305,7 +305,7 @@ namespace GConf { public weak GConf.Sources modified_sources; public weak string key; } - [CCode (cheader_filename = "gconf/gconf.h")] + [CCode (copy_function = "gconf_value_copy", cheader_filename = "gconf/gconf.h")] public class Value { public GConf.ValueType type; public int compare (GConf.Value value_b); diff --git a/vapi/gdk-2.0.vala b/vapi/gdk-2.0.vala index 671fcdd..97131c7 100644 --- a/vapi/gdk-2.0.vala +++ b/vapi/gdk-2.0.vala @@ -1163,7 +1163,7 @@ namespace Gdk { public static weak Gdk.Bitmap create_from_data (Gdk.Drawable drawable, string data, int width, int height); } [CCode (ref_function = "gdk_cursor_ref", unref_function = "gdk_cursor_unref", cheader_filename = "gdk/gdk.h")] - public class Cursor { + public class Cursor : GLib.Boxed { public Gdk.CursorType type; public weak Gdk.Display get_display (); public weak Gdk.Pixbuf get_image (); @@ -1391,7 +1391,7 @@ namespace Gdk { public Gdk.WindowState new_window_state; } [CCode (ref_function = "gdk_font_ref", unref_function = "gdk_font_unref", cheader_filename = "gdk/gdk.h")] - public class Font { + public class Font : GLib.Boxed { public Gdk.FontType type; public int ascent; public int descent; @@ -1517,14 +1517,13 @@ namespace Gdk { [CCode (cheader_filename = "gdk/gdk.h")] public class PointerHooks { } - [CCode (cheader_filename = "gdk/gdk.h")] + [CCode (copy_function = "gdk_region_copy", free_function = "gdk_region_destroy", cheader_filename = "gdk/gdk.h")] public class Region { public long size; public long numRects; public weak Gdk.RegionBox rects; public weak Gdk.RegionBox extents; public weak Gdk.Region copy (); - public void destroy (); public bool empty (); public bool equal (Gdk.Region region2); public void get_clipbox (out Gdk.Rectangle rectangle); @@ -1665,7 +1664,7 @@ namespace Gdk { public static int trap_pop (); public static void trap_push (); } - [CCode (cheader_filename = "gdk/gdk.h")] + [CCode (copy_function = "gdk_event_copy", cheader_filename = "gdk/gdk.h")] public class Event { public weak Gdk.Event copy (); public static weak Gdk.Event get (); diff --git a/vapi/glib-2.0.vala b/vapi/glib-2.0.vala index b803eb5..2d4a080 100644 --- a/vapi/glib-2.0.vala +++ b/vapi/glib-2.0.vala @@ -575,6 +575,7 @@ namespace GLib { } + [CCode (has_type_id = true)] public class TypeInstance { } @@ -652,9 +653,8 @@ namespace GLib { public class InitiallyUnowned : Object { } - public /* static */ interface Boxed { - public abstract G copy (); - public abstract void free (); + [CCode (cname = "gpointer", has_type_id = true, type_id = "G_TYPE_BOXED", marshaller_type_name = "BOXED", get_value_function = "g_value_get_boxed", set_value_function = "g_value_set_boxed")] + public abstract class Boxed { } [CCode (free_function = "g_free", type_id = "G_TYPE_VALUE")] @@ -739,8 +739,7 @@ namespace GLib { public static delegate void Callback (); - [CCode (type_id = "G_TYPE_CLOSURE")] - public class Closure { + public class Closure : Boxed { } public static delegate void ClosureNotify (pointer data, Closure closure); @@ -1175,8 +1174,8 @@ namespace GLib { /* IO Channels */ - [CCode (ref_function = "g_io_channel_ref", unref_function = "g_io_channel_unref", type_id = "G_TYPE_IO_CHANNEL")] - public class IOChannel { + [CCode (ref_function = "g_io_channel_ref", unref_function = "g_io_channel_unref")] + public class IOChannel : Boxed { public IOChannel.file (string! filename, string! mode) throws FileError; [CCode (cname = "g_io_channel_unix_new")] public IOChannel.unix_new (int fd); @@ -1398,8 +1397,8 @@ namespace GLib { public bool valid (); } - [CCode (free_function = "g_date_free", type_id = "G_TYPE_DATE")] - public class Date { + [CCode (free_function = "g_date_free")] + public class Date : Boxed { public Date (); public Date.dmy (DateDay day, DateMonth month, DateYear year); public Date.julian (uint julian_day); @@ -1862,8 +1861,8 @@ namespace GLib { NEWLINE_ANY } - [CCode (ref_function = "g_regex_ref", unref_function = "g_regex_unref", type_id = "G_TYPE_REGEX")] - public class Regex { + [CCode (ref_function = "g_regex_ref", unref_function = "g_regex_unref")] + public class Regex : Boxed { public Regex (string! pattern, RegexCompileFlags compile_options = 0, RegexMatchFlags match_options = 0) throws RegexError; public string! get_pattern (); public int get_max_backref (); @@ -2155,8 +2154,8 @@ namespace GLib { /* Hash Tables */ - [CCode (ref_function = "g_hash_table_ref", unref_function = "g_hash_table_unref", type_id = "G_TYPE_HASH_TABLE")] - public class HashTable { + [CCode (ref_function = "g_hash_table_ref", unref_function = "g_hash_table_unref")] + public class HashTable : Boxed { public HashTable (HashFunc hash_func, EqualFunc key_equal_func); public HashTable.full (HashFunc hash_func, EqualFunc key_equal_func, DestroyNotify key_destroy_func, DestroyNotify value_destroy_func); public void insert (K# key, V# value); @@ -2193,7 +2192,7 @@ namespace GLib { /* Strings */ [CCode (free_function = "g_string_free", type_id = "G_TYPE_GSTRING")] - public class String { + public class String : Boxed { public String (string init = ""); [CCode (cname = "g_string_sized_new")] public String.sized (ulong dfl_size); diff --git a/vapi/gnome-desktop-2.0.vala b/vapi/gnome-desktop-2.0.vala index 05d7477..b334469 100644 --- a/vapi/gnome-desktop-2.0.vala +++ b/vapi/gnome-desktop-2.0.vala @@ -57,7 +57,7 @@ namespace Gnome { public class Hint : Gtk.Dialog { } [CCode (ref_function = "gnome_desktop_item_ref", unref_function = "gnome_desktop_item_unref", cheader_filename = "libgnome/gnome-desktop-item.h")] - public class DesktopItem { + public class DesktopItem : GLib.Boxed { public bool attr_exists (string attr); public void clear_localestring (string attr); public void clear_section (string section); diff --git a/vapi/gnome-vfs-2.0.vala b/vapi/gnome-vfs-2.0.vala index dcc971f..a1af708 100644 --- a/vapi/gnome-vfs-2.0.vala +++ b/vapi/gnome-vfs-2.0.vala @@ -466,7 +466,7 @@ namespace GnomeVFS { public signal void drive_disconnected (GnomeVFS.Drive drive); } [CCode (cheader_filename = "libgnomevfs/gnome-vfs.h")] - public class Address { + public class Address : GLib.Boxed { public weak GnomeVFS.Address dup (); public bool equal (GnomeVFS.Address b); public int get_family_type (); @@ -480,12 +480,11 @@ namespace GnomeVFS { [CCode (cheader_filename = "libgnomevfs/gnome-vfs.h")] public class AsyncHandle { } - [CCode (cheader_filename = "libgnomevfs/gnome-vfs.h")] + [CCode (free_function = "gnome_vfs_cancellation_destroy", cheader_filename = "libgnomevfs/gnome-vfs.h")] public class Cancellation { public void ack (); public void cancel (); public bool check (); - public void destroy (); public int get_fd (); public Cancellation (); } @@ -651,7 +650,6 @@ namespace GnomeVFS { public class InetConnection { public GnomeVFS.Result create (string host_name, uint host_port, GnomeVFS.Cancellation cancellation); public GnomeVFS.Result create_from_address (GnomeVFS.Address address, uint host_port, GnomeVFS.Cancellation cancellation); - public void destroy (GnomeVFS.Cancellation cancellation); public weak GnomeVFS.Address get_address (); public int get_fd (); public weak string get_ip (); @@ -676,7 +674,7 @@ namespace GnomeVFS { public weak GLib.List list; public uint entries_read; } - [CCode (cheader_filename = "libgnomevfs/gnome-vfs.h")] + [CCode (copy_function = "gnome_vfs_mime_application_copy", cheader_filename = "libgnomevfs/gnome-vfs.h")] public class MimeApplication { public weak string id; public weak string name; @@ -911,11 +909,10 @@ namespace GnomeVFS { [CCode (cheader_filename = "libgnomevfs/gnome-vfs.h")] public class ResolveHandle { } - [CCode (cheader_filename = "libgnomevfs/gnome-vfs.h")] + [CCode (free_function = "gnome_vfs_ssl_destroy", cheader_filename = "libgnomevfs/gnome-vfs.h")] public class SSL { public GnomeVFS.Result create (string host, uint port, GnomeVFS.Cancellation cancellation); public GnomeVFS.Result create_from_fd (int fd, GnomeVFS.Cancellation cancellation); - public void destroy (GnomeVFS.Cancellation cancellation); public static bool enabled (); public GnomeVFS.Result read (pointer buffer, GnomeVFS.FileSize bytes, out GnomeVFS.FileSize bytes_read, GnomeVFS.Cancellation cancellation); public GnomeVFS.Result set_timeout (out GLib.TimeVal timeout, GnomeVFS.Cancellation cancellation); @@ -955,9 +952,8 @@ namespace GnomeVFS { public GnomeVFS.Result read (pointer buffer, GnomeVFS.FileSize bytes, out GnomeVFS.FileSize bytes_read, GnomeVFS.Cancellation cancellation); public GnomeVFS.Result write (pointer buffer, int bytes, out GnomeVFS.FileSize bytes_written, GnomeVFS.Cancellation cancellation); } - [CCode (cheader_filename = "libgnomevfs/gnome-vfs.h")] + [CCode (free_function = "gnome_vfs_socket_buffer_destroy", cheader_filename = "libgnomevfs/gnome-vfs.h")] public class SocketBuffer { - public GnomeVFS.Result destroy (bool close_socket, GnomeVFS.Cancellation cancellation); public GnomeVFS.Result flush (GnomeVFS.Cancellation cancellation); public SocketBuffer (GnomeVFS.Socket socket); public GnomeVFS.Result peekc (string character, GnomeVFS.Cancellation cancellation); diff --git a/vapi/gstreamer-0.10.vala b/vapi/gstreamer-0.10.vala index 751afb9..fdbe586 100644 --- a/vapi/gstreamer-0.10.vala +++ b/vapi/gstreamer-0.10.vala @@ -1209,7 +1209,7 @@ namespace Gst { public class BinaryTypeFindFactory { } [CCode (ref_function = "gst_caps_ref", unref_function = "gst_caps_unref", cheader_filename = "gst/gst.h")] - public class Caps { + public class Caps : GLib.Boxed { public GLib.Type type; public int refcount; public Gst.CapsFlags flags; @@ -1286,8 +1286,8 @@ namespace Gst { public Gst.Format format; public int64 value; } - [CCode (cheader_filename = "gst/gst.h")] - public class IndexEntry { + [CCode (copy_function = "gst_index_entry_copy", cheader_filename = "gst/gst.h")] + public class IndexEntry : GLib.Boxed { public bool assoc_map (Gst.Format format, int64 value); public weak Gst.IndexEntry copy (); public static GLib.Type get_type (); @@ -1336,7 +1336,7 @@ namespace Gst { public GLib.Quark quark; } [CCode (cheader_filename = "gst/gst.h")] - public class Segment { + public class Segment : GLib.Boxed { public double rate; public double abs_rate; public Gst.Format format; @@ -1377,8 +1377,8 @@ namespace Gst { public weak Gst.Caps get_caps (); public static GLib.Type get_type (); } - [CCode (cheader_filename = "gst/gst.h")] - public class Structure { + [CCode (copy_function = "gst_structure_copy", cheader_filename = "gst/gst.h")] + public class Structure : GLib.Boxed { public GLib.Type type; public weak Gst.Structure copy (); public static weak Gst.Structure empty_new (string name); @@ -1426,8 +1426,8 @@ namespace Gst { public void set_value (string fieldname, GLib.Value value); public weak string to_string (); } - [CCode (cheader_filename = "gst/gst.h")] - public class TagList { + [CCode (copy_function = "gst_tag_list_copy", cheader_filename = "gst/gst.h")] + public class TagList : GLib.Boxed { public GLib.Type type; public void add (Gst.TagMergeMode mode, string tag); public void add_valist (Gst.TagMergeMode mode, string tag, pointer var_args); @@ -1475,9 +1475,8 @@ namespace Gst { public TagList (); public void remove_tag (string tag); } - [CCode (cheader_filename = "gst/gst.h")] + [CCode (free_function = "gst_trace_destroy", cheader_filename = "gst/gst.h")] public class Trace { - public void destroy (); public void flush (); public Trace (string filename, int size); public static void read_tsc (int64 dst); diff --git a/vapi/gtk+-2.0.vala b/vapi/gtk+-2.0.vala index 43a9ba0..2a7464e 100644 --- a/vapi/gtk+-2.0.vala +++ b/vapi/gtk+-2.0.vala @@ -5058,8 +5058,8 @@ namespace Gtk { public weak string domain_dirname; public weak string default_locales; } - [CCode (cheader_filename = "gtk/gtk.h")] - public class IconInfo { + [CCode (copy_function = "gtk_icon_info_copy", cheader_filename = "gtk/gtk.h")] + public class IconInfo : GLib.Boxed { public weak Gtk.IconInfo copy (); [NoArrayLength] public bool get_attach_points (Gdk.Point[] points, int n_points); @@ -5073,7 +5073,7 @@ namespace Gtk { public void set_raw_coordinates (bool raw_coordinates); } [CCode (ref_function = "gtk_icon_set_ref", unref_function = "gtk_icon_set_unref", cheader_filename = "gtk/gtk.h")] - public class IconSet { + public class IconSet : GLib.Boxed { public void add_source (Gtk.IconSource source); public weak Gtk.IconSet copy (); [NoArrayLength] @@ -5083,8 +5083,8 @@ namespace Gtk { public IconSet.from_pixbuf (Gdk.Pixbuf pixbuf); public weak Gdk.Pixbuf render_icon (Gtk.Style style, Gtk.TextDirection direction, Gtk.StateType state, Gtk.IconSize size, Gtk.Widget widget, string detail); } - [CCode (cheader_filename = "gtk/gtk.h")] - public class IconSource { + [CCode (copy_function = "gtk_icon_source_copy", cheader_filename = "gtk/gtk.h")] + public class IconSource : GLib.Boxed { public weak Gtk.IconSource copy (); public Gtk.TextDirection get_direction (); public bool get_direction_wildcarded (); @@ -5165,8 +5165,8 @@ namespace Gtk { public int start; public int end; } - [CCode (cheader_filename = "gtk/gtk.h")] - public class PaperSize { + [CCode (copy_function = "gtk_paper_size_copy", cheader_filename = "gtk/gtk.h")] + public class PaperSize : GLib.Boxed { public weak Gtk.PaperSize copy (); public static weak string get_default (); public double get_default_bottom_margin (Gtk.Unit unit); @@ -5241,7 +5241,7 @@ namespace Gtk { public int age; } [CCode (ref_function = "gtk_recent_info_ref", unref_function = "gtk_recent_info_unref", cheader_filename = "gtk/gtk.h")] - public class RecentInfo { + public class RecentInfo : GLib.Boxed { public bool exists (); public ulong get_added (); public int get_age (); @@ -5273,8 +5273,8 @@ namespace Gtk { public double ruler_scale; public int subdivide; } - [CCode (cheader_filename = "gtk/gtk.h")] - public class SelectionData { + [CCode (copy_function = "gtk_selection_data_copy", cheader_filename = "gtk/gtk.h")] + public class SelectionData : GLib.Boxed { public Gdk.Atom selection; public Gdk.Atom target; public Gdk.Atom type; @@ -5307,7 +5307,7 @@ namespace Gtk { public weak string origin; public weak GLib.Value value; } - [CCode (cheader_filename = "gtk/gtk.h")] + [CCode (copy_function = "gtk_stock_item_copy", cheader_filename = "gtk/gtk.h")] public class StockItem { public weak string stock_id; public weak string label; @@ -5350,7 +5350,7 @@ namespace Gtk { public uint info; } [CCode (ref_function = "gtk_target_list_ref", unref_function = "gtk_target_list_unref", cheader_filename = "gtk/gtk.h")] - public class TargetList { + public class TargetList : GLib.Boxed { public weak GLib.List list; public uint ref_count; public void add (Gdk.Atom target, uint flags, uint info); @@ -5384,7 +5384,7 @@ namespace Gtk { public uint is_text; } [CCode (ref_function = "gtk_text_attributes_ref", unref_function = "gtk_text_attributes_unref", cheader_filename = "gtk/gtk.h")] - public class TextAttributes { + public class TextAttributes : GLib.Boxed { public weak Gtk.TextAppearance appearance; public Gtk.Justification justification; public Gtk.TextDirection direction; @@ -5423,8 +5423,8 @@ namespace Gtk { [CCode (cheader_filename = "gtk/gtk.h")] public class ThemeEngine { } - [CCode (cheader_filename = "gtk/gtk.h")] - public class TreePath { + [CCode (copy_function = "gtk_tree_path_copy", cheader_filename = "gtk/gtk.h")] + public class TreePath : GLib.Boxed { public void append_index (int index_); public int compare (Gtk.TreePath b); public weak Gtk.TreePath copy (); @@ -5446,8 +5446,8 @@ namespace Gtk { public weak string to_string (); public bool up (); } - [CCode (cheader_filename = "gtk/gtk.h")] - public class TreeRowReference { + [CCode (copy_function = "gtk_tree_row_reference_copy", cheader_filename = "gtk/gtk.h")] + public class TreeRowReference : GLib.Boxed { public weak Gtk.TreeRowReference copy (); public static void deleted (GLib.Object proxy, Gtk.TreePath path); public weak Gtk.TreeModel get_model (); diff --git a/vapi/libglade-2.0.vala b/vapi/libglade-2.0.vala index 2af98df..2650228 100644 --- a/vapi/libglade-2.0.vala +++ b/vapi/libglade-2.0.vala @@ -49,7 +49,7 @@ namespace Glade { public weak Glade.WidgetInfo child; public weak string internal_child; } - [CCode (cheader_filename = "glade/glade.h")] + [CCode (free_function = "glade_interface_destroy", cheader_filename = "glade/glade.h")] public class Interface { public weak string requires; public uint n_requires; @@ -57,7 +57,6 @@ namespace Glade { public uint n_toplevels; public weak GLib.HashTable names; public weak GLib.HashTable strings; - public void destroy (); public void dump (string filename); } [CCode (cheader_filename = "glade/glade.h")] diff --git a/vapi/libgnome-2.0.vala b/vapi/libgnome-2.0.vala index 836daef..6e1418d 100644 --- a/vapi/libgnome-2.0.vala +++ b/vapi/libgnome-2.0.vala @@ -96,7 +96,7 @@ namespace Gnome { public weak string espeaker { get; set; } } [CCode (cheader_filename = "libgnome/libgnome.h")] - public class ModuleInfo { + public class ModuleInfo : GLib.Boxed { public weak string name; public weak string version; public weak string description; diff --git a/vapi/libsoup-2.2.vala b/vapi/libsoup-2.2.vala index 225c167..f9f8db3 100644 --- a/vapi/libsoup-2.2.vala +++ b/vapi/libsoup-2.2.vala @@ -461,10 +461,9 @@ namespace Soup { public uchar @in; public bool doByteReverse; } - [CCode (cheader_filename = "libsoup/soup.h")] + [CCode (free_function = "soup_message_queue_destroy", cheader_filename = "libsoup/soup.h")] public class MessageQueue { public void append (Soup.Message msg); - public void destroy (); public weak Soup.Message first (Soup.MessageQueueIter iter); public void free_iter (Soup.MessageQueueIter iter); public MessageQueue (); @@ -526,7 +525,7 @@ namespace Soup { public Soup.ServerUnregisterFn unregister; public pointer user_data; } - [CCode (cheader_filename = "libsoup/soup.h")] + [CCode (copy_function = "soup_uri_copy", cheader_filename = "libsoup/soup.h")] public class Uri { public GLib.Quark protocol; public weak string user; diff --git a/vapi/pango.vala b/vapi/pango.vala index dbd2f34..16c461e 100644 --- a/vapi/pango.vala +++ b/vapi/pango.vala @@ -212,7 +212,7 @@ namespace Pango { WORD_CHAR, } [CCode (cheader_filename = "pango/pango.h")] - public class Language { + public class Language : GLib.Boxed { public weak string! to_string (); public static weak Pango.Language from_string (string language); public static weak Pango.Language get_default (); @@ -421,10 +421,9 @@ namespace Pango { public weak Pango.Attribute attr; public int value; } - [CCode (cheader_filename = "pango/pango.h")] + [CCode (copy_function = "pango_attr_iterator_copy", free_function = "pango_attr_iterator_destroy", cheader_filename = "pango/pango.h")] public class AttrIterator { public weak Pango.AttrIterator copy (); - public void destroy (); public weak Pango.Attribute get (Pango.AttrType type); public weak GLib.SList get_attrs (); public void get_font (Pango.FontDescription desc, Pango.Language language, GLib.SList extra_attrs); @@ -438,7 +437,7 @@ namespace Pango { public AttrLanguage (Pango.Language language); } [CCode (ref_function = "pango_attr_list_ref", unref_function = "pango_attr_list_unref", cheader_filename = "pango/pango.h")] - public class AttrList { + public class AttrList : GLib.Boxed { public void change (Pango.Attribute attr); public weak Pango.AttrList copy (); public weak Pango.AttrList filter (Pango.AttrFilterFunc func, pointer data); @@ -472,13 +471,12 @@ namespace Pango { public weak Pango.Attribute attr; public weak string value; } - [CCode (cheader_filename = "pango/pango.h")] + [CCode (copy_function = "pango_attribute_copy", free_function = "pango_attribute_destroy", cheader_filename = "pango/pango.h")] public class Attribute { public pointer klass; public uint start_index; public uint end_index; public weak Pango.Attribute copy (); - public void destroy (); public bool equal (Pango.Attribute attr2); } [CCode (ref_function = "pango_coverage_ref", unref_function = "pango_coverage_unref", cheader_filename = "pango/pango.h")] @@ -499,8 +497,8 @@ namespace Pango { [CCode (cheader_filename = "pango/pango.h")] public class EngineShape { } - [CCode (cheader_filename = "pango/pango.h")] - public class FontDescription { + [CCode (copy_function = "pango_font_description_copy", cheader_filename = "pango/pango.h")] + public class FontDescription : GLib.Boxed { public bool better_match (Pango.FontDescription old_match, Pango.FontDescription new_match); public weak Pango.FontDescription copy (); public weak Pango.FontDescription copy_static (); @@ -534,7 +532,7 @@ namespace Pango { public void unset_fields (Pango.FontMask to_unset); } [CCode (ref_function = "pango_font_metrics_ref", unref_function = "pango_font_metrics_unref", cheader_filename = "pango/pango.h")] - public class FontMetrics { + public class FontMetrics : GLib.Boxed { public int get_approximate_char_width (); public int get_approximate_digit_width (); public int get_ascent (); @@ -565,8 +563,8 @@ namespace Pango { public void letter_space (string text, Pango.LogAttr log_attrs, int letter_spacing); public weak Pango.GlyphItem split (string text, int split_index); } - [CCode (cheader_filename = "pango/pango.h")] - public class GlyphString { + [CCode (copy_function = "pango_glyph_string_copy", cheader_filename = "pango/pango.h")] + public class GlyphString : GLib.Boxed { public int num_glyphs; public weak Pango.GlyphInfo glyphs; public int log_clusters; @@ -585,8 +583,8 @@ namespace Pango { public class GlyphVisAttr { public uint is_cluster_start; } - [CCode (cheader_filename = "pango/pango.h")] - public class Item { + [CCode (copy_function = "pango_item_copy", cheader_filename = "pango/pango.h")] + public class Item : GLib.Boxed { public int offset; public int length; public int num_chars; @@ -597,7 +595,7 @@ namespace Pango { public weak Pango.Item split (int split_index, int split_offset); } [CCode (cheader_filename = "pango/pango.h")] - public class LayoutIter { + public class LayoutIter : GLib.Boxed { public bool at_last_line (); public int get_baseline (); public void get_char_extents (out Pango.Rectangle logical_rect); @@ -618,7 +616,7 @@ namespace Pango { public bool next_run (); } [CCode (ref_function = "pango_layout_line_ref", unref_function = "pango_layout_line_unref", cheader_filename = "pango/pango.h")] - public class LayoutLine { + public class LayoutLine : GLib.Boxed { public weak Pango.Layout layout; public int start_index; public int length; @@ -659,8 +657,8 @@ namespace Pango { public ScriptIter (string text, int length); public bool next (); } - [CCode (cheader_filename = "pango/pango.h")] - public class TabArray { + [CCode (copy_function = "pango_tab_array_copy", cheader_filename = "pango/pango.h")] + public class TabArray : GLib.Boxed { public weak Pango.TabArray copy (); public bool get_positions_in_pixels (); public int get_size (); diff --git a/vapi/poppler-glib.vala b/vapi/poppler-glib.vala index 802b136..a811ad7 100644 --- a/vapi/poppler-glib.vala +++ b/vapi/poppler-glib.vala @@ -293,7 +293,7 @@ namespace Poppler { public weak string title; public weak string uri; } - [CCode (cheader_filename = "poppler.h")] + [CCode (copy_function = "poppler_dest_copy", cheader_filename = "poppler.h")] public class Dest { public Poppler.DestType type; public int page_num; @@ -309,7 +309,7 @@ namespace Poppler { public weak Poppler.Dest copy (); public static GLib.Type get_type (); } - [CCode (cheader_filename = "poppler.h")] + [CCode (copy_function = "poppler_fonts_iter_copy", cheader_filename = "poppler.h")] public class FontsIter { public weak Poppler.FontsIter copy (); public weak string get_file_name (); @@ -321,7 +321,7 @@ namespace Poppler { public bool is_subset (); public bool next (); } - [CCode (cheader_filename = "poppler.h")] + [CCode (copy_function = "poppler_form_field_mapping_copy", cheader_filename = "poppler.h")] public class FormFieldMapping { public weak Poppler.Rectangle area; public weak Poppler.FormField field; @@ -329,7 +329,7 @@ namespace Poppler { public static GLib.Type get_type (); public FormFieldMapping (); } - [CCode (cheader_filename = "poppler.h")] + [CCode (copy_function = "poppler_image_mapping_copy", cheader_filename = "poppler.h")] public class ImageMapping { public weak Poppler.Rectangle area; public weak Gdk.Pixbuf image; @@ -337,7 +337,7 @@ namespace Poppler { public static GLib.Type get_type (); public ImageMapping (); } - [CCode (cheader_filename = "poppler.h")] + [CCode (copy_function = "poppler_index_iter_copy", cheader_filename = "poppler.h")] public class IndexIter { public weak Poppler.IndexIter copy (); public weak Poppler.Action get_action (); @@ -347,7 +347,7 @@ namespace Poppler { public IndexIter (Poppler.Document document); public bool next (); } - [CCode (cheader_filename = "poppler.h")] + [CCode (copy_function = "poppler_link_mapping_copy", cheader_filename = "poppler.h")] public class LinkMapping { public weak Poppler.Rectangle area; public weak Poppler.Action action; @@ -355,7 +355,7 @@ namespace Poppler { public static GLib.Type get_type (); public LinkMapping (); } - [CCode (cheader_filename = "poppler.h")] + [CCode (copy_function = "poppler_page_transition_copy", cheader_filename = "poppler.h")] public class PageTransition { public Poppler.PageTransitionType type; public Poppler.PageTransitionAlignment alignment; @@ -368,7 +368,7 @@ namespace Poppler { public static GLib.Type get_type (); public PageTransition (); } - [CCode (cheader_filename = "poppler.h")] + [CCode (copy_function = "poppler_rectangle_copy", cheader_filename = "poppler.h")] public class Rectangle { public double x1; public double y1; diff --git a/vapigen/valagidlparser.vala b/vapigen/valagidlparser.vala index 5f68062..08eff31 100644 --- a/vapigen/valagidlparser.vala +++ b/vapigen/valagidlparser.vala @@ -342,6 +342,7 @@ public class Vala.GIdlParser : CodeVisitor { string ref_function = null; string unref_function = null; + string copy_function = null; string free_function = null; foreach (weak IdlNode member in st_node.members) { @@ -350,9 +351,12 @@ public class Vala.GIdlParser : CodeVisitor { ref_function = ((IdlNodeFunction) member).symbol; } else if (member.name == "unref") { unref_function = ((IdlNodeFunction) member).symbol; - } else if (member.name == "free") { + } else if (member.name == "free" || member.name == "destroy") { free_function = ((IdlNodeFunction) member).symbol; } else { + if (member.name == "copy") { + copy_function = ((IdlNodeFunction) member).symbol; + } var m = parse_function ((IdlNodeFunction) member); if (m != null) { cl.add_method (m); @@ -369,6 +373,9 @@ public class Vala.GIdlParser : CodeVisitor { if (ref_function != null) { cl.set_ref_function (ref_function); } + if (copy_function != null) { + cl.set_dup_function (copy_function); + } if (unref_function != null) { cl.set_unref_function (unref_function); } else if (free_function != null) { @@ -442,11 +449,17 @@ public class Vala.GIdlParser : CodeVisitor { cl.set_type_id (cl.get_upper_case_cname ("TYPE_")); current_source_file.add_node (cl); } - + + var parent = new TypeReference (); + parent.namespace_name = "GLib"; + parent.type_name = "Boxed"; + cl.add_base_type (parent); + current_data_type = cl; string ref_function = null; string unref_function = null; + string copy_function = null; string free_function = null; foreach (weak IdlNode member in boxed_node.members) { @@ -455,9 +468,12 @@ public class Vala.GIdlParser : CodeVisitor { ref_function = ((IdlNodeFunction) member).symbol; } else if (member.name == "unref") { unref_function = ((IdlNodeFunction) member).symbol; - } else if (member.name == "free") { + } else if (member.name == "free" || member.name == "destroy") { free_function = ((IdlNodeFunction) member).symbol; } else { + if (member.name == "copy") { + copy_function = ((IdlNodeFunction) member).symbol; + } var m = parse_function ((IdlNodeFunction) member); if (m != null) { cl.add_method (m); @@ -474,6 +490,9 @@ public class Vala.GIdlParser : CodeVisitor { if (ref_function != null) { cl.set_ref_function (ref_function); } + if (copy_function != null) { + cl.set_dup_function (copy_function); + } if (unref_function != null) { cl.set_unref_function (unref_function); } else if (free_function != null) { -- 2.7.4