Commit 5b1678fa authored by thomas's avatar thomas
Browse files

no message


git-svn-id: https://svn.grrrr.org/ext/trunk@450 4d9ac71a-51e6-0310-8455-cad1006bcd31
parent 367f4176
......@@ -101,7 +101,7 @@ Version history:
0.4.1:
- full port for Max@OSX
- completely redesigned message and attribute handling: now hashed and a much more efficient
- completely redesigned message and attribute handling: now hashed and much more efficient
- added some prerequisites for usage of flext as a shared library
- put overloaded new/delete into flext support class
- introduced "Finalize" virtual method, called after all "Init" methods
......@@ -126,6 +126,7 @@ Version history:
- implemented threading support with the MacOS MP thread library
- stripped the ThrMutex and ThrCond classes of non-portable (and irrelevant) functionality
- simplified "ToQueue*" and threaded "ToOut*" message queue mechanism for Max/MSP
- deprecated FLEXT_ADDMETHOD_V and FLEXT_ADDMETHOD_A definitions which only lead to confusion
0.4.0:
- the use of the const keyword is enforced (e.g. the preferred type for symbols is now "const t_symbol *")
......@@ -291,6 +292,7 @@ general:
- add log messages for debugging version
- feed assist function with in/outlet description
- MaxMSP: how to call separate help files for objects in a library?
- use PD's t_float type for floating point values (and what about t_int?)
bugs:
- PD: problems with timed buffer redrawing (takes a lot of cpu time)
......@@ -302,7 +304,9 @@ tests:
- PD: figure out what "pointer" messages do and where they occur
- some more mutexes needed for thread safety?
- buffer resize: flext_base::buffer::Frames(): should we use buffer or system sample rate?
- what about FLEXT_ADDMETHOD_V (for var arg lists) and FLEXT_ADDMETHOD_A (anythings)... nonsense?
-> yes, these definitions obscure the meaning of _ as an indication for usage of a message tag
features:
- abstraction for clock functions
......
......@@ -21,9 +21,9 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#define STD
#endif
flext_base::attritem::attritem(const t_symbol *t,metharg tp,methfun f,bool g):
flext_base::attritem::attritem(const t_symbol *t,metharg tp,methfun f,int fl):
item(t,0,NULL),argtp(tp),
fun(f),isget(g)
fun(f),flags(fl)
{
}
......@@ -57,7 +57,7 @@ void flext_base::AddAttrib(itemarr *aa,itemarr *ma,const char *attr,metharg tp,m
// if(sfun) // if commented out, there will be a warning at run-time (more user-friendly)
{
attritem *a = new attritem(asym,tp,sfun,false);
attritem *a = new attritem(asym,tp,sfun,attritem::afl_bothexist|attritem::afl_set);
aa->Add(a);
// bind attribute to a method
......@@ -68,7 +68,7 @@ void flext_base::AddAttrib(itemarr *aa,itemarr *ma,const char *attr,metharg tp,m
// if(gfun) // if commented out, there will be a warning at run-time (more user-friendly)
{
attritem *a = new attritem(asym,tp,gfun,true);
attritem *a = new attritem(asym,tp,gfun,attritem::afl_bothexist|attritem::afl_get);
aa->Add(a);
static char tmp[256] = "get";
......@@ -124,17 +124,22 @@ bool flext_base::ListAttrib()
int ccnt = clattrhead?clattrhead->Count():0;
AtomList la(ccnt+cnt);
for(int i = 0,ix = 0; i <= 1; ++i) {
int ix = 0;
for(int i = 0; i <= 1; ++i) {
itemarr *a = i?attrhead:clattrhead;
if(a) {
for(int ai = 0; ai < a->Size(); ++ai) {
for(item *l = a->Item(ai); l; l = l->nxt)
SetSymbol(la[ix++],l->tag);
{
attritem *a = (attritem *)l;
if(!a->BothExist() || a->IsGet())
SetSymbol(la[ix++],a->tag);
}
}
}
}
ToOutAnything(outattr,MakeSymbol("attributes"),la.Count(),la.Atoms());
ToOutAnything(outattr,MakeSymbol("attributes"),ix,la.Atoms());
return true;
}
else
......@@ -145,10 +150,10 @@ bool flext_base::SetAttrib(const t_symbol *tag,int argc,const t_atom *argv)
{
// search for matching attribute
attritem *a = (attritem *)attrhead->Find(tag);
while(a && (a->tag != tag || a->inlet != 0 || a->isget)) a = (attritem *)a->nxt;
while(a && (a->tag != tag || a->inlet != 0 || a->IsGet())) a = (attritem *)a->nxt;
if(!a) {
a = (attritem *)clattrhead->Find(tag);
while(a && (a->tag != tag || a->inlet != 0 || a->isget)) a = (attritem *)a->nxt;
while(a && (a->tag != tag || a->inlet != 0 || a->IsGet())) a = (attritem *)a->nxt;
}
if(a)
......
......@@ -582,10 +582,19 @@ protected:
class attritem:
public item {
public:
attritem(const t_symbol *tag,metharg tp,methfun fun,bool get);
attritem(const t_symbol *tag,metharg tp,methfun fun,int flags);
~attritem();
bool isget;
enum {
afl_getset = 0x01, afl_get = 0x00, afl_set = 0x01,
afl_bothexist = 0x02
};
bool IsGet() const { return (flags&afl_getset) == afl_get; }
bool IsSet() const { return (flags&afl_getset) == afl_set; }
bool BothExist() const { return (flags&afl_bothexist) != 0; }
int flags;
metharg argtp;
methfun fun;
};
......
......@@ -671,20 +671,10 @@ FLEXT_THREAD_1(M_FUN,t_symptr)
\
AddMethod(CL,IX,"bang",FLEXT_CALL_PRE(M_FUN))
//! Add a handler for a method with no arguments
//! Add a handler for a method with either no, list or anything arguments
#define FLEXT_CADDMETHOD(CL,IX,M_FUN) \
AddMethod(CL,IX,FLEXT_CALL_PRE(M_FUN))
//! Add a handler for a method with a (variable argument) list
#define FLEXT_CADDMETHOD_V(CL,IX,M_FUN) \
\
AddMethod(CL,IX,FLEXT_CALL_PRE(M_FUN))
//! Add a handler for a method with an anything argument
#define FLEXT_CADDMETHOD_A(CL,IX,M_FUN) \
\
AddMethod(CL,IX,FLEXT_CALL_PRE(M_FUN))
//! Add a a handler for a method with implicit arguments
#define FLEXT_CADDMETHOD_(CL,IX,M_TAG,M_FUN) \
\
......@@ -777,21 +767,29 @@ SetDist(true)
\
AddMethod(IX,"bang",FLEXT_CALL_PRE(M_FUN))
//! Add a handler for a method with no arguments
//! Add a handler for a method with either no, list or anything arguments
#define FLEXT_ADDMETHOD(IX,M_FUN) \
AddMethod(IX,FLEXT_CALL_PRE(M_FUN))
//! Add a handler for a method with a (variable argument) list
#if 0
// FLEXT_ADDMETHOD_V and FLEXT_ADDMETHOD_A definitions obscure that _ indicates the usage of a message tag
/*! \brief Add a handler for a method with a (variable argument) list
\note This is already covered by FLEXT_ADDMETHOD, but here for the sake of clarity
*/
#define FLEXT_ADDMETHOD_V(IX,M_FUN) \
\
AddMethod(IX,FLEXT_CALL_PRE(M_FUN))
//! Add a handler for a method with an anything argument
/*! \brief Add a handler for a method with an anything argument
\note This is already covered by FLEXT_ADDMETHOD, but here for the sake of clarity
*/
#define FLEXT_ADDMETHOD_A(IX,M_FUN) \
\
AddMethod(IX,FLEXT_CALL_PRE(M_FUN))
#endif
//! Add a a handler for a method with implicit arguments
//! Add a a handler for a tagged method with implicit arguments
#define FLEXT_ADDMETHOD_(IX,M_TAG,M_FUN) \
\
AddMethod(IX,M_TAG,FLEXT_CALL_PRE(M_FUN))
......
......@@ -81,7 +81,7 @@ bool flext_base::TryMethTag(const methitem *m,int inlet,const t_symbol *t,int ar
if(m->attr) {
// attributes are treated differently
if(m->attr->isget)
if(m->attr->IsGet())
return GetAttrib(m->attr);
else
return SetAttrib(m->attr,argc,argv);
......
......@@ -155,7 +155,7 @@ public:
//! Zero a memory region
static void ZeroMem(void *dst,int bytes);
//! Sleep for an amount of time
static void Sleep(float s);
static void Sleep(double s);
//! @} FLEXT_S_UTIL
......
......@@ -34,13 +34,14 @@ void flext::ZeroMem(void *dst,int bytes)
memset(dst,0,bytes);
}
void flext::Sleep(float s)
void flext::Sleep(double s)
{
#if FLEXT_OS == FLEXT_OS_WIN
::Sleep((long)(s*1000));
::Sleep((long)(s*1000.));
#elif FLEXT_OS == FLEXT_OS_LINUX || FLEXT_OS == FLEXT_OS_IRIX || defined(__GNUC__)
usleep((long)(s*1000000));
usleep((long)(s*1000000.));
#elif FLEXT_OS == FLEXT_OS_MACOS
// that's just for OS9!
UnsignedWide tick;
Microseconds(&tick);
double target = tick.hi*((double)(1L<<((sizeof tick.lo)*4))*(double)(1L<<((sizeof tick.lo)*4)))+tick.lo+s*1.e6;
......
......@@ -44,10 +44,10 @@ protected:
private:
// callback for method "m_trigger" (with one float argument)
FLEXT_CALLBACK_F(m_trigger);
FLEXT_CALLBACK_F(m_trigger)
// define attribute callbacks for variable "arg" (with GET and SET properties)
FLEXT_ATTRVAR_F(arg);
FLEXT_ATTRVAR_F(arg)
};
// instantiate the class
......
......@@ -7,7 +7,11 @@ WARRANTIES, see the file, "license.txt," in this distribution.
-------------------------------------------------------------------------
This is an example of an object doing various float operations
This is an example of an object doing various float operations.
Methods and attributes are registered at class level (opposed to object level in example "attr1").
For details, see also example "adv2"
*/
......@@ -58,26 +62,27 @@ private:
static void setup(t_class *);
// callback for method "m_trigger" (with one float argument)
FLEXT_CALLBACK_F(m_trigger);
FLEXT_CALLBACK_F(m_trigger)
// define attribute callbacks for variable "arg" ("ATTRVAR" means GET and SET)
FLEXT_ATTRVAR_F(arg);
FLEXT_ATTRVAR_F(arg)
// define attribute callbacks for variable "res" (GET only)
FLEXT_ATTRGET_F(res);
FLEXT_ATTRGET_F(res)
// methods for getting/setting the operation mode
void opget(const t_symbol *&s) const;
void opset(const t_symbol *&s);
// define attribute callbacks for variable "res" (GET only)
FLEXT_CALLGET_S(opget);
FLEXT_CALLSET_S(opset);
FLEXT_CALLGET_S(opget)
FLEXT_CALLSET_S(opset)
};
// instantiate the class
FLEXT_NEW("attr2",attr2)
// instantiate static variables
const t_symbol
*attr2::sym_set,
......@@ -85,7 +90,7 @@ const t_symbol
*attr2::sym_div,*attr2::sym_mul,
*attr2::sym_pow;
void attr2::setup(t_class *)
void attr2::setup(t_class *c)
{
// Upon class creation setup some symbols
// This is done only upon creation of of the first "attr2" object
......@@ -95,6 +100,21 @@ void attr2::setup(t_class *)
sym_mul = MakeSymbol("*");
sym_div = MakeSymbol("/");
sym_pow = MakeSymbol("**");
// setup methods and attributes at class scope
// register method (for floats) "m_trigger" for inlet 0
FLEXT_CADDMETHOD(c,0,m_trigger);
// register attribute "arg" with the variable "arg"
FLEXT_CADDATTR_VAR1(c,"arg",arg);
// register attribute "result" with variable "res"
FLEXT_CADDATTR_GET(c,"result",res);
// register attribute "op" with methods "opget" and "opset"
FLEXT_CADDATTR_VAR(c,"op",opget,opset);
}
......@@ -107,18 +127,6 @@ attr2::attr2():
// define outlets
AddOutFloat(); // one float outlet (has index 0)
// register method (for floats) "m_trigger" for inlet 0
FLEXT_ADDMETHOD(0,m_trigger);
// register attribute "arg" with the variable "arg"
FLEXT_ADDATTR_VAR1("arg",arg);
// register attribute "result" with variable "res"
FLEXT_ADDATTR_GET("result",res);
// register attribute "op" with methods "opget" and "opset"
FLEXT_ADDATTR_VAR("op",opget,opset);
}
// receive an operand, do the math operation and trigger the output
......
......@@ -16,6 +16,14 @@
@make -f ..\makefile.pd-bcc NAME=adv1 SETUPFUNCTION=adv1_setup
@cd ..
@cd adv2
@make -f ..\makefile.pd-bcc NAME=adv2 SETUPFUNCTION=adv2_setup
@cd ..
@cd adv3
@make -f ..\makefile.pd-bcc NAME=adv3 SETUPFUNCTION=adv3_setup
@cd ..
@cd attr1
@make -f ..\makefile.pd-bcc NAME=attr1 SETUPFUNCTION=attr1_setup
@cd ..
......@@ -24,6 +32,10 @@
@make -f ..\makefile.pd-bcc NAME=attr2 SETUPFUNCTION=attr2_setup
@cd ..
@cd attr3
@make -f ..\makefile.pd-bcc NAME=attr3 SETUPFUNCTION=attr3_setup
@cd ..
@cd signal1
@make -f ..\makefile.pd-bcc NAME=signal1~ SETUPFUNCTION=signal1_tilde_setup
@cd ..
......
......@@ -4,8 +4,11 @@ nmake /f makefile.pd-msvc NAME=simple1 DIR=simple1
nmake /f makefile.pd-msvc NAME=simple2 DIR=simple2
nmake /f makefile.pd-msvc NAME=simple3 DIR=simple3
nmake /f makefile.pd-msvc NAME=adv1 DIR=adv1
nmake /f makefile.pd-msvc NAME=adv2 DIR=adv2
nmake /f makefile.pd-msvc NAME=adv3 DIR=adv3
nmake /f makefile.pd-msvc NAME=attr1 DIR=attr1
nmake /f makefile.pd-msvc NAME=attr2 DIR=attr2
nmake /f makefile.pd-msvc NAME=attr3 DIR=attr3
nmake /f makefile.pd-msvc NAME=signal1~ DIR=signal1
nmake /f makefile.pd-msvc NAME=signal2~ DIR=signal2
nmake /f makefile.pd-msvc NAME=sndobj1~ DIR=sndobj1
......
......@@ -49,8 +49,8 @@ protected:
float arg; // argument variable
private:
FLEXT_CALLBACK_F(m_trigger); // callback for method "m_trigger" (with one float argument)
FLEXT_ATTRVAR_F(arg);
FLEXT_CALLBACK_F(m_trigger) // callback for method "m_trigger" (with one float argument)
FLEXT_ATTRVAR_F(arg)
};
libbase::libbase():
......
......@@ -26,7 +26,7 @@ LIBS=m pd
# all the source files from the package
EXAMPLES=simple1 simple2 simple3 adv1 attr1 attr2 signal1~ signal2~ sndobj1~ lib1 # thread1 thread2
EXAMPLES=simple1 simple2 simple3 adv1 adv2 adv3 attr1 attr2 attr3 signal1~ signal2~ sndobj1~ lib1 # thread1 thread2
TARGETS=$(patsubst %,$(OUTPATH)/%.dll,$(EXAMPLES))
......
......@@ -24,7 +24,7 @@ LDFLAGS=-bundle -bundle_loader $(PD)
# all the source files from the package
EXAMPLES=simple1 simple2 simple3 adv1 attr1 attr2 signal1~ signal2~ sndobj1~ lib1 thread1 thread2
EXAMPLES=simple1 simple2 simple3 adv1 adv2 adv3 attr1 attr2 attr3 signal1~ signal2~ sndobj1~ lib1 thread1 thread2
TARGETS=$(patsubst %,$(OUTPATH)/%.pd_darwin,$(EXAMPLES))
......
......@@ -24,7 +24,7 @@ LIBS=m
# all the source files from the package
EXAMPLES=simple1 simple2 simple3 adv1 attr1 attr2 sndobj1~ signal1~ signal2~ lib1 thread1 thread2
EXAMPLES=simple1 simple2 simple3 adv1 adv2 adv3 attr1 attr2 attr3 sndobj1~ signal1~ signal2~ lib1 thread1 thread2
TARGETS=$(patsubst %,$(OUTPATH)/%.pd_linux,$(EXAMPLES))
......
#N canvas 329 97 587 348 12;
#X msg 26 97 help;
#X msg 123 146 born;
#X msg 172 147 to;
#X msg 214 149 hula;
#X msg 228 230 yeah;
#X msg 228 192 hula 1;
#X text 280 231 other symbol;
#X text 261 150 tag without argument;
#X text 297 190 tag and argument;
#X text 72 97 print a help message;
#X obj 16 7 cnv 15 550 40 empty empty adv2 10 22 0 24 -260818 -1 0
;
#X text 174 8 flext tutorial \, (C)2002 Thomas Grill;
#X text 174 28 http://www.parasitaere-kapazitaeten.net;
#X obj 148 293 adv2;
#X text 21 49 this is identical to the simple3 example;
#X connect 0 0 13 0;
#X connect 1 0 13 0;
#X connect 2 0 13 0;
#X connect 3 0 13 0;
#X connect 4 0 13 0;
#X connect 5 0 13 0;
#N canvas 175 139 597 355 12;
#X obj 16 7 cnv 15 550 40 empty empty adv3 10 22 0 24 -260818 -1 0
;
#X text 174 8 flext tutorial \, (C)2002 Thomas Grill;
#X text 174 28 http://www.parasitaere-kapazitaeten.net;
#X obj 229 266 adv3 2 5 1;
#X obj 305 303 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 223 300 nbx 5 18 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
12 -228992 -1 -1 0 256;
#X msg 269 120 1 10;
#X msg 389 118 1;
#X msg 424 118 -1;
#X msg 460 118 2;
#X obj 88 119 bng 25 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
-1;
#X msg 313 119 7 2;
#X text 325 300 end has been reached;
#X obj 157 117 nbx 5 18 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
12 -228992 -1 -1 0 256;
#X msg 158 140 set \$1;
#X text 72 98 trigger;
#X text 147 98 set counter;
#X text 264 99 set bounds;
#X text 390 96 set step size;
#X msg 80 186 reset;
#X text 83 166 reset;
#X text 21 49 this is a port of IOhannes Zmoelnings "counter" example
;
#X connect 3 0 5 0;
#X connect 3 1 4 0;
#X connect 6 0 3 1;
#X connect 7 0 3 2;
#X connect 8 0 3 2;
#X connect 9 0 3 2;
#X connect 10 0 3 0;
#X connect 11 0 3 1;
#X connect 13 0 14 0;
#X connect 14 0 3 0;
#X connect 19 0 3 0;
#N canvas 175 139 603 453 12;
#X obj 16 7 cnv 15 550 40 empty empty attr3 10 22 0 24 -260818 -1 0
;
#X text 174 8 flext tutorial \, (C)2002 Thomas Grill;
#X text 174 28 http://www.parasitaere-kapazitaeten.net;
#X obj 293 364 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X obj 196 361 nbx 5 18 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
12 -228992 -1 -1 8 256;
#X msg 264 129 1 10;
#X msg 384 127 1;
#X msg 419 127 -1;
#X msg 455 127 2;
#X obj 36 128 bng 25 250 50 0 empty empty empty 0 -6 0 8 -258699 -1
-1;
#X msg 308 128 7 2;
#X obj 159 123 nbx 5 18 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
12 -228992 -1 -1 0 256;
#X msg 160 146 set \$1;
#X text 20 107 trigger;
#X text 149 104 set counter;
#X text 259 108 set bounds;
#X text 385 105 set step size;
#X msg 87 135 reset;
#X text 90 115 reset;
#X text 23 63 with attributes;
#X obj 197 327 attr3 @bounds 2 5 @step 1;
#X msg 32 195 getattributes;
#X obj 392 363 print;
#X text 440 362 attributes;
#X msg 32 237 getcount;
#X msg 258 234 getbounds;
#X msg 388 232 getstep;
#X text 149 193 list all attributes;
#X msg 32 266 count 3;
#X text 109 238 get count;
#X text 104 266 set count;
#X msg 257 261 bounds 5 15;
#X msg 387 259 step 3;
#X text 21 49 this is a port of IOhannes Zmoelnings "counter" example
;
#X connect 5 0 20 1;
#X connect 6 0 20 2;
#X connect 7 0 20 2;
#X connect 8 0 20 2;
#X connect 9 0 20 0;
#X connect 10 0 20 1;
#X connect 11 0 12 0;
#X connect 12 0 20 0;
#X connect 17 0 20 0;
#X connect 20 0 4 0;
#X connect 20 1 3 0;
#X connect 20 2 22 0;
#X connect 21 0 20 0;
#X connect 24 0 20 0;
#X connect 25 0 20 0;
#X connect 26 0 20 0;
#X connect 28 0 20 0;
#X connect 31 0 20 0;
#X connect 32 0 20 0;
#N canvas 405 36 584 392 12;
#X obj 56 348 dac~;
#X obj 15 8 cnv 15 550 40 empty empty sndobj1 10 22 0 24 -260818 -1
0;
#X text 175 8 flext tutorial \, (C)2002 Thomas Grill;
#X text 175 28 http://www.parasitaere-kapazitaeten.net;
#X text 170 285 adjust the volume;
#X text 35 97 source;
#X obj 171 268 hsl 128 15 0.01 1 1 0 empty empty empty -2 -6 0 8 -261681
-1 -1 7200 1;
#X msg 160 148 shL \$1;
#X msg 218 148 shR \$1;
#X obj 244 84 hsl 128 15 0.5 2 1 0 empty empty empty -2 -6 0 8 -261681
-1 -1 1800 1;
#X obj 244 104 hsl 128 15 0.5 2 1 0 empty empty empty -2 -6 0 8 -261681
-1 -1 5100 1;
#X text 149 82 pitch left;
#X text 149 102 pitch right;
#X obj 31 119 osc~ 442;
#X obj 32 226 sndobj1~ @shL 0.7 @shR 1.2;
#X obj 32 304 *~ 0.3;
#X obj 91 304 *~ 0.3;
#X connect 6 0 15 1;
#X connect 6 0 16 1;
#X connect 7 0 14 0;
#X connect 8 0 14 0;
#X connect 9 0 7 0;
#X connect 10 0 8 0;
#X connect 13 0 14 0;
#X connect 13 0 14 1;
#X connect 14 0 15 0;
#X connect 14 1 16 0;
#X connect 15 0 0 0;
#X connect 16 0 0 1;
......@@ -37,7 +37,7 @@ protected:
void m_bang(); // method for bang
private:
FLEXT_CALLBACK(m_bang); // callback for method "m_bang"
FLEXT_CALLBACK(m_bang) // callback for method "m_bang"
};
// instantiate the class
......
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