Hello. Maybe offtopic, but there are convenient C++ Perl API (designed to use instead of perl native one) provided by XS::Framework; With this API it can be done as xs::Ref ref = sv1; xs::Sv value = sv2; ref.value(value); or (the same) Ref(sv1).value(sv2); ÑÑ, 18 маÑ. 2020 г. в 19:24, Paul "LeoNerd" Evans <leonerd@leonerd.org.uk>: > I'm trying to do the following in a bit of XS code: > > CV *cv = ...; > sv_setrv(get_sv("Some::Package::VAR", GV_ADD), (SV *)cv); > > this fails because there isn't an sv_setrv(). I vote it should be added. > > However, I'm struggling to find a sensible implementation for it. A > hacked-up version that does work just fine is: > > static void sv_setrv(SV *sv, SV *rv) > { > SV *tmp = newRV_noinc(rv); > sv_setsv(sv, tmp); > SvREFCNT_dec(tmp); > } > > but of course this is rather silly having to create and throw away that > `tmp`. > > I've tried hunting around perl core for various bits to copypaste, but > lots of tempting ideas end up containing macros that are #ifdef > PERL_CORE so I can't see them from XS. > > Can anyone suggest something better? > > -- > Paul "LeoNerd" Evans > > leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS > http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/ > -- Oleg Pronin, Crazy Panda LTDThread Previous | Thread Next