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

            Line data    Source code
       1              : /* valaversion.vala
       2              :  *
       3              :  * Copyright (C) 2018  Rico Tzschichholz
       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              :  *      Rico Tzschichholz <ricotz@ubuntu.com>
      21              :  */
      22              : 
      23              : namespace Vala {
      24              :         /**
      25              :          * Like get_major_version, but from the headers used at application compile time,
      26              :          * rather than from the library linked against at application run time
      27              :          */
      28              :         public const int MAJOR_VERSION = 0;
      29              :         /**
      30              :          * Like get_minor_version, but from the headers used at application compile time,
      31              :          * rather than from the library linked against at application run time
      32              :          */
      33              :         public const int MINOR_VERSION = 57;
      34              :         /**
      35              :          * Like get_micro_version, but from the headers used at application compile time,
      36              :          * rather than from the library linked against at application run time
      37              :          */
      38              :         public const int MICRO_VERSION = 0;
      39              : 
      40              :         /**
      41              :          * The API version string
      42              :          */
      43              :         public const string API_VERSION = "0.58";
      44              : 
      45              :         /**
      46              :          * The full build-version string generated by the build-system
      47              :          */
      48              :         public const string BUILD_VERSION = "0.57.0.298-a8cae1";
      49              : 
      50              :         /**
      51              :          * Returns the major version number of the vala library.
      52              :          *
      53              :          * This function is in the library, so it represents the GTK+
      54              :          * library your code is running against.
      55              :          *
      56              :          * @return the major version number of the vala library
      57              :          */
      58              :         public uint get_major_version () {
      59            0 :                 return MAJOR_VERSION;
      60              :         }
      61              : 
      62              :         /**
      63              :          * Returns the minor version number of the vala library.
      64              :          *
      65              :          * This function is in the library, so it represents the vala
      66              :          * library your code is are running against.
      67              :          *
      68              :          * @return the minor version number of the vala library
      69              :          */
      70              :         public uint get_minor_version () {
      71            0 :                 return MINOR_VERSION;
      72              :         }
      73              : 
      74              :         /**
      75              :          * Returns the micro version number of the vala library.
      76              :          *
      77              :          * This function is in the library, so it represents the vala
      78              :          * library your code is running against.
      79              :          *
      80              :          * @return the micro version number of the vala library
      81              :          */
      82              :         public uint get_micro_version () {
      83            0 :                 return MICRO_VERSION;
      84              :         }
      85              : 
      86              :         /**
      87              :          * Returns the full build-version string of the vala library.
      88              :          *
      89              :          * This function is in the library, so it represents the vala
      90              :          * library your code is running against.
      91              :          *
      92              :          * @return the full build-version string of the vala library
      93              :          */
      94              :         public unowned string get_build_version () {
      95         3005 :                 return BUILD_VERSION;
      96              :         }
      97              : 
      98              :         /**
      99              :          * Checks that the vala library in use is compatible with the given version.
     100              :          *
     101              :          * This function is in the library, so it represents the vala
     102              :          * library your code is running against.
     103              :          *
     104              :          * @param required_major the required major version
     105              :          * @param required_minor the required minor version
     106              :          * @param required_micro the required micro version
     107              :          * @return null if the vala library is compatible with the given version,
     108              :          * or a string describing the version mismatch.
     109              :          */
     110              :         public unowned string? check_version (uint required_major, uint required_minor, uint required_micro)
     111              :         {
     112            0 :                 uint effective_micro = 100 * MINOR_VERSION + MICRO_VERSION;
     113            0 :                 uint required_effective_micro = 100 * required_minor + required_micro;
     114              : 
     115            0 :                 if (required_major > MAJOR_VERSION)
     116            0 :                         return "vala version too old (major mismatch)";
     117              : 
     118            0 :                 if (required_effective_micro > effective_micro)
     119            0 :                         return "vala version too old (micro mismatch)";
     120              : 
     121            0 :                 return null;
     122              :         }
     123              : }
        

Generated by: LCOV version 2.0-1