Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi everyone, I have started work on a module to interface the Lotus C API (Lotus Notes / Domino) from Perl. I want to store handles / error msg / other values using each object's IVX, NVX and/or PVX slots depending on the object. So, for example lets say I have this:
$ns = Notes::Session->new();
In the XS function I bless the reference into "Notes::Session", set flags and return it on the stack. I would like to put a global session count into that object's IVX slot and could then have another function to access it (say Notes::Session::session_count or $ns->session_count()). After having blessed the SV into a package (making it an "object") however, it seems I can't use any of the sv_set*v() functions to change those values as the object gets DESTROYed().
Is it possible to change an object's slots like this? If so, how?

Thanks and best regards, Christian Cloutier.

Replies are listed 'Best First'.
Re: XS Extending Question
by diotalevi (Canon) on Feb 17, 2003 at 23:49 UTC

    First see DominoPerl where I started work on this project. The best approach to this is likely via Inline::C over the C++ interface - it has most of the really nice convenience functions so you don't have to deal with composite data records directly (always a plus).

    The other part - you're abusing the object. Stop it. You'll want to have Notes::Session be a singleton object and quit it with doing all the work in XS. You'll be much happier if you just wrap the basic API using Inline::C or XS and delegate all the other stuff to perl code.

    About the referenced code - I'd like to pick it back up one of these days and I've described to you how I think it's best done. (as in, that's my web site I pointed you towards). Send me an e-mail if you want more detail. (or post another node. Whatever works)


    Seeking Green geeks in Minnesota