GObject: warn on use of deprecated properties
[platform/upstream/glib.git] / gobject / gparamspecs.c
index f49936b..c48ae0c 100644 (file)
@@ -13,9 +13,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
 /*
 
 #include <string.h>
 
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
 #include "gparamspecs.h"
+#include "gtype-private.h"
 #include "gvaluecollector.h"
+
 #include "gvaluearray.h"
 
 
@@ -1160,7 +1162,7 @@ param_variant_values_cmp (GParamSpec   *pspec,
 GType *g_param_spec_types = NULL;
 
 void
-g_param_spec_types_init (void) 
+_g_param_spec_types_init (void)        
 {
   const guint n_types = 23;
   GType type, *spec_types, *spec_types_bound;
@@ -1591,7 +1593,7 @@ g_param_spec_types_init (void)
 /* --- GParamSpec initialization --- */
 
 /**
- * g_param_spec_char: (skip)
+ * g_param_spec_char:
  * @name: canonical name of the property specified
  * @nick: nick name for the property specified
  * @blurb: description of the property specified
@@ -1602,7 +1604,7 @@ g_param_spec_types_init (void)
  *
  * Creates a new #GParamSpecChar instance specifying a %G_TYPE_CHAR property.
  *
- * Returns: a newly created parameter specification
+ * Returns: (transfer full): a newly created parameter specification
  */
 GParamSpec*
 g_param_spec_char (const gchar *name,
@@ -1622,6 +1624,8 @@ g_param_spec_char (const gchar *name,
                                 nick,
                                 blurb,
                                 flags);
+  if (cspec == NULL)
+    return NULL;
   
   cspec->minimum = minimum;
   cspec->maximum = maximum;
@@ -1631,7 +1635,7 @@ g_param_spec_char (const gchar *name,
 }
 
 /**
- * g_param_spec_uchar: (skip)
+ * g_param_spec_uchar:
  * @name: canonical name of the property specified
  * @nick: nick name for the property specified
  * @blurb: description of the property specified
@@ -1642,7 +1646,7 @@ g_param_spec_char (const gchar *name,
  *
  * Creates a new #GParamSpecUChar instance specifying a %G_TYPE_UCHAR property.
  *
- * Returns: a newly created parameter specification
+ * Returns: (transfer full): a newly created parameter specification
  */
 GParamSpec*
 g_param_spec_uchar (const gchar *name,
@@ -1662,6 +1666,8 @@ g_param_spec_uchar (const gchar *name,
                                 nick,
                                 blurb,
                                 flags);
+  if (uspec == NULL)
+    return NULL;
   
   uspec->minimum = minimum;
   uspec->maximum = maximum;
@@ -1671,7 +1677,7 @@ g_param_spec_uchar (const gchar *name,
 }
 
 /**
- * g_param_spec_boolean: (skip)
+ * g_param_spec_boolean:
  * @name: canonical name of the property specified
  * @nick: nick name for the property specified
  * @blurb: description of the property specified
@@ -1683,7 +1689,7 @@ g_param_spec_uchar (const gchar *name,
  *
  * See g_param_spec_internal() for details on property names.
  *
- * Returns: a newly created parameter specification
+ * Returns: (transfer full): a newly created parameter specification
  */
 GParamSpec*
 g_param_spec_boolean (const gchar *name,
@@ -1701,6 +1707,8 @@ g_param_spec_boolean (const gchar *name,
                                 nick,
                                 blurb,
                                 flags);
+  if (bspec == NULL)
+    return NULL;
   
   bspec->default_value = default_value;
   
@@ -1708,7 +1716,7 @@ g_param_spec_boolean (const gchar *name,
 }
 
 /**
- * g_param_spec_int: (skip)
+ * g_param_spec_int:
  * @name: canonical name of the property specified
  * @nick: nick name for the property specified
  * @blurb: description of the property specified
@@ -1721,7 +1729,7 @@ g_param_spec_boolean (const gchar *name,
  *
  * See g_param_spec_internal() for details on property names.
  *
- * Returns: a newly created parameter specification
+ * Returns: (transfer full): a newly created parameter specification
  */
 GParamSpec*
 g_param_spec_int (const gchar *name,
@@ -1741,6 +1749,8 @@ g_param_spec_int (const gchar *name,
                                 nick,
                                 blurb,
                                 flags);
+  if (ispec == NULL)
+    return NULL;
   
   ispec->minimum = minimum;
   ispec->maximum = maximum;
@@ -1750,7 +1760,7 @@ g_param_spec_int (const gchar *name,
 }
 
 /**
- * g_param_spec_uint: (skip)
+ * g_param_spec_uint:
  * @name: canonical name of the property specified
  * @nick: nick name for the property specified
  * @blurb: description of the property specified
@@ -1763,7 +1773,7 @@ g_param_spec_int (const gchar *name,
  *
  * See g_param_spec_internal() for details on property names.
  *
- * Returns: a newly created parameter specification
+ * Returns: (transfer full): a newly created parameter specification
  */
 GParamSpec*
 g_param_spec_uint (const gchar *name,
@@ -1783,6 +1793,8 @@ g_param_spec_uint (const gchar *name,
                                 nick,
                                 blurb,
                                 flags);
+  if (uspec == NULL)
+    return NULL;
   
   uspec->minimum = minimum;
   uspec->maximum = maximum;
@@ -1792,7 +1804,7 @@ g_param_spec_uint (const gchar *name,
 }
 
 /**
- * g_param_spec_long: (skip)
+ * g_param_spec_long:
  * @name: canonical name of the property specified
  * @nick: nick name for the property specified
  * @blurb: description of the property specified
@@ -1805,7 +1817,7 @@ g_param_spec_uint (const gchar *name,
  *
  * See g_param_spec_internal() for details on property names.
  *
- * Returns: a newly created parameter specification
+ * Returns: (transfer full): a newly created parameter specification
  */
 GParamSpec*
 g_param_spec_long (const gchar *name,
@@ -1825,6 +1837,8 @@ g_param_spec_long (const gchar *name,
                                 nick,
                                 blurb,
                                 flags);
+  if (lspec == NULL)
+    return NULL;
   
   lspec->minimum = minimum;
   lspec->maximum = maximum;
@@ -1834,7 +1848,7 @@ g_param_spec_long (const gchar *name,
 }
 
 /**
- * g_param_spec_ulong: (skip)
+ * g_param_spec_ulong:
  * @name: canonical name of the property specified
  * @nick: nick name for the property specified
  * @blurb: description of the property specified
@@ -1848,7 +1862,7 @@ g_param_spec_long (const gchar *name,
  *
  * See g_param_spec_internal() for details on property names.
  *
- * Returns: a newly created parameter specification
+ * Returns: (transfer full): a newly created parameter specification
  */
 GParamSpec*
 g_param_spec_ulong (const gchar *name,
@@ -1868,6 +1882,8 @@ g_param_spec_ulong (const gchar *name,
                                 nick,
                                 blurb,
                                 flags);
+  if (uspec == NULL)
+    return NULL;
   
   uspec->minimum = minimum;
   uspec->maximum = maximum;
@@ -1877,7 +1893,7 @@ g_param_spec_ulong (const gchar *name,
 }
 
 /**
- * g_param_spec_int64: (skip)
+ * g_param_spec_int64:
  * @name: canonical name of the property specified
  * @nick: nick name for the property specified
  * @blurb: description of the property specified
@@ -1890,7 +1906,7 @@ g_param_spec_ulong (const gchar *name,
  *
  * See g_param_spec_internal() for details on property names.
  *
- * Returns: a newly created parameter specification
+ * Returns: (transfer full): a newly created parameter specification
  */
 GParamSpec*
 g_param_spec_int64 (const gchar *name,
@@ -1910,6 +1926,8 @@ g_param_spec_int64 (const gchar *name,
                                 nick,
                                 blurb,
                                 flags);
+  if (lspec == NULL)
+    return NULL;
   
   lspec->minimum = minimum;
   lspec->maximum = maximum;
@@ -1919,7 +1937,7 @@ g_param_spec_int64 (const gchar *name,
 }
 
 /**
- * g_param_spec_uint64: (skip)
+ * g_param_spec_uint64:
  * @name: canonical name of the property specified
  * @nick: nick name for the property specified
  * @blurb: description of the property specified
@@ -1933,7 +1951,7 @@ g_param_spec_int64 (const gchar *name,
  *
  * See g_param_spec_internal() for details on property names.
  *
- * Returns: a newly created parameter specification
+ * Returns: (transfer full): a newly created parameter specification
  */
 GParamSpec*
 g_param_spec_uint64 (const gchar *name,
@@ -1953,6 +1971,8 @@ g_param_spec_uint64 (const gchar *name,
                                 nick,
                                 blurb,
                                 flags);
+  if (uspec == NULL)
+    return NULL;
   
   uspec->minimum = minimum;
   uspec->maximum = maximum;
@@ -1962,7 +1982,7 @@ g_param_spec_uint64 (const gchar *name,
 }
 
 /**
- * g_param_spec_unichar: (skip)
+ * g_param_spec_unichar:
  * @name: canonical name of the property specified
  * @nick: nick name for the property specified
  * @blurb: description of the property specified
@@ -1975,7 +1995,7 @@ g_param_spec_uint64 (const gchar *name,
  *
  * See g_param_spec_internal() for details on property names.
  *
- * Returns: a newly created parameter specification
+ * Returns: (transfer full): a newly created parameter specification
  */
 GParamSpec*
 g_param_spec_unichar (const gchar *name,
@@ -1991,6 +2011,8 @@ g_param_spec_unichar (const gchar *name,
                                 nick,
                                 blurb,
                                 flags);
+  if (uspec == NULL)
+    return NULL;
   
   uspec->default_value = default_value;
   
@@ -1998,7 +2020,7 @@ g_param_spec_unichar (const gchar *name,
 }
 
 /**
- * g_param_spec_enum: (skip)
+ * g_param_spec_enum:
  * @name: canonical name of the property specified
  * @nick: nick name for the property specified
  * @blurb: description of the property specified
@@ -2011,7 +2033,7 @@ g_param_spec_unichar (const gchar *name,
  *
  * See g_param_spec_internal() for details on property names.
  *
- * Returns: a newly created parameter specification
+ * Returns: (transfer full): a newly created parameter specification
  */
 GParamSpec*
 g_param_spec_enum (const gchar *name,
@@ -2035,6 +2057,8 @@ g_param_spec_enum (const gchar *name,
                                 nick,
                                 blurb,
                                 flags);
+  if (espec == NULL)
+    return NULL;
   
   espec->enum_class = enum_class;
   espec->default_value = default_value;
@@ -2044,7 +2068,7 @@ g_param_spec_enum (const gchar *name,
 }
 
 /**
- * g_param_spec_flags: (skip)
+ * g_param_spec_flags:
  * @name: canonical name of the property specified
  * @nick: nick name for the property specified
  * @blurb: description of the property specified
@@ -2057,7 +2081,7 @@ g_param_spec_enum (const gchar *name,
  *
  * See g_param_spec_internal() for details on property names.
  *
- * Returns: a newly created parameter specification
+ * Returns: (transfer full): a newly created parameter specification
  */
 GParamSpec*
 g_param_spec_flags (const gchar *name,
@@ -2081,6 +2105,8 @@ g_param_spec_flags (const gchar *name,
                                 nick,
                                 blurb,
                                 flags);
+  if (fspec == NULL)
+    return NULL;
   
   fspec->flags_class = flags_class;
   fspec->default_value = default_value;
@@ -2090,7 +2116,7 @@ g_param_spec_flags (const gchar *name,
 }
 
 /**
- * g_param_spec_float: (skip)
+ * g_param_spec_float:
  * @name: canonical name of the property specified
  * @nick: nick name for the property specified
  * @blurb: description of the property specified
@@ -2103,7 +2129,7 @@ g_param_spec_flags (const gchar *name,
  *
  * See g_param_spec_internal() for details on property names.
  *
- * Returns: a newly created parameter specification
+ * Returns: (transfer full): a newly created parameter specification
  */
 GParamSpec*
 g_param_spec_float (const gchar *name,
@@ -2123,6 +2149,8 @@ g_param_spec_float (const gchar *name,
                                 nick,
                                 blurb,
                                 flags);
+  if (fspec == NULL)
+    return NULL;
   
   fspec->minimum = minimum;
   fspec->maximum = maximum;
@@ -2132,7 +2160,7 @@ g_param_spec_float (const gchar *name,
 }
 
 /**
- * g_param_spec_double: (skip)
+ * g_param_spec_double:
  * @name: canonical name of the property specified
  * @nick: nick name for the property specified
  * @blurb: description of the property specified
@@ -2146,7 +2174,7 @@ g_param_spec_float (const gchar *name,
  *
  * See g_param_spec_internal() for details on property names.
  *
- * Returns: a newly created parameter specification
+ * Returns: (transfer full): a newly created parameter specification
  */
 GParamSpec*
 g_param_spec_double (const gchar *name,
@@ -2166,6 +2194,8 @@ g_param_spec_double (const gchar *name,
                                 nick,
                                 blurb,
                                 flags);
+  if (dspec == NULL)
+    return NULL;
   
   dspec->minimum = minimum;
   dspec->maximum = maximum;
@@ -2175,7 +2205,7 @@ g_param_spec_double (const gchar *name,
 }
 
 /**
- * g_param_spec_string: (skip)
+ * g_param_spec_string:
  * @name: canonical name of the property specified
  * @nick: nick name for the property specified
  * @blurb: description of the property specified
@@ -2186,7 +2216,7 @@ g_param_spec_double (const gchar *name,
  *
  * See g_param_spec_internal() for details on property names.
  *
- * Returns: a newly created parameter specification
+ * Returns: (transfer full): a newly created parameter specification
  */
 GParamSpec*
 g_param_spec_string (const gchar *name,
@@ -2200,6 +2230,9 @@ g_param_spec_string (const gchar *name,
                                                   nick,
                                                   blurb,
                                                   flags);
+  if (sspec == NULL)
+    return NULL;
+
   g_free (sspec->default_value);
   sspec->default_value = g_strdup (default_value);
   
@@ -2207,7 +2240,7 @@ g_param_spec_string (const gchar *name,
 }
 
 /**
- * g_param_spec_param: (skip)
+ * g_param_spec_param:
  * @name: canonical name of the property specified
  * @nick: nick name for the property specified
  * @blurb: description of the property specified
@@ -2219,7 +2252,7 @@ g_param_spec_string (const gchar *name,
  *
  * See g_param_spec_internal() for details on property names.
  *
- * Returns: a newly created parameter specification
+ * Returns: (transfer full): a newly created parameter specification
  */
 GParamSpec*
 g_param_spec_param (const gchar *name,
@@ -2237,13 +2270,16 @@ g_param_spec_param (const gchar *name,
                                 nick,
                                 blurb,
                                 flags);
+  if (pspec == NULL)
+    return NULL;
+
   G_PARAM_SPEC (pspec)->value_type = param_type;
   
   return G_PARAM_SPEC (pspec);
 }
 
 /**
- * g_param_spec_boxed: (skip)
+ * g_param_spec_boxed:
  * @name: canonical name of the property specified
  * @nick: nick name for the property specified
  * @blurb: description of the property specified
@@ -2255,7 +2291,7 @@ g_param_spec_param (const gchar *name,
  *
  * See g_param_spec_internal() for details on property names.
  *
- * Returns: a newly created parameter specification
+ * Returns: (transfer full): a newly created parameter specification
  */
 GParamSpec*
 g_param_spec_boxed (const gchar *name,
@@ -2274,23 +2310,26 @@ g_param_spec_boxed (const gchar *name,
                                 nick,
                                 blurb,
                                 flags);
+  if (bspec == NULL)
+    return NULL;
+
   G_PARAM_SPEC (bspec)->value_type = boxed_type;
   
   return G_PARAM_SPEC (bspec);
 }
 
 /**
- * g_param_spec_pointer: (skip)
+ * g_param_spec_pointer:
  * @name: canonical name of the property specified
  * @nick: nick name for the property specified
  * @blurb: description of the property specified
  * @flags: flags for the property specified
  *
- * Creates a new #GParamSpecPoiner instance specifying a pointer property.
+ * Creates a new #GParamSpecPointer instance specifying a pointer property.
  *
  * See g_param_spec_internal() for details on property names.
  *
- * Returns: a newly created parameter specification
+ * Returns: (transfer full): a newly created parameter specification
  */
 GParamSpec*
 g_param_spec_pointer (const gchar *name,
@@ -2305,11 +2344,14 @@ g_param_spec_pointer (const gchar *name,
                                 nick,
                                 blurb,
                                 flags);
+  if (pspec == NULL)
+    return NULL;
+
   return G_PARAM_SPEC (pspec);
 }
 
 /**
- * g_param_spec_gtype: (skip)
+ * g_param_spec_gtype:
  * @name: canonical name of the property specified
  * @nick: nick name for the property specified
  * @blurb: description of the property specified
@@ -2324,7 +2366,7 @@ g_param_spec_pointer (const gchar *name,
  *
  * Since: 2.10
  *
- * Returns: a newly created parameter specification
+ * Returns: (transfer full): a newly created parameter specification
  */
 GParamSpec*
 g_param_spec_gtype (const gchar *name,
@@ -2340,6 +2382,8 @@ g_param_spec_gtype (const gchar *name,
                                 nick,
                                 blurb,
                                 flags);
+  if (tspec == NULL)
+    return NULL;
 
   tspec->is_a_type = is_a_type;
 
@@ -2381,6 +2425,9 @@ g_param_spec_value_array (const gchar *name,
                                 nick,
                                 blurb,
                                 flags);
+  if (aspec == NULL)
+    return NULL;
+
   if (element_spec)
     {
       aspec->element_spec = g_param_spec_ref (element_spec);
@@ -2391,7 +2438,7 @@ g_param_spec_value_array (const gchar *name,
 }
 
 /**
- * g_param_spec_object: (skip)
+ * g_param_spec_object:
  * @name: canonical name of the property specified
  * @nick: nick name for the property specified
  * @blurb: description of the property specified
@@ -2403,7 +2450,7 @@ g_param_spec_value_array (const gchar *name,
  *
  * See g_param_spec_internal() for details on property names.
  *
- * Returns: a newly created parameter specification
+ * Returns: (transfer full): a newly created parameter specification
  */
 GParamSpec*
 g_param_spec_object (const gchar *name,
@@ -2421,6 +2468,9 @@ g_param_spec_object (const gchar *name,
                                 nick,
                                 blurb,
                                 flags);
+  if (ospec == NULL)
+    return NULL;
+
   G_PARAM_SPEC (ospec)->value_type = object_type;
   
   return G_PARAM_SPEC (ospec);
@@ -2462,6 +2512,8 @@ g_param_spec_override (const gchar *name,
   pspec = g_param_spec_internal (G_TYPE_PARAM_OVERRIDE,
                                 name, NULL, NULL,
                                 overridden->flags);
+  if (pspec == NULL)
+    return NULL;
   
   pspec->value_type = G_PARAM_SPEC_VALUE_TYPE (overridden);
   G_PARAM_SPEC_OVERRIDE (pspec)->overridden = g_param_spec_ref (overridden);
@@ -2470,13 +2522,13 @@ g_param_spec_override (const gchar *name,
 }
 
 /**
- * g_param_spec_variant: (skip)
+ * g_param_spec_variant:
  * @name: canonical name of the property specified
  * @nick: nick name for the property specified
  * @blurb: description of the property specified
  * @type: a #GVariantType
- * @default_value: (allow-none): a #GVariant of type @type to use as the
- *                 default value, or %NULL
+ * @default_value: (allow-none) (transfer full): a #GVariant of type @type to
+ *                 use as the default value, or %NULL
  * @flags: flags for the property specified
  *
  * Creates a new #GParamSpecVariant instance specifying a #GVariant
@@ -2486,7 +2538,7 @@ g_param_spec_override (const gchar *name,
  *
  * See g_param_spec_internal() for details on property names.
  *
- * Returns: the newly created #GParamSpec
+ * Returns: (transfer full): the newly created #GParamSpec
  *
  * Since: 2.26
  */
@@ -2509,6 +2561,8 @@ g_param_spec_variant (const gchar        *name,
                                  nick,
                                  blurb,
                                  flags);
+  if (vspec == NULL)
+    return NULL;
 
   vspec->type = g_variant_type_copy (type);
   if (default_value)