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

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

 --- James McCartney <asynth@xxxxxx> escribió: 

> There is a document on writing primitives:   
> SuperCollider3/doc/Primitives.rtf

 Ok. So for educational purposes, suppose i have a
library call like this:

ComplexStuff : BasicStuff {
    setMyArray { | array |
        array.size.do( {arg i;
              //setToArray should be the primitive
             this.setToArray(i , array.at(i));

So, on the other hand, i have the following in my

the library c++ code goes like


class ComplexStuff : public BasicStuff
 std::vector<BasicTrumpets> array;
 virtual void SetToArray(int index ,  BasicTrumpets&
    if (array.size()<=index)

So, now to the intrincate part: the binding call;
somehow i must declare

   int ComplexStuff_setToArray(struct VMGlobals* g,
int )
    PyrSlot* complexstuff_instance = g->sp - 2;
    PyrSlot* index = g->sp - 1;      
    PyrSlot* basicTrumpetinstance = g->sp;

 *((int*)(index)) ,
*((BasicTrumpet*)(basicTrumpetinstace)) );

  and finally;

 definePrimitive(base, index++,
"_ComplexStuff_setToArray" , ComplexStuff_setToArray ,
2, 0);

 Im probably got all those casts very badly, im sure
is not so simple, but it shows what im trying to do

 is this more or less how this works? It seem i still
cannot click well into the mechanism

Running on:
1.5 Ghz P4
asus v800x chipset
RH9 CCRMA-patched linux


¡Llevate a Yahoo! en tu Unifón! 
Ahora podés usar Yahoo! Messenger en tu Unifón, en cualquier momento y lugar. 
Encontrá más información en: http://ar.mobile.yahoo.com/sms.html