in reply to How to extract/set RV information?

I don't have experience linking Perl "guts" to C++ "guts". I am wondering about the I/F between Perl and C++ and the functional partitioning? My first thought would be to not use any machine specific or low level stuff at all, but rather use a text based I/F protocol across these pipes.

It would also be helpful if you could just post as simple of a set of code that you can that demonstrates the problem.

Replies are listed 'Best First'.
Re^2: How to extract/set RV information?
by gszczesz (Novice) on Jun 09, 2009 at 13:19 UTC
    As an example, after running some perl code and retrieving the returned SV off the stack, I can extract a long value from it by running:

    long value = SvIVx( thesv );

    If I want to pass the long value back to my perl program, I can put it inside an SV by running the following:

    SV* newsv = newSViv(long_in);

    Same goes for double and string values. It is relativelly easy to extract them form the SV, pass it along to other programs, and then put it back into an SV.

    No idea how to do the same for a reference, RV.

    Greg

      I don't have an answer right now, but I do have a recommendation: buy "Advanced Perl Programming" by S. Srinivasan. The discussion of Perl Value Types starts on page 328. HV's are discussed starting on page 337. Pages 328-350 are "not particularly easy", but are understandable with C knowledge.