summaryrefslogtreecommitdiff
path: root/tests/generics/floating-type-cast.c-expected
blob: 8a5f030044ead47f3b9eed752f8c5395c51bccbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/* generics_floating_type_cast.c generated by valac, the Vala compiler
 * generated from generics_floating_type_cast.vala, do not modify */

#include <glib-object.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <string.h>

#if !defined(VALA_EXTERN)
#if defined(_WIN32) || defined(__CYGWIN__)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define _g_free0(var) ((var == NULL) ? NULL : (var = (g_free (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

VALA_EXTERN void foo (GType g_type,
          GBoxedCopyFunc g_dup_func,
          GDestroyNotify g_destroy_func,
          GType t_type,
          GBoxedCopyFunc t_dup_func,
          GDestroyNotify t_destroy_func,
          gconstpointer g,
          gconstpointer t);
static gboolean _float_equal (const gfloat * s1,
                       const gfloat * s2);
static gboolean _double_equal (const gdouble * s1,
                        const gdouble * s2);
static void _vala_main (void);
static gfloat* _float_dup (gfloat* self);
static gdouble* _double_dup (gdouble* self);

static gboolean
_float_equal (const gfloat * s1,
              const gfloat * s2)
{
	if (s1 == s2) {
		return TRUE;
	}
	if (s1 == NULL) {
		return FALSE;
	}
	if (s2 == NULL) {
		return FALSE;
	}
	return (*s1) == (*s2);
}

static gboolean
_double_equal (const gdouble * s1,
               const gdouble * s2)
{
	if (s1 == s2) {
		return TRUE;
	}
	if (s1 == NULL) {
		return FALSE;
	}
	if (s2 == NULL) {
		return FALSE;
	}
	return (*s1) == (*s2);
}

void
foo (GType g_type,
     GBoxedCopyFunc g_dup_func,
     GDestroyNotify g_destroy_func,
     GType t_type,
     GBoxedCopyFunc t_dup_func,
     GDestroyNotify t_destroy_func,
     gconstpointer g,
     gconstpointer t)
{
	gfloat _tmp0_;
	gdouble _tmp1_;
	_tmp0_ = 23.0f;
	_vala_assert (_float_equal ((gfloat*) g, &_tmp0_) == TRUE, "(float?) g == 23.0f");
	_tmp1_ = 42.0;
	_vala_assert (_double_equal ((gdouble*) t, &_tmp1_) == TRUE, "(double?) t == 42.0");
}

static gfloat*
_float_dup (gfloat* self)
{
	gfloat* dup;
	dup = g_new0 (gfloat, 1);
	memcpy (dup, self, sizeof (gfloat));
	return dup;
}

static gpointer
__float_dup0 (gpointer self)
{
	return self ? _float_dup (self) : NULL;
}

static gdouble*
_double_dup (gdouble* self)
{
	gdouble* dup;
	dup = g_new0 (gdouble, 1);
	memcpy (dup, self, sizeof (gdouble));
	return dup;
}

static gpointer
__double_dup0 (gpointer self)
{
	return self ? _double_dup (self) : NULL;
}

static void
_vala_main (void)
{
	gfloat* _tmp0_ = NULL;
	gfloat _tmp1_;
	gfloat* _tmp2_;
	gdouble* _tmp3_ = NULL;
	gdouble _tmp4_;
	gdouble* _tmp5_;
	gfloat* _tmp6_ = NULL;
	gfloat _tmp7_;
	gfloat* _tmp8_;
	gdouble* _tmp9_ = NULL;
	gdouble _tmp10_;
	gdouble* _tmp11_;
	_tmp1_ = 23.0f;
	_tmp2_ = __float_dup0 (&_tmp1_);
	_tmp0_ = _tmp2_;
	_tmp4_ = 42.0;
	_tmp5_ = __double_dup0 (&_tmp4_);
	_tmp3_ = _tmp5_;
	foo (G_TYPE_FLOAT, (GBoxedCopyFunc) _float_dup, (GDestroyNotify) g_free, G_TYPE_DOUBLE, (GBoxedCopyFunc) _double_dup, (GDestroyNotify) g_free, _tmp0_, _tmp3_);
	_tmp7_ = 23.0f;
	_tmp8_ = __float_dup0 (&_tmp7_);
	_tmp6_ = _tmp8_;
	_tmp10_ = 42.0;
	_tmp11_ = __double_dup0 (&_tmp10_);
	_tmp9_ = _tmp11_;
	foo (G_TYPE_FLOAT, (GBoxedCopyFunc) _float_dup, (GDestroyNotify) g_free, G_TYPE_DOUBLE, (GBoxedCopyFunc) _double_dup, (GDestroyNotify) g_free, _tmp6_, _tmp9_);
	_g_free0 (_tmp9_);
	_g_free0 (_tmp6_);
	_g_free0 (_tmp3_);
	_g_free0 (_tmp0_);
}

int
main (int argc,
      char ** argv)
{
	_vala_main ();
	return 0;
}