in reply to XS: SvPVLV examples?

You might have some luck decompiling the core XS modules, and greping them for PVLV. Maybe that will provide some more hints and examples...

(you may have already tried this, but thought i'd offer my 2cents anyway given the few responses so far... )

Replies are listed 'Best First'.
Re^2: XS: SvPVLV examples?
by BrowserUk (Patriarch) on Sep 25, 2009 at 01:42 UTC

    Well, the architypical examples are pp_substr and pp_vec.

    The latter is the simpler of the two, but I'm confused somewhat by the "TARG" which suddenly comes into existance and seems to be the basis for everything else. Sometimes it is used as-is (ie.in the state it magically appears in when the subroutine is called); sometimes it is upgraded to a PVLV and has magic attached to it; sometimes it is ignored (or discarded?) in favour of a newmortal SV.

    There is also stuff in there about opcodes and opcode states which muddies things further. That why I was hoping to find a non-core example of someone doing it. I assume(d) it would be simpler.

    But maybe there are no non-core examples, because noone else can work out how to do it either. TARG barely rates a mention in any of the documentation I've seen.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      substr and vec are special in the fact that they are lvalue functions.

      ref returns "LVALUE" for references to PVLV variables (except it lies SCALAR for tied scalars), so it's clear "LV" refers to "lvalue".

      PVLV adds the following fields to its "base class", PVMG (scalar with magic):

      STRLEN xlv_targoff; STRLEN xlv_targlen; SV* xlv_targ; char xlv_type; /* k=keys .=pos x=substr v=vec /=join/re * y=alem/helem/iter t=tie T=tied HE */

      The extra fields only have meaning to the associated magic handlers (found in mg.c).

        I know.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.