Commit d1e37cfc authored by thomas's avatar thomas
Browse files

no message


git-svn-id: https://svn.grrrr.org/ext/trunk@97 4d9ac71a-51e6-0310-8455-cad1006bcd31
parent 007cd430
......@@ -15,10 +15,11 @@ Donations for further development of the package are highly appreciated.
Package files:
- readme.txt: this one
- gpl.txt,license.txt: GPL license stuff
- flstdc.h: Basic definitions in classic C - Common vocabulary for the different platforms
- flstdc.h: Basic definitions in classic C - some common vocabulary for the different platforms
- flbase.h,flbase.cpp: GEM-like C++ interface
- flext.h,flext.cpp: actual base classes for message (flext_base) and dsp (flext_dsp) processing
- flbuf.cpp: buffer object handling for base classes
- fldefs.h: definitions for internal flext use
- flcwmax.h: trivial prefix header file for Max/MSP CodeWarrior projects
......@@ -49,9 +50,11 @@ pros:
- better readability of code compared to straight C externals
- faster development, more robust coding
- sharing of common methods and data by using base classes
- any input to any inlet (with the exception of signal streams)
cons:
- introduces a small overhead to speed (esp. to messages)
- overhead in object size (due to possibly unneeded code)
see flext.h for the documented base classes
......@@ -61,17 +64,18 @@ see flext.h for the documented base classes
Version history:
0.2.0:
- internal proxy objects for any non-leftmost inlets
- method/argument parsing is done by flext
- integrated more system functions into flext_base & eliminated superfluous #defines
- distribute list (into inlet 0) elements over inlets (right to left, only if no explicit list handler defined)
- added outlets for anythings
- defines for callback-to-method functions and method setup (FLEXT_CALLBACK*, FLEXT_ADD*)
- no support for default arguments (A_DEFFLOAT and A_DEFSYMBOL).. use GIMME instead!
- uses PD's or Max's memory allocation functions (for safety in Max's overdrive)
- added outlets for anythings
- no support for default arguments (A_DEFFLOAT and A_DEFSYMBOL).. use GIMME instead!
- better graphics update behavior for PD
- changed "enable" message for DSP objects to "dspon" ("enable" is reserved in Max/MSP)
- internal proxy objects for any non-leftmost inlets
- improved behavior for invalid/undefined buffers/arrays
- changed "enable" message for DSP objects to "dspon" ("enable" is reserved in Max/MSP)
- 128-bit aligned memory allocation with new[]
- method/argument parsing is done by flext
- integrated more system functions into flext_base & eliminated superfluous #defines
0.1.1:
- documentation for flext.h
......@@ -123,13 +127,11 @@ bugs:
no unfixed known
tests:
- do i have to destroy the method list elements with the list?
- do i have to destroy the method list elements with the list? i guess so....
features:
- MAX/MSP disributes list elements over inlets (if no explicit handler defined) -> emulate this also for flext?
- abstraction for parsing argument lists
- abstraction for creating lists and anythings
- simulate loadbang on object creation for PD
- abstraction for clock functions
- message queue? (for multithreaded operation)
- sending messages to own inlet (passing computation to other patch objects - message queue?)
......
No preview for this file type
......@@ -151,7 +151,11 @@ flext_base::~flext_base()
delete[] inlets;
}
// do i have to destroy the method list elements?
// delete method list elements
while(!mlst.empty()) {
delete mlst.back();
mlst.pop_back();
}
}
flext_base::xlet::~xlet() { if(nxt) delete nxt; }
......@@ -214,7 +218,8 @@ BL flext_base::setup_inout()
}
else if(incnt >= 1) {
switch(list[0]) {
case xlet::tp_def:
case xlet::tp_any:
// leftmost inlet is already there...
break;
case xlet::tp_sig:
++insigs;
......@@ -272,50 +277,52 @@ BL flext_base::setup_inout()
while(insigs < incnt && list[insigs] == xlet::tp_sig) ++insigs;
for(ix = incnt-1; ix >= insigs; --ix) {
switch(list[ix]) {
case xlet::tp_sig:
error("%s: All signal inlets must be at the left side",thisName());
if(ix == 0) {
if(list[ix] != xlet::tp_any) {
error("%s: Leftmost inlet must be of type signal or default",thisName());
ok = false;
break;
case xlet::tp_float:
if(ix >= 10) {
post("%s: Only 9 float inlets possible",thisName());
}
}
else {
switch(list[ix]) {
case xlet::tp_sig:
error("%s: All signal inlets must be at the left side",thisName());
ok = false;
}
else
floatin(x_obj,ix);
break;
case xlet::tp_flint:
if(ix >= 10) {
post("%s: Only 9 flint inlets possible",thisName());
break;
case xlet::tp_float:
if(ix >= 10) {
post("%s: Only 9 float inlets possible",thisName());
ok = false;
}
else
floatin(x_obj,ix);
break;
case xlet::tp_flint:
if(ix >= 10) {
post("%s: Only 9 flint inlets possible",thisName());
ok = false;
}
else
intin(x_obj,ix);
break;
case xlet::tp_any: // non-leftmost
case xlet::tp_sym:
case xlet::tp_list:
inlets[ix] = (px_object *)proxy_new(x_obj,ix,&((flext_hdr *)x_obj)->curinlet);
break;
/*
case xlet::tp_def:
if(ix) error("%s: Default inlet type reserved for inlet #0",thisName());
break;
*/
default:
error("%s: Wrong type for inlet #%i: %i",thisName(),ix,(I)list[ix]);
ok = false;
}
else
intin(x_obj,ix);
break;
case xlet::tp_sym:
case xlet::tp_any:
case xlet::tp_list:
inlets[ix] = (px_object *)proxy_new(x_obj,ix,&((flext_hdr *)x_obj)->curinlet);
break;
case xlet::tp_def:
if(ix) error("%s: Default inlet type reserved for inlet #0",thisName());
break;
default:
error("%s: Wrong type for inlet #%i: %i",thisName(),ix,(I)list[ix]);
ok = false;
}
}
if(insigs) {
dsp_setup(thisHdr(),insigs); // signal inlets
}
else {
if(incnt && list[0] != xlet::tp_def) {
error("%s: Leftmost inlet must be of type signal or default",thisName());
ok = false;
}
}
}
if(insigs) dsp_setup(thisHdr(),insigs); // signal inlets
}
#endif
......@@ -554,11 +561,32 @@ BL flext_base::m_methodmain(I inlet,const t_symbol *s,I argc,t_atom *argv)
else ++it;
}
if(!ret) LOG("Did not find any method tag");
if(!ret && inlet == 0 && s == sym_list) {
// distribute list elements over inlets (Max/MSP behavior)
I a = incnt-insigs;
if(a > argc) a = argc;
for(I i = a-1; i >= 0; --i) { // right to left distribution
const t_symbol *s = NULL;
if(is_float(argv[i])) s = sym_float;
else if(is_int(argv[i])) s = sym_int;
else if(is_symbol(argv[i])) s = sym_symbol;
#ifdef PD
else if(is_pointer(argv[i])) s = sym_pointer; // can pointer atoms occur here?
#endif
if(s) m_methodmain(i,s,1,argv+i);
}
ret = true;
}
if(!ret) m_method_(inlet,s,argc,argv);
return ret; // true if appropriate handler was found and called
}
V flext_base::m_method_(I inlet,const t_symbol *s,I argc,t_atom *argv) {}
flext_base::methitem::methitem(I in,t_symbol *t):
inlet(in),tag(t),
......
......@@ -65,9 +65,14 @@ public:
// quickhelp for inlets/outlets (Max/MSP only)
virtual V m_assist(L /*msg*/,L /*arg*/,C * /*s*/) {}
// called for every incoming message (returns true if a handler was found and called)
// called for every incoming message
// all method handling is done in there
// returns true if a handler was found and called)
virtual BL m_methodmain(I inlet,const t_symbol *s,I argc,t_atom *argv);
// called for every unhandled message (by m_methodmain)
virtual V m_method_(I inlet,const t_symbol *s,I argc,t_atom *argv);
// --- buffer/array stuff -----------------------------------------
......@@ -122,18 +127,18 @@ public:
// define inlets/outlets - all (also default) inlets must be defined
// argument m specifies multiple inlet/outlet count
V add_in_def() { AddInlet(xlet::tp_def,1); }
// V add_in_def() { AddInlet(xlet::tp_def,1); }
V add_in_anything(I m = 1) { AddInlet(xlet::tp_any,m); } // leftmost or via proxy
V add_in_float(I m = 1) { AddInlet(xlet::tp_float,m); }
V add_in_flint(I m = 1) { AddInlet(xlet::tp_flint,m); }
V add_in_symbol(I m = 1) { AddInlet(xlet::tp_sym,m); }
V add_in_list(I m = 1) { AddInlet(xlet::tp_list,m); } // via proxy
V add_in_anything(I m = 1) { AddInlet(xlet::tp_any,m); } // via proxy
V add_out_anything(I m = 1) { AddOutlet(xlet::tp_any,m); }
V add_out_float(I m = 1) { AddOutlet(xlet::tp_float,m); }
V add_out_flint(I m = 1) { AddOutlet(xlet::tp_flint,m); }
V add_out_symbol(I m = 1) { AddOutlet(xlet::tp_sym,m); }
V add_out_list(I m = 1) { AddOutlet(xlet::tp_list,m); }
V add_out_anything(I m = 1) { AddOutlet(xlet::tp_any,m); }
// must be called to actually set up the defined inlets/outlets
// only ONCE!!!
......@@ -269,7 +274,9 @@ protected:
struct xlet {
enum type {
tp_none = 0,tp_def,tp_float,tp_flint,tp_sym,tp_list,tp_sig,tp_any
tp_none = 0,
// tp_def,
tp_float,tp_flint,tp_sym,tp_list,tp_sig,tp_any
};
xlet(type t): tp(t),nxt(NULL) {}
......
Supports Markdown
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