Commit 45ddb2f2 authored by thomas's avatar thomas
Browse files

*** empty log message ***


git-svn-id: https://svn.grrrr.org/ext/trunk@266 4d9ac71a-51e6-0310-8455-cad1006bcd31
parent b231bb23
......@@ -42,7 +42,7 @@ all: $(TARGDIR) $(TARGET) $(TARGET_D) $(TARGET_T) $(TARGET_TD)
$(TARGDIR):
mkdir $(TARGDIR)
$(SRCS): $(HDRS) $(IHDRS) $(MAKEFILE)
$(patsubst %,source/%,$(SRCS)): $(patsubst %,source/%,$(HDRS)) $(patsubst %,source/%,$(IHDRS)) $(MAKEFILE)
touch $@
$(TARGDIR)/%.o : source/%.cpp
......
......@@ -297,7 +297,7 @@ public:
a_gimme,a_xgimme
};
typedef void (*methfun)(t_class *c);
typedef bool (*methfun)(t_class *c);
/*! \defgroup FLEXT_C_ADDMETHOD Flext method handling
\internal
......@@ -309,25 +309,25 @@ public:
void AddMethodDef(int inlet,const char *tag); // call virtual function for tag && inlet
void AddMethod(int inlet,const char *tag,methfun fun,metharg tp,...);
void AddMethod(int inlet,void (*m)(flext_base *,int,t_atom *)) { AddMethod(inlet,"list",(methfun)m,a_gimme,a_null); }
void AddMethod(int inlet,const char *tag,void (*m)(flext_base *)) { AddMethod(inlet,tag,(methfun)m,a_null); } // pure method
void AddMethod(int inlet,void (*m)(flext_base *,const t_symbol *,int,t_atom *)) { AddMethod(inlet,"anything",(methfun)m,a_xgimme,a_null); } // anything
void AddMethod(int inlet,void (*m)(flext_base *,t_symbol *&)) { AddMethod(inlet,"symbol",(methfun)m,a_symbol,a_null); } // single symbol
void AddMethod(int inlet,void (*m)(flext_base *,float &)) { AddMethod(inlet,"float",(methfun)m,a_float,a_null); } // single float
void AddMethod(int inlet,void (*m)(flext_base *,float &,float &)) { AddMethod(inlet,"list",(methfun)m,a_float,a_float,a_null); } // list of 2 floats
void AddMethod(int inlet,void (*m)(flext_base *,float &,float &,float &)) { AddMethod(inlet,"list",(methfun)m,a_float,a_float,a_float,a_null); } // list of 3 floats
void AddMethod(int inlet,bool (*m)(flext_base *,int,t_atom *)) { AddMethod(inlet,"list",(methfun)m,a_gimme,a_null); }
void AddMethod(int inlet,const char *tag,bool (*m)(flext_base *)) { AddMethod(inlet,tag,(methfun)m,a_null); } // pure method
void AddMethod(int inlet,bool (*m)(flext_base *,const t_symbol *,int,t_atom *)) { AddMethod(inlet,"anything",(methfun)m,a_xgimme,a_null); } // anything
void AddMethod(int inlet,bool (*m)(flext_base *,t_symbol *&)) { AddMethod(inlet,"symbol",(methfun)m,a_symbol,a_null); } // single symbol
void AddMethod(int inlet,bool (*m)(flext_base *,float &)) { AddMethod(inlet,"float",(methfun)m,a_float,a_null); } // single float
void AddMethod(int inlet,bool (*m)(flext_base *,float &,float &)) { AddMethod(inlet,"list",(methfun)m,a_float,a_float,a_null); } // list of 2 floats
void AddMethod(int inlet,bool (*m)(flext_base *,float &,float &,float &)) { AddMethod(inlet,"list",(methfun)m,a_float,a_float,a_float,a_null); } // list of 3 floats
#ifdef PD
void AddMethod(int inlet,void (*m)(flext_base *,int &)) { AddMethod(inlet,"float",(methfun)m,a_int,a_null); } // single float
void AddMethod(int inlet,bool (*m)(flext_base *,int &)) { AddMethod(inlet,"float",(methfun)m,a_int,a_null); } // single float
#else
void AddMethod(int inlet,void (*m)(flext_base *,int &)) { AddMethod(inlet,"int",(methfun)m,a_int,a_null); } // single float
void AddMethod(int inlet,bool (*m)(flext_base *,int &)) { AddMethod(inlet,"int",(methfun)m,a_int,a_null); } // single float
#endif
void AddMethod(int inlet,void (*m)(flext_base *,int &,int &)) { AddMethod(inlet,"list",(methfun)m,a_int,a_int,a_null); } // list of 2 floats
void AddMethod(int inlet,void (*m)(flext_base *,int &,int &,int &)) { AddMethod(inlet,"list",(methfun)m,a_int,a_int,a_int,a_null); } // list of 3 floats
void AddMethod(int inlet,const char *tag,void (*m)(flext_base *,int,t_atom *)) { AddMethod(inlet,tag,(methfun)m,a_gimme,a_null); } // method+gimme
void AddMethod(int inlet,const char *tag,void (*m)(flext_base *,const t_symbol *,int,t_atom *)) { AddMethod(inlet,tag,(methfun)m,a_xgimme,a_null); } // method+gimme
void AddMethod(int inlet,const char *tag,void (*m)(flext_base *,t_symbol *&)) { AddMethod(inlet,tag,(methfun)m,a_symbol,a_null); } // method+symbol
void AddMethod(int inlet,const char *tag,void (*m)(flext_base *,float &)) { AddMethod(inlet,tag,(methfun)m,a_float,a_null); } // method+float
void AddMethod(int inlet,const char *tag,void (*m)(flext_base *,int &)) { AddMethod(inlet,tag,(methfun)m,a_int,a_null); } // method+int
void AddMethod(int inlet,bool (*m)(flext_base *,int &,int &)) { AddMethod(inlet,"list",(methfun)m,a_int,a_int,a_null); } // list of 2 floats
void AddMethod(int inlet,bool (*m)(flext_base *,int &,int &,int &)) { AddMethod(inlet,"list",(methfun)m,a_int,a_int,a_int,a_null); } // list of 3 floats
void AddMethod(int inlet,const char *tag,bool (*m)(flext_base *,int,t_atom *)) { AddMethod(inlet,tag,(methfun)m,a_gimme,a_null); } // method+gimme
void AddMethod(int inlet,const char *tag,bool (*m)(flext_base *,const t_symbol *,int,t_atom *)) { AddMethod(inlet,tag,(methfun)m,a_xgimme,a_null); } // method+gimme
void AddMethod(int inlet,const char *tag,bool (*m)(flext_base *,t_symbol *&)) { AddMethod(inlet,tag,(methfun)m,a_symbol,a_null); } // method+symbol
void AddMethod(int inlet,const char *tag,bool (*m)(flext_base *,float &)) { AddMethod(inlet,tag,(methfun)m,a_float,a_null); } // method+float
void AddMethod(int inlet,const char *tag,bool (*m)(flext_base *,int &)) { AddMethod(inlet,tag,(methfun)m,a_int,a_null); } // method+int
//! Set MaxMSP style of distributing list elements over (message) inlets
void SetDist(bool d = true) { distmsgs = d; }
......@@ -493,7 +493,7 @@ public:
/*! \brief Increase/Decrease priority of the current thread
*/
static void ChangePriority(int dp,pthread_t thr = pthread_self());
static bool ChangePriority(int dp,pthread_t thr = pthread_self());
/*! \brief Get current thread id
*/
......
......@@ -268,53 +268,53 @@ REAL_LIB_3(NAME,NEW_CLASS, 1, TYPE1, TYPE2, TYPE3)
//! Set up a method callback with no arguments
#define FLEXT_CALLBACK(M_FUN) \
static void cb_ ## M_FUN(flext_base *c) \
static bool cb_ ## M_FUN(flext_base *c) \
{ static_cast<thisType *>(c)->M_FUN(); }
//! Set up a method callback for an anything argument
#define FLEXT_CALLBACK_A(M_FUN) \
static void cb_ ## M_FUN(flext_base *c,const t_symbol *s,int argc,t_atom *argv) \
{ static_cast<thisType *>(c)->M_FUN(s,argc,argv); }
static bool cb_ ## M_FUN(flext_base *c,const t_symbol *s,int argc,t_atom *argv) \
{ static_cast<thisType *>(c)->M_FUN(s,argc,argv); return true; }
//! Set up a method callback for a variable argument list
#define FLEXT_CALLBACK_V(M_FUN) \
static void cb_ ## M_FUN(flext_base *c,int argc,t_atom *argv) \
{ static_cast<thisType *>(c)->M_FUN(argc,argv); }
static bool cb_ ## M_FUN(flext_base *c,int argc,t_atom *argv) \
{ static_cast<thisType *>(c)->M_FUN(argc,argv); return true; }
//! Set up a method callback for a data package (void *) argument
#define FLEXT_CALLBACK_X(M_FUN) \
static void cb_ ## M_FUN(flext_base *c,void *data) \
{ static_cast<thisType *>(c)->M_FUN(data); }
static bool cb_ ## M_FUN(flext_base *c,void *data) \
{ static_cast<thisType *>(c)->M_FUN(data); return true; }
//! Set up a method callback for a boolean argument
#define FLEXT_CALLBACK_B(M_FUN) \
static void cb_ ## M_FUN(flext_base *c,int &arg1) \
{ static_cast<thisType *>(c)->M_FUN(arg1 != 0); }
static bool cb_ ## M_FUN(flext_base *c,int &arg1) \
{ static_cast<thisType *>(c)->M_FUN(arg1 != 0); return true; }
//! Set up a method callback for 1 argument
#define FLEXT_CALLBACK_1(M_FUN,TP1) \
static void cb_ ## M_FUN(flext_base *c,TP1 &arg1) \
{ static_cast<thisType *>(c)->M_FUN(arg1); }
static bool cb_ ## M_FUN(flext_base *c,TP1 &arg1) \
{ static_cast<thisType *>(c)->M_FUN(arg1); return true; }
//! Set up a method callback for 2 arguments
#define FLEXT_CALLBACK_2(M_FUN,TP1,TP2) \
static void cb_ ## M_FUN(flext_base *c,TP1 &arg1,TP2 &arg2) \
{ static_cast<thisType *>(c)->M_FUN(arg1,arg2); }
static bool cb_ ## M_FUN(flext_base *c,TP1 &arg1,TP2 &arg2) \
{ static_cast<thisType *>(c)->M_FUN(arg1,arg2); return true; }
//! Set up a method callback for 3 arguments
#define FLEXT_CALLBACK_3(M_FUN,TP1,TP2,TP3) \
static void cb_ ## M_FUN(flext_base *c,TP1 &arg1,TP2 &arg2,TP3 &arg3) \
{ static_cast<thisType *>(c)->M_FUN(arg1,arg2,arg3); }
static bool cb_ ## M_FUN(flext_base *c,TP1 &arg1,TP2 &arg2,TP3 &arg3) \
{ static_cast<thisType *>(c)->M_FUN(arg1,arg2,arg3); return true; }
//! Set up a method callback for 4 arguments
#define FLEXT_CALLBACK_4(M_FUN,TP1,TP2,TP3,TP4) \
static void cb_ ## M_FUN(flext_base *c,TP1 &arg1,TP2 &arg2,TP3 &arg3,TP4 &arg4) \
{ static_cast<thisType *>(c)->M_FUN(arg1,arg2,arg3,arg4); }
static bool cb_ ## M_FUN(flext_base *c,TP1 &arg1,TP2 &arg2,TP3 &arg3,TP4 &arg4) \
{ static_cast<thisType *>(c)->M_FUN(arg1,arg2,arg3,arg4); return true; }
//! Set up a method callback for 5 arguments
#define FLEXT_CALLBACK_5(M_FUN,TP1,TP2,TP3,TP4,TP5) \
static void cb_ ## M_FUN(flext_base *c,TP1 &arg1,TP2 &arg2,TP3 &arg3,TP4 &arg4,TP5 &arg5) \
{ static_cast<thisType *>(c)->M_FUN(arg1,arg2,arg3,arg4,arg5); }
static bool cb_ ## M_FUN(flext_base *c,TP1 &arg1,TP2 &arg2,TP3 &arg3,TP4 &arg4,TP5 &arg5) \
{ static_cast<thisType *>(c)->M_FUN(arg1,arg2,arg3,arg4,arg5); return true; }
// Shortcuts
......@@ -371,9 +371,9 @@ FLEXT_CALLBACK_1(M_FUN,t_symptr)
//! Set up a threaded method callback with no arguments
#define FLEXT_THREAD(M_FUN) \
static void cb_ ## M_FUN(flext_base *c) { \
static bool cb_ ## M_FUN(flext_base *c) { \
thr_params *p = new thr_params(c); \
StartThread(thr_ ## M_FUN,p,#M_FUN); \
return StartThread(thr_ ## M_FUN,p,#M_FUN); \
} \
static void *thr_ ## M_FUN(thr_params *p) { \
thisType *th = static_cast<thisType *>(p->cl); \
......@@ -388,9 +388,9 @@ static void *thr_ ## M_FUN(thr_params *p) { \
//! Set up a threaded method callback for an anything argument
#define FLEXT_THREAD_A(M_FUN) \
static void cb_ ## M_FUN(flext_base *c,const t_symbol *s,int argc,t_atom *argv) { \
static bool cb_ ## M_FUN(flext_base *c,const t_symbol *s,int argc,t_atom *argv) { \
thr_params *p = new thr_params(c); p->set_any(s,argc,argv); \
StartThread(thr_ ## M_FUN,p,#M_FUN); \
return StartThread(thr_ ## M_FUN,p,#M_FUN); \
} \
static void *thr_ ## M_FUN(thr_params *p) { \
thisType *th = static_cast<thisType *>(p->cl); \
......@@ -407,9 +407,9 @@ static void *thr_ ## M_FUN(thr_params *p) { \
//! Set up a threaded method callback for a variable argument list
#define FLEXT_THREAD_V(M_FUN) \
static void cb_ ## M_FUN(flext_base *c,int argc,t_atom *argv) { \
static bool cb_ ## M_FUN(flext_base *c,int argc,t_atom *argv) { \
thr_params *p = new thr_params(c); p->set_list(argc,argv); \
StartThread(thr_ ## M_FUN,p,#M_FUN); \
return StartThread(thr_ ## M_FUN,p,#M_FUN); \
} \
static void *thr_ ## M_FUN(thr_params *p) { \
thisType *th = static_cast<thisType *>(p->cl); \
......@@ -428,9 +428,9 @@ static void *thr_ ## M_FUN(thr_params *p) { \
\note Data is pure... no destructor is called upon delete
*/
#define FLEXT_THREAD_X(M_FUN) \
static void cb_ ## M_FUN(flext_base *c,void *data) { \
static bool cb_ ## M_FUN(flext_base *c,void *data) { \
thr_params *p = new thr_params(c); p->var[0]._ext.data = data; \
StartThread(thr_ ## M_FUN,p,#M_FUN); \
return StartThread(thr_ ## M_FUN,p,#M_FUN); \
} \
static void *thr_ ## M_FUN(thr_params *p) { \
thisType *th = static_cast<thisType *>(p->cl); \
......@@ -447,9 +447,9 @@ static void *thr_ ## M_FUN(thr_params *p) { \
//! Set up a threaded method callback for a boolean argument
#define FLEXT_THREAD_B(M_FUN) \
static void cb_ ## M_FUN(flext_base *c,int &arg1) { \
static bool cb_ ## M_FUN(flext_base *c,int &arg1) { \
thr_params *p = new thr_params(c); p->var[0]._bool = arg1 != 0; \
StartThread(thr_ ## M_FUN,p,#M_FUN); \
return StartThread(thr_ ## M_FUN,p,#M_FUN); \
} \
static void *thr_ ## M_FUN(thr_params *p) { \
thisType *th = static_cast<thisType *>(p->cl); \
......@@ -465,10 +465,10 @@ static void *thr_ ## M_FUN(thr_params *p) { \
//! Set up a threaded method callback for 1 argument
#define FLEXT_THREAD_1(M_FUN,TP1) \
static void cb_ ## M_FUN(flext_base *c,TP1 &arg1) { \
static bool cb_ ## M_FUN(flext_base *c,TP1 &arg1) { \
thr_params *p = new thr_params(c,1); \
p->var[0]._ ## TP1 = arg1; \
StartThread(thr_ ## M_FUN,p,#M_FUN); \
return StartThread(thr_ ## M_FUN,p,#M_FUN); \
} \
static void *thr_ ## M_FUN(thr_params *p) { \
thisType *th = static_cast<thisType *>(p->cl); \
......@@ -484,11 +484,11 @@ static void *thr_ ## M_FUN(thr_params *p) { \
//! Set up a threaded method callback for 2 arguments
#define FLEXT_THREAD_2(M_FUN,TP1,TP2) \
static void cb_ ## M_FUN(flext_base *c,TP1 &arg1,TP2 &arg2) { \
static bool cb_ ## M_FUN(flext_base *c,TP1 &arg1,TP2 &arg2) { \
thr_params *p = new thr_params(c,2); \
p->var[0]._ ## TP1 = arg1; \
p->var[1]._ ## TP2 = arg2; \
StartThread(thr_ ## M_FUN,p,#M_FUN); \
return StartThread(thr_ ## M_FUN,p,#M_FUN); \
} \
static void *thr_ ## M_FUN(thr_params *p) { \
thisType *th = static_cast<thisType *>(p->cl); \
......@@ -505,12 +505,12 @@ static void *thr_ ## M_FUN(thr_params *p) { \
//! Set up a threaded method callback for 3 arguments
#define FLEXT_THREAD_3(M_FUN,TP1,TP2,TP3) \
static void cb_ ## M_FUN(flext_base *c,TP1 &arg1,TP2 &arg2,TP3 &arg3) { \
static bool cb_ ## M_FUN(flext_base *c,TP1 &arg1,TP2 &arg2,TP3 &arg3) { \
thr_params *p = new thr_params(c,3); \
p->var[0]._ ## TP1 = arg1; \
p->var[1]._ ## TP2 = arg2; \
p->var[2]._ ## TP3 = arg3; \
StartThread(thr_ ## M_FUN,p,#M_FUN); \
return StartThread(thr_ ## M_FUN,p,#M_FUN); \
} \
static void *thr_ ## M_FUN(thr_params *p) { \
thisType *th = static_cast<thisType *>(p->cl); \
......@@ -528,13 +528,13 @@ static void *thr_ ## M_FUN(thr_params *p) { \
//! Set up a threaded method callback for 4 arguments
#define FLEXT_THREAD_4(M_FUN,TP1,TP2,TP3,TP4) \
static void cb_ ## M_FUN(flext_base *c,TP1 &arg1,TP2 &arg2,TP3 &arg3,TP4 &arg4) { \
static bool cb_ ## M_FUN(flext_base *c,TP1 &arg1,TP2 &arg2,TP3 &arg3,TP4 &arg4) { \
thr_params *p = new thr_params(c,4); \
p->var[0]._ ## TP1 = arg1; \
p->var[1]._ ## TP2 = arg2; \
p->var[2]._ ## TP3 = arg3; \
p->var[3]._ ## TP4 = arg4; \
StartThread(thr_ ## M_FUN,p,#M_FUN); \
return StartThread(thr_ ## M_FUN,p,#M_FUN); \
} \
static void *thr_ ## M_FUN(thr_params *p) { \
thisType *th = static_cast<thisType *>(p->cl); \
......@@ -553,14 +553,14 @@ static void *thr_ ## M_FUN(thr_params *p) { \
//! Set up a threaded method callback for 5 arguments
#define FLEXT_THREAD_5(M_FUN,TP1,TP2,TP3,TP4,TP5) \
static void cb_ ## M_FUN(flext_base *c,TP1 &arg1,TP2 &arg2,TP3 &arg3,TP4 &arg4,TP5 &arg5) { \
static bool cb_ ## M_FUN(flext_base *c,TP1 &arg1,TP2 &arg2,TP3 &arg3,TP4 &arg4,TP5 &arg5) { \
thr_params *p = new thr_params(c,5); \
p->var[0]._ ## TP1 = arg1; \
p->var[1]._ ## TP2 = arg2; \
p->var[2]._ ## TP3 = arg3; \
p->var[3]._ ## TP4 = arg4; \
p->var[4]._ ## TP5 = arg5; \
StartThread(thr_ ## M_FUN,p,#M_FUN); \
return StartThread(thr_ ## M_FUN,p,#M_FUN); \
} \
static void *thr_ ## M_FUN(thr_params *p) { \
thisType *th = static_cast<thisType *>(p->cl); \
......
......@@ -46,7 +46,9 @@ bool flext_base::StartThread(void *(*meth)(thr_params *p),thr_params *p,char *me
pthread_t thrid;
int ret = pthread_create (&thrid,&attr,(void *(*)(void *))meth,p);
if(ret) {
#ifdef _DEBUG
error((char *)(ret == EAGAIN?"%s - Unsufficient resources to launch thread!":"%s - Could not launch method!"),methname);
#endif
delete p;
return false;
}
......@@ -117,19 +119,26 @@ void flext_base::YTick(flext_base *th) {
#endif
void flext_base::ChangePriority(int dp,pthread_t id)
bool flext_base::ChangePriority(int dp,pthread_t id)
{
sched_param parm;
int policy;
if(pthread_getschedparam(id,&policy,&parm)) {
#ifdef _DEBUG
post("flext - failed to get parms");
#endif
return false;
}
else {
parm.sched_priority += dp;
if(pthread_setschedparam(id,policy,&parm)) {
#ifdef _DEBUG
post("flext - failed to change priority");
#endif
return false;
}
}
return true;
}
......
......@@ -27,7 +27,7 @@ public:
adv1(int argc,t_atom *argv);
protected:
void m_any(t_symbol *s,int argc,t_atom *argv); // method which digests anything
void m_any(const t_symbol *s,int argc,t_atom *argv); // method which digests anything
AtomList lst;
private:
......@@ -70,7 +70,7 @@ adv1::adv1(int argc,t_atom *argv)
// method
void adv1::m_any(t_symbol *s,int argc,t_atom *argv)
void adv1::m_any(const t_symbol *s,int argc,t_atom *argv)
{
// reserve space for as many atoms as possibly necessary
AtomList result(lst.Count()+argc+2);
......
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