TestInterpreterPlugin help

Stephan Rudlof sr at evolgo.de
Sat Jan 12 20:31:22 UTC 2002


Joshua,

Joshua 'Schwa' Gargus wrote:
> 
> Hi Stephan,
> 
> Thanks for replying from your hotel,
> 
> On Wed, Jan 09, 2002 at 11:47:59PM +0100, Stephan Rudlof wrote:
> > Somewhat late, since I'm sitting in a hotel (working outside and had big
> > problems to connect...), but here are a few hints:
> >
> > Joshua 'Schwa' Gargus wrote:
> > >
> > > Hello,
> > >
> > > I'm having trouble passing around a pointer between interpreted Squeak
> > > code and compiled plugin code.  I have a primitive method that returns
> > > a pointer like this:
> > >
> > > ^ aPtr asOop: Unsigned
> > >
> > > This seems to work fine; depending on the value, I get either a
> > > SmallInteger or a LargePositiveInteger.  The problem arises when I try
> > > to pass this into another primitive method that looks like this:
> > >
> >
> > > primNeedPointer: aPtr
> > >
> > >     self
> > >         primitive: 'primNeedPointer'
> > >         parameters: #(Unsigned)
> > >     "more stuff..."
> > >
> > > The generated C code causing the failure is:
> > >
> > > interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(0), "Unsigned"));
> > >
> > > Looking at the code for isKindOf(), it is clear why it fails: the
> > > object (a SmallInteger or LargePositiveInteger) is not an instance
> > > of Unsigned or one of its subclasses.
> >
> > You could use "Integer" here.
> >
> > But there is another problem: if you have a LargeInteger as 'ptr' its oop
> > may have changed between the calls of the two prims.
> 
> I suppose that this is because of a possible garbage collection.

Correct.

> However, I'm
> failing to see why this is a problem, since the value of the LargeInteger would
> be the same even if its oop changed.

This is true.

> Could you clarify exactly what the problem
> is?

I have to admit that I have seen the wrong ghosts here...

But there is another one:
Your example has given the impression to me (this may be wrong) that you try
to hold a C ptr as SmallInteger or LargePositiveInteger in ST between the
calls of these two prims. If it is a SmallInteger you could use
	interpreterProxy->integerValueOf: oop
to transform it back into the C ptr, because its oop is directly
transformable into its value.
For a LargePositiveInteger this wouldn't work, because its oop has nothing
to do with its value.

Probably you know it yet.


Greetings,

Stephan

> ...

PS: Currently I don't *receive* any mail (problems with provider), so please
be patient if there should be another question...
-- 
Stephan Rudlof (sr at evolgo.de)
   "Genius doesn't work on an assembly line basis.
    You can't simply say, 'Today I will be brilliant.'"
    -- Kirk, "The Ultimate Computer", stardate 4731.3




More information about the Squeak-dev mailing list