develooper Front page | perl.perl5.porters | Postings from January 2018

CvNAME_HEK_set() - public API?

Thread Next
From:
Paul "LeoNerd" Evans
Date:
January 24, 2018 02:05
Subject:
CvNAME_HEK_set() - public API?
Message ID:
20180124020526.34063cf3@shy.leonerd.org.uk
I'm trying to reïmplement the general spirit of cv_clone() but
specifically for my different use-case in Future::AsyncAwait; the chunk
of code I copypasted from pad.c in this case is

  if(CvNAMED(orig))
    CvNAME_HEK_set(new, share_hek_hek(CvNAME_HEK(orig)));
  else
    CvGV_set(new, CvGV(orig));

I notice that `CvNAME_HEK_set()` is available in cv.h, and feels the
sort of macro that would be public API.

I also notice that it doesn't work. Its definition calls
`unshare_hek()`, which embed.h only defines inside #ifdef PERL_CORE,
meaning it's not visible to XS users. If I simply steal the one-line

  #define unshare_hek(a)          Perl_unshare_hek(aTHX_ a)

then it appears to work fine, but it makes me feel cautious.

A quick stare around Sub::Util's set_subname implementation doesn't
reveal anything involving HEKs, only GVs, so I don't seem to be able to
gain any insight there.

Should I be using this API?

-- 
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About