From cb8ef0fef25efa4d33001e06b3b021d1377e396e Mon Sep 17 00:00:00 2001 From: Raffaele Sandrini Date: Thu, 9 Nov 2006 14:00:36 +0000 Subject: [PATCH] add GArray and GTree structures write header files attributes for classes 2006-11-09 Raffaele Sandrini * vapi/glib-2.0.vala: add GArray and GTree structures * vala/valainterfacewriter.vala: write header files attributes for classes svn path=/trunk/; revision=172 --- vala/ChangeLog | 6 +++ vala/vala/valainterfacewriter.vala | 14 +++++++ vala/vapi/glib-2.0.vala | 65 ++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) diff --git a/vala/ChangeLog b/vala/ChangeLog index 434d48765..77b759478 100644 --- a/vala/ChangeLog +++ b/vala/ChangeLog @@ -1,3 +1,9 @@ +2006-11-09 Raffaele Sandrini + + * vapi/glib-2.0.vala: add GArray and GTree structures + * vala/valainterfacewriter.vala: write header files attributes for + classes + 2006-11-09 Jürg Billeter * vapi/libxml-2.0.vala: some fixes and additions diff --git a/vala/vala/valainterfacewriter.vala b/vala/vala/valainterfacewriter.vala index 7b23de573..7ec35e61b 100644 --- a/vala/vala/valainterfacewriter.vala +++ b/vala/vala/valainterfacewriter.vala @@ -93,6 +93,20 @@ public class Vala.InterfaceWriter : CodeVisitor { } write_indent (); + + var first = true; + string cheaders; + foreach (string cheader in cl.get_cheader_filenames ()) { + if (first) { + cheaders = cheader; + first = false; + } else { + cheaders = "%s, %s".printf (cheaders, cheader); + } + } + write_string ("[CCode (cheader_filename = \"%s\")]".printf (cheaders)); + write_newline (); + write_string ("public "); if (cl.is_abstract) { write_string ("abstract "); diff --git a/vala/vapi/glib-2.0.vala b/vala/vapi/glib-2.0.vala index 40d8b14ab..7973934a0 100644 --- a/vala/vapi/glib-2.0.vala +++ b/vala/vapi/glib-2.0.vala @@ -29,6 +29,10 @@ public struct bool { public struct pointer { } +[CCode (cname = "gconstpointer", cheader_filename = "glib.h", type_id = "G_TYPE_POINTER", marshaller_type_name = "POINTER", get_value_function = "g_value_get_pointer", set_value_function = "g_value_set_pointer")] +public struct constpointer { +} + [CCode (cheader_filename = "glib.h", type_id = "G_TYPE_CHAR", marshaller_type_name = "CHAR", get_value_function = "g_value_get_char", set_value_function = "g_value_set_char")] [IntegerType (rank = 1)] public struct char { @@ -1117,4 +1121,65 @@ namespace GLib { public static Quark from_string (string string); public string to_string (); } + + /* GArray */ + + [ReferenceType ()] + public struct Array { + public construct (bool zero_terminated, bool clear, uint element_size); + [CCode (cname = "g_array_sized_new")] + public construct sized (bool zero_terminated, bool clear, uint element_size, uint reserved_size); + [ReturnsModifiedPointer ()] + public void append_val (G value); + [ReturnsModifiedPointer ()] + public void append_vals (constpointer data, uint len); + [ReturnsModifiedPointer ()] + public void prepend_val (G value); + [ReturnsModifiedPointer ()] + public void prepend_vals (constpointer data, uint len); + [ReturnsModifiedPointer ()] + public void insert_val (uint index, G value); + [ReturnsModifiedPointer ()] + public void insert_vals (uint index, constpointer data, uint len); + [ReturnsModifiedPointer ()] + public void remove_index (uint index); + [ReturnsModifiedPointer ()] + public void remove_index_fast (uint index); + [ReturnsModifiedPointer ()] + public void remove_range (uint index, uint length); + public void sort (CompareFunc compare_func); + public void sort_with_data (CompareDataFunc compare_func, pointer user_data); + [ReturnsModifiedPointer ()] + public void set_size (uint length); + public string free (bool free_segment); + } + + /* GTree */ + + public callback int TraverseFunc (pointer key, pointer value, pointer data); + + [CCode (c_prefix="C_")] + public enum TraverseType { + IN_ORDER, + PRE_ORDER, + POST_ORDER, + LEVEL_ORDER + } + + [ReferenceType (free_function = "g_tree_destroy")] + public struct Tree { + public construct (CompareFunc key_compare_func); + public construct with_data (CompareFunc key_compare_func, pointer key_compare_data); + public construct full (CompareFunc key_compare_func, pointer key_compare_data, DestroyNotify key_destroy_func, DestroyNotify value_destroy_func); + public void insert (K key, V value); + public void replace (K key, V value); + public int nnodes (); + public int height (); + public V lookup (K key); + public bool lookup_extended (K lookup_key, K orig_key, V value); + public void tree_foreach (TraverseFunc traverse_func, TraverseType traverse_type, pointer user_data); + public V tree_search (CompareFunc search_func, pointer user_data); + public bool remove (K key); + public bool steal (K key); + } } -- 2.47.3