Mailing List Archive

perlapi/xsubpp patches
These patches to perlapi.pod reflect some of the relaxed requirements of the
xsubpp 1.10 that is in 5.001m. I did not attempt to deal with ALIAS,
PREINIT, INPUT, or INIT-- I haven't figured out ALIAS; I don't yet fully
understand the intermingling of INIT with PREINIT; and I have no idea what
INPUT is.

Apply over the perlapi found in 5.001m.

Dean

*** pod/perlapi.pod Wed May 31 16:08:11 1995
--- ../patches/perlapi.pod Sun Oct 8 01:01:06 1995
***************
*** 24,30 ****
linked.

Many of the examples which follow will concentrate on creating an
! interface between Perl and the ONC+RPC bind library functions.
Specifically, the rpcb_gettime() function will be used to demonstrate many
features of the XS language. This function has two parameters; the first
is an input parameter and the second is an output parameter. The function
--- 24,30 ----
linked.

Many of the examples which follow will concentrate on creating an
! interface between Perl and the ONC+ RPC bind library functions.
Specifically, the rpcb_gettime() function will be used to demonstrate many
features of the XS language. This function has two parameters; the first
is an input parameter and the second is an output parameter. The function
***************
*** 66,73 ****

bool_t
rpcb_gettime(host,timep)
! char * host
! time_t &timep
OUTPUT:
timep

--- 66,73 ----

bool_t
rpcb_gettime(host,timep)
! char *host
! time_t &timep
OUTPUT:
timep

***************
*** 107,136 ****

=head2 The Anatomy of an XSUB

! The following XSUB allows a Perl program to access a C library function called sin(). The XSUB will imitate the C
! function which takes a single argument and returns a single
! value.

double
sin(x)
! double<tab>x

! The compiler expects a tab between the parameter name and its type, and
! any or no whitespace before the type. When using C pointers the
! indirection operator C<*> should be considered part of the type and the
! address operator C<&> should be considered part of the variable, as is
! demonstrated in the rpcb_gettime() function above. See the section on
! typemaps for more about handling qualifiers and unary operators in C
! types.

! The parameter list of a function must not have whitespace
! after the open-parenthesis or before the close-parenthesis.

INCORRECT CORRECT

double double
sin( x ) sin(x)
! double x double x

The function name and the return type must be placed on
separate lines.
--- 107,135 ----

=head2 The Anatomy of an XSUB

! The following XSUB allows a Perl program to access a C library function
! called sin(). The XSUB will imitate the C function which takes a single
! argument and returns a single value.

double
sin(x)
! double x

! When using C pointers the indirection operator C<*> should be considered
! part of the type and the address operator C<&> should be considered part of
! the variable, as is demonstrated in the rpcb_gettime() function above. See
! the section on typemaps for more about handling qualifiers and unary
! operators in C types.

! The parameter list of a function must not have whitespace after the
! open-parenthesis or before the close-parenthesis. (This restriction will be
! relaxed in later versions of B<xsubpp>.)

INCORRECT CORRECT

double double
sin( x ) sin(x)
! double x double x

The function name and the return type must be placed on
separate lines.
***************
*** 138,145 ****
INCORRECT CORRECT

double sin(x) double
! double x sin(x)
! double x

=head2 The Argument Stack

--- 137,144 ----
INCORRECT CORRECT

double sin(x) double
! double x sin(x)
! double x

=head2 The Argument Stack

***************
*** 151,158 ****
first position on that stack which belongs to the active
function will be referred to as position 0 for that function.

! XSUBs refer to their stack arguments with the macro B<ST(x)>, where I<x> refers
! to a position in this XSUB's part of the stack. Position 0 for that
function would be known to the XSUB as ST(0). The XSUB's incoming
parameters and outgoing return values always begin at ST(0). For many
simple cases the B<xsubpp> compiler will generate the code necessary to
--- 150,157 ----
first position on that stack which belongs to the active
function will be referred to as position 0 for that function.

! XSUBs refer to their stack arguments with the macro B<ST(x)>, where I<x>
! refers to a position in this XSUB's part of the stack. Position 0 for that
function would be known to the XSUB as ST(0). The XSUB's incoming
parameters and outgoing return values always begin at ST(0). For many
simple cases the B<xsubpp> compiler will generate the code necessary to
***************
*** 246,259 ****
The OUTPUT: keyword can also be used to indicate that function parameters
are output variables. This may be necessary when a parameter has been
modified within the function and the programmer would like the update to
! be seen by Perl. If function parameters are listed under OUTPUT: along
! with the RETVAL variable then the RETVAL variable must be the last one
! listed.

bool_t
rpcb_gettime(host,timep)
! char * host
! time_t &timep
OUTPUT:
timep

--- 245,256 ----
The OUTPUT: keyword can also be used to indicate that function parameters
are output variables. This may be necessary when a parameter has been
modified within the function and the programmer would like the update to
! be seen by Perl.

bool_t
rpcb_gettime(host,timep)
! char *host
! time_t &timep
OUTPUT:
timep

***************
*** 263,272 ****

bool_t
rpcb_gettime(host,timep)
! char * host
! time_t &timep
OUTPUT:
! timep<tab>sv_setnv(ST(1), (double)timep);

=head2 The CODE: Keyword

--- 260,269 ----

bool_t
rpcb_gettime(host,timep)
! char *host
! time_t &timep
OUTPUT:
! timep sv_setnv(ST(1), (double)timep);

=head2 The CODE: Keyword

***************
*** 284,291 ****

