LCOV - code coverage report
Current view: top level - codegen - valainterfaceregisterfunction.vala (source / functions) Coverage Total Hit
Test: vala 0.57.0.298-a8cae1 Lines: 93.1 % 29 27
Test Date: 2024-04-25 11:34:36 Functions: - 0 0

            Line data    Source code
       1              : /* valainterfaceregisterfunction.vala
       2              :  *
       3              :  * Copyright (C) 2006-2011  Jürg Billeter
       4              :  * Copyright (C) 2006-2007  Raffaele Sandrini
       5              :  *
       6              :  * This library is free software; you can redistribute it and/or
       7              :  * modify it under the terms of the GNU Lesser General Public
       8              :  * License as published by the Free Software Foundation; either
       9              :  * version 2.1 of the License, or (at your option) any later version.
      10              : 
      11              :  * This library is distributed in the hope that it will be useful,
      12              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      14              :  * Lesser General Public License for more details.
      15              : 
      16              :  * You should have received a copy of the GNU Lesser General Public
      17              :  * License along with this library; if not, write to the Free Software
      18              :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
      19              :  *
      20              :  * Author:
      21              :  *      Jürg Billeter <j@bitron.ch>
      22              :  *      Raffaele Sandrini <raffaele@sandrini.ch>
      23              :  */
      24              : 
      25              : using GLib;
      26              : 
      27              : /**
      28              :  * C function to register an interface at runtime.
      29              :  */
      30           88 : public class Vala.InterfaceRegisterFunction : TypeRegisterFunction {
      31              :         /**
      32              :          * Specifies the interface to be registered.
      33              :          */
      34              :         public weak Interface interface_reference {
      35         1041 :                 get {
      36         1041 :                         return (Interface) type_symbol;
      37              :                 }
      38              :         }
      39              : 
      40         1077 :         public InterfaceRegisterFunction (Interface iface) {
      41          359 :                 base (iface);
      42              :         }
      43              : 
      44          359 :         public override string get_type_struct_name () {
      45          359 :                 return get_ccode_type_name (interface_reference);
      46              :         }
      47              : 
      48          359 :         public override string get_base_init_func_name () {
      49          359 :                 return "NULL";
      50              :         }
      51              : 
      52          359 :         public override string get_class_finalize_func_name () {
      53          359 :                 return "NULL";
      54              :         }
      55              : 
      56            0 :         public override string get_base_finalize_func_name () {
      57            0 :                 return "NULL";
      58              :         }
      59              : 
      60          359 :         public override string get_class_init_func_name () {
      61          359 :                 return "%s_default_init".printf (get_ccode_lower_case_name (interface_reference));
      62              :         }
      63              : 
      64          359 :         public override string get_instance_struct_size () {
      65          359 :                 return "0";
      66              :         }
      67              : 
      68          359 :         public override string get_instance_init_func_name () {
      69          359 :                 return "NULL";
      70              :         }
      71              : 
      72          359 :         public override string get_parent_type_name () {
      73          359 :                 return "G_TYPE_INTERFACE";
      74              :         }
      75              : 
      76          117 :         public override void get_type_interface_init_statements (CodeContext context, CCodeBlock block, bool plugin) {
      77              :                 /* register all prerequisites */
      78          295 :                 foreach (DataType prereq_ref in interface_reference.get_prerequisites ()) {
      79           89 :                         unowned TypeSymbol prereq = prereq_ref.type_symbol;
      80              : 
      81           89 :                         var func = new CCodeFunctionCall (new CCodeIdentifier ("g_type_interface_add_prerequisite"));
      82           89 :                         func.add_argument (new CCodeIdentifier ("%s_type_id".printf (get_ccode_lower_case_name (interface_reference))));
      83           89 :                         func.add_argument (new CCodeIdentifier (get_ccode_type_id (prereq)));
      84              : 
      85           89 :                         block.add_statement (new CCodeExpressionStatement (func));
      86              :                 }
      87              : 
      88          117 :                 ((CCodeBaseModule) context.codegen).register_dbus_info (block, interface_reference);
      89              :         }
      90              : }
        

Generated by: LCOV version 2.0-1