summaryrefslogtreecommitdiffstats
path: root/upstream/mageia-cauldron/man3pm/ExtUtils::ParseXS::Utilities.3pm
blob: e88ad986b7e42acc1e911b98d39c8568e5a2de4b (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
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
.\" -*- mode: troff; coding: utf-8 -*-
.\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
.ie n \{\
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
.    if \nF \{\
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{\
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "ExtUtils::ParseXS::Utilities 3pm"
.TH ExtUtils::ParseXS::Utilities 3pm 2023-11-28 "perl v5.38.2" "Perl Programmers Reference Guide"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH NAME
ExtUtils::ParseXS::Utilities \- Subroutines used with ExtUtils::ParseXS
.SH SYNOPSIS
.IX Header "SYNOPSIS"
.Vb 10
\&  use ExtUtils::ParseXS::Utilities qw(
\&    standard_typemap_locations
\&    trim_whitespace
\&    C_string
\&    valid_proto_string
\&    process_typemaps
\&    map_type
\&    standard_XS_defs
\&    assign_func_args
\&    analyze_preprocessor_statements
\&    set_cond
\&    Warn
\&    blurt
\&    death
\&    check_conditional_preprocessor_statements
\&    escape_file_for_line_directive
\&    report_typemap_failure
\&  );
.Ve
.SH SUBROUTINES
.IX Header "SUBROUTINES"
The following functions are not considered to be part of the public interface.
They are documented here for the benefit of future maintainers of this module.
.ie n .SS standard_typemap_locations()
.el .SS \f(CWstandard_typemap_locations()\fP
.IX Subsection "standard_typemap_locations()"
.IP \(bu 4
Purpose
.Sp
Provide a list of filepaths where \fItypemap\fR files may be found.  The
filepaths \-\- relative paths to files (not just directory paths) \-\- appear in this list in lowest-to-highest priority.
.Sp
The highest priority is to look in the current directory.
.Sp
.Vb 1
\&  \*(Aqtypemap\*(Aq
.Ve
.Sp
The second and third highest priorities are to look in the parent of the
current directory and a directory called \fIlib/ExtUtils\fR underneath the parent
directory.
.Sp
.Vb 2
\&  \*(Aq../typemap\*(Aq,
\&  \*(Aq../lib/ExtUtils/typemap\*(Aq,
.Ve
.Sp
The fourth through ninth highest priorities are to look in the corresponding
grandparent, great-grandparent and great-great-grandparent directories.
.Sp
.Vb 6
\&  \*(Aq../../typemap\*(Aq,
\&  \*(Aq../../lib/ExtUtils/typemap\*(Aq,
\&  \*(Aq../../../typemap\*(Aq,
\&  \*(Aq../../../lib/ExtUtils/typemap\*(Aq,
\&  \*(Aq../../../../typemap\*(Aq,
\&  \*(Aq../../../../lib/ExtUtils/typemap\*(Aq,
.Ve
.Sp
The tenth and subsequent priorities are to look in directories named
\&\fIExtUtils\fR which are subdirectories of directories found in \f(CW@INC\fR \-\-
\&\fIprovided\fR a file named \fItypemap\fR actually exists in such a directory.
Example:
.Sp
.Vb 1
\&  \*(Aq/usr/local/lib/perl5/5.10.1/ExtUtils/typemap\*(Aq,
.Ve
.Sp
However, these filepaths appear in the list returned by
\&\f(CWstandard_typemap_locations()\fR in reverse order, \fIi.e.\fR, lowest-to-highest.
.Sp
.Vb 10
\&  \*(Aq/usr/local/lib/perl5/5.10.1/ExtUtils/typemap\*(Aq,
\&  \*(Aq../../../../lib/ExtUtils/typemap\*(Aq,
\&  \*(Aq../../../../typemap\*(Aq,
\&  \*(Aq../../../lib/ExtUtils/typemap\*(Aq,
\&  \*(Aq../../../typemap\*(Aq,
\&  \*(Aq../../lib/ExtUtils/typemap\*(Aq,
\&  \*(Aq../../typemap\*(Aq,
\&  \*(Aq../lib/ExtUtils/typemap\*(Aq,
\&  \*(Aq../typemap\*(Aq,
\&  \*(Aqtypemap\*(Aq
.Ve
.IP \(bu 4
Arguments
.Sp
.Vb 1
\&  my @stl = standard_typemap_locations( \e@INC );
.Ve
.Sp
Reference to \f(CW@INC\fR.
.IP \(bu 4
Return Value
.Sp
Array holding list of directories to be searched for \fItypemap\fR files.
.ie n .SS trim_whitespace()
.el .SS \f(CWtrim_whitespace()\fP
.IX Subsection "trim_whitespace()"
.IP \(bu 4
Purpose
.Sp
Perform an in-place trimming of leading and trailing whitespace from the
first argument provided to the function.
.IP \(bu 4
Argument
.Sp
.Vb 1
\&  trim_whitespace($arg);
.Ve
.IP \(bu 4
Return Value
.Sp
None.  Remember:  this is an \fIin-place\fR modification of the argument.
.ie n .SS C_string()
.el .SS \f(CWC_string()\fP
.IX Subsection "C_string()"
.IP \(bu 4
Purpose
.Sp
Escape backslashes (\f(CW\*(C`\e\*(C'\fR) in prototype strings.
.IP \(bu 4
Arguments
.Sp
.Vb 1
\&      $ProtoThisXSUB = C_string($_);
.Ve
.Sp
String needing escaping.
.IP \(bu 4
Return Value
.Sp
Properly escaped string.
.ie n .SS valid_proto_string()
.el .SS \f(CWvalid_proto_string()\fP
.IX Subsection "valid_proto_string()"
.IP \(bu 4
Purpose
.Sp
Validate prototype string.
.IP \(bu 4
Arguments
.Sp
String needing checking.
.IP \(bu 4
Return Value
.Sp
Upon success, returns the same string passed as argument.
.Sp
Upon failure, returns \f(CW0\fR.
.ie n .SS process_typemaps()
.el .SS \f(CWprocess_typemaps()\fP
.IX Subsection "process_typemaps()"
.IP \(bu 4
Purpose
.Sp
Process all typemap files.
.IP \(bu 4
Arguments
.Sp
.Vb 1
\&  my $typemaps_object = process_typemaps( $args{typemap}, $pwd );
.Ve
.Sp
List of two elements:  \f(CW\*(C`typemap\*(C'\fR element from \f(CW%args\fR; current working
directory.
.IP \(bu 4
Return Value
.Sp
Upon success, returns an ExtUtils::Typemaps object.
.ie n .SS map_type()
.el .SS \f(CWmap_type()\fP
.IX Subsection "map_type()"
.IP \(bu 4
Purpose
.Sp
Performs a mapping at several places inside \f(CW\*(C`PARAGRAPH\*(C'\fR loop.
.IP \(bu 4
Arguments
.Sp
.Vb 1
\&  $type = map_type($self, $type, $varname);
.Ve
.Sp
List of three arguments.
.IP \(bu 4
Return Value
.Sp
String holding augmented version of second argument.
.ie n .SS standard_XS_defs()
.el .SS \f(CWstandard_XS_defs()\fP
.IX Subsection "standard_XS_defs()"
.IP \(bu 4
Purpose
.Sp
Writes to the \f(CW\*(C`.c\*(C'\fR output file certain preprocessor directives and function
headers needed in all such files.
.IP \(bu 4
Arguments
.Sp
None.
.IP \(bu 4
Return Value
.Sp
Returns true.
.ie n .SS assign_func_args()
.el .SS \f(CWassign_func_args()\fP
.IX Subsection "assign_func_args()"
.IP \(bu 4
Purpose
.Sp
Perform assignment to the \f(CW\*(C`func_args\*(C'\fR attribute.
.IP \(bu 4
Arguments
.Sp
.Vb 1
\&  $string = assign_func_args($self, $argsref, $class);
.Ve
.Sp
List of three elements.  Second is an array reference; third is a string.
.IP \(bu 4
Return Value
.Sp
String.
.ie n .SS analyze_preprocessor_statements()
.el .SS \f(CWanalyze_preprocessor_statements()\fP
.IX Subsection "analyze_preprocessor_statements()"
.IP \(bu 4
Purpose
.Sp
Within each function inside each Xsub, print to the \fI.c\fR output file certain
preprocessor statements.
.IP \(bu 4
Arguments
.Sp
.Vb 4
\&      ( $self, $XSS_work_idx, $BootCode_ref ) =
\&        analyze_preprocessor_statements(
\&          $self, $statement, $XSS_work_idx, $BootCode_ref
\&        );
.Ve
.Sp
List of four elements.
.IP \(bu 4
Return Value
.Sp
Modifed values of three of the arguments passed to the function.  In
particular, the \f(CW\*(C`XSStack\*(C'\fR and \f(CW\*(C`InitFileCode\*(C'\fR attributes are modified.
.ie n .SS set_cond()
.el .SS \f(CWset_cond()\fP
.IX Subsection "set_cond()"
.IP \(bu 4
Purpose
.IP \(bu 4
Arguments
.IP \(bu 4
Return Value
.ie n .SS current_line_number()
.el .SS \f(CWcurrent_line_number()\fP
.IX Subsection "current_line_number()"
.IP \(bu 4
Purpose
.Sp
Figures out the current line number in the XS file.
.IP \(bu 4
Arguments
.Sp
\&\f(CW$self\fR
.IP \(bu 4
Return Value
.Sp
The current line number.
.ie n .SS Warn()
.el .SS \f(CWWarn()\fP
.IX Subsection "Warn()"
.IP \(bu 4
Purpose
.Sp
Print warnings with line number details at the end.
.IP \(bu 4
Arguments
.Sp
List of text to output.
.IP \(bu 4
Return Value
.Sp
None.
.ie n .SS WarnHint()
.el .SS \f(CWWarnHint()\fP
.IX Subsection "WarnHint()"
.IP \(bu 4
Purpose
.Sp
Prints warning with line number details. The last argument is assumed
to be a hint string.
.IP \(bu 4
Arguments
.Sp
List of strings to warn, followed by one argument representing a hint.
If that argument is defined then it will be split on newlines and output
line by line after the main warning.
.IP \(bu 4
Return Value
.Sp
None.
.ie n .SS _MsgHint()
.el .SS \f(CW_MsgHint()\fP
.IX Subsection "_MsgHint()"
.IP \(bu 4
Purpose
.Sp
Constructs an exception message with line number details. The last argument is
assumed to be a hint string.
.IP \(bu 4
Arguments
.Sp
List of strings to warn, followed by one argument representing a hint.
If that argument is defined then it will be split on newlines and concatenated
line by line (parenthesized) after the main message.
.IP \(bu 4
Return Value
.Sp
The constructed string.
.ie n .SS blurt()
.el .SS \f(CWblurt()\fP
.IX Subsection "blurt()"
.IP \(bu 4
Purpose
.IP \(bu 4
Arguments
.IP \(bu 4
Return Value
.ie n .SS death()
.el .SS \f(CWdeath()\fP
.IX Subsection "death()"
.IP \(bu 4
Purpose
.IP \(bu 4
Arguments
.IP \(bu 4
Return Value
.ie n .SS check_conditional_preprocessor_statements()
.el .SS \f(CWcheck_conditional_preprocessor_statements()\fP
.IX Subsection "check_conditional_preprocessor_statements()"
.IP \(bu 4
Purpose
.IP \(bu 4
Arguments
.IP \(bu 4
Return Value
.ie n .SS escape_file_for_line_directive()
.el .SS \f(CWescape_file_for_line_directive()\fP
.IX Subsection "escape_file_for_line_directive()"
.IP \(bu 4
Purpose
.Sp
Escapes a given code source name (typically a file name but can also
be a command that was read from) so that double-quotes and backslashes are escaped.
.IP \(bu 4
Arguments
.Sp
A string.
.IP \(bu 4
Return Value
.Sp
A string with escapes for double-quotes and backslashes.
.ie n .SS """report_typemap_failure"""
.el .SS \f(CWreport_typemap_failure\fP
.IX Subsection "report_typemap_failure"
.IP \(bu 4
Purpose
.Sp
Do error reporting for missing typemaps.
.IP \(bu 4
Arguments
.Sp
The \f(CW\*(C`ExtUtils::ParseXS\*(C'\fR object.
.Sp
An \f(CW\*(C`ExtUtils::Typemaps\*(C'\fR object.
.Sp
The string that represents the C type that was not found in the typemap.
.Sp
Optionally, the string \f(CW\*(C`death\*(C'\fR or \f(CW\*(C`blurt\*(C'\fR to choose
whether the error is immediately fatal or not. Default: \f(CW\*(C`blurt\*(C'\fR
.IP \(bu 4
Return Value
.Sp
Returns nothing. Depending on the arguments, this
may call \f(CW\*(C`death\*(C'\fR or \f(CW\*(C`blurt\*(C'\fR, the former of which is
fatal.