Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jonathan Wilkes
flext
Commits
9e43291d
Commit
9e43291d
authored
Mar 27, 2002
by
thomas
Browse files
no message
git-svn-id:
https://svn.grrrr.org/ext/trunk@117
4d9ac71a-51e6-0310-8455-cad1006bcd31
parent
f618490b
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
flext.cw
View file @
9e43291d
No preview for this file type
readme.txt
View file @
9e43291d
...
...
@@ -68,7 +68,7 @@ Version history:
- Max/MSP: all signal inlets can receive messages
- method/argument parsing is done by flext - float/int are not distinguished, the first handler wins
- 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
)
- distribute list (into inlet 0) elements over inlets (right to left)
- added outlets for anythings
- defines for callback-to-method functions and method setup (FLEXT_CALLBACK*, FLEXT_ADD*)
- uses PD's or Max's memory allocation functions (for safety in Max's overdrive)
...
...
@@ -78,6 +78,9 @@ Version history:
- 128-bit aligned memory allocation with new[]
- use MaxMSP internal z_disabled flag with flext_dsp for pausing/resuming dsp processing
- included CHECK_TILDE, a test whether a tilde object (defined as FLEXT_TILDE_*) has a trailing ~. (debug mode only)
- changed notation of flext functions from to_out_float like to ToOutFloat like
- eliminated trivial shortcuts for built-in types
- compatibility mode is now set by the preprocessor define COMPAT
0.1.1:
- documentation for flext.h
...
...
@@ -108,6 +111,7 @@ Platform specific:
Restrictions in compatibility mode:
- Max allows only 9 float/int inlets
- Max allows only 3 typed creation arguments -> use GIMME for more
Porting to new platforms:
- enums must be int-sized
...
...
@@ -130,6 +134,7 @@ bugs:
tests:
- PD: figure out what "pointer" messages do and where they occur
- MaxMSP: is it true that float creation arguments are doubles? (see Max-dev-list)
features:
- abstraction for parsing argument lists
...
...
source/flbase.h
View file @
9e43291d
...
...
@@ -169,7 +169,7 @@ protected: \
inline t_sigobj *thisHdr() { return &x_obj->obj; } \
inline t_class *thisClass() { return FLEXT_GETCLASS(x_obj); } \
inline const char *thisName() const { return m_name; } \
static NEW_CLASS *thisObject(
V
*c) { return (NEW_CLASS *)((flext_hdr *)c)->data; }
static NEW_CLASS *thisObject(
void
*c) { return (NEW_CLASS *)((flext_hdr *)c)->data; }
#define FLEXT_HEADER_S(NEW_CLASS, PARENT_CLASS) \
...
...
@@ -185,7 +185,7 @@ protected: \
inline t_sigobj *thisHdr() { return &x_obj->obj; } \
inline t_class *thisClass() { return FLEXT_GETCLASS(x_obj); } \
inline const char *thisName() const { return m_name; } \
static NEW_CLASS *thisObject(
V
*c) { return (NEW_CLASS *)((flext_hdr *)c)->data; } \
static NEW_CLASS *thisObject(
void
*c) { return (NEW_CLASS *)((flext_hdr *)c)->data; } \
private: \
static void cb_setup(t_class *classPtr);
...
...
@@ -251,6 +251,9 @@ static void cb_setup(t_class *classPtr);
#define FLEXT_TILDE_3ARGS(NAME,NEW_CLASS, TYPE, TTWO, TTHREE) \
REAL_NEW_WITH_ARG_ARG_ARG(NAME,NEW_CLASS, _tilde_setup, _class, TYPE, FLEXTTP(TYPE), TTWO, FLEXTTP(TTWO), TTHREE, FLEXTTP(TTHREE))
#ifndef COMPAT
//
// FOUR ARGUMENTS
/////////////////////////////////////////////////
...
...
@@ -260,6 +263,8 @@ static void cb_setup(t_class *classPtr);
#define FLEXT_TILDE_4ARGS(NAME,NEW_CLASS, TYPE, TTWO, TTHREE, TFOUR) \
REAL_NEW_WITH_ARG_ARG_ARG_ARG(NAME,NEW_CLASS, _tilde_setup, _class, TYPE, FLEXTTP(TYPE), TTWO, FLEXTTP(TTWO), TTHREE, FLEXTTP(TTHREE), TFOUR, FLEXTTP(TFOUR))
#endif
////////////////////////////////////////
// These definitions are used below
////////////////////////////////////////
...
...
source/flbuf.cpp
View file @
9e43291d
...
...
@@ -14,7 +14,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#define DIRTY_INTERVAL 0 // buffer dirty check in msec
#endif
flext_base
::
buffer
::
buffer
(
t_symbol
*
bn
,
BL
delayed
)
:
flext_base
::
buffer
::
buffer
(
t_symbol
*
bn
,
bool
delayed
)
:
sym
(
NULL
),
data
(
NULL
),
chns
(
0
),
frames
(
0
)
{
...
...
@@ -35,10 +35,10 @@ flext_base::buffer::~buffer()
#endif
}
I
flext_base
::
buffer
::
Set
(
t_symbol
*
s
,
BL
nameonly
)
int
flext_base
::
buffer
::
Set
(
t_symbol
*
s
,
bool
nameonly
)
{
I
ret
=
0
;
BL
valid
=
data
!=
NULL
;
// valid now? (before change)
int
ret
=
0
;
bool
valid
=
data
!=
NULL
;
// valid now? (before change)
if
(
s
&&
sym
!=
s
)
{
ret
=
-
1
;
...
...
@@ -54,8 +54,8 @@ I flext_base::buffer::Set(t_symbol *s,BL nameonly)
}
else
if
(
!
nameonly
)
{
#ifdef PD
I
frames1
;
F
*
data1
;
int
frames1
;
float
*
data1
;
t_garray
*
a
=
(
t_garray
*
)
pd_findbyclass
(
sym
,
garray_class
);
if
(
!
a
)
...
...
@@ -106,7 +106,7 @@ I flext_base::buffer::Set(t_symbol *s,BL nameonly)
#ifdef PD
V
flext_base
::
buffer
::
SetRefrIntv
(
F
intv
)
void
flext_base
::
buffer
::
SetRefrIntv
(
float
intv
)
{
interval
=
intv
;
if
(
interval
==
0
&&
ticking
)
{
...
...
@@ -115,11 +115,11 @@ V flext_base::buffer::SetRefrIntv(F intv)
}
}
#else
V
flext_base
::
buffer
::
SetRefrIntv
(
F
)
{}
void
flext_base
::
buffer
::
SetRefrIntv
(
float
)
{}
#endif
V
flext_base
::
buffer
::
Dirty
(
BL
force
)
void
flext_base
::
buffer
::
Dirty
(
bool
force
)
{
if
(
sym
)
{
#ifdef PD
...
...
@@ -150,7 +150,7 @@ V flext_base::buffer::Dirty(BL force)
}
#ifdef PD
V
flext_base
::
buffer
::
cb_tick
(
buffer
*
b
)
void
flext_base
::
buffer
::
cb_tick
(
buffer
*
b
)
{
t_garray
*
a
=
(
t_garray
*
)
pd_findbyclass
(
b
->
sym
,
garray_class
);
if
(
a
)
garray_redraw
(
a
);
...
...
source/fldsp.cpp
View file @
9e43291d
...
...
@@ -14,7 +14,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
// === flext_dsp ==============================================
V
flext_dsp
::
cb_setup
(
t_class
*
c
)
void
flext_dsp
::
cb_setup
(
t_class
*
c
)
{
#ifdef PD
CLASS_MAINSIGNALIN
(
c
,
flext_hdr
,
defsig
);
...
...
@@ -52,13 +52,13 @@ t_int *flext_dsp::dspmeth(t_int *w)
#else
if
(
obj
->
dspon
)
#endif
obj
->
m_signal
((
I
)
w
[
2
],
obj
->
invecs
,
obj
->
outvecs
);
obj
->
m_signal
((
int
)
w
[
2
],
obj
->
invecs
,
obj
->
outvecs
);
return
w
+
3
;
}
V
flext_dsp
::
m_dsp
(
I
/*n*/
,
F
*
const
*
/*insigs*/
,
F
*
const
*
/*outsigs*/
)
{}
void
flext_dsp
::
m_dsp
(
int
/*n*/
,
float
*
const
*
/*insigs*/
,
float
*
const
*
/*outsigs*/
)
{}
V
flext_dsp
::
cb_dsp
(
t_class
*
c
,
t_signal
**
sp
)
void
flext_dsp
::
cb_dsp
(
t_class
*
c
,
t_signal
**
sp
)
{
flext_dsp
*
obj
=
thisObject
(
c
);
...
...
@@ -66,13 +66,13 @@ V flext_dsp::cb_dsp(t_class *c,t_signal **sp)
obj
->
srate
=
sp
[
0
]
->
s_sr
;
// store in and out signal vectors
I
i
,
in
=
obj
->
c
nt
_ins
ig
(),
out
=
obj
->
c
nt
_o
ut
s
ig
();
int
i
,
in
=
obj
->
C
nt
InS
ig
(),
out
=
obj
->
C
nt
O
ut
S
ig
();
if
(
obj
->
invecs
)
delete
[]
obj
->
invecs
;
obj
->
invecs
=
new
F
*
[
in
];
obj
->
invecs
=
new
float
*
[
in
];
for
(
i
=
0
;
i
<
in
;
++
i
)
obj
->
invecs
[
i
]
=
sp
[
i
]
->
s_vec
;
if
(
obj
->
outvecs
)
delete
[]
obj
->
outvecs
;
obj
->
outvecs
=
new
F
*
[
out
];
obj
->
outvecs
=
new
float
*
[
out
];
for
(
i
=
0
;
i
<
out
;
++
i
)
obj
->
outvecs
[
i
]
=
sp
[
in
+
i
]
->
s_vec
;
// with the following call derived classes can do their eventual DSP setup
...
...
@@ -83,8 +83,8 @@ V flext_dsp::cb_dsp(t_class *c,t_signal **sp)
}
#ifndef MAXMSP
V
flext_dsp
::
cb_enable
(
t_class
*
c
,
FI
on
)
{
thisObject
(
c
)
->
m_enable
(
on
!=
0
);
}
V
flext_dsp
::
m_enable
(
BL
en
)
{
dspon
=
en
;
}
void
flext_dsp
::
cb_enable
(
t_class
*
c
,
flint
on
)
{
thisObject
(
c
)
->
m_enable
(
on
!=
0
);
}
void
flext_dsp
::
m_enable
(
bool
en
)
{
dspon
=
en
;
}
#endif
source/flext.cpp
View file @
9e43291d
...
...
@@ -22,25 +22,25 @@ struct flext_base::px_object // no virtual table!
{
t_object
obj
;
// MUST reside at memory offset 0
flext_base
*
base
;
I
index
;
int
index
;
V
init
(
flext_base
*
b
,
I
ix
)
{
base
=
b
;
index
=
ix
;
}
static
V
px_method
(
px_object
*
c
,
const
t_symbol
*
s
,
I
argc
,
t_atom
*
argv
);
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
);
};
V
flext_base
::
px_object
::
px_method
(
px_object
*
obj
,
const
t_symbol
*
s
,
I
argc
,
t_atom
*
argv
)
void
flext_base
::
px_object
::
px_method
(
px_object
*
obj
,
const
t_symbol
*
s
,
int
argc
,
t_atom
*
argv
)
{
obj
->
base
->
m_methodmain
(
obj
->
index
,
s
,
argc
,
argv
);
}
V
flext_base
::
cb_px_anything
(
t_class
*
c
,
const
t_symbol
*
s
,
I
argc
,
t_atom
*
argv
)
void
flext_base
::
cb_px_anything
(
t_class
*
c
,
const
t_symbol
*
s
,
int
argc
,
t_atom
*
argv
)
{
thisObject
(
c
)
->
m_methodmain
(
0
,
s
,
argc
,
argv
);
}
#define DEF_IN_FT(IX) \
V
flext_base::cb_px_ft ## IX(t_class *c,
F
v) { \
void
flext_base::cb_px_ft ## IX(t_class *c,
float
v) { \
t_atom atom; SETFLOAT(&atom,v); \
thisObject(c)->m_methodmain(IX,&s_float,1,&atom); \
}
...
...
@@ -50,16 +50,16 @@ add_method1(c,cb_px_ft ## IX,"ft" #IX,A_FLOAT)
#elif defined(MAXMSP)
V
flext_base
::
cb_px_anything
(
t_class
*
c
,
const
t_symbol
*
s
,
I
argc
,
t_atom
*
argv
)
void
flext_base
::
cb_px_anything
(
t_class
*
c
,
const
t_symbol
*
s
,
int
argc
,
t_atom
*
argv
)
{
// check if inlet allows anything (or list)
flext_base
*
o
=
thisObject
(
c
);
I
ci
=
((
flext_hdr
*
)
o
->
x_obj
)
->
curinlet
;
int
ci
=
((
flext_hdr
*
)
o
->
x_obj
)
->
curinlet
;
o
->
m_methodmain
(
ci
,
s
,
argc
,
argv
);
}
V
flext_base
::
cb_px_int
(
t_class
*
c
,
I
v
)
void
flext_base
::
cb_px_int
(
t_class
*
c
,
int
v
)
{
// check if inlet allows int type
t_atom
atom
;
...
...
@@ -67,7 +67,7 @@ V flext_base::cb_px_int(t_class *c,I v)
cb_px_anything
(
c
,
sym_int
,
1
,
&
atom
);
}
V
flext_base
::
cb_px_float
(
t_class
*
c
,
F
v
)
void
flext_base
::
cb_px_float
(
t_class
*
c
,
float
v
)
{
// check if inlet allows float type
t_atom
atom
;
...
...
@@ -75,15 +75,15 @@ V flext_base::cb_px_float(t_class *c,F v)
cb_px_anything
(
c
,
sym_float
,
1
,
&
atom
);
}
V
flext_base
::
cb_px_bang
(
t_class
*
c
)
void
flext_base
::
cb_px_bang
(
t_class
*
c
)
{
// check if inlet allows bang
cb_px_anything
(
c
,
sym_bang
,
0
,
NULL
);
}
#define DEF_IN_FT(IX) \
V
flext_base::cb_px_in ## IX(t_class *c,
I
v) {
L
&ci = ((flext_hdr *)thisObject(c)->x_obj)->curinlet; ci = IX; cb_px_int(c,v); ci = 0; } \
V
flext_base::cb_px_ft ## IX(t_class *c,
F
v) {
L
&ci = ((flext_hdr *)thisObject(c)->x_obj)->curinlet; ci = IX; cb_px_float(c,v); ci = 0; }
void
flext_base::cb_px_in ## IX(t_class *c,
int
v) {
long
&ci = ((flext_hdr *)thisObject(c)->x_obj)->curinlet; ci = IX; cb_px_int(c,v); ci = 0; } \
void
flext_base::cb_px_ft ## IX(t_class *c,
float
v) {
long
&ci = ((flext_hdr *)thisObject(c)->x_obj)->curinlet; ci = IX; cb_px_float(c,v); ci = 0; }
#define ADD_IN_FT(IX) \
add_method1(c,cb_px_in ## IX,"in" #IX,A_INT); \
...
...
@@ -106,7 +106,7 @@ DEF_IN_FT(9)
// === flext_base ============================================
BL
flext_base
::
compatibility
=
true
;
//bool
flext_base::compatibility = true;
const
t_symbol
*
flext_base
::
sym_float
=
NULL
;
...
...
@@ -140,7 +140,7 @@ flext_base::~flext_base()
if
(
outlets
)
delete
[]
outlets
;
if
(
inlets
)
{
for
(
I
ix
=
0
;
ix
<
incnt
;
++
ix
)
for
(
int
ix
=
0
;
ix
<
incnt
;
++
ix
)
if
(
inlets
[
ix
])
{
#ifdef PD
pd_free
(
&
inlets
[
ix
]
->
obj
.
ob_pd
);
...
...
@@ -156,7 +156,7 @@ flext_base::~flext_base()
flext_base
::
xlet
::~
xlet
()
{
if
(
nxt
)
delete
nxt
;
}
V
flext_base
::
AddXlet
(
xlet
::
type
tp
,
I
mult
,
xlet
*&
root
)
void
flext_base
::
AddXlet
(
xlet
::
type
tp
,
int
mult
,
xlet
*&
root
)
{
if
(
!
root
&&
mult
)
{
root
=
new
xlet
(
tp
);
--
mult
;
}
if
(
mult
)
{
...
...
@@ -167,21 +167,21 @@ V flext_base::AddXlet(xlet::type tp,I mult,xlet *&root)
}
V
flext_base
::
to_out_f
loat
(
outlet
*
o
,
F
f
)
{
outlet_float
((
t_outlet
*
)
o
,
f
);
}
V
flext_base
::
to_out_f
lint
(
outlet
*
o
,
FI
f
)
{
outlet_flint
((
t_outlet
*
)
o
,
f
);
}
V
flext_base
::
to_out_s
ymbol
(
outlet
*
o
,
const
t_symbol
*
s
)
{
outlet_symbol
((
t_outlet
*
)
o
,
const_cast
<
t_symbol
*>
(
s
));
}
V
flext_base
::
to_out_l
ist
(
outlet
*
o
,
I
argc
,
t_atom
*
argv
)
{
outlet_list
((
t_outlet
*
)
o
,
gensym
(
"list"
),
argc
,
argv
);
}
V
flext_base
::
to_out_a
nything
(
outlet
*
o
,
const
t_symbol
*
s
,
I
argc
,
t_atom
*
argv
)
{
outlet_anything
((
t_outlet
*
)
o
,
const_cast
<
t_symbol
*>
(
s
),
argc
,
argv
);
}
void
flext_base
::
ToOutF
loat
(
outlet
*
o
,
float
f
)
{
outlet_float
((
t_outlet
*
)
o
,
f
);
}
void
flext_base
::
ToOutF
lint
(
outlet
*
o
,
flint
f
)
{
outlet_flint
((
t_outlet
*
)
o
,
f
);
}
void
flext_base
::
ToOutS
ymbol
(
outlet
*
o
,
const
t_symbol
*
s
)
{
outlet_symbol
((
t_outlet
*
)
o
,
const_cast
<
t_symbol
*>
(
s
));
}
void
flext_base
::
ToOutL
ist
(
outlet
*
o
,
int
argc
,
t_atom
*
argv
)
{
outlet_list
((
t_outlet
*
)
o
,
gensym
(
"list"
),
argc
,
argv
);
}
void
flext_base
::
ToOutA
nything
(
outlet
*
o
,
const
t_symbol
*
s
,
int
argc
,
t_atom
*
argv
)
{
outlet_anything
((
t_outlet
*
)
o
,
const_cast
<
t_symbol
*>
(
s
),
argc
,
argv
);
}
BL
flext_base
::
s
etup
_ino
ut
()
bool
flext_base
::
S
etup
InO
ut
()
{
BL
ok
=
true
;
bool
ok
=
true
;
incnt
=
insigs
=
0
;
if
(
inlets
)
{
for
(
I
ix
=
0
;
ix
<
incnt
;
++
ix
)
for
(
int
ix
=
0
;
ix
<
incnt
;
++
ix
)
if
(
inlets
[
ix
])
{
#ifdef PD
pd_free
(
&
inlets
[
ix
]
->
obj
.
ob_pd
);
...
...
@@ -198,7 +198,7 @@ BL flext_base::setup_inout()
incnt
=
0
;
for
(
xi
=
inlist
;
xi
;
xi
=
xi
->
nxt
)
++
incnt
;
xlet
::
type
*
list
=
new
xlet
::
type
[
incnt
];
I
i
;
int
i
;
for
(
xi
=
inlist
,
i
=
0
;
xi
;
xi
=
xi
->
nxt
,
++
i
)
list
[
i
]
=
xi
->
tp
;
delete
inlist
;
inlist
=
NULL
;
...
...
@@ -208,7 +208,7 @@ BL flext_base::setup_inout()
// type info is now in list array
#ifdef PD
{
I
cnt
=
0
;
int
cnt
=
0
;
if
(
incnt
>=
1
)
{
switch
(
list
[
0
])
{
...
...
@@ -225,11 +225,11 @@ BL flext_base::setup_inout()
}
}
for
(
I
ix
=
1
;
ix
<
incnt
;
++
ix
,
++
cnt
)
{
for
(
int
ix
=
1
;
ix
<
incnt
;
++
ix
,
++
cnt
)
{
switch
(
list
[
ix
])
{
case
xlet
::
tp_float
:
case
xlet
::
tp_flint
:
{
C
sym
[]
=
"ft??"
;
char
sym
[]
=
"ft??"
;
if
(
ix
>=
10
)
{
if
(
compatibility
)
{
// Max allows max. 9 inlets
...
...
@@ -269,7 +269,7 @@ BL flext_base::setup_inout()
}
break
;
default:
error
(
"%s: Wrong type for inlet #%i: %i"
,
thisName
(),
ix
,(
I
)
list
[
ix
]);
error
(
"%s: Wrong type for inlet #%i: %i"
,
thisName
(),
ix
,(
int
)
list
[
ix
]);
ok
=
false
;
}
}
...
...
@@ -278,7 +278,7 @@ BL flext_base::setup_inout()
}
#elif defined(MAXMSP)
{
I
ix
,
cnt
;
int
ix
,
cnt
;
// count leftmost signal inlets
while
(
insigs
<
incnt
&&
list
[
insigs
]
==
xlet
::
tp_sig
)
++
insigs
;
...
...
@@ -322,7 +322,7 @@ BL flext_base::setup_inout()
break;
*/
default:
error
(
"%s: Wrong type for inlet #%i: %i"
,
thisName
(),
ix
,(
I
)
list
[
ix
]);
error
(
"%s: Wrong type for inlet #%i: %i"
,
thisName
(),
ix
,(
int
)
list
[
ix
]);
ok
=
false
;
}
}
...
...
@@ -345,7 +345,7 @@ BL flext_base::setup_inout()
outcnt
=
0
;
for
(
xi
=
outlist
;
xi
;
xi
=
xi
->
nxt
)
++
outcnt
;
xlet
::
type
*
list
=
new
xlet
::
type
[
outcnt
];
I
i
;
int
i
;
for
(
xi
=
outlist
,
i
=
0
;
xi
;
xi
=
xi
->
nxt
,
++
i
)
list
[
i
]
=
xi
->
tp
;
delete
outlist
;
outlist
=
NULL
;
...
...
@@ -353,9 +353,9 @@ BL flext_base::setup_inout()
// type info is now in list array
#ifdef PD
for
(
I
ix
=
0
;
ix
<
outcnt
;
++
ix
)
for
(
int
ix
=
0
;
ix
<
outcnt
;
++
ix
)
#elif defined(MAXMSP)
for
(
I
ix
=
outcnt
-
1
;
ix
>=
0
;
--
ix
)
for
(
int
ix
=
outcnt
-
1
;
ix
>=
0
;
--
ix
)
#endif
{
switch
(
list
[
ix
])
{
...
...
@@ -391,7 +391,7 @@ BL flext_base::setup_inout()
}
V
flext_base
::
cb_setup
(
t_class
*
c
)
void
flext_base
::
cb_setup
(
t_class
*
c
)
{
#ifdef PD
sym_anything
=
&
s_anything
;
...
...
@@ -442,14 +442,14 @@ V flext_base::cb_setup(t_class *c)
ADD_IN_FT
(
9
);
}
V
flext_base
::
cb_help
(
t_class
*
c
)
{
thisObject
(
c
)
->
m_help
();
}
void
flext_base
::
cb_help
(
t_class
*
c
)
{
thisObject
(
c
)
->
m_help
();
}
V
flext_base
::
cb_loadbang
(
t_class
*
c
)
{
thisObject
(
c
)
->
m_loadbang
();
}
void
flext_base
::
cb_loadbang
(
t_class
*
c
)
{
thisObject
(
c
)
->
m_loadbang
();
}
#ifdef MAXMSP
V
flext_base
::
cb_assist
(
t_class
*
c
,
V
*
/*b*/
,
L
msg
,
L
arg
,
C
*
s
)
{
thisObject
(
c
)
->
m_assist
(
msg
,
arg
,
s
);
}
void
flext_base
::
cb_assist
(
t_class
*
c
,
void
*
/*b*/
,
long
msg
,
long
arg
,
char
*
s
)
{
thisObject
(
c
)
->
m_assist
(
msg
,
arg
,
s
);
}
#endif
V
flext_base
::
m_help
()
void
flext_base
::
m_help
()
{
// This should better be overloaded
post
(
"%s (using flext "
FLEXT_VERSTR
") - compiled on %s %s"
,
thisName
(),
__DATE__
,
__TIME__
);
...
...
@@ -457,29 +457,29 @@ V flext_base::m_help()
union
t_any
{
F
ft
;
I
it
;
float
ft
;
int
it
;
t_symbol
*
st
;
#ifdef PD
t_gpointer
*
pt
;
#endif
};
typedef
V
(
*
methfun_G
)(
flext_base
*
c
,
I
argc
,
t_atom
*
argv
);
typedef
V
(
*
methfun_A
)(
flext_base
*
c
,
const
t_symbol
*
s
,
I
argc
,
t_atom
*
argv
);
typedef
V
(
*
methfun_0
)(
flext_base
*
c
);
typedef
void
(
*
methfun_G
)(
flext_base
*
c
,
int
argc
,
t_atom
*
argv
);
typedef
void
(
*
methfun_A
)(
flext_base
*
c
,
const
t_symbol
*
s
,
int
argc
,
t_atom
*
argv
);
typedef
void
(
*
methfun_0
)(
flext_base
*
c
);
#define MAXARGS 5
typedef
V
(
*
methfun_1
)(
flext_base
*
c
,
t_any
&
);
typedef
V
(
*
methfun_2
)(
flext_base
*
c
,
t_any
&
,
t_any
&
);
typedef
V
(
*
methfun_3
)(
flext_base
*
c
,
t_any
&
,
t_any
&
,
t_any
&
);
typedef
V
(
*
methfun_4
)(
flext_base
*
c
,
t_any
&
,
t_any
&
,
t_any
&
,
t_any
&
);
typedef
V
(
*
methfun_5
)(
flext_base
*
c
,
t_any
&
,
t_any
&
,
t_any
&
,
t_any
&
,
t_any
&
);
typedef
void
(
*
methfun_1
)(
flext_base
*
c
,
t_any
&
);
typedef
void
(
*
methfun_2
)(
flext_base
*
c
,
t_any
&
,
t_any
&
);
typedef
void
(
*
methfun_3
)(
flext_base
*
c
,
t_any
&
,
t_any
&
,
t_any
&
);
typedef
void
(
*
methfun_4
)(
flext_base
*
c
,
t_any
&
,
t_any
&
,
t_any
&
,
t_any
&
);
typedef
void
(
*
methfun_5
)(
flext_base
*
c
,
t_any
&
,
t_any
&
,
t_any
&
,
t_any
&
,
t_any
&
);
BL
flext_base
::
m_methodmain
(
I
inlet
,
const
t_symbol
*
s
,
I
argc
,
t_atom
*
argv
)
bool
flext_base
::
m_methodmain
(
int
inlet
,
const
t_symbol
*
s
,
int
argc
,
t_atom
*
argv
)
{
BL
ret
=
false
;
bool
ret
=
false
;
LOG3
(
"methodmain inlet:%i args:%i symbol:%s"
,
inlet
,
argc
,
s
?
s
->
s_name
:
""
);
...
...
@@ -501,29 +501,29 @@ BL flext_base::m_methodmain(I inlet,const t_symbol *s,I argc,t_atom *argv)
ret
=
true
;
}
else
if
(
argc
==
m
->
argc
)
{
I
ix
;
int
ix
;
t_any
aargs
[
MAXARGS
];
BL
ok
=
true
;
bool
ok
=
true
;
for
(
ix
=
0
;
ix
<
argc
&&
ok
;
++
ix
)
{
switch
(
m
->
args
[
ix
])
{
case
a_float
:
{
if
(
is_f
loat
(
argv
[
ix
]))
aargs
[
ix
].
ft
=
g
et
_f
loat
(
argv
[
ix
]);
else
if
(
is_i
nt
(
argv
[
ix
]))
aargs
[
ix
].
ft
=
(
F
)
get_i
nt
(
argv
[
ix
]);
if
(
IsF
loat
(
argv
[
ix
]))
aargs
[
ix
].
ft
=
G
et
F
loat
(
argv
[
ix
]);
else
if
(
IsI
nt
(
argv
[
ix
]))
aargs
[
ix
].
ft
=
(
float
)
GetI
nt
(
argv
[
ix
]);
else
ok
=
false
;
// if(ok) LOG2("int arg %i = %f",ix,aargs[ix].ft);
break
;
}
case
a_int
:
{
if
(
is_f
loat
(
argv
[
ix
]))
aargs
[
ix
].
it
=
(
I
)
get_f
loat
(
argv
[
ix
]);
else
if
(
is_i
nt
(
argv
[
ix
]))
aargs
[
ix
].
it
=
g
et
_i
nt
(
argv
[
ix
]);
if
(
IsF
loat
(
argv
[
ix
]))
aargs
[
ix
].
it
=
(
int
)
GetF
loat
(
argv
[
ix
]);
else
if
(
IsI
nt
(
argv
[
ix
]))
aargs
[
ix
].
it
=
G
et
I
nt
(
argv
[
ix
]);
else
ok
=
false
;
// if(ok) LOG2("float arg %i = %i",ix,aargs[ix].it);
break
;
}
case
a_symbol
:
{
if
(
is_s
ymbol
(
argv
[
ix
]))
aargs
[
ix
].
st
=
g
et
_s
ymbol
(
argv
[
ix
]);
if
(
IsS
ymbol
(
argv
[
ix
]))
aargs
[
ix
].
st
=
G
et
S
ymbol
(
argv
[
ix
]);
else
ok
=
false
;
// if(ok) LOG2("symbol arg %i = %s",ix,get_string(aargs[ix].st));
...
...
@@ -531,7 +531,7 @@ BL flext_base::m_methodmain(I inlet,const t_symbol *s,I argc,t_atom *argv)
}
#ifdef PD
case
a_pointer
:
{
if
(
is_p
ointer
(
argv
[
ix
]))
aargs
[
ix
].
pt
=
g
et
_p
ointer
(
argv
[
ix
]);
if
(
IsP
ointer
(
argv
[
ix
]))
aargs
[
ix
].
pt
=
G
et
P
ointer
(
argv
[
ix
]);
else
ok
=
false
;
break
;
}
...
...
@@ -559,15 +559,15 @@ BL flext_base::m_methodmain(I inlet,const t_symbol *s,I argc,t_atom *argv)
if
(
!
ret
&&
distmsgs
&&
inlet
==
0
&&
s
==
sym_list
&&
insigs
<=
1
)
{
// distribute list elements over inlets (Max/MSP behavior)
I
i
=
incnt
;
int
i
=
incnt
;
if
(
i
>
argc
)
i
=
argc
;
for
(
--
i
;
i
>=
0
;
--
i
)
{
// right to left distribution
const
t_symbol
*
s
=
NULL
;
if
(
is_f
loat
(
argv
[
i
]))
s
=
sym_float
;
else
if
(
is_i
nt
(
argv
[
i
]))
s
=
sym_int
;
else
if
(
is_s
ymbol
(
argv
[
i
]))
s
=
sym_symbol
;
if
(
IsF
loat
(
argv
[
i
]))
s
=
sym_float
;
else
if
(
IsI
nt
(
argv
[
i
]))
s
=
sym_int
;
else
if
(
IsS
ymbol
(
argv
[
i
]))
s
=
sym_symbol
;
#ifdef PD
else
if
(
is_p
ointer
(
argv
[
i
]))
s
=
sym_pointer
;
// can pointer atoms occur here?
else
if
(
IsP
ointer
(
argv
[
i
]))
s
=
sym_pointer
;
// can pointer atoms occur here?
#endif
if
(
s
)
m_methodmain
(
i
,
s
,
1
,
argv
+
i
);
}
...
...
@@ -580,7 +580,7 @@ BL flext_base::m_methodmain(I inlet,const t_symbol *s,I argc,t_atom *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
)
void
flext_base
::
m_method_
(
int
inlet
,
const
t_symbol
*
s
,
int
argc
,
t_atom
*
argv
)
{
#ifdef _DEBUG
post
(
"%s: message unhandled - inlet:%i args:%i symbol:%s"
,
thisName
(),
inlet
,
argc
,
s
?
s
->
s_name
:
""
);
...
...
@@ -588,7 +588,7 @@ 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
)
:
flext_base
::
methitem
::
methitem
(
int
in
,
t_symbol
*
t
)
:
inlet
(
in
),
tag
(
t
),
fun
(
NULL
),
argc
(
0
),
args
(
NULL
),
...
...
@@ -601,7 +601,7 @@ flext_base::methitem::~methitem()
if
(
args
)
delete
[]
args
;
}
V
flext_base
::
methitem
::
SetArgs
(
methfun
_fun
,
I
_argc
,
metharg
*
_args
)
void
flext_base
::
methitem
::
SetArgs
(
methfun
_fun
,
int
_argc
,
metharg
*
_args
)
{
fun
=
_fun
;
if
(
args
)
delete
[]
args
;
...
...
@@ -610,36 +610,36 @@ V flext_base::methitem::SetArgs(methfun _fun,I _argc,metharg *_args)
V
flext_base
::
AddMethItem
(
methitem
*
m
)
void
flext_base
::
AddMethItem
(
methitem
*
m
)
{
if
(
mlst
)
{
methitem
*
mi
;
for
(
mi
=
mlst
;
mi
->
nxt
;
mi
=
mi
->
nxt
)
(
V
)
0
;
for
(
mi
=
mlst
;
mi
->
nxt
;
mi
=
mi
->
nxt
)
(
void
)
0
;
mi
->
nxt
=
m
;
}
else
mlst
=
m
;
}
V
flext_base
::
a
dd
_m
eth
_def
(
I
inlet
)
void
flext_base
::
A
dd
M
eth
odDef
(
int
inlet
)
{
AddMethItem
(
new
methitem
(
inlet
,
NULL
));
}
V
flext_base
::
a
dd
_m
eth
_def
(
I
inlet
,
const
C
*
tag
)
void
flext_base
::
A
dd
M
eth
odDef
(
int
inlet
,
const
char
*
tag
)
{
AddMethItem
(
new
methitem
(
inlet
,
gensym
(
const_cast
<
C
*>
(
tag
))));
AddMethItem
(
new
methitem
(
inlet
,
gensym
(
const_cast
<
char
*>
(
tag
))));
}
V
flext_base
::
a
dd
_m
eth
_one
(
I
inlet
,
const
C
*
tag
,
methfun
fun
,
metharg
tp
,...)
void
flext_base
::
A
dd
M
eth
od
(
int
inlet
,
const
char
*
tag
,
methfun
fun
,
metharg
tp
,...)
{
methitem
*
mi
=
new
methitem
(
inlet
,
gensym
(
const_cast
<
C
*>
(
tag
)));
methitem
*
mi
=
new
methitem
(
inlet
,
gensym
(
const_cast
<
char
*>
(
tag
)));
va_list
marker
;
va_start
(
marker
,
tp
);
I
argc
=
0
;
int
argc
=
0
;
metharg
*
args
=
NULL
,
arg
=
tp
;
for
(;
arg
!=
a_null
;
++
argc
)
arg
=
(
metharg
)
va_arg
(
marker
,
I
);
//metharg);
for
(;
arg
!=
a_null
;
++
argc
)
arg
=
(
metharg
)
va_arg
(
marker
,
int
);
//metharg);
va_end
(
marker
);
if
(
argc
>
0
)
{
...
...
@@ -652,7 +652,7 @@ V flext_base::add_meth_one(I inlet,const C *tag,methfun fun,metharg tp,...)
va_start
(
marker
,
tp
);
metharg
a
=
tp
;
for
(
I
ix
=
0
;
ix
<
argc
;
++
ix
)
{
for
(
int
ix
=
0
;
ix
<
argc
;
++
ix
)
{
if
(
a
==
a_gimme
&&
ix
>
0
)
{
error
(
"GIMME argument must be the first and only one"
);
}
...
...
@@ -662,7 +662,7 @@ V flext_base::add_meth_one(I inlet,const C *tag,methfun fun,metharg tp,...)
}