Slang - self primitive: parameters:

Brad Fuller brad at sonaural.com
Wed Dec 14 02:03:02 UTC 2005


Brad Fuller wrote:

> Hello all,
>
> I'm trying to generate a 'ulong' in Slang using the "self primitive: 
> parameters:" method.
>
>    self primitive: 'primitivePutOutputParms'
>        parameters: #(#SmallInteger #SmallInteger #Unsigned #Float 
> #String).
>
> But, I don't know how.  #Float generates a double and SmallInteger 
> generates "int".  What are the other ones? Is this a dictionary?
> When I use #Unsigned it generates:
>
>    int parm2;
>
>    
> interpreterProxy->success(interpreterProxy->isKindOf(interpreterProxy->stackValue(2), 
> "Unsigned"));
>    parm2 = interpreterProxy->stackValue(2);
>
> which I don't think I want, do I?
>
> Also, does anyone know how to generate void pointer?: (void *)?

Further to add to this thread:

I need to return a char pointer from a primitive back to Squeak, but I 
can't find out how to do it in Slang. Can anyone give me pointers?


Using:
self returnTypeC: 'char *'
works great for the return of a routine, but I need the return value to 
be pushed on the stack for return back to Squeak.

what I have is this which doesn't work quite right.. (primarily because 
I can't quite get the whole idea of this):

primitiveGetText
    | text |

    self var: #text declareC: 'char *text'.
    self primitive: 'primitiveGetText'.
    text := self cCode: 'GetText()'.
    ^text asValue: String.

Which results in:

EXPORT(int) primitiveGetText(void) {
    char *text;
    int _return_value;

    text = GetText();
    _return_value = ((char *) interpreterProxy->firstIndexableField(text));
    if (interpreterProxy->failed()) {
        return null;
    }
    interpreterProxy->popthenPush(1, _return_value);
    return null;
}

I've been fooling with this all day.. getting frustrating!

thanks,
brad



More information about the Vm-dev mailing list