in reply to Re^2: ExtUtils::ParseXS has changed
in thread ExtUtils::ParseXS has changed

...has a pointless typemap entry for 'PDL_Long *'... has no INPUT or OUTPUT ...

I don't think there is any tricking going on

The default typemap has

T_PTR $var = INT2PTR($type,SvIV($arg))

I don't think it needs INPUT/OUTPUT

Since PDL_Long * pos is the RETVAL, and the return type is SV*, you need a typemap entry

You might not need it if you specified T_PTR as return type

T_PTR at_c(x,position) pdl* x PDL_Long * pos = NO_INIT CODE: // code that does stuff OUTPUT: RETVAL

I would test it, but, PDL takes a while to compile :)

Replies are listed 'Best First'.
Re^4: ExtUtils::ParseXS has changed
by syphilis (Archbishop) on Aug 17, 2011 at 08:18 UTC
    Since PDL_Long * pos is the RETVAL

    I don't think so.
    That //code... stuff specifies SET_RETVAL_NV(x); which I think does *not* set pos to the RETVAL.
    Afaik at no stage does a 'PDL_Long *' get passed from perl to XS (or vice-versa) which is precisely why there should be no need for any typemap entry for 'PDL_Long *'.

    I also find that it doesn't matter whether the typemap has:
    PDL_Long * T_PTR
    or
    PDL_Long * T_FOO
    I suspect you could specify just about anything.

    And why would we need this typemap entry only with ExtUtils-ParseXS-3.0x ?
    Even perl-5.14.1 ships with version 2.2210 - and it doesn't require any typemap entry.

    I would test it, but, PDL takes a while to compile

    Like I said, it doesn't take long to hit the error - about 1 minute into the 'make' stage is all it takes to find out what works and what doesn't. The thing that takes most time is the running of 'make realclean' between successive attempts :-)

    Cheers,
    Rob

      Since PDL_Long * pos is the RETVAL

      I don't think so...

      Reading http://perldoc.perl.org/perlxs.html#The-NO_INIT-Keyword again, I see I have misread

      After checking the generated Basic/Core/Core.c, I'm guessing it is an regression

      Also, it seems to me that any initializations using NO_INIT need to go after CODE

        Reading http://perldoc.perl.org/perlxs.html#The-NO_INIT-Keyword again, I see I have misread

        When I read that link it seems to me that the current PDL code is totally misusing the NO_INIT keyword.
        Looks to me that the variable 'pos' is simply a variable that has a value assigned to it - which, one suspects, is (by itself) insufficient to make it an "output" variable at all.

        Also, it seems to me that any initializations using NO_INIT need to go after CODE

        No, it needs to go *before* CODE. (Perhaps that's what you meant.) With both 2.2210 and 3.03, when I put PDL_Long * pos = NO_INIT; in the CODE section I get an error such as:
        Core.xs:673: error: `NO_INIT' undeclared (first use in this function)
        Cheers,
        Rob

        Update: This has now reached the point where I'm thinking I should probably present the function in its entirety. So here it is as it currently appears in Core.xs (which is autogenerated from Core.xs.PL):
        SV * at_c(x,position) pdl* x PDL_Long * pos = NO_INIT CODE: int npos, ipos; double result; pdl_make_physvaffine( x ); pos = pdl_packdims( ST(1), &npos); if (pos == NULL || npos < x->ndims) croak("Invalid position"); /* allow additional trailing indices * which must be all zero, i.e. a * [3,1,5] piddle is treated as an [3,1,5,1,1,1,....] * infinite dim piddle */ for (ipos=x->ndims; ipos<npos; ipos++) if (pos[ipos] != 0) croak("Invalid position"); result=pdl_at(PDL_REPRP(x), x->datatype, pos, x->dims, (PDL_VAFFOK(x) ? x->vafftrans->incs : x->dimincs), PDL_REPROFF +S(x), x->ndims); SET_RETVAL_NV(x) ; OUTPUT: RETVAL
        To reiterate - that will work fine as is with 2.2210, but only works with 3.03 if there is a typemap entry for 'PDL_Long *'. (With 3.03 it doesn't seem to matter what that typemap entry specifies - as long as there is one.)
        If I don't amend the typemap, then to make that Core.xs work with both 2.2210 and 3.03 I have to remove the PDL_Long * pos = NO_INIT and begin the CODE section with a PDL_Long * pos; declaration.