Well, not trivial -- you would have to be careful to reload the parameter state immediately after the call, since a GC could invalidate most pointers inside the prim, but such a solution would be nice, indeed. Indeed, even the ability to send a #value to a message block would be a nice toehold toward solving the problem. Once again, user needs to take care that pointers aren't invalidated between calls, but that's more a question of hygiene than functionality.
Of course, this begs the question. Why think small if we are really setting up means to embed Squeak into a C program or other system? Perhaps rather than doing this piecemeal, we should go full boat and set up a credible and complete API once for embedding once and for all? Now that Headless Squeaks are being constructed, something like this might be quite useful.
-----Original Message----- From: MIME :spair@advantive.com Sent: Thursday, April 29, 1999 1:22 PM To: squeak@cs.uiuc.edu Subject: RE: Calling methods from primitives
What if you altered the instruction pointer (IP) and stack pointer (SP; to push any parameters) and then called interpret? Would that work? Also, would the debugger be able to handle having the primitive context on the stack?
It seems to me if that would work, it should then be trivial to implement a macro for doing message sends from the VM (or pluggable prims).
- Stephen
-----Original Message----- From: stp@silcom.com [mailto:stp@silcom.com]On Behalf Of Stephen Pope Sent: Thursday, April 29, 1999 12:08 PM To: squeak@cs.uiuc.edu Subject: Re: Calling methods from primitives
Stephen Pair wrote:
Does anyone how to invoke a method on an object from within a
primitive? Is
there a way?
There's no direct and simple way to handle arbitrary "call-backs" from the VM into Smalltalk. I do it via Semaphores. You can easily register a semaphore as an external object, then signal it from a primitive. If you have a Smalltalk process waiting on the semaphore, it can do whatever it wants -- send a message, call another primitive, etc.
-- stp
Stephen Travis Pope stp@create.ucsb.edu http://www.create.ucsb.edu/~stp/
<< File: ENVELOPE.TXT >>
-----Original Message----- From: MIME :spair@advantive.com Sent: Thursday, April 29, 1999 1:22 PM To: squeak@cs.uiuc.edu Subject: RE: Calling methods from primitives
What if you altered the instruction pointer (IP) and stack pointer (SP; to push any parameters) and then called interpret? Would that work? Also, would the debugger be able to handle having the primitive context on the stack?
It seems to me if that would work, it should then be trivial to implement a macro for doing message sends from the VM (or pluggable prims).
- Stephen
-----Original Message----- From: stp@silcom.com [mailto:stp@silcom.com]On Behalf Of Stephen Pope Sent: Thursday, April 29, 1999 12:08 PM To: squeak@cs.uiuc.edu Subject: Re: Calling methods from primitives
Stephen Pair wrote:
Does anyone how to invoke a method on an object from within a
primitive? Is
there a way?
There's no direct and simple way to handle arbitrary "call-backs" from the VM into Smalltalk. I do it via Semaphores. You can easily register a semaphore as an external object, then signal it from a primitive. If you have a Smalltalk process waiting on the semaphore, it can do whatever it wants -- send a message, call another primitive, etc.
-- stp
Stephen Travis Pope stp@create.ucsb.edu http://www.create.ucsb.edu/~stp/
<< File: ENVELOPE.TXT >>
squeak-dev@lists.squeakfoundation.org