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

            Line data    Source code
       1              : /* valaglibvalue.vala
       2              :  *
       3              :  * Copyright (C) 2010  Jürg Billeter
       4              :  * Copyright (C) 2011  Luca Bruno
       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              :  *      Luca Bruno <lucabru@src.gnome.org>
      23              :  */
      24              : 
      25       318117 : public class Vala.GLibValue : TargetValue {
      26       317275 :         public CCodeExpression cvalue;
      27              :         public bool lvalue;
      28              :         public bool non_null;
      29       317275 :         public string? ctype;
      30              : 
      31       317275 :         public List<CCodeExpression> array_length_cvalues;
      32       317275 :         public CCodeExpression? array_size_cvalue;
      33              :         public bool array_null_terminated;
      34       317275 :         public CCodeExpression? array_length_cexpr;
      35              : 
      36       317275 :         public CCodeExpression? delegate_target_cvalue;
      37       317275 :         public CCodeExpression? delegate_target_destroy_notify_cvalue;
      38              : 
      39       317275 :         public GLibValue (DataType? value_type = null, CCodeExpression? cvalue = null, bool lvalue = false) {
      40       317275 :                 base (value_type);
      41      1067542 :                 this.cvalue = cvalue;
      42       317275 :                 this.lvalue = lvalue;
      43              :         }
      44              : 
      45        15384 :         public void append_array_length_cvalue (CCodeExpression length_cvalue) {
      46        15384 :                 if (array_length_cvalues == null) {
      47        12444 :                         array_length_cvalues = new ArrayList<CCodeExpression> ();
      48              :                 }
      49        15384 :                 array_length_cvalues.add (length_cvalue);
      50              :         }
      51              : 
      52       152382 :         public GLibValue copy () {
      53       152382 :                 var result = new GLibValue (value_type.copy (), cvalue, lvalue);
      54       152382 :                 result.actual_value_type = actual_value_type;
      55       152382 :                 result.non_null = non_null;
      56       304764 :                 result.ctype = ctype;
      57              : 
      58       152382 :                 if (array_length_cvalues != null) {
      59        21551 :                         foreach (var cexpr in array_length_cvalues) {
      60         7999 :                                 result.append_array_length_cvalue (cexpr);
      61              :                         }
      62              :                 }
      63       152401 :                 result.array_size_cvalue = array_size_cvalue;
      64       152382 :                 result.array_null_terminated = array_null_terminated;
      65       152382 :                 result.array_length_cexpr = array_length_cexpr;
      66              : 
      67       170928 :                 result.delegate_target_cvalue = delegate_target_cvalue;
      68       170615 :                 result.delegate_target_destroy_notify_cvalue = delegate_target_destroy_notify_cvalue;
      69              : 
      70       152382 :                 return result;
      71              :         }
      72              : }
      73              : 
      74              : namespace Vala {
      75       292015 :         public static unowned CCodeExpression? get_cvalue (Expression expr) {
      76       292015 :                 if (expr.target_value == null) {
      77        38306 :                         return null;
      78              :                 }
      79       253709 :                 return ((GLibValue) expr.target_value).cvalue;
      80              :         }
      81              : 
      82       132050 :         public static unowned CCodeExpression? get_cvalue_ (TargetValue value) {
      83       132050 :                 return ((GLibValue) value).cvalue;
      84              :         }
      85              : 
      86        69887 :         public static void set_cvalue (Expression expr, CCodeExpression? cvalue) {
      87        69887 :                 unowned GLibValue glib_value = (GLibValue) expr.target_value;
      88        69887 :                 if (glib_value == null) {
      89        63773 :                         expr.target_value = new GLibValue (expr.value_type);
      90        63773 :                         glib_value = (GLibValue) expr.target_value;
      91              :                 }
      92       139680 :                 glib_value.cvalue = cvalue;
      93              :         }
      94              : 
      95         2979 :         public static unowned CCodeExpression? get_array_size_cvalue (TargetValue value) {
      96         2979 :                 return ((GLibValue) value).array_size_cvalue;
      97              :         }
      98              : 
      99        35451 :         public static void set_array_size_cvalue (TargetValue value, CCodeExpression? cvalue) {
     100        35771 :                 ((GLibValue) value).array_size_cvalue = cvalue;
     101              :         }
     102              : 
     103           83 :         public static unowned CCodeExpression? get_delegate_target (Expression expr) {
     104           83 :                 if (expr.target_value == null) {
     105            0 :                         return null;
     106              :                 }
     107           83 :                 return ((GLibValue) expr.target_value).delegate_target_cvalue;
     108              :         }
     109              : 
     110        17673 :         public static void set_delegate_target (Expression expr, CCodeExpression? delegate_target) {
     111        17673 :                 unowned GLibValue? glib_value = (GLibValue) expr.target_value;
     112        17673 :                 if (glib_value == null) {
     113           14 :                         expr.target_value = new GLibValue (expr.value_type);
     114           14 :                         glib_value = (GLibValue) expr.target_value;
     115              :                 }
     116        35346 :                 glib_value.delegate_target_cvalue = delegate_target;
     117              :         }
     118              : 
     119           81 :         public static unowned CCodeExpression? get_delegate_target_destroy_notify (Expression expr) {
     120           81 :                 unowned GLibValue? glib_value = (GLibValue) expr.target_value;
     121           81 :                 if (glib_value == null) {
     122            0 :                         return null;
     123              :                 }
     124           81 :                 return glib_value.delegate_target_destroy_notify_cvalue;
     125              :         }
     126              : 
     127        17728 :         public static void set_delegate_target_destroy_notify (Expression expr, CCodeExpression? destroy_notify) {
     128        17728 :                 unowned GLibValue? glib_value = (GLibValue) expr.target_value;
     129        17728 :                 if (glib_value == null) {
     130            0 :                         expr.target_value = new GLibValue (expr.value_type);
     131            0 :                         glib_value = (GLibValue) expr.target_value;
     132              :                 }
     133        35456 :                 glib_value.delegate_target_destroy_notify_cvalue = destroy_notify;
     134              :         }
     135              : 
     136         1261 :         public static void append_array_length (Expression expr, CCodeExpression size) {
     137         1261 :                 unowned GLibValue? glib_value = (GLibValue) expr.target_value;
     138         1261 :                 if (glib_value == null) {
     139          887 :                         expr.target_value = new GLibValue (expr.value_type);
     140          887 :                         glib_value = (GLibValue) expr.target_value;
     141              :                 }
     142         1261 :                 glib_value.append_array_length_cvalue (size);
     143              :         }
     144              : 
     145           26 :         public static void set_array_length (Expression expr, CCodeExpression size) {
     146           26 :                 unowned GLibValue? glib_value = (GLibValue) expr.target_value;
     147           26 :                 if (glib_value == null) {
     148            0 :                         expr.target_value = new GLibValue (expr.value_type);
     149            0 :                         glib_value = (GLibValue) expr.target_value;
     150              :                 } else {
     151           26 :                         glib_value.array_length_cvalues = null;
     152              :                 }
     153           26 :                 glib_value.append_array_length_cvalue (size);
     154              :         }
     155              : 
     156           19 :         public static unowned List<CCodeExpression>? get_array_lengths (Expression expr) {
     157           19 :                 unowned GLibValue? glib_value = (GLibValue) expr.target_value;
     158           19 :                 if (glib_value == null) {
     159            0 :                         return null;
     160              :                 }
     161           19 :                 return glib_value.array_length_cvalues;
     162              :         }
     163              : 
     164          337 :         public static bool get_lvalue (TargetValue value) {
     165          337 :                 return ((GLibValue) value).lvalue;
     166              :         }
     167              : 
     168          223 :         public static bool get_non_null (TargetValue value) {
     169          223 :                 return ((GLibValue) value).non_null;
     170              :         }
     171              : 
     172        40550 :         public static unowned string? get_ctype (TargetValue value) {
     173        40550 :                 return ((GLibValue) value).ctype;
     174              :         }
     175              : 
     176           32 :         public static bool get_array_null_terminated (TargetValue value) {
     177           32 :                 return ((GLibValue) value).array_null_terminated;
     178              :         }
     179              : 
     180            4 :         public static unowned CCodeExpression? get_array_length_cexpr (TargetValue value) {
     181            4 :                 return ((GLibValue) value).array_length_cexpr;
     182              :         }
     183              : }
        

Generated by: LCOV version 2.0-1