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

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

On Tue, Nov 23, 2004 at 10:40:55AM -0300, Charlls Quarra wrote:
> Im trying to implement a color for each channel in a
> scope. So i have the following method insice the
> SCUMScope class
>     setChannelsColors { | array |
>         array.size.do( {arg i;
>              this.setChannelColor(i , array.at(i));
>            }
>          )
>     }
> So, i am calling the C++ method from the sc class, but
> when i do it says the 'setChannelColor' message not
> understood (the C++ class)

this is a fundamental misunderstanding. sclang doesn't know
zilch about c++ classes, methods, variables etc. in order to
make native code available to the language runtime, you have
to write a 'primitive', which is a wrapper function that
adheres to a certain calling convention, make the primitive
available by name with definePrimitive and call the
primitive from sclang as in:

prMyMethod {

> > depending on what you want to do it might be better
> > to
> > implement your method as a property/attribute in
> > SCUM_Scope::setProperty.

what you really want is a property, e.g. channelColors, that
is handled in setProperty. you'll have to decode an array of
Color objects in the primitive, store the information in a
member variable and use it in SCUM_Scope::drawGL().