[vala] Warn when owned keyword is not used for called_once delegates



commit 21c8e57f3990774e28a97cbf644371b5c4183503
Author: Luca Bruno <lucabru src gnome org>
Date:   Wed Jun 5 22:58:10 2013 +0200

    Warn when owned keyword is not used for called_once delegates

 vala/valadelegatetype.vala |    3 +++
 vapi/glib-2.0.vapi         |    8 ++++----
 2 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/vala/valadelegatetype.vala b/vala/valadelegatetype.vala
index 91029d3..92bd1e2 100644
--- a/vala/valadelegatetype.vala
+++ b/vala/valadelegatetype.vala
@@ -113,6 +113,9 @@ public class Vala.DelegateType : DataType {
        }
 
        public override bool check (CodeContext context) {
+               if (is_called_once && !value_owned) {
+                       Report.warning (source_reference, "delegates with scope=\"async\" must be owned");
+               }
                return delegate_symbol.check (context);
        }
 
diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi
index 5c18683..b45eee4 100644
--- a/vapi/glib-2.0.vapi
+++ b/vapi/glib-2.0.vapi
@@ -1693,17 +1693,17 @@ namespace GLib {
 #endif
        public class Thread<T> {
 #if GLIB_2_32
-               public Thread (string? name, ThreadFunc<T> func);
+               public Thread (string? name, owned ThreadFunc<T> func);
                [CCode (cname = "g_thread_try_new")]
-               public Thread.try (string? name, ThreadFunc<T> func) throws GLib.Error;
+               public Thread.try (string? name, owned ThreadFunc<T> func) throws GLib.Error;
 #endif
                public static bool supported ();
                [Deprecated (since = "2.32", replacement = "new Thread<T> ()")]
                [CCode (simple_generics = true)]
-               public static unowned Thread<T> create<T> (ThreadFunc<T> func, bool joinable) throws 
ThreadError;
+               public static unowned Thread<T> create<T> (owned ThreadFunc<T> func, bool joinable) throws 
ThreadError;
                [Deprecated (since = "2.32", replacement = "new Thread<T> ()")]
                [CCode (simple_generics = true)]
-               public static unowned Thread<T> create_full<T> (ThreadFunc<T> func, ulong stack_size, bool 
joinable, bool bound, ThreadPriority priority) throws ThreadError;
+               public static unowned Thread<T> create_full<T> (owned ThreadFunc<T> func, ulong stack_size, 
bool joinable, bool bound, ThreadPriority priority) throws ThreadError;
                [CCode (simple_generics = true)]
                public static unowned Thread<T> self<T> ();
                public T join ();


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