File: typemap

package info (click to toggle)
libglib-perl 3:1.329.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 1,320 kB
  • sloc: perl: 4,950; ansic: 923; makefile: 7
file content (294 lines) | stat: -rw-r--r-- 7,044 bytes parent folder | download | duplicates (2)
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# Copyright (C) 2003-2005, 2010 by the gtk2-perl team (see the file AUTHORS for
# the full list)
# 
# This library is free software; you can redistribute it and/or modify it under
# the terms of the GNU Library General Public License as published by the Free
# Software Foundation; either version 2.1 of the License, or (at your option)
# any later version.
# 
# This library is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU Library General Public License for
# more details.
# 
# You should have received a copy of the GNU Library General Public License
# along with this library; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# $Id$
#

TYPEMAP

gboolean	T_BOOL
gint		T_IV
guint		T_UV
gint8		T_IV
guint8		T_UV
gint16		T_IV
guint16		T_UV
gint32		T_IV
guint32		T_UV
gint64		T_GINT64
guint64		T_GUINT64
gshort		T_SHORT
gushort		T_U_SHORT
glong		T_IV
gulong		T_UV
gunichar	T_GUNICHAR
gchar		T_IV
guchar		T_UV
gfloat		T_FLOAT
gdouble		T_DOUBLE
gsize		T_UV
gssize		T_IV
gpointer	T_PTR

gchar *				T_GCHAR
const gchar *			T_GCHAR
gchar_own *			T_GCHAR_OWN
gchar_length *			T_GCHAR_LEN
const gchar_length *		T_GCHAR_LEN
gchar_utf8_length *		T_GCHAR_UTF8_LEN
const gchar_utf8_length *	T_GCHAR_UTF8_LEN
gchar_ornull *			T_GCHAR_ORNULL
gchar_own_ornull *		T_GCHAR_OWN_ORNULL
const gchar_ornull *		T_GCHAR_ORNULL

char_ornull *			T_CHAR_ORNULL
char_own *			T_CHAR_OWN
char_own_ornull *		T_CHAR_OWN_ORNULL
const char_ornull *		T_CHAR_ORNULL

char_byte *			T_CHAR_BYTE
const char_byte *		T_CHAR_BYTE
char_byte_ornull *		T_CHAR_BYTE_ORNULL
const char_byte_ornull *	T_CHAR_BYTE_ORNULL

guchar *			T_GUCHAR
const guchar *			T_GUCHAR

GObject*		T_GPERL_GENERIC_WRAPPER
GObject_ornull*		T_GPERL_GENERIC_WRAPPER
GObject_noinc*		T_GPERL_GENERIC_WRAPPER

GParamSpec*		T_GPERL_GENERIC_WRAPPER
GParamSpec_ornull*	T_GPERL_GENERIC_WRAPPER
GParamFlags		T_GPERL_GENERIC_WRAPPER

GSignalFlags		T_GPERL_GENERIC_WRAPPER

GKeyFile*		T_GPERL_GENERIC_WRAPPER
GKeyFileFlags		T_GPERL_GENERIC_WRAPPER

GBookmarkFile*		T_GPERL_GENERIC_WRAPPER

GIOCondition		T_G_TYPE_IO_CONDITION

GMainContext*		T_G_MAIN_CONTEXT
GMainLoop*		T_G_MAIN_LOOP

GPerlFilename		T_GPERL_FILENAME
GPerlFilename_const	T_GPERL_FILENAME
GPerlFilename_own	T_GPERL_FILENAME_OWN
GPerlFilename_ornull	T_GPERL_FILENAME_ORNULL

GOptionContext *	T_GPERL_GENERIC_WRAPPER
GOptionContext_own *	T_GPERL_GENERIC_WRAPPER
GOptionGroup *		T_GPERL_GENERIC_WRAPPER
GOptionGroup_own *	T_GPERL_GENERIC_WRAPPER

GUserDirectory		T_GPERL_GENERIC_WRAPPER

GVariant *		T_GPERL_GENERIC_WRAPPER
const GVariant *	T_GPERL_GENERIC_WRAPPER
GVariant_noinc *	T_GPERL_GENERIC_WRAPPER

GVariantType *		T_GPERL_GENERIC_WRAPPER
const GVariantType *	T_GPERL_GENERIC_WRAPPER
GVariantType_own *	T_GPERL_GENERIC_WRAPPER

GVariantDict *		T_GPERL_GENERIC_WRAPPER
const GVariantDict *	T_GPERL_GENERIC_WRAPPER
GVariantDict_own *	T_GPERL_GENERIC_WRAPPER

GBytes *		T_GPERL_GENERIC_WRAPPER
GBytes_own *		T_GPERL_GENERIC_WRAPPER

###############################################################################
INPUT

# a general-purpose typemap... strips any trailing star and/or leading "const",
# leaving only the type name in the form SvMyType.  this allows you to make a
# typedef such as "typedef MyType MyType_ornull", and SvMyType_ornull will be
# called for those.
T_GPERL_GENERIC_WRAPPER
	$var = Sv${(my $ntype = $type) =~ s/(?:const\s+)?([:\w]+)(?:\s*\*)$/$1/x;
	           \$ntype} ($arg);

T_GINT64
	$var = SvGInt64 ($arg);

T_GUINT64
	$var = SvGUInt64 ($arg);

