1ExtUtils::XSSymSet(3pm)Perl Programmers Reference GuideExtUtils::XSSymSet(3pm)
2
3
4
6 ExtUtils::XSSymSet - keep sets of symbol names palatable to the VMS
7 linker
8
10 use ExtUtils::XSSymSet;
11
12 $set = new ExtUtils::XSSymSet;
13 while ($sym = make_symbol()) { $set->addsym($sym); }
14 foreach $safesym ($set->all_trimmed) {
15 print "Processing $safesym (derived from ",
16 $self->get_orig($safesym), ")\n";
17 do_stuff($safesym);
18 }
19
20 $safesym = ExtUtils::XSSymSet->trimsym($onesym);
21
23 Since the VMS linker distinguishes symbols based only on the first 31
24 characters of their names, it is occasionally necessary to shorten
25 symbol names in order to avoid collisions. (This is especially true of
26 names generated by xsubpp, since prefixes generated by nested package
27 names can become quite long.) "ExtUtils::XSSymSet" provides functions
28 to shorten names in a consistent fashion, and to track a set of names
29 to insure that each is unique. While designed with xsubpp in mind, it
30 may be used with any set of strings.
31
32 This package supplies the following functions, all of which should be
33 called as methods.
34
35 new([$maxlen[,$silent]])
36 Creates an empty "ExtUtils::XSSymset" set of symbols. This
37 function may be called as a static method or via an existing
38 object. If $maxlen or $silent are specified, they are used as the
39 defaults for maximum name length and warning behavior in future
40 calls to addsym() or trimsym() via this object. If the compiler
41 has been instructed to do its own symbol shortening via
42 $Config{'useshortenedsymbols'}, a value of 2048 is assumed for
43 $maxlen as a way of bypassing the shortening done by this module.
44
45 addsym($name[,$maxlen[,$silent]])
46 Creates a symbol name from $name, using the methods described under
47 trimsym(), which is unique in this set of symbols, and returns the
48 new name. $name and its resultant are added to the set, and any
49 future calls to addsym() specifying the same $name will return the
50 same result, regardless of the value of $maxlen specified. Unless
51 $silent is true, warnings are output if $name had to be trimmed or
52 changed in order to avoid collision with an existing symbol name.
53 $maxlen and $silent default to the values specified when this set
54 of symbols was created. This method must be called via an existing
55 object.
56
57 trimsym($name[,$maxlen[,$silent]])
58 Creates a symbol name $maxlen or fewer characters long from $name
59 and returns it. If $name is too long, it first tries to shorten it
60 by removing duplicate characters, then by periodically removing
61 non-underscore characters, and finally, if necessary, by
62 periodically removing characters of any type. $maxlen defaults to
63 31. Unless $silent is true, a warning is output if $name is
64 altered in any way. This function may be called either as a static
65 method or via an existing object, but in the latter case no check
66 is made to insure that the resulting name is unique in the set of
67 symbols. If the compiler has been instructed to do its own
68 symbol shortening via $Config{'useshortenedsymbols'}, a value of
69 2048 is assumed for $maxlen as a way of bypassing the shortening
70 done by this module.
71
72 delsym($name)
73 Removes $name from the set of symbols, where $name is the original
74 symbol name passed previously to addsym(). If $name existed in the
75 set of symbols, returns its "trimmed" equivalent, otherwise returns
76 "undef". This method must be called via an existing object.
77
78 get_orig($trimmed)
79 Returns the original name which was trimmed to $trimmed by a
80 previous call to addsym(), or "undef" if $trimmed does not
81 correspond to a member of this set of symbols. This method must be
82 called via an existing object.
83
84 get_trimmed($name)
85 Returns the trimmed name which was generated from $name by a
86 previous call to addsym(), or "undef" if $name is not a member of
87 this set of symbols. This method must be called via an existing
88 object.
89
90 all_orig()
91 Returns a list containing all of the original symbol names from
92 this set.
93
94 all_trimmed()
95 Returns a list containing all of the trimmed symbol names from this
96 set.
97
99 Charles Bailey <bailey@newman.upenn.edu>
100
102 Last revised 8-Oct-2010, for Perl 5.13.6.
103
104
105
106perl v5.26.3 2018-03-01 ExtUtils::XSSymSet(3pm)