aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas O Fredericks <mrtof@users.sourceforge.net>2009-10-07 00:41:31 +0000
committerThomas O Fredericks <mrtof@users.sourceforge.net>2009-10-07 00:41:31 +0000
commitcd658ffed1329080f06f84e890dcda4302ca5864 (patch)
treeac51de57a2ff6289dc8b06ec29876091fe5534e7
parentdcd3ce848a86fc70339ed94432d96aee73d63e62 (diff)
replacing the old param with the new param
svn path=/trunk/externals/tof/; revision=12553
-rw-r--r--src/param.c302
-rw-r--r--src/param.h354
-rw-r--r--src/paramCustom.c (renamed from test/paramCustom.c)0
-rw-r--r--src/paramDump.c90
-rw-r--r--src/paramFile.c177
-rw-r--r--src/paramId.c (renamed from test/paramId.c)0
-rw-r--r--src/paramRoute.c2
-rw-r--r--test/Makefile2
-rw-r--r--test/param.c290
-rw-r--r--test/param.h348
-rw-r--r--test/paramDump.c121
-rw-r--r--test/paramFile.c273
-rw-r--r--test/paramRoute.c136
13 files changed, 437 insertions, 1658 deletions
diff --git a/src/param.c b/src/param.c
index 6551748..2aab6aa 100644
--- a/src/param.c
+++ b/src/param.c
@@ -20,8 +20,6 @@
*/
-
-
#include "tof.h"
#include "param.h"
@@ -29,55 +27,67 @@ extern int sys_noloadbang;
static t_class *param_class;
static t_class *param_inlet2_class;
-struct _param_inlet2;
-
-typedef struct _param
-{
- t_object x_obj;
- struct _param_inlet2 *x_param_inlet2;
-
- //t_symbol *x_path;
- t_symbol *s_PARAM;
- //t_symbol *x_update_gui;
- t_symbol *s_set;
- struct param *x_param;
- int noloadbang;
-} t_param;
-
-typedef struct _param_inlet2
-{
- t_object x_obj;
- t_param *p_owner;
-} t_param_inlet2;
+struct _paramClass_inlet2;
+typedef struct _paramClass {
+ t_object x_obj;
+ struct _paramClass_inlet2 *inlet2;
+ t_param* param;
+ int noloadbang;
+ t_symbol* selector;
+ int alloc;
+ int ac;
+ t_atom* av;
+ int gac; // gui options count
+ t_atom* gav; // gui options
+ t_outlet* outlet;
+ t_symbol* receive;
+ t_symbol* send;
+ t_symbol* set_s;
+} t_paramClass;
+typedef struct _paramClass_inlet2
+{
+ t_object x_obj;
+ t_paramClass *p_owner;
+} t_paramClass_inlet2;
-static void param_bang(t_param *x)
+static void paramClass_bang(t_paramClass *x)
{
- if ( x->x_param) {
- param_output(x->x_param,x->x_obj.ob_outlet);
+ outlet_anything(x->outlet, x->selector, x->ac, x->av);
- //if (PARAMECHO) param_send_prepend(x->x_param, x->s_PARAM ,x->x_param->path );
- if(x->x_param->selector != &s_bang ) param_send_prepend(x->x_param, x->x_param->send ,x->s_set );
- }
+ if(x->selector != &s_bang ) tof_send_anything_prepend(x->send,x->selector,x->ac,x->av,x->set_s );
+
}
-static void param_loadbang(t_param *x)
+static void paramClass_loadbang(t_paramClass *x)
{
if (!sys_noloadbang && !x->noloadbang)
- param_bang(x);
+ paramClass_bang(x);
}
-static void param_anything(t_param *x, t_symbol *s, int ac, t_atom *av)
+static void paramClass_anything(t_paramClass *x, t_symbol *s, int ac, t_atom *av)
{
#ifdef PARAMDEBUG
post("RECEIVING SOMETHING");
#endif
- if ( x->x_param) set_param_anything(x->x_param,s,ac,av);
+ if ( s == &s_bang || ac == 0 ) {
+ x->ac = 0;
+ x->selector = s;
+ } else {
+ if(ac > x->alloc) {
+ x->av = resizebytes(x->av, x->alloc*sizeof(*(x->av)),
+ (10 + ac)*sizeof(*(x->av)));
+ x->alloc = 10 + ac;
+ }
+ x->ac = ac;
+ x->selector = s;
+ tof_copy_atoms(av, x->av, ac);
+ }
- param_bang(x);
+ paramClass_bang(x);
}
@@ -86,120 +96,176 @@ static void param_anything(t_param *x, t_symbol *s, int ac, t_atom *av)
// SECOND INLET METHOD
-static void param_inlet2_anything(t_param_inlet2 *p, t_symbol *s, int ac, t_atom *av)
+static void paramClass_inlet2_anything(t_paramClass_inlet2 *p, t_symbol *s, int ac, t_atom *av)
{
-
- if ( p->p_owner->x_param ) set_param_anything(p->p_owner->x_param, s,ac,av);
+ paramClass_anything(p->p_owner, s,ac,av);
}
// DECONSTRUCTOR
-static void param_free(t_param *x)
+static void paramClass_free(t_paramClass *x)
{
- if(x->x_param_inlet2) pd_free((t_pd *)x->x_param_inlet2);
+ if(x->inlet2) pd_free((t_pd *)x->inlet2);
- if (x->x_param) {
- pd_unbind(&x->x_obj.ob_pd, x->x_param->receive);
- param_unregister(x->x_param);
- }
+ if (x->receive) pd_unbind(&x->x_obj.ob_pd, x->receive);
+
+ if (x->param) param_unregister(x->param);
+
+ freebytes(x->gav, x->gac * sizeof(*(x->gav)));
+
+ freebytes(x->av, x->alloc * sizeof(*(x->av)));
}
+// SPECIAL PARAM GET FUNCTION
+static void paramClass_get(t_paramClass *x, t_symbol** s, int* ac, t_atom** av) {
+ *s = x->selector;
+ *ac = x->ac;
+ *av = x->av;
+}
+
+// SPECIAL PARAM SAVE FUNCTION
+static void paramClass_save(t_paramClass *x, t_binbuf* bb) {
+ //Put my data in binbuf
+ if ((x->selector != &s_bang)) {
+ int ac = x->ac + 2;
+ t_atom *av = getbytes(ac*sizeof(*av));
+ tof_copy_atoms(x->av,av+2,x->ac);
+ SETSYMBOL(av, x->param->path);
+ SETSYMBOL(av+1, x->selector);
+ binbuf_add(bb, ac, av);
+ binbuf_addsemi(bb);
+ freebytes(av, ac*sizeof(*av));
+ }
+}
+
+// SPECIAL PARAM GUI FUNCTION
+static void paramClass_GUI(t_paramClass *x, int* ac, t_atom** av) {
+ *ac = x->gac;
+ *av = x->gav;
+}
+
+
+
// CONSTRUCTOR
-static void *param_new(t_symbol *s, int ac, t_atom *av)
+static void* paramClass_new(t_symbol *s, int ac, t_atom *av)
{
- t_param *x = (t_param *)pd_new(param_class);
- t_param_inlet2 *p = (t_param_inlet2 *)pd_new(param_inlet2_class);
-
- // Stuff
- x->s_set = gensym("set");
- x->s_PARAM = gensym("PARAM");
-
- // Set up second inlet proxy
- x->x_param_inlet2 = p;
- p->p_owner = x;
+ t_paramClass *x = (t_paramClass *)pd_new(param_class);
- // GET THE CURRENT CANVAS
- t_canvas* canvas=tof_get_canvas();
+
+ // GET THE CURRENT CANVAS
+ t_canvas* canvas=tof_get_canvas();
- // GET THE NAME
- t_symbol* name = param_get_name(ac,av);
+ // GET THE NAME
+ t_symbol* name = param_get_name(ac,av);
- if (name) {
-
- t_symbol* path = param_get_path(canvas,name);
- t_symbol* root = tof_get_dollarzero(tof_get_root_canvas(canvas));
-
-
- // FIND PARAM VALUE
- // A. In canvas' arguments
- // B. In object's arguments
- // C. Defaults to a bang
+ if (!name) return NULL;
- int ac_p = 0;
- t_atom* av_p = NULL;
+ t_symbol* path = param_get_path(canvas,name);
+ t_symbol* root = tof_get_dollarzero(tof_get_root_canvas(canvas));
-
- // A. In canvas' arguments
- int ac_c = 0;
- t_atom* av_c = NULL;
-
- t_canvas * before = tof_get_canvas_before_root(canvas);
- tof_get_canvas_arguments(before,&ac_c , &av_c);
- tof_find_tagged_argument('/',name, ac_c, av_c,&ac_p,&av_p);
+ x->param = param_register(x,root,path,\
+ (t_paramGetMethod) paramClass_get,\
+ (t_paramSaveMethod) paramClass_save,\
+ (t_paramGUIMethod) paramClass_GUI);
- // B. I object's arguments
- if ( ac_p == 0 && ac > 1) {
- int ac_a = 0;
- t_atom* av_a = NULL;
- tof_find_tagged_argument('/',name, ac, av,&ac_p,&av_p);
- //tof_get_tagged_argument('/',ac,av,&start,&count);
- //if (count > 1) {
- // ac_p = ac_a;
- // av_p = av_a + 1;
- //}
- }
+ if (!x->param) return NULL;
+
+ // FIND PARAM VALUE
+ // A. In canvas' arguments
+ // B. In object's arguments
+ // C. Defaults to a bang
+
+ int ac_p = 0;
+ t_atom* av_p = NULL;
+
+ // A. In canvas' arguments
+ int ac_c = 0;
+ t_atom* av_c = NULL;
+
+ t_canvas * before = tof_get_canvas_before_root(canvas);
+ tof_get_canvas_arguments(before,&ac_c , &av_c);
+ tof_find_tagged_argument('/',name, ac_c, av_c,&ac_p,&av_p);
+
+ // B. I object's arguments
+ if ( ac_p == 0 && ac > 1) {
+ int ac_a = 0;
+ t_atom* av_a = NULL;
+ tof_find_tagged_argument('/',name, ac, av,&ac_p,&av_p);
+ //tof_get_tagged_argument('/',ac,av,&start,&count);
+ //if (count > 1) {
+ // ac_p = ac_a;
+ // av_p = av_a + 1;
+ //}
+ }
- // FIND THE NO LOADBANG TAG: /nlb
- int i;
- x->noloadbang = 0;
- for ( i =0; i < ac; i++) {
- if ( IS_A_SYMBOL(av,i) && (strcmp("/nlb",atom_getsymbol(av+i)->s_name) == 0)) {
- x->noloadbang = 1;
- break;
- }
+
+ // FIND THE NO LOADBANG TAG: /nlb
+ int i;
+ x->noloadbang = 0;
+
+ for ( i =0; i < ac; i++) {
+ if ( IS_A_SYMBOL(av,i) && (strcmp("/nlb",atom_getsymbol(av+i)->s_name) == 0)) {
+ x->noloadbang = 1;
+ break;
}
+ }
+
+
-
- //FIND THE GUI OPTIONS: /g
- int ac_g = 0;
- t_atom* av_g = NULL;
+ //FIND THE GUI OPTIONS: /g
+ int ac_g = 0;
+ t_atom* av_g = NULL;
// There could be a problem if the the name is also /g
tof_find_tagged_argument('/',gensym("/g"), ac, av,&ac_g,&av_g);
+ x->gac = ac_g;
+ x->gav = getbytes(x->gac * sizeof(*(x->gav)));
+ tof_copy_atoms(av_g,x->gav,x->gac);
- x->x_param = param_register(root,path,ac_p,av_p,ac_g,av_g);
+
+ int l = strlen(path->s_name) + strlen(root->s_name) + 2;
+ char* receiver = getbytes( l * sizeof(*receiver));
+ strcat(receiver,root->s_name);
+ strcat(receiver,path->s_name);
+ x->receive = gensym(receiver);
+ strcat(receiver,"_");
+ x->send = gensym(receiver);
+ freebytes(receiver, l * sizeof(*receiver));
#ifdef PARAMDEBUG
- post("receive:%s",x->x_param->receive->s_name);
- post("send:%s",x->x_param->send->s_name);
+ post("receive:%s",x->receive->s_name);
+ post("send:%s",x->send->s_name);
#endif
+
// BIND RECEIVER
- pd_bind(&x->x_obj.ob_pd, x->x_param->receive );
- // CREATE INLETS AND OUTLETS
- inlet_new((t_object *)x, (t_pd *)p, 0, 0);
- outlet_new(&x->x_obj, &s_list);
+ pd_bind(&x->x_obj.ob_pd, x->receive );
- } else {
+ // Create memory space
+ t_symbol* selector;
+ tof_set_selector(&selector,&ac_p,&av_p);
+ x->selector = selector;
+ x->alloc = ac_p + 10;
+ x->ac = ac_p;
+ x->av = getbytes(x->alloc * sizeof(*(x->av)));
+ tof_copy_atoms(av_p, x->av, x->ac);
- pd_error(x,"Could not create param. See possible errors above.");
- }
+
+
+ x->set_s = gensym("set");
-
+ // Set up second inlet proxy
+ t_paramClass_inlet2 *p = (t_paramClass_inlet2 *)pd_new(param_inlet2_class);
+ x->inlet2 = p;
+ p->p_owner = x;
+
+ // CREATE INLETS AND OUTLETS
+ inlet_new((t_object *)x, (t_pd *)p, 0, 0);
+ x->outlet = outlet_new(&x->x_obj, &s_list);
return (x);
}
@@ -207,18 +273,18 @@ static void *param_new(t_symbol *s, int ac, t_atom *av)
void param_setup(void)
{
param_class = class_new(gensym("param"),
- (t_newmethod)param_new, (t_method)param_free,
- sizeof(t_param), 0, A_GIMME, 0);
+ (t_newmethod)paramClass_new, (t_method)paramClass_free,
+ sizeof(t_paramClass), 0, A_GIMME, 0);
- class_addanything(param_class, param_anything);
- class_addbang(param_class, param_bang);
+ class_addanything(param_class, paramClass_anything);
+ class_addbang(param_class, paramClass_bang);
- class_addmethod(param_class, (t_method)param_loadbang, gensym("loadbang"), 0);
+ class_addmethod(param_class, (t_method)paramClass_loadbang, gensym("loadbang"), 0);
param_inlet2_class = class_new(gensym("_param_inlet2"),
- 0, 0, sizeof(t_param_inlet2), CLASS_PD | CLASS_NOINLET, 0);
+ 0, 0, sizeof(t_paramClass_inlet2), CLASS_PD | CLASS_NOINLET, 0);
- class_addanything(param_inlet2_class, param_inlet2_anything);
+ class_addanything(param_inlet2_class, paramClass_inlet2_anything);
}
diff --git a/src/param.h b/src/param.h
index 92a34e8..a6f9686 100644
--- a/src/param.h
+++ b/src/param.h
@@ -1,5 +1,8 @@
//#define PARAMDEBUG
-#include <stdio.h>
+
+typedef void (*t_paramGetMethod)(void*,t_symbol**,int*,t_atom**);
+typedef void (*t_paramSaveMethod)(void*,t_binbuf*);
+typedef void (*t_paramGUIMethod)(void*,int*,t_atom**);
char param_buf_temp_a[MAXPDSTRING];
char param_buf_temp_b[MAXPDSTRING];
@@ -7,65 +10,34 @@ char* param_separator = "/";
//char PARAMECHO = 0;
-
-struct param {
-
- t_symbol* root;
- t_symbol* path; //Path(name) of the param
- t_symbol* send;
- t_symbol* receive;
- t_symbol* selector; //Type of data stored
- int alloc; //Memory allocated
- int ac; //Number of values stored
- t_atom* av; //Values stored
- struct param* next; //Next param
- struct param* previous; //Previous param
- int users; //Number of param objects using this param
- //t_symbol* id; //The base id
- int ac_g; //Gui argument count
- t_atom* av_g; //Gui argument values
-};
-
-struct paramroot {
+//struct _paramroot;
+
+typedef struct _param {
+ t_symbol* root;
+ t_symbol* path; //Path(name) of the param
+ void* x;
+ struct _param* next; //Next param
+ struct _param* previous; //Previous param
+ t_paramGetMethod get; //Function to get current value
+ t_paramSaveMethod save; //Function to save
+ t_paramGUIMethod GUI;
+ //t_symbol* send;
+ //t_symbol* receive;
+} t_param;
+
+typedef struct _paramroot {
t_symbol* root;
- struct param* params; //param list
- struct paramroot* next; //Next paramroot
- struct paramroot* previous; //Previous paramroot
-};
-
-struct paramroot* paramroots;
+ t_param* params; //param list
+ struct _paramroot* next; //Next paramroot
+ struct _paramroot* previous; //Previous paramroot
+} t_paramroot;
-//struct param* paramlist;
+t_paramroot* PARAMROOTS;
-static void set_param_anything( struct param* p, t_symbol* s, int ac, t_atom *av) {
+static t_paramroot* param_get_root(t_symbol* root) {
- if ( s == &s_bang || ac == 0 ) {
- p->ac = 0;
- p->selector = s;
- } else {
- if(ac > p->alloc) {
- p->av = resizebytes(p->av, p->alloc*sizeof(*(p->av)),
- (10 + ac)*sizeof(*(p->av)));
- p->alloc = 10 + ac;
- }
- p->ac = ac;
- p->selector = s;
- tof_copy_atoms(av, p->av, ac);
- }
-}
-
-
-static void set_param( struct param* p, int ac, t_atom *av) {
- t_symbol* s;
- tof_set_selector(&s,&ac, &av );
- set_param_anything(p,s,ac,av);
-}
-
-
-static struct paramroot* param_get_root(t_symbol* root) {
-
- if (paramroots == NULL) {
+ if (PARAMROOTS == NULL) {
#ifdef PARAMDEBUG
post("Could not get...not even one root created");
#endif
@@ -74,7 +46,7 @@ static struct paramroot* param_get_root(t_symbol* root) {
// Pointer to the start of paramroots
- struct paramroot* branch = paramroots;
+ t_paramroot* branch = PARAMROOTS;
while( branch ) {
if ( branch->root == root) {
@@ -94,10 +66,10 @@ static struct paramroot* param_get_root(t_symbol* root) {
}
-static struct paramroot* param_root_attach(t_symbol* root){
+static t_paramroot* param_root_attach(t_symbol* root){
// Pointer to the start of paramroots
- struct paramroot* branch = paramroots;
+ t_paramroot* branch = PARAMROOTS;
while( branch ) {
if ( branch->root == root) {
@@ -118,7 +90,7 @@ static struct paramroot* param_root_attach(t_symbol* root){
#endif
// Create and add paramroot to the end
- struct paramroot* newbranch = getbytes(sizeof(*newbranch));
+ t_paramroot* newbranch = getbytes(sizeof(*newbranch));
newbranch->root = root;
newbranch->next = NULL;
newbranch->params = NULL;
@@ -134,7 +106,7 @@ static struct paramroot* param_root_attach(t_symbol* root){
post("Creating first root");
#endif
newbranch->previous = NULL;
- paramroots = newbranch;
+ PARAMROOTS = newbranch;
}
@@ -144,10 +116,10 @@ static struct paramroot* param_root_attach(t_symbol* root){
-static struct param* get_param_list(t_symbol* root) {
+static t_param* get_param_list(t_symbol* root) {
- struct paramroot* branch = param_get_root(root);
+ t_paramroot* branch = param_get_root(root);
if (branch) {
#ifdef PARAMDEBUG
@@ -165,12 +137,13 @@ static struct param* get_param_list(t_symbol* root) {
static t_symbol* param_get_name ( int ac, t_atom* av ) {
if (ac && IS_A_SYMBOL(av, 0)) {
- char *firstChar = (atom_getsymbol(av))->s_name;
- if (*firstChar == *param_separator) {
- return atom_getsymbol(av);
+ char* name = atom_getsymbol(av)->s_name;
+ if (*name == *param_separator ) {
+ int length = strlen(name);
+ if (name[length-1] != '_') return atom_getsymbol(av);
}
}
- post("param requires a name that starts with a \"/\"");
+ post("param names must start with a \"/\" and can not end with a \"_\"!");
return NULL;
}
@@ -198,7 +171,7 @@ static t_symbol* param_get_path( t_canvas* i_canvas, t_symbol* name) {
// Ignore all supatches
if ( tof_canvas_is_not_subpatch(i_canvas) ) {
tof_get_canvas_arguments(i_canvas,&i_ac, &i_av);
- id_temp=tof_get_canvas_name(i_canvas);
+ id_temp=NULL;
//id_temp= canvas_realizedollar(i_canvas, gensym("$0"));
int ac_a = 0;
t_atom* av_a = NULL;
@@ -215,7 +188,12 @@ static t_symbol* param_get_path( t_canvas* i_canvas, t_symbol* name) {
//found_id_flag = 1;
break;
}
- }
+ }
+
+ if (id_temp == NULL) {
+
+ id_temp = tof_remove_extension(tof_get_canvas_name(i_canvas));
+ }
// if ever an /id is missing, this param is not saveable
//if (found_id_flag == 0) saveable = 0;
@@ -230,8 +208,6 @@ static t_symbol* param_get_path( t_canvas* i_canvas, t_symbol* name) {
//strcat(sbuf_name,separator);
if ( name != NULL) {
strcat(sbuf_name,name->s_name);
- } else {
- strcat(sbuf_name, param_separator);
}
return gensym(sbuf_name);
@@ -245,25 +221,23 @@ static t_symbol* param_get_path( t_canvas* i_canvas, t_symbol* name) {
//static struct param* register_param( t_canvas* canvas, int o_ac, t_atom* o_av) {
-static struct param* param_register(t_symbol* root, t_symbol* path, int ac, t_atom* av,int ac_g, t_atom* av_g) {
+static t_param* param_register(void* x,t_symbol* root, t_symbol* path,\
+ t_paramGetMethod get, t_paramSaveMethod save, t_paramGUIMethod GUI) {
//char *separator = "/";
-
-
/* GET POINTER TO PARAMLIST FOR THAT ROOT */
- struct paramroot* branch = param_root_attach(root);
- struct param* last = branch->params;
+ t_paramroot* branch = param_root_attach(root);
+ t_param* last = branch->params;
// Search for param with same path
while( last ) {
if ( last->path == path) {
- #ifdef PARAMDEBUG
- post("Found param with same name");
- #endif
- last->users = last->users + 1;
- return last;
+
+ pd_error(x,"Found param with same name: %s", path->s_name);
+
+ return NULL;
}
if ( last->next == NULL ) break;
last = last->next;
@@ -271,29 +245,29 @@ static struct param* param_register(t_symbol* root, t_symbol* path, int ac, t_at
// Create and add param to the end
-
-
-
- struct param* p = getbytes(sizeof(*p));
+ t_param* p = getbytes(sizeof(*p));
p->root = root;
- p->alloc = 0;
+ //p->alloc = 0;
p->path = path;
// Create receive and send symbols: $0/path
- strcpy(param_buf_temp_a,p->root->s_name);
+ //strcpy(param_buf_temp_a,p->root->s_name);
//strcat(param_buf_temp_a,separator);
- strcat(param_buf_temp_a,p->path->s_name);
- p->receive = gensym(param_buf_temp_a);
- strcat(param_buf_temp_a,"_");
- p->send = gensym(param_buf_temp_a);
+ //strcat(param_buf_temp_a,p->path->s_name);
+ //p->receive = gensym(param_buf_temp_a);
+ //strcat(param_buf_temp_a,"_");
+ //p->send = gensym(param_buf_temp_a);
p->next = NULL;
- p->users = 1;
+ p->x = x;
+ p->get = get;
+ p->save = save;
+ p->GUI = GUI;
//p->id = id;
- set_param( p, ac, av);
- p->ac_g = ac_g;
- p->av_g = getbytes(ac_g*sizeof(*(p->av_g)));
- tof_copy_atoms(av_g,p->av_g,ac_g);
+ //set_param( p, ac, av);
+ //p->ac_g = ac_g;
+ //p->av_g = getbytes(ac_g*sizeof(*(p->av_g)));
+ //tof_copy_atoms(av_g,p->av_g,ac_g);
if (last) {
#ifdef PARAMDEBUG
post("Appending param");
@@ -313,16 +287,16 @@ static struct param* param_register(t_symbol* root, t_symbol* path, int ac, t_at
}
-static void param_unregister(struct param* p) {
+static void param_unregister(t_param* p) {
//post("unregistering %s", p->path->s_name);
- struct paramroot* branch = param_get_root(p->root);
- struct param* paramlist = branch->params;
+ t_paramroot* branch = param_get_root(p->root);
+ t_param* paramlist = branch->params;
if ( paramlist) {
- p->users = p->users - 1;
- if ( p->users == 0 ) {
+ //p->users = p->users - 1;
+ //if ( p->users == 0 ) {
// Remove param
//post("Removing last param of this name");
if (p->previous) {
@@ -339,10 +313,10 @@ static void param_unregister(struct param* p) {
paramlist = p->next;
if ( p->next != NULL) p->next->previous = NULL;
}
- freebytes(p->av, p->alloc * sizeof *(p->av) );
- freebytes(p->av_g, p->ac_g * sizeof *(p->av_g) );
+ //freebytes(p->av, p->alloc * sizeof *(p->av) );
+ //freebytes(p->av_g, p->ac_g * sizeof *(p->av_g) );
freebytes(p, sizeof *p);
- }
+ //}
// Update the params for that root
if (paramlist == NULL) {
@@ -350,7 +324,7 @@ static void param_unregister(struct param* p) {
branch->previous->next = branch->next;
if (branch->next) branch->next->previous = branch->previous;
} else {
- paramroots = branch->next;
+ PARAMROOTS = branch->next;
if ( branch->next != NULL) branch->next->previous = NULL;
}
#ifdef PARAMDEBUG
@@ -370,175 +344,3 @@ static void param_unregister(struct param* p) {
-
-static void param_send_prepend(struct param *p, t_symbol* s,t_symbol* prepend) {
-
- if (p) {
- if((p->selector == &s_bang)) {
- // if (s->s_thing)
- // pd_bang(s->s_thing);
- } else {
- if (s->s_thing) {
- if ( p->selector == &s_list || p->selector == &s_float || p->selector == &s_symbol ) {
- typedmess(s->s_thing, prepend, p->ac, p->av);
- } else {
- int ac = p->ac + 1;
- t_atom *av = getbytes(ac*sizeof(*av));
- tof_copy_atoms(p->av,av+1,p->ac);
- SETSYMBOL(av, p->selector);
- typedmess(s->s_thing, prepend, ac, av);
- freebytes(av, ac*sizeof(*av));
- }
- }
- }
- }
-}
-
-static void param_output(struct param *p, t_outlet* outlet) {
- // SHOULD I COPY THIS DATA BEFORE SENDING IT OUT?
- // OR IS THE NORM TO ONLY COPY ON INPUT?
- if (p) {
- if(!(p->selector == &s_bang) ) {
-
- outlet_anything(outlet, p->selector, p->ac, p->av);
- }
- }
-}
-
-
-static void param_output_prepend(struct param* p, t_outlet* outlet, t_symbol* s) {
-
- if (p->selector == &s_list || p->selector == &s_float || p->selector == &s_symbol) {
- //t_atom *av = (t_atom *)getbytes(p->ac*sizeof(t_atom));
- //tof_copy_atoms(p->av,av,p->ac);
- outlet_anything(outlet,s,p->ac,p->av);
- //freebytes(av, p->ac*sizeof(t_atom));
- } else if (p->selector != &s_bang) {
- int ac = p->ac + 1;
- t_atom *av = (t_atom *)getbytes(ac*sizeof(t_atom));
- tof_copy_atoms(p->av,av+1,p->ac);
- SETSYMBOL(av, p->selector);
- outlet_anything(outlet,s,ac,av);
- freebytes(av, ac*sizeof(t_atom));
- } else if (p->selector == &s_bang) {
- outlet_anything(outlet,s,0,NULL);
- }
-
-}
-
-
-// Write will only save the params that share the same root
-static int param_write(t_canvas* canvas, t_symbol* filename) {
-
-
- int w_error;
-
- //t_symbol* filename = param_makefilename(basename, n);
-
- t_binbuf *bbuf = binbuf_new();
-
- struct param *p = get_param_list(tof_get_dollarzero(canvas));
- while(p) {
- if ((p->selector != &s_bang)) {
- int ac = p->ac + 2;
- t_atom *av = getbytes(ac*sizeof(*av));
- tof_copy_atoms(p->av,av+2,p->ac);
- SETSYMBOL(av, p->path);
- SETSYMBOL(av+1, p->selector);
- binbuf_add(bbuf, ac, av);
- binbuf_addsemi(bbuf);
-
- freebytes(av, ac*sizeof(*av));
- }
- p = p->next;
- }
-
-
- char buf[MAXPDSTRING];
- canvas_makefilename(canvas, filename->s_name,
- buf, MAXPDSTRING);
-
-
- w_error = (binbuf_write(bbuf, buf, "", 0));
- //pd_error("%s: write failed", filename->s_name);
-
- binbuf_free(bbuf);
-
- return w_error;
-
-}
-
-
-static int param_read(t_canvas* canvas, t_symbol* filename)
-{
-
- int r_error;
-
- //t_symbol* filename = param_makefilename(basename, n);
-
- t_binbuf *bbuf = binbuf_new();
-
- r_error= (binbuf_read_via_canvas(bbuf, filename->s_name, canvas, 0));
- //pd_error(x, "%s: read failed", filename->s_name);
-
- t_symbol* root = tof_get_dollarzero(canvas);
-
- int bb_ac = binbuf_getnatom(bbuf);
- int ac = 0;
- t_atom *bb_av = binbuf_getvec(bbuf);
- t_atom *av = bb_av;
-
- while (bb_ac--) {
- if (bb_av->a_type == A_SEMI) {
- if ( IS_A_SYMBOL(av,0) && ac > 1) {
- t_symbol* path = atom_getsymbol(av);
- strcpy(param_buf_temp_a,root->s_name);
- strcat(param_buf_temp_a,path->s_name);
- t_symbol* s = gensym(param_buf_temp_a);
- #ifdef PARAMDEBUG
- post("Restoring:%s",s->s_name);
- #endif
-
- // STUPID SYMBOL WITH SPACES MANAGEMENT
- if ( s->s_thing && ac > 3 && IS_A_SYMBOL(av,1) && atom_getsymbol(av+1) == &s_symbol) {
- // This whole block is simply to convert symbols saved with spaces to complete symbols
-
- t_binbuf *bbuf_stupid = binbuf_new();
- binbuf_add(bbuf_stupid, ac-2, av+2);
-
- char *char_buf;
- int char_length;
- binbuf_gettext(bbuf_stupid, &char_buf, &char_length);
- char_buf = resizebytes(char_buf, char_length, char_length+1);
- char_buf[char_length] = 0;
- t_symbol* stupid_symbol = gensym(char_buf);
- //post("STUPID: %s",stupid_symbol->s_name);
- freebytes(char_buf, char_length+1);
- binbuf_free(bbuf_stupid);
- t_atom* stupid_atom = getbytes(sizeof(*stupid_atom));
- SETSYMBOL(stupid_atom, stupid_symbol);
- pd_typedmess(s->s_thing, &s_symbol, 1, stupid_atom);
- freebytes(stupid_atom, sizeof(*stupid_atom));
-
- } else {
- if ( s->s_thing) pd_forwardmess(s->s_thing, ac-1, av+1);
- }
- }
-
- ac = 0;
- av = bb_av + 1;
- } else {
-
- ac = ac + 1;
- }
- bb_av++;
- }
-
- binbuf_free(bbuf);
-
- return r_error;
-}
-
-
-
-
diff --git a/test/paramCustom.c b/src/paramCustom.c
index 834b32f..834b32f 100644
--- a/test/paramCustom.c
+++ b/src/paramCustom.c
diff --git a/src/paramDump.c b/src/paramDump.c
index a236533..b9f73b9 100644
--- a/src/paramDump.c
+++ b/src/paramDump.c
@@ -24,7 +24,6 @@
#include "param.h"
-
static t_class *paramDump_class;
@@ -32,93 +31,54 @@ typedef struct _paramDump
{
t_object x_obj;
t_outlet* outlet;
- t_symbol* s_set;
+ //t_symbol* s_set;
t_symbol* root;
} t_paramDump;
-// Dump out the values of a specific id
-//static void paramDump_values(t_paramDump *x, t_symbol* s, int a_ac, t_atom* a_av) {
-/*
-static void paramDump_values(t_paramDump *x, t_symbol* s) {
-
- //if ( s == &s_list && a_ac > 0 && IS_A_SYMBOL(a_av,0) ) s = atom_getsymbol(a_av);
-
- //if ( !(s == &s_list || s == &s_float) ) {
- char* star = "*";
- int all = !(strcmp(s->s_name, star));
-
-
- struct param* pp = get_param_list();
- while (pp) {
- if (pp->root == x->root && (all || pp->id == s) ) {
- param_output_prepend(pp,x->outlet,pp->path);
-
- }
- pp = pp->next;
- }
- //}
-}
-
-*/
static void paramDump_guis(t_paramDump *x, t_symbol* s) {
- //char* star = "*";
- //int all = !(strcmp(s->s_name, star));
-
- struct param* pp = get_param_list(x->root);
- while (pp) {
- if (pp->ac_g ) {
-
- outlet_anything(x->outlet,pp->path,pp->ac_g,pp->av_g);
-
- }
- pp = pp->next;
- }
-}
-
-/*
-static void paramDump_update_guis(t_paramDump *x, t_symbol* s) {
- char* star = "*";
- int all = !(strcmp(s->s_name, star));
- struct param* pp = get_param_list();
- while (pp) {
- if (pp->ac_g && pp->root == x->root && (all || pp->id == s) ) {
-
- param_send_prepend(pp, pp->path_ ,x->s_set );
- //if ( pp->path_g->s_thing)
- // pd_typedmess(pp->path_g->s_thing, pp->selector,pp->ac, pp->av);
-
- //outlet_anything(x->outlet,pp->path,pp->ac_g,pp->av_g);
+ t_param* p = get_param_list(x->root);
+ int ac;
+ t_atom* av;
+
+ while (p) {
+ if (p->GUI ) {
+ p->GUI(p->x,&ac,&av);
+ outlet_anything(x->outlet,p->path,ac,av);
}
- pp = pp->next;
+ p = p->next;
}
+
}
-*/
// Dump out everything (OR THE ID'S OR JUST THE NAMES?)
static void paramDump_bang(t_paramDump *x) {
-
- struct param* pp = get_param_list(x->root);
+ t_param* p = get_param_list(x->root);
#ifdef PARAMDEBUG
- if (pp == NULL) {
+ if (p == NULL) {
post("No params found");
} else {
post("Found params");
}
#endif
- while (pp) {
- //if (pp->root == x->root) {
- param_output_prepend(pp,x->outlet,pp->path);
-
- //}
- pp = pp->next;
+
+ t_symbol* selector;
+ int ac;
+ t_atom* av;
+
+ while (p) {
+ if ( p->get ) {
+ p->get(p->x, &selector, &ac, &av);
+ tof_outlet_anything_prepend(x->outlet,selector,ac,av,p->path);
+ }
+ p = p->next;
}
@@ -139,7 +99,7 @@ static void *paramDump_new(t_symbol *s, int ac, t_atom *av) {
x->root = tof_get_dollarzero(tof_get_root_canvas(tof_get_canvas()));
- x->s_set = gensym("set");
+ //x->s_set = gensym("set");
x->outlet = outlet_new(&x->x_obj, &s_list);
diff --git a/src/paramFile.c b/src/paramFile.c
index 328eb51..db9b28d 100644
--- a/src/paramFile.c
+++ b/src/paramFile.c
@@ -12,38 +12,162 @@ struct _paramFile_inlet2;
typedef struct _paramFile
{
- t_object x_obj;
- //t_outlet *outlet;
- t_canvas *canvas;
- t_symbol *basename;
- struct _paramFile_inlet2 *inlet2;
+ t_object x_obj;
+ t_canvas *canvas;
+ t_symbol* basename;
+ t_symbol* root;
+ struct _paramFile_inlet2 *inlet2;
+ int working;
} t_paramFile;
+
typedef struct _paramFile_inlet2 {
t_object x_obj;
t_paramFile *x;
} t_paramFile_inlet2;
-
-
-static t_symbol* paramFile_makefilename(t_symbol* basename, t_float f) {
+static t_symbol* paramFile_makefilename(t_paramFile* x, t_float f) {
if (f < 0) f = 0;
if ( f > 127) f = 127;
int i = (int) f;
- int length = strlen(basename->s_name)+11;
+ int length = strlen(x->basename->s_name)+11;
char* buf = getbytes( length * sizeof (*buf));
- sprintf(buf,"%s-%03d.param",basename->s_name,i);
- //strcpy(buf,basename->s_name);
- //strcat(buf,".param");
+ sprintf(buf,"%s-%03d.param",x->basename->s_name,i);
t_symbol* filename = gensym(buf);
freebytes(buf, length * sizeof (*buf));
- //post("File name:%s",filename->s_name);
return filename;
}
+
+static void paramFile_write(t_paramFile* x, int f) {
+
+ if ( x->working ) {
+ pd_error(x,"paramFile can only save or load to one file at a time");
+ return;
+ }
+ x->working = 1;
+
+ t_symbol* filename = paramFile_makefilename(x,f);
+ post("Writing: %s",filename->s_name);
+
+ int w_error;
+
+ t_binbuf *bbuf = binbuf_new();
+
+ t_param *p = get_param_list(x->root);
+
+ while(p) {
+
+ if ( p->save ) p->save(p->x,bbuf);
+
+ p = p->next;
+ }
+
+
+ char buf[MAXPDSTRING];
+ canvas_makefilename(x->canvas, filename->s_name,buf, MAXPDSTRING);
+
+
+ w_error = (binbuf_write(bbuf, buf, "", 0));
+
+
+ binbuf_free(bbuf);
+
+ if (w_error) pd_error(x,"%s: write failed", filename->s_name);
+
+
+ x->working = 0;
+}
+
+static void paramFile_read(t_paramFile* x, int f)
+{
+
+ if ( x->working ) {
+ pd_error(x,"paramFile can only save or load to one file at a time");
+ return;
+ }
+ x->working = 1;
+
+ t_symbol* filename = paramFile_makefilename(x,f);
+ post("Reading: %s",filename->s_name);
+
+ int r_error;
+
+ //t_symbol* filename = param_makefilename(basename, n);
+
+ t_binbuf *bbuf = binbuf_new();
+
+ r_error= (binbuf_read_via_canvas(bbuf, filename->s_name, x->canvas, 0));
+ //pd_error(x, "%s: read failed", filename->s_name);
+
+ t_symbol* root = x->root;
+
+ int bb_ac = binbuf_getnatom(bbuf);
+ int ac = 0;
+ t_atom *bb_av = binbuf_getvec(bbuf);
+ t_atom *av = bb_av;
+
+ while (bb_ac--) {
+ if (bb_av->a_type == A_SEMI) {
+ if ( IS_A_SYMBOL(av,0) && ac > 1) {
+ t_symbol* path = atom_getsymbol(av);
+ strcpy(param_buf_temp_a,root->s_name);
+ strcat(param_buf_temp_a,path->s_name);
+ t_symbol* s = gensym(param_buf_temp_a);
+ #ifdef PARAMDEBUG
+ post("Restoring:%s",s->s_name);
+ #endif
+
+ // STUPID SYMBOL WITH SPACES MANAGEMENT
+ if ( s->s_thing && ac > 3 && IS_A_SYMBOL(av,1) && atom_getsymbol(av+1) == &s_symbol) {
+ // This whole block is simply to convert symbols saved with spaces to complete symbols
+
+ t_binbuf *bbuf_stupid = binbuf_new();
+ binbuf_add(bbuf_stupid, ac-2, av+2);
+
+ char *char_buf;
+ int char_length;
+ binbuf_gettext(bbuf_stupid, &char_buf, &char_length);
+ char_buf = resizebytes(char_buf, char_length, char_length+1);
+ char_buf[char_length] = 0;
+ t_symbol* stupid_symbol = gensym(char_buf);
+ //post("STUPID: %s",stupid_symbol->s_name);
+ freebytes(char_buf, char_length+1);
+ binbuf_free(bbuf_stupid);
+ t_atom* stupid_atom = getbytes(sizeof(*stupid_atom));
+ SETSYMBOL(stupid_atom, stupid_symbol);
+ pd_typedmess(s->s_thing, &s_symbol, 1, stupid_atom);
+ freebytes(stupid_atom, sizeof(*stupid_atom));
+
+ } else {
+ if ( s->s_thing) pd_forwardmess(s->s_thing, ac-1, av+1);
+ }
+ }
+
+ ac = 0;
+ av = bb_av + 1;
+ } else {
+
+ ac = ac + 1;
+ }
+ bb_av++;
+ }
+
+ binbuf_free(bbuf);
+
+ if ( r_error) pd_error(x, "%s: read failed", filename->s_name);
+
+ x->working = 0;
+}
+
+
+
+
+
+/*
static void paramFile_write(t_paramFile *x, t_float f) {
@@ -52,18 +176,18 @@ static void paramFile_write(t_paramFile *x, t_float f) {
if ( param_write(x->canvas,filename) ) pd_error(x,"%s: write failed", filename->s_name);
}
-
-
+*/
+/*
static void paramFile_read(t_paramFile *x, t_float f) {
- t_symbol* filename = paramFile_makefilename(x->basename,f);
+ t_symbol* filename = paramFile_makefilename(x,f);
post("Reading: %s",filename->s_name);
if (param_read(x->canvas, filename)) pd_error(x, "%s: read failed", filename->s_name);
}
-
+*/
static void paramFile_bang(t_paramFile *x) {
@@ -78,6 +202,7 @@ static void paramFile_float(t_paramFile *x, t_float f) {
}
+
static void paramFile_inlet2_bang(t_paramFile_inlet2 *inlet2) {
paramFile_read(inlet2->x,0);
@@ -95,7 +220,7 @@ static void paramFile_free(t_paramFile *x)
if(x->inlet2) pd_free((t_pd *)x->inlet2);
-
+
}
@@ -111,17 +236,11 @@ static void* paramFile_new(t_symbol *s, int ac, t_atom *av) {
t_symbol* canvasname = tof_get_canvas_name(x->canvas);
// remove the .pd (actually removes everything after the .)
- int length = strlen(canvasname->s_name) + 1;
- char* buf = getbytes( (length ) * sizeof (*buf));
- strcpy(buf,canvasname->s_name);
- char* lastperiod = strrchr(buf,'.');
- if ( lastperiod != NULL ) {
- *lastperiod = '\0';
- x->basename = gensym(buf);
- } else {
- x->basename = canvasname;
- }
- freebytes(buf, (length ) * sizeof (*buf));
+ x->basename = tof_remove_extension(canvasname);
+
+ x->working = 0;
+
+ x->root = tof_get_dollarzero(x->canvas);
//x->outlet = outlet_new(&x->x_obj, &s_list);
diff --git a/test/paramId.c b/src/paramId.c
index fbd3d29..fbd3d29 100644
--- a/test/paramId.c
+++ b/src/paramId.c
diff --git a/src/paramRoute.c b/src/paramRoute.c
index 44db9e7..cc02cfe 100644
--- a/src/paramRoute.c
+++ b/src/paramRoute.c
@@ -76,7 +76,7 @@ static void paramRoute_anything(t_paramRoute *x, t_symbol *s, int ac, t_atom *av
strcpy(param_buf_temp_a, x->root->s_name);
strcpy(param_buf_temp_b, x->path->s_name);
- strcat(param_buf_temp_b, s->s_name + 1);
+ strcat(param_buf_temp_b, s->s_name);
t_symbol* path = gensym(param_buf_temp_b);
strcat(param_buf_temp_a, param_buf_temp_b);
t_symbol* target = gensym(param_buf_temp_a);
diff --git a/test/Makefile b/test/Makefile
index e1d67f9..22929fb 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,6 +1,6 @@
default:
-PARAM: param paramDump paramRoute paramFile
+PARAM: param paramDump paramRoute paramFile paramId paramCustom
current:
echo make class
diff --git a/test/param.c b/test/param.c
deleted file mode 100644
index 2aab6aa..0000000
--- a/test/param.c
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * param.c
- *
- * Copyright 2009 Thomas O Fredericks <tom@hp>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-
-
-#include "tof.h"
-#include "param.h"
-
-extern int sys_noloadbang;
-
-static t_class *param_class;
-static t_class *param_inlet2_class;
-struct _paramClass_inlet2;
-
-typedef struct _paramClass {
- t_object x_obj;
- struct _paramClass_inlet2 *inlet2;
- t_param* param;
- int noloadbang;
- t_symbol* selector;
- int alloc;
- int ac;
- t_atom* av;
- int gac; // gui options count
- t_atom* gav; // gui options
- t_outlet* outlet;
- t_symbol* receive;
- t_symbol* send;
- t_symbol* set_s;
-} t_paramClass;
-
-typedef struct _paramClass_inlet2
-{
- t_object x_obj;
- t_paramClass *p_owner;
-} t_paramClass_inlet2;
-
-
-
-static void paramClass_bang(t_paramClass *x)
-{
- outlet_anything(x->outlet, x->selector, x->ac, x->av);
-
- if(x->selector != &s_bang ) tof_send_anything_prepend(x->send,x->selector,x->ac,x->av,x->set_s );
-
-}
-
-static void paramClass_loadbang(t_paramClass *x)
-{
- if (!sys_noloadbang && !x->noloadbang)
- paramClass_bang(x);
-}
-
-static void paramClass_anything(t_paramClass *x, t_symbol *s, int ac, t_atom *av)
-{
- #ifdef PARAMDEBUG
- post("RECEIVING SOMETHING");
- #endif
- if ( s == &s_bang || ac == 0 ) {
- x->ac = 0;
- x->selector = s;
- } else {
- if(ac > x->alloc) {
- x->av = resizebytes(x->av, x->alloc*sizeof(*(x->av)),
- (10 + ac)*sizeof(*(x->av)));
- x->alloc = 10 + ac;
- }
- x->ac = ac;
- x->selector = s;
- tof_copy_atoms(av, x->av, ac);
- }
-
- paramClass_bang(x);
-
-}
-
-
-
-
-// SECOND INLET METHOD
-
-static void paramClass_inlet2_anything(t_paramClass_inlet2 *p, t_symbol *s, int ac, t_atom *av)
-{
- paramClass_anything(p->p_owner, s,ac,av);
-}
-
-// DECONSTRUCTOR
-
-static void paramClass_free(t_paramClass *x)
-{
-
- if(x->inlet2) pd_free((t_pd *)x->inlet2);
-
- if (x->receive) pd_unbind(&x->x_obj.ob_pd, x->receive);
-
- if (x->param) param_unregister(x->param);
-
- freebytes(x->gav, x->gac * sizeof(*(x->gav)));
-
- freebytes(x->av, x->alloc * sizeof(*(x->av)));
-
-}
-
-// SPECIAL PARAM GET FUNCTION
-static void paramClass_get(t_paramClass *x, t_symbol** s, int* ac, t_atom** av) {
- *s = x->selector;
- *ac = x->ac;
- *av = x->av;
-}
-
-// SPECIAL PARAM SAVE FUNCTION
-static void paramClass_save(t_paramClass *x, t_binbuf* bb) {
- //Put my data in binbuf
- if ((x->selector != &s_bang)) {
- int ac = x->ac + 2;
- t_atom *av = getbytes(ac*sizeof(*av));
- tof_copy_atoms(x->av,av+2,x->ac);
- SETSYMBOL(av, x->param->path);
- SETSYMBOL(av+1, x->selector);
- binbuf_add(bb, ac, av);
- binbuf_addsemi(bb);
- freebytes(av, ac*sizeof(*av));
- }
-}
-
-// SPECIAL PARAM GUI FUNCTION
-static void paramClass_GUI(t_paramClass *x, int* ac, t_atom** av) {
- *ac = x->gac;
- *av = x->gav;
-}
-
-
-
-// CONSTRUCTOR
-static void* paramClass_new(t_symbol *s, int ac, t_atom *av)
-{
- t_paramClass *x = (t_paramClass *)pd_new(param_class);
-
-
- // GET THE CURRENT CANVAS
- t_canvas* canvas=tof_get_canvas();
-
- // GET THE NAME
- t_symbol* name = param_get_name(ac,av);
-
- if (!name) return NULL;
-
- t_symbol* path = param_get_path(canvas,name);
- t_symbol* root = tof_get_dollarzero(tof_get_root_canvas(canvas));
-
- x->param = param_register(x,root,path,\
- (t_paramGetMethod) paramClass_get,\
- (t_paramSaveMethod) paramClass_save,\
- (t_paramGUIMethod) paramClass_GUI);
-
- if (!x->param) return NULL;
-
- // FIND PARAM VALUE
- // A. In canvas' arguments
- // B. In object's arguments
- // C. Defaults to a bang
-
- int ac_p = 0;
- t_atom* av_p = NULL;
-
-
- // A. In canvas' arguments
- int ac_c = 0;
- t_atom* av_c = NULL;
-
- t_canvas * before = tof_get_canvas_before_root(canvas);
- tof_get_canvas_arguments(before,&ac_c , &av_c);
- tof_find_tagged_argument('/',name, ac_c, av_c,&ac_p,&av_p);
-
- // B. I object's arguments
- if ( ac_p == 0 && ac > 1) {
- int ac_a = 0;
- t_atom* av_a = NULL;
- tof_find_tagged_argument('/',name, ac, av,&ac_p,&av_p);
- //tof_get_tagged_argument('/',ac,av,&start,&count);
- //if (count > 1) {
- // ac_p = ac_a;
- // av_p = av_a + 1;
- //}
- }
-
-
-
- // FIND THE NO LOADBANG TAG: /nlb
- int i;
- x->noloadbang = 0;
-
- for ( i =0; i < ac; i++) {
- if ( IS_A_SYMBOL(av,i) && (strcmp("/nlb",atom_getsymbol(av+i)->s_name) == 0)) {
- x->noloadbang = 1;
- break;
- }
- }
-
-
-
- //FIND THE GUI OPTIONS: /g
- int ac_g = 0;
- t_atom* av_g = NULL;
- // There could be a problem if the the name is also /g
- tof_find_tagged_argument('/',gensym("/g"), ac, av,&ac_g,&av_g);
- x->gac = ac_g;
- x->gav = getbytes(x->gac * sizeof(*(x->gav)));
- tof_copy_atoms(av_g,x->gav,x->gac);
-
-
-
- int l = strlen(path->s_name) + strlen(root->s_name) + 2;
- char* receiver = getbytes( l * sizeof(*receiver));
- strcat(receiver,root->s_name);
- strcat(receiver,path->s_name);
- x->receive = gensym(receiver);
- strcat(receiver,"_");
- x->send = gensym(receiver);
- freebytes(receiver, l * sizeof(*receiver));
- #ifdef PARAMDEBUG
- post("receive:%s",x->receive->s_name);
- post("send:%s",x->send->s_name);
- #endif
-
-
- // BIND RECEIVER
- pd_bind(&x->x_obj.ob_pd, x->receive );
-
-
- // Create memory space
- t_symbol* selector;
- tof_set_selector(&selector,&ac_p,&av_p);
- x->selector = selector;
- x->alloc = ac_p + 10;
- x->ac = ac_p;
- x->av = getbytes(x->alloc * sizeof(*(x->av)));
- tof_copy_atoms(av_p, x->av, x->ac);
-
-
-
- x->set_s = gensym("set");
-
- // Set up second inlet proxy
- t_paramClass_inlet2 *p = (t_paramClass_inlet2 *)pd_new(param_inlet2_class);
- x->inlet2 = p;
- p->p_owner = x;
-
- // CREATE INLETS AND OUTLETS
- inlet_new((t_object *)x, (t_pd *)p, 0, 0);
- x->outlet = outlet_new(&x->x_obj, &s_list);
-
- return (x);
-}
-
-void param_setup(void)
-{
- param_class = class_new(gensym("param"),
- (t_newmethod)paramClass_new, (t_method)paramClass_free,
- sizeof(t_paramClass), 0, A_GIMME, 0);
-
-
- class_addanything(param_class, paramClass_anything);
- class_addbang(param_class, paramClass_bang);
-
- class_addmethod(param_class, (t_method)paramClass_loadbang, gensym("loadbang"), 0);
-
- param_inlet2_class = class_new(gensym("_param_inlet2"),
- 0, 0, sizeof(t_paramClass_inlet2), CLASS_PD | CLASS_NOINLET, 0);
-
- class_addanything(param_inlet2_class, paramClass_inlet2_anything);
-
-}
diff --git a/test/param.h b/test/param.h
deleted file mode 100644
index 5e73e7a..0000000
--- a/test/param.h
+++ /dev/null
@@ -1,348 +0,0 @@
-//#define PARAMDEBUG
-
-typedef void (*t_paramGetMethod)(void*,t_symbol**,int*,t_atom**);
-typedef void (*t_paramSaveMethod)(void*,t_binbuf*);
-typedef void (*t_paramGUIMethod)(void*,int*,t_atom**);
-
-char param_buf_temp_a[MAXPDSTRING];
-char param_buf_temp_b[MAXPDSTRING];
-char* param_separator = "/";
-
-//char PARAMECHO = 0;
-
-//struct _paramroot;
-
-typedef struct _param {
- t_symbol* root;
- t_symbol* path; //Path(name) of the param
- void* x;
- struct _param* next; //Next param
- struct _param* previous; //Previous param
- t_paramGetMethod get; //Function to get current value
- t_paramSaveMethod save; //Function to save
- t_paramGUIMethod GUI;
- //t_symbol* send;
- //t_symbol* receive;
-} t_param;
-
-typedef struct _paramroot {
- t_symbol* root;
- t_param* params; //param list
- struct _paramroot* next; //Next paramroot
- struct _paramroot* previous; //Previous paramroot
-} t_paramroot;
-
-t_paramroot* PARAMROOTS;
-
-
-static t_paramroot* param_get_root(t_symbol* root) {
-
- if (PARAMROOTS == NULL) {
- #ifdef PARAMDEBUG
- post("Could not get...not even one root created");
- #endif
- return NULL;
- }
-
-
- // Pointer to the start of paramroots
- t_paramroot* branch = PARAMROOTS;
-
- while( branch ) {
- if ( branch->root == root) {
- #ifdef PARAMDEBUG
- post("Found root:%s",root->s_name);
- #endif
-
- return branch;
- }
- branch = branch->next;
- }
- #ifdef PARAMDEBUG
- post("Could not find root");
- #endif
- return branch;
-
-}
-
-
-static t_paramroot* param_root_attach(t_symbol* root){
-
- // Pointer to the start of paramroots
- t_paramroot* branch = PARAMROOTS;
-
- while( branch ) {
- if ( branch->root == root) {
- #ifdef PARAMDEBUG
- post("Found root:%s",root->s_name);
- #endif
-
- return branch;
- }
- if ( branch->next == NULL ) break;
- branch = branch->next;
- }
-
- // we did not find a paramroot linked to this root canvas
- // so we create it
- #ifdef PARAMDEBUG
- post("Creating root:%s",root->s_name);
- #endif
-
- // Create and add paramroot to the end
- t_paramroot* newbranch = getbytes(sizeof(*newbranch));
- newbranch->root = root;
- newbranch->next = NULL;
- newbranch->params = NULL;
-
- if (branch) {
- #ifdef PARAMDEBUG
- post("Appending it to previous roots");
- #endif
- newbranch->previous = branch;
- branch->next = newbranch;
- } else {
- #ifdef PARAMDEBUG
- post("Creating first root");
- #endif
- newbranch->previous = NULL;
- PARAMROOTS = newbranch;
- }
-
-
- return newbranch;
-
-}
-
-
-
-static t_param* get_param_list(t_symbol* root) {
-
-
- t_paramroot* branch = param_get_root(root);
- if (branch) {
-
- #ifdef PARAMDEBUG
- post("Getting params from %s",branch->root->s_name);
- if (!branch->params) post("Root contains no params");
- #endif
- return branch->params;
- }
-
- return NULL;
-
-}
-
-
-static t_symbol* param_get_name ( int ac, t_atom* av ) {
-
- if (ac && IS_A_SYMBOL(av, 0)) {
- char* name = atom_getsymbol(av)->s_name;
- if (*name == *param_separator ) {
- int length = strlen(name);
- if (name[length-1] != '_') return atom_getsymbol(av);
- }
- }
- post("param names must start with a \"/\" and can not end with a \"_\"!");
- return NULL;
-}
-
-
-static t_symbol* param_get_path( t_canvas* i_canvas, t_symbol* name) {
-
- char* sbuf_name = param_buf_temp_a;
- char* sbuf_temp = param_buf_temp_b;
- sbuf_name[0] = '\0';
- sbuf_temp[0] = '\0';
- //char* separator = "/";
-
-
- t_symbol* id_s = gensym("/id"); // symbol that points to "/id" symbol
-
- // arguments of the current canvas being analyzed
- int i_ac;
- t_atom * i_av;
-
- // temp pointer to the current id being added to the path
- t_symbol* id_temp;
-
- /* FIND ID AND BASEPATH */
- while( i_canvas->gl_owner) {
- // Ignore all supatches
- if ( tof_canvas_is_not_subpatch(i_canvas) ) {
- tof_get_canvas_arguments(i_canvas,&i_ac, &i_av);
- id_temp=NULL;
- //id_temp= canvas_realizedollar(i_canvas, gensym("$0"));
- int ac_a = 0;
- t_atom* av_a = NULL;
- int iter = 0;
- //found_id_flag = 0;
-
- while( tof_next_tagged_argument(*param_separator,i_ac,i_av,&ac_a,&av_a,&iter) ) {
-
- if ( IS_A_SYMBOL(av_a,0)
- && (id_s == av_a->a_w.w_symbol)
- && (ac_a > 1) ) {
- id_temp = atom_getsymbol(av_a+1);
- //id_canvas = i_canvas;
- //found_id_flag = 1;
- break;
- }
- }
-
- if (id_temp == NULL) {
-
- id_temp = tof_remove_extension(tof_get_canvas_name(i_canvas));
- }
- // if ever an /id is missing, this param is not saveable
- //if (found_id_flag == 0) saveable = 0;
-
- // Prepend newly found ID
- strcpy(sbuf_temp,sbuf_name);
- strcpy(sbuf_name, param_separator);
- strcat(sbuf_name, id_temp->s_name);
- strcat(sbuf_name,sbuf_temp);
- }
- i_canvas = i_canvas->gl_owner;
- }
- //strcat(sbuf_name,separator);
- if ( name != NULL) {
- strcat(sbuf_name,name->s_name);
- } else {
- strcat(sbuf_name, param_separator);
- }
-
- return gensym(sbuf_name);
-
-}
-
-
-
-// root, path, ac, av, ac_g, av_g
-// From there, deduct id, path_, etc...
-
-//static struct param* register_param( t_canvas* canvas, int o_ac, t_atom* o_av) {
-
-static t_param* param_register(void* x,t_symbol* root, t_symbol* path,\
- t_paramGetMethod get, t_paramSaveMethod save, t_paramGUIMethod GUI) {
-
-
- //char *separator = "/";
-
- /* GET POINTER TO PARAMLIST FOR THAT ROOT */
- t_paramroot* branch = param_root_attach(root);
- t_param* last = branch->params;
-
- // Search for param with same path
- while( last ) {
- if ( last->path == path) {
-
- pd_error(x,"Found param with same name: %s", path->s_name);
-
- return NULL;
- }
- if ( last->next == NULL ) break;
- last = last->next;
- }
-
- // Create and add param to the end
-
- t_param* p = getbytes(sizeof(*p));
- p->root = root;
- //p->alloc = 0;
- p->path = path;
-
- // Create receive and send symbols: $0/path
- //strcpy(param_buf_temp_a,p->root->s_name);
- //strcat(param_buf_temp_a,separator);
- //strcat(param_buf_temp_a,p->path->s_name);
- //p->receive = gensym(param_buf_temp_a);
- //strcat(param_buf_temp_a,"_");
- //p->send = gensym(param_buf_temp_a);
-
- p->next = NULL;
- p->x = x;
- p->get = get;
- p->save = save;
- p->GUI = GUI;
- //p->id = id;
- //set_param( p, ac, av);
- //p->ac_g = ac_g;
- //p->av_g = getbytes(ac_g*sizeof(*(p->av_g)));
- //tof_copy_atoms(av_g,p->av_g,ac_g);
- if (last) {
- #ifdef PARAMDEBUG
- post("Appending param");
- #endif
- p->previous = last;
- last->next = p;
- } else {
- #ifdef PARAMDEBUG
- post("Creating first param");
- #endif
- p->previous = NULL;
- branch->params = p;
- }
-
-
- return p;
-
-}
-
-static void param_unregister(t_param* p) {
-
- //post("unregistering %s", p->path->s_name);
- t_paramroot* branch = param_get_root(p->root);
- t_param* paramlist = branch->params;
-
- if ( paramlist) {
-
- //p->users = p->users - 1;
- //if ( p->users == 0 ) {
- // Remove param
- //post("Removing last param of this name");
- if (p->previous) {
- p->previous->next = p->next;
- if (p->next) p->next->previous = p->previous;
- /*
- if (p->next == NULL) {
- p->previous->next = NULL;
- } else {
- p->previous->next = p->next;
- }
- */
- } else {
- paramlist = p->next;
- if ( p->next != NULL) p->next->previous = NULL;
- }
- //freebytes(p->av, p->alloc * sizeof *(p->av) );
- //freebytes(p->av_g, p->ac_g * sizeof *(p->av_g) );
- freebytes(p, sizeof *p);
- //}
-
- // Update the params for that root
- if (paramlist == NULL) {
- if (branch->previous) {
- branch->previous->next = branch->next;
- if (branch->next) branch->next->previous = branch->previous;
- } else {
- PARAMROOTS = branch->next;
- if ( branch->next != NULL) branch->next->previous = NULL;
- }
- #ifdef PARAMDEBUG
- post("Removing root:%s",branch->root->s_name);
- #endif
- freebytes(branch, sizeof *branch);
- } else {
- branch->params = paramlist;
- }
-
- } else {
- post("Euh... no params found!");
- }
-
-
-}
-
-
-
diff --git a/test/paramDump.c b/test/paramDump.c
deleted file mode 100644
index b9f73b9..0000000
--- a/test/paramDump.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * paramDump.c
- *
- * Copyright 2009 Thomas O Fredericks <tom@hp>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-
-
-#include "tof.h"
-#include "param.h"
-
-
-static t_class *paramDump_class;
-
-
-typedef struct _paramDump
-{
- t_object x_obj;
- t_outlet* outlet;
- //t_symbol* s_set;
- t_symbol* root;
-} t_paramDump;
-
-
-
-static void paramDump_guis(t_paramDump *x, t_symbol* s) {
-
-
-
- t_param* p = get_param_list(x->root);
- int ac;
- t_atom* av;
-
- while (p) {
- if (p->GUI ) {
- p->GUI(p->x,&ac,&av);
- outlet_anything(x->outlet,p->path,ac,av);
-
- }
- p = p->next;
- }
-
-}
-
-
-// Dump out everything (OR THE ID'S OR JUST THE NAMES?)
-static void paramDump_bang(t_paramDump *x) {
-
- t_param* p = get_param_list(x->root);
- #ifdef PARAMDEBUG
- if (p == NULL) {
- post("No params found");
- } else {
- post("Found params");
- }
- #endif
-
- t_symbol* selector;
- int ac;
- t_atom* av;
-
- while (p) {
- if ( p->get ) {
- p->get(p->x, &selector, &ac, &av);
- tof_outlet_anything_prepend(x->outlet,selector,ac,av,p->path);
- }
- p = p->next;
- }
-
-
-}
-
-
-
-static void paramDump_free(t_paramDump *x)
-{
-
-
-}
-
-
-static void *paramDump_new(t_symbol *s, int ac, t_atom *av) {
- t_paramDump *x = (t_paramDump *)pd_new(paramDump_class);
-
- x->root = tof_get_dollarzero(tof_get_root_canvas(tof_get_canvas()));
-
-
- //x->s_set = gensym("set");
-
- x->outlet = outlet_new(&x->x_obj, &s_list);
-
- return (x);
-}
-
-void paramDump_setup(void) {
- paramDump_class = class_new(gensym("paramDump"),
- (t_newmethod)paramDump_new, (t_method)paramDump_free,
- sizeof(t_paramDump), 0, A_GIMME, 0);
-
- class_addbang(paramDump_class, paramDump_bang);
-
- //class_addmethod(paramDump_class, (t_method) paramDump_values, gensym("values"), A_DEFSYMBOL,0);
-
- class_addmethod(paramDump_class, (t_method) paramDump_guis, gensym("guis"), A_DEFSYMBOL,0);
- //class_addmethod(paramDump_class, (t_method) paramDump_update_guis, gensym("update"), A_DEFSYMBOL,0);
-
-}
diff --git a/test/paramFile.c b/test/paramFile.c
deleted file mode 100644
index db9b28d..0000000
--- a/test/paramFile.c
+++ /dev/null
@@ -1,273 +0,0 @@
-
-#include "tof.h"
-#include "param.h"
-#include <stdio.h>
-#include <fcntl.h>
-
-
-
-static t_class *paramFile_class;
-static t_class *paramFile_inlet2_class;
-struct _paramFile_inlet2;
-
-typedef struct _paramFile
-{
- t_object x_obj;
- t_canvas *canvas;
- t_symbol* basename;
- t_symbol* root;
- struct _paramFile_inlet2 *inlet2;
- int working;
-} t_paramFile;
-
-
-typedef struct _paramFile_inlet2 {
- t_object x_obj;
- t_paramFile *x;
-} t_paramFile_inlet2;
-
-static t_symbol* paramFile_makefilename(t_paramFile* x, t_float f) {
-
- if (f < 0) f = 0;
- if ( f > 127) f = 127;
-
- int i = (int) f;
- int length = strlen(x->basename->s_name)+11;
- char* buf = getbytes( length * sizeof (*buf));
- sprintf(buf,"%s-%03d.param",x->basename->s_name,i);
- t_symbol* filename = gensym(buf);
- freebytes(buf, length * sizeof (*buf));
- return filename;
-}
-
-
-
-static void paramFile_write(t_paramFile* x, int f) {
-
- if ( x->working ) {
- pd_error(x,"paramFile can only save or load to one file at a time");
- return;
- }
- x->working = 1;
-
- t_symbol* filename = paramFile_makefilename(x,f);
- post("Writing: %s",filename->s_name);
-
- int w_error;
-
- t_binbuf *bbuf = binbuf_new();
-
- t_param *p = get_param_list(x->root);
-
- while(p) {
-
- if ( p->save ) p->save(p->x,bbuf);
-
- p = p->next;
- }
-
-
- char buf[MAXPDSTRING];
- canvas_makefilename(x->canvas, filename->s_name,buf, MAXPDSTRING);
-
-
- w_error = (binbuf_write(bbuf, buf, "", 0));
-
-
- binbuf_free(bbuf);
-
- if (w_error) pd_error(x,"%s: write failed", filename->s_name);
-
-
- x->working = 0;
-}
-
-static void paramFile_read(t_paramFile* x, int f)
-{
-
- if ( x->working ) {
- pd_error(x,"paramFile can only save or load to one file at a time");
- return;
- }
- x->working = 1;
-
- t_symbol* filename = paramFile_makefilename(x,f);
- post("Reading: %s",filename->s_name);
-
- int r_error;
-
- //t_symbol* filename = param_makefilename(basename, n);
-
- t_binbuf *bbuf = binbuf_new();
-
- r_error= (binbuf_read_via_canvas(bbuf, filename->s_name, x->canvas, 0));
- //pd_error(x, "%s: read failed", filename->s_name);
-
- t_symbol* root = x->root;
-
- int bb_ac = binbuf_getnatom(bbuf);
- int ac = 0;
- t_atom *bb_av = binbuf_getvec(bbuf);
- t_atom *av = bb_av;
-
- while (bb_ac--) {
- if (bb_av->a_type == A_SEMI) {
- if ( IS_A_SYMBOL(av,0) && ac > 1) {
- t_symbol* path = atom_getsymbol(av);
- strcpy(param_buf_temp_a,root->s_name);
- strcat(param_buf_temp_a,path->s_name);
- t_symbol* s = gensym(param_buf_temp_a);
- #ifdef PARAMDEBUG
- post("Restoring:%s",s->s_name);
- #endif
-
- // STUPID SYMBOL WITH SPACES MANAGEMENT
- if ( s->s_thing && ac > 3 && IS_A_SYMBOL(av,1) && atom_getsymbol(av+1) == &s_symbol) {
- // This whole block is simply to convert symbols saved with spaces to complete symbols
-
- t_binbuf *bbuf_stupid = binbuf_new();
- binbuf_add(bbuf_stupid, ac-2, av+2);
-
- char *char_buf;
- int char_length;
- binbuf_gettext(bbuf_stupid, &char_buf, &char_length);
- char_buf = resizebytes(char_buf, char_length, char_length+1);
- char_buf[char_length] = 0;
- t_symbol* stupid_symbol = gensym(char_buf);
- //post("STUPID: %s",stupid_symbol->s_name);
- freebytes(char_buf, char_length+1);
- binbuf_free(bbuf_stupid);
- t_atom* stupid_atom = getbytes(sizeof(*stupid_atom));
- SETSYMBOL(stupid_atom, stupid_symbol);
- pd_typedmess(s->s_thing, &s_symbol, 1, stupid_atom);
- freebytes(stupid_atom, sizeof(*stupid_atom));
-
- } else {
- if ( s->s_thing) pd_forwardmess(s->s_thing, ac-1, av+1);
- }
- }
-
- ac = 0;
- av = bb_av + 1;
- } else {
-
- ac = ac + 1;
- }
- bb_av++;
- }
-
- binbuf_free(bbuf);
-
- if ( r_error) pd_error(x, "%s: read failed", filename->s_name);
-
- x->working = 0;
-}
-
-
-
-
-
-/*
-static void paramFile_write(t_paramFile *x, t_float f) {
-
-
- t_symbol* filename = paramFile_makefilename(x->basename,f);
- post("Writing: %s",filename->s_name);
- if ( param_write(x->canvas,filename) ) pd_error(x,"%s: write failed", filename->s_name);
-
-}
-*/
-/*
-static void paramFile_read(t_paramFile *x, t_float f) {
-
-
- t_symbol* filename = paramFile_makefilename(x,f);
- post("Reading: %s",filename->s_name);
- if (param_read(x->canvas, filename)) pd_error(x, "%s: read failed", filename->s_name);
-
-
-}
-*/
-
-
-static void paramFile_bang(t_paramFile *x) {
-
- paramFile_write(x,0);
-}
-
-
-static void paramFile_float(t_paramFile *x, t_float f) {
-
- paramFile_write(x,f);
-
-}
-
-
-static void paramFile_inlet2_bang(t_paramFile_inlet2 *inlet2) {
-
- paramFile_read(inlet2->x,0);
-
-}
-
-static void paramFile_inlet2_float(t_paramFile_inlet2 *inlet2,t_float f) {
-
- paramFile_read(inlet2->x,f);
-
-}
-
-static void paramFile_free(t_paramFile *x)
-{
-
- if(x->inlet2) pd_free((t_pd *)x->inlet2);
-
-
-}
-
-
-static void* paramFile_new(t_symbol *s, int ac, t_atom *av) {
- t_paramFile *x = (t_paramFile *)pd_new(paramFile_class);
- t_paramFile_inlet2 *inlet2 = (t_paramFile_inlet2 *)pd_new(paramFile_inlet2_class);
-
- inlet2->x = x;
- x->inlet2 = inlet2;
-
- t_canvas* canvas = tof_get_canvas();
- x->canvas = tof_get_root_canvas(canvas);
- t_symbol* canvasname = tof_get_canvas_name(x->canvas);
-
- // remove the .pd (actually removes everything after the .)
- x->basename = tof_remove_extension(canvasname);
-
- x->working = 0;
-
- x->root = tof_get_dollarzero(x->canvas);
-
- //x->outlet = outlet_new(&x->x_obj, &s_list);
-
- inlet_new((t_object *)x, (t_pd *)inlet2, 0, 0);
-
- return (x);
-
-}
-
-
-void paramFile_setup(void) {
- paramFile_class = class_new(gensym("paramFile"),
- (t_newmethod)paramFile_new, (t_method)paramFile_free,
- sizeof(t_paramFile), 0, A_GIMME, 0);
-
- class_addbang(paramFile_class, paramFile_bang);
- class_addfloat(paramFile_class, paramFile_float);
-
- paramFile_inlet2_class = class_new(gensym("paramFile_inlet2"),
- 0, 0, sizeof(t_paramFile_inlet2), CLASS_PD | CLASS_NOINLET, 0);
-
- class_addbang(paramFile_inlet2_class, paramFile_inlet2_bang);
- class_addfloat(paramFile_inlet2_class, paramFile_inlet2_float);
-
- class_addmethod(paramFile_class, (t_method) paramFile_read, gensym("load"), A_DEFFLOAT,0);
- class_addmethod(paramFile_class, (t_method) paramFile_write, gensym("save"), A_DEFFLOAT,0);
-
-}
-
-
diff --git a/test/paramRoute.c b/test/paramRoute.c
deleted file mode 100644
index 44db9e7..0000000
--- a/test/paramRoute.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * paramRoute.c
- *
- * Copyright 2009 Thomas O Fredericks <tom@hp>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-
-
-
-
-#include "tof.h"
-#include "param.h"
-
-
-static t_class *paramRoute_class;
-
-typedef struct _paramRoute
-{
- t_object x_obj;
- t_symbol *path;
- t_outlet *x_outlet;
- t_symbol *s_save;
- t_symbol *s_load;
- t_symbol* s_empty;
- t_canvas* canvas;
- t_symbol* root;
-
-} t_paramRoute;
-
-
-static void paramRoute_anything(t_paramRoute *x, t_symbol *s, int ac, t_atom *av) {
-
- //I DEACTIVATED THE SAVE & LOAD FEATURES UNTIL I BETTER DEFINE PARAMROUTE'S STATE SAVING
-
- if (s == x->s_save) { // Save
-
- //~ if (x->id) {
- //~ int n = 0;
- //~ if ( ac ) n = atom_getfloat(av);
- //~ t_symbol* filename = paramRoute_makefilename(x->id,n);
- //~ if ( param_write(x->canvas,filename, x->id) )
- //~ pd_error("[paramRoute] could not write %s",filename->s_name);
- //~ } else {
- //~ pd_error(x,"[paramRoute] requires an /id");
- //~ }
- } else if ( s == x->s_load) { // Load
- //~ if (x->id) {
- //~ int n = 0;
- //~ if ( ac ) n = atom_getfloat(av);
- //~ t_symbol* filename = paramRoute_makefilename(x->id,n);
- //~ if ( param_read(x->canvas, paramRoute_makefilename(x->id,n)) )
- //~ pd_error("[paramRoute] could not read %s",filename->s_name);;
- //~ } else {
- //~ pd_error(x,"[paramRoute] requires an /id");
- //~ }
- } else { // Try to send
-
- if (ac) {
- //int sendBufLength = strlen(x->path->s_name) + strlen(s->s_name) + 1;
- //char *sendBuf = (char*)getbytes((sendBufLength)*sizeof(char));
- if ( s->s_name[0] == '/' && strlen(s->s_name) > 1) {
- strcpy(param_buf_temp_a, x->root->s_name);
- strcpy(param_buf_temp_b, x->path->s_name);
-
- strcat(param_buf_temp_b, s->s_name + 1);
- t_symbol* path = gensym(param_buf_temp_b);
- strcat(param_buf_temp_a, param_buf_temp_b);
- t_symbol* target = gensym(param_buf_temp_a);
- //freebytes(sendBuf, (sendBufLength)*sizeof(char));
- //post("target:%s",target->s_name);
- if (target->s_thing) {
- pd_forwardmess(target->s_thing, ac, av);
- } else {
- outlet_anything(x->x_outlet,path,ac,av);
- }
- } else {
- pd_error(x,"Target name must start with a \"/\"");
- }
- }
-
- }
-
-}
-
-// DECONSTRUCTOR
-static void paramRoute_free(t_paramRoute*x)
-{
-
-}
-
-// CONSTRUCTOR
-static void *paramRoute_new(t_symbol *s, int ac, t_atom *av) {
- t_paramRoute *x = (t_paramRoute *)pd_new(paramRoute_class);
-
- x->s_save = gensym("save");
- x->s_load = gensym("load");
- x->s_empty = gensym("");
-
-
- // GET THE CURRENT CANVAS
- t_canvas *canvas=tof_get_canvas();
-
- // Get the root canvas
- x->canvas = tof_get_root_canvas(canvas);
-
- x->root = tof_get_dollarzero(x->canvas);
-
- x->path = param_get_path(canvas,NULL);
-
- // INLETS AND OUTLETS
- x->x_outlet = outlet_new(&x->x_obj, &s_list);
- return (x);
-}
-
-void paramRoute_setup(void) {
- paramRoute_class = class_new(gensym("paramRoute"),
- (t_newmethod)paramRoute_new, (t_method)paramRoute_free,
- sizeof(t_paramRoute), 0, A_GIMME, 0);
-
- class_addanything(paramRoute_class, paramRoute_anything);
-
-}