[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] Using Smalltalk as a scripting language

From: Roland Plüss
Subject: Re: [Help-smalltalk] Using Smalltalk as a scripting language
Date: Thu, 29 Oct 2009 00:24:22 +0100
User-agent: Thunderbird (X11/20090926)

>> How is this class registered. Meaning how does gst know about the new
>> class? It's written there that you define a class in smalltalk as in the
>> example. But where is the gluing made between the c struct and the
>> appropriate smalltalk class?
> You load a file containing the Smalltalk class before the user's files
> (or you create an image after loading that file, which is the same).
>> How do I register a method in a class which
>> is a c function?
> On the C side you use defineCFunc, on the Smalltalk side (in the same
> file as above) you use <cCall: 'foo' ...> as described in the manual.
> Each binding has two sides, a C side and a Smalltalk side.  A simple
> one is the MD5/SHA1 binding in packages/digest.
> Regarding your other message:
I tried this and stumbled across a problem. Let's say I have a c++ class
which contains c stuff especially a pointer to the game engine. Now I
want to provide a wrapper to smalltalk for this. To begin with I make it
simple and want to make a class DEEngine which only exposes a method
#quit which shuts down the engine. This would be a class side method
since it's a singleton class. Now  I have to register a c function using
    gst_define_cfunc( "stClassEngine.ccQuit", ccQuit )
where ccQuit is defined as
    static void ccQuit( OOP self )
inside the stClassEngine class. I put OOP self there since did not see
any way for the c function to know otherwise which object received the
message. Now how to I attach personal data to a smalltalk object? So if
I define the class DEEngine in smalltalk script and this script is
parsed the VM is going to create an instance of this class. But this
class has no knowledge about the pointer to the game engine but calling
ccQuit requires the engine pointer to be present. I had a similar
problem when I messed with Python and there I had to make a singleton
keeping all the pointers so I can access it. That's not really object
oriented programming at all. Is there a way in smalltalk to defined sort
of private memory space inside an object so I can put custom data into
it or do I have to make the same mess as in Python?

To my understanding I can access smalltalk code using the trick written
.That though only allows access to object data the way smalltalk
allocates it. If there would be a way to attach some sort of unused data
after the smalltalk internal data I could force my stuff into a
smalltalk object. Any way to pull that off?

Yours sincerely
Plüss Roland

Leader and Head Programmer
- Game: Epsylon ( , )
- Game Engine: Drag(en)gine ( , )
- Normal Map Generator: DENormGen ( )

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]