<br><br><div class="gmail_quote">On Wed, May 19, 2010 at 7:50 AM, Ang BeePeng <span dir="ltr">&lt;<a href="mailto:beepeng86@yahoo.com">beepeng86@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Hi,<br>
<br>
Many thanks for helps that I get, I&#39;m able to store objects in Squeak.dll<br>
and use it with a exteranl program, main.exe.<br>
<br>
Now I have Squeak.dll responding to main.exe. Say if I need a line, with<br>
startPoint, endPoint, colour etc.. I will ask Squeak.dll to create an object<br>
from Class Line, return the pointer to exe. While in exe, line is a struct<br>
that have sqPointer, startPoint, endPoint, etc.<br>
<br>
Say if I have a function that ask Squeak to move the line. Squeak<br>
object(line) will then move, and instance variable endPoint will be change.<br>
There, Squeak should notify exe to update its value.<br>
<br>
What should I do to achieve that? Simple variable pass in? or maybe<br>
call-back? Event notification?<br></blockquote><div><br></div><div>Use &quot;sendbacks&quot;.  When I did this for VisualWorks I had an interface that comprised a small set of external handles for Smalltalk objects and a send message entry-point.  Given a handle on Smalltalk Symbol nil and #findInterned: and a mapping from C strings to Smalltalk strings one can access any class or selector in the system.  e.g. to evaluate</div>
<div>    MyClass doSomething</div><div>you can say</div><div>    myClassName = vmSendMessage1(vmSymbolClass, vmFindInternedColonSelector, vmAsSmalltalkString(&quot;MyClass&quot;));</div><div>    doSomethingSelector = vmSendMessage1(vmSymbolClass, vmFindInternedColonSelector, vmAsSmalltalkString(&quot;doSomethingSelector&quot;));</div>
<div>    if (myClassName == vmNil || doSomethingSelector == vmNil) abort();</div>    atSelector = vmSendMessage1(vmSymbolClass, vmFindInternedColonSelector, vmAsSmalltalkString(&quot;at:&quot;));<div>    myClass = vmSendMessage1(vmSmalltalk, atSelector, myClassName);</div>
<div>    vmSendMessage0(myClass, doSomethingSelector);</div><div>etc.</div><div><br></div><div>You can make things easier by providing a slightly broader interface (I included handles for at: and includesKey:) and by providing utility wrappers, e.g. lookupSelector or (as the VW interface already does) vmSendCMessage which looks like:</div>
<div><br></div><div><div>   myClassName = vmSendCMessage1(vmSymbolClass, &quot;findInterned:&quot;, vmAsSmalltalkString(&quot;MyClass&quot;));</div><div>    if (myClassName == vmNil) abort();</div><div>    myClass = vmSendCMessage1(vmSmalltalk, &quot;at:&quot;, myClassName);</div>
<div>    vmSendCMessage0(myClass, &quot;doSomething&quot;);</div><div><br></div><div>You can implement sendbacks above callbacks.  For callbacks look at the Alien code or Igor&#39;s recent code.</div><div><br></div><div>In the above in my VisualWors prototype the VM managed a handle table such that the handles handed out to C did not move and are looked up by the mapping machinery in the VM to map them to Smalltalk objects.  Much more convenient than addGCRoot: but slower.  The table was reference counted to manage lifetimes.  The handle of an immediate (Character or SmallInteger) was the immediate itself so only non-immediates actually appeared in the external oop table.</div>
<div><br></div><div>HTH</div><div>Eliot</div><div><br></div><div><br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Thanks for your valuable opinion.<br>

<br>
Ang Beepeng<br>
<font color="#888888">--<br>
View this message in context: <a href="http://forum.world.st/Passing-value-to-external-program-tp2222974p2222974.html" target="_blank">http://forum.world.st/Passing-value-to-external-program-tp2222974p2222974.html</a><br>

Sent from the Squeak - Dev mailing list archive at Nabble.com.<br>
<br>
</font></blockquote></div><br>