bool_t
rpcb_gettime(host,timep)
! char * host
! time_t timep
CODE:
RETVAL = rpcb_gettime( host, &timep );
OUTPUT:
--- 281,288 ----

bool_t
rpcb_gettime(host,timep)
! char *host
! time_t timep
CODE:
RETVAL = rpcb_gettime( host, &timep );
OUTPUT:
***************
*** 314,321 ****

bool_t
rpcb_gettime(host,timep)
! char * host
! time_t &timep = NO_INIT
OUTPUT:
timep

--- 311,318 ----

bool_t
rpcb_gettime(host,timep)
! char *host
! time_t &timep = NO_INIT
OUTPUT:
timep

***************
*** 335,342 ****

bool_t
rpcb_gettime(host,timep)
! char * host = (char *)SvPV(ST(0),na);
! time_t &timep = 0;
OUTPUT:
timep

--- 332,339 ----

bool_t
rpcb_gettime(host,timep)
! char *host = (char *)SvPV(ST(0),na);
! time_t &timep = 0;
OUTPUT:
timep

***************
*** 368,375 ****

bool_t
rpcb_gettime(timep,host="localhost")
! char * host
! time_t timep = NO_INIT
CODE:
RETVAL = rpcb_gettime( host, &timep );
OUTPUT:
--- 365,372 ----

bool_t
rpcb_gettime(timep,host="localhost")
! char *host
! time_t timep = NO_INIT
CODE:
RETVAL = rpcb_gettime( host, &timep );
OUTPUT:
***************
*** 398,404 ****

bool_t
rpcb_gettime(timep, ...)
! time_t timep = NO_INIT
CODE:
{
char *host = "localhost";
--- 395,401 ----

bool_t
rpcb_gettime(timep, ...)
! time_t timep = NO_INIT
CODE:
{
char *host = "localhost";
***************
*** 427,433 ****

void
rpcb_gettime(host)
! char * host
PPCODE:
{
time_t timep;
--- 424,430 ----

void
rpcb_gettime(host)
! char *host
PPCODE:
{
time_t timep;
***************
*** 513,519 ****

void
rpcb_gettime(host)
! char * host
PPCODE:
{
time_t timep;
--- 510,516 ----

void
rpcb_gettime(host)
! char *host
PPCODE:
{
time_t timep;
***************
*** 728,734 ****
is of the expected type.

The following XS code shows the getnetconfigent() function which is used
! with ONC TIRPC. The getnetconfigent() function will return a pointer to a
C structure and has the C prototype shown below. The example will
demonstrate how the C pointer will become a Perl reference. Perl will
consider this reference to be a pointer to a blessed object and will
--- 725,731 ----
is of the expected type.

The following XS code shows the getnetconfigent() function which is used
! with ONC+ TIRPC. The getnetconfigent() function will return a pointer to a
C structure and has the C prototype shown below. The example will
demonstrate how the C pointer will become a Perl reference. Perl will
consider this reference to be a pointer to a blessed object and will
***************
*** 754,766 ****

Netconfig *
getnetconfigent(netid)
! char * netid

MODULE = RPC PACKAGE = NetconfigPtr PREFIX = rpcb_

void
rpcb_DESTROY(netconf)
! Netconfig * netconf
CODE:
printf("Now in NetconfigPtr::DESTROY\n");
free( netconf );
--- 751,763 ----

Netconfig *
getnetconfigent(netid)
! char *netid

MODULE = RPC PACKAGE = NetconfigPtr PREFIX = rpcb_

void
rpcb_DESTROY(netconf)
! Netconfig *netconf
CODE:
printf("Now in NetconfigPtr::DESTROY\n");
free( netconf );
***************
*** 899,905 ****

void
rpcb_gettime(host="localhost")
! char * host
CODE:
{
time_t timep;
--- 896,902 ----

void
rpcb_gettime(host="localhost")
! char *host
CODE:
{
time_t timep;
***************
*** 910,922 ****

Netconfig *
getnetconfigent(netid="udp")
! char * netid

MODULE = RPC PACKAGE = NetconfigPtr PREFIX = rpcb_

void
rpcb_DESTROY(netconf)
! Netconfig * netconf
CODE:
printf("NetconfigPtr::DESTROY\n");
free( netconf );
--- 907,919 ----

Netconfig *
getnetconfigent(netid="udp")
! char *netid

MODULE = RPC PACKAGE = NetconfigPtr PREFIX = rpcb_

void
rpcb_DESTROY(netconf)
! Netconfig *netconf
CODE:
printf("NetconfigPtr::DESTROY\n");
free( netconf );
***************
*** 956,959 ****
=head1 AUTHOR

Dean Roehrich F<E<lt>roehrich@cray.comE<gt>>
! May 3, 1995
--- 953,956 ----
=head1 AUTHOR

Dean Roehrich F<E<lt>roehrich@cray.comE<gt>>
! Oct 8, 1995
Re: perlapi/xsubpp patches [ In reply to ]
From: Dean Roehrich <roehrich@cray.com>
>
> These patches to perlapi.pod reflect some of the relaxed requirements of the
> xsubpp 1.10 that is in 5.001m. I did not attempt to deal with ALIAS,
> PREINIT, INPUT, or INIT-- I haven't figured out ALIAS; I don't yet fully
> understand the intermingling of INIT with PREINIT; and I have no idea what
> INPUT is.
>
> Apply over the perlapi found in 5.001m.
>
> Dean

Excellent.

It is well worth the effort of updating the document just to reflect
the whitespace stuff.

Paul