Commit 96fc764d authored by thomas's avatar thomas
Browse files

optimizations around method registration

git-svn-id: https://svn.grrrr.org/ext/trunk@1155 4d9ac71a-51e6-0310-8455-cad1006bcd31
parent 792189e4
......@@ -52,8 +52,8 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#ifdef FLEXT_ATTRHIDE
#ifndef __FLEXT_CLONEWIDGET
static void (*ori_vis)(t_gobj *c, t_glist *, int vis) = NULL;
static void (*ori_select)(t_gobj *c, t_glist *, int state) = NULL;
static t_visfn ori_vis = NULL;
static t_selectfn ori_select = NULL;
#endif
#endif
......
......@@ -2,7 +2,7 @@
flext - C++ layer for Max/MSP and pd (pure data) externals
Copyright (c) 2001-2005 Thomas Grill (gr@grrrr.org)
Copyright (c) 2001-2006 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
......@@ -840,8 +840,7 @@ protected:
static void ToSysMsg(MsgBundle *mb);
// add class method handlers
static void AddMessageMethods(t_class *c);
static void AddSignalMethods(t_class *c);
static void AddMessageMethods(t_class *c,bool dsp);
private:
class pxbnd_object;
......@@ -982,6 +981,12 @@ private:
void BinbufAttr(t_binbuf *b,bool transdoll);
#endif
static void cb_bang(flext_hdr *c);
static void cb_float(flext_hdr *c,t_float f);
static void cb_symbol(flext_hdr *c,const t_symbol *s);
// static void cb_pointer(fltext_hdr *c,const t_gpointer *p);
static void cb_anything(flext_hdr *c,const t_symbol *s,int argc,t_atom *argv);
// proxy object (for additional inlets)
static t_class *px_class;
......@@ -992,26 +997,29 @@ private:
int index;
void init(flext_base *b,int ix) { base = b; index = ix; }
static void px_method(px_object *c,const t_symbol *s,int argc,t_atom *argv);
static void px_bang(px_object *c);
static void px_float(px_object *c,t_float f);
static void px_symbol(px_object *c,const t_symbol *s);
// static void px_pointer(px_object *c,const t_gpointer *p);
static void px_anything(px_object *c,const t_symbol *s,int argc,t_atom *argv);
};
static void cb_px_anything(flext_hdr *c,const t_symbol *s,int argc,t_atom *argv);
static void cb_px_ft1(flext_hdr *c,float f);
static void cb_px_ft2(flext_hdr *c,float f);
static void cb_px_ft3(flext_hdr *c,float f);
static void cb_px_ft4(flext_hdr *c,float f);
static void cb_px_ft5(flext_hdr *c,float f);
static void cb_px_ft6(flext_hdr *c,float f);
static void cb_px_ft7(flext_hdr *c,float f);
static void cb_px_ft8(flext_hdr *c,float f);
static void cb_px_ft9(flext_hdr *c,float f);
static void cb_px_ft1(flext_hdr *c,t_float f);
static void cb_px_ft2(flext_hdr *c,t_float f);
static void cb_px_ft3(flext_hdr *c,t_float f);
static void cb_px_ft4(flext_hdr *c,t_float f);
static void cb_px_ft5(flext_hdr *c,t_float f);
static void cb_px_ft6(flext_hdr *c,t_float f);
static void cb_px_ft7(flext_hdr *c,t_float f);
static void cb_px_ft8(flext_hdr *c,t_float f);
static void cb_px_ft9(flext_hdr *c,t_float f);
#elif FLEXT_SYS == FLEXT_SYS_MAX
typedef object px_object;
static void cb_px_float(flext_hdr *c,double f);
static void cb_px_int(flext_hdr *c,long v);
static void cb_px_bang(flext_hdr *c);
static void cb_bang(flext_hdr *c);
static void cb_float(flext_hdr *c,double f);
static void cb_int(flext_hdr *c,long v);
static void cb_anything(flext_hdr *c,const t_symbol *s,short argc,t_atom *argv);
static void cb_px_in1(flext_hdr *c,long v);
static void cb_px_in2(flext_hdr *c,long v);
......@@ -1032,8 +1040,6 @@ private:
static void cb_px_ft7(flext_hdr *c,double f);
static void cb_px_ft8(flext_hdr *c,double f);
static void cb_px_ft9(flext_hdr *c,double f);
static void cb_px_anything(flext_hdr *c,const t_symbol *s,short argc,t_atom *argv);
#endif
px_object **inlets;
......@@ -1062,7 +1068,7 @@ private:
// ---------
//! set up inlet proxies
static void SetProxies(t_class *c);
static void SetProxies(t_class *c,bool dsp);
//! initialize inlets (according to class or object constructor definitions)
bool InitInlets();
......
......@@ -2,7 +2,7 @@
flext - C++ layer for Max/MSP and pd (pure data) externals
Copyright (c) 2001-2005 Thomas Grill (gr@grrrr.org)
Copyright (c) 2001-2006 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
......@@ -20,15 +20,9 @@ WARRANTIES, see the file, "license.txt," in this distribution.
void flext_dsp::Setup(t_classid id)
{
t_class *c = getClass(id);
#if FLEXT_SYS == FLEXT_SYS_MAX
if(!IsLib(id))
#endif
AddSignalMethods(c);
#if FLEXT_SYS == FLEXT_SYS_PD
add_method1(c,cb_enable,"enable",A_FLOAT);
// add_method1(c,cb_enable,"enable",A_FLOAT);
AddMethod(id,0,MakeSymbol("enable"),&cb_enable);
#endif
}
......@@ -119,5 +113,6 @@ void flext_dsp::CbSignal()
#if FLEXT_SYS == FLEXT_SYS_PD
void flext_dsp::cb_enable(flext_hdr *c,t_float on) { thisObject(c)->dspon = on != 0; }
//void flext_dsp::cb_enable(flext_hdr *c,t_float on) { thisObject(c)->dspon = on != 0; }
bool flext_dsp::cb_enable(flext_base *b,float &on) { static_cast<flext_dsp *>(b)->dspon = on != 0; return true; }
#endif
......@@ -2,7 +2,7 @@
flext - C++ layer for Max/MSP and pd (pure data) externals
Copyright (c) 2001-2005 Thomas Grill (gr@grrrr.org)
Copyright (c) 2001-2006 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
......@@ -163,7 +163,7 @@ private:
static void Setup(t_classid c);
#if FLEXT_SYS == FLEXT_SYS_PD
static void cb_enable(flext_hdr *c,t_float on);
static bool cb_enable(flext_base *c,float &on);
bool dspon;
#endif
......
......@@ -2,7 +2,7 @@
flext - C++ layer for Max/MSP and pd (pure data) externals
Copyright (c) 2001-2005 Thomas Grill (gr@grrrr.org)
Copyright (c) 2001-2006 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
......@@ -141,7 +141,7 @@ void flext_base::Exit()
}
void flext_base::AddMessageMethods(t_class *c)
void flext_base::AddMessageMethods(t_class *c,bool dsp)
{
add_loadbang(c,cb_loadbang);
#if FLEXT_SYS == FLEXT_SYS_PD
......@@ -149,27 +149,25 @@ void flext_base::AddMessageMethods(t_class *c)
#elif FLEXT_SYS == FLEXT_SYS_MAX
add_assist(c,cb_assist);
add_dblclick(c,cb_click);
#else
#pragma message ("no implementation of loadbang or assist")
#endif
SetProxies(c);
SetProxies(c,dsp);
StartQueue();
}
void flext_base::AddSignalMethods(t_class *c)
{
if(dsp) {
#if FLEXT_SYS == FLEXT_SYS_MAX
add_dsp(c,cb_dsp);
dsp_initclass();
add_dsp(c,cb_dsp);
dsp_initclass();
#elif FLEXT_SYS == FLEXT_SYS_PD
CLASS_MAINSIGNALIN(c,flext_hdr,defsig); // float messages going into the left inlet are converted to signal
add_dsp(c,cb_dsp);
CLASS_MAINSIGNALIN(c,flext_hdr,defsig); // float messages going into the left inlet are converted to signal
add_dsp(c,cb_dsp);
#else
#error Platform not supported!
#endif
}
}
/*! Set up proxy classes and basic methods at class creation time
This ensures that they are processed before the registered flext messages
*/
......@@ -180,7 +178,7 @@ void flext_base::Setup(t_classid id)
#if FLEXT_SYS == FLEXT_SYS_MAX
if(!IsLib(id))
#endif
AddMessageMethods(c);
AddMessageMethods(c,IsDSP(id));
if(process_attributes) {
AddMethod(id,0,"getattributes",cb_ListAttrib);
......
......@@ -2,7 +2,7 @@
flext - C++ layer for Max/MSP and pd (pure data) externals
Copyright (c) 2001-2005 Thomas Grill (gr@grrrr.org)
Copyright (c) 2001-2006 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
......@@ -213,8 +213,7 @@ void flext_obj::lib_init(const char *name,void setupfun(),bool attr)
sizeof(flext_hdr),NULL,A_GIMME,A_NULL);
// for all classes in library add methods
flext_base::AddMessageMethods(curlib->clss);
if(curlib->dsp) flext_base::AddSignalMethods(curlib->clss);
flext_base::AddMessageMethods(curlib->clss,curlib->dsp);
#endif
curlib = NULL;
......
......@@ -2,7 +2,7 @@
flext - C++ layer for Max/MSP and pd (pure data) externals
Copyright (c) 2001-2005 Thomas Grill (gr@grrrr.org)
Copyright (c) 2001-2006 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
......@@ -119,23 +119,17 @@ bool flext_base::InitInlets()
switch(xi.tp) {
case xlet_float:
case xlet_int: {
inlets[ix-1] = NULL;
char sym[] = "ft??";
if(ix >= 10) {
if(compatibility) {
// Max allows max. 9 inlets
post("%s: Only 9 float/int inlets allowed in compatibility mode",thisName());
ok = false;
}
else {
if(ix > 99)
post("%s: Inlet index > 99 not allowed for float/int inlets",thisName());
sym[2] = '0'+ix/10,sym[3] = '0'+ix%10;
}
if(ix > 9) {
// proxy inlet needed
(inlets[ix-1] = (px_object *)pd_new(px_class))->init(this,ix); // proxy for 2nd inlet messages
in = inlet_new(&x_obj->obj,&inlets[ix-1]->obj.ob_pd, (t_symbol *)sym_float, (t_symbol *)sym_float);
}
else {
inlets[ix-1] = NULL;
char sym[] = "ft?";
sym[2] = '0'+ix;
in = inlet_new(&x_obj->obj, &x_obj->obj.ob_pd, (t_symbol *)sym_float, gensym(sym));
}
else
sym[2] = '0'+ix,sym[3] = 0;
if(ok) in = inlet_new(&x_obj->obj, &x_obj->obj.ob_pd, (t_symbol *)sym_float, gensym(sym));
break;
}
case xlet_sym:
......@@ -157,8 +151,7 @@ bool flext_base::InitInlets()
ok = false;
}
else {
// pd doesn't seem to be able to handle signals and messages into the same inlet...
// pd is not able to handle signals and messages into the same inlet...
in = inlet_new(&x_obj->obj, &x_obj->obj.ob_pd, (t_symbol *)sym_signal, (t_symbol *)sym_signal);
++insigs;
}
......
......@@ -2,7 +2,7 @@
flext - C++ layer for Max/MSP and pd (pure data) externals
Copyright (c) 2001-2005 Thomas Grill (gr@grrrr.org)
Copyright (c) 2001-2006 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
......@@ -22,100 +22,178 @@ WARRANTIES, see the file, "license.txt," in this distribution.
t_class *flext_base::px_class = NULL;
void flext_base::px_object::px_method(px_object *obj,const t_symbol *s,int argc,t_atom *argv)
void flext_base::px_object::px_bang(px_object *obj)
{
obj->base->CbMethodHandler(obj->index,sym_bang,0,NULL);
}
void flext_base::px_object::px_float(px_object *obj,t_float f)
{
t_atom a; SetFloat(a,f);
obj->base->CbMethodHandler(obj->index,sym_float,1,&a);
}
void flext_base::px_object::px_symbol(px_object *obj,const t_symbol *s)
{
t_atom a; SetSymbol(a,s);
obj->base->CbMethodHandler(obj->index,sym_symbol,1,&a);
}
/*
void flext_base::px_object::px_pointer(px_object *obj,const t_gpointer *p)
{
t_atom a; SetPointer(a,p);
obj->base->CbMethodHandler(obj->index,sym_pointer,1,&a);
}
*/
void flext_base::px_object::px_anything(px_object *obj,const t_symbol *s,int argc,t_atom *argv)
{
obj->base->CbMethodHandler(obj->index,s,argc,argv);
}
void flext_base::cb_px_anything(flext_hdr *c,const t_symbol *s,int argc,t_atom *argv)
void flext_base::cb_bang(flext_hdr *c)
{
thisObject(c)->CbMethodHandler(0,sym_bang,0,NULL);
}
void flext_base::cb_float(flext_hdr *c,t_float f)
{
t_atom a; SetFloat(a,f);
thisObject(c)->CbMethodHandler(0,sym_float,1,&a);
}
void flext_base::cb_symbol(flext_hdr *c,const t_symbol *s)
{
t_atom a; SetSymbol(a,s);
thisObject(c)->CbMethodHandler(0,sym_symbol,1,&a);
}
/*
void flext_base::cb_pointer(flext_hdr *c,const t_gpointer *p)
{
t_atom a; SetPointer(a,p);
thisObject(c)->CbMethodHandler(0,sym_pointer,1,&a);
}
*/
void flext_base::cb_anything(flext_hdr *c,const t_symbol *s,int argc,t_atom *argv)
{
thisObject(c)->CbMethodHandler(0,s,argc,argv);
}
#define DEF_IN_FT(IX) \
void flext_base::cb_px_ft ## IX(flext_hdr *c,float v) { t_atom atom; SetFloat(atom,v); thisObject(c)->CbMethodHandler(IX,sym_float,1,&atom); }
#define DEF_PROXYMSG(IX) \
void flext_base::cb_px_ft ## IX(flext_hdr *c,t_float v) { t_atom atom; SetFloat(atom,v); thisObject(c)->CbMethodHandler(IX,sym_float,1,&atom); }
#define ADD_IN_FT(IX) \
#define ADD_PROXYMSG(c,IX) \
add_method1(c,cb_px_ft ## IX,"ft" #IX,A_FLOAT)
//AddMethod(c,0,flext::MakeSymbol("ft" #IX),cb_px_ft ## IX)
#elif FLEXT_SYS == FLEXT_SYS_MAX
void flext_base::cb_px_anything(flext_hdr *c,const t_symbol *s,short argc,t_atom *argv)
void flext_base::cb_anything(flext_hdr *c,const t_symbol *s,short argc,t_atom *argv)
{
int ci = ((flext_hdr *)c)->curinlet;
thisObject(c)->CbMethodHandler(ci,s,argc,argv);
}
void flext_base::cb_px_int(flext_hdr *c,long v)
void flext_base::cb_int(flext_hdr *c,long v)
{
t_atom atom; SetInt(atom,v);
int ci = ((flext_hdr *)c)->curinlet;
thisObject(c)->CbMethodHandler(ci,sym_int,1,&atom);
}
void flext_base::cb_px_float(flext_hdr *c,double v)
void flext_base::cb_float(flext_hdr *c,double v)
{
t_atom atom; SetFloat(atom,v);
int ci = ((flext_hdr *)c)->curinlet;
thisObject(c)->CbMethodHandler(ci,sym_float,1,&atom);
}
void flext_base::cb_px_bang(flext_hdr *c)
void flext_base::cb_bang(flext_hdr *c)
{
int ci = ((flext_hdr *)c)->curinlet;
thisObject(c)->CbMethodHandler(ci,sym_bang,0,NULL);
}
#define DEF_IN_FT(IX) \
#define DEF_PROXYMSG(IX) \
void flext_base::cb_px_in ## IX(flext_hdr *c,long v) { t_atom atom; SetInt(atom,v); thisObject(c)->CbMethodHandler(IX,sym_int,1,&atom); } \
void flext_base::cb_px_ft ## IX(flext_hdr *c,double v) { t_atom atom; SetFloat(atom,v); thisObject(c)->CbMethodHandler(IX,sym_float,1,&atom); }
#define ADD_IN_FT(IX) \
add_method1(c,cb_px_in ## IX,"in" #IX,A_INT); \
add_method1(c,cb_px_ft ## IX,"ft" #IX,A_FLOAT)
//void flext_base::cb_px_in ## IX(flext_hdr *c,long v) { t_atom atom; SetInt(atom,v); thisObject(c)->CbMethodHandler(IX,sym_int,1,&atom); } \
//void flext_base::cb_px_ft ## IX(flext_hdr *c,double v) { t_atom atom; SetFloat(atom,v); thisObject(c)->CbMethodHandler(IX,sym_float,1,&atom); }
#define ADD_PROXYMSG(c,IX) \
addinx((method)(cb_px_in ## IX),IX); \
addftx((method)(cb_px_ft ## IX),IX)
//add_method1(c,cb_px_in ## IX,"in" #IX,A_INT); \
//add_method1(c,cb_px_ft ## IX,"ft" #IX,A_FLOAT)
//AddMethod(c,0,flext::MakeSymbol("in" #IX),cb_px_in ## IX); \
//AddMethod(c,0,flext::MakeSymbol("ft" #IX),cb_px_ft ## IX)
#endif
#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX
DEF_IN_FT(1)
DEF_IN_FT(2)
DEF_IN_FT(3)
DEF_IN_FT(4)
DEF_IN_FT(5)
DEF_IN_FT(6)
DEF_IN_FT(7)
DEF_IN_FT(8)
DEF_IN_FT(9)
void flext_base::SetProxies(t_class *c)
DEF_PROXYMSG(1)
DEF_PROXYMSG(2)
DEF_PROXYMSG(3)
DEF_PROXYMSG(4)
DEF_PROXYMSG(5)
DEF_PROXYMSG(6)
DEF_PROXYMSG(7)
DEF_PROXYMSG(8)
DEF_PROXYMSG(9)
void flext_base::SetProxies(t_class *c,bool dsp)
{
// proxy for extra inlets
#if FLEXT_SYS == FLEXT_SYS_PD
add_anything(c,cb_px_anything); // for leftmost inlet
px_class = class_new(gensym("flext_base proxy"),NULL,NULL,sizeof(px_object),CLASS_PD|CLASS_NOINLET, A_NULL);
add_anything(px_class,px_object::px_method); // for other inlets
// for leftmost inlet
class_addbang(c,cb_bang);
if(!dsp) class_addfloat(c,cb_float);
class_addsymbol(c,cb_symbol);
// class_addpointer(c,cb_pointer);
class_addlist(c,cb_anything);
class_addanything(c,cb_anything);
// proxy for extra inlets
if(!px_class) {
// only once
px_class = class_new(gensym(" flext_base proxy "),NULL,NULL,sizeof(px_object),CLASS_PD|CLASS_NOINLET, A_NULL);
class_addbang(px_class,px_object::px_bang); // for other inlets
class_addfloat(px_class,px_object::px_float); // for other inlets
class_addsymbol(px_class,px_object::px_symbol); // for other inlets
// class_addpointer(px_class,px_object::px_pointer); // for other inlets
class_addlist(px_class,px_object::px_anything); // for other inlets
class_addanything(px_class,px_object::px_anything); // for other inlets
}
#elif FLEXT_SYS == FLEXT_SYS_MAX
add_bang(c,cb_px_bang);
add_method1(c,cb_px_int,"int",A_INT);
add_method1(c,cb_px_float,"float",A_FLOAT);
// add_methodG(c,cb_px_anything,"list");
add_anything(c,cb_px_anything);
addbang((method)cb_bang);
addint((method)cb_int);
addfloat((method)cb_float);
addmess((method)cb_anything,"anything",A_GIMME,A_NOTHING);
#else
#error Not implemented!
#endif
// setup non-leftmost ints and floats
ADD_IN_FT(1);
ADD_IN_FT(2);
ADD_IN_FT(3);
ADD_IN_FT(4);
ADD_IN_FT(5);
ADD_IN_FT(6);
ADD_IN_FT(7);
ADD_IN_FT(8);
ADD_IN_FT(9);
ADD_PROXYMSG(c,1);
ADD_PROXYMSG(c,2);
ADD_PROXYMSG(c,3);
ADD_PROXYMSG(c,4);
ADD_PROXYMSG(c,5);
ADD_PROXYMSG(c,6);
ADD_PROXYMSG(c,7);
ADD_PROXYMSG(c,8);
ADD_PROXYMSG(c,9);
}
#endif
......@@ -301,7 +301,7 @@ static unsigned long setsimdcaps()
if(cpuinfo.os_support&_CPU_FEATURE_3DNOW) simdflags += flext::simd_3dnow;
if(cpuinfo.os_support&_CPU_FEATURE_SSE) simdflags += flext::simd_sse;
if(cpuinfo.os_support&_CPU_FEATURE_SSE2) simdflags += flext::simd_sse2;
#elif FLEXT_CPU == FLEXT_CPU_PPC
#elif FLEXT_CPU == FLEXT_CPU_PPC && defined(__VEC__)
#if FLEXT_OSAPI == FLEXT_OSAPI_MAC_MACH
int selectors[2] = { CTL_HW, HW_VECTORUNIT };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment