This file is indexed.

/usr/share/perl5/ExtUtils/XSBuilder.pod is in libextutils-xsbuilder-perl 0.28-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
=head1 NAME

ExtUtils::XSBuilder - Automatic Perl XS glue code generation

=head1 DESCRIPTION

ExtUtils::XSBuilder is a set modules to parse C header files and create XS
glue code and documentation out of it. Idealy this allows to "write" an
interface to a C library without coding a line. Since no C API is ideal,
some adjuments are necessary most of the time. So to use this module you
must still be familiar with C and XS programming, but it removes a lot of
stupid work and copy & paste from you. Also when the C API changes, most
of the time you only have to rerun XSBuilder to get your new Perl API.

The creation process takes place in the following steps:

=head2 Derive a class from ExtUtils::XSBuilder::ParseSource

This class must override some methods to tell XSBuilder which C header files
to parse and some other necessary parameters. You need at least to override
the C<package> method to give the name of the package you want to create and 
either the C<find_includes> method which returns all C header files to parse,
or the C<include_dirs> method to return a list of all directories which
should be scanned for C header files.

Of course there are more methods you can overide. See 
L<ExtUtils::XSBuilder::ParseSource> for a full list of overrideable methods.

=head2 Scan the source files

If your derived class is called MyClass::ParseSource you simply start the 
source scan with

    perl -MMyClass::ParseSource -e 'MyClass::ParseSource->run'

You may also put this into a small script to ease usage, set the Perl libpath,
etc.

During the source scan, XSBuilder creates a set of tables which contain the
results of parsing. If you haven't changed the default locations in your
subclass, these tables are created under C<xs/tables>, followed by the
name of the module returned by the C<package> method you created. There you
will find four generated modules: C<FunctionTable.pm>, which holds the
function declarations; C<StructureTable.pm>, which holds the structures;
C<ConstantTable.pm>, which contains constants found in the header files; and
C<CallbackTable.pm>, which contains definitions for callback types.

Since source scanning may take some time, we create intermediate tables and
transform them into XS code later, rather than creating XS code directly.
Since we save the result, we can avoid rescanning the source files as long as
they don't change.

=head2 Derive a class from ExtUtils::XSBuilder::WrapXS

The WrapXS class is responsible for taking the information generated both from
the source files and from the map files (see below) to create the XS code.
As with the ParseSource class, you must override this method with your own
implementaion, to tell WrapXS what to do.

See L<ExtUtils::XSBuilder::WrapXS> for a list of overrideable methods.

=head2 Create map files

XSBuilder will not automatically create XS functions for all C functions and
structures. You must provide hints in order for the XS files to be created
properly. The map files are the mechanism to provide these hints. By default,
the map files are found under C<xs/maps>. There are four map types, C<types>,
C<functions>, C<structures>, and C<callbacks>. Each map file is named with
a user selectable prefix (e.g. C<foo>,) followed by an underscore, the map
type name, and the map extension C<.map>. For example, hints for functions
relating to error processing in your source may be contained in a map file
named C<error_functions.map>.

=over 4

=item foo_types.map

Contains the mapping from C types to Perl classes.

=item foo_functions.map

Contains the mapping from C functions to Perl functions. Can be used to 
reorder arguments, tell XSBuilder which arguments are actualy return values 
and in which Perl package the function will be created.

=item foo_structures.map

Contains the mapping from C structures to Perl classes and defines for which
classes the access methods should be created. You can also specify if you want
a C<new> method for the class.

=item foo_callbacks.map

Contains the mapping form C callback functions to Perl callback functions. Can
be used to reorder arguments, tell XSBuilder which arguments are return
values, and in which Perl package the functions will be created.

=back

For a detailed description of the map file formats see below.

To have a starting point, XSBuilder is able to create default map files which
simply include all types, functions and structures. You can recreate the map
files anytime and XSBuilder will append all items which are not already in the
map files.

First copy the _types.map file from the xsbuilder directory to your maps
directory. This file contains the standard mapping for some basic types.

If, for example, your derived class is called MyClass::WrapXS, you simply
start the creation/update of the map files with

    perl -MMyClass::WrapXS -e 'MyClass::WrapXS->checkmaps(" ")' 

