Branch data Line data Source code
1 : : /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ 2 : : // SPDX-License-Identifier: MIT OR LGPL-2.0-or-later 3 : : // SPDX-FileCopyrightText: 2020 Marco Trevisan <marco.trevisan@canonical.com> 4 : : 5 : : #pragma once 6 : : 7 : : #include <config.h> 8 : : 9 : : #include <stdint.h> 10 : : 11 : : #include <girepository.h> 12 : : #include <glib-object.h> // for GType 13 : : #include <glib.h> // for gboolean 14 : : 15 : : namespace Gjs { 16 : : 17 : : template <typename T, GITypeTag TAG = GI_TYPE_TAG_VOID> 18 : : constexpr inline const char* static_type_name() = delete; 19 : : 20 : : template <> 21 : : constexpr inline const char* static_type_name<bool>() { 22 : : return "bool"; 23 : : } 24 : : 25 : : template <> 26 : 0 : constexpr inline const char* static_type_name<int8_t>() { 27 : 0 : return "int8"; 28 : : } 29 : : 30 : : template <> 31 : 1 : constexpr inline const char* static_type_name<uint8_t>() { 32 : 1 : return "uint8"; 33 : : } 34 : : 35 : : template <> 36 : 0 : constexpr inline const char* static_type_name<int16_t>() { 37 : 0 : return "int16"; 38 : : } 39 : : 40 : : template <> 41 : 1 : constexpr inline const char* static_type_name<uint16_t>() { 42 : 1 : return "uint16"; 43 : : } 44 : : 45 : : template <> 46 : 0 : constexpr inline const char* static_type_name<int32_t>() { 47 : 0 : return "int32"; 48 : : } 49 : : 50 : : template <> 51 : 2 : constexpr inline const char* static_type_name<uint32_t>() { 52 : 2 : return "uint32"; 53 : : } 54 : : 55 : : template <> 56 : 0 : constexpr inline const char* static_type_name<char32_t>() { 57 : 0 : return "char32_t"; 58 : : } 59 : : 60 : : template <> 61 : 0 : constexpr inline const char* static_type_name<int64_t>() { 62 : 0 : return "int64"; 63 : : } 64 : : 65 : : template <> 66 : 4 : constexpr inline const char* static_type_name<uint64_t>() { 67 : 4 : return "uint64"; 68 : : } 69 : : 70 : : template <> 71 : 0 : constexpr inline const char* static_type_name<float>() { 72 : 0 : return "float"; 73 : : } 74 : : 75 : : template <> 76 : 0 : constexpr inline const char* static_type_name<double>() { 77 : 0 : return "double"; 78 : : } 79 : : 80 : : template <> 81 : : constexpr inline const char* static_type_name<void*>() { 82 : : return "pointer"; 83 : : } 84 : : 85 : : template <> 86 : 2 : constexpr inline const char* static_type_name<GType, GI_TYPE_TAG_GTYPE>() { 87 : 2 : return "GType"; 88 : : } 89 : : 90 : : template <> 91 : 0 : constexpr inline const char* static_type_name<gboolean, GI_TYPE_TAG_BOOLEAN>() { 92 : 0 : return "boolean"; 93 : : } 94 : : 95 : : template <> 96 : 1 : constexpr inline const char* static_type_name<GValue>() { 97 : 1 : return "GValue"; 98 : : } 99 : : 100 : : template <> 101 : 1 : inline const char* static_type_name<char*>() { 102 : 1 : return "string"; 103 : : } 104 : : 105 : : } // namespace Gjs