develooper Front page | perl.perl5.changes | Postings from May 2020

[Perl/perl5] 75be60: Add dualvar-creating newSVivpv and newSVivpvn

From:
Paul Evans
Date:
May 26, 2020 14:08
Subject:
[Perl/perl5] 75be60: Add dualvar-creating newSVivpv and newSVivpvn
Message ID:
Perl/perl5/push/refs/heads/leonerd/newSVivpv/000000-5fff32@github.com
  Branch: refs/heads/leonerd/newSVivpv
  Home:   https://github.com/Perl/perl5
  Commit: 75be6036ec2dbdb67df6319d8a3bc64c75a3324f
      https://github.com/Perl/perl5/commit/75be6036ec2dbdb67df6319d8a3bc64c75a3324f
  Author: Paul "LeoNerd" Evans <leonerd@leonerd.org.uk>
  Date:   2020-05-26 (Tue, 26 May 2020)

  Changed paths:
    M embed.fnc
    M embed.h
    M ext/XS-APItest/APItest.xs
    A ext/XS-APItest/t/newSVivpv.t
    M proto.h
    M sv.c

  Log Message:
  -----------
  Add dualvar-creating newSVivpv and newSVivpvn

These two new functions create IV-and-PV dualvars, in similar style to
the other newSV*() family.

They are most convenient for wrapping error values from external
libraries, to create dual number/string values in a similar style to
core's $! wrapping of errno.

For example:

    int err = uv_...();
    if(err != 0) return newSVivpv(err, uv_strerr(err));

This makes the usual style of error-type dualvar that can both be tested
for numerical equality and additionally used as a string to yield its
human-readable error message

    croak "Unable to complete: $err" unless $err == UV::UV_EAGAIN;


  Commit: 5fff328743f855c27ef058b9a2e7496b1cc57e61
      https://github.com/Perl/perl5/commit/5fff328743f855c27ef058b9a2e7496b1cc57e61
  Author: Paul "LeoNerd" Evans <leonerd@leonerd.org.uk>
  Date:   2020-05-26 (Tue, 26 May 2020)

  Changed paths:
    M handy.h

  Log Message:
  -----------
  Also add a newSVivpvs() macro to handy.h


Compare: https://github.com/Perl/perl5/compare/75be6036ec2d%5E...5fff328743f8



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About