LCOV - code coverage report
Current view: top level - tests - regress.c (source / functions) Hit Total Coverage
Test: gjs- Code Coverage Lines: 1283 1494 85.9 %
Date: 2023-09-17 02:39:54 Functions: 309 335 92.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 212 329 64.4 %

           Branch data     Line data    Source code
       1                 :            : /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
       2                 :            : /* This file gets installed, so we can't assume config.h is available */
       3                 :            : #ifdef HAVE_CONFIG_H
       4                 :            : #include "config.h"
       5                 :            : #endif
       6                 :            : 
       7                 :            : #include <string.h>
       8                 :            : #include <stdlib.h>
       9                 :            : #include <glib-object.h>
      10                 :            : #include <gobject/gvaluecollector.h>
      11                 :            : 
      12                 :            : #include "regress.h"
      13                 :            : 
      14                 :            : static gboolean abort_on_error = TRUE;
      15                 :            : 
      16                 :            : #define ASSERT_VALUE(condition)  \
      17                 :            :   if (abort_on_error)             \
      18                 :            :     g_assert (condition);         \
      19                 :            :   else                            \
      20                 :            :     g_warn_if_fail (condition);   \
      21                 :            : 
      22                 :            : void
      23                 :          0 : regress_set_abort_on_error (gboolean in)
      24                 :            : {
      25                 :          0 :   abort_on_error = in;
      26                 :          0 : }
      27                 :            : 
      28                 :            : /* return annotations */
      29                 :            : 
      30                 :            : /**
      31                 :            :  * regress_test_return_allow_none:
      32                 :            :  *
      33                 :            :  * Returns: (allow-none):
      34                 :            :  */
      35                 :            : char *
      36                 :          1 : regress_test_return_allow_none (void)
      37                 :            : {
      38                 :          1 :   return NULL;
      39                 :            : }
      40                 :            : 
      41                 :            : /**
      42                 :            :  * regress_test_return_nullable:
      43                 :            :  *
      44                 :            :  * Returns: (nullable):
      45                 :            :  */
      46                 :            : char *
      47                 :          1 : regress_test_return_nullable (void)
      48                 :            : {
      49                 :          1 :   return NULL;
      50                 :            : }
      51                 :            : 
      52                 :            : /* basic types */
      53                 :            : gboolean
      54                 :          2 : regress_test_boolean (gboolean in)
      55                 :            : {
      56                 :          2 :   return in;
      57                 :            : }
      58                 :            : 
      59                 :            : gboolean
      60                 :          1 : regress_test_boolean_true (gboolean in)
      61                 :            : {
      62   [ +  -  -  +  :          1 :   ASSERT_VALUE (in == TRUE);
                   -  - ]
      63                 :          1 :   return in;
      64                 :            : }
      65                 :            : 
      66                 :            : gboolean
      67                 :          1 : regress_test_boolean_false (gboolean in)
      68                 :            : {
      69   [ +  -  -  +  :          1 :   ASSERT_VALUE (in == FALSE);
                   -  - ]
      70                 :          1 :   return in;
      71                 :            : }
      72                 :            : 
      73                 :            : gint8
      74                 :          8 : regress_test_int8 (gint8 in)
      75                 :            : {
      76                 :          8 :   return in;
      77                 :            : }
      78                 :            : 
      79                 :            : guint8
      80                 :          5 : regress_test_uint8 (guint8 in)
      81                 :            : {
      82                 :          5 :   return in;
      83                 :            : }
      84                 :            : 
      85                 :            : gint16
      86                 :          8 : regress_test_int16 (gint16 in)
      87                 :            : {
      88                 :          8 :   return in;
      89                 :            : }
      90                 :            : 
      91                 :            : guint16
      92                 :          5 : regress_test_uint16 (guint16 in)
      93                 :            : {
      94                 :          5 :   return in;
      95                 :            : }
      96                 :            : 
      97                 :            : gint32
      98                 :          8 : regress_test_int32 (gint32 in)
      99                 :            : {
     100                 :          8 :   return in;
     101                 :            : }
     102                 :            : 
     103                 :            : guint32
     104                 :          5 : regress_test_uint32 (guint32 in)
     105                 :            : {
     106                 :          5 :   return in;
     107                 :            : }
     108                 :            : 
     109                 :            : gint64
     110                 :         12 : regress_test_int64 (gint64 in)
     111                 :            : {
     112                 :         12 :   return in;
     113                 :            : }
     114                 :            : 
     115                 :            : guint64
     116                 :          7 : regress_test_uint64 (guint64 in)
     117                 :            : {
     118                 :          7 :   return in;
     119                 :            : }
     120                 :            : 
     121                 :            : gshort
     122                 :          8 : regress_test_short (gshort in)
     123                 :            : {
     124                 :          8 :   return in;
     125                 :            : }
     126                 :            : 
     127                 :            : gushort
     128                 :          5 : regress_test_ushort (gushort in)
     129                 :            : {
     130                 :          5 :   return in;
     131                 :            : }
     132                 :            : 
     133                 :            : gint
     134                 :          8 : regress_test_int (gint in)
     135                 :            : {
     136                 :          8 :   return in;
     137                 :            : }
     138                 :            : 
     139                 :            : guint
     140                 :          5 : regress_test_uint (guint in)
     141                 :            : {
     142                 :          5 :   return in;
     143                 :            : }
     144                 :            : 
     145                 :            : glong
     146                 :         12 : regress_test_long (glong in)
     147                 :            : {
     148                 :         12 :   return in;
     149                 :            : }
     150                 :            : 
     151                 :            : gulong
     152                 :          7 : regress_test_ulong (gulong in)
     153                 :            : {
     154                 :          7 :   return in;
     155                 :            : }
     156                 :            : 
     157                 :            : gssize
     158                 :         12 : regress_test_ssize (gssize in)
     159                 :            : {
     160                 :         12 :   return in;
     161                 :            : }
     162                 :            : 
     163                 :            : gsize
     164                 :          7 : regress_test_size (gsize in)
     165                 :            : {
     166                 :          7 :   return in;
     167                 :            : }
     168                 :            : 
     169                 :            : gfloat
     170                 :          8 : regress_test_float (gfloat in)
     171                 :            : {
     172                 :          8 :   return in;
     173                 :            : }
     174                 :            : 
     175                 :            : gdouble
     176                 :          8 : regress_test_double (gdouble in)
     177                 :            : {
     178                 :          8 :   return in;
     179                 :            : }
     180                 :            : 
     181                 :            : gunichar
     182                 :          3 : regress_test_unichar (gunichar in)
     183                 :            : {
     184                 :          3 :   return in;
     185                 :            : }
     186                 :            : 
     187                 :            : time_t
     188                 :          1 : regress_test_timet (time_t in)
     189                 :            : {
     190                 :          1 :   return in;
     191                 :            : }
     192                 :            : 
     193                 :            : GType
     194                 :          3 : regress_test_gtype (GType in)
     195                 :            : {
     196                 :          3 :   return in;
     197                 :            : }
     198                 :            : 
     199                 :            : int
     200                 :          1 : regress_test_closure (GClosure *closure)
     201                 :            : {
     202                 :          1 :   GValue return_value = {0, };
     203                 :            :   int ret;
     204                 :            : 
     205                 :          1 :   g_value_init (&return_value, G_TYPE_INT);
     206                 :            : 
     207                 :          1 :   g_closure_invoke (closure,
     208                 :            :                     &return_value,
     209                 :            :                     0, NULL,
     210                 :            :                     NULL);
     211                 :            : 
     212                 :          1 :   ret = g_value_get_int (&return_value);
     213                 :            : 
     214                 :          1 :   g_value_unset(&return_value);
     215                 :            : 
     216                 :          1 :   return ret;
     217                 :            : }
     218                 :            : 
     219                 :            : int
     220                 :          1 : regress_test_closure_one_arg (GClosure *closure, int arg)
     221                 :            : {
     222                 :          1 :   GValue return_value = {0, };
     223                 :            :   GValue arguments[1];
     224                 :            :   int ret;
     225                 :            : 
     226                 :          1 :   g_value_init (&return_value, G_TYPE_INT);
     227                 :            : 
     228                 :          1 :   memset (&arguments[0], 0, sizeof (arguments));
     229                 :          1 :   g_value_init (&arguments[0], G_TYPE_INT);
     230                 :          1 :   g_value_set_int (&arguments[0], arg);
     231                 :            : 
     232                 :          1 :   g_closure_invoke (closure,
     233                 :            :                     &return_value,
     234                 :            :                     1, arguments,
     235                 :            :                     NULL);
     236                 :            : 
     237                 :          1 :   ret = g_value_get_int (&return_value);
     238                 :            : 
     239                 :          1 :   g_value_unset(&return_value);
     240                 :          1 :   g_value_unset(&arguments[0]);
     241                 :            : 
     242                 :          1 :   return ret;
     243                 :            : }
     244                 :            : 
     245                 :            : /**
     246                 :            :  * regress_test_closure_variant:
     247                 :            :  * @closure: GClosure which takes one GVariant and returns a GVariant
     248                 :            :  * @arg: (allow-none) (transfer none): a GVariant passed as argument to @closure
     249                 :            :  *
     250                 :            :  * Return value: (transfer full): the return value of @closure
     251                 :            :  */
     252                 :            : GVariant*
     253                 :          1 : regress_test_closure_variant (GClosure *closure, GVariant* arg)
     254                 :            : {
     255                 :          1 :   GValue return_value = {0, };
     256                 :          1 :   GValue arguments[1] = {{0,} };
     257                 :            :   GVariant *ret;
     258                 :            : 
     259                 :          1 :   g_value_init (&return_value, G_TYPE_VARIANT);
     260                 :            : 
     261                 :          1 :   g_value_init (&arguments[0], G_TYPE_VARIANT);
     262                 :          1 :   g_value_set_variant (&arguments[0], arg);
     263                 :            : 
     264                 :          1 :   g_closure_invoke (closure,
     265                 :            :                     &return_value,
     266                 :            :                     1, arguments,
     267                 :            :                     NULL);
     268                 :            : 
     269                 :          1 :   ret = g_value_get_variant (&return_value);
     270         [ +  - ]:          1 :   if (ret != NULL)
     271                 :          1 :     g_variant_ref (ret);
     272                 :            : 
     273                 :          1 :   g_value_unset (&return_value);
     274                 :          1 :   g_value_unset (&arguments[0]);
     275                 :            : 
     276                 :          1 :   return ret;
     277                 :            : }
     278                 :            : 
     279                 :            : /**
     280                 :            :  * regress_test_value_arg:
     281                 :            :  * @v: (transfer none): a GValue expected to contain an int
     282                 :            :  *
     283                 :            :  * Return value: the int contained in the GValue.
     284                 :            :  */
     285                 :            : int
     286                 :          1 : regress_test_int_value_arg(const GValue *v)
     287                 :            : {
     288                 :            :   int i;
     289                 :            : 
     290                 :          1 :   i = g_value_get_int (v);
     291                 :            : 
     292                 :          1 :   return i;
     293                 :            : }
     294                 :            : 
     295                 :            : static GValue global_value;
     296                 :            : /**
     297                 :            :  * regress_test_value_return:
     298                 :            :  * @i: an int
     299                 :            :  *
     300                 :            :  * Return value: (transfer none): the int wrapped in a GValue.
     301                 :            :  */
     302                 :            : const GValue *
     303                 :          1 : regress_test_value_return(int i)
     304                 :            : {
     305                 :          1 :   memset(&global_value, '\0', sizeof(GValue));
     306                 :            : 
     307                 :          1 :   g_value_init (&global_value, G_TYPE_INT);
     308                 :          1 :   g_value_set_int (&global_value, i);
     309                 :            : 
     310                 :          1 :   return &global_value;
     311                 :            : }
     312                 :            : 
     313                 :            : /************************************************************************/
     314                 :            : /* foreign structs */
     315                 :            : 
     316                 :            : #ifndef _GI_DISABLE_CAIRO
     317                 :            : /**
     318                 :            :  * regress_test_cairo_context_full_return:
     319                 :            :  *
     320                 :            :  * Returns: (transfer full):
     321                 :            :  */
     322                 :            : cairo_t *
     323                 :          2 : regress_test_cairo_context_full_return (void)
     324                 :            : {
     325                 :            :   cairo_surface_t *surface;
     326                 :            :   cairo_t *cr;
     327                 :          2 :   surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 10, 10);
     328                 :          2 :   cr = cairo_create (surface);
     329                 :          2 :   cairo_surface_destroy (surface);
     330                 :          2 :   return cr;
     331                 :            : }
     332                 :            : 
     333                 :            : /**
     334                 :            :  * regress_test_cairo_context_none_in:
     335                 :            :  * @context: (transfer none):
     336                 :            :  */
     337                 :            : void
     338                 :          1 : regress_test_cairo_context_none_in (cairo_t *context)
     339                 :            : {
     340                 :          1 :   cairo_surface_t *surface = cairo_get_target (context);
     341                 :            : 
     342                 :          1 :   g_assert (cairo_image_surface_get_format (surface) == CAIRO_FORMAT_ARGB32);
     343                 :          1 :   g_assert (cairo_image_surface_get_width (surface) == 10);
     344                 :          1 :   g_assert (cairo_image_surface_get_height (surface) == 10);
     345                 :          1 : }
     346                 :            : 
     347                 :            : 
     348                 :            : /**
     349                 :            :  * regress_test_cairo_surface_none_return:
     350                 :            :  *
     351                 :            :  * Returns: (transfer none):
     352                 :            :  */
     353                 :            : cairo_surface_t *
     354                 :          1 : regress_test_cairo_surface_none_return (void)
     355                 :            : {
     356                 :            :   static cairo_surface_t *surface;
     357                 :            : 
     358         [ +  - ]:          1 :   if (surface == NULL) {
     359                 :          1 :     surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 10, 10);
     360                 :            :   }
     361                 :            : 
     362                 :          1 :   return surface;
     363                 :            : }
     364                 :            : 
     365                 :            : /**
     366                 :            :  * regress_test_cairo_surface_full_return:
     367                 :            :  *
     368                 :            :  * Returns: (transfer full):
     369                 :            :  */
     370                 :            : cairo_surface_t *
     371                 :          1 : regress_test_cairo_surface_full_return (void)
     372                 :            : {
     373                 :          1 :   return cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 10, 10);
     374                 :            : }
     375                 :            : 
     376                 :            : /**
     377                 :            :  * regress_test_cairo_surface_none_in:
     378                 :            :  * @surface: (transfer none):
     379                 :            :  */
     380                 :            : void
     381                 :          1 : regress_test_cairo_surface_none_in (cairo_surface_t *surface)
     382                 :            : {
     383                 :          1 :   g_assert (cairo_image_surface_get_format (surface) == CAIRO_FORMAT_ARGB32);
     384                 :          1 :   g_assert (cairo_image_surface_get_width (surface) == 10);
     385                 :          1 :   g_assert (cairo_image_surface_get_height (surface) == 10);
     386                 :          1 : }
     387                 :            : 
     388                 :            : /**
     389                 :            :  * regress_test_cairo_surface_full_out:
     390                 :            :  * @surface: (out) (transfer full):
     391                 :            :  */
     392                 :            : void
     393                 :          1 : regress_test_cairo_surface_full_out (cairo_surface_t **surface)
     394                 :            : {
     395                 :          1 :   *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 10, 10);
     396                 :          1 : }
     397                 :            : #endif
     398                 :            : 
     399                 :            : /**
     400                 :            :  * regress_test_gvariant_i:
     401                 :            :  *
     402                 :            :  * Returns: (transfer none): New variant
     403                 :            :  */
     404                 :            : GVariant *
     405                 :          1 : regress_test_gvariant_i (void)
     406                 :            : {
     407                 :          1 :   return g_variant_new_int32 (1);
     408                 :            : }
     409                 :            : 
     410                 :            : /**
     411                 :            :  * regress_test_gvariant_s:
     412                 :            :  *
     413                 :            :  * Returns: (transfer none): New variant
     414                 :            :  */
     415                 :            : GVariant *
     416                 :          1 : regress_test_gvariant_s (void)
     417                 :            : {
     418                 :          1 :   return g_variant_new_string ("one");
     419                 :            : }
     420                 :            : 
     421                 :            : /**
     422                 :            :  * regress_test_gvariant_asv:
     423                 :            :  *
     424                 :            :  * Returns: (transfer none): New variant
     425                 :            :  */
     426                 :            : GVariant *
     427                 :          1 : regress_test_gvariant_asv (void)
     428                 :            : {
     429                 :            :   GVariantBuilder b;
     430                 :            : 
     431                 :          1 :   g_variant_builder_init (&b, G_VARIANT_TYPE ("a{sv}"));
     432                 :            : 
     433                 :          1 :   g_variant_builder_add (&b, "{sv}", "name", g_variant_new_string ("foo"));
     434                 :          1 :   g_variant_builder_add (&b, "{sv}", "timeout", g_variant_new_int32 (10));
     435                 :            : 
     436                 :          1 :   return g_variant_builder_end (&b);
     437                 :            : }
     438                 :            : 
     439                 :            : /**
     440                 :            :  * regress_test_gvariant_v:
     441                 :            :  *
     442                 :            :  * Returns: (transfer none): New variant
     443                 :            :  */
     444                 :            : GVariant *
     445                 :          1 : regress_test_gvariant_v (void)
     446                 :            : {
     447                 :          1 :   return g_variant_new_variant (g_variant_new_string ("contents"));
     448                 :            : }
     449                 :            : 
     450                 :            : /**
     451                 :            :  * regress_test_gvariant_as:
     452                 :            :  *
     453                 :            :  * Returns: (transfer none): New variant
     454                 :            :  */
     455                 :            : GVariant *
     456                 :          1 : regress_test_gvariant_as (void)
     457                 :            : {
     458                 :          1 :   const char *as[] = { "one", "two", "three", NULL };
     459                 :            : 
     460                 :          1 :   return g_variant_new_strv (as, -1);
     461                 :            : }
     462                 :            : 
     463                 :            : /************************************************************************/
     464                 :            : /* utf8 */
     465                 :            : /* insert BLACK HEART SUIT to ensure UTF-8 doesn't get mangled */
     466                 :            : static const char utf8_const[]    = "const \xe2\x99\xa5 utf8";
     467                 :            : static const char utf8_nonconst[] = "nonconst \xe2\x99\xa5 utf8";
     468                 :            : 
     469                 :            : /**
     470                 :            :  * regress_test_utf8_const_return:
     471                 :            :  *
     472                 :            :  * Return value: UTF-8 string
     473                 :            :  */
     474                 :            : const char *
     475                 :          1 : regress_test_utf8_const_return (void)
     476                 :            : {
     477                 :            :   /* transfer mode none */
     478                 :          1 :   return utf8_const;
     479                 :            : }
     480                 :            : 
     481                 :            : /**
     482                 :            :  * regress_test_utf8_nonconst_return:
     483                 :            :  *
     484                 :            :  * Return value: (transfer full): UTF-8 string
     485                 :            :  */
     486                 :            : char *
     487                 :          1 : regress_test_utf8_nonconst_return (void)
     488                 :            : {
     489                 :          1 :   return g_strdup (utf8_nonconst);
     490                 :            : }
     491                 :            : 
     492                 :            : /**
     493                 :            :  * regress_test_utf8_const_in:
     494                 :            :  *
     495                 :            :  */
     496                 :            : void
     497                 :          1 : regress_test_utf8_const_in (const char *in)
     498                 :            : {
     499                 :            :   /* transfer mode none */
     500                 :          1 :   g_assert (strcmp (in, utf8_const) == 0);
     501                 :          1 : }
     502                 :            : 
     503                 :            : /**
     504                 :            :  * regress_test_utf8_out:
     505                 :            :  * @out: (out) (transfer full):
     506                 :            :  */
     507                 :            : void
     508                 :          1 : regress_test_utf8_out (char **out)
     509                 :            : {
     510                 :            :   /* out parameter, transfer mode full */
     511                 :          1 :   *out = g_strdup (utf8_nonconst);
     512                 :          1 : }
     513                 :            : 
     514                 :            : /**
     515                 :            :  * regress_test_utf8_inout:
     516                 :            :  * @inout: (inout) (transfer full):
     517                 :            :  */
     518                 :            : void
     519                 :          0 : regress_test_utf8_inout (char **inout)
     520                 :            : {
     521                 :            :   /* inout parameter, transfer mode full */
     522                 :          0 :   g_assert (strcmp (*inout, utf8_const) == 0);
     523                 :          0 :   g_free (*inout);
     524                 :          0 :   *inout = g_strdup (utf8_nonconst);
     525                 :          0 : }
     526                 :            : 
     527                 :            : /**
     528                 :            :  * regress_test_filename_return:
     529                 :            :  *
     530                 :            :  * Return value: (element-type filename) (transfer full): list of strings
     531                 :            :  */
     532                 :            : GSList *
     533                 :          1 : regress_test_filename_return (void)
     534                 :            : {
     535                 :          1 :   GSList *filenames = NULL;
     536                 :          1 :   filenames = g_slist_prepend (filenames, g_filename_from_utf8("/etc/fstab", -1, NULL, NULL, NULL));
     537                 :          1 :   filenames = g_slist_prepend (filenames, g_filename_from_utf8("åäö", -1, NULL, NULL, NULL));
     538                 :          1 :   return filenames;
     539                 :            : }
     540                 :            : 
     541                 :            : /* in arguments after out arguments */
     542                 :            : 
     543                 :            : /**
     544                 :            :  * regress_test_int_out_utf8:
     545                 :            :  * @length: (out):
     546                 :            :  * @in:
     547                 :            :  */
     548                 :            : void
     549                 :          1 : regress_test_int_out_utf8 (int *length, const char *in)
     550                 :            : {
     551                 :          1 :     *length = g_utf8_strlen(in, -1);
     552                 :          1 : }
     553                 :            : 
     554                 :            : 
     555                 :            : /* multiple output arguments */
     556                 :            : 
     557                 :            : /**
     558                 :            :  * regress_test_multi_double_args:
     559                 :            :  * @in:
     560                 :            :  * @one: (out):
     561                 :            :  * @two: (out):
     562                 :            :  */
     563                 :            : void
     564                 :          1 : regress_test_multi_double_args (gdouble in, gdouble *one, gdouble *two)
     565                 :            : {
     566                 :          1 :   *one = in * 2;
     567                 :          1 :   *two = in * 3;
     568                 :          1 : }
     569                 :            : 
     570                 :            : /**
     571                 :            :  * regress_test_utf8_out_out:
     572                 :            :  * @out0: (out) (transfer full): a copy of "first"
     573                 :            :  * @out1: (out) (transfer full): a copy of "second"
     574                 :            :  */
     575                 :            : void
     576                 :          1 : regress_test_utf8_out_out (char **out0, char **out1)
     577                 :            : {
     578                 :          1 :   *out0 = g_strdup ("first");
     579                 :          1 :   *out1 = g_strdup ("second");
     580                 :          1 : }
     581                 :            : 
     582                 :            : /**
     583                 :            :  * regress_test_utf8_out_nonconst_return:
     584                 :            :  * @out: (out) (transfer full): a copy of "second"
     585                 :            :  *
     586                 :            :  * Returns: (transfer full): a copy of "first"
     587                 :            :  */
     588                 :            : char *
     589                 :          1 : regress_test_utf8_out_nonconst_return (char **out)
     590                 :            : {
     591                 :          1 :   *out = g_strdup ("second");
     592                 :          1 :   return g_strdup ("first");
     593                 :            : }
     594                 :            : 
     595                 :            : /**
     596                 :            :  * regress_test_utf8_null_in:
     597                 :            :  * @in: (allow-none):
     598                 :            :  */
     599                 :            : void
     600                 :          1 : regress_test_utf8_null_in (char *in)
     601                 :            : {
     602                 :          1 :   g_assert (in == NULL);
     603                 :          1 : }
     604                 :            : 
     605                 :            : /**
     606                 :            :  * regress_test_utf8_null_out:
     607                 :            :  * @char_out: (allow-none) (out):
     608                 :            :  */
     609                 :          1 : void regress_test_utf8_null_out (char **char_out)
     610                 :            : {
     611                 :          1 :   *char_out = NULL;
     612                 :          1 : }
     613                 :            : 
     614                 :            : 
     615                 :            : /* non-basic-types */
     616                 :            : 
     617                 :            : static const char *test_sequence[] = {"1", "2", "3"};
     618                 :            : 
     619                 :            : /* array */
     620                 :            : 
     621                 :            : /**
     622                 :            :  * regress_test_array_int_in:
     623                 :            :  * @n_ints:
     624                 :            :  * @ints: (array length=n_ints): List of ints
     625                 :            :  */
     626                 :            : int
     627                 :          1 : regress_test_array_int_in (int n_ints, int *ints)
     628                 :            : {
     629                 :          1 :   int i, sum = 0;
     630         [ +  + ]:          5 :   for (i = 0; i < n_ints; i++)
     631                 :          4 :     sum += ints[i];
     632                 :          1 :   return sum;
     633                 :            : }
     634                 :            : 
     635                 :            : /**
     636                 :            :  * regress_test_array_int_out:
     637                 :            :  * @n_ints: (out): the length of @ints
     638                 :            :  * @ints: (out) (array length=n_ints) (transfer full): a list of 5 integers, from 0 to 4 in consecutive order
     639                 :            :  */
     640                 :            : void
     641                 :          1 : regress_test_array_int_out (int *n_ints, int **ints)
     642                 :            : {
     643                 :            :   int i;
     644                 :          1 :   *n_ints = 5;
     645                 :          1 :   *ints = g_malloc0(sizeof(**ints) * *n_ints);
     646         [ +  + ]:          5 :   for (i = 1; i < *n_ints; i++)
     647                 :          4 :     (*ints)[i] = (*ints)[i-1] + 1;
     648                 :          1 : }
     649                 :            : 
     650                 :            : /**
     651                 :            :  * regress_test_array_int_inout:
     652                 :            :  * @n_ints: (inout): the length of @ints
     653                 :            :  * @ints: (inout) (array length=n_ints) (transfer full): a list of integers whose items will be increased by 1, except the first that will be dropped
     654                 :            :  */
     655                 :            : void
     656                 :          0 : regress_test_array_int_inout (int *n_ints, int **ints)
     657                 :            : {
     658                 :            :   int i;
     659                 :            :   int *new_ints;
     660                 :            : 
     661         [ #  # ]:          0 :   if (0 < *n_ints)
     662                 :            :     {
     663                 :          0 :       *n_ints -= 1;
     664                 :          0 :       new_ints = g_malloc(sizeof(**ints) * *n_ints);
     665         [ #  # ]:          0 :       for (i = 0; i < *n_ints; i++)
     666                 :          0 :         new_ints[i] = (*ints)[i + 1] + 1;
     667                 :            : 
     668                 :          0 :       g_free (*ints);
     669                 :          0 :       *ints = new_ints;
     670                 :            :     }
     671                 :          0 : }
     672                 :            : 
     673                 :            : /**
     674                 :            :  * regress_test_array_gint8_in:
     675                 :            :  * @n_ints:
     676                 :            :  * @ints: (array length=n_ints): List of ints
     677                 :            :  */
     678                 :            : int
     679                 :          2 : regress_test_array_gint8_in (int n_ints, gint8 *ints)
     680                 :            : {
     681                 :          2 :   int i, sum = 0;
     682         [ +  + ]:         10 :   for (i = 0; i < n_ints; i++)
     683                 :          8 :     sum += ints[i];
     684                 :          2 :   return sum;
     685                 :            : }
     686                 :            : 
     687                 :            : /**
     688                 :            :  * regress_test_array_gint16_in:
     689                 :            :  * @n_ints:
     690                 :            :  * @ints: (array length=n_ints): List of ints
     691                 :            :  */
     692                 :            : int
     693                 :          3 : regress_test_array_gint16_in (int n_ints, gint16 *ints)
     694                 :            : {
     695                 :          3 :   int i, sum = 0;
     696         [ +  + ]:         15 :   for (i = 0; i < n_ints; i++)
     697                 :         12 :     sum += ints[i];
     698                 :          3 :   return sum;
     699                 :            : }
     700                 :            : 
     701                 :            : /**
     702                 :            :  * regress_test_array_gint32_in:
     703                 :            :  * @n_ints:
     704                 :            :  * @ints: (array length=n_ints): List of ints
     705                 :            :  */
     706                 :            : gint32
     707                 :          1 : regress_test_array_gint32_in (int n_ints, gint32 *ints)
     708                 :            : {
     709                 :            :   int i;
     710                 :          1 :   gint32 sum = 0;
     711         [ +  + ]:          5 :   for (i = 0; i < n_ints; i++)
     712                 :          4 :     sum += ints[i];
     713                 :          1 :   return sum;
     714                 :            : }
     715                 :            : 
     716                 :            : /**
     717                 :            :  * regress_test_array_gint64_in:
     718                 :            :  * @n_ints:
     719                 :            :  * @ints: (array length=n_ints): List of ints
     720                 :            :  */
     721                 :            : gint64
     722                 :          1 : regress_test_array_gint64_in (int n_ints, gint64 *ints)
     723                 :            : {
     724                 :            :   int i;
     725                 :          1 :   gint64 sum = 0;
     726         [ +  + ]:          5 :   for (i = 0; i < n_ints; i++)
     727                 :          4 :     sum += ints[i];
     728                 :          1 :   return sum;
     729                 :            : }
     730                 :            : 
     731                 :            : /**
     732                 :            :  * regress_test_strv_in:
     733                 :            :  * @arr: (array zero-terminated=1) (transfer none):
     734                 :            :  */
     735                 :            : gboolean
     736                 :          2 : regress_test_strv_in (char **arr)
     737                 :            : {
     738         [ -  + ]:          2 :   if (g_strv_length (arr) != 3)
     739                 :          0 :     return FALSE;
     740         [ +  + ]:          2 :   if (strcmp (arr[0], "1") != 0)
     741                 :          1 :     return FALSE;
     742         [ -  + ]:          1 :   if (strcmp (arr[1], "2") != 0)
     743                 :          0 :     return FALSE;
     744         [ -  + ]:          1 :   if (strcmp (arr[2], "3") != 0)
     745                 :          0 :     return FALSE;
     746                 :          1 :   return TRUE;
     747                 :            : }
     748                 :            : 
     749                 :            : /**
     750                 :            :  * regress_test_array_gtype_in:
     751                 :            :  * @n_types:
     752                 :            :  * @types: (array length=n_types): List of types
     753                 :            :  *
     754                 :            :  * Return value: (transfer full): string representation of provided types
     755                 :            :  */
     756                 :            : char *
     757                 :          1 : regress_test_array_gtype_in (int n_types, GType *types)
     758                 :            : {
     759                 :            :   GString *string;
     760                 :            :   int i;
     761                 :            : 
     762                 :          1 :   string = g_string_new ("[");
     763         [ +  + ]:          4 :   for (i = 0; i < n_types; i++)
     764                 :            :     {
     765                 :          3 :       g_string_append (string, g_type_name (types[i]));
     766                 :            :       g_string_append_c (string, ',');
     767                 :            :     }
     768                 :            :   g_string_append_c (string, ']');
     769                 :          1 :   return g_string_free (string, FALSE);
     770                 :            : }
     771                 :            : 
     772                 :            : /**
     773                 :            :  * regress_test_strv_out:
     774                 :            :  *
     775                 :            :  * Returns: (transfer full):
     776                 :            :  */
     777                 :            : char **
     778                 :          2 : regress_test_strv_out (void)
     779                 :            : {
     780                 :          2 :   int i = 0;
     781                 :          2 :   int n = 6;
     782                 :          2 :   char **ret = g_new (char *, n);
     783                 :          2 :   ret[i++] = g_strdup ("thanks");
     784                 :          2 :   ret[i++] = g_strdup ("for");
     785                 :          2 :   ret[i++] = g_strdup ("all");
     786                 :          2 :   ret[i++] = g_strdup ("the");
     787                 :          2 :   ret[i++] = g_strdup ("fish");
     788                 :          2 :   ret[i++] = NULL;
     789                 :          2 :   g_assert (i == n);
     790                 :          2 :   return ret;
     791                 :            : }
     792                 :            : 
     793                 :            : /**
     794                 :            :  * regress_test_strv_out_container:
     795                 :            :  *
     796                 :            :  * Return value: (array zero-terminated=1) (transfer container):
     797                 :            :  */
     798                 :            : const char **
     799                 :          1 : regress_test_strv_out_container (void)
     800                 :            : {
     801                 :          1 :   const char **ret = g_new (const char *, 4);
     802                 :          1 :   ret[0] = "1";
     803                 :          1 :   ret[1] = "2";
     804                 :          1 :   ret[2] = "3";
     805                 :          1 :   ret[3] = NULL;
     806                 :          1 :   return ret;
     807                 :            : }
     808                 :            : 
     809                 :            : /**
     810                 :            :  * regress_test_strv_outarg:
     811                 :            :  * @retp: (array zero-terminated=1) (out) (transfer container):
     812                 :            :  */
     813                 :            : void
     814                 :          1 : regress_test_strv_outarg (const char ***retp)
     815                 :            : {
     816                 :          1 :   const char **ret = g_new (const char *, 4);
     817                 :          1 :   ret[0] = "1";
     818                 :          1 :   ret[1] = "2";
     819                 :          1 :   ret[2] = "3";
     820                 :          1 :   ret[3] = NULL;
     821                 :          1 :   *retp = ret;
     822                 :          1 : }
     823                 :            : 
     824                 :            : /**
     825                 :            :  * regress_test_array_fixed_size_int_in:
     826                 :            :  * @ints: (array fixed-size=5): a list of 5 integers
     827                 :            :  *
     828                 :            :  * Returns: the sum of the items in @ints
     829                 :            :  */
     830                 :            : int
     831                 :          1 : regress_test_array_fixed_size_int_in (int *ints)
     832                 :            : {
     833                 :          1 :   int i, sum = 0;
     834         [ +  + ]:          6 :   for (i = 0; i < 5; i++)
     835                 :          5 :     sum += ints[i];
     836                 :          1 :   return sum;
     837                 :            : }
     838                 :            : 
     839                 :            : /**
     840                 :            :  * regress_test_array_fixed_size_int_out:
     841                 :            :  * @ints: (out) (array fixed-size=5) (transfer full): a list of 5 integers ranging from 0 to 4
     842                 :            :  */
     843                 :            : void
     844                 :          1 : regress_test_array_fixed_size_int_out (int **ints)
     845                 :            : {
     846                 :            :   int i;
     847                 :          1 :   *ints = g_malloc0(sizeof(**ints) * 5);
     848         [ +  + ]:          5 :   for (i = 1; i < 5; i++)
     849                 :          4 :     (*ints)[i] = (*ints)[i-1] + 1;
     850                 :          1 : }
     851                 :            : 
     852                 :            : /**
     853                 :            :  * regress_test_array_fixed_size_int_return:
     854                 :            :  *
     855                 :            :  * Returns: (array fixed-size=5) (transfer full): a list of 5 integers ranging from 0 to 4
     856                 :            :  */
     857                 :            : int *
     858                 :          1 : regress_test_array_fixed_size_int_return (void)
     859                 :            : {
     860                 :            :   int i, *ints;
     861                 :          1 :   ints = g_malloc0(sizeof(*ints) * 5);
     862         [ +  + ]:          5 :   for (i = 1; i < 5; i++)
     863                 :          4 :     ints[i] = ints[i-1] + 1;
     864                 :          1 :   return ints;
     865                 :            : }
     866                 :            : 
     867                 :            : /**
     868                 :            :  * regress_test_array_static_in_int
     869                 :            :  * @x: (array fixed-size=10): a list of 10 integers
     870                 :            :  */
     871                 :            : #if (defined(__GNUC__) || defined(__clang__)) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
     872                 :            : void
     873                 :          1 : regress_test_array_static_in_int (int x[static 10])
     874                 :            : {
     875                 :          1 : }
     876                 :            : #else
     877                 :            : void
     878                 :            : regress_test_array_static_in_int (int x[10])
     879                 :            : {
     880                 :            : }
     881                 :            : #endif
     882                 :            : 
     883                 :            : /**
     884                 :            :  * regress_test_strv_out_c:
     885                 :            :  *
     886                 :            :  * Returns: (transfer none):
     887                 :            :  */
     888                 :            : const char * const*
     889                 :          1 : regress_test_strv_out_c (void)
     890                 :            : {
     891                 :            :   static char **ret = NULL;
     892                 :            : 
     893         [ +  - ]:          1 :   if (ret == NULL)
     894                 :          1 :     ret = regress_test_strv_out ();
     895                 :            : 
     896                 :          1 :   return (const char * const *) ret;
     897                 :            : }
     898                 :            : 
     899                 :            : /**
     900                 :            :  * regress_test_array_int_full_out:
     901                 :            :  * @len: length of the returned array.
     902                 :            :  *
     903                 :            :  * Returns: (array length=len) (transfer full): a new array of integers.
     904                 :            :  */
     905                 :            : int *
     906                 :          1 : regress_test_array_int_full_out(int *len)
     907                 :            : {
     908                 :            :   int *result, i;
     909                 :          1 :   *len = 5;
     910                 :          1 :   result = g_malloc0(sizeof(*result) * (*len));
     911         [ +  + ]:          5 :   for (i=1; i < (*len); i++)
     912                 :          4 :     result[i] = result[i-1] + 1;
     913                 :          1 :   return result;
     914                 :            : }
     915                 :            : 
     916                 :            : /**
     917                 :            :  * regress_test_array_int_none_out:
     918                 :            :  * @len: length of the returned array.
     919                 :            :  *
     920                 :            :  * Returns: (array length=len) (transfer none): a static array of integers.
     921                 :            :  */
     922                 :            : int *
     923                 :          1 : regress_test_array_int_none_out(int *len)
     924                 :            : {
     925                 :            :   static int result[5] = { 1, 2, 3, 4, 5 };
     926                 :          1 :   *len = 5;
     927                 :          1 :   return result;
     928                 :            : }
     929                 :            : 
     930                 :            : /**
     931                 :            :  * regress_test_array_int_null_in:
     932                 :            :  * @arr: (array length=len) (allow-none):
     933                 :            :  * @len: length
     934                 :            :  */
     935                 :            : void
     936                 :          1 : regress_test_array_int_null_in (int *arr,
     937                 :            :                                 int  len G_GNUC_UNUSED)
     938                 :            : {
     939                 :          1 :   g_assert (arr == NULL);
     940                 :          1 : }
     941                 :            : 
     942                 :            : /**
     943                 :            :  * regress_test_array_int_null_out:
     944                 :            :  * @arr: (out) (array length=len) (allow-none):
     945                 :            :  * @len: (out) : length
     946                 :            :  */
     947                 :            : void
     948                 :          1 : regress_test_array_int_null_out (int **arr, int *len)
     949                 :            : {
     950                 :          1 :   *arr = NULL;
     951                 :          1 :   *len = 0;
     952                 :          1 : }
     953                 :            : 
     954                 :            : /* interface */
     955                 :            : 
     956                 :            : /************************************************************************/
     957                 :            : /* GList */
     958                 :            : 
     959                 :            : static /*const*/ GList *
     960                 :          4 : regress_test_sequence_list (void)
     961                 :            : {
     962                 :            :     static GList *list = NULL;
     963         [ +  + ]:          4 :     if (!list) {
     964                 :            :         gsize i;
     965         [ +  + ]:          4 :         for (i = 0; i < G_N_ELEMENTS(test_sequence); ++i) {
     966                 :          3 :             list = g_list_prepend (list, (gpointer)test_sequence[i]);
     967                 :            :         }
     968                 :          1 :         list = g_list_reverse (list);
     969                 :            :     }
     970                 :          4 :     return list;
     971                 :            : }
     972                 :            : 
     973                 :            : /**
     974                 :            :  * regress_test_glist_nothing_return:
     975                 :            :  *
     976                 :            :  * Return value: (element-type utf8) (transfer none):
     977                 :            :  */
     978                 :            : const GList *
     979                 :          1 : regress_test_glist_nothing_return (void)
     980                 :            : {
     981                 :          1 :   return regress_test_sequence_list ();
     982                 :            : }
     983                 :            : 
     984                 :            : /**
     985                 :            :  * regress_test_glist_nothing_return2:
     986                 :            :  *
     987                 :            :  * Return value: (element-type utf8) (transfer none):
     988                 :            :  */
     989                 :            : GList *
     990                 :          1 : regress_test_glist_nothing_return2 (void)
     991                 :            : {
     992                 :          1 :   return regress_test_sequence_list ();
     993                 :            : }
     994                 :            : 
     995                 :            : /**
     996                 :            :  * regress_test_glist_container_return:
     997                 :            :  *
     998                 :            :  * Return value: (element-type utf8) (transfer container):
     999                 :            :  */
    1000                 :            : GList *
    1001                 :          1 : regress_test_glist_container_return (void)
    1002                 :            : {
    1003                 :          1 :   return g_list_copy (regress_test_sequence_list ());
    1004                 :            : }
    1005                 :            : 
    1006                 :            : /**
    1007                 :            :  * regress_test_glist_everything_return:
    1008                 :            :  *
    1009                 :            :  * Return value: (element-type utf8) (transfer full):
    1010                 :            :  */
    1011                 :            : GList *
    1012                 :          1 : regress_test_glist_everything_return (void)
    1013                 :            : {
    1014                 :            :   GList *list;
    1015                 :            :   GList *l;
    1016                 :            : 
    1017                 :          1 :   list = g_list_copy (regress_test_sequence_list ());
    1018         [ +  + ]:          4 :   for (l = list; l != NULL; l = l->next)
    1019                 :          6 :       l->data = g_strdup (l->data);
    1020                 :          1 :   return list;
    1021                 :            : }
    1022                 :            : 
    1023                 :            : static void
    1024                 :          2 : regress_assert_test_sequence_list (const GList *in)
    1025                 :            : {
    1026                 :            :   const GList *l;
    1027                 :            :   gsize i;
    1028                 :            : 
    1029         [ +  + ]:          8 :   for (i = 0, l = in; l != NULL; ++i, l = l->next) {
    1030                 :          6 :       g_assert (i < G_N_ELEMENTS(test_sequence));
    1031                 :          6 :       g_assert (strcmp (l->data, test_sequence[i]) == 0);
    1032                 :            :   }
    1033                 :          2 :   g_assert (i == G_N_ELEMENTS(test_sequence));
    1034                 :          2 : }
    1035                 :            : 
    1036                 :            : /**
    1037                 :            :  * regress_test_glist_gtype_container_in:
    1038                 :            :  * @in: (element-type GType) (transfer container):
    1039                 :            :  */
    1040                 :            : void
    1041                 :          1 : regress_test_glist_gtype_container_in (GList *in)
    1042                 :            : {
    1043                 :          1 :   GList *l = in;
    1044                 :            : 
    1045                 :          1 :   g_assert (GPOINTER_TO_SIZE (l->data) == REGRESS_TEST_TYPE_OBJ);
    1046                 :          1 :   l = l->next;
    1047                 :          1 :   g_assert (GPOINTER_TO_SIZE (l->data) == REGRESS_TEST_TYPE_SUB_OBJ);
    1048                 :          1 :   l = l->next;
    1049                 :          1 :   g_assert (l == NULL);
    1050                 :            : 
    1051                 :          1 :   g_list_free (in);
    1052                 :          1 : }
    1053                 :            : 
    1054                 :            : /**
    1055                 :            :  * regress_test_glist_nothing_in:
    1056                 :            :  * @in: (element-type utf8):
    1057                 :            :  */
    1058                 :            : void
    1059                 :          1 : regress_test_glist_nothing_in (const GList *in)
    1060                 :            : {
    1061                 :          1 :   regress_assert_test_sequence_list (in);
    1062                 :          1 : }
    1063                 :            : 
    1064                 :            : /**
    1065                 :            :  * regress_test_glist_nothing_in2:
    1066                 :            :  * @in: (element-type utf8):
    1067                 :            :  */
    1068                 :            : void
    1069                 :          1 : regress_test_glist_nothing_in2 (GList *in)
    1070                 :            : {
    1071                 :          1 :   regress_assert_test_sequence_list (in);
    1072                 :          1 : }
    1073                 :            : 
    1074                 :            : /**
    1075                 :            :  * regress_test_glist_null_in:
    1076                 :            :  * @in: (element-type utf8) (allow-none):
    1077                 :            :  */
    1078                 :            : void
    1079                 :          1 : regress_test_glist_null_in (GSList *in)
    1080                 :            : {
    1081                 :          1 :   g_assert (in == NULL);
    1082                 :          1 : }
    1083                 :            : 
    1084                 :            : /**
    1085                 :            :  * regress_test_glist_null_out:
    1086                 :            :  * @out_list: (out) (element-type utf8) (allow-none):
    1087                 :            :  */
    1088                 :            : void
    1089                 :          1 : regress_test_glist_null_out (GSList **out_list)
    1090                 :            : {
    1091                 :          1 :   *out_list = NULL;
    1092                 :          1 : }
    1093                 :            : 
    1094                 :            : 
    1095                 :            : /************************************************************************/
    1096                 :            : /* GSList */
    1097                 :            : 
    1098                 :            : static /*const*/ GSList *
    1099                 :          4 : regress_test_sequence_slist (void)
    1100                 :            : {
    1101                 :            :     static GSList *list = NULL;
    1102         [ +  + ]:          4 :     if (!list) {
    1103                 :            :         gsize i;
    1104         [ +  + ]:          4 :         for (i = 0; i < G_N_ELEMENTS(test_sequence); ++i) {
    1105                 :          3 :             list = g_slist_prepend (list, (gpointer)test_sequence[i]);
    1106                 :            :         }
    1107                 :          1 :         list = g_slist_reverse (list);
    1108                 :            :     }
    1109                 :          4 :     return list;
    1110                 :            : }
    1111                 :            : 
    1112                 :            : /**
    1113                 :            :  * regress_test_gslist_nothing_return:
    1114                 :            :  *
    1115                 :            :  * Return value: (element-type utf8) (transfer none):
    1116                 :            :  */
    1117                 :            : const GSList *
    1118                 :          1 : regress_test_gslist_nothing_return (void)
    1119                 :            : {
    1120                 :          1 :   return regress_test_sequence_slist ();
    1121                 :            : }
    1122                 :            : 
    1123                 :            : /**
    1124                 :            :  * regress_test_gslist_nothing_return2:
    1125                 :            :  *
    1126                 :            :  * Return value: (element-type utf8) (transfer none):
    1127                 :            :  */
    1128                 :            : GSList *
    1129                 :          1 : regress_test_gslist_nothing_return2 (void)
    1130                 :            : {
    1131                 :          1 :   return regress_test_sequence_slist ();
    1132                 :            : }
    1133                 :            : 
    1134                 :            : /**
    1135                 :            :  * regress_test_gslist_container_return:
    1136                 :            :  *
    1137                 :            :  * Return value: (element-type utf8) (transfer container):
    1138                 :            :  */
    1139                 :            : GSList *
    1140                 :          1 : regress_test_gslist_container_return (void)
    1141                 :            : {
    1142                 :          1 :   return g_slist_copy (regress_test_sequence_slist ());
    1143                 :            : }
    1144                 :            : 
    1145                 :            : /**
    1146                 :            :  * regress_test_gslist_everything_return:
    1147                 :            :  *
    1148                 :            :  * Return value: (element-type utf8) (transfer full):
    1149                 :            :  */
    1150                 :            : GSList *
    1151                 :          1 : regress_test_gslist_everything_return (void)
    1152                 :            : {
    1153                 :            :   GSList *list;
    1154                 :            :   GSList *l;
    1155                 :            : 
    1156                 :          1 :   list = g_slist_copy (regress_test_sequence_slist ());
    1157         [ +  + ]:          4 :   for (l = list; l != NULL; l = l->next)
    1158                 :          6 :       l->data = g_strdup (l->data);
    1159                 :          1 :   return list;
    1160                 :            : }
    1161                 :            : 
    1162                 :            : static void
    1163                 :          2 : regress_assert_test_sequence_slist (const GSList *in)
    1164                 :            : {
    1165                 :            :   const GSList *l;
    1166                 :            :   gsize i;
    1167                 :            : 
    1168         [ +  + ]:          8 :   for (i = 0, l = in; l != NULL; ++i, l = l->next) {
    1169                 :          6 :       g_assert (i < G_N_ELEMENTS(test_sequence));
    1170                 :          6 :       g_assert (strcmp (l->data, test_sequence[i]) == 0);
    1171                 :            :   }
    1172                 :          2 :   g_assert (i == G_N_ELEMENTS(test_sequence));
    1173                 :          2 : }
    1174                 :            : 
    1175                 :            : /**
    1176                 :            :  * regress_test_gslist_nothing_in:
    1177                 :            :  * @in: (element-type utf8):
    1178                 :            :  */
    1179                 :            : void
    1180                 :          1 : regress_test_gslist_nothing_in (const GSList *in)
    1181                 :            : {
    1182                 :          1 :   regress_assert_test_sequence_slist (in);
    1183                 :          1 : }
    1184                 :            : 
    1185                 :            : /**
    1186                 :            :  * regress_test_gslist_nothing_in2:
    1187                 :            :  * @in: (element-type utf8):
    1188                 :            :  */
    1189                 :            : void
    1190                 :          1 : regress_test_gslist_nothing_in2 (GSList *in)
    1191                 :            : {
    1192                 :          1 :   regress_assert_test_sequence_slist (in);
    1193                 :          1 : }
    1194                 :            : 
    1195                 :            : /**
    1196                 :            :  * regress_test_gslist_null_in:
    1197                 :            :  * @in: (element-type utf8) (allow-none):
    1198                 :            :  */
    1199                 :            : void
    1200                 :          1 : regress_test_gslist_null_in (GSList *in)
    1201                 :            : {
    1202                 :          1 :   g_assert (in == NULL);
    1203                 :          1 : }
    1204                 :            : 
    1205                 :            : /**
    1206                 :            :  * regress_test_gslist_null_out:
    1207                 :            :  * @out_list: (out) (element-type utf8) (allow-none):
    1208                 :            :  */
    1209                 :            : void
    1210                 :          1 : regress_test_gslist_null_out (GSList **out_list)
    1211                 :            : {
    1212                 :          1 :   *out_list = NULL;
    1213                 :          1 : }
    1214                 :            : 
    1215                 :            : /************************************************************************/
    1216                 :            : /* GHash */
    1217                 :            : 
    1218                 :            : static const char *table_data[3][2] = {
    1219                 :            :   { "foo", "bar" }, { "baz", "bat" }, { "qux", "quux" }
    1220                 :            : };
    1221                 :            : 
    1222                 :            : static GHashTable *
    1223                 :          2 : regress_test_table_ghash_new_container (void)
    1224                 :            : {
    1225                 :            :   GHashTable *hash;
    1226                 :            :   int i;
    1227                 :          2 :   hash = g_hash_table_new(g_str_hash, g_str_equal);
    1228         [ +  + ]:          8 :   for (i=0; i<3; i++)
    1229                 :          6 :     g_hash_table_insert(hash,
    1230                 :          6 :                         (gpointer) table_data[i][0],
    1231                 :          6 :                         (gpointer) table_data[i][1]);
    1232                 :          2 :   return hash;
    1233                 :            : }
    1234                 :            : 
    1235                 :            : static GHashTable *
    1236                 :          3 : regress_test_table_ghash_new_full (void)
    1237                 :            : {
    1238                 :            :   GHashTable *hash;
    1239                 :            :   int i;
    1240                 :          3 :   hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
    1241         [ +  + ]:         12 :   for (i=0; i<3; i++)
    1242                 :          9 :     g_hash_table_insert(hash,
    1243                 :          9 :                         g_strdup(table_data[i][0]),
    1244                 :         18 :                         g_strdup(table_data[i][1]));
    1245                 :          3 :   return hash;
    1246                 :            : }
    1247                 :            : 
    1248                 :            : static /*const*/ GHashTable *
    1249                 :          4 : regress_test_table_ghash_const (void)
    1250                 :            : {
    1251                 :            :   static GHashTable *hash = NULL;
    1252         [ +  + ]:          4 :   if (!hash) {
    1253                 :          1 :     hash = regress_test_table_ghash_new_container();
    1254                 :            :   }
    1255                 :          4 :   return hash;
    1256                 :            : }
    1257                 :            : 
    1258                 :            : /**
    1259                 :            :  * regress_test_ghash_null_return:
    1260                 :            :  *
    1261                 :            :  * Return value: (element-type utf8 utf8) (transfer none) (allow-none):
    1262                 :            :  */
    1263                 :            : const GHashTable *
    1264                 :          1 : regress_test_ghash_null_return (void)
    1265                 :            : {
    1266                 :          1 :   return NULL;
    1267                 :            : }
    1268                 :            : 
    1269                 :            : /**
    1270                 :            :  * regress_test_ghash_nothing_return:
    1271                 :            :  *
    1272                 :            :  * Return value: (element-type utf8 utf8) (transfer none):
    1273                 :            :  */
    1274                 :            : const GHashTable *
    1275                 :          1 : regress_test_ghash_nothing_return (void)
    1276                 :            : {
    1277                 :          1 :   return regress_test_table_ghash_const ();
    1278                 :            : }
    1279                 :            : 
    1280                 :            : /**
    1281                 :            :  * regress_test_ghash_nothing_return2:
    1282                 :            :  *
    1283                 :            :  * Return value: (element-type utf8 utf8) (transfer none):
    1284                 :            :  */
    1285                 :            : GHashTable *
    1286                 :          1 : regress_test_ghash_nothing_return2 (void)
    1287                 :            : {
    1288                 :          1 :   return regress_test_table_ghash_const ();
    1289                 :            : }
    1290                 :            : 
    1291                 :            : static GValue *
    1292                 :          6 : g_value_new (GType type)
    1293                 :            : {
    1294                 :          6 :   GValue *value = g_slice_new0(GValue);
    1295                 :          6 :   g_value_init(value, type);
    1296                 :          6 :   return value;
    1297                 :            : }
    1298                 :            : 
    1299                 :            : static void
    1300                 :          0 : g_value_free (GValue *value)
    1301                 :            : {
    1302                 :          0 :   g_value_unset(value);
    1303                 :          0 :   g_slice_free(GValue, value);
    1304                 :          0 : }
    1305                 :            : 
    1306                 :            : static const gchar *string_array[] = {
    1307                 :            :   "first",
    1308                 :            :   "second",
    1309                 :            :   "third",
    1310                 :            :   NULL
    1311                 :            : };
    1312                 :            : 
    1313                 :            : /**
    1314                 :            :  * regress_test_ghash_gvalue_return:
    1315                 :            :  *
    1316                 :            :  * Return value: (element-type utf8 GValue) (transfer none):
    1317                 :            :  */
    1318                 :            : GHashTable *
    1319                 :          1 : regress_test_ghash_gvalue_return (void)
    1320                 :            : {
    1321                 :            :   static GHashTable *hash = NULL;
    1322                 :            : 
    1323         [ +  - ]:          1 :   if (hash == NULL)
    1324                 :            :     {
    1325                 :            :       GValue *value;
    1326                 :          1 :       hash = g_hash_table_new_full(g_str_hash, g_str_equal,
    1327                 :            :                                    g_free, (GDestroyNotify)g_value_free);
    1328                 :            : 
    1329                 :          1 :       value = g_value_new(G_TYPE_INT);
    1330                 :          1 :       g_value_set_int(value, 12);
    1331                 :          1 :       g_hash_table_insert(hash, g_strdup("integer"), value);
    1332                 :            : 
    1333                 :          1 :       value = g_value_new(G_TYPE_BOOLEAN);
    1334                 :          1 :       g_value_set_boolean(value, TRUE);
    1335                 :          1 :       g_hash_table_insert(hash, g_strdup("boolean"), value);
    1336                 :            : 
    1337                 :          1 :       value = g_value_new(G_TYPE_STRING);
    1338                 :          1 :       g_value_set_string(value, "some text");
    1339                 :          1 :       g_hash_table_insert(hash, g_strdup("string"), value);
    1340                 :            : 
    1341                 :          1 :       value = g_value_new(G_TYPE_STRV);
    1342                 :          1 :       g_value_set_boxed(value, string_array);
    1343                 :          1 :       g_hash_table_insert(hash, g_strdup("strings"), value);
    1344                 :            : 
    1345                 :          1 :       value = g_value_new(REGRESS_TEST_TYPE_FLAGS);
    1346                 :          1 :       g_value_set_flags(value, REGRESS_TEST_FLAG1 | REGRESS_TEST_FLAG3);
    1347                 :          1 :       g_hash_table_insert(hash, g_strdup("flags"), value);
    1348                 :            : 
    1349                 :          1 :       value = g_value_new(regress_test_enum_get_type());
    1350                 :          1 :       g_value_set_enum(value, REGRESS_TEST_VALUE2);
    1351                 :          1 :       g_hash_table_insert(hash, g_strdup("enum"), value);
    1352                 :            :     }
    1353                 :            : 
    1354                 :          1 :   return hash;
    1355                 :            : }
    1356                 :            : 
    1357                 :            : /**
    1358                 :            :  * regress_test_ghash_gvalue_in:
    1359                 :            :  * @hash: (element-type utf8 GValue): the hash table returned by
    1360                 :            :  * regress_test_ghash_gvalue_return().
    1361                 :            :  */
    1362                 :            : void
    1363                 :          0 : regress_test_ghash_gvalue_in (GHashTable *hash)
    1364                 :            : {
    1365                 :            :   GValue *value;
    1366                 :            :   const gchar **strings;
    1367                 :            :   int i;
    1368                 :            : 
    1369                 :          0 :   g_assert(hash != NULL);
    1370                 :            : 
    1371                 :          0 :   value = g_hash_table_lookup(hash, "integer");
    1372                 :          0 :   g_assert(value != NULL);
    1373                 :          0 :   g_assert(G_VALUE_HOLDS_INT(value));
    1374                 :          0 :   g_assert(g_value_get_int(value) == 12);
    1375                 :            : 
    1376                 :          0 :   value = g_hash_table_lookup(hash, "boolean");
    1377                 :          0 :   g_assert(value != NULL);
    1378                 :          0 :   g_assert(G_VALUE_HOLDS_BOOLEAN(value));
    1379                 :          0 :   g_assert(g_value_get_boolean(value) == TRUE);
    1380                 :            : 
    1381                 :          0 :   value = g_hash_table_lookup(hash, "string");
    1382                 :          0 :   g_assert(value != NULL);
    1383                 :          0 :   g_assert(G_VALUE_HOLDS_STRING(value));
    1384                 :          0 :   g_assert(strcmp(g_value_get_string(value), "some text") == 0);
    1385                 :            : 
    1386                 :          0 :   value = g_hash_table_lookup(hash, "strings");
    1387                 :          0 :   g_assert(value != NULL);
    1388                 :          0 :   g_assert(G_VALUE_HOLDS(value, G_TYPE_STRV));
    1389                 :          0 :   strings = g_value_get_boxed(value);
    1390                 :          0 :   g_assert(strings != NULL);
    1391         [ #  # ]:          0 :   for (i = 0; string_array[i] != NULL; i++)
    1392                 :          0 :     g_assert(strcmp(strings[i], string_array[i]) == 0);
    1393                 :            : 
    1394                 :          0 :   value = g_hash_table_lookup(hash, "flags");
    1395                 :          0 :   g_assert(value != NULL);
    1396                 :          0 :   g_assert(G_VALUE_HOLDS_FLAGS(value));
    1397                 :          0 :   g_assert(g_value_get_flags(value) == (REGRESS_TEST_FLAG1 | REGRESS_TEST_FLAG3));
    1398                 :            : 
    1399                 :          0 :   value = g_hash_table_lookup(hash, "enum");
    1400                 :          0 :   g_assert(value != NULL);
    1401                 :          0 :   g_assert(G_VALUE_HOLDS_ENUM(value));
    1402                 :          0 :   g_assert(g_value_get_enum(value) == REGRESS_TEST_VALUE2);
    1403                 :          0 : }
    1404                 :            : 
    1405                 :            : /**
    1406                 :            :  * regress_test_ghash_container_return:
    1407                 :            :  *
    1408                 :            :  * Return value: (element-type utf8 utf8) (transfer container):
    1409                 :            :  */
    1410                 :            : GHashTable *
    1411                 :          1 : regress_test_ghash_container_return (void)
    1412                 :            : {
    1413                 :          1 :   return regress_test_table_ghash_new_container ();
    1414                 :            : }
    1415                 :            : 
    1416                 :            : /**
    1417                 :            :  * regress_test_ghash_everything_return:
    1418                 :            :  *
    1419                 :            :  * Return value: (element-type utf8 utf8) (transfer full):
    1420                 :            :  */
    1421                 :            : GHashTable *
    1422                 :          1 : regress_test_ghash_everything_return (void)
    1423                 :            : {
    1424                 :          1 :   return regress_test_table_ghash_new_full ();
    1425                 :            : }
    1426                 :            : 
    1427                 :            : static void
    1428                 :          2 : assert_test_table_ghash (const GHashTable *in)
    1429                 :            : {
    1430                 :          2 :   GHashTable *h = regress_test_table_ghash_const();
    1431                 :            :   GHashTableIter iter;
    1432                 :            :   gpointer key, value;
    1433                 :            : 
    1434                 :          2 :   g_assert(g_hash_table_size(h) ==
    1435                 :            :            g_hash_table_size((GHashTable*)in));
    1436                 :            : 
    1437                 :          2 :   g_hash_table_iter_init(&iter, (GHashTable*)in);
    1438         [ +  + ]:          8 :   while (g_hash_table_iter_next (&iter, &key, &value))
    1439                 :          6 :     g_assert( strcmp(g_hash_table_lookup(h, (char*)key), (char*)value) == 0);
    1440                 :          2 : }
    1441                 :            : 
    1442                 :            : /**
    1443                 :            :  * regress_test_ghash_null_in:
    1444                 :            :  * @in: (element-type utf8 utf8) (allow-none):
    1445                 :            :  */
    1446                 :            : void
    1447                 :          1 : regress_test_ghash_null_in (const GHashTable *in)
    1448                 :            : {
    1449                 :          1 :   g_assert (in == NULL);
    1450                 :          1 : }
    1451                 :            : 
    1452                 :            : /**
    1453                 :            :  * regress_test_ghash_null_out:
    1454                 :            :  * @out: (element-type utf8 utf8) (allow-none) (out):
    1455                 :            :  */
    1456                 :            : void
    1457                 :          1 : regress_test_ghash_null_out (const GHashTable **out)
    1458                 :            : {
    1459                 :          1 :   *out = NULL;
    1460                 :          1 : }
    1461                 :            : 
    1462                 :            : /**
    1463                 :            :  * regress_test_ghash_nothing_in:
    1464                 :            :  * @in: (element-type utf8 utf8):
    1465                 :            :  */
    1466                 :            : void
    1467                 :          1 : regress_test_ghash_nothing_in (const GHashTable *in)
    1468                 :            : {
    1469                 :          1 :   assert_test_table_ghash (in);
    1470                 :          1 : }
    1471                 :            : 
    1472                 :            : /**
    1473                 :            :  * regress_test_ghash_nothing_in2:
    1474                 :            :  * @in: (element-type utf8 utf8):
    1475                 :            :  */
    1476                 :            : void
    1477                 :          1 : regress_test_ghash_nothing_in2 (GHashTable *in)
    1478                 :            : {
    1479                 :          1 :   assert_test_table_ghash (in);
    1480                 :          1 : }
    1481                 :            : 
    1482                 :            : /* Nested collection types */
    1483                 :            : 
    1484                 :            : /**
    1485                 :            :  * regress_test_ghash_nested_everything_return:
    1486                 :            :  *
    1487                 :            :  * Specify nested parameterized types directly with the (type ) annotation.
    1488                 :            :  *
    1489                 :            :  * Return value: (type GLib.HashTable<utf8,GLib.HashTable<utf8,utf8>>) (transfer full):
    1490                 :            :  */
    1491                 :            : GHashTable *
    1492                 :          2 : regress_test_ghash_nested_everything_return (void)
    1493                 :            : {
    1494                 :            :   GHashTable *hash;
    1495                 :          2 :   hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
    1496                 :            :                                (void (*) (gpointer)) g_hash_table_destroy);
    1497                 :          4 :   g_hash_table_insert(hash, g_strdup("wibble"), regress_test_table_ghash_new_full());
    1498                 :          2 :   return hash;
    1499                 :            : }
    1500                 :            : 
    1501                 :            : /**
    1502                 :            :  * regress_test_ghash_nested_everything_return2:
    1503                 :            :  *
    1504                 :            :  * Another way of specifying nested parameterized types: using the
    1505                 :            :  * element-type annotation.
    1506                 :            :  *
    1507                 :            :  * Return value: (element-type utf8 GLib.HashTable<utf8,utf8>) (transfer full):
    1508                 :            :  */
    1509                 :            : GHashTable *
    1510                 :          1 : regress_test_ghash_nested_everything_return2 (void)
    1511                 :            : {
    1512                 :          1 :   return regress_test_ghash_nested_everything_return();
    1513                 :            : }
    1514                 :            : 
    1515                 :            : /************************************************************************/
    1516                 :            : 
    1517                 :            : /**
    1518                 :            :  * regress_test_garray_container_return:
    1519                 :            :  *
    1520                 :            :  * Returns: (transfer container) (type GLib.PtrArray) (element-type utf8):
    1521                 :            :  */
    1522                 :            : GPtrArray *
    1523                 :          1 : regress_test_garray_container_return (void)
    1524                 :            : {
    1525                 :            :   GPtrArray *array;
    1526                 :            : 
    1527                 :          1 :   array = g_ptr_array_new_with_free_func (g_free);
    1528                 :          1 :   g_ptr_array_add (array, g_strdup ("regress"));
    1529                 :            : 
    1530                 :          1 :   return array;
    1531                 :            : }
    1532                 :            : 
    1533                 :            : /**
    1534                 :            :  * regress_test_garray_full_return:
    1535                 :            :  *
    1536                 :            :  * Returns: (transfer full) (type GLib.PtrArray) (element-type utf8):
    1537                 :            :  */
    1538                 :            : GPtrArray *
    1539                 :          1 : regress_test_garray_full_return (void)
    1540                 :            : {
    1541                 :            :   GPtrArray *array;
    1542                 :            : 
    1543                 :          1 :   array = g_ptr_array_new ();
    1544                 :          1 :   g_ptr_array_add (array, g_strdup ("regress"));
    1545                 :            : 
    1546                 :          1 :   return array;
    1547                 :            : }
    1548                 :            : 
    1549                 :            : /************************************************************************/
    1550                 :            : 
    1551                 :            : /* error? */
    1552                 :            : 
    1553                 :            : /* enums / flags */
    1554                 :            : 
    1555                 :            : /**
    1556                 :            :  * NUM_REGRESS_FOO: (skip)
    1557                 :            :  *
    1558                 :            :  * num of elements in RegressFoo
    1559                 :            :  */
    1560                 :            : 
    1561                 :            : GType
    1562                 :         26 : regress_test_enum_get_type (void)
    1563                 :            : {
    1564                 :            :     static GType etype = 0;
    1565         [ +  + ]:         26 :     if (G_UNLIKELY(etype == 0)) {
    1566                 :            :         static const GEnumValue values[] = {
    1567                 :            :             { REGRESS_TEST_VALUE1, "REGRESS_TEST_VALUE1", "value1" },
    1568                 :            :             { REGRESS_TEST_VALUE2, "REGRESS_TEST_VALUE2", "value2" },
    1569                 :            :             { REGRESS_TEST_VALUE3, "REGRESS_TEST_VALUE3", "value3" },
    1570                 :            :             { REGRESS_TEST_VALUE4, "REGRESS_TEST_VALUE4", "value4" },
    1571                 :            :             { REGRESS_TEST_VALUE5, "REGRESS_TEST_VALUE5", "value5" },
    1572                 :            :             { 0, NULL, NULL }
    1573                 :            :         };
    1574                 :          4 :         etype = g_enum_register_static (g_intern_static_string ("RegressTestEnum"), values);
    1575                 :            :     }
    1576                 :            : 
    1577                 :         26 :     return etype;
    1578                 :            : }
    1579                 :            : 
    1580                 :            : GType
    1581                 :          4 : regress_test_enum_unsigned_get_type (void)
    1582                 :            : {
    1583                 :            :     static GType etype = 0;
    1584         [ +  + ]:          4 :     if (G_UNLIKELY(etype == 0)) {
    1585                 :            :         static const GEnumValue values[] = {
    1586                 :            :             { REGRESS_TEST_UNSIGNED_VALUE1, "REGRESS_TEST_UNSIGNED_VALUE1", "value1" },
    1587                 :            :             { REGRESS_TEST_UNSIGNED_VALUE2, "REGRESS_TEST_UNSIGNED_VALUE2", "value2" },
    1588                 :            :             { 0, NULL, NULL }
    1589                 :            :         };
    1590                 :          2 :         etype = g_enum_register_static (g_intern_static_string ("RegressTestEnumUnsigned"), values);
    1591                 :            :     }
    1592                 :            : 
    1593                 :          4 :     return etype;
    1594                 :            : }
    1595                 :            : 
    1596                 :            : GType
    1597                 :          5 : regress_test_flags_get_type (void)
    1598                 :            : {
    1599                 :            :     static GType etype = 0;
    1600         [ +  + ]:          5 :     if (G_UNLIKELY(etype == 0)) {
    1601                 :            :         static const GFlagsValue values[] = {
    1602                 :            :             { REGRESS_TEST_FLAG1, "TEST_FLAG1", "flag1" },
    1603                 :            :             { REGRESS_TEST_FLAG2, "TEST_FLAG2", "flag2" },
    1604                 :            :             { REGRESS_TEST_FLAG3, "TEST_FLAG3", "flag3" },
    1605                 :            :             { 0, NULL, NULL }
    1606                 :            :         };
    1607                 :          3 :         etype = g_flags_register_static (g_intern_static_string ("RegressTestFlags"), values);
    1608                 :            :     }
    1609                 :            : 
    1610                 :          5 :     return etype;
    1611                 :            : }
    1612                 :            : 
    1613                 :            : const gchar *
    1614                 :          2 : regress_test_enum_param(RegressTestEnum e)
    1615                 :            : {
    1616                 :            :   GEnumValue *ev;
    1617                 :            :   GEnumClass *ec;
    1618                 :            : 
    1619                 :          2 :   ec = g_type_class_ref (regress_test_enum_get_type ());
    1620                 :          2 :   ev = g_enum_get_value (ec, e);
    1621                 :          2 :   g_type_class_unref (ec);
    1622                 :            : 
    1623                 :          2 :   return ev->value_nick;
    1624                 :            : }
    1625                 :            : 
    1626                 :            : const gchar *
    1627                 :          2 : regress_test_unsigned_enum_param(RegressTestEnumUnsigned e)
    1628                 :            : {
    1629                 :            :   GEnumValue *ev;
    1630                 :            :   GEnumClass *ec;
    1631                 :            : 
    1632                 :          2 :   ec = g_type_class_ref (regress_test_enum_unsigned_get_type ());
    1633                 :          2 :   ev = g_enum_get_value (ec, e);
    1634                 :          2 :   g_type_class_unref (ec);
    1635                 :            : 
    1636                 :          2 :   return ev->value_nick;
    1637                 :            : }
    1638                 :            : 
    1639                 :            : /**
    1640                 :            :  * regress_global_get_flags_out:
    1641                 :            :  * @v: (out): A flags value
    1642                 :            :  *
    1643                 :            :  */
    1644                 :            : void
    1645                 :          1 : regress_global_get_flags_out (RegressTestFlags *v)
    1646                 :            : {
    1647                 :          1 :   *v = REGRESS_TEST_FLAG1 | REGRESS_TEST_FLAG3;
    1648                 :          1 : }
    1649                 :            : 
    1650                 :            : /* error domains */
    1651                 :            : 
    1652                 :            : GType
    1653                 :          1 : regress_test_error_get_type (void)
    1654                 :            : {
    1655                 :            :     static GType etype = 0;
    1656         [ +  - ]:          1 :     if (G_UNLIKELY(etype == 0)) {
    1657                 :            :         static const GEnumValue values[] = {
    1658                 :            :             { REGRESS_TEST_ERROR_CODE1, "REGRESS_TEST_ERROR_CODE1", "code1" },
    1659                 :            :             { REGRESS_TEST_ERROR_CODE2, "REGRESS_TEST_ERROR_CODE2", "code2" },
    1660                 :            :             { REGRESS_TEST_ERROR_CODE3, "REGRESS_TEST_ERROR_CODE3", "code3" },
    1661                 :            :             { 0, NULL, NULL }
    1662                 :            :         };
    1663                 :          1 :         etype = g_enum_register_static (g_intern_static_string ("RegressTestError"), values);
    1664                 :            :     }
    1665                 :            : 
    1666                 :          1 :     return etype;
    1667                 :            : }
    1668                 :            : 
    1669                 :            : GQuark
    1670                 :          1 : regress_test_error_quark (void)
    1671                 :            : {
    1672                 :          1 :   return g_quark_from_static_string ("regress-test-error");
    1673                 :            : }
    1674                 :            : 
    1675                 :            : GType
    1676                 :          1 : regress_test_abc_error_get_type (void)
    1677                 :            : {
    1678                 :            :     static GType etype = 0;
    1679         [ +  - ]:          1 :     if (G_UNLIKELY(etype == 0)) {
    1680                 :            :         static const GEnumValue values[] = {
    1681                 :            :             { REGRESS_TEST_ABC_ERROR_CODE1, "REGRESS_TEST_ABC_ERROR_CODE1", "code1" },
    1682                 :            :             { REGRESS_TEST_ABC_ERROR_CODE2, "REGRESS_TEST_ABC_ERROR_CODE2", "code2" },
    1683                 :            :             { REGRESS_TEST_ABC_ERROR_CODE3, "REGRESS_TEST_ABC_ERROR_CODE3", "code3" },
    1684                 :            :             { 0, NULL, NULL }
    1685                 :            :         };
    1686                 :          1 :         etype = g_enum_register_static (g_intern_static_string ("RegressTestABCError"), values);
    1687                 :            :     }
    1688                 :            : 
    1689                 :          1 :     return etype;
    1690                 :            : }
    1691                 :            : 
    1692                 :            : GQuark
    1693                 :          1 : regress_test_abc_error_quark (void)
    1694                 :            : {
    1695                 :          1 :   return g_quark_from_static_string ("regress-test-abc-error");
    1696                 :            : }
    1697                 :            : 
    1698                 :            : GType
    1699                 :          1 : regress_test_unconventional_error_get_type (void)
    1700                 :            : {
    1701                 :            :     static GType etype = 0;
    1702         [ +  - ]:          1 :     if (G_UNLIKELY(etype == 0)) {
    1703                 :            :         static const GEnumValue values[] = {
    1704                 :            :             { REGRESS_TEST_OTHER_ERROR_CODE1, "REGRESS_TEST_OTHER_ERROR_CODE1", "code1" },
    1705                 :            :             { REGRESS_TEST_OTHER_ERROR_CODE2, "REGRESS_TEST_OTHER_ERROR_CODE2", "code2" },
    1706                 :            :             { REGRESS_TEST_OTHER_ERROR_CODE3, "REGRESS_TEST_OTHER_ERROR_CODE3", "code3" },
    1707                 :            :             { 0, NULL, NULL }
    1708                 :            :         };
    1709                 :          1 :         etype = g_enum_register_static (g_intern_static_string ("RegressTestOtherError"), values);
    1710                 :            :     }
    1711                 :            : 
    1712                 :          1 :     return etype;
    1713                 :            : }
    1714                 :            : 
    1715                 :            : GQuark
    1716                 :          1 : regress_test_unconventional_error_quark (void)
    1717                 :            : {
    1718                 :          1 :   return g_quark_from_static_string ("regress-test-other-error");
    1719                 :            : }
    1720                 :            : 
    1721                 :            : 
    1722                 :            : GQuark
    1723                 :          1 : regress_test_def_error_quark (void)
    1724                 :            : {
    1725                 :          1 :   return g_quark_from_static_string ("regress-test-def-error");
    1726                 :            : }
    1727                 :            : 
    1728                 :            : GQuark
    1729                 :          1 : regress_atest_error_quark (void)
    1730                 :            : {
    1731                 :          1 :   return g_quark_from_static_string ("regress-atest-error");
    1732                 :            : }
    1733                 :            : 
    1734                 :            : /* structures */
    1735                 :            : 
    1736                 :            : /**
    1737                 :            :  * regress_test_struct_a_clone:
    1738                 :            :  * @a: the structure
    1739                 :            :  * @a_out: (out caller-allocates): the cloned structure
    1740                 :            :  *
    1741                 :            :  * Make a copy of a RegressTestStructA
    1742                 :            :  */
    1743                 :            : void
    1744                 :          1 : regress_test_struct_a_clone (RegressTestStructA *a,
    1745                 :            :                      RegressTestStructA *a_out)
    1746                 :            : {
    1747                 :          1 :   *a_out = *a;
    1748                 :          1 : }
    1749                 :            : 
    1750                 :            : /**
    1751                 :            :  * regress_test_struct_a_parse:
    1752                 :            :  * @a_out: (out caller-allocates): the structure that is to be filled
    1753                 :            :  * @string: ignored
    1754                 :            :  */
    1755                 :            : void
    1756                 :          1 : regress_test_struct_a_parse (RegressTestStructA *a_out,
    1757                 :            :                              const gchar        *string G_GNUC_UNUSED)
    1758                 :            : {
    1759                 :          1 :         a_out->some_int = 23;
    1760                 :          1 : }
    1761                 :            : 
    1762                 :            : /**
    1763                 :            :  * regress_test_array_struct_out:
    1764                 :            :  * @arr: (out) (array length=len) (transfer full):
    1765                 :            :  * @len: (out)
    1766                 :            :  *
    1767                 :            :  * This is similar to gdk_keymap_get_entries_for_keyval().
    1768                 :            :  */
    1769                 :            : void
    1770                 :          1 : regress_test_array_struct_out (RegressTestStructA **arr, int *len)
    1771                 :            : {
    1772                 :          1 :   *arr = g_new0(RegressTestStructA, 3);
    1773                 :          1 :   (*arr)[0].some_int = 22;
    1774                 :          1 :   (*arr)[1].some_int = 33;
    1775                 :          1 :   (*arr)[2].some_int = 44;
    1776                 :          1 :   *len = 3;
    1777                 :          1 : }
    1778                 :            : 
    1779                 :            : /**
    1780                 :            :  * regress_test_struct_b_clone:
    1781                 :            :  * @b: the structure
    1782                 :            :  * @b_out: (out): the cloned structure
    1783                 :            :  *
    1784                 :            :  * Make a copy of a RegressTestStructB
    1785                 :            :  */
    1786                 :            : void
    1787                 :          1 : regress_test_struct_b_clone (RegressTestStructB *b,
    1788                 :            :                      RegressTestStructB *b_out)
    1789                 :            : {
    1790                 :          1 :   *b_out = *b;
    1791                 :          1 : }
    1792                 :            : 
    1793                 :            : /* plain-old-data boxed types */
    1794                 :            : 
    1795                 :            : RegressTestSimpleBoxedA *
    1796                 :          5 : regress_test_simple_boxed_a_copy (RegressTestSimpleBoxedA *a)
    1797                 :            : {
    1798                 :          5 :   RegressTestSimpleBoxedA *new_a = g_slice_new (RegressTestSimpleBoxedA);
    1799                 :            : 
    1800                 :          5 :   *new_a = *a;
    1801                 :            : 
    1802                 :          5 :   return new_a;
    1803                 :            : }
    1804                 :            : 
    1805                 :            : static void
    1806                 :          5 : regress_test_simple_boxed_a_free (RegressTestSimpleBoxedA *a)
    1807                 :            : {
    1808                 :          5 :   g_slice_free (RegressTestSimpleBoxedA, a);
    1809                 :          5 : }
    1810                 :            : 
    1811                 :            : GType
    1812                 :         15 : regress_test_simple_boxed_a_get_gtype (void)
    1813                 :            : {
    1814                 :            :   static GType our_type = 0;
    1815                 :            : 
    1816         [ +  + ]:         15 :   if (our_type == 0)
    1817                 :          4 :     our_type = g_boxed_type_register_static (g_intern_static_string ("RegressTestSimpleBoxedA"),
    1818                 :            :                                              (GBoxedCopyFunc)regress_test_simple_boxed_a_copy,
    1819                 :            :                                              (GBoxedFreeFunc)regress_test_simple_boxed_a_free);
    1820                 :         15 :   return our_type;
    1821                 :            : }
    1822                 :            : 
    1823                 :            : RegressTestSimpleBoxedB *
    1824                 :          1 : regress_test_simple_boxed_b_copy (RegressTestSimpleBoxedB *b)
    1825                 :            : {
    1826                 :          1 :   RegressTestSimpleBoxedB *new_b = g_slice_new (RegressTestSimpleBoxedB);
    1827                 :            : 
    1828                 :          1 :   *new_b = *b;
    1829                 :            : 
    1830                 :          1 :   return new_b;
    1831                 :            : }
    1832                 :            : 
    1833                 :            : gboolean
    1834                 :          3 : regress_test_simple_boxed_a_equals (RegressTestSimpleBoxedA *a,
    1835                 :            :                             RegressTestSimpleBoxedA *other_a)
    1836                 :            : {
    1837                 :          6 :   return (a->some_int == other_a->some_int &&
    1838   [ +  -  +  - ]:          6 :           a->some_int8 == other_a->some_int8 &&
    1839         [ +  - ]:          3 :           a->some_double == other_a->some_double);
    1840                 :            : }
    1841                 :            : 
    1842                 :            : const RegressTestSimpleBoxedA*
    1843                 :          1 : regress_test_simple_boxed_a_const_return (void)
    1844                 :            : {
    1845                 :            :   static RegressTestSimpleBoxedA simple_a = {
    1846                 :            :     5, 6, 7.0, REGRESS_TEST_VALUE1
    1847                 :            :   };
    1848                 :            : 
    1849                 :          1 :   return &simple_a;
    1850                 :            : }
    1851                 :            : 
    1852                 :            : static void
    1853                 :          1 : regress_test_simple_boxed_b_free (RegressTestSimpleBoxedB *a)
    1854                 :            : {
    1855                 :          1 :   g_slice_free (RegressTestSimpleBoxedB, a);
    1856                 :          1 : }
    1857                 :            : 
    1858                 :            : GType
    1859                 :          2 : regress_test_simple_boxed_b_get_type (void)
    1860                 :            : {
    1861                 :            :   static GType our_type = 0;
    1862                 :            : 
    1863         [ +  - ]:          2 :   if (our_type == 0)
    1864                 :          2 :     our_type = g_boxed_type_register_static (g_intern_static_string ("RegressTestSimpleBoxedB"),
    1865                 :            :                                              (GBoxedCopyFunc)regress_test_simple_boxed_b_copy,
    1866                 :            :                                              (GBoxedFreeFunc)regress_test_simple_boxed_b_free);
    1867                 :          2 :   return our_type;
    1868                 :            : }
    1869                 :            : 
    1870                 :            : /* opaque boxed */
    1871                 :            : 
    1872                 :            : struct _RegressTestBoxedPrivate
    1873                 :            : {
    1874                 :            :   guint magic;
    1875                 :            : };
    1876                 :            : 
    1877                 :            : /**
    1878                 :            :  * regress_test_boxed_new:
    1879                 :            :  *
    1880                 :            :  * Returns: (transfer full):
    1881                 :            :  */
    1882                 :            : RegressTestBoxed *
    1883                 :         31 : regress_test_boxed_new (void)
    1884                 :            : {
    1885                 :         31 :   RegressTestBoxed *boxed = g_slice_new0(RegressTestBoxed);
    1886                 :         31 :   boxed->priv = g_slice_new0(RegressTestBoxedPrivate);
    1887                 :         31 :   boxed->priv->magic = 0xdeadbeef;
    1888                 :            : 
    1889                 :         31 :   return boxed;
    1890                 :            : }
    1891                 :            : 
    1892                 :            : /**
    1893                 :            :  * regress_test_boxed_new_alternative_constructor1:
    1894                 :            :  *
    1895                 :            :  * Returns: (transfer full):
    1896                 :            :  */
    1897                 :            : RegressTestBoxed *
    1898                 :          1 : regress_test_boxed_new_alternative_constructor1 (int i)
    1899                 :            : {
    1900                 :          1 :   RegressTestBoxed *boxed = g_slice_new0(RegressTestBoxed);
    1901                 :          1 :   boxed->priv = g_slice_new0(RegressTestBoxedPrivate);
    1902                 :          1 :   boxed->priv->magic = 0xdeadbeef;
    1903                 :          1 :   boxed->some_int8 = i;
    1904                 :            : 
    1905                 :          1 :   return boxed;
    1906                 :            : }
    1907                 :            : 
    1908                 :            : /**
    1909                 :            :  * regress_test_boxed_new_alternative_constructor2:
    1910                 :            :  *
    1911                 :            :  * Returns: (transfer full):
    1912                 :            :  */
    1913                 :            : RegressTestBoxed *
    1914                 :          1 : regress_test_boxed_new_alternative_constructor2 (int i, int j)
    1915                 :            : {
    1916                 :          1 :   RegressTestBoxed *boxed = g_slice_new0(RegressTestBoxed);
    1917                 :          1 :   boxed->priv = g_slice_new0(RegressTestBoxedPrivate);
    1918                 :          1 :   boxed->priv->magic = 0xdeadbeef;
    1919                 :          1 :   boxed->some_int8 = i + j;
    1920                 :            : 
    1921                 :          1 :   return boxed;
    1922                 :            : }
    1923                 :            : 
    1924                 :            : /**
    1925                 :            :  * regress_test_boxed_new_alternative_constructor3:
    1926                 :            :  *
    1927                 :            :  * Returns: (transfer full):
    1928                 :            :  */
    1929                 :            : RegressTestBoxed *
    1930                 :          1 : regress_test_boxed_new_alternative_constructor3 (char *s)
    1931                 :            : {
    1932                 :          1 :   RegressTestBoxed *boxed = g_slice_new0(RegressTestBoxed);
    1933                 :          1 :   boxed->priv = g_slice_new0(RegressTestBoxedPrivate);
    1934                 :          1 :   boxed->priv->magic = 0xdeadbeef;
    1935                 :          1 :   boxed->some_int8 = atoi(s);
    1936                 :            : 
    1937                 :          1 :   return boxed;
    1938                 :            : }
    1939                 :            : 
    1940                 :            : /**
    1941                 :            :  * regress_test_boxed_copy:
    1942                 :            :  *
    1943                 :            :  * Returns: (transfer full):
    1944                 :            :  */
    1945                 :            : RegressTestBoxed *
    1946                 :         21 : regress_test_boxed_copy (RegressTestBoxed *boxed)
    1947                 :            : {
    1948                 :         21 :   RegressTestBoxed *new_boxed = regress_test_boxed_new();
    1949                 :            :   RegressTestBoxedPrivate *save;
    1950                 :            : 
    1951                 :         21 :   save = new_boxed->priv;
    1952                 :         21 :   *new_boxed = *boxed;
    1953                 :         21 :   new_boxed->priv = save;
    1954                 :            : 
    1955                 :         21 :   return new_boxed;
    1956                 :            : }
    1957                 :            : 
    1958                 :            : gboolean
    1959                 :          1 : regress_test_boxed_equals (RegressTestBoxed *boxed,
    1960                 :            :                    RegressTestBoxed *other)
    1961                 :            : {
    1962   [ +  -  +  - ]:          2 :   return (other->some_int8 == boxed->some_int8 &&
    1963                 :          1 :           regress_test_simple_boxed_a_equals(&other->nested_a, &boxed->nested_a));
    1964                 :            : }
    1965                 :            : 
    1966                 :            : void
    1967                 :          1 : regress_test_boxeds_not_a_method (RegressTestBoxed *boxed G_GNUC_UNUSED)
    1968                 :            : {
    1969                 :          1 : }
    1970                 :            : 
    1971                 :            : void
    1972                 :          1 : regress_test_boxeds_not_a_static (void)
    1973                 :            : {
    1974                 :          1 : }
    1975                 :            : 
    1976                 :            : static void
    1977                 :         35 : regress_test_boxed_free (RegressTestBoxed *boxed)
    1978                 :            : {
    1979                 :         35 :   g_assert (boxed->priv->magic == 0xdeadbeef);
    1980                 :            : 
    1981                 :         35 :   g_slice_free (RegressTestBoxedPrivate, boxed->priv);
    1982                 :         35 :   g_slice_free (RegressTestBoxed, boxed);
    1983                 :         35 : }
    1984                 :            : 
    1985                 :            : GType
    1986                 :         20 : regress_test_boxed_get_type (void)
    1987                 :            : {
    1988                 :            :   static GType our_type = 0;
    1989                 :            : 
    1990         [ +  + ]:         20 :   if (our_type == 0)
    1991                 :          4 :     our_type = g_boxed_type_register_static (g_intern_static_string ("RegressTestBoxed"),
    1992                 :            :                                              (GBoxedCopyFunc)regress_test_boxed_copy,
    1993                 :            :                                              (GBoxedFreeFunc)regress_test_boxed_free);
    1994                 :         20 :   return our_type;
    1995                 :            : }
    1996                 :            : 
    1997                 :            : RegressTestBoxedB *
    1998                 :          5 : regress_test_boxed_b_new (gint8 some_int8, glong some_long)
    1999                 :            : {
    2000                 :            :   RegressTestBoxedB *boxed;
    2001                 :            : 
    2002                 :          5 :   boxed = g_slice_new (RegressTestBoxedB);
    2003                 :          5 :   boxed->some_int8 = some_int8;
    2004                 :          5 :   boxed->some_long = some_long;
    2005                 :            : 
    2006                 :          5 :   return boxed;
    2007                 :            : }
    2008                 :            : 
    2009                 :            : RegressTestBoxedB *
    2010                 :          3 : regress_test_boxed_b_copy (RegressTestBoxedB *boxed)
    2011                 :            : {
    2012                 :          3 :   return regress_test_boxed_b_new (boxed->some_int8, boxed->some_long);
    2013                 :            : }
    2014                 :            : 
    2015                 :            : static void
    2016                 :          5 : regress_test_boxed_b_free (RegressTestBoxedB *boxed)
    2017                 :            : {
    2018                 :          5 :   g_slice_free (RegressTestBoxedB, boxed);
    2019                 :          5 : }
    2020                 :            : 
    2021   [ +  +  +  -  :          8 : G_DEFINE_BOXED_TYPE(RegressTestBoxedB,
                   +  + ]
    2022                 :            :                     regress_test_boxed_b,
    2023                 :            :                     regress_test_boxed_b_copy,
    2024                 :            :                     regress_test_boxed_b_free);
    2025                 :            : 
    2026                 :            : RegressTestBoxedC *
    2027                 :          2 : regress_test_boxed_c_new (void)
    2028                 :            : {
    2029                 :            :   RegressTestBoxedC *boxed;
    2030                 :            : 
    2031                 :          2 :   boxed = g_slice_new (RegressTestBoxedC);
    2032                 :          2 :   boxed->refcount = 1;
    2033                 :          2 :   boxed->another_thing = 42; /* what else */
    2034                 :            : 
    2035                 :          2 :   return boxed;
    2036                 :            : }
    2037                 :            : 
    2038                 :            : static RegressTestBoxedC *
    2039                 :          1 : regress_test_boxed_c_ref (RegressTestBoxedC *boxed)
    2040                 :            : {
    2041                 :          1 :   g_atomic_int_inc (&boxed->refcount);
    2042                 :          1 :   return boxed;
    2043                 :            : }
    2044                 :            : 
    2045                 :            : static void
    2046                 :          3 : regress_test_boxed_c_unref (RegressTestBoxedC *boxed)
    2047                 :            : {
    2048         [ +  + ]:          3 :   if (g_atomic_int_dec_and_test (&boxed->refcount)) {
    2049                 :          2 :     g_slice_free (RegressTestBoxedC, boxed);
    2050                 :            :   }
    2051                 :          3 : }
    2052                 :            : 
    2053   [ +  -  +  -  :          4 : G_DEFINE_BOXED_TYPE(RegressTestBoxedC,
                   +  - ]
    2054                 :            :                     regress_test_boxed_c,
    2055                 :            :                     regress_test_boxed_c_ref,
    2056                 :            :                     regress_test_boxed_c_unref);
    2057                 :            : 
    2058                 :            : struct _RegressTestBoxedD {
    2059                 :            :   char *a_string;
    2060                 :            :   gint a_int;
    2061                 :            : };
    2062                 :            : 
    2063                 :            : RegressTestBoxedD *
    2064                 :          2 : regress_test_boxed_d_new (const char *a_string, int a_int)
    2065                 :            : {
    2066                 :            :   RegressTestBoxedD *boxed;
    2067                 :            : 
    2068                 :          2 :   boxed = g_slice_new (RegressTestBoxedD);
    2069                 :          2 :   boxed->a_string = g_strdup (a_string);
    2070                 :          2 :   boxed->a_int = a_int;
    2071                 :            : 
    2072                 :          2 :   return boxed;
    2073                 :            : }
    2074                 :            : 
    2075                 :            : RegressTestBoxedD *
    2076                 :          3 : regress_test_boxed_d_copy (RegressTestBoxedD *boxed)
    2077                 :            : {
    2078                 :            :   RegressTestBoxedD *ret;
    2079                 :            : 
    2080                 :          3 :   ret = g_slice_new (RegressTestBoxedD);
    2081                 :          3 :   ret->a_string = g_strdup (boxed->a_string);
    2082                 :          3 :   ret->a_int = boxed->a_int;
    2083                 :            : 
    2084                 :          3 :   return ret;
    2085                 :            : }
    2086                 :            : 
    2087                 :            : void
    2088                 :          5 : regress_test_boxed_d_free (RegressTestBoxedD *boxed)
    2089                 :            : {
    2090                 :          5 :   g_free (boxed->a_string);
    2091                 :          5 :   g_slice_free (RegressTestBoxedD, boxed);
    2092                 :          5 : }
    2093                 :            : 
    2094                 :            : int
    2095                 :          2 : regress_test_boxed_d_get_magic (RegressTestBoxedD *boxed)
    2096                 :            : {
    2097                 :          2 :   return strlen (boxed->a_string) + boxed->a_int;
    2098                 :            : }
    2099                 :            : 
    2100   [ +  +  +  -  :         10 : G_DEFINE_BOXED_TYPE(RegressTestBoxedD,
                   +  + ]
    2101                 :            :                     regress_test_boxed_d,
    2102                 :            :                     regress_test_boxed_d_copy,
    2103                 :            :                     regress_test_boxed_d_free);
    2104                 :            : 
    2105   [ +  +  +  -  :        628 : G_DEFINE_TYPE(RegressTestObj, regress_test_obj, G_TYPE_OBJECT);
                   +  + ]
    2106                 :            : 
    2107                 :            : enum
    2108                 :            : {
    2109                 :            :   PROP_TEST_OBJ_BARE = 1,
    2110                 :            :   PROP_TEST_OBJ_BOXED,
    2111                 :            :   PROP_TEST_OBJ_HASH_TABLE,
    2112                 :            :   PROP_TEST_OBJ_LIST,
    2113                 :            :   PROP_TEST_OBJ_PPTRARRAY,
    2114                 :            :   PROP_TEST_OBJ_HASH_TABLE_OLD,
    2115                 :            :   PROP_TEST_OBJ_LIST_OLD,
    2116                 :            :   PROP_TEST_OBJ_INT,
    2117                 :            :   PROP_TEST_OBJ_FLOAT,
    2118                 :            :   PROP_TEST_OBJ_DOUBLE,
    2119                 :            :   PROP_TEST_OBJ_STRING,
    2120                 :            :   PROP_TEST_OBJ_GTYPE,
    2121                 :            :   PROP_TEST_OBJ_NAME_CONFLICT,
    2122                 :            :   PROP_TEST_OBJ_BYTE_ARRAY,
    2123                 :            :   PROP_TEST_OBJ_WRITE_ONLY,
    2124                 :            : };
    2125                 :            : 
    2126                 :            : static void
    2127                 :        411 : regress_test_obj_set_property (GObject      *object,
    2128                 :            :                        guint         property_id,
    2129                 :            :                        const GValue *value,
    2130                 :            :                        GParamSpec   *pspec)
    2131                 :            : {
    2132                 :        411 :   RegressTestObj *self = REGRESS_TEST_OBJECT (object);
    2133                 :            :   GList *list;
    2134                 :            : 
    2135   [ +  +  -  +  :        411 :   switch (property_id)
          +  +  +  +  +  
             +  +  +  - ]
    2136                 :            :     {
    2137                 :          8 :     case PROP_TEST_OBJ_BARE:
    2138                 :          8 :       regress_test_obj_set_bare (self, g_value_get_object (value));
    2139                 :          8 :       break;
    2140                 :            : 
    2141                 :          6 :     case PROP_TEST_OBJ_BOXED:
    2142         [ +  + ]:          6 :       if (self->boxed)
    2143                 :          1 :         regress_test_boxed_free (self->boxed);
    2144                 :          6 :       self->boxed = g_value_dup_boxed (value);
    2145                 :          6 :       break;
    2146                 :            : 
    2147                 :          0 :     case PROP_TEST_OBJ_HASH_TABLE:
    2148                 :            :     case PROP_TEST_OBJ_HASH_TABLE_OLD:
    2149         [ #  # ]:          0 :       if (self->hash_table)
    2150                 :          0 :         g_hash_table_unref (self->hash_table);
    2151                 :          0 :       self->hash_table = g_hash_table_ref (g_value_get_boxed (value));
    2152                 :          0 :       break;
    2153                 :            : 
    2154                 :         10 :     case PROP_TEST_OBJ_LIST:
    2155                 :            :     case PROP_TEST_OBJ_LIST_OLD:
    2156                 :         10 :       g_list_free_full (self->list, g_free);
    2157                 :         10 :       list = g_value_get_pointer (value);
    2158                 :         10 :       self->list = g_list_copy_deep (list, (GCopyFunc) (void *) g_strdup, NULL);
    2159                 :         10 :       break;
    2160                 :            : 
    2161                 :         65 :     case PROP_TEST_OBJ_INT:
    2162                 :         65 :       self->some_int8 = g_value_get_int (value);
    2163                 :         65 :       break;
    2164                 :            : 
    2165                 :         63 :     case PROP_TEST_OBJ_FLOAT:
    2166                 :         63 :       self->some_float = g_value_get_float (value);
    2167                 :         63 :       break;
    2168                 :            : 
    2169                 :         63 :     case PROP_TEST_OBJ_DOUBLE:
    2170                 :         63 :       self->some_double = g_value_get_double (value);
    2171                 :         63 :       break;
    2172                 :            : 
    2173                 :          6 :     case PROP_TEST_OBJ_STRING:
    2174         [ +  + ]:          6 :       g_clear_pointer (&self->string, g_free);
    2175                 :          6 :       self->string = g_value_dup_string (value);
    2176                 :          6 :       break;
    2177                 :            : 
    2178                 :          5 :     case PROP_TEST_OBJ_GTYPE:
    2179                 :          5 :       self->gtype = g_value_get_gtype (value);
    2180                 :          5 :       break;
    2181                 :            : 
    2182                 :         92 :     case PROP_TEST_OBJ_NAME_CONFLICT:
    2183                 :         92 :       self->name_conflict = g_value_get_int (value);
    2184                 :         92 :       break;
    2185                 :            : 
    2186                 :         92 :     case PROP_TEST_OBJ_BYTE_ARRAY:
    2187                 :         92 :       self->byte_array = g_value_get_boxed (value);
    2188                 :         92 :       break;
    2189                 :            : 
    2190                 :          1 :     case PROP_TEST_OBJ_WRITE_ONLY:
    2191         [ +  - ]:          1 :       if (g_value_get_boolean (value))
    2192                 :          1 :         self->some_int8 = 0;
    2193                 :          1 :       break;
    2194                 :            : 
    2195                 :          0 :     default:
    2196                 :            :       /* We don't have any other property... */
    2197                 :          0 :       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
    2198                 :          0 :       break;
    2199                 :            :     }
    2200                 :        411 : }
    2201                 :            : 
    2202                 :            : static void
    2203                 :         26 : regress_test_obj_get_property (GObject    *object,
    2204                 :            :                         guint       property_id,
    2205                 :            :                         GValue     *value,
    2206                 :            :                         GParamSpec *pspec)
    2207                 :            : {
    2208                 :         26 :   RegressTestObj *self = REGRESS_TEST_OBJECT (object);
    2209                 :            : 
    2210   [ +  +  -  -  :         26 :   switch (property_id)
          +  +  +  +  -  
                +  -  - ]
    2211                 :            :     {
    2212                 :          4 :     case PROP_TEST_OBJ_BARE:
    2213                 :          4 :       g_value_set_object (value, self->bare);
    2214                 :          4 :       break;
    2215                 :            : 
    2216                 :          2 :     case PROP_TEST_OBJ_BOXED:
    2217                 :          2 :       g_value_set_boxed (value, self->boxed);
    2218                 :          2 :       break;
    2219                 :            : 
    2220                 :          0 :     case PROP_TEST_OBJ_HASH_TABLE:
    2221                 :            :     case PROP_TEST_OBJ_HASH_TABLE_OLD:
    2222         [ #  # ]:          0 :       if (self->hash_table != NULL)
    2223                 :          0 :         g_hash_table_ref (self->hash_table);
    2224                 :          0 :       g_value_set_boxed (value, self->hash_table);
    2225                 :          0 :       break;
    2226                 :            : 
    2227                 :          0 :     case PROP_TEST_OBJ_LIST:
    2228                 :            :     case PROP_TEST_OBJ_LIST_OLD:
    2229                 :          0 :       g_value_set_pointer (value, self->list);
    2230                 :          0 :       break;
    2231                 :            : 
    2232                 :          8 :     case PROP_TEST_OBJ_INT:
    2233                 :          8 :       g_value_set_int (value, self->some_int8);
    2234                 :          8 :       break;
    2235                 :            : 
    2236                 :          4 :     case PROP_TEST_OBJ_FLOAT:
    2237                 :          4 :       g_value_set_float (value, self->some_float);
    2238                 :          4 :       break;
    2239                 :            : 
    2240                 :          4 :     case PROP_TEST_OBJ_DOUBLE:
    2241                 :          4 :       g_value_set_double (value, self->some_double);
    2242                 :          4 :       break;
    2243                 :            : 
    2244                 :          2 :     case PROP_TEST_OBJ_STRING:
    2245                 :          2 :       g_value_set_string (value, self->string);
    2246                 :          2 :       break;
    2247                 :            : 
    2248                 :          0 :     case PROP_TEST_OBJ_GTYPE:
    2249                 :          0 :       g_value_set_gtype (value, self->gtype);
    2250                 :          0 :       break;
    2251                 :            : 
    2252                 :          2 :     case PROP_TEST_OBJ_NAME_CONFLICT:
    2253                 :          2 :       g_value_set_int (value, self->name_conflict);
    2254                 :          2 :       break;
    2255                 :            : 
    2256                 :          0 :     case PROP_TEST_OBJ_BYTE_ARRAY:
    2257                 :          0 :       g_value_set_boxed (value, self->byte_array);
    2258                 :          0 :       break;
    2259                 :            : 
    2260                 :          0 :     default:
    2261                 :            :       /* We don't have any other property... */
    2262                 :          0 :       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
    2263                 :          0 :       break;
    2264                 :            :     }
    2265                 :         26 : }
    2266                 :            : 
    2267                 :            : static void
    2268                 :         92 : regress_test_obj_dispose (GObject *gobject)
    2269                 :            : {
    2270                 :         92 :   RegressTestObj *self = REGRESS_TEST_OBJECT (gobject);
    2271                 :            : 
    2272         [ +  + ]:         92 :   if (self->bare)
    2273                 :            :     {
    2274                 :          7 :       g_object_unref (self->bare);
    2275                 :            : 
    2276                 :          7 :       self->bare = NULL;
    2277                 :            :     }
    2278                 :            : 
    2279         [ +  + ]:         92 :   if (self->boxed)
    2280                 :            :     {
    2281                 :          5 :       regress_test_boxed_free (self->boxed);
    2282                 :          5 :       self->boxed = NULL;
    2283                 :            :     }
    2284                 :            : 
    2285         [ -  + ]:         92 :   if (self->list)
    2286                 :            :     {
    2287                 :          0 :       g_list_free_full (self->list, g_free);
    2288                 :          0 :       self->list = NULL;
    2289                 :            :     }
    2290                 :            : 
    2291         [ -  + ]:         92 :   g_clear_pointer (&self->hash_table, g_hash_table_unref);
    2292         [ +  + ]:         92 :   g_clear_pointer (&self->string, g_free);
    2293                 :            : 
    2294                 :            :   /* Chain up to the parent class */
    2295                 :         92 :   G_OBJECT_CLASS (regress_test_obj_parent_class)->dispose (gobject);
    2296                 :         92 : }
    2297                 :            : 
    2298                 :            : static int
    2299                 :          1 : regress_test_obj_default_matrix (RegressTestObj *obj G_GNUC_UNUSED,
    2300                 :            :                                  const char     *somestr G_GNUC_UNUSED)
    2301                 :            : {
    2302                 :          1 :   return 42;
    2303                 :            : }
    2304                 :            : 
    2305                 :            : enum {
    2306                 :            :   REGRESS_TEST_OBJ_SIGNAL_SIG_NEW_WITH_ARRAY_PROP,
    2307                 :            :   REGRESS_TEST_OBJ_SIGNAL_SIG_NEW_WITH_ARRAY_LEN_PROP,
    2308                 :            :   REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_HASH_PROP,
    2309                 :            :   REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_STRV,
    2310                 :            :   REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_OBJ,
    2311                 :            :   REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_FOREIGN_STRUCT,
    2312                 :            :   REGRESS_TEST_OBJ_SIGNAL_FIRST,
    2313                 :            :   REGRESS_TEST_OBJ_SIGNAL_CLEANUP,
    2314                 :            :   REGRESS_TEST_OBJ_SIGNAL_ALL,
    2315                 :            :   REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_INT64_PROP,
    2316                 :            :   REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_UINT64_PROP,
    2317                 :            :   REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_INTARRAY_RET,
    2318                 :            :   REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_INOUT_INT,
    2319                 :            :   REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_GERROR,
    2320                 :            :   N_REGRESS_TEST_OBJ_SIGNALS
    2321                 :            : };
    2322                 :            : 
    2323                 :            : static guint regress_test_obj_signals[N_REGRESS_TEST_OBJ_SIGNALS] = { 0 };
    2324                 :            : 
    2325                 :            : static void
    2326                 :          4 : regress_test_obj_class_init (RegressTestObjClass *klass)
    2327                 :            : {
    2328                 :          4 :   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
    2329                 :            :   GParamSpec *pspec;
    2330                 :            :   GType param_types[1];
    2331                 :            : 
    2332                 :          4 :   klass->test_signal =
    2333                 :          4 :     g_signal_newv ("test",
    2334                 :            :                    G_TYPE_FROM_CLASS (gobject_class),
    2335                 :            :                    G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
    2336                 :            :                    NULL /* closure */,
    2337                 :            :                    NULL /* accumulator */,
    2338                 :            :                    NULL /* accumulator data */,
    2339                 :            :                    g_cclosure_marshal_VOID__VOID,
    2340                 :            :                    G_TYPE_NONE /* return_type */,
    2341                 :            :                    0     /* n_params */,
    2342                 :            :                    NULL  /* param_types */);
    2343                 :            : 
    2344                 :          4 :   param_types[0] = regress_test_simple_boxed_a_get_gtype() | G_SIGNAL_TYPE_STATIC_SCOPE;
    2345                 :          4 :   klass->test_signal_with_static_scope_arg =
    2346                 :          4 :     g_signal_newv ("test-with-static-scope-arg",
    2347                 :            :                    G_TYPE_FROM_CLASS (gobject_class),
    2348                 :            :                    G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
    2349                 :            :                    NULL /* closure */,
    2350                 :            :                    NULL /* accumulator */,
    2351                 :            :                    NULL /* accumulator data */,
    2352                 :            :                    g_cclosure_marshal_VOID__BOXED,
    2353                 :            :                    G_TYPE_NONE /* return_type */,
    2354                 :            :                    1     /* n_params */,
    2355                 :            :                    param_types);
    2356                 :            : 
    2357                 :            :   /**
    2358                 :            :    * RegressTestObj::sig-with-array-prop:
    2359                 :            :    * @self: an object
    2360                 :            :    * @arr: (type GArray) (element-type uint): numbers
    2361                 :            :    *
    2362                 :            :    * This test signal is like TelepathyGlib's
    2363                 :            :    *  TpChannel:: group-members-changed-detailed:
    2364                 :            :    */
    2365                 :          4 :   regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_NEW_WITH_ARRAY_PROP] =
    2366                 :          4 :     g_signal_new ("sig-with-array-prop",
    2367                 :            :                   G_TYPE_FROM_CLASS (gobject_class),
    2368                 :            :                   G_SIGNAL_RUN_LAST,
    2369                 :            :                   0,
    2370                 :            :                   NULL,
    2371                 :            :                   NULL,
    2372                 :            :                   g_cclosure_marshal_VOID__BOXED,
    2373                 :            :                   G_TYPE_NONE,
    2374                 :            :                   1,
    2375                 :            :                   G_TYPE_ARRAY);
    2376                 :            : 
    2377                 :            :   /**
    2378                 :            :    * RegressTestObj::sig-with-array-len-prop:
    2379                 :            :    * @self: an object
    2380                 :            :    * @arr: (array length=len) (element-type uint) (allow-none): numbers, or %NULL
    2381                 :            :    * @len: length of @arr, or 0
    2382                 :            :    *
    2383                 :            :    * This test signal similar to GSettings::change-event.
    2384                 :            :    * You can use this with regress_test_obj_emit_sig_with_array_len_prop(), or
    2385                 :            :    * raise from the introspection client language.
    2386                 :            :    */
    2387                 :          4 :   regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_NEW_WITH_ARRAY_LEN_PROP] =
    2388                 :          4 :     g_signal_new ("sig-with-array-len-prop",
    2389                 :            :                   G_TYPE_FROM_CLASS (gobject_class),
    2390                 :            :                   G_SIGNAL_RUN_LAST,
    2391                 :            :                   0,
    2392                 :            :                   NULL,
    2393                 :            :                   NULL,
    2394                 :            :                   NULL,
    2395                 :            :                   G_TYPE_NONE,
    2396                 :            :                   2,
    2397                 :            :                   G_TYPE_POINTER,
    2398                 :            :                   G_TYPE_INT);
    2399                 :            : 
    2400                 :            :   /**
    2401                 :            :    * RegressTestObj::sig-with-hash-prop:
    2402                 :            :    * @self: an object
    2403                 :            :    * @hash: (element-type utf8 GObject.Value):
    2404                 :            :    *
    2405                 :            :    * This test signal is like TelepathyGlib's
    2406                 :            :    *  TpAccount::status-changed
    2407                 :            :    */
    2408                 :          4 :   regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_HASH_PROP] =
    2409                 :          4 :     g_signal_new ("sig-with-hash-prop",
    2410                 :            :                   G_TYPE_FROM_CLASS (gobject_class),
    2411                 :            :                   G_SIGNAL_RUN_LAST,
    2412                 :            :                   0,
    2413                 :            :                   NULL,
    2414                 :            :                   NULL,
    2415                 :            :                   g_cclosure_marshal_VOID__BOXED,
    2416                 :            :                   G_TYPE_NONE,
    2417                 :            :                   1,
    2418                 :            :                   G_TYPE_HASH_TABLE);
    2419                 :            : 
    2420                 :            :   /**
    2421                 :            :    * RegressTestObj::sig-with-strv:
    2422                 :            :    * @self: an object
    2423                 :            :    * @strs: strings
    2424                 :            :    *
    2425                 :            :    * Test GStrv as a param.
    2426                 :            :    */
    2427                 :          4 :   regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_STRV] =
    2428                 :          4 :     g_signal_new ("sig-with-strv",
    2429                 :            :                   G_TYPE_FROM_CLASS (gobject_class),
    2430                 :            :                   G_SIGNAL_RUN_LAST,
    2431                 :            :                   0,
    2432                 :            :                   NULL,
    2433                 :            :                   NULL,
    2434                 :            :                   g_cclosure_marshal_VOID__BOXED,
    2435                 :            :                   G_TYPE_NONE,
    2436                 :            :                   1,
    2437                 :            :                   G_TYPE_STRV);
    2438                 :            : 
    2439                 :            :    /**
    2440                 :            :    * RegressTestObj::sig-with-obj:
    2441                 :            :    * @self: an object
    2442                 :            :    * @obj: (transfer none): A newly created RegressTestObj
    2443                 :            :    *
    2444                 :            :    * Test transfer none GObject as a param (tests refcounting).
    2445                 :            :    * Use with regress_test_obj_emit_sig_with_obj
    2446                 :            :    */
    2447                 :          4 :   regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_OBJ] =
    2448                 :          4 :     g_signal_new ("sig-with-obj",
    2449                 :            :                   G_TYPE_FROM_CLASS (gobject_class),
    2450                 :            :                   G_SIGNAL_RUN_LAST,
    2451                 :            :                   0,
    2452                 :            :                   NULL,
    2453                 :            :                   NULL,
    2454                 :            :                   g_cclosure_marshal_VOID__OBJECT,
    2455                 :            :                   G_TYPE_NONE,
    2456                 :            :                   1,
    2457                 :            :                   G_TYPE_OBJECT);
    2458                 :            : 
    2459                 :            : #ifndef _GI_DISABLE_CAIRO
    2460                 :            :    /**
    2461                 :            :    * RegressTestObj::sig-with-foreign-struct:
    2462                 :            :    * @self: an object
    2463                 :            :    * @cr: (transfer none): A cairo context.
    2464                 :            :    */
    2465                 :          4 :   regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_FOREIGN_STRUCT] =
    2466                 :          4 :     g_signal_new ("sig-with-foreign-struct",
    2467                 :            :                   G_TYPE_FROM_CLASS (gobject_class),
    2468                 :            :                   G_SIGNAL_RUN_LAST,
    2469                 :            :                   0,
    2470                 :            :                   NULL,
    2471                 :            :                   NULL,
    2472                 :            :                   NULL,
    2473                 :            :                   G_TYPE_NONE,
    2474                 :            :                   1,
    2475                 :            :                   CAIRO_GOBJECT_TYPE_CONTEXT);
    2476                 :            : #endif
    2477                 :            : 
    2478                 :          4 :   regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_FIRST] =
    2479                 :          4 :     g_signal_new ("first",
    2480                 :            :                   G_TYPE_FROM_CLASS (gobject_class),
    2481                 :            :                   G_SIGNAL_RUN_FIRST,
    2482                 :            :                   0,
    2483                 :            :                   NULL,
    2484                 :            :                   NULL,
    2485                 :            :                   g_cclosure_marshal_VOID__VOID,
    2486                 :            :                   G_TYPE_NONE,
    2487                 :            :                   0);
    2488                 :            : 
    2489                 :          4 :     regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_CLEANUP] =
    2490                 :          4 :     g_signal_new ("cleanup",
    2491                 :            :                   G_TYPE_FROM_CLASS (gobject_class),
    2492                 :            :                   G_SIGNAL_RUN_CLEANUP,
    2493                 :            :                   0,
    2494                 :            :                   NULL,
    2495                 :            :                   NULL,
    2496                 :            :                   g_cclosure_marshal_VOID__VOID,
    2497                 :            :                   G_TYPE_NONE,
    2498                 :            :                   0);
    2499                 :            : 
    2500                 :          4 :     regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_ALL] =
    2501                 :          4 :     g_signal_new ("all",
    2502                 :            :                   G_TYPE_FROM_CLASS (gobject_class),
    2503                 :            :                   G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | G_SIGNAL_ACTION | G_SIGNAL_NO_HOOKS,
    2504                 :            :                   0,
    2505                 :            :                   NULL,
    2506                 :            :                   NULL,
    2507                 :            :                   g_cclosure_marshal_VOID__VOID,
    2508                 :            :                   G_TYPE_NONE,
    2509                 :            :                   0);
    2510                 :            : 
    2511                 :            :   /**
    2512                 :            :    * RegressTestObj::sig-with-int64-prop:
    2513                 :            :    * @self: an object
    2514                 :            :    * @i: an integer
    2515                 :            :    *
    2516                 :            :    * You can use this with regress_test_obj_emit_sig_with_int64, or raise from
    2517                 :            :    * the introspection client langage.
    2518                 :            :    */
    2519                 :          4 :   regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_INT64_PROP] =
    2520                 :          4 :     g_signal_new ("sig-with-int64-prop",
    2521                 :            :                   G_TYPE_FROM_CLASS (gobject_class),
    2522                 :            :                   G_SIGNAL_RUN_LAST,
    2523                 :            :                   0,
    2524                 :            :                   NULL,
    2525                 :            :                   NULL,
    2526                 :            :                   g_cclosure_marshal_VOID__BOXED,
    2527                 :            :                   G_TYPE_INT64,
    2528                 :            :                   1,
    2529                 :            :                   G_TYPE_INT64);
    2530                 :            : 
    2531                 :            :   /**
    2532                 :            :    * RegressTestObj::sig-with-uint64-prop:
    2533                 :            :    * @self: an object
    2534                 :            :    * @i: an integer
    2535                 :            :    *
    2536                 :            :    * You can use this with regress_test_obj_emit_sig_with_uint64, or raise from
    2537                 :            :    * the introspection client langage.
    2538                 :            :    */
    2539                 :          4 :   regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_UINT64_PROP] =
    2540                 :          4 :     g_signal_new ("sig-with-uint64-prop",
    2541                 :            :                   G_TYPE_FROM_CLASS (gobject_class),
    2542                 :            :                   G_SIGNAL_RUN_LAST,
    2543                 :            :                   0,
    2544                 :            :                   NULL,
    2545                 :            :                   NULL,
    2546                 :            :                   g_cclosure_marshal_VOID__BOXED,
    2547                 :            :                   G_TYPE_UINT64,
    2548                 :            :                   1,
    2549                 :            :                   G_TYPE_UINT64);
    2550                 :            : 
    2551                 :            :   /**
    2552                 :            :    * RegressTestObj::sig-with-intarray-ret:
    2553                 :            :    * @self: an object
    2554                 :            :    * @i: an integer
    2555                 :            :    *
    2556                 :            :    * Returns: (array zero-terminated=1) (element-type gint) (transfer full):
    2557                 :            :    */
    2558                 :          4 :   regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_INTARRAY_RET] =
    2559                 :          4 :     g_signal_new ("sig-with-intarray-ret",
    2560                 :            :                   G_TYPE_FROM_CLASS (gobject_class),
    2561                 :            :                   G_SIGNAL_RUN_LAST,
    2562                 :            :                   0,
    2563                 :            :                   NULL,
    2564                 :            :                   NULL,
    2565                 :            :                   g_cclosure_marshal_VOID__BOXED,
    2566                 :            :                   G_TYPE_ARRAY,
    2567                 :            :                   1,
    2568                 :            :                   G_TYPE_INT);
    2569                 :            : 
    2570                 :            :   /**
    2571                 :            :    * RegressTestObj::sig-with-inout-int
    2572                 :            :    * @self: The object that emitted the signal
    2573                 :            :    * @position: (inout) (type int): The position, in characters, at which to
    2574                 :            :    *     insert the new text. This is an in-out paramter. After the signal
    2575                 :            :    *     emission is finished, it should point after the newly inserted text.
    2576                 :            :    *
    2577                 :            :    * This signal is modeled after GtkEditable::insert-text.
    2578                 :            :    */
    2579                 :          4 :   regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_INOUT_INT] =
    2580                 :          4 :     g_signal_new ("sig-with-inout-int",
    2581                 :            :                   G_TYPE_FROM_CLASS (gobject_class),
    2582                 :            :                   G_SIGNAL_RUN_LAST,
    2583                 :            :                   0,
    2584                 :            :                   NULL,
    2585                 :            :                   NULL,
    2586                 :            :                   NULL,
    2587                 :            :                   G_TYPE_NONE,
    2588                 :            :                   1,
    2589                 :            :                   G_TYPE_POINTER);
    2590                 :            : 
    2591                 :            :   /**
    2592                 :            :    * RegressTestObj::sig-with-gerror:
    2593                 :            :    * @self: The object that emitted the signal
    2594                 :            :    * @error: (nullable) (type GLib.Error): A #GError if something went wrong
    2595                 :            :    *   internally in @self. You must not free this #GError.
    2596                 :            :    *
    2597                 :            :    * This signal is modeled after #GstDiscoverer::discovered, and is added to
    2598                 :            :    * exercise the path of a #GError being marshalled as a boxed type instead of
    2599                 :            :    * an exception in the introspected language.
    2600                 :            :    *
    2601                 :            :    * Use via regress_test_obj_emit_sig_with_error() and
    2602                 :            :    * regress_test_obj_emit_sig_with_null_error(), or emit via the introspected
    2603                 :            :    * language.
    2604                 :            :    */
    2605                 :          4 :   regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_GERROR] =
    2606                 :          4 :       g_signal_new ("sig-with-gerror", G_TYPE_FROM_CLASS (klass),
    2607                 :            :                     G_SIGNAL_RUN_LAST, 0, NULL, NULL,
    2608                 :            :                     g_cclosure_marshal_generic, G_TYPE_NONE, 1,
    2609                 :          4 :                     G_TYPE_ERROR | G_SIGNAL_TYPE_STATIC_SCOPE);
    2610                 :            : 
    2611                 :          4 :   gobject_class->set_property = regress_test_obj_set_property;
    2612                 :          4 :   gobject_class->get_property = regress_test_obj_get_property;
    2613                 :          4 :   gobject_class->dispose = regress_test_obj_dispose;
    2614                 :            : 
    2615                 :          4 :   pspec = g_param_spec_object ("bare",
    2616                 :            :                                "Bare property",
    2617                 :            :                                "A contained object",
    2618                 :            :                                G_TYPE_OBJECT,
    2619                 :            :                                G_PARAM_READWRITE);
    2620                 :          4 :   g_object_class_install_property (gobject_class,
    2621                 :            :                                    PROP_TEST_OBJ_BARE,
    2622                 :            :                                    pspec);
    2623                 :            : 
    2624                 :          4 :   pspec = g_param_spec_boxed ("boxed",
    2625                 :            :                               "Boxed property",
    2626                 :            :                               "A contained boxed struct",
    2627                 :            :                               REGRESS_TEST_TYPE_BOXED,
    2628                 :            :                               G_PARAM_READWRITE);
    2629                 :          4 :   g_object_class_install_property (gobject_class,
    2630                 :            :                                    PROP_TEST_OBJ_BOXED,
    2631                 :            :                                    pspec);
    2632                 :            : 
    2633                 :            :   /**
    2634                 :            :    * RegressTestObj:hash-table: (type GLib.HashTable(utf8,gint8)) (transfer container)
    2635                 :            :    */
    2636                 :          4 :   pspec = g_param_spec_boxed ("hash-table",
    2637                 :            :                               "GHashTable property",
    2638                 :            :                               "A contained GHashTable",
    2639                 :            :                               G_TYPE_HASH_TABLE,
    2640                 :            :                               G_PARAM_READWRITE);
    2641                 :          4 :   g_object_class_install_property (gobject_class,
    2642                 :            :                                    PROP_TEST_OBJ_HASH_TABLE,
    2643                 :            :                                    pspec);
    2644                 :            : 
    2645                 :            :   /**
    2646                 :            :    * RegressTestObj:list: (type GLib.List(utf8)) (transfer none) (default-value NULL)
    2647                 :            :    */
    2648                 :          4 :   pspec = g_param_spec_pointer ("list",
    2649                 :            :                                 "GList property",
    2650                 :            :                                 "A contained GList",
    2651                 :            :                                 G_PARAM_READWRITE);
    2652                 :          4 :   g_object_class_install_property (gobject_class,
    2653                 :            :                                    PROP_TEST_OBJ_LIST,
    2654                 :            :                                    pspec);
    2655                 :            : 
    2656                 :            :   /**
    2657                 :            :    * RegressTestObj:pptrarray: (type GLib.PtrArray(utf8)) (transfer none)
    2658                 :            :    */
    2659                 :          4 :   pspec = g_param_spec_pointer ("pptrarray",
    2660                 :            :                                 "PtrArray property as a pointer",
    2661                 :            :                                 "Test annotating with GLib.PtrArray",
    2662                 :            :                                 G_PARAM_READWRITE);
    2663                 :          4 :   g_object_class_install_property (gobject_class,
    2664                 :            :                                    PROP_TEST_OBJ_PPTRARRAY,
    2665                 :            :                                    pspec);
    2666                 :            : 
    2667                 :            :   /**
    2668                 :            :    * RegressTestObj:hash-table-old: (type GLib.HashTable<utf8,gint8>) (transfer container)
    2669                 :            :    */
    2670                 :          4 :   pspec = g_param_spec_boxed ("hash-table-old",
    2671                 :            :                               "GHashTable property with <>",
    2672                 :            :                               "A contained GHashTable with <>",
    2673                 :            :                               G_TYPE_HASH_TABLE,
    2674                 :            :                               G_PARAM_READWRITE);
    2675                 :          4 :   g_object_class_install_property (gobject_class,
    2676                 :            :                                    PROP_TEST_OBJ_HASH_TABLE_OLD,
    2677                 :            :                                    pspec);
    2678                 :            : 
    2679                 :            :   /**
    2680                 :            :    * RegressTestObj:list-old: (type GLib.List<utf8>) (transfer none)
    2681                 :            :    */
    2682                 :          4 :   pspec = g_param_spec_pointer ("list-old",
    2683                 :            :                                 "GList property with ()",
    2684                 :            :                                 "A contained GList with <>",
    2685                 :            :                                 G_PARAM_READWRITE);
    2686                 :          4 :   g_object_class_install_property (gobject_class,
    2687                 :            :                                    PROP_TEST_OBJ_LIST_OLD,
    2688                 :            :                                    pspec);
    2689                 :            : 
    2690                 :            : 
    2691                 :            : 
    2692                 :            :   /**
    2693                 :            :    * RegressTestObj:int:
    2694                 :            :    */
    2695                 :          4 :   pspec = g_param_spec_int ("int",
    2696                 :            :                             "int property",
    2697                 :            :                             "A contained int",
    2698                 :            :                             G_MININT,
    2699                 :            :                             G_MAXINT,
    2700                 :            :                             0,
    2701                 :            :                             G_PARAM_READWRITE);
    2702                 :          4 :   g_object_class_install_property (gobject_class,
    2703                 :            :                                    PROP_TEST_OBJ_INT,
    2704                 :            :                                    pspec);
    2705                 :            : 
    2706                 :            :   /**
    2707                 :            :    * RegressTestObj:float:
    2708                 :            :    */
    2709                 :          4 :   pspec = g_param_spec_float ("float",
    2710                 :            :                               "float property",
    2711                 :            :                               "A contained float",
    2712                 :            :                               G_MINFLOAT,
    2713                 :            :                               G_MAXFLOAT,
    2714                 :            :                               1.0f,
    2715                 :            :                               G_PARAM_READWRITE);
    2716                 :          4 :   g_object_class_install_property (gobject_class,
    2717                 :            :                                    PROP_TEST_OBJ_FLOAT,
    2718                 :            :                                    pspec);
    2719                 :            : 
    2720                 :            :   /**
    2721                 :            :    * RegressTestObj:double:
    2722                 :            :    */
    2723                 :          4 :   pspec = g_param_spec_double ("double",
    2724                 :            :                                "double property",
    2725                 :            :                                "A contained double",
    2726                 :            :                                G_MINDOUBLE,
    2727                 :            :                                G_MAXDOUBLE,
    2728                 :            :                                1.0,
    2729                 :            :                                G_PARAM_READWRITE);
    2730                 :          4 :   g_object_class_install_property (gobject_class,
    2731                 :            :                                    PROP_TEST_OBJ_DOUBLE,
    2732                 :            :                                    pspec);
    2733                 :            : 
    2734                 :            :   /**
    2735                 :            :    * RegressTestObj:string: (setter set_string) (getter get_string)
    2736                 :            :    */
    2737                 :          4 :   pspec = g_param_spec_string ("string",
    2738                 :            :                                "string property",
    2739                 :            :                                "A contained string",
    2740                 :            :                                NULL,
    2741                 :            :                                G_PARAM_READWRITE);
    2742                 :          4 :   g_object_class_install_property (gobject_class,
    2743                 :            :                                    PROP_TEST_OBJ_STRING,
    2744                 :            :                                    pspec);
    2745                 :            : 
    2746                 :            : 
    2747                 :            :   /**
    2748                 :            :    * RegressTestObj:gtype: (default-value G_TYPE_INVALID)
    2749                 :            :    */
    2750                 :          4 :   pspec = g_param_spec_gtype ("gtype",
    2751                 :            :                               "GType property",
    2752                 :            :                               "A GType property",
    2753                 :            :                               G_TYPE_NONE,
    2754                 :            :                               G_PARAM_READWRITE);
    2755                 :          4 :   g_object_class_install_property (gobject_class,
    2756                 :            :                                    PROP_TEST_OBJ_GTYPE,
    2757                 :            :                                    pspec);
    2758                 :            : 
    2759                 :            :   /**
    2760                 :            :    * RegressTestObj:name-conflict:
    2761                 :            :    */
    2762                 :          4 :   pspec = g_param_spec_int ("name-conflict",
    2763                 :            :                             "name-conflict property",
    2764                 :            :                             "A property name that conflicts with a method",
    2765                 :            :                             G_MININT,
    2766                 :            :                             G_MAXINT,
    2767                 :            :                             42,
    2768                 :            :                             G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
    2769                 :          4 :   g_object_class_install_property (gobject_class,
    2770                 :            :                                    PROP_TEST_OBJ_NAME_CONFLICT,
    2771                 :            :                                    pspec);
    2772                 :            : 
    2773                 :            :   /**
    2774                 :            :    * RegressTestObj:byte-array:
    2775                 :            :    */
    2776                 :          4 :   pspec = g_param_spec_boxed ("byte-array",
    2777                 :            :                               "GByteArray property",
    2778                 :            :                               "A contained byte array without any element-type annotations",
    2779                 :            :                               G_TYPE_BYTE_ARRAY,
    2780                 :            :                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
    2781                 :          4 :   g_object_class_install_property (gobject_class,
    2782                 :            :                                    PROP_TEST_OBJ_BYTE_ARRAY,
    2783                 :            :                                    pspec);
    2784                 :            : 
    2785                 :            :   /**
    2786                 :            :    * RegressTestObj:write-only:
    2787                 :            :    */
    2788                 :          4 :   pspec = g_param_spec_boolean ("write-only", "Write-only property",
    2789                 :            :                                 "A write-only bool property that resets the value of TestObj:int to 0 when true",
    2790                 :            :                                 FALSE, G_PARAM_WRITABLE);
    2791                 :          4 :   g_object_class_install_property (gobject_class, PROP_TEST_OBJ_WRITE_ONLY, pspec);
    2792                 :            : 
    2793                 :          4 :   klass->matrix = regress_test_obj_default_matrix;
    2794                 :          4 : }
    2795                 :            : 
    2796                 :            : static void
    2797                 :         92 : regress_test_obj_init (RegressTestObj *obj)
    2798                 :            : {
    2799                 :         92 :   obj->bare = NULL;
    2800                 :         92 :   obj->boxed = NULL;
    2801                 :         92 :   obj->hash_table = NULL;
    2802                 :         92 :   obj->gtype = G_TYPE_INVALID;
    2803                 :         92 : }
    2804                 :            : 
    2805                 :            : /**
    2806                 :            :  * regress_test_obj_new: (constructor)
    2807                 :            :  * @obj: A #RegressTestObj
    2808                 :            :  */
    2809                 :            : RegressTestObj *
    2810                 :          1 : regress_test_obj_new (RegressTestObj *obj G_GNUC_UNUSED)
    2811                 :            : {
    2812                 :          1 :   return g_object_new (REGRESS_TEST_TYPE_OBJ, NULL);
    2813                 :            : }
    2814                 :            : 
    2815                 :            : /**
    2816                 :            :  * regress_constructor: (constructor)
    2817                 :            :  *
    2818                 :            :  */
    2819                 :            : RegressTestObj *
    2820                 :          4 : regress_constructor (void)
    2821                 :            : {
    2822                 :          4 :   return g_object_new (REGRESS_TEST_TYPE_OBJ, NULL);
    2823                 :            : }
    2824                 :            : 
    2825                 :            : /**
    2826                 :            :  * regress_test_obj_new_from_file:
    2827                 :            :  */
    2828                 :            : RegressTestObj *
    2829                 :          2 : regress_test_obj_new_from_file (const char *x G_GNUC_UNUSED,
    2830                 :            :                                 GError    **error G_GNUC_UNUSED)
    2831                 :            : {
    2832                 :          2 :   return g_object_new (REGRESS_TEST_TYPE_OBJ, NULL);
    2833                 :            : }
    2834                 :            : 
    2835                 :            : /**
    2836                 :            :  * regress_test_obj_set_bare:
    2837                 :            :  * @bare: (allow-none):
    2838                 :            :  */
    2839                 :            : void
    2840                 :         10 : regress_test_obj_set_bare (RegressTestObj *obj, GObject *bare)
    2841                 :            : {
    2842         [ +  + ]:         10 :   if (obj->bare)
    2843                 :          2 :     g_object_unref (obj->bare);
    2844                 :         10 :   obj->bare = bare;
    2845         [ +  + ]:         10 :   if (obj->bare)
    2846                 :          9 :     g_object_ref (obj->bare);
    2847                 :         10 : }
    2848                 :            : 
    2849                 :            : /**
    2850                 :            :  * regress_test_obj_set_string: (set-property string)
    2851                 :            :  * @obj:
    2852                 :            :  * @str:
    2853                 :            :  */
    2854                 :            : void
    2855                 :          0 : regress_test_obj_set_string (RegressTestObj *obj, const char *str)
    2856                 :            : {
    2857         [ #  # ]:          0 :   if (g_strcmp0 (str, obj->string) == 0)
    2858                 :          0 :     return;
    2859                 :            : 
    2860                 :          0 :   g_free (obj->string);
    2861                 :          0 :   obj->string = g_strdup (str);
    2862                 :          0 :   g_object_notify (G_OBJECT (obj), "string");
    2863                 :            : }
    2864                 :            : 
    2865                 :            : /**
    2866                 :            :  * regress_test_obj_get_string: (get-property string)
    2867                 :            :  * @obj:
    2868                 :            :  *
    2869                 :            :  * Returns: (transfer none):
    2870                 :            :  */
    2871                 :            : const char *
    2872                 :          0 : regress_test_obj_get_string (RegressTestObj *obj)
    2873                 :            : {
    2874                 :          0 :   return obj->string;
    2875                 :            : }
    2876                 :            : 
    2877                 :            : void
    2878                 :          1 : regress_test_obj_emit_sig_with_obj (RegressTestObj *obj)
    2879                 :            : {
    2880                 :          1 :     RegressTestObj *obj_param = regress_constructor ();
    2881                 :          1 :     g_object_set (obj_param, "int", 3, NULL);
    2882                 :          1 :     g_signal_emit_by_name (obj, "sig-with-obj", obj_param);
    2883                 :          1 :     g_object_unref (obj_param);
    2884                 :          1 : }
    2885                 :            : 
    2886                 :            : #ifndef _GI_DISABLE_CAIRO
    2887                 :            : void
    2888                 :          1 : regress_test_obj_emit_sig_with_foreign_struct (RegressTestObj *obj)
    2889                 :            : {
    2890                 :          1 :   cairo_t *cr = regress_test_cairo_context_full_return ();
    2891                 :          1 :   g_signal_emit_by_name (obj, "sig-with-foreign-struct", cr);
    2892                 :          1 :   cairo_destroy (cr);
    2893                 :          1 : }
    2894                 :            : #endif
    2895                 :            : 
    2896                 :            : void
    2897                 :          0 : regress_test_obj_emit_sig_with_int64 (RegressTestObj *obj)
    2898                 :            : {
    2899                 :          0 :   gint64 ret = 0;
    2900                 :          0 :   RegressTestObj *obj_param = regress_constructor ();
    2901                 :          0 :   g_signal_emit_by_name (obj, "sig-with-int64-prop", G_MAXINT64, &ret);
    2902                 :          0 :   g_object_unref (obj_param);
    2903                 :          0 :   g_assert (ret == G_MAXINT64);
    2904                 :          0 : }
    2905                 :            : 
    2906                 :            : void
    2907                 :          0 : regress_test_obj_emit_sig_with_uint64 (RegressTestObj *obj)
    2908                 :            : {
    2909                 :          0 :   guint64 ret = 0;
    2910                 :          0 :   RegressTestObj *obj_param = regress_constructor ();
    2911                 :          0 :   g_signal_emit_by_name (obj, "sig-with-uint64-prop", G_MAXUINT64, &ret);
    2912                 :          0 :   g_object_unref (obj_param);
    2913                 :          0 :   g_assert (ret == G_MAXUINT64);
    2914                 :          0 : }
    2915                 :            : 
    2916                 :            : /**
    2917                 :            :  * regress_test_obj_emit_sig_with_array_len_prop:
    2918                 :            :  */
    2919                 :            : void
    2920                 :          1 : regress_test_obj_emit_sig_with_array_len_prop (RegressTestObj *obj)
    2921                 :            : {
    2922                 :          1 :   int arr[] = { 0, 1, 2, 3, 4 };
    2923                 :          1 :   g_signal_emit_by_name (obj, "sig-with-array-len-prop", &arr, 5);
    2924                 :          1 : }
    2925                 :            : 
    2926                 :            : /**
    2927                 :            :  * regress_test_obj_emit_sig_with_inout_int:
    2928                 :            :  * @obj: The object to emit the signal.
    2929                 :            :  *
    2930                 :            :  * The signal handler must increment the inout parameter by 1.
    2931                 :            :  */
    2932                 :            : void
    2933                 :          0 : regress_test_obj_emit_sig_with_inout_int (RegressTestObj *obj)
    2934                 :            : {
    2935                 :          0 :   int inout = 42;
    2936                 :          0 :   g_signal_emit_by_name (obj, "sig-with-inout-int", &inout);
    2937                 :          0 :   g_assert_cmpint (inout, ==, 43);
    2938                 :          0 : }
    2939                 :            : 
    2940                 :            : /**
    2941                 :            :  * regress_test_obj_emit_sig_with_error:
    2942                 :            :  * @self: The object to emit the signal.
    2943                 :            :  */
    2944                 :            : void
    2945                 :          1 : regress_test_obj_emit_sig_with_error (RegressTestObj *self)
    2946                 :            : {
    2947                 :          1 :   GError *err = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED,
    2948                 :            :                                      "Something failed");
    2949                 :          1 :   g_signal_emit_by_name (self, "sig-with-gerror", err);
    2950                 :          1 :   g_error_free (err);
    2951                 :          1 : }
    2952                 :            : 
    2953                 :            : /**
    2954                 :            :  * regress_test_obj_emit_sig_with_null_error:
    2955                 :            :  * @self: The object to emit the signal.
    2956                 :            :  */
    2957                 :            : void
    2958                 :          1 : regress_test_obj_emit_sig_with_null_error (RegressTestObj *self)
    2959                 :            : {
    2960                 :          1 :   g_signal_emit_by_name (self, "sig-with-gerror", NULL);
    2961                 :          1 : }
    2962                 :            : 
    2963                 :            : int
    2964                 :          2 : regress_test_obj_instance_method (RegressTestObj *obj G_GNUC_UNUSED)
    2965                 :            : {
    2966                 :          2 :     return -1;
    2967                 :            : }
    2968                 :            : 
    2969                 :            : /**
    2970                 :            :  * regress_test_obj_instance_method_full:
    2971                 :            :  * @obj: (transfer full):
    2972                 :            :  *
    2973                 :            :  */
    2974                 :            : void
    2975                 :          1 : regress_test_obj_instance_method_full (RegressTestObj *obj)
    2976                 :            : {
    2977                 :          1 :   g_object_unref (obj);
    2978                 :          1 : }
    2979                 :            : 
    2980                 :            : double
    2981                 :          1 : regress_test_obj_static_method (int x)
    2982                 :            : {
    2983                 :          1 :   return x;
    2984                 :            : }
    2985                 :            : 
    2986                 :            : /**
    2987                 :            :  * regress_forced_method: (method)
    2988                 :            :  * @obj: A #RegressTestObj
    2989                 :            :  *
    2990                 :            :  */
    2991                 :            : void
    2992                 :          1 : regress_forced_method (RegressTestObj *obj G_GNUC_UNUSED)
    2993                 :            : {
    2994                 :          1 : }
    2995                 :            : 
    2996                 :            : /**
    2997                 :            :  * regress_test_obj_torture_signature_0:
    2998                 :            :  * @obj: A #RegressTestObj
    2999                 :            :  * @x:
    3000                 :            :  * @y: (out):
    3001                 :            :  * @z: (out):
    3002                 :            :  * @foo:
    3003                 :            :  * @q: (out):
    3004                 :            :  * @m:
    3005                 :            :  *
    3006                 :            :  */
    3007                 :            : void
    3008                 :          1 : regress_test_obj_torture_signature_0 (RegressTestObj    *obj G_GNUC_UNUSED,
    3009                 :            :                               int         x,
    3010                 :            :                               double     *y,
    3011                 :            :                               int        *z,
    3012                 :            :                               const char *foo,
    3013                 :            :                               int        *q,
    3014                 :            :                               guint       m)
    3015                 :            : {
    3016                 :          1 :   *y = x;
    3017                 :          1 :   *z = x * 2;
    3018                 :          1 :   *q = g_utf8_strlen (foo, -1) + m;
    3019                 :          1 : }
    3020                 :            : 
    3021                 :            : /**
    3022                 :            :  * regress_test_obj_torture_signature_1:
    3023                 :            :  * @obj: A #RegressTestObj
    3024                 :            :  * @x:
    3025                 :            :  * @y: (out):
    3026                 :            :  * @z: (out):
    3027                 :            :  * @foo:
    3028                 :            :  * @q: (out):
    3029                 :            :  * @m:
    3030                 :            :  * @error: A #GError
    3031                 :            :  *
    3032                 :            :  * This function throws an error if m is odd.
    3033                 :            :  */
    3034                 :            : gboolean
    3035                 :          2 : regress_test_obj_torture_signature_1 (RegressTestObj   *obj G_GNUC_UNUSED,
    3036                 :            :                               int        x,
    3037                 :            :                               double     *y,
    3038                 :            :                               int        *z,
    3039                 :            :                               const char *foo,
    3040                 :            :                               int        *q,
    3041                 :            :                               guint       m,
    3042                 :            :                               GError    **error)
    3043                 :            : {
    3044                 :          2 :   *y = x;
    3045                 :          2 :   *z = x * 2;
    3046                 :          2 :   *q = g_utf8_strlen (foo, -1) + m;
    3047         [ +  + ]:          2 :   if (m % 2 == 0)
    3048                 :          1 :       return TRUE;
    3049                 :          1 :   g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "m is odd");
    3050                 :          1 :   return FALSE;
    3051                 :            : }
    3052                 :            : 
    3053                 :            : /**
    3054                 :            :  * regress_test_obj_skip_return_val:
    3055                 :            :  * @obj: a #RegressTestObj
    3056                 :            :  * @a: Parameter.
    3057                 :            :  * @out_b: (out): A return value.
    3058                 :            :  * @c: Other parameter.
    3059                 :            :  * @inout_d: (inout): Will be incremented.
    3060                 :            :  * @out_sum: (out): Return value.
    3061                 :            :  * @num1: Number.
    3062                 :            :  * @num2: Number.
    3063                 :            :  * @error: Return location for error.
    3064                 :            :  *
    3065                 :            :  * Check that the return value is skipped
    3066                 :            :  *
    3067                 :            :  * Returns: (skip): %TRUE if the call succeeds, %FALSE if @error is set.
    3068                 :            :  */
    3069                 :            : gboolean
    3070                 :          0 : regress_test_obj_skip_return_val (RegressTestObj *obj G_GNUC_UNUSED,
    3071                 :            :                                   gint            a,
    3072                 :            :                                   gint           *out_b,
    3073                 :            :                                   gdouble         c G_GNUC_UNUSED,
    3074                 :            :                                   gint           *inout_d,
    3075                 :            :                                   gint           *out_sum,
    3076                 :            :                                   gint            num1,
    3077                 :            :                                   gint            num2,
    3078                 :            :                                   GError        **error G_GNUC_UNUSED)
    3079                 :            : {
    3080         [ #  # ]:          0 :   if (out_b != NULL)
    3081                 :          0 :     *out_b = a + 1;
    3082         [ #  # ]:          0 :   if (inout_d != NULL)
    3083                 :          0 :     *inout_d = *inout_d + 1;
    3084         [ #  # ]:          0 :   if (out_sum != NULL)
    3085                 :          0 :     *out_sum = num1 + 10*num2;
    3086                 :          0 :   return TRUE;
    3087                 :            : }
    3088                 :            : 
    3089                 :            : /**
    3090                 :            :  * regress_test_obj_skip_return_val_no_out:
    3091                 :            :  * @obj: a #RegressTestObj
    3092                 :            :  * @a: Parameter.
    3093                 :            :  * @error: Return location for error.
    3094                 :            :  *
    3095                 :            :  * Check that the return value is skipped. Succeed if a is nonzero, otherwise
    3096                 :            :  * raise an error.
    3097                 :            :  *
    3098                 :            :  * Returns: (skip): %TRUE if the call succeeds, %FALSE if @error is set.
    3099                 :            :  */
    3100                 :            : gboolean
    3101                 :          0 : regress_test_obj_skip_return_val_no_out (RegressTestObj *obj G_GNUC_UNUSED,
    3102                 :            :                                          gint            a,
    3103                 :            :                                          GError        **error)
    3104                 :            : {
    3105         [ #  # ]:          0 :   if (a == 0) {
    3106                 :          0 :     g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "a is zero");
    3107                 :          0 :     return FALSE;
    3108                 :            :   } else {
    3109                 :          0 :     return TRUE;
    3110                 :            :   }
    3111                 :            : }
    3112                 :            : 
    3113                 :            : /**
    3114                 :            :  * regress_test_obj_skip_param:
    3115                 :            :  * @obj: A #RegressTestObj.
    3116                 :            :  * @a: Parameter.
    3117                 :            :  * @out_b: (out): Return value.
    3118                 :            :  * @c: (skip): Other parameter.
    3119                 :            :  * @inout_d: (inout): Will be incremented.
    3120                 :            :  * @out_sum: (out): Return value.
    3121                 :            :  * @num1: Number.
    3122                 :            :  * @num2: Number.
    3123                 :            :  * @error: Return location for error.
    3124                 :            :  *
    3125                 :            :  * Check that a parameter is skipped
    3126                 :            :  *
    3127                 :            :  * Returns: %TRUE if the call succeeds, %FALSE if @error is set.
    3128                 :            :  */
    3129                 :            : gboolean
    3130                 :          0 : regress_test_obj_skip_param (RegressTestObj *obj G_GNUC_UNUSED,
    3131                 :            :                              gint            a,
    3132                 :            :                              gint           *out_b,
    3133                 :            :                              gdouble         c G_GNUC_UNUSED,
    3134                 :            :                              gint           *inout_d,
    3135                 :            :                              gint           *out_sum,
    3136                 :            :                              gint            num1,
    3137                 :            :                              gint            num2,
    3138                 :            :                              GError        **error G_GNUC_UNUSED)
    3139                 :            : {
    3140         [ #  # ]:          0 :   if (out_b != NULL)
    3141                 :          0 :     *out_b = a + 1;
    3142         [ #  # ]:          0 :   if (inout_d != NULL)
    3143                 :          0 :     *inout_d = *inout_d + 1;
    3144         [ #  # ]:          0 :   if (out_sum != NULL)
    3145                 :          0 :     *out_sum = num1 + 10*num2;
    3146                 :          0 :   return TRUE;
    3147                 :            : }
    3148                 :            : 
    3149                 :            : /**
    3150                 :            :  * regress_test_obj_skip_out_param:
    3151                 :            :  * @obj: A #RegressTestObj.
    3152                 :            :  * @a: Parameter.
    3153                 :            :  * @out_b: (out) (skip): Return value.
    3154                 :            :  * @c: Other parameter.
    3155                 :            :  * @inout_d: (inout): Will be incremented.
    3156                 :            :  * @out_sum: (out): Return value.
    3157                 :            :  * @num1: Number.
    3158                 :            :  * @num2: Number.
    3159                 :            :  * @error: Return location for error.
    3160                 :            :  *
    3161                 :            :  * Check that the out value is skipped
    3162                 :            :  *
    3163                 :            :  * Returns: %TRUE if the call succeeds, %FALSE if @error is set.
    3164                 :            :  */
    3165                 :            : gboolean
    3166                 :          0 : regress_test_obj_skip_out_param (RegressTestObj *obj G_GNUC_UNUSED,
    3167                 :            :                                  gint            a,
    3168                 :            :                                  gint           *out_b,
    3169                 :            :                                  gdouble         c G_GNUC_UNUSED,
    3170                 :            :                                  gint           *inout_d,
    3171                 :            :                                  gint           *out_sum,
    3172                 :            :                                  gint            num1,
    3173                 :            :                                  gint            num2,
    3174                 :            :                                  GError        **error G_GNUC_UNUSED)
    3175                 :            : {
    3176         [ #  # ]:          0 :   if (out_b != NULL)
    3177                 :          0 :     *out_b = a + 1;
    3178         [ #  # ]:          0 :   if (inout_d != NULL)
    3179                 :          0 :     *inout_d = *inout_d + 1;
    3180         [ #  # ]:          0 :   if (out_sum != NULL)
    3181                 :          0 :     *out_sum = num1 + 10*num2;
    3182                 :          0 :   return TRUE;
    3183                 :            : }
    3184                 :            : 
    3185                 :            : /**
    3186                 :            :  * regress_test_obj_skip_inout_param:
    3187                 :            :  * @obj: A #RegressTestObj.
    3188                 :            :  * @a: Parameter.
    3189                 :            :  * @out_b: (out): Return value.
    3190                 :            :  * @c: Other parameter.
    3191                 :            :  * @inout_d: (inout) (skip): Will be incremented.
    3192                 :            :  * @out_sum: (out): Return value.
    3193                 :            :  * @num1: Number.
    3194                 :            :  * @num2: Number.
    3195                 :            :  * @error: Return location for error.
    3196                 :            :  *
    3197                 :            :  * Check that the out value is skipped
    3198                 :            :  *
    3199                 :            :  * Returns: %TRUE if the call succeeds, %FALSE if @error is set.
    3200                 :            :  */
    3201                 :            : gboolean
    3202                 :          0 : regress_test_obj_skip_inout_param (RegressTestObj *obj G_GNUC_UNUSED,
    3203                 :            :                                    gint            a,
    3204                 :            :                                    gint           *out_b,
    3205                 :            :                                    gdouble         c G_GNUC_UNUSED,
    3206                 :            :                                    gint           *inout_d,
    3207                 :            :                                    gint           *out_sum,
    3208                 :            :                                    gint            num1,
    3209                 :            :                                    gint            num2,
    3210                 :            :                                    GError        **error G_GNUC_UNUSED)
    3211                 :            : {
    3212         [ #  # ]:          0 :   if (out_b != NULL)
    3213                 :          0 :     *out_b = a + 1;
    3214         [ #  # ]:          0 :   if (inout_d != NULL)
    3215                 :          0 :     *inout_d = *inout_d + 1;
    3216         [ #  # ]:          0 :   if (out_sum != NULL)
    3217                 :          0 :     *out_sum = num1 + 10*num2;
    3218                 :          0 :   return TRUE;
    3219                 :            : }
    3220                 :            : 
    3221                 :            : /**
    3222                 :            :  * regress_test_obj_do_matrix: (virtual matrix)
    3223                 :            :  * @obj: A #RegressTestObj
    3224                 :            :  * @somestr: Meaningless string
    3225                 :            :  *
    3226                 :            :  * This method is virtual.  Notably its name differs from the virtual
    3227                 :            :  * slot name, which makes it useful for testing bindings handle this
    3228                 :            :  * case.
    3229                 :            :  */
    3230                 :            : int
    3231                 :          1 : regress_test_obj_do_matrix (RegressTestObj *obj, const char *somestr)
    3232                 :            : {
    3233                 :          1 :   return REGRESS_TEST_OBJ_GET_CLASS (obj)->matrix (obj, somestr);
    3234                 :            : }
    3235                 :            : 
    3236                 :            : /**
    3237                 :            :  * regress_func_obj_null_in:
    3238                 :            :  * @obj: (allow-none): A #RegressTestObj
    3239                 :            :  */
    3240                 :            : void
    3241                 :          2 : regress_func_obj_null_in (RegressTestObj *obj G_GNUC_UNUSED)
    3242                 :            : {
    3243                 :          2 : }
    3244                 :            : 
    3245                 :            : /**
    3246                 :            :  * regress_test_obj_null_out:
    3247                 :            :  * @obj: (allow-none) (out): A #RegressTestObj
    3248                 :            :  */
    3249                 :            : void
    3250                 :          1 : regress_test_obj_null_out (RegressTestObj **obj)
    3251                 :            : {
    3252         [ +  - ]:          1 :   if (obj)
    3253                 :          1 :     *obj = NULL;
    3254                 :          1 : }
    3255                 :            : 
    3256                 :            : /**
    3257                 :            :  * regress_func_obj_nullable_in:
    3258                 :            :  * @obj: (nullable): A #RegressTestObj
    3259                 :            :  */
    3260                 :            : void
    3261                 :          1 : regress_func_obj_nullable_in (RegressTestObj *obj G_GNUC_UNUSED)
    3262                 :            : {
    3263                 :          1 : }
    3264                 :            : 
    3265                 :            : /**
    3266                 :            :  * regress_test_obj_not_nullable_typed_gpointer_in:
    3267                 :            :  * @obj: A #RegressTestObj
    3268                 :            :  * @input: (type GObject): some #GObject
    3269                 :            :  */
    3270                 :            : void
    3271                 :          1 : regress_test_obj_not_nullable_typed_gpointer_in (RegressTestObj *obj G_GNUC_UNUSED,
    3272                 :            :                                                  gpointer        input G_GNUC_UNUSED)
    3273                 :            : {
    3274                 :          1 : }
    3275                 :            : 
    3276                 :            : /**
    3277                 :            :  * regress_test_obj_not_nullable_element_typed_gpointer_in:
    3278                 :            :  * @obj: A #RegressTestObj
    3279                 :            :  * @input: (element-type guint8) (array length=count): some uint8 array
    3280                 :            :  * @count: length of @input
    3281                 :            :  */
    3282                 :            : void
    3283                 :          1 : regress_test_obj_not_nullable_element_typed_gpointer_in (RegressTestObj *obj G_GNUC_UNUSED,
    3284                 :            :                                                          gpointer        input G_GNUC_UNUSED,
    3285                 :            :                                                          guint           count G_GNUC_UNUSED)
    3286                 :            : {
    3287                 :          1 : }
    3288                 :            : 
    3289                 :            : /**
    3290                 :            :  * regress_test_obj_name_conflict:
    3291                 :            :  * @obj: A #RegressTestObj
    3292                 :            :  */
    3293                 :            : void
    3294                 :          0 : regress_test_obj_name_conflict (RegressTestObj *obj G_GNUC_UNUSED)
    3295                 :            : {
    3296                 :          0 : }
    3297                 :            : 
    3298                 :            : /**
    3299                 :            :  * regress_test_array_fixed_out_objects:
    3300                 :            :  * @objs: (out) (array fixed-size=2) (transfer full): An array of #RegressTestObj
    3301                 :            :  */
    3302                 :            : void
    3303                 :          1 : regress_test_array_fixed_out_objects (RegressTestObj ***objs)
    3304                 :            : {
    3305                 :          1 :     RegressTestObj **values = (RegressTestObj**)g_new(gpointer, 2);
    3306                 :            : 
    3307                 :          1 :     values[0] = regress_constructor();
    3308                 :          1 :     values[1] = regress_constructor();
    3309                 :            : 
    3310                 :          1 :     *objs = values;
    3311                 :          1 : }
    3312                 :            : 
    3313                 :            : typedef struct _CallbackInfo CallbackInfo;
    3314                 :            : 
    3315                 :            : struct _CallbackInfo
    3316                 :            : {
    3317                 :            :   RegressTestCallbackUserData callback;
    3318                 :            :   GDestroyNotify notify;
    3319                 :            :   gpointer user_data;
    3320                 :            : };
    3321                 :            : 
    3322                 :            : static void
    3323                 :          2 : regress_test_sub_obj_iface_init (RegressTestInterfaceIface *iface G_GNUC_UNUSED)
    3324                 :            : {
    3325                 :          2 : }
    3326                 :            : 
    3327                 :            : enum {
    3328                 :            :   PROP_TEST_SUB_OBJ_NUMBER = 1,
    3329                 :            :   PROP_TEST_SUB_OBJ_BOOLEAN,
    3330                 :            : };
    3331                 :            : 
    3332   [ +  +  +  -  :         60 : G_DEFINE_TYPE_WITH_CODE(RegressTestSubObj, regress_test_sub_obj,
                   +  + ]
    3333                 :            :                         REGRESS_TEST_TYPE_OBJ,
    3334                 :            :                         G_IMPLEMENT_INTERFACE(REGRESS_TEST_TYPE_INTERFACE,
    3335                 :            :                                               regress_test_sub_obj_iface_init));
    3336                 :            : 
    3337                 :            : 
    3338                 :            : static void
    3339                 :         40 : regress_test_sub_obj_set_property (GObject      *object,
    3340                 :            :                                    guint         property_id,
    3341                 :            :                                    const GValue *value,
    3342                 :            :                                    GParamSpec   *pspec)
    3343                 :            : {
    3344                 :         40 :   RegressTestSubObj *self = REGRESS_TEST_SUB_OBJECT (object);
    3345                 :            : 
    3346      [ +  +  - ]:         40 :   switch (property_id)
    3347                 :            :     {
    3348                 :         20 :     case PROP_TEST_SUB_OBJ_NUMBER:
    3349                 :         20 :       self->number = g_value_get_int (value);
    3350                 :         20 :       break;
    3351                 :            : 
    3352                 :         20 :     case PROP_TEST_SUB_OBJ_BOOLEAN:
    3353                 :         20 :       self->boolean = g_value_get_boolean (value);
    3354                 :         20 :       break;
    3355                 :            : 
    3356                 :          0 :     default:
    3357                 :          0 :       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
    3358                 :            :     }
    3359                 :         40 : }
    3360                 :            : 
    3361                 :            : static void
    3362                 :          6 : regress_test_sub_obj_get_property (GObject    *object,
    3363                 :            :                                    guint       property_id,
    3364                 :            :                                    GValue     *value,
    3365                 :            :                                    GParamSpec *pspec)
    3366                 :            : {
    3367                 :          6 :   RegressTestSubObj *self = REGRESS_TEST_SUB_OBJECT (object);
    3368                 :            : 
    3369      [ +  +  - ]:          6 :   switch (property_id)
    3370                 :            :     {
    3371                 :          4 :     case PROP_TEST_SUB_OBJ_NUMBER:
    3372                 :          4 :       g_value_set_int (value, self->number);
    3373                 :          4 :       break;
    3374                 :            : 
    3375                 :          2 :     case PROP_TEST_SUB_OBJ_BOOLEAN:
    3376                 :          2 :       g_value_set_boolean (value, self->boolean);
    3377                 :          2 :       break;
    3378                 :            : 
    3379                 :          0 :     default:
    3380                 :          0 :       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
    3381                 :            :     }
    3382                 :          6 : }
    3383                 :            : 
    3384                 :            : static void
    3385                 :          2 : regress_test_sub_obj_class_init (RegressTestSubObjClass *klass)
    3386                 :            : {
    3387                 :          2 :   const guint flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS;
    3388                 :          2 :   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
    3389                 :          2 :   gobject_class->get_property = regress_test_sub_obj_get_property;
    3390                 :          2 :   gobject_class->set_property = regress_test_sub_obj_set_property;
    3391                 :            : 
    3392                 :          2 :   g_object_class_install_property (gobject_class, PROP_TEST_SUB_OBJ_BOOLEAN,
    3393                 :            :                                    g_param_spec_boolean ("boolean", "Boolean", "Boolean",
    3394                 :            :                                                          TRUE, flags));
    3395                 :            : 
    3396                 :          2 :   g_object_class_override_property (gobject_class, PROP_TEST_SUB_OBJ_NUMBER,
    3397                 :            :                                     "number");
    3398                 :          2 : }
    3399                 :            : 
    3400                 :            : static void
    3401                 :         19 : regress_test_sub_obj_init (RegressTestSubObj *self G_GNUC_UNUSED)
    3402                 :            : {
    3403                 :         19 : }
    3404                 :            : 
    3405                 :            : RegressTestObj*
    3406                 :          1 : regress_test_sub_obj_new (void)
    3407                 :            : {
    3408                 :          1 :   return g_object_new (REGRESS_TEST_TYPE_SUB_OBJ, NULL);
    3409                 :            : }
    3410                 :            : 
    3411                 :            : int
    3412                 :          1 : regress_test_sub_obj_instance_method (RegressTestSubObj *self G_GNUC_UNUSED)
    3413                 :            : {
    3414                 :          1 :     return 0;
    3415                 :            : }
    3416                 :            : 
    3417                 :            : void
    3418                 :          1 : regress_test_sub_obj_unset_bare (RegressTestSubObj *obj)
    3419                 :            : {
    3420                 :          1 :   regress_test_obj_set_bare(REGRESS_TEST_OBJECT(obj), NULL);
    3421                 :          1 : }
    3422                 :            : 
    3423                 :            : /* RegressTestFundamental */
    3424                 :            : 
    3425                 :            : /**
    3426                 :            :  * regress_test_fundamental_object_ref:
    3427                 :            :  *
    3428                 :            :  * Returns: (transfer full): A new #RegressTestFundamentalObject
    3429                 :            :  */
    3430                 :            : RegressTestFundamentalObject *
    3431                 :         47 : regress_test_fundamental_object_ref (RegressTestFundamentalObject * fundamental_object)
    3432                 :            : {
    3433                 :         47 :   g_return_val_if_fail (fundamental_object != NULL, NULL);
    3434                 :         47 :   g_atomic_int_inc (&fundamental_object->refcount);
    3435                 :            : 
    3436                 :         47 :   return fundamental_object;
    3437                 :            : }
    3438                 :            : 
    3439                 :            : static void
    3440                 :         16 : regress_test_fundamental_object_free (RegressTestFundamentalObject * fundamental_object)
    3441                 :            : {
    3442                 :            :   RegressTestFundamentalObjectClass *mo_class;
    3443                 :         16 :   regress_test_fundamental_object_ref (fundamental_object);
    3444                 :            : 
    3445                 :         16 :   mo_class = REGRESS_TEST_FUNDAMENTAL_OBJECT_GET_CLASS (fundamental_object);
    3446                 :         16 :   mo_class->finalize (fundamental_object);
    3447                 :            : 
    3448         [ +  - ]:         16 :   if (G_LIKELY (g_atomic_int_dec_and_test (&fundamental_object->refcount))) {
    3449                 :         16 :     g_type_free_instance ((GTypeInstance *) fundamental_object);
    3450                 :            :   }
    3451                 :         16 : }
    3452                 :            : 
    3453                 :            : void
    3454                 :         47 : regress_test_fundamental_object_unref (RegressTestFundamentalObject * fundamental_object)
    3455                 :            : {
    3456                 :         47 :   g_return_if_fail (fundamental_object != NULL);
    3457                 :         47 :   g_return_if_fail (fundamental_object->refcount > 0);
    3458                 :            : 
    3459         [ +  + ]:         47 :   if (G_UNLIKELY (g_atomic_int_dec_and_test (&fundamental_object->refcount))) {
    3460                 :         16 :     regress_test_fundamental_object_free (fundamental_object);
    3461                 :            :   }
    3462                 :            : }
    3463                 :            : 
    3464                 :            : static void
    3465                 :          4 : regress_test_fundamental_object_replace (RegressTestFundamentalObject ** olddata, RegressTestFundamentalObject * newdata)
    3466                 :            : {
    3467                 :            :   RegressTestFundamentalObject *olddata_val;
    3468                 :            : 
    3469                 :          4 :   g_return_if_fail (olddata != NULL);
    3470                 :            : 
    3471                 :          4 :   olddata_val = g_atomic_pointer_get ((gpointer *) olddata);
    3472                 :            : 
    3473         [ -  + ]:          4 :   if (olddata_val == newdata)
    3474                 :          0 :     return;
    3475                 :            : 
    3476         [ +  - ]:          4 :   if (newdata)
    3477                 :          4 :     regress_test_fundamental_object_ref (newdata);
    3478                 :            : 
    3479         [ -  + ]:          4 :   while (!g_atomic_pointer_compare_and_exchange ((gpointer *) olddata,
    3480                 :            :           olddata_val, newdata)) {
    3481                 :          0 :     olddata_val = g_atomic_pointer_get ((gpointer *) olddata);
    3482                 :            :   }
    3483                 :            : 
    3484         [ -  + ]:          4 :   if (olddata_val)
    3485                 :          0 :     regress_test_fundamental_object_unref (olddata_val);
    3486                 :            : }
    3487                 :            : 
    3488                 :            : static void
    3489                 :         22 : regress_test_value_fundamental_object_init (GValue * value)
    3490                 :            : {
    3491                 :         22 :   value->data[0].v_pointer = NULL;
    3492                 :         22 : }
    3493                 :            : 
    3494                 :            : static void
    3495                 :         32 : regress_test_value_fundamental_object_free (GValue * value)
    3496                 :            : {
    3497         [ +  + ]:         32 :   if (value->data[0].v_pointer) {
    3498                 :         14 :     regress_test_fundamental_object_unref (REGRESS_TEST_FUNDAMENTAL_OBJECT_CAST (value->data[0].v_pointer));
    3499                 :            :   }
    3500                 :         32 : }
    3501                 :            : 
    3502                 :            : static void
    3503                 :          3 : regress_test_value_fundamental_object_copy (const GValue * src_value, GValue * dest_value)
    3504                 :            : {
    3505         [ +  - ]:          3 :   if (src_value->data[0].v_pointer) {
    3506                 :          3 :     dest_value->data[0].v_pointer =
    3507                 :          3 :         regress_test_fundamental_object_ref (REGRESS_TEST_FUNDAMENTAL_OBJECT_CAST (src_value->data[0].
    3508                 :            :             v_pointer));
    3509                 :            :   } else {
    3510                 :          0 :     dest_value->data[0].v_pointer = NULL;
    3511                 :            :   }
    3512                 :          3 : }
    3513                 :            : 
    3514                 :            : static gpointer
    3515                 :         27 : regress_test_value_fundamental_object_peek_pointer (const GValue * value)
    3516                 :            : {
    3517                 :         27 :   return value->data[0].v_pointer;
    3518                 :            : }
    3519                 :            : 
    3520                 :            : static gchar *
    3521                 :          7 : regress_test_value_fundamental_object_collect (GValue      *value,
    3522                 :            :                                                guint        n_collect_values,
    3523                 :            :                                                GTypeCValue *collect_values,
    3524                 :            :                                                guint        collect_flags G_GNUC_UNUSED)
    3525                 :            : {
    3526                 :          7 :   g_assert (n_collect_values > 0);
    3527                 :            : 
    3528         [ +  - ]:          7 :   if (collect_values[0].v_pointer) {
    3529                 :          7 :     value->data[0].v_pointer =
    3530                 :          7 :         regress_test_fundamental_object_ref (collect_values[0].v_pointer);
    3531                 :            :   } else {
    3532                 :          0 :     value->data[0].v_pointer = NULL;
    3533                 :            :   }
    3534                 :            : 
    3535                 :          7 :   return NULL;
    3536                 :            : }
    3537                 :            : 
    3538                 :            : static gchar *
    3539                 :          0 : regress_test_value_fundamental_object_lcopy (const GValue * value,
    3540                 :            :                                      guint n_collect_values,
    3541                 :            :                                      GTypeCValue * collect_values,
    3542                 :            :                                      guint collect_flags)
    3543                 :            : {
    3544                 :            :   gpointer *fundamental_object_p;
    3545                 :            : 
    3546                 :          0 :   g_assert (n_collect_values > 0);
    3547                 :            : 
    3548                 :          0 :   fundamental_object_p = collect_values[0].v_pointer;
    3549                 :            : 
    3550         [ #  # ]:          0 :   if (!fundamental_object_p) {
    3551                 :          0 :     return g_strdup_printf ("value location for '%s' passed as NULL",
    3552                 :            :         G_VALUE_TYPE_NAME (value));
    3553                 :            :   }
    3554                 :            : 
    3555         [ #  # ]:          0 :   if (!value->data[0].v_pointer)
    3556                 :          0 :     *fundamental_object_p = NULL;
    3557         [ #  # ]:          0 :   else if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
    3558                 :          0 :     *fundamental_object_p = value->data[0].v_pointer;
    3559                 :            :   else
    3560                 :          0 :     *fundamental_object_p = regress_test_fundamental_object_ref (value->data[0].v_pointer);
    3561                 :            : 
    3562                 :          0 :   return NULL;
    3563                 :            : }
    3564                 :            : 
    3565                 :            : static void
    3566                 :         10 : regress_test_fundamental_object_finalize (RegressTestFundamentalObject *self G_GNUC_UNUSED)
    3567                 :            : {
    3568                 :            : 
    3569                 :         10 : }
    3570                 :            : 
    3571                 :            : static RegressTestFundamentalObject *
    3572                 :          0 : regress_test_fundamental_object_copy_default (const RegressTestFundamentalObject *self G_GNUC_UNUSED)
    3573                 :            : {
    3574                 :          0 :   g_warning ("RegressTestFundamentalObject classes must implement RegressTestFundamentalObject::copy");
    3575                 :          0 :   return NULL;
    3576                 :            : }
    3577                 :            : 
    3578                 :            : static void
    3579                 :          3 : regress_test_fundamental_object_class_init (gpointer g_class,
    3580                 :            :                                             gpointer class_data G_GNUC_UNUSED)
    3581                 :            : {
    3582                 :          3 :   RegressTestFundamentalObjectClass *mo_class = REGRESS_TEST_FUNDAMENTAL_OBJECT_CLASS (g_class);
    3583                 :            : 
    3584                 :          3 :   mo_class->copy = regress_test_fundamental_object_copy_default;
    3585                 :          3 :   mo_class->finalize = regress_test_fundamental_object_finalize;
    3586                 :          3 : }
    3587                 :            : 
    3588                 :            : static void
    3589                 :         11 : regress_test_fundamental_object_init (GTypeInstance *instance,
    3590                 :            :                                       gpointer       klass G_GNUC_UNUSED)
    3591                 :            : {
    3592                 :         11 :   RegressTestFundamentalObject *fundamental_object = REGRESS_TEST_FUNDAMENTAL_OBJECT_CAST (instance);
    3593                 :            : 
    3594                 :         11 :   fundamental_object->refcount = 1;
    3595                 :         11 : }
    3596                 :            : 
    3597                 :            : /**
    3598                 :            :  * RegressTestFundamentalObject: (ref-func regress_test_fundamental_object_ref) (unref-func regress_test_fundamental_object_unref) (set-value-func regress_test_value_set_fundamental_object) (get-value-func regress_test_value_get_fundamental_object)
    3599                 :            :  */
    3600                 :            : 
    3601                 :            : GType
    3602                 :         40 : regress_test_fundamental_object_get_type (void)
    3603                 :            : {
    3604                 :            :   static GType _test_fundamental_object_type = 0;
    3605                 :            : 
    3606         [ +  + ]:         40 :   if (G_UNLIKELY (_test_fundamental_object_type == 0)) {
    3607                 :            :     static const GTypeValueTable value_table = {
    3608                 :            :       regress_test_value_fundamental_object_init,
    3609                 :            :       regress_test_value_fundamental_object_free,
    3610                 :            :       regress_test_value_fundamental_object_copy,
    3611                 :            :       regress_test_value_fundamental_object_peek_pointer,
    3612                 :            :       (char *) "p",
    3613                 :            :       regress_test_value_fundamental_object_collect,
    3614                 :            :       (char *) "p",
    3615                 :            :       regress_test_value_fundamental_object_lcopy
    3616                 :            :     };
    3617                 :            :     static const GTypeInfo fundamental_object_info = {
    3618                 :            :       sizeof (RegressTestFundamentalObjectClass),
    3619                 :            :       NULL, NULL,
    3620                 :            :       regress_test_fundamental_object_class_init,
    3621                 :            :       NULL,
    3622                 :            :       NULL,
    3623                 :            :       sizeof (RegressTestFundamentalObject),
    3624                 :            :       0,
    3625                 :            :       (GInstanceInitFunc) regress_test_fundamental_object_init,
    3626                 :            :       &value_table
    3627                 :            :     };
    3628                 :            :     static const GTypeFundamentalInfo fundamental_object_fundamental_info = {
    3629                 :            :       (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE |
    3630                 :            :           G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE)
    3631                 :            :     };
    3632                 :            : 
    3633                 :          4 :     _test_fundamental_object_type = g_type_fundamental_next ();
    3634                 :          4 :     g_type_register_fundamental (_test_fundamental_object_type, "RegressTestFundamentalObject",
    3635                 :            :         &fundamental_object_info, &fundamental_object_fundamental_info, G_TYPE_FLAG_ABSTRACT);
    3636                 :            : 
    3637                 :            :   }
    3638                 :            : 
    3639                 :         40 :   return _test_fundamental_object_type;
    3640                 :            : }
    3641                 :            : 
    3642                 :            : /**
    3643                 :            :  * regress_test_value_set_fundamental_object: (skip)
    3644                 :            :  * @value:
    3645                 :            :  * @fundamental_object:
    3646                 :            :  */
    3647                 :            : void
    3648                 :          4 : regress_test_value_set_fundamental_object (GValue * value, RegressTestFundamentalObject * fundamental_object)
    3649                 :            : {
    3650                 :            :   gpointer *pointer_p;
    3651                 :            : 
    3652                 :          4 :   g_return_if_fail (REGRESS_TEST_VALUE_HOLDS_FUNDAMENTAL_OBJECT (value));
    3653                 :          4 :   g_return_if_fail (fundamental_object == NULL || REGRESS_TEST_IS_FUNDAMENTAL_OBJECT (fundamental_object));
    3654                 :            : 
    3655                 :          4 :   pointer_p = &value->data[0].v_pointer;
    3656                 :            : 
    3657                 :          4 :   regress_test_fundamental_object_replace ((RegressTestFundamentalObject **) pointer_p, fundamental_object);
    3658                 :            : }
    3659                 :            : 
    3660                 :            : /**
    3661                 :            :  * regress_test_value_get_fundamental_object: (skip)
    3662                 :            :  * @value:
    3663                 :            :  */
    3664                 :            : RegressTestFundamentalObject *
    3665                 :          6 : regress_test_value_get_fundamental_object (const GValue * value)
    3666                 :            : {
    3667                 :          6 :   g_return_val_if_fail (REGRESS_TEST_VALUE_HOLDS_FUNDAMENTAL_OBJECT (value), NULL);
    3668                 :            : 
    3669                 :          6 :   return value->data[0].v_pointer;
    3670                 :            : }
    3671                 :            : 
    3672                 :            : static RegressTestFundamentalObjectClass *parent_class = NULL;
    3673                 :            : 
    3674   [ +  +  +  -  :         35 : G_DEFINE_TYPE (RegressTestFundamentalSubObject, regress_test_fundamental_sub_object, REGRESS_TEST_TYPE_FUNDAMENTAL_OBJECT);
                   +  + ]
    3675                 :            : 
    3676                 :            : static RegressTestFundamentalSubObject *
    3677                 :          0 : _regress_test_fundamental_sub_object_copy (RegressTestFundamentalSubObject * fundamental_sub_object)
    3678                 :            : {
    3679                 :            :   RegressTestFundamentalSubObject *copy;
    3680                 :            : 
    3681                 :          0 :   copy = regress_test_fundamental_sub_object_new(NULL);
    3682                 :          0 :   copy->data = g_strdup(fundamental_sub_object->data);
    3683                 :          0 :   return copy;
    3684                 :            : }
    3685                 :            : 
    3686                 :            : static void
    3687                 :          9 : regress_test_fundamental_sub_object_finalize (RegressTestFundamentalSubObject * fundamental_sub_object)
    3688                 :            : {
    3689                 :          9 :   g_return_if_fail (fundamental_sub_object != NULL);
    3690                 :            : 
    3691                 :          9 :   g_free(fundamental_sub_object->data);
    3692                 :          9 :   regress_test_fundamental_object_finalize (REGRESS_TEST_FUNDAMENTAL_OBJECT (fundamental_sub_object));
    3693                 :            : }
    3694                 :            : 
    3695                 :            : static void
    3696                 :          3 : regress_test_fundamental_sub_object_class_init (RegressTestFundamentalSubObjectClass * klass)
    3697                 :            : {
    3698                 :          3 :   parent_class = g_type_class_peek_parent (klass);
    3699                 :            : 
    3700                 :          3 :   klass->fundamental_object_class.copy = (RegressTestFundamentalObjectCopyFunction) _regress_test_fundamental_sub_object_copy;
    3701                 :          3 :   klass->fundamental_object_class.finalize =
    3702                 :            :       (RegressTestFundamentalObjectFinalizeFunction) regress_test_fundamental_sub_object_finalize;
    3703                 :          3 : }
    3704                 :            : 
    3705                 :            : static void
    3706                 :         10 : regress_test_fundamental_sub_object_init(RegressTestFundamentalSubObject *self G_GNUC_UNUSED)
    3707                 :            : {
    3708                 :            : 
    3709                 :         10 : }
    3710                 :            : 
    3711                 :            : /**
    3712                 :            :  * regress_test_fundamental_sub_object_new:
    3713                 :            :  */
    3714                 :            : RegressTestFundamentalSubObject *
    3715                 :         10 : regress_test_fundamental_sub_object_new (const char * data)
    3716                 :            : {
    3717                 :            :   RegressTestFundamentalSubObject *object;
    3718                 :            : 
    3719                 :         10 :   object = (RegressTestFundamentalSubObject *) g_type_create_instance (regress_test_fundamental_sub_object_get_type());
    3720                 :         10 :   object->data = g_strdup(data);
    3721                 :         10 :   return object;
    3722                 :            : }
    3723                 :            : 
    3724                 :            : /**/
    3725                 :            : 
    3726                 :            : #define regress_test_fundamental_hidden_sub_object_get_type \
    3727                 :            :   _regress_test_fundamental_hidden_sub_object_get_type
    3728                 :            : 
    3729                 :            : GType regress_test_fundamental_hidden_sub_object_get_type (void);
    3730                 :            : 
    3731                 :            : typedef struct _RegressTestFundamentalHiddenSubObject RegressTestFundamentalHiddenSubObject;
    3732                 :            : typedef struct _GObjectClass                   RegressTestFundamentalHiddenSubObjectClass;
    3733                 :            : struct _RegressTestFundamentalHiddenSubObject {
    3734                 :            :   RegressTestFundamentalObject parent_instance;
    3735                 :            : };
    3736                 :            : 
    3737   [ +  +  +  -  :          3 : G_DEFINE_TYPE (RegressTestFundamentalHiddenSubObject,
                   +  - ]
    3738                 :            :                regress_test_fundamental_hidden_sub_object,
    3739                 :            :                REGRESS_TEST_TYPE_FUNDAMENTAL_OBJECT);
    3740                 :            : 
    3741                 :            : static void
    3742                 :          1 : regress_test_fundamental_hidden_sub_object_init (RegressTestFundamentalHiddenSubObject *self G_GNUC_UNUSED)
    3743                 :            : {
    3744                 :          1 : }
    3745                 :            : 
    3746                 :            : static void
    3747                 :          1 : regress_test_fundamental_hidden_sub_object_class_init (RegressTestFundamentalHiddenSubObjectClass *klass G_GNUC_UNUSED)
    3748                 :            : {
    3749                 :          1 : }
    3750                 :            : 
    3751                 :            : /**
    3752                 :            :  * regress_test_create_fundamental_hidden_class_instance:
    3753                 :            :  *
    3754                 :            :  * Return value: (transfer full):
    3755                 :            :  */
    3756                 :            : RegressTestFundamentalObject *
    3757                 :          1 : regress_test_create_fundamental_hidden_class_instance (void)
    3758                 :            : {
    3759                 :          1 :   return (RegressTestFundamentalObject *) g_type_create_instance (_regress_test_fundamental_hidden_sub_object_get_type());
    3760                 :            : }
    3761                 :            : 
    3762                 :            : 
    3763                 :            : /**
    3764                 :            :  * RegressTestFundamentalObjectNoGetSetFunc: (ref-func regress_test_fundamental_object_ref) (unref-func regress_test_fundamental_object_unref)
    3765                 :            :  *
    3766                 :            :  * Just like a #RegressTestFundamentalObject but without gvalue setter and getter
    3767                 :            :  */
    3768                 :            : 
    3769                 :            : static void
    3770                 :          6 : regress_test_fundamental_object_no_get_set_func_finalize (RegressTestFundamentalObjectNoGetSetFunc *self)
    3771                 :            : {
    3772         [ +  - ]:          6 :   g_clear_pointer(&self->data, g_free);
    3773                 :          6 : }
    3774                 :            : 
    3775                 :            : static RegressTestFundamentalObjectNoGetSetFunc *
    3776                 :          0 : regress_test_fundamental_object_no_get_set_func_copy (RegressTestFundamentalObjectNoGetSetFunc *self)
    3777                 :            : {
    3778                 :          0 :   return regress_test_fundamental_object_no_get_set_func_new (self->data);
    3779                 :            : }
    3780                 :            : 
    3781                 :            : static void
    3782                 :          1 : regress_test_fundamental_object_no_get_set_func_class_init (gpointer g_class,
    3783                 :            :                                                             gpointer class_data G_GNUC_UNUSED)
    3784                 :            : {
    3785                 :          1 :   RegressTestFundamentalObjectClass *mo_class = (RegressTestFundamentalObjectClass*) (g_class);
    3786                 :            : 
    3787                 :          1 :   mo_class->copy = (RegressTestFundamentalObjectCopyFunction) regress_test_fundamental_object_no_get_set_func_copy;
    3788                 :          1 :   mo_class->finalize = (RegressTestFundamentalObjectFinalizeFunction) regress_test_fundamental_object_no_get_set_func_finalize;
    3789                 :          1 : }
    3790                 :            : 
    3791                 :            : static void
    3792                 :          6 : regress_test_fundamental_object_no_get_set_func_init (GTypeInstance *instance,
    3793                 :            :                                                       gpointer       klass G_GNUC_UNUSED)
    3794                 :            : {
    3795                 :          6 :   RegressTestFundamentalObject *object = (RegressTestFundamentalObject*) (instance);
    3796                 :          6 :   object->refcount = 1;
    3797                 :          6 : }
    3798                 :            : 
    3799                 :            : GType
    3800                 :         21 : regress_test_fundamental_object_no_get_set_func_get_type (void)
    3801                 :            : {
    3802                 :            :   static GType _test_fundamental_object_type = 0;
    3803                 :            : 
    3804         [ +  + ]:         21 :   if (G_UNLIKELY (_test_fundamental_object_type == 0)) {
    3805                 :            :     static const GTypeValueTable value_table = {
    3806                 :            :       regress_test_value_fundamental_object_init,
    3807                 :            :       regress_test_value_fundamental_object_free,
    3808                 :            :       regress_test_value_fundamental_object_copy,
    3809                 :            :       regress_test_value_fundamental_object_peek_pointer,
    3810                 :            :       (char *) "p",
    3811                 :            :       regress_test_value_fundamental_object_collect,
    3812                 :            :       (char *) "p",
    3813                 :            :       regress_test_value_fundamental_object_lcopy
    3814                 :            :     };
    3815                 :            :     static const GTypeInfo fundamental_object_info = {
    3816                 :            :       sizeof (RegressTestFundamentalObjectNoGetSetFuncClass),
    3817                 :            :       NULL, NULL,
    3818                 :            :       regress_test_fundamental_object_no_get_set_func_class_init,
    3819                 :            :       NULL,
    3820                 :            :       NULL,
    3821                 :            :       sizeof (RegressTestFundamentalObjectNoGetSetFunc),
    3822                 :            :       0,
    3823                 :            :       (GInstanceInitFunc) regress_test_fundamental_object_no_get_set_func_init,
    3824                 :            :       &value_table
    3825                 :            :     };
    3826                 :            :     static const GTypeFundamentalInfo fundamental_object_fundamental_info = {
    3827                 :            :       (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE |
    3828                 :            :           G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE)
    3829                 :            :     };
    3830                 :            : 
    3831                 :          2 :     _test_fundamental_object_type = g_type_fundamental_next ();
    3832                 :          2 :     g_type_register_fundamental (_test_fundamental_object_type, "RegressTestFundamentalObjectNoGetSetFunc",
    3833                 :            :         &fundamental_object_info, &fundamental_object_fundamental_info, 0);
    3834                 :            :   }
    3835                 :            : 
    3836                 :         21 :   return _test_fundamental_object_type;
    3837                 :            : }
    3838                 :            : 
    3839                 :            : /**
    3840                 :            :  * regress_test_fundamental_object_no_get_set_func_new:
    3841                 :            :  *
    3842                 :            :  * Return value: (transfer full):
    3843                 :            :  */
    3844                 :            : RegressTestFundamentalObjectNoGetSetFunc *
    3845                 :          4 : regress_test_fundamental_object_no_get_set_func_new (const char *data)
    3846                 :            : {
    3847                 :            :   RegressTestFundamentalObjectNoGetSetFunc *object;
    3848                 :            : 
    3849                 :          4 :   object = (RegressTestFundamentalObjectNoGetSetFunc *) g_type_create_instance (regress_test_fundamental_object_no_get_set_func_get_type ());
    3850                 :          4 :   object->data = g_strdup (data);
    3851                 :            : 
    3852                 :          4 :   return object;
    3853                 :            : }
    3854                 :            : 
    3855                 :            : const char *
    3856                 :          3 : regress_test_fundamental_object_no_get_set_func_get_data (RegressTestFundamentalObjectNoGetSetFunc *fundamental)
    3857                 :            : {
    3858                 :          3 :   g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (fundamental, regress_test_fundamental_object_no_get_set_func_get_type ()), NULL);
    3859                 :            : 
    3860                 :          3 :   return fundamental->data;
    3861                 :            : }
    3862                 :            : 
    3863   [ +  +  +  -  :         10 : G_DEFINE_TYPE (RegressTestFundamentalSubObjectNoGetSetFunc, regress_test_fundamental_sub_object_no_get_set_func, regress_test_fundamental_object_no_get_set_func_get_type ());
                   +  + ]
    3864                 :            : 
    3865                 :            : static void
    3866                 :          1 : regress_test_fundamental_sub_object_no_get_set_func_class_init (RegressTestFundamentalSubObjectNoGetSetFuncClass *klass G_GNUC_UNUSED)
    3867                 :            : {
    3868                 :          1 : }
    3869                 :            : 
    3870                 :            : static void
    3871                 :          2 : regress_test_fundamental_sub_object_no_get_set_func_init (RegressTestFundamentalSubObjectNoGetSetFunc *self G_GNUC_UNUSED)
    3872                 :            : {
    3873                 :          2 : }
    3874                 :            : 
    3875                 :            : /**
    3876                 :            :  * regress_test_fundamental_sub_object_no_get_set_func_new:
    3877                 :            :  *
    3878                 :            :  * Return value: (transfer full):
    3879                 :            :  */
    3880                 :            : RegressTestFundamentalSubObjectNoGetSetFunc *
    3881                 :          2 : regress_test_fundamental_sub_object_no_get_set_func_new (const char *data)
    3882                 :            : {
    3883                 :            :   RegressTestFundamentalSubObjectNoGetSetFunc *object;
    3884                 :            :   RegressTestFundamentalObjectNoGetSetFunc *parent_object;
    3885                 :            : 
    3886                 :          2 :   object = (RegressTestFundamentalSubObjectNoGetSetFunc *) g_type_create_instance (regress_test_fundamental_sub_object_no_get_set_func_get_type ());
    3887                 :          2 :   parent_object = (RegressTestFundamentalObjectNoGetSetFunc *) object;
    3888                 :          2 :   parent_object->data = g_strdup (data);
    3889                 :            : 
    3890                 :          2 :   return object;
    3891                 :            : }
    3892                 :            : 
    3893                 :            : static void
    3894                 :          1 : fundamental_object_no_get_set_func_transform_to_compatible_with_fundamental_sub_object (const GValue *src_value,
    3895                 :            :                                                                                         GValue       *dest_value)
    3896                 :            : {
    3897                 :            :   RegressTestFundamentalObjectNoGetSetFunc *src_object;
    3898                 :            :   RegressTestFundamentalSubObject *dest_object;
    3899                 :            : 
    3900                 :          1 :   g_return_if_fail (G_VALUE_TYPE (src_value) == regress_test_fundamental_object_no_get_set_func_get_type ());
    3901                 :          1 :   g_return_if_fail (G_VALUE_TYPE (dest_value) == regress_test_fundamental_sub_object_get_type ());
    3902                 :            : 
    3903                 :          1 :   src_object = g_value_peek_pointer (src_value);
    3904                 :          1 :   dest_object = regress_test_fundamental_sub_object_new (src_object->data);
    3905                 :            : 
    3906                 :          1 :   g_value_set_instance (dest_value, dest_object);
    3907                 :            : }
    3908                 :            : 
    3909                 :            : void
    3910                 :          1 : regress_test_fundamental_object_no_get_set_func_make_compatible_with_fundamental_sub_object (void)
    3911                 :            : {
    3912                 :          1 :   g_value_register_transform_func (
    3913                 :            :     regress_test_fundamental_object_no_get_set_func_get_type (),
    3914                 :            :     regress_test_fundamental_sub_object_get_type (),
    3915                 :            :     fundamental_object_no_get_set_func_transform_to_compatible_with_fundamental_sub_object);
    3916                 :          1 : }
    3917                 :            : 
    3918                 :            : /**
    3919                 :            :  * regress_test_callback:
    3920                 :            :  * @callback: (scope call) (allow-none):
    3921                 :            :  *
    3922                 :            :  **/
    3923                 :            : int
    3924                 :          3 : regress_test_callback (RegressTestCallback callback)
    3925                 :            : {
    3926         [ +  + ]:          3 :     if (callback != NULL)
    3927                 :          2 :         return callback();
    3928                 :          1 :     return 0;
    3929                 :            : }
    3930                 :            : 
    3931                 :            : /**
    3932                 :            :  * regress_test_multi_callback:
    3933                 :            :  * @callback: (scope call) (allow-none):
    3934                 :            :  *
    3935                 :            :  **/
    3936                 :            : int
    3937                 :          2 : regress_test_multi_callback (RegressTestCallback callback)
    3938                 :            : {
    3939                 :          2 :     int sum = 0;
    3940         [ +  + ]:          2 :     if (callback != NULL) {
    3941                 :          1 :         sum += callback();
    3942                 :          1 :         sum += callback();
    3943                 :            :     }
    3944                 :            : 
    3945                 :          2 :     return sum;
    3946                 :            : }
    3947                 :            : 
    3948                 :            : /**
    3949                 :            :  * regress_test_array_callback:
    3950                 :            :  * @callback: (scope call):
    3951                 :            :  *
    3952                 :            :  **/
    3953                 :          1 : int regress_test_array_callback (RegressTestCallbackArray callback)
    3954                 :            : {
    3955                 :            :   static const char *strings[] = { "one", "two", "three" };
    3956                 :            :   static int ints[] = { -1, 0, 1, 2 };
    3957                 :          1 :   int sum = 0;
    3958                 :            : 
    3959                 :          1 :   sum += callback(ints, 4, strings, 3);
    3960                 :          1 :   sum += callback(ints, 4, strings, 3);
    3961                 :            : 
    3962                 :          1 :   return sum;
    3963                 :            : }
    3964                 :            : 
    3965                 :            : /**
    3966                 :            :  * regress_test_array_inout_callback:
    3967                 :            :  * @callback: (scope call):
    3968                 :            :  *
    3969                 :            :  */
    3970                 :            : int
    3971                 :          0 : regress_test_array_inout_callback (RegressTestCallbackArrayInOut callback)
    3972                 :            : {
    3973                 :            :   int *ints;
    3974                 :            :   int length;
    3975                 :            : 
    3976                 :          0 :   ints = g_new (int, 5);
    3977         [ #  # ]:          0 :   for (length = 0; length < 5; ++length)
    3978                 :          0 :     ints[length] = length - 2;
    3979                 :            : 
    3980                 :          0 :   callback (&ints, &length);
    3981                 :            : 
    3982                 :          0 :   g_assert_cmpint (length, ==, 4);
    3983         [ #  # ]:          0 :   for (length = 0; length < 4; ++length)
    3984                 :          0 :     g_assert_cmpint (ints[length], ==, length - 1);
    3985                 :            : 
    3986                 :          0 :   callback (&ints, &length);
    3987                 :            : 
    3988                 :          0 :   g_assert_cmpint (length, ==, 3);
    3989         [ #  # ]:          0 :   for (length = 0; length < 3; ++length)
    3990                 :          0 :     g_assert_cmpint (ints[length], ==, length);
    3991                 :            : 
    3992                 :          0 :   g_free (ints);
    3993                 :          0 :   return length;
    3994                 :            : }
    3995                 :            : 
    3996                 :            : /**
    3997                 :            :  * regress_test_simple_callback:
    3998                 :            :  * @callback: (scope call) (allow-none):
    3999                 :            :  *
    4000                 :            :  **/
    4001                 :            : void
    4002                 :          2 : regress_test_simple_callback (RegressTestSimpleCallback callback)
    4003                 :            : {
    4004         [ +  + ]:          2 :     if (callback != NULL)
    4005                 :          1 :         callback();
    4006                 :            : 
    4007                 :          2 :     return;
    4008                 :            : }
    4009                 :            : 
    4010                 :            : /**
    4011                 :            :  * regress_test_noptr_callback:
    4012                 :            :  * @callback: (scope call) (allow-none):
    4013                 :            :  *
    4014                 :            :  **/
    4015                 :            : void
    4016                 :          2 : regress_test_noptr_callback (RegressTestNoPtrCallback callback)
    4017                 :            : {
    4018         [ +  + ]:          2 :     if (callback != NULL)
    4019                 :          1 :         callback();
    4020                 :            : 
    4021                 :          2 :     return;
    4022                 :            : }
    4023                 :            : 
    4024                 :            : /**
    4025                 :            :  * regress_test_callback_user_data:
    4026                 :            :  * @callback: (scope call):
    4027                 :            :  * @user_data: (not nullable):
    4028                 :            :  *
    4029                 :            :  * Call - callback parameter persists for the duration of the method
    4030                 :            :  * call and can be released on return.
    4031                 :            :  **/
    4032                 :            : int
    4033                 :          1 : regress_test_callback_user_data (RegressTestCallbackUserData callback,
    4034                 :            :                          gpointer user_data)
    4035                 :            : {
    4036                 :          1 :   return callback(user_data);
    4037                 :            : }
    4038                 :            : 
    4039                 :            : /**
    4040                 :            :  * regress_test_callback_return_full:
    4041                 :            :  * @callback: (scope call):
    4042                 :            :  *
    4043                 :            :  **/
    4044                 :            : void
    4045                 :          1 : regress_test_callback_return_full (RegressTestCallbackReturnFull callback)
    4046                 :            : {
    4047                 :            :   RegressTestObj *obj;
    4048                 :            : 
    4049                 :          1 :   obj = callback ();
    4050                 :          1 :   g_object_unref (obj);
    4051                 :          1 : }
    4052                 :            : 
    4053                 :            : static GSList *notified_callbacks = NULL;
    4054                 :            : 
    4055                 :            : /**
    4056                 :            :  * regress_test_callback_destroy_notify:
    4057                 :            :  * @callback: (scope notified):
    4058                 :            :  *
    4059                 :            :  * Notified - callback persists until a DestroyNotify delegate
    4060                 :            :  * is invoked.
    4061                 :            :  **/
    4062                 :            : int
    4063                 :          2 : regress_test_callback_destroy_notify (RegressTestCallbackUserData callback,
    4064                 :            :                               gpointer user_data,
    4065                 :            :                               GDestroyNotify notify)
    4066                 :            : {
    4067                 :            :   int retval;
    4068                 :            :   CallbackInfo *info;
    4069                 :            : 
    4070                 :          2 :   retval = callback(user_data);
    4071                 :            : 
    4072                 :          2 :   info = g_slice_new(CallbackInfo);
    4073                 :          2 :   info->callback = callback;
    4074                 :          2 :   info->notify = notify;
    4075                 :          2 :   info->user_data = user_data;
    4076                 :            : 
    4077                 :          2 :   notified_callbacks = g_slist_prepend(notified_callbacks, info);
    4078                 :            : 
    4079                 :          2 :   return retval;
    4080                 :            : }
    4081                 :            : 
    4082                 :            : /**
    4083                 :            :  * regress_test_callback_destroy_notify_no_user_data:
    4084                 :            :  * @callback: (scope notified):
    4085                 :            :  *
    4086                 :            :  * Adds a scope notified callback with no user data. This can invoke an error
    4087                 :            :  * condition in bindings which needs to be tested.
    4088                 :            :  **/
    4089                 :            : int
    4090                 :          0 : regress_test_callback_destroy_notify_no_user_data (RegressTestCallbackUserData callback,
    4091                 :            :                               GDestroyNotify notify)
    4092                 :            : {
    4093                 :          0 :   return regress_test_callback_destroy_notify(callback, NULL, notify);
    4094                 :            : }
    4095                 :            : 
    4096                 :            : /**
    4097                 :            :  * regress_test_callback_thaw_notifications:
    4098                 :            :  *
    4099                 :            :  * Invokes all callbacks installed by #test_callback_destroy_notify(),
    4100                 :            :  * adding up their return values, and removes them, invoking the
    4101                 :            :  * corresponding destroy notfications.
    4102                 :            :  *
    4103                 :            :  * Return value: Sum of the return values of the invoked callbacks.
    4104                 :            :  */
    4105                 :            : int
    4106                 :          2 : regress_test_callback_thaw_notifications (void)
    4107                 :            : {
    4108                 :          2 :   int retval = 0;
    4109                 :            :   GSList *node;
    4110                 :            : 
    4111         [ +  + ]:          5 :   for (node = notified_callbacks; node != NULL; node = node->next)
    4112                 :            :     {
    4113                 :          3 :       CallbackInfo *info = node->data;
    4114                 :          3 :       retval += info->callback (info->user_data);
    4115         [ +  - ]:          3 :       if (info->notify)
    4116                 :          3 :         info->notify (info->user_data);
    4117                 :          3 :       g_slice_free (CallbackInfo, info);
    4118                 :            :     }
    4119                 :            : 
    4120                 :          2 :   g_slist_free (notified_callbacks);
    4121                 :          2 :   notified_callbacks = NULL;
    4122                 :            : 
    4123                 :          2 :   return retval;
    4124                 :            : }
    4125                 :            : 
    4126                 :            : static GSList *async_callbacks = NULL;
    4127                 :            : 
    4128                 :            : /**
    4129                 :            :  * regress_test_callback_async:
    4130                 :            :  * @callback: (scope async):
    4131                 :            :  *
    4132                 :            :  **/
    4133                 :            : void
    4134                 :          1 : regress_test_callback_async (RegressTestCallbackUserData callback,
    4135                 :            :                      gpointer user_data)
    4136                 :            : {
    4137                 :            :   CallbackInfo *info;
    4138                 :            : 
    4139                 :          1 :   info = g_slice_new(CallbackInfo);
    4140                 :          1 :   info->callback = callback;
    4141                 :          1 :   info->user_data = user_data;
    4142                 :            : 
    4143                 :          1 :   async_callbacks = g_slist_prepend(async_callbacks, info);
    4144                 :          1 : }
    4145                 :            : 
    4146                 :            : /**
    4147                 :            :  * regress_test_callback_thaw_async:
    4148                 :            :  */
    4149                 :            : int
    4150                 :          1 : regress_test_callback_thaw_async (void)
    4151                 :            : {
    4152                 :          1 :   int retval = 0;
    4153                 :            :   GSList *node;
    4154                 :            : 
    4155         [ +  + ]:          2 :   for (node = async_callbacks; node != NULL; node = node->next)
    4156                 :            :     {
    4157                 :          1 :       CallbackInfo *info = node->data;
    4158                 :          1 :       retval = info->callback (info->user_data);
    4159                 :          1 :       g_slice_free (CallbackInfo, info);
    4160                 :            :     }
    4161                 :            : 
    4162                 :          1 :   g_slist_free (async_callbacks);
    4163                 :          1 :   async_callbacks = NULL;
    4164                 :          1 :   return retval;
    4165                 :            : }
    4166                 :            : 
    4167                 :            : void
    4168                 :          1 : regress_test_async_ready_callback (GAsyncReadyCallback callback)
    4169                 :            : {
    4170                 :            :   G_GNUC_BEGIN_IGNORE_DEPRECATIONS
    4171                 :          1 :   GSimpleAsyncResult *result = g_simple_async_result_new (NULL, callback, NULL,
    4172                 :            :     regress_test_async_ready_callback);
    4173                 :          1 :   g_simple_async_result_complete_in_idle (result);
    4174                 :          1 :   g_object_unref (result);
    4175                 :            :   G_GNUC_END_IGNORE_DEPRECATIONS
    4176                 :          1 : }
    4177                 :            : 
    4178                 :            : /**
    4179                 :            :  * regress_test_obj_instance_method_callback:
    4180                 :            :  * @callback: (scope call) (allow-none):
    4181                 :            :  *
    4182                 :            :  **/
    4183                 :            : void
    4184                 :          1 : regress_test_obj_instance_method_callback (RegressTestObj     *self G_GNUC_UNUSED,
    4185                 :            :                                            RegressTestCallback callback)
    4186                 :            : {
    4187         [ +  - ]:          1 :     if (callback != NULL)
    4188                 :          1 :         callback();
    4189                 :          1 : }
    4190                 :            : 
    4191                 :            : /**
    4192                 :            :  * regress_test_obj_static_method_callback:
    4193                 :            :  * @callback: (scope call) (allow-none):
    4194                 :            :  *
    4195                 :            :  **/
    4196                 :            : void
    4197                 :          1 : regress_test_obj_static_method_callback (RegressTestCallback callback)
    4198                 :            : {
    4199         [ +  - ]:          1 :     if (callback != NULL)
    4200                 :          1 :         callback();
    4201                 :          1 : }
    4202                 :            : 
    4203                 :            : /**
    4204                 :            :  * regress_test_obj_new_callback:
    4205                 :            :  * @callback: (scope notified):
    4206                 :            :  **/
    4207                 :            : RegressTestObj *
    4208                 :          1 : regress_test_obj_new_callback (RegressTestCallbackUserData callback, gpointer user_data,
    4209                 :            :                        GDestroyNotify notify)
    4210                 :            : {
    4211                 :            :   CallbackInfo *info;
    4212                 :            : 
    4213                 :          1 :   callback(user_data);
    4214                 :            : 
    4215                 :          1 :   info = g_slice_new(CallbackInfo);
    4216                 :          1 :   info->callback = callback;
    4217                 :          1 :   info->notify = notify;
    4218                 :          1 :   info->user_data = user_data;
    4219                 :            : 
    4220                 :          1 :   notified_callbacks = g_slist_prepend(notified_callbacks, info);
    4221                 :            : 
    4222                 :          1 :   return g_object_new (REGRESS_TEST_TYPE_OBJ, NULL);
    4223                 :            : }
    4224                 :            : 
    4225                 :            : /**
    4226                 :            :  * regress_test_hash_table_callback:
    4227                 :            :  * @data: (element-type utf8 gint): GHashTable that gets passed to callback
    4228                 :            :  * @callback: (scope call):
    4229                 :            :  **/
    4230                 :            : void
    4231                 :          1 : regress_test_hash_table_callback (GHashTable *data, RegressTestCallbackHashtable callback)
    4232                 :            : {
    4233                 :          1 :   callback (data);
    4234                 :          1 : }
    4235                 :            : 
    4236                 :            : /**
    4237                 :            :  * regress_test_gerror_callback:
    4238                 :            :  * @callback: (scope call):
    4239                 :            :  **/
    4240                 :            : void
    4241                 :          1 : regress_test_gerror_callback (RegressTestCallbackGError callback)
    4242                 :            : {
    4243                 :            :   GError *error;
    4244                 :            : 
    4245                 :          1 :   error = g_error_new_literal (G_IO_ERROR,
    4246                 :            :                                G_IO_ERROR_NOT_SUPPORTED,
    4247                 :            :                                "regression test error");
    4248                 :          1 :   callback (error);
    4249                 :          1 :   g_error_free (error);
    4250                 :          1 : }
    4251                 :            : 
    4252                 :            : /**
    4253                 :            :  * regress_test_null_gerror_callback:
    4254                 :            :  * @callback: (scope call):
    4255                 :            :  **/
    4256                 :            : void
    4257                 :          1 : regress_test_null_gerror_callback (RegressTestCallbackGError callback)
    4258                 :            : {
    4259                 :          1 :   callback (NULL);
    4260                 :          1 : }
    4261                 :            : 
    4262                 :            : /**
    4263                 :            :  * regress_test_owned_gerror_callback:
    4264                 :            :  * @callback: (scope call):
    4265                 :            :  **/
    4266                 :            : void
    4267                 :          1 : regress_test_owned_gerror_callback (RegressTestCallbackOwnedGError callback)
    4268                 :            : {
    4269                 :            :   GError *error;
    4270                 :            : 
    4271                 :          1 :   error = g_error_new_literal (G_IO_ERROR,
    4272                 :            :                                G_IO_ERROR_PERMISSION_DENIED,
    4273                 :            :                                "regression test owned error");
    4274                 :          1 :   callback (error);
    4275                 :          1 : }
    4276                 :            : 
    4277                 :            : /**
    4278                 :            :  * regress_test_skip_unannotated_callback: (skip)
    4279                 :            :  * @callback: No annotation here
    4280                 :            :  *
    4281                 :            :  * Should not emit a warning:
    4282                 :            :  * https://bugzilla.gnome.org/show_bug.cgi?id=685399
    4283                 :            :  */
    4284                 :            : void
    4285                 :          0 : regress_test_skip_unannotated_callback (RegressTestCallback callback G_GNUC_UNUSED)
    4286                 :            : {
    4287                 :          0 : }
    4288                 :            : 
    4289                 :            : /* interface */
    4290                 :            : 
    4291                 :            : typedef RegressTestInterfaceIface RegressTestInterfaceInterface;
    4292   [ +  +  +  -  :          8 : G_DEFINE_INTERFACE (RegressTestInterface, regress_test_interface, G_TYPE_OBJECT)
                   +  + ]
    4293                 :            : 
    4294                 :            : static void
    4295                 :          2 : regress_test_interface_default_init(RegressTestInterfaceIface *iface)
    4296                 :            : {
    4297                 :          2 :   const guint flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS;
    4298                 :            :   static gboolean initialized = FALSE;
    4299         [ -  + ]:          2 :   if (initialized)
    4300                 :          0 :     return;
    4301                 :            : 
    4302                 :            :   /**
    4303                 :            :    * RegressTestInterface::interface-signal:
    4304                 :            :    * @self: the object which emitted the signal
    4305                 :            :    * @ptr: (type int): the code must look up the signal with
    4306                 :            :    *   g_interface_info_find_signal() in order to get this to work.
    4307                 :            :    */
    4308                 :          2 :   g_signal_new ("interface-signal", REGRESS_TEST_TYPE_INTERFACE,
    4309                 :            :                 G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL,
    4310                 :            :                 G_TYPE_NONE, 1, G_TYPE_POINTER);
    4311                 :            : 
    4312                 :            :   /**
    4313                 :            :    * RegressTestInterface:number:
    4314                 :            :    */
    4315                 :          2 :   g_object_interface_install_property (iface,
    4316                 :            :                                        g_param_spec_int ("number", "Number", "Number",
    4317                 :            :                                                          0, 10, 0, flags));
    4318                 :            : 
    4319                 :          2 :   initialized = TRUE;
    4320                 :            : }
    4321                 :            : 
    4322                 :            : /**
    4323                 :            :  * regress_test_interface_emit_signal:
    4324                 :            :  * @self: the object to emit the signal
    4325                 :            :  */
    4326                 :            : void
    4327                 :          1 : regress_test_interface_emit_signal (RegressTestInterface *self)
    4328                 :            : {
    4329                 :          1 :   g_signal_emit_by_name (self, "interface-signal", NULL);
    4330                 :          1 : }
    4331                 :            : 
    4332                 :            : /* gobject with non-standard prefix */
    4333   [ +  +  +  -  :         18 : G_DEFINE_TYPE(RegressTestWi8021x, regress_test_wi_802_1x, G_TYPE_OBJECT);
                   +  + ]
    4334                 :            : 
    4335                 :            : enum
    4336                 :            : {
    4337                 :            :   PROP_TEST_WI_802_1X_TESTBOOL = 1
    4338                 :            : };
    4339                 :            : 
    4340                 :            : static void
    4341                 :          1 : regress_test_wi_802_1x_set_property (GObject      *object,
    4342                 :            :                              guint         property_id,
    4343                 :            :                              const GValue *value,
    4344                 :            :                              GParamSpec   *pspec)
    4345                 :            : {
    4346                 :          1 :   RegressTestWi8021x *self = REGRESS_TEST_WI_802_1X (object);
    4347                 :            : 
    4348         [ +  - ]:          1 :   switch (property_id)
    4349                 :            :     {
    4350                 :          1 :     case PROP_TEST_WI_802_1X_TESTBOOL:
    4351                 :          1 :       regress_test_wi_802_1x_set_testbool (self, g_value_get_boolean (value));
    4352                 :          1 :       break;
    4353                 :            : 
    4354                 :          0 :     default:
    4355                 :            :       /* We don't have any other property... */
    4356                 :          0 :       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
    4357                 :          0 :       break;
    4358                 :            :     }
    4359                 :          1 : }
    4360                 :            : 
    4361                 :            : static void
    4362                 :          2 : regress_test_wi_802_1x_get_property (GObject    *object,
    4363                 :            :                         guint       property_id,
    4364                 :            :                         GValue     *value,
    4365                 :            :                         GParamSpec *pspec)
    4366                 :            : {
    4367                 :          2 :   RegressTestWi8021x *self = REGRESS_TEST_WI_802_1X (object);
    4368                 :            : 
    4369         [ +  - ]:          2 :   switch (property_id)
    4370                 :            :     {
    4371                 :          2 :     case PROP_TEST_WI_802_1X_TESTBOOL:
    4372                 :          2 :       g_value_set_boolean (value, regress_test_wi_802_1x_get_testbool (self));
    4373                 :          2 :       break;
    4374                 :            : 
    4375                 :          0 :     default:
    4376                 :            :       /* We don't have any other property... */
    4377                 :          0 :       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
    4378                 :          0 :       break;
    4379                 :            :     }
    4380                 :          2 : }
    4381                 :            : 
    4382                 :            : static void
    4383                 :          5 : regress_test_wi_802_1x_dispose (GObject *gobject)
    4384                 :            : {
    4385                 :            :   /* Chain up to the parent class */
    4386                 :          5 :   G_OBJECT_CLASS (regress_test_wi_802_1x_parent_class)->dispose (gobject);
    4387                 :          5 : }
    4388                 :            : 
    4389                 :            : static void
    4390                 :          2 : regress_test_wi_802_1x_class_init (RegressTestWi8021xClass *klass)
    4391                 :            : {
    4392                 :          2 :   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
    4393                 :            :   GParamSpec *pspec;
    4394                 :            : 
    4395                 :          2 :   gobject_class->set_property = regress_test_wi_802_1x_set_property;
    4396                 :          2 :   gobject_class->get_property = regress_test_wi_802_1x_get_property;
    4397                 :          2 :   gobject_class->dispose = regress_test_wi_802_1x_dispose;
    4398                 :            : 
    4399                 :          2 :   pspec = g_param_spec_boolean ("testbool",
    4400                 :            :                                 "Nick for testbool",
    4401                 :            :                                 "Blurb for testbool",
    4402                 :            :                                 TRUE,
    4403                 :            :                                 G_PARAM_READWRITE);
    4404                 :          2 :   g_object_class_install_property (gobject_class,
    4405                 :            :                                    PROP_TEST_WI_802_1X_TESTBOOL,
    4406                 :            :                                    pspec);
    4407                 :          2 : }
    4408                 :            : 
    4409                 :            : static void
    4410                 :          5 : regress_test_wi_802_1x_init (RegressTestWi8021x *obj)
    4411                 :            : {
    4412                 :          5 :   obj->testbool = TRUE;
    4413                 :          5 : }
    4414                 :            : 
    4415                 :            : RegressTestWi8021x *
    4416                 :          1 : regress_test_wi_802_1x_new (void)
    4417                 :            : {
    4418                 :          1 :   return g_object_new (REGRESS_TEST_TYPE_WI_802_1X, NULL);
    4419                 :            : }
    4420                 :            : 
    4421                 :            : void
    4422                 :          2 : regress_test_wi_802_1x_set_testbool (RegressTestWi8021x *obj, gboolean val)
    4423                 :            : {
    4424                 :          2 :   obj->testbool = val;
    4425                 :          2 : }
    4426                 :            : 
    4427                 :            : gboolean
    4428                 :          4 : regress_test_wi_802_1x_get_testbool (RegressTestWi8021x *obj)
    4429                 :            : {
    4430                 :          4 :   return obj->testbool;
    4431                 :            : }
    4432                 :            : 
    4433                 :            : int
    4434                 :          1 : regress_test_wi_802_1x_static_method (int x)
    4435                 :            : {
    4436                 :          1 :   return 2*x;
    4437                 :            : }
    4438                 :            : 
    4439                 :            : /* floating gobject */
    4440   [ +  +  +  -  :          8 : G_DEFINE_TYPE(RegressTestFloating, regress_test_floating, G_TYPE_INITIALLY_UNOWNED);
                   +  + ]
    4441                 :            : 
    4442                 :            : static void
    4443                 :          2 : regress_test_floating_finalize(GObject *object)
    4444                 :            : {
    4445                 :          2 :   g_assert(!g_object_is_floating (object));
    4446                 :            : 
    4447                 :          2 :   G_OBJECT_CLASS(regress_test_floating_parent_class)->finalize(object);
    4448                 :          2 : }
    4449                 :            : 
    4450                 :            : static void
    4451                 :          2 : regress_test_floating_class_init (RegressTestFloatingClass *klass)
    4452                 :            : {
    4453                 :          2 :   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
    4454                 :          2 :   gobject_class->finalize = regress_test_floating_finalize;
    4455                 :          2 : }
    4456                 :            : 
    4457                 :            : static void
    4458                 :          2 : regress_test_floating_init (RegressTestFloating *self G_GNUC_UNUSED)
    4459                 :            : {
    4460                 :          2 : }
    4461                 :            : 
    4462                 :            : /**
    4463                 :            :  * regress_test_floating_new:
    4464                 :            :  *
    4465                 :            :  * Returns:: A new floating #RegressTestFloating
    4466                 :            :  */
    4467                 :            : RegressTestFloating *
    4468                 :          1 : regress_test_floating_new (void)
    4469                 :            : {
    4470                 :          1 :   return g_object_new (REGRESS_TEST_TYPE_FLOATING, NULL);
    4471                 :            : }
    4472                 :            : 
    4473                 :            : 
    4474                 :            : /**
    4475                 :            :  * regress_test_torture_signature_0:
    4476                 :            :  * @x:
    4477                 :            :  * @y: (out):
    4478                 :            :  * @z: (out):
    4479                 :            :  * @foo:
    4480                 :            :  * @q: (out):
    4481                 :            :  * @m:
    4482                 :            :  *
    4483                 :            :  */
    4484                 :            : void
    4485                 :          1 : regress_test_torture_signature_0 (int         x,
    4486                 :            :                           double     *y,
    4487                 :            :                           int        *z,
    4488                 :            :                           const char *foo,
    4489                 :            :                           int        *q,
    4490                 :            :                           guint       m)
    4491                 :            : {
    4492                 :          1 :   *y = x;
    4493                 :          1 :   *z = x * 2;
    4494                 :          1 :   *q = g_utf8_strlen (foo, -1) + m;
    4495                 :          1 : }
    4496                 :            : 
    4497                 :            : /**
    4498                 :            :  * regress_test_torture_signature_1:
    4499                 :            :  * @x:
    4500                 :            :  * @y: (out):
    4501                 :            :  * @z: (out):
    4502                 :            :  * @foo:
    4503                 :            :  * @q: (out):
    4504                 :            :  * @m:
    4505                 :            :  * @error: A #GError
    4506                 :            :  *
    4507                 :            :  * This function throws an error if m is odd.
    4508                 :            :  */
    4509                 :            : gboolean
    4510                 :          2 : regress_test_torture_signature_1 (int         x,
    4511                 :            :                           double     *y,
    4512                 :            :                           int        *z,
    4513                 :            :                           const char *foo,
    4514                 :            :                           int        *q,
    4515                 :            :                           guint       m,
    4516                 :            :                           GError    **error)
    4517                 :            : {
    4518                 :          2 :   *y = x;
    4519                 :          2 :   *z = x * 2;
    4520                 :          2 :   *q = g_utf8_strlen (foo, -1) + m;
    4521         [ +  + ]:          2 :   if (m % 2 == 0)
    4522                 :          1 :       return TRUE;
    4523                 :          1 :   g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "m is odd");
    4524                 :          1 :   return FALSE;
    4525                 :            : }
    4526                 :            : 
    4527                 :            : /**
    4528                 :            :  * regress_test_torture_signature_2:
    4529                 :            :  * @x:
    4530                 :            :  * @callback:
    4531                 :            :  * @user_data:
    4532                 :            :  * @notify:
    4533                 :            :  * @y: (out):
    4534                 :            :  * @z: (out):
    4535                 :            :  * @foo:
    4536                 :            :  * @q: (out):
    4537                 :            :  * @m:
    4538                 :            :  *
    4539                 :            :  */
    4540                 :            : void
    4541                 :          1 : regress_test_torture_signature_2 (int                   x,
    4542                 :            :                           RegressTestCallbackUserData  callback,
    4543                 :            :                           gpointer              user_data,
    4544                 :            :                           GDestroyNotify        notify,
    4545                 :            :                           double               *y,
    4546                 :            :                           int                  *z,
    4547                 :            :                           const char           *foo,
    4548                 :            :                           int                  *q,
    4549                 :            :                           guint                 m)
    4550                 :            : {
    4551                 :          1 :   *y = x;
    4552                 :          1 :   *z = x * 2;
    4553                 :          1 :   *q = g_utf8_strlen (foo, -1) + m;
    4554                 :          1 :   callback(user_data);
    4555                 :          1 :   notify (user_data);
    4556                 :          1 : }
    4557                 :            : 
    4558                 :            : /**
    4559                 :            :  * regress_test_date_in_gvalue:
    4560                 :            :  *
    4561                 :            :  * Returns: (transfer full):
    4562                 :            :  */
    4563                 :            : GValue *
    4564                 :          1 : regress_test_date_in_gvalue (void)
    4565                 :            : {
    4566                 :          1 :   GValue *value = g_new0 (GValue, 1);
    4567                 :          1 :   GDate *date = g_date_new_dmy (5, 12, 1984);
    4568                 :            : 
    4569                 :          1 :   g_value_init (value, G_TYPE_DATE);
    4570                 :          1 :   g_value_take_boxed (value, date);
    4571                 :            : 
    4572                 :          1 :   return value;
    4573                 :            : }
    4574                 :            : 
    4575                 :            : /**
    4576                 :            :  * regress_test_strv_in_gvalue:
    4577                 :            :  *
    4578                 :            :  * Returns: (transfer full):
    4579                 :            :  */
    4580                 :            : GValue *
    4581                 :          1 : regress_test_strv_in_gvalue (void)
    4582                 :            : {
    4583                 :          1 :   GValue *value = g_new0 (GValue, 1);
    4584                 :          1 :   const char *strv[] = { "one", "two", "three", NULL };
    4585                 :            : 
    4586                 :          1 :   g_value_init (value, G_TYPE_STRV);
    4587                 :          1 :   g_value_set_boxed (value, strv);
    4588                 :            : 
    4589                 :          1 :   return value;
    4590                 :            : }
    4591                 :            : 
    4592                 :            : /**
    4593                 :            :  * regress_test_null_strv_in_gvalue:
    4594                 :            :  *
    4595                 :            :  * Returns: (transfer full):
    4596                 :            :  */
    4597                 :            : GValue *
    4598                 :          1 : regress_test_null_strv_in_gvalue (void)
    4599                 :            : {
    4600                 :          1 :   GValue *value = g_new0 (GValue, 1);
    4601                 :          1 :   const char **strv = NULL;
    4602                 :            : 
    4603                 :          1 :   g_value_init (value, G_TYPE_STRV);
    4604                 :          1 :   g_value_set_boxed (value, strv);
    4605                 :            : 
    4606                 :          1 :   return value;
    4607                 :            : }
    4608                 :            : 
    4609                 :            : /**
    4610                 :            :  * regress_test_multiline_doc_comments:
    4611                 :            :  *
    4612                 :            :  * This is a function.
    4613                 :            :  *
    4614                 :            :  * It has multiple lines in the documentation.
    4615                 :            :  *
    4616                 :            :  * The sky is blue.
    4617                 :            :  *
    4618                 :            :  * You will give me your credit card number.
    4619                 :            :  */
    4620                 :            : void
    4621                 :          1 : regress_test_multiline_doc_comments (void)
    4622                 :            : {
    4623                 :          1 : }
    4624                 :            : 
    4625                 :            : /**
    4626                 :            :  * regress_test_nested_parameter:
    4627                 :            :  * @a: An integer
    4628                 :            :  *
    4629                 :            :  * <informaltable>
    4630                 :            :  *   <tgroup cols="3">
    4631                 :            :  *     <thead>
    4632                 :            :  *       <row>
    4633                 :            :  *         <entry>Syntax</entry>
    4634                 :            :  *         <entry>Explanation</entry>
    4635                 :            :  *         <entry>Examples</entry>
    4636                 :            :  *       </row>
    4637                 :            :  *     </thead>
    4638                 :            :  *     <tbody>
    4639                 :            :  *       <row>
    4640                 :            :  *         <entry>rgb(@r, @g, @b)</entry>
    4641                 :            :  *         <entry>An opaque color; @r, @g, @b can be either integers between
    4642                 :            :  *                0 and 255 or percentages</entry>
    4643                 :            :  *         <entry><literallayout>rgb(128, 10, 54)
    4644                 :            :  * rgb(20%, 30%, 0%)</literallayout></entry>
    4645                 :            :  *       </row>
    4646                 :            :  *       <row>
    4647                 :            :  *         <entry>rgba(@r, @g, @b, @a)</entry>
    4648                 :            :  *         <entry>A translucent color; @r, @g, @b are as in the previous row,
    4649                 :            :  *                @a is a floating point number between 0 and 1</entry>
    4650                 :            :  *         <entry><literallayout>rgba(255, 255, 0, 0.5)</literallayout></entry>
    4651                 :            :  *       </row>
    4652                 :            :  *    </tbody>
    4653                 :            :  *  </tgroup>
    4654                 :            :  * </informaltable>
    4655                 :            :  *
    4656                 :            :  * What we're testing here is that the scanner ignores the @a nested inside XML.
    4657                 :            :  */
    4658                 :            : void
    4659                 :          1 : regress_test_nested_parameter (int a G_GNUC_UNUSED)
    4660                 :            : {
    4661                 :          1 : }
    4662                 :            : 
    4663                 :            : /**
    4664                 :            :  * regress_introspectable_via_alias:
    4665                 :            :  *
    4666                 :            :  */
    4667                 :            : void
    4668                 :          0 : regress_introspectable_via_alias (RegressPtrArrayAlias *data G_GNUC_UNUSED)
    4669                 :            : {
    4670                 :          0 : }
    4671                 :            : 
    4672                 :            : /**
    4673                 :            :  * regress_not_introspectable_via_alias:
    4674                 :            :  *
    4675                 :            :  */
    4676                 :            : void
    4677                 :          0 : regress_not_introspectable_via_alias (RegressVaListAlias ok G_GNUC_UNUSED)
    4678                 :            : {
    4679                 :          0 : }
    4680                 :            : 
    4681                 :            : /**
    4682                 :            :  * regress_aliased_caller_alloc:
    4683                 :            :  * @boxed: (out):
    4684                 :            :  */
    4685                 :          1 : void regress_aliased_caller_alloc (RegressAliasedTestBoxed *boxed)
    4686                 :            : {
    4687                 :          1 :   boxed->priv = g_slice_new0 (RegressTestBoxedPrivate);
    4688                 :          1 :   boxed->priv->magic = 0xdeadbeef;
    4689                 :          1 : }
    4690                 :            : 
    4691                 :            : void
    4692                 :          1 : regress_test_struct_fixed_array_frob (RegressTestStructFixedArray *str)
    4693                 :            : {
    4694                 :            :   guint i;
    4695                 :          1 :   str->just_int = 7;
    4696                 :            : 
    4697         [ +  + ]:         11 :   for (i = 0; i < G_N_ELEMENTS(str->array); i++)
    4698                 :         10 :     str->array[i] = 42 + i;
    4699                 :          1 : }
    4700                 :            : 
    4701                 :            : /**
    4702                 :            :  * regress_has_parameter_named_attrs:
    4703                 :            :  * @foo: some int
    4704                 :            :  * @attributes: (type guint32) (array fixed-size=32): list of attributes
    4705                 :            :  *
    4706                 :            :  * This test case mirrors GnomeKeyringPasswordSchema from
    4707                 :            :  * libgnome-keyring.
    4708                 :            :  */
    4709                 :            : void
    4710                 :          1 : regress_has_parameter_named_attrs (int        foo G_GNUC_UNUSED,
    4711                 :            :                                    gpointer   attributes G_GNUC_UNUSED)
    4712                 :            : {
    4713                 :          1 : }
    4714                 :            : 
    4715                 :            : /**
    4716                 :            :  * regress_test_versioning:
    4717                 :            :  *
    4718                 :            :  * Since: 1.32.1: Actually, this function was introduced earlier
    4719                 :            :  *   than this, but it didn't do anything before this version.
    4720                 :            :  * Deprecated: 1.33.3: This function has been deprecated,
    4721                 :            :  *   because it sucks. Use foobar instead.
    4722                 :            :  * Stability: Unstable: Maybe someday we will find the time
    4723                 :            :  *   to stabilize this function. Who knows?
    4724                 :            :  */
    4725                 :            : void
    4726                 :          1 : regress_test_versioning (void)
    4727                 :            : {
    4728                 :          1 : }
    4729                 :            : 
    4730                 :            : void
    4731                 :          2 : regress_like_xkl_config_item_set_name (RegressLikeXklConfigItem *self,
    4732                 :            :                                        char const *name)
    4733                 :            : {
    4734                 :          2 :   strncpy (self->name, name, sizeof (self->name) - 1);
    4735                 :          2 :   self->name[sizeof(self->name)-1] = '\0';
    4736                 :          2 : }
    4737                 :            : 
    4738                 :            : /**
    4739                 :            :  * regress_get_variant:
    4740                 :            :  *
    4741                 :            :  * Returns: (transfer floating): A new variant
    4742                 :            :  */
    4743                 :            : GVariant *
    4744                 :          1 : regress_get_variant (void)
    4745                 :            : {
    4746                 :          1 :   return g_variant_new_int32 (42);
    4747                 :            : }
    4748                 :            : 
    4749                 :            : /**
    4750                 :            :  * regress_test_array_struct_out_none:
    4751                 :            :  * @arr: (out) (array length=len) (transfer none): An array
    4752                 :            :  * @len: (out): Length of @arr
    4753                 :            :  *
    4754                 :            :  * Test flat array output with transfer none.
    4755                 :            :  * 
    4756                 :            :  * Similar to:
    4757                 :            :  * - mm_modem_peek_ports() with structs
    4758                 :            :  * - gdk_query_visual_types() with enums
    4759                 :            :  * - gdk_event_get_axes() with doubles
    4760                 :            :  */
    4761                 :            : void
    4762                 :          1 : regress_test_array_struct_out_none (RegressTestStructA **arr, gsize *len)
    4763                 :            : {
    4764                 :            :   static RegressTestStructA array[3] = {
    4765                 :            :     {.some_int = 111},
    4766                 :            :     {.some_int = 222},
    4767                 :            :     {.some_int = 333},
    4768                 :            :   };
    4769                 :            : 
    4770                 :          1 :   *arr = array;
    4771                 :          1 :   *len = 3;
    4772                 :          1 : }
    4773                 :            : 
    4774                 :            : /**
    4775                 :            :  * regress_test_array_struct_out_container:
    4776                 :            :  * @arr: (out) (array length=len) (transfer container): An array
    4777                 :            :  * @len: (out): Length of @arr
    4778                 :            :  *
    4779                 :            :  * Test flat array output with transfer container.
    4780                 :            :  *
    4781                 :            :  * Similar to pango_layout_get_log_attrs().
    4782                 :            :  */
    4783                 :            : void
    4784                 :          1 : regress_test_array_struct_out_container (RegressTestStructA **arr, gsize *len)
    4785                 :            : {
    4786                 :            : 
    4787                 :          1 :   *arr = g_new0 (RegressTestStructA, 5);
    4788                 :          1 :   (*arr)[0].some_int = 11;
    4789                 :          1 :   (*arr)[1].some_int = 13;
    4790                 :          1 :   (*arr)[2].some_int = 17;
    4791                 :          1 :   (*arr)[3].some_int = 19;
    4792                 :          1 :   (*arr)[4].some_int = 23;
    4793                 :          1 :   *len = 5;
    4794                 :          1 : }
    4795                 :            : 
    4796                 :            : /**
    4797                 :            :  * regress_test_array_struct_out_full_fixed:
    4798                 :            :  * @arr: (out) (array fixed-size=4) (transfer full): An array
    4799                 :            :  *
    4800                 :            :  * Test flat fixed-size array output with transfer full.
    4801                 :            :  */
    4802                 :            : void
    4803                 :          1 : regress_test_array_struct_out_full_fixed (RegressTestStructA **arr)
    4804                 :            : {
    4805                 :          1 :   *arr = g_new0 (RegressTestStructA, 4);
    4806                 :          1 :   (*arr)[0].some_int = 2;
    4807                 :          1 :   (*arr)[1].some_int = 3;
    4808                 :          1 :   (*arr)[2].some_int = 5;
    4809                 :          1 :   (*arr)[3].some_int = 7;
    4810                 :          1 : }
    4811                 :            : 
    4812                 :            : /**
    4813                 :            :  * regress_test_array_struct_out_caller_alloc:
    4814                 :            :  * @arr: (out caller-allocates) (array length=len): An array
    4815                 :            :  * @len: Length of @arr
    4816                 :            :  *
    4817                 :            :  * Test flat caller-allocated array output.
    4818                 :            :  *
    4819                 :            :  * Similar to g_main_context_query().
    4820                 :            :  */
    4821                 :            : void
    4822                 :          0 : regress_test_array_struct_out_caller_alloc (RegressTestStructA *arr, gsize len)
    4823                 :            : {
    4824                 :            :   guint i;
    4825                 :            : 
    4826                 :          0 :   g_assert (arr != NULL);
    4827                 :            : 
    4828                 :          0 :   memset (arr, 0, sizeof (RegressTestStructA) * len);
    4829         [ #  # ]:          0 :   for (i=0; i != len; ++i)
    4830                 :          0 :     arr[i].some_int = 111 * (i + 1);
    4831                 :          0 : }
    4832                 :            : 
    4833                 :            : /**
    4834                 :            :  * regress_test_array_struct_in_full:
    4835                 :            :  * @arr: (in) (array length=len) (transfer full): An array
    4836                 :            :  * @len: Length of @arr
    4837                 :            :  *
    4838                 :            :  * Test flat array input with transfer full.
    4839                 :            :  *
    4840                 :            :  * Similar to: 
    4841                 :            :  * - gsf_property_settings_free() with structs but they contain pointers
    4842                 :            :  * - g_byte_array_new_take() with guint8s
    4843                 :            :  */
    4844                 :            : void
    4845                 :          1 : regress_test_array_struct_in_full (RegressTestStructA *arr, gsize len)
    4846                 :            : {
    4847                 :          1 :   g_assert_cmpint (len, ==, 2);
    4848                 :          1 :   g_assert_cmpint (arr[0].some_int, ==, 201);
    4849                 :          1 :   g_assert_cmpint (arr[1].some_int, ==, 202);
    4850                 :          1 :   g_free (arr);
    4851                 :          1 : }
    4852                 :            : 
    4853                 :            : /**
    4854                 :            :  * regress_test_array_struct_in_none:
    4855                 :            :  * @arr: (in) (array length=len) (transfer none): An array.
    4856                 :            :  * @len: Length of @arr
    4857                 :            :  *
    4858                 :            :  * Test flat array input with transfer none.
    4859                 :            :  *
    4860                 :            :  * Similar to g_main_context_check() or gtk_target_list_new().
    4861                 :            :  */
    4862                 :            : void
    4863                 :          1 : regress_test_array_struct_in_none (RegressTestStructA *arr, gsize len)
    4864                 :            : {
    4865                 :          1 :   g_assert_cmpint (len, ==, 3);
    4866                 :          1 :   g_assert_cmpint (arr[0].some_int, ==, 301);
    4867                 :          1 :   g_assert_cmpint (arr[1].some_int, ==, 302);
    4868                 :          1 :   g_assert_cmpint (arr[2].some_int, ==, 303);
    4869                 :          1 : }
    4870                 :            : 

Generated by: LCOV version 1.14