Otherwise I have to create a temporary wrapper each time I need such operation, which seemingly not quite necessary:

As I said: "(Doesn't make a whole bunch of sense to me,".

In theory, you should be able to test the appropriate flag bit directly:

0x00100000 SVs_OBJECT

This flag is set when the object is "blessed". It can only be set for value type SvPVMG or subtypes of it. This flag also indicates that the STASH pointer is valid and points to a namespace HV.

But I cannot find any macro for accessing it, and direct access is frowned upon. That said, it seems unlikely that the flags word is going to change much, so it is a possibility.

But that said, the way you will normally gain access to your objects is through your functions having been passed an argument. Which will usually, if not always, be an RV that references it. In that case, you wouldn't have to create another Rv as you shoudl still have access to the one passed to you.

The only other case I can think of is when the object has just been created (ie. in new() or equivalent.), at which point you will (should) know whether you have already blessed it. Also, you would have to create an RV before returning it to the caller, so there would be no need for a temporary one.

I think that to make headway, you would have to show the circumstances (ie.code) where have the object but no RV and need to determine if it has already been blessed?


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.

In reply to Re^7: SV creation inside XS by BrowserUk
in thread SV creation inside XS by llancet

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.