The argument to checkmaps supplies a character to be prepended to the first
column of the new map entries. If you do not pass an argument to checkmaps, no
map files are written, and checkmaps will only compare what is missing. (You
need to print the result somehow e.g. by using Data::Dumper). You may also put
this into a small script to ease usage, set the Perl libpath, etc.

After you have created your default maps, you must edit the 
C<xs/maps/new_type.map> file, which contains all types that were found in the
source. Append a pipe (C<|>) followed by the class or type name, e.g.

    int                 | IV
    struct request_rec  | Apache::RequestRec

.

=head2 Create the XS files

Now we can create the code. By running

    perl -MMyClass::WrapXS -e 'MyClass::WrapXS->run'

XSBuilder will create the XS, pm and Makefile.PL files for every module that 
is mentioned in the maps. The result is placed as a directory hierarchy under
WrapXS. To control the content of the C<Makefile.PL> and the C<pm> file, you
can override the C<makefilepl_text> and C<pm_text> methods. You can include
additional code in the XS files by writing an include file which is included
at the top of the XS file. This file can contain helper functions that can't
be automatically generated. The files must be placed under the C<xs>
directory, with the correct path and name. For example, to have a header file
included for the module Apache::DAV, create a file named
C<xs/Apache/DAV/Apache__DAV.h>. The same can be done for inclusion in the pm
file. Following the example above, the file name would be 
C<xs/Apache/DAV/DAV_pm>.


=head1 Format of the map files

For all map files blank lines are ignored and lines starting with a C<#> are
treated as comments and are also ignored.

=head2 Types map file

Contains the mapping from C type to Perl classes.

Format is the name of the C type followed by the name of the Perl class
or the XS type specifier, separated by a C<|>. Example:

    int                 | IV
    struct request_rec  | Apache::RequestRec

If you have a Perl class with a single-level namespace (e.g. Apache) you need
to postfix it with two colons (e.g. "Apache::"). When both a typedef and a
structure share the same name, structures must be written as with a "struct "
prefix (e.g. "struct foo".) Addionally, you can give the id for the typemap if
you need a special conversion and one or more other names for the struct:

    struct request_rec  | Apache::RequestRec | T_APACHEOBJ | r

An optional fifth parameter specifies that the data needs to be copied
when assigned to a struct member and selects the way how memory is allocated:

    char *   | PV | | | strdup

The actual code for memory allocation is provided inside the structure map,
for example:

    MALLOC=strdup:$dest = ($type)ap_pstrdup(obj -> pool, $src)
    MALLOC=malloc:ap_palloc(obj -> pool, $src, sizeof($type)) ; memcpy($dest,$src,sizeof($type))

This gives two ways to allocate memory and copy the data into it. The fifth
parameter in the type map selects which of these two should be used. $src,
$dest and $type are replaced by the source, the destination and the type.
C<obj> is a pointer to the C-structure.

=head3 Special Types

=over

=item String, PV and PVnull

A string is represented in C as a pointer to an null terminated range of
characters. In Perl the it is called C<PV> (pointer value). When converting
a Perl C<undef> to a C string Perl by default converts it to an empty string.
While this is save, this is not always what is required, because many
C interfaces treat NULL as a special case. For this reason the C<PVnull> type
is introduced, which converts C<undef> to C<NULL> and C<NULL> to C<undef>.

To make it work you need the following line in your type map file:

	PVnull		| PVnull | | | strdup

Now you can defines any type, structure memeber or function argument
as type C<PVnull>.
	

=back

=head2 Functions map file

Contains the mapping from C functions to Perl functions. This can be used to 
reorder arguments, tell XSBuilder which arguments are return values, and in
which Perl package the function will be created.

There are some directives which affect the function mappings that follow it.
Each directive may appear in the file more than once.

=over 4

=item MODULE

the module name (file name) where the function should be defined, e.g. 

    MODULE=Apache::Connection

will define the functions that follow in files named Apache/Connection.{pm,xs}

=item PACKAGE

The name of the package that functions are defined in. If undefined, PACKAGE
defaults to the value of MODULE. A value of 'guess' indicates that package
name should be guessed based on first argument found that maps to a Perl
class. Falls back on the prefix (ap_ -> Apache, apr_ -> APR).

=item PREFIX

The prefix to be stripped from C functions when creating the XS stubs.
Defaults to the value of PACKAGE, converted to C naming convention. For
example,

    PREFIX=APR::Base64

