@@ -1981,6 +1981,9 @@ return a single SV whose value is set to C<RETVAL>'s value at the time of
19811981return. In addition, a non-void autocall XSUB will call the underlying C
19821982library function and assign its return value to C<RETVAL>.
19831983
1984+ In addition the return type can be a Perl package name; see
1985+ L</Fully-qualified type names and Perl objects> for details.
1986+
19841987If the return type is prefixed with the C<NO_OUTPUT> keyword, then the
19851988C<RETVAL> variable is still declared, but code to return its value is
19861989suppressed. It is typically useful when making an autocall function
@@ -2086,6 +2089,7 @@ signature.
20862089Some examples of valid XSUB parameter declarations:
20872090
20882091 char *foo # parameter with type
2092+ Foo::Bar foo # parameter with Perl package type
20892093 char *foo = "abc" # default value
20902094 char *foo = NO_INIT # doesn't complain if arg missing
20912095 OUT char *foo # caller's arg gets updated
@@ -2133,6 +2137,32 @@ in a C<CODE> block or similar. Their values aren't normally returned.
21332137There are several variations on this basic pattern, which are explained in
21342138the following subsections.
21352139
2140+ =head3 Fully-qualified type names and Perl objects
2141+
2142+ Foo::Bar
2143+ foo(Foo::Bar self, ...)
2144+
2145+ Normally the type of an XUB's parameter or return value is a valid C type,
2146+ such as C<"char *">. However you can also use Perl package names. When a
2147+ type name includes a colon, it undergoes some extra processing; in
2148+ particular, the actual type as emitted into the C file is transformed
2149+ using C<s/:/_/g> (unless F<xsubpp> has been invoked with C<-hiertype>), so
2150+ that a legal C type is present. The complete effects for a type of
2151+ C<Foo::Bar> are as follows.
2152+
2153+ The type string C<Foo::Bar> is looked up in the typemap I<as-is> to find
2154+ the logical XS type; then the C<INPUT> and C<OUTPUT> typemap templates are
2155+ expanded with the C<$ntype> variable set to C<"Foo::Bar"> and the C<$type>
2156+ variable set to C<"Foo__Bar">. The declaration of the corresponding auto
2157+ variables uses the modified type string, so the example above might
2158+ result in these declarations in the C code:
2159+
2160+ Foo__Bar RETVAL;
2161+ Foo__Bar self = ...;
2162+
2163+ With the appropriate XS typemap entries and C typedefs, this can be used
2164+ to assist in declaring XSUBs which are passed and return Perl objects.
2165+
21362166=head3 XSUB Parameter Placeholders
21372167
21382168Sometimes you want to skip an argument. There are two supported techniques
0 commit comments