1divert(-1)
2
3dnl $Id$
4
5dnl  Glib::Variant specializations for fundamental types
6dnl
7dnl  Copyright 2010 The gtkmm Development Team
8dnl
9dnl  This library is free software; you can redistribute it and/or
10dnl  modify it under the terms of the GNU Lesser General Public
11dnl  License as published by the Free Software Foundation; either
12dnl  version 2.1 of the License, or (at your option) any later version.
13dnl
14dnl  This library is distributed in the hope that it will be useful,
15dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
16dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17dnl  Lesser General Public License for more details.
18dnl
19dnl  You should have received a copy of the GNU Lesser General Public
20dnl  License along with this library.  If not, see <http://www.gnu.org/licenses/>.
21
22include(template.macros.m4)
23
24dnl
25dnl For instance, GLIB_VARIANT_BASIC(C++ type, C type, C type name [,C type name 2])
26dnl Parameters:
27dnl C++ type: The C++ type for the specialization, such as bool.
28dnl C type: The C type used by the C API, such as gboolean.
29dnl C type name: The text used in the C API functions and macros, such as boolean
30dnl   in g_variant_get_boolean() and G_VARIANT_TYPE_BOOLEAN.
31dnl C type name 2: Optional second text, such as handle in g_variant_get_handle()
32dnl   and G_VARIANT_TYPE_HANDLE.
33dnl
34define([GLIB_VARIANT_BASIC],[dnl
35LINE(]__line__[)dnl
36
37dnl Please ignore the format stuff.  I was just tired and played a little.
38/**** Glib::Variant<$1> translit(format([%]eval(57-len([$1]))[s],[****/]),[ ],[*])
39
40// static
41const VariantType& Variant<$1>::variant_type()
42{
43  static VariantType type(G_VARIANT_TYPE_[]UPPER($3));
44  return type;
45}
46
47Variant<$1> Variant<$1>::create($1 data)
48{
49  auto result = Variant<$1>(g_variant_new_$3(data));
50  return result;
51}
52ifelse($4,,,[
53Variant<$1> Variant<$1>::create_$4($1 data)
54{
55  auto result = Variant<$1>(g_variant_new_$4(data));
56  return result;
57}
58])dnl
59
60$1 Variant<$1>::get() const
61{
62ifelse($4,,[dnl
63  return g_variant_get_$3(gobject_);
64],[dnl
65  if (get_type().equal(VARIANT_TYPE_[]UPPER($3)))
66    return g_variant_get_$3(gobject_);
67  else
68    return g_variant_get_$4(gobject_);
69])dnl
70}
71])
72
73divert[]dnl
74// This is a generated file, do not edit.  Generated from __file__
75
76#include <glibmm/variant.h>
77
78namespace Glib
79{
80
81GLIB_VARIANT_BASIC(bool, gboolean, boolean)
82GLIB_VARIANT_BASIC(unsigned char, guchar, byte)
83GLIB_VARIANT_BASIC(gint16, gint16, int16)
84GLIB_VARIANT_BASIC(guint16, guint16, uint16)
85GLIB_VARIANT_BASIC(gint32, gint32, int32, handle)
86GLIB_VARIANT_BASIC(guint32, guint32, uint32)
87GLIB_VARIANT_BASIC(gint64, gint64, int64)
88GLIB_VARIANT_BASIC(guint64, guint64, uint64)
89GLIB_VARIANT_BASIC(double, gdouble, double)
90
91} // namespace Glib
92