T_GUNICHAR
	$var = g_utf8_get_char (SvGChar ($arg));

T_GCHAR
	/* same as SvGChar(), but not in a function */
	sv_utf8_upgrade ($arg);
	$var = ($type)SvPV_nolen ($arg);

T_GCHAR_ORNULL
	/* same as SvGChar(), but allows undef as NULL */
	if (gperl_sv_is_defined ($arg)) {
		sv_utf8_upgrade ($arg);
		$var = ($type)SvPV_nolen ($arg);
	} else {
		$var = NULL;
	}

T_GCHAR_LEN
	sv_utf8_upgrade ($arg);
	$var = ($type)SvPV ($arg, STRLEN_length_of_$var);
        XSauto_length_of_$var = STRLEN_length_of_$var;

T_GCHAR_UTF8_LEN
	sv_utf8_upgrade ($arg);
	$var = ($type)SvPV ($arg, STRLEN_length_of_$var);
        XSauto_length_of_$var = g_utf8_strlen ($var, STRLEN_length_of_$var);

T_GUCHAR
	$var = ($type)SvPV_nolen ($arg);

T_CHAR_ORNULL
	if (gperl_sv_is_defined ($arg)) {
		$var = ($type)SvPV_nolen ($arg);
	} else {
		$var = NULL;
	}

T_CHAR_BYTE
	$var = ($type)SvPVbyte_nolen ($arg);

T_CHAR_BYTE_ORNULL
	if (gperl_sv_is_defined ($arg)) {
		$var = ($type)SvPVbyte_nolen ($arg);
	} else {
		$var = NULL;
	}

T_G_TYPE_IO_CONDITION
	$var = gperl_convert_flags (G_TYPE_IO_CONDITION, $arg);

T_G_MAIN_CONTEXT
	if (!gperl_sv_is_ref ($arg)) {
		$var = NULL;
	} else {
		$var = INT2PTR ($type, SvIV (SvRV ($arg)));
	}
T_G_MAIN_LOOP
	$var = INT2PTR ($type, SvIV (SvRV ($arg)))

T_GPERL_FILENAME
	$var = ($type) gperl_filename_from_sv ($arg)

T_GPERL_FILENAME_ORNULL
	$var = ($type)
		(gperl_sv_is_defined ($arg)
		 ? gperl_filename_from_sv ($arg)
		 : NULL)

###############################################################################
OUTPUT

T_GPERL_GENERIC_WRAPPER
	$arg = newSV${(my $ntype = $type) =~ s/(?:const\s+)?([:\w]+)(?:\s*\*)$/$1/;
		      \$ntype} ($var);

T_GINT64
	$arg = newSVGInt64 ($var);

T_GUINT64
	$arg = newSVGUInt64 ($var);

T_GUNICHAR
	{
	gchar temp[6];
	gint length = g_unichar_to_utf8 ($var, temp);
	sv_setpvn ((SV*)$arg, temp, length);
	SvUTF8_on ($arg);
	}

T_GCHAR
	/* same as newSVGChar(), but not in a function */
	sv_setpv ((SV*)$arg, $var);
	SvUTF8_on ($arg);

T_GCHAR_ORNULL
	/* newSVGChar() allows NULL, but T_GCHAR does not. allow NULL. */
	if ($var) {
		sv_setpv ((SV*)$arg, $var);
		SvUTF8_on ($arg);
	} else {
		SvSetSV ($arg, &PL_sv_undef);
	}

T_GCHAR_OWN
	/* used when we can directly own the returned string. */
	/* we have to copy in the case when perl's malloc != gtk's malloc,
         * so best copy all the time. */
	sv_setpv ((SV*)$arg, $var);
	SvUTF8_on ($arg);
        g_free ($var);

T_GCHAR_OWN_ORNULL
	if ($var) {
		sv_setpv ((SV*)$arg, $var);
		SvUTF8_on ($arg);
	        g_free ($var);
	} else {
		SvSetSV ($arg, &PL_sv_undef);
	}

T_CHAR_ORNULL
	if ($var) {
		sv_setpv ((SV*)$arg, $var);
	} else {
		SvSetSV ($arg, &PL_sv_undef);
	}

T_CHAR_OWN_ORNULL
	if ($var) {
		sv_setpv ((SV*)$arg, $var);
		g_free ($var);
	} else {
		SvSetSV ($arg, &PL_sv_undef);
	}

T_GUCHAR
	sv_setpv ((SV*)$arg, (char*)$var);

T_CHAR_OWN
	sv_setpv ((SV*)$arg, $var);
        g_free ($var);

T_G_TYPE_IO_CONDITION
	$arg = gperl_convert_back_flags (G_TYPE_IO_CONDITION, $var);

T_G_MAIN_CONTEXT
	sv_setref_pv ($arg, \"Glib::MainContext\", $var);
	g_main_context_ref ($var);

T_G_MAIN_LOOP
	sv_setref_pv ($arg, \"Glib::MainLoop\", $var);
	g_main_loop_ref ($var);

T_GPERL_FILENAME
	sv_setsv ($arg, sv_2mortal (gperl_sv_from_filename ($var)));

T_GPERL_FILENAME_OWN
	sv_setsv ($arg, sv_2mortal (gperl_sv_from_filename ($var)));
        g_free ($var);