Mailing List Archive

Nested perl contexts
Could a kind soul please help me with the following problem:

I am trying to run multiple nested perl contexts, about like
this simplified pseudo code:

outerPerl= malloc(sizeof(PerlInterpreter));
perl_construct(outerPerl);
perl_parse(outerPerl,xs_init,argc,argv,environ);
perl_run(outerPerl);

[.lots of other things, that call functions in
the outerPerl context, and also:

innerPerl= malloc(sizeof(PerlInterpreter));
perl_construct(innerPerl);
perl_parse(innerPerl,xs_init,argc,argv,environ);
perl_run(innerPerl);

[more stuff that calls functions in innerPerl]

perl_destruct(innerPerl);
perl_free(innerPerl);

curinterp=outerPerl;

At this point, things in the outerPerl context don't
work anymore.

Of course perl is compiled with MULTIPLICITY, and I made
changes to perl_run, so that calllist(endav) gets delayed
till before perl_destruct().

What I think I have to do is execute part of perl_run()
again, but my understanding of the inner workings of perl
doesn't seem to be good enough yet to figure it out. I
suspect it has to do with setjmp()...

Please, any pointer anyone?

Gerd Knops
Re: Nested perl contexts [ In reply to ]
Some more info: After deleting the inner perl instance, and switching
back to the outer instance, the following code:

dSP ;
PUSHMARK(sp) ;
XPUSHs(sv_2mortal(newSVpv((char *)className,0)));
PUTBACK ;
perl_call_pv("main::objc",G_EVAL|G_DISCARD);

fails to deliver the argument to the perl function! The function gets
executed, but 'className' does not show up. The same code works fine,
when called before the inner instance was used. This leads me to
believe, that somewhere in perl_call_pv some ptr or whatever is used,
that got modified by the inner perl instance, and not set back.

Tracing through the code, I did not find anything yet.

Any help, ideas, pointers would be very appretiated.

Gerd Knops


Begin forwarded message:

From: Gerd Knops <gerti@BITart.com>
Date: Thu, 5 Oct 95 18:57:15 -0500
To: perl5-porters@africa.nicoh.com
Subject: Nested perl contexts
Reply-To: gerti@BITart.com
Sender: owner-perl5-porters@nicoh.com
List-Name: perl5-porters

Could a kind soul please help me with the following problem:

I am trying to run multiple nested perl contexts, about like
this simplified pseudo code:

outerPerl= malloc(sizeof(PerlInterpreter));
perl_construct(outerPerl);
perl_parse(outerPerl,xs_init,argc,argv,environ);
perl_run(outerPerl);

[.lots of other things, that call functions in
the outerPerl context, and also:

innerPerl= malloc(sizeof(PerlInterpreter));
perl_construct(innerPerl);
perl_parse(innerPerl,xs_init,argc,argv,environ);
perl_run(innerPerl);

[more stuff that calls functions in innerPerl]

perl_destruct(innerPerl);
perl_free(innerPerl);

curinterp=outerPerl;

At this point, things in the outerPerl context don't
work anymore.

Of course perl is compiled with MULTIPLICITY, and I made
changes to perl_run, so that calllist(endav) gets delayed
till before perl_destruct().

What I think I have to do is execute part of perl_run()
again, but my understanding of the inner workings of perl
doesn't seem to be good enough yet to figure it out. I
suspect it has to do with setjmp()...

Please, any pointer anyone?

Gerd Knops