FAQ
# New Ticket Created by perlbug@plan9.de
# Please include the string: [perl #96872]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=96872 >



This is a bug report for perl from perlbug@plan9.de,
generated with the help of perlbug 1.39 running under perl 5.12.3.


-----------------------------------------------------------------
[Please describe your issue here]

lib/ExtUtils/typemap current defines CV * (T_CVREF) in terms of
scalar references to code:

if (SvROK(xsub_tmp_sv) && SvTYPE(SvRV(xsub_tmp_sv)) == SVt_PVCV){

However, this does not correlate well with how perl defines "thing you
call like a function", for example overloaded objects.

For some years now I use these functions to get a callable CV from an SV
(only s_get_cv is very relevant):

static SV *
s_get_cv (SV *cb_sv)
{
dTHX;
HV *st;
GV *gvp;

return (SV *)sv_2cv (cb_sv, &st, &gvp, 0);
}

static SV *
s_get_cv_croak (SV *cb_sv)
{
SV *cv = s_get_cv (cb_sv);

if (!cv)
{
dTHX;
croak ("%s: callback must be a CODE reference or another callable object", SvPV_nolen (cb_sv));
}

return cv;
}

Basically, it's a straightforward application of sv_2cv, which should be
both future-proof and very compatible, i.e. it gives me a CV for about
anything that I can call in perl, and certainly for any RV-to-CV, so is a
superset of what older typemaps do.



[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=core
severity=wishlist
---
Site configuration information for perl 5.12.3:

Configured by Marc Lehmann at Wed Feb 23 06:21:02 CET 2011.

Summary of my perl5 (revision 5 version 12 subversion 3) configuration:

Platform:
osname=linux, osvers=2.6.32-5-amd64, archname=x86_64-linux
uname='linux cerebro 2.6.32-5-amd64 #1 smp wed jan 12 03:40:32 utc 2011 x86_64 gnulinux '
config_args='-Duselargefiles -Duse64bitint -Dusemymalloc=n -Dstatic_ext=Fcntl -Dcc=gcc -Dccflags=-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -USITEARCH_EXP -USITELIB_EXP -UARCHLIB_EXP -D_GNU_SOURCE -I/opt/include -ggdb -gdwarf-2 -g3 -Doptimize=-O6 -fno-strict-aliasing -Dcccdlflags=-fPIC -Dldflags=-L/opt/perl/lib -L/opt/lib -Dlibs=-ldl -lm -lcrypt -lgdbm -Dprefix=/opt/perl -Dprivlib=/opt/perl/lib/perl5 -Darchlib=/opt/perl/lib/perl5 -Uusevendorprefix -Dsiteprefix=/opt/perl -Dsitelib=/opt/perl/lib/perl5 -Dsitearch=/opt/perl/lib/perl5 -Dsitebin=/opt/perl/bin -Dman1dir=/opt/perl/man/man1 -Dman3dir=/opt/perl/man/man3 -Dsiteman1dir=/opt/perl/man/man1 -Dsiteman3dir=/opt/perl/man/man3 -Dman1ext=1 -Dman3ext=3 -Dpager=/usr/bin/less -Uafs -Uusesfio -Uusenm -Uuseshrplib -Ud_dosuid -Dusethreads=undef -Duse5005threads=undef -Duseithreads=undef -Dusemultiplicity=undef -Demail=perl-binary@plan9.de -Dcf_email=perl-binary@plan9.de -Dcf_by=Marc Lehmann -Dlocincpth=/opt/perl/include /opt/incl
ude -Dmyhostname=localhost -Dmultiarch=undef -Dbin=/opt/perl/bin -Dxxxusedevel -DxxxDEBUGGING -Dxxxuse_debugging_perl -Dxxxuse_debugmalloc -dEs'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -USITEARCH_EXP -USITELIB_EXP -UARCHLIB_EXP -D_GNU_SOURCE -I/opt/include -ggdb -gdwarf-2 -g3 -fno-strict-aliasing -pipe -I/opt/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O6 -fno-strict-aliasing',
cppflags='-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -USITEARCH_EXP -USITELIB_EXP -UARCHLIB_EXP -D_GNU_SOURCE -I/opt/include -ggdb -gdwarf-2 -g3 -fno-strict-aliasing -pipe -I/opt/include'
ccversion='', gccversion='4.4.5', gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='gcc', ldflags ='-L/opt/perl/lib -L/opt/lib -L/usr/lib/x86_64-linux-gnu -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64 /usr/lib/x86_64-linux-gnu
libs=-ldl -lm -lcrypt -lgdbm
perllibs=-ldl -lm -lcrypt
libc=/lib/libc-2.11.2.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.11.2'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O6 -fno-strict-aliasing -L/opt/perl/lib -L/opt/lib -L/usr/lib/x86_64-linux-gnu -L/usr/local/lib'

Locally applied patches:


---
@INC for perl 5.12.3:
/root/src/sex
/opt/perl/lib/perl5
/opt/perl/lib/perl5
.

---
Environment for perl 5.12.3:
HOME=/root
LANG (unset)
LANGUAGE (unset)
LC_CTYPE=en_US.UTF-8
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/root/s2:/root/s:/opt/bin:/opt/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11/bin:/usr/games:/usr/local/bin:/usr/local/sbin:/root/pserv:.
PERL5LIB=/root/src/sex
PERL5_CPANPLUS_CONFIG=/root/.cpanplus/config
PERLDB_OPTS=ornaments=0
PERL_ANYEVENT_DBI_TESTS=1
PERL_ANYEVENT_EDNS0=1
PERL_ANYEVENT_NET_TESTS=1
PERL_ANYEVENT_PROTOCOLS=ipv4,ipv6
PERL_ANYEVENT_STRICT=1
PERL_BADLANG (unset)
PERL_UNICODE=E
SHELL=/bin/bash

Search Discussions

  • Steffen Mueller at Aug 12, 2011 at 5:16 pm

    On 08/12/2011 05:29 PM, perlbug @ plan9 . de wrote:
    # New Ticket Created by perlbug@plan9.de
    # Please include the string: [perl #96872]
    # in the subject line of all future correspondence about this issue.
    #<URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=96872>
    lib/ExtUtils/typemap current defines CV * (T_CVREF) in terms of
    scalar references to code:

    if (SvROK(xsub_tmp_sv)&& SvTYPE(SvRV(xsub_tmp_sv)) == SVt_PVCV){

    However, this does not correlate well with how perl defines "thing you
    call like a function", for example overloaded objects. [...]
    Basically, it's a straightforward application of sv_2cv, which should be
    both future-proof and very compatible, i.e. it gives me a CV for about
    anything that I can call in perl, and certainly for any RV-to-CV, so is a
    superset of what older typemaps do.
    For what it's worth, I can't see a problem with this, have used similar
    functions for the same purpose, and am all in favour of modifying the
    typemap accordingly.

    If nobody opposes, I'll modify the typemap. No promises that I won't
    forget, though.

    Best regards,
    Steffen
  • Father Chrysostomos via RT at May 22, 2012 at 6:08 am

    On Fri Aug 12 10:16:55 2011, smueller@cpan.org wrote:
    On 08/12/2011 05:29 PM, perlbug @ plan9 . de wrote:
    # New Ticket Created by perlbug@plan9.de
    # Please include the string: [perl #96872]
    # in the subject line of all future correspondence about this issue.
    #<URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=96872>
    lib/ExtUtils/typemap current defines CV * (T_CVREF) in terms of
    scalar references to code:

    if (SvROK(xsub_tmp_sv)&& SvTYPE(SvRV(xsub_tmp_sv)) == SVt_PVCV){

    However, this does not correlate well with how perl defines "thing you
    call like a function", for example overloaded objects. [...]
    Basically, it's a straightforward application of sv_2cv, which should be
    both future-proof and very compatible, i.e. it gives me a CV for about
    anything that I can call in perl, and certainly for any RV-to-CV, so
    is a
    superset of what older typemaps do.
    For what it's worth, I can't see a problem with this, have used similar
    functions for the same purpose, and am all in favour of modifying the
    typemap accordingly.

    If nobody opposes, I'll modify the typemap. No promises that I won't
    forget, though.
    Did you ever make this change? It seems to ring a bell.

    --

    Father Chrysostomos


    ---
    via perlbug: queue: perl5 status: open
    https://rt.perl.org:443/rt3/Ticket/Display.html?id=96872
  • Eric Brine at May 22, 2012 at 6:56 am

    On Tue, May 22, 2012 at 2:07 AM, Father Chrysostomos via RT wrote:
    On Fri Aug 12 10:16:55 2011, smueller@cpan.org wrote:
    If nobody opposes, I'll modify the typemap. No promises that I won't
    forget, though.
    Did you ever make this change? It seems to ring a bell.
    It wasn't committed to blead if so.

    T_CVREF
    STMT_START {
    SV* const xsub_tmp_sv = $arg;
    SvGETMAGIC(xsub_tmp_sv);
    if (SvROK(xsub_tmp_sv) && SvTYPE(SvRV(xsub_tmp_sv)) == SVt_PVCV){
    $var = (CV*)SvRV(xsub_tmp_sv);
    }
    else{
    Perl_croak(aTHX_ \"%s: %s is not a CODE reference\",
    ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
    \"$var\");
    }
    } STMT_END
    T_CVREF_REFCOUNT_FIXED
    STMT_START {
    SV* const xsub_tmp_sv = $arg;
    SvGETMAGIC(xsub_tmp_sv);
    if (SvROK(xsub_tmp_sv) && SvTYPE(SvRV(xsub_tmp_sv)) == SVt_PVCV){
    $var = (CV*)SvRV(xsub_tmp_sv);
    }
    else{
    Perl_croak(aTHX_ \"%s: %s is not a CODE reference\",
    ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
    \"$var\");
    }
    } STMT_END
  • Steffen Mueller at May 22, 2012 at 4:07 pm

    On 05/22/2012 08:56 AM, Eric Brine wrote:
    On Tue, May 22, 2012 at 2:07 AM, Father Chrysostomos via RT
    wrote:

    On Fri Aug 12 10:16:55 2011, smueller@cpan.org
    wrote:
    If nobody opposes, I'll modify the typemap. No promises that I won't
    forget, though.
    Did you ever make this change? It seems to ring a bell.


    It wasn't committed to blead if so.
    Then I most certainly failed to follow through. Apologies to everyone
    involved. :(

    Running tests now, but I probably won't be able to commit anything
    before tomorrow.

    Would the following naive change work?

    STMT_START {
    HV *st;
    GV *gvp;
    SV * const xsub_tmp_sv = $arg;
    SvGETMAGIC(xsub_tmp_sv);
    $var = sv_2cv(xsub_tmp_sv, &st, &gvp, 0);
    if (!$var) {
    Perl_croak(aTHX_ \"%s: %s is not a CODE reference\",
    ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
    \"$var\");
    }
    } STMT_END

    --Steffen
  • Father Chrysostomos via RT at May 22, 2012 at 6:12 pm

    On Tue May 22 09:07:31 2012, smueller@cpan.org wrote:
    On 05/22/2012 08:56 AM, Eric Brine wrote:
    On Tue, May 22, 2012 at 2:07 AM, Father Chrysostomos via RT
    wrote:

    On Fri Aug 12 10:16:55 2011, smueller@cpan.org
    wrote:
    If nobody opposes, I'll modify the typemap. No promises that
    I won't
    forget, though.
    Did you ever make this change? It seems to ring a bell.


    It wasn't committed to blead if so.
    Then I most certainly failed to follow through. Apologies to everyone
    involved. :(

    Running tests now, but I probably won't be able to commit anything
    before tomorrow.

    Would the following naive change work?

    STMT_START {
    HV *st;
    GV *gvp;
    SV * const xsub_tmp_sv = $arg;
    SvGETMAGIC(xsub_tmp_sv);
    $var = sv_2cv(xsub_tmp_sv, &st, &gvp, 0);
    if (!$var) {
    Perl_croak(aTHX_ \"%s: %s is not a CODE reference\",
    ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
    \"$var\");
    }
    } STMT_END
    I believe so. It would also allow globs, but that’s probably a good
    thing, for consistency’s sake. In other words, it will be Just Like &{...}

    --

    Father Chrysostomos


    ---
    via perlbug: queue: perl5 status: open
    https://rt.perl.org:443/rt3/Ticket/Display.html?id=96872
  • Steffen Mueller via RT at May 22, 2012 at 9:06 pm
    Change applied as 8465c88d321256783d00b03482a840dab3ad16be. Sorry again
    for dropping the ball on this before and thanks for the reminder.

    Best regards,
    Steffen

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupperl5-porters @
categoriesperl
postedAug 12, '11 at 3:29p
activeMay 22, '12 at 9:06p
posts7
users4
websiteperl.org

People

Translate

site design / logo © 2022 Grokbase