will strip C<apr_base64_> from the C functions. If the prefix does not match,
it defaults to C<ap_> or C<apr_>.

=back

B<NOTE:> You must have at least one C<MODULE> definition
otherwise all functions will be ignored.

The format of entries is:

    C function name | dispatch function name (dispatch argspec) | argspec | Perl alias

The C<dispatch function name> (the C function that is actually called)
defaults to C function name. If the dispatch function name is just a prefix
(mpxs_, MPXS_), the C<C function name> is appended to it. The return type may
be specified before the C<C function name>, and defaults to the C<return_type>
in the C<{foo}::FunctionTable> module generated by the C<ParseSource> module.

The C<dispatch argspec> is optional. If supplied, it can be used to pass
different parameters to the dispatch function then to the XS function. If the
function name begins with C<DEFINE_>, a new function is defined (for defining
functions that are not parsed from the source). C<argspec> must be supplied.
C<DEFINE_> is not included in the generated function name. 

The C<argspec> defaults to arguments in C<{foo}::FunctionTable>, as generated
by the C<ParseSource> module. Argument types can be specified to override
those in the C<{foo}::FunctionTable>. Default values can also be specified,
e.g. arg=default_value

For example:
  ap_get_client_block   | mpxs_ | r, SV *:buffer, bufsiz
  ap_setup_client_block |       | r, read_policy=REQUEST_CHUNKED_ERROR
  ap_make_array      | ap_make_array(r->pool, nelts, elt_size) | request_rec *:r, nelts, elt_size


argspec of '...' indicates passthru, calling the function with

    (aTHX_ I32 items, SP **sp, SV **MARK)

To mark an argument as return only you can prefix it with < e.g. 

    dav_open_lockdb | | r, ro, <lockdb

will be called as ($error get the return value of the C function)

    ($error, $lockdb) = $r -> open_lockdb (0) ;

The return argument (e.g. lockdb) will always be passed by address 
to the function.

The function alias, if defined, will be created in the current C<PACKAGE>.

Function names on lines that do not begin with a word character or a single
space are skipped. Function names can be prefixed with the following symbols:

    '!' => 'disabled or not yet implemented',
    '~' => 'implemented but not auto-generated',
    '-' => 'likely never be available to Perl',
    '>' => '"private" to your C library',
    '?' => 'unclassified',

=head2 Structures map file

Contains the mapping from C structures to Perl classes and defines the members
for which access methods should be created. A C<new> method may be specified,
if desired. The format looks like the following:

    <struct_name>
      member1
      member2
      new
    </struct_name>

An optional module name can be given, to specify in which module the code
should be placed. To place the structure in My::Module, for example, specify:

    <struct_name MODULE=My::Module>

For all members that are listed here, XSBuilder will generate an access method
to read and write it's content. If you want to name the perl access method
differently than the C member, you can write

   cMemberValue | member_value | type

this will map the C<cMemberValue> structure member to the access function 
C<member_value>. The default is to use the same name in Perl as in C.
As third argument you can give a typename. This defaults to the type of the 
variable. It can be used to specify a different type, for special conversion needs.
(e.g. PV versus PVnull)
If you give the C<new> member, XSBuilder will create a new method for that
class, which can be used to create a new instance and initialize it with data.

=head2 Callbacks map file

The format of entries is:

    C function name | argspec

The content is the same as function map, it but contains the callbacks.

=head1 Additional generated methods

For structures, XSBuilder will generate two additional methods: C<new>, and
C<init_callbacks>.

=head2 new ($initialvalue)

With C<new> you can create a new Perl object for an C structure. Optionally,
you can pass either a hashref with initial data, or another object, who's
data will be copied into the new object.

=head2 init_callbacks

C<init_callbacks> should be called during object initialization. It will fill
in all callback members of a structure with pointers that cause a method call
into the object, when the callback is called from C.

You can call it either with

    $obj -> init_callbacks

or

    MyModule -> init_callbacks ($obj) ;


=head1 Callbacks

A callback which is part of a structure will cause a call to the method with
the same name as the structure member, prefixed with C<cb_>. For example, if
you have a structure member named C<open>, then the Perl method C<cb_open>
will be called whenever the C code calls the callback.

If you want to call the callback on your own you need to call the method which
is called like the structure member, e.g. C<open>.

NOTE: You need to call C<init_callbacks> during your method initialzation to
be able to call callbacks.