LCOV - code coverage report
Current view: top level - ccode - valaccodedefine.vala (source / functions) Coverage Total Hit
Test: vala 0.57.0.253-297e8 Lines: 100.0 % 21 21
Test Date: 2024-02-21 16:21:37 Functions: - 0 0

            Line data    Source code
       1              : /* valaccodedefine.vala
       2              :  *
       3              :  * Copyright (C) 2018  Dr. Michael 'Mickey' Lauer
       4              :  *
       5              :  * This library is free software; you can redistribute it and/or
       6              :  * modify it under the terms of the GNU Lesser General Public
       7              :  * License as published by the Free Software Foundation; either
       8              :  * version 2.1 of the License, or (at your option) any later version.
       9              : 
      10              :  * This library is distributed in the hope that it will be useful,
      11              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      12              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13              :  * Lesser General Public License for more details.
      14              : 
      15              :  * You should have received a copy of the GNU Lesser General Public
      16              :  * License along with this library; if not, write to the Free Software
      17              :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
      18              :  *
      19              :  * Author:
      20              :  *      Dr. Michael 'Mickey' Lauer <mickey@vanille-media.de>
      21              :  *      Rico Tzschichholz <ricotz@ubuntu.com>
      22              :  */
      23              : 
      24              : using GLib;
      25              : 
      26              : /**
      27              :  * Represents a definition in the C code.
      28              :  */
      29        19531 : public class Vala.CCodeDefine : CCodeNode {
      30              :         /**
      31              :          * The name of this definition.
      32              :          */
      33        56079 :         public string name { get; set; }
      34              : 
      35              :         /**
      36              :          * The value of this definition.
      37              :          */
      38        48383 :         public string? value { get; set; }
      39              : 
      40              :         /**
      41              :          * The value expression of this definition.
      42              :          */
      43        22541 :         public CCodeExpression? value_expression { get; set; }
      44              : 
      45        33759 :         public CCodeDefine (string name, string? value = null) {
      46        14845 :                 this.name = name;
      47        14845 :                 this.value = value;
      48              :         }
      49              : 
      50         7859 :         public CCodeDefine.with_expression (string name, CCodeExpression expression) {
      51         3848 :                 this.name = name;
      52         3848 :                 this.value_expression = expression;
      53              :         }
      54              : 
      55        11008 :         public override void write (CCodeWriter writer) {
      56        11008 :                 writer.write_indent ();
      57        11008 :                 writer.write_string ("#define ");
      58        11008 :                 writer.write_string (name);
      59        11008 :                 if (value != null) {
      60         7225 :                         writer.write_string (" ");
      61         7225 :                         writer.write_string (@value);
      62         3783 :                 } else if (value_expression != null) {
      63         3782 :                         writer.write_string (" ");
      64         3782 :                         value_expression.write_inner (writer);
      65              :                 }
      66        11008 :                 writer.write_newline ();
      67              :         }
      68              : }
        

Generated by: LCOV version 2.0-1