aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/source
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2004-08-31 04:07:35 +0000
committerThomas Grill <xovo@users.sourceforge.net>2004-08-31 04:07:35 +0000
commit1a23e8233e6c1cbc30b9ddee4df153c21f4b282b (patch)
tree1c79382a41ef857e5beeed6f27ca1c85c81ddac1 /externals/grill/flext/source
parentd28900c480f4ea568acdff80372f12383d463e8c (diff)
""
svn path=/trunk/; revision=1982
Diffstat (limited to 'externals/grill/flext/source')
-rw-r--r--externals/grill/flext/source/flout.cpp335
1 files changed, 174 insertions, 161 deletions
diff --git a/externals/grill/flext/source/flout.cpp b/externals/grill/flext/source/flout.cpp
index 245de189..0c7beedc 100644
--- a/externals/grill/flext/source/flout.cpp
+++ b/externals/grill/flext/source/flout.cpp
@@ -67,203 +67,216 @@ bool flext_base::InitInlets()
incnt = insigs = 0;
// digest inlist
- {
- xlet *xi;
- incnt = 0;
- for(xi = inlist; xi; xi = xi->nxt) ++incnt;
- xlet::type *list = new xlet::type[incnt];
- int i;
- for(xi = inlist,i = 0; xi; xi = xi->nxt,++i) list[i] = xi->tp;
-
+
+ xlet *xi;
+ incnt = 0;
+ for(xi = inlist; xi; xi = xi->nxt) ++incnt;
+ xlet::type *list = new xlet::type[incnt];
+ int i;
+ for(xi = inlist,i = 0; xi; xi = xi->nxt,++i) list[i] = xi->tp;
+
#if FLEXT_SYS == FLEXT_SYS_MAX
- // copy inlet descriptions
- indesc = new char *[incnt];
- for(xi = inlist,i = 0; xi; xi = xi->nxt,++i) {
- int l = xi->desc?strlen(xi->desc):0;
- if(l) {
- indesc[i] = new char[l+1];
- memcpy(indesc[i],xi->desc,l);
- indesc[i][l] = 0;
- }
- else
- indesc[i] = NULL;
+ // copy inlet descriptions
+ indesc = new char *[incnt];
+ for(xi = inlist,i = 0; xi; xi = xi->nxt,++i) {
+ int l = xi->desc?strlen(xi->desc):0;
+ if(l) {
+ indesc[i] = new char[l+1];
+ memcpy(indesc[i],xi->desc,l);
+ indesc[i][l] = 0;
}
+ else
+ indesc[i] = NULL;
+ }
#endif
- delete inlist; inlist = NULL;
-
#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX
- inlets = new px_object *[incnt];
- for(i = 0; i < incnt; ++i) inlets[i] = NULL;
+ inlets = new px_object *[incnt];
+ for(i = 0; i < incnt; ++i) inlets[i] = NULL;
#endif
-
- // type info is now in list array
+
+ // type info is now in list array
#if FLEXT_SYS == FLEXT_SYS_PD
- {
- int cnt = 0;
+ {
+ int cnt = 0;
+ xi = inlist; // points to first inlet
- if(incnt >= 1) {
- switch(list[0]) {
- case xlet::tp_sig:
- ++insigs;
- break;
- default:
- // leftmost inlet is already there...
- break;
- }
- ++cnt;
- }
+ if(incnt >= 1) {
+ switch(list[0]) {
+ case xlet::tp_sig:
+ ++insigs;
+ break;
+ default:
+ // leftmost inlet is already there...
+ break;
+ }
+ ++cnt;
- for(int ix = 1; ix < incnt; ++ix,++cnt) {
- switch(list[ix]) {
- case xlet::tp_float:
- case xlet::tp_int: {
- 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;
- }
- }
- else
- sym[2] = '0'+ix,sym[3] = 0;
- if(ok) inlet_new(&x_obj->obj, &x_obj->obj.ob_pd, (t_symbol *)sym_float, gensym(sym));
- break;
- }
- case xlet::tp_sym:
- (inlets[ix] = (px_object *)pd_new(px_class))->init(this,ix); // proxy for 2nd inlet messages
- inlet_new(&x_obj->obj,&inlets[ix]->obj.ob_pd, (t_symbol *)sym_symbol, (t_symbol *)sym_symbol);
- break;
- case xlet::tp_list:
- (inlets[ix] = (px_object *)pd_new(px_class))->init(this,ix); // proxy for 2nd inlet messages
- inlet_new(&x_obj->obj,&inlets[ix]->obj.ob_pd, (t_symbol *)sym_list, (t_symbol *)sym_list);
- break;
- case xlet::tp_any:
- (inlets[ix] = (px_object *)pd_new(px_class))->init(this,ix); // proxy for 2nd inlet messages
- inlet_new(&x_obj->obj,&inlets[ix]->obj.ob_pd, 0, 0);
- break;
- case xlet::tp_sig:
- if(compatibility && list[ix-1] != xlet::tp_sig) {
- post("%s: All signal inlets must be left-aligned in compatibility mode",thisName());
+#if PD_MINOR_VERSION >= 37 && defined(PD_DEVEL_VERSION)
+ // set tooltip
+ if(xi->desc && *xi->desc) class_settip(thisClass(),gensym(xi->desc));
+#endif
+ }
+
+ for(int ix = 1; ix < incnt; ++ix,++cnt) {
+ xi = xi->nxt; // points to next inlet
+
+ t_inlet *in = NULL;
+ switch(list[ix]) {
+ case xlet::tp_float:
+ case xlet::tp_int: {
+ 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 {
- // pd doesn't seem to be able to handle signals and messages into the same inlet...
-
- inlet_new(&x_obj->obj, &x_obj->obj.ob_pd, (t_symbol *)sym_signal, (t_symbol *)sym_signal);
- ++insigs;
+ 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;
}
- break;
- default:
- error("%s: Wrong type for inlet #%i: %i",thisName(),ix,(int)list[ix]);
+ }
+ 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::tp_sym:
+ (inlets[ix] = (px_object *)pd_new(px_class))->init(this,ix); // proxy for 2nd inlet messages
+ in = inlet_new(&x_obj->obj,&inlets[ix]->obj.ob_pd, (t_symbol *)sym_symbol, (t_symbol *)sym_symbol);
+ break;
+ case xlet::tp_list:
+ (inlets[ix] = (px_object *)pd_new(px_class))->init(this,ix); // proxy for 2nd inlet messages
+ in = inlet_new(&x_obj->obj,&inlets[ix]->obj.ob_pd, (t_symbol *)sym_list, (t_symbol *)sym_list);
+ break;
+ case xlet::tp_any:
+ (inlets[ix] = (px_object *)pd_new(px_class))->init(this,ix); // proxy for 2nd inlet messages
+ in = inlet_new(&x_obj->obj,&inlets[ix]->obj.ob_pd, 0, 0);
+ break;
+ case xlet::tp_sig:
+ if(compatibility && list[ix-1] != xlet::tp_sig) {
+ post("%s: All signal inlets must be left-aligned in compatibility mode",thisName());
ok = false;
- }
- }
+ }
+ else {
+ // pd doesn't seem to be 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;
+ }
+ break;
+ default:
+ error("%s: Wrong type for inlet #%i: %i",thisName(),ix,(int)list[ix]);
+ ok = false;
+ }
- incnt = cnt;
+#if PD_MINOR_VERSION >= 37 && defined(PD_DEVEL_VERSION)
+ // set tooltip
+ if(in && xi->desc && *xi->desc) inlet_settip(in,gensym(xi->desc));
+#endif
}
+
+ incnt = cnt;
+ }
#elif FLEXT_SYS == FLEXT_SYS_MAX
- {
- int ix,cnt;
- // count leftmost signal inlets
- while(insigs < incnt && list[insigs] == xlet::tp_sig) ++insigs;
-
- for(cnt = 0,ix = incnt-1; ix >= insigs; --ix,++cnt) {
- if(ix == 0) {
- if(list[ix] != xlet::tp_any) {
- error("%s: Leftmost inlet must be of type signal or anything",thisName());
- ok = false;
- }
- }
- else {
- switch(list[ix]) {
- case xlet::tp_sig:
- error("%s: All signal inlets must be left-aligned",thisName());
- ok = false;
- 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_int:
- if(ix >= 10) {
- post("%s: Only 9 int 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;
- default:
- error("%s: Wrong type for inlet #%i: %i",thisName(),ix,(int)list[ix]);
- ok = false;
- }
+ {
+ int ix,cnt;
+ // count leftmost signal inlets
+ while(insigs < incnt && list[insigs] == xlet::tp_sig) ++insigs;
+
+ for(cnt = 0,ix = incnt-1; ix >= insigs; --ix,++cnt) {
+ if(ix == 0) {
+ if(list[ix] != xlet::tp_any) {
+ error("%s: Leftmost inlet must be of type signal or anything",thisName());
+ ok = false;
}
}
-
-// incnt = cnt;
-
- if(insigs)
-// dsp_setup(thisHdr(),insigs); // signal inlets
- dsp_setupbox(thisHdr(),insigs); // signal inlets
- }
-#elif FLEXT_SYS == FLEXT_SYS_JMAX
- {
- t_class *cl = thisClass();
- int cnt = 0;
- for(int ix = 0; ix < incnt; ++ix,++cnt) {
+ else {
switch(list[ix]) {
- case xlet::tp_float:
- case xlet::tp_int:
-// fts_class_inlet_number(cl, ix, jmax_proxy);
- break;
- case xlet::tp_sym:
-// fts_class_inlet_symbol(cl, ix, jmax_proxy);
- break;
case xlet::tp_sig:
- if(compatibility && list[ix-1] != xlet::tp_sig) {
- post("%s: All signal inlets must be left-aligned in compatibility mode",thisName());
+ error("%s: All signal inlets must be left-aligned",thisName());
+ ok = false;
+ break;
+ case xlet::tp_float:
+ if(ix >= 10) {
+ post("%s: Only 9 float inlets possible",thisName());
ok = false;
}
- else {
- if(!insigs) fts_dsp_declare_inlet(cl,0);
- ++insigs;
+ else
+ floatin(x_obj,ix);
+ break;
+ case xlet::tp_int:
+ if(ix >= 10) {
+ post("%s: Only 9 int inlets possible",thisName());
+ ok = false;
}
- // no break -> let a signal inlet also accept any messages
+ else
+ intin(x_obj,ix);
+ break;
+ case xlet::tp_any: // non-leftmost
+ case xlet::tp_sym:
case xlet::tp_list:
- case xlet::tp_any:
-// fts_class_inlet_varargs(cl,ix, jmax_proxy);
+ inlets[ix] = (px_object *)proxy_new(x_obj,ix,&((flext_hdr *)x_obj)->curinlet);
break;
default:
error("%s: Wrong type for inlet #%i: %i",thisName(),ix,(int)list[ix]);
ok = false;
}
}
+ }
- incnt = cnt;
+// incnt = cnt;
- fts_object_set_inlets_number((fts_object_t *)thisHdr(), incnt);
+ if(insigs)
+// dsp_setup(thisHdr(),insigs); // signal inlets
+ dsp_setupbox(thisHdr(),insigs); // signal inlets
+ }
+#elif FLEXT_SYS == FLEXT_SYS_JMAX
+ {
+ t_class *cl = thisClass();
+ int cnt = 0;
+ for(int ix = 0; ix < incnt; ++ix,++cnt) {
+ switch(list[ix]) {
+ case xlet::tp_float:
+ case xlet::tp_int:
+// fts_class_inlet_number(cl, ix, jmax_proxy);
+ break;
+ case xlet::tp_sym:
+// fts_class_inlet_symbol(cl, ix, jmax_proxy);
+ break;
+ case xlet::tp_sig:
+ if(compatibility && list[ix-1] != xlet::tp_sig) {
+ post("%s: All signal inlets must be left-aligned in compatibility mode",thisName());
+ ok = false;
+ }
+ else {
+ if(!insigs) fts_dsp_declare_inlet(cl,0);
+ ++insigs;
+ }
+ // no break -> let a signal inlet also accept any messages
+ case xlet::tp_list:
+ case xlet::tp_any:
+// fts_class_inlet_varargs(cl,ix, jmax_proxy);
+ break;
+ default:
+ error("%s: Wrong type for inlet #%i: %i",thisName(),ix,(int)list[ix]);
+ ok = false;
+ }
}
+
+ incnt = cnt;
+
+ fts_object_set_inlets_number((fts_object_t *)thisHdr(), incnt);
+ }
#else
#error
#endif
- delete[] list;
- }
+ delete inlist; inlist = NULL;
+
+ delete[] list;
return ok;
}
@@ -312,8 +325,6 @@ bool flext_base::InitOutlets()
}
#endif
- delete outlist; outlist = NULL;
-
#if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX
outlets = new outlet *[outcnt+(procattr?1:0)];
@@ -400,6 +411,8 @@ bool flext_base::InitOutlets()
}
#endif
+ delete outlist; outlist = NULL;
+
return ok;
}