in reply to SV creation inside XS

You're making the same mistake I (and others) made. That of assuming that newSVrv() creates a new RV that points to the SV passed to it as an argument. It doesn't.

The documentation for the call reads:

newSVrv

Creates a new SV for the RV, rv, to point to. If rv is not an RV then it will be upgraded to one. If classname is non-null then the new SV will be blessed in the specified package. The new SV is returned and its reference count is 1.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
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.

Replies are listed 'Best First'.
Re^2: SV creation inside XS
by llancet (Friar) on Nov 07, 2011 at 01:01 UTC
    Got it!
    But what should I do if I want to bless an exist HV to some package? For instance, if the HV is from somewhere else, and I want to bless it into xstest package...

      Search perlapi for sv_bless()

      sv_bless

      Blesses an SV into a specified package. The SV must be an RV. The package must be designated by its stash (see gv_stashpv() ). The reference count of the SV is unaffected.

      SV* sv_bless(SV* sv, HV* stash)

      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      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.
        Is it harmful if I bless a blessed object? If it is, I need some way to know whether my referent is blessed. However, "sv_isobject" works on a reference. Is there any similar thing works on a referent?