[Top][All Lists]

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

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

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

>>> So with other words no damage is done if I hijack #new for the creation
>>> purpose and leaving #initialize to the scripts only for code to setup
>>> their smalltalk type parameters.
>> Yeah, you can even hijack #basicNew (normally a primitive, but a cCall
>> is also a "primitive") and do the usual
>> new [ ^super new initialize ]
> I had a 50% chance of getting it right, and didn't.  I obviously meant
>     new [ ^self basicNew initialize ]
Got stumped :( . I forgot that the class I try to wrap right now is a
singleton. With other words in that case I need to assign a c-pointer
somehow to the class itself not the instance of it. But the class object
is created by smalltalk so I can't mess with it. In fact I need to hack
the class itself since using a cCall #new for an object I need to have
access to the wrapped engine already. Maybe that's not clear. So let's
make an example.

class STSomething which wrapps CSomething.
to create CSomething in c++ land I need a pointer to CEngine in c++
land. But when I assign a cCall for #new in STSomething I do not have
access to the CEngine pointer. For this to work I need the STSomething
class object to store the pointer to the CEngine so that once the cCall
#new is called on STSomething I can create the new object with a brand
new pointer to CSomething.

So basically I need to mess with the STSomething object. Can I do the
same hack you mentioned simply for STSomething like this?

Object subclass: STSomething [
    STSomething class [
        <shape: #byte>
        new [ <cCall: 'CSomething_new' returning: #void args: #(#self)> ]

Or is GST going to whip my ass for that?

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]