[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.sc::::::::::
ComplexStuff : BasicStuff {
.....
setMyArray { | array |
array.size.do( {arg i;
//setToArray should be the primitive
call
this.setToArray(i , array.at(i));
}
)
}
.....
}
So, on the other hand, i have the following in my
library
the library c++ code goes like
:::::::ComplexStuff.h:::::::::
class ComplexStuff : public BasicStuff
{
std::vector<BasicTrumpets> array;
......
virtual void SetToArray(int index , BasicTrumpets&
u)
{
if (array.size()<=index)
array.resize(index+1);
array[index]=u;
}
}
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;
((ComplexStuff*)complexstuff_instance)->setToArray(
*((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
256Mb
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