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

Re: [sc-dev] SC -> c++ interface



on 2004-11-23 16:45:18 -0300, Charlls Quarra wrote:
> I see in SCUM_Prim.cpp that you define some primitives
> as "_SCUM_View_DoSomething". Is this simply a naming
> convention or the _ are translated as some member 
> operator into the sc language? I see a similar pattern
> in the LangPrimSource

just a naming convention.

>  Anyhow, this name you feed into the definePrimitive
> call is not the same name that those primitives are
> known from the sc language. Where the actual names (sc
> names of the primitives) are stored?

the name you pass to definePrimitive is what sclang
uses to resolve primitives; it's the key into a lookup table
to retrieve the address of the actual primitive.

so e.g.

definePrimitive(
    base, index++,                 // book keeping
    "_SCUM_Object_SetProperty",    // primitive name
    SCUM_Prim::Object_SetProperty, // function address
    3,                             // num args
    0                              // num varargs
    );

corresponds to

prSetProperty { | key, value |
    _SCUM_Object_SetProperty
    ^this.primitiveFailed
}

the number of required arguments is three because the
receiver is passed on the stack, too.

<sk>