aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas O Fredericks <mrtof@users.sourceforge.net>2009-10-26 20:32:27 +0000
committerThomas O Fredericks <mrtof@users.sourceforge.net>2009-10-26 20:32:27 +0000
commit7541b9f1ba232dce4aceb41115c17292bd7298f4 (patch)
treeb4dde0f6f22577896bdaaa4fa698e987491098e6 /src
parentd6e37fa5490c8e3465eb4e92a0f9d9a60d3dbc4b (diff)
Delocalized param
svn path=/trunk/externals/tof/; revision=12679
Diffstat (limited to 'src')
-rw-r--r--src/param.c25
-rw-r--r--src/param.h2
-rw-r--r--src/paramCustom.h26
-rw-r--r--src/paramFile.h82
-rw-r--r--src/paramGui.h30
-rw-r--r--src/paramRoute.h53
6 files changed, 144 insertions, 74 deletions
diff --git a/src/param.c b/src/param.c
index ae1f0c2..fc2daf0 100644
--- a/src/param.c
+++ b/src/param.c
@@ -19,6 +19,9 @@
* MA 02110-1301, USA.
*/
+//#define PARAMDEBUG
+//#define LOCAL
+
#include "param.h"
#include "paramCustom.h"
#include "paramDump.h"
@@ -262,7 +265,10 @@ static void* paramClass_new(t_symbol *s, int ac, t_atom *av)
int l = strlen(path->s_name) + strlen(root->s_name) + 2;
char* receiver = getbytes( l * sizeof(*receiver));
+ receiver[0]='\0';
+ #ifdef LOCAL
strcat(receiver,root->s_name);
+ #endif
strcat(receiver,path->s_name);
x->receive = gensym(receiver);
strcat(receiver,"_");
@@ -310,17 +316,18 @@ static void* param_new(t_symbol *s, int argc, t_atom *argv) {
//post("RUNNING COMMON NEW");
- t_pd* x;
+ t_pd* x = NULL;
if ( !argc || argv[0].a_type == A_FLOAT ) {
x = NULL;
} else {
- t_symbol *s2 = argv[0].a_w.w_symbol;
+ t_symbol *s2 = argv[0].a_w.w_symbol;
- //post("Loading: %s",s2->s_name);
-
- if (s2 == gensym("custom"))
+ //post("Loading: %s",s2->s_name);
+ if ( s2->s_name[0] == '/' )
+ x = paramClass_new(s, argc, argv);
+ else if (s2 == gensym("custom"))
x = paramCustom_new(s, argc-1, argv+1);
else if (s2 == gensym("dump"))
x = paramDump_new(s, argc-1, argv+1);
@@ -333,11 +340,11 @@ static void* param_new(t_symbol *s, int argc, t_atom *argv) {
else if (s2 == gensym("gui"))
x = paramGui_new(s, argc-1, argv+1);
else
- x = paramClass_new(s, argc, argv);
+ post("Param is missing an argument. Possible values: custom, dump, file, path, route, gui or a /name.");
}
+ /*
if ( x == NULL) {
- post("Param is missing a symbolic argument. Possible values: custom, dump, file, path, route, gui or a /name.");
- //post(" custom");
+ //post(" custom");
//dump file id route gui or a /\"name\"
//post("- dump");
//post("- file");
@@ -346,7 +353,7 @@ static void* param_new(t_symbol *s, int argc, t_atom *argv) {
//post("- gui");
//post("- or a /name.");
}
-
+ */
return (x);
}
diff --git a/src/param.h b/src/param.h
index 1c0b3a5..46daca6 100644
--- a/src/param.h
+++ b/src/param.h
@@ -2,7 +2,7 @@
#include <stdio.h>
#include <fcntl.h>
-//#define PARAMDEBUG
+
typedef void (*t_paramGetMethod)(void*,t_symbol**,int*,t_atom**);
typedef void (*t_paramSaveMethod)(void*,t_binbuf*,int);
diff --git a/src/paramCustom.h b/src/paramCustom.h
index 3d3f979..db1e66e 100644
--- a/src/paramCustom.h
+++ b/src/paramCustom.h
@@ -10,7 +10,7 @@ typedef struct _paramCustom {
t_outlet* outlet;
t_outlet* outlet2;
t_binbuf* bb;
- t_symbol* receive;
+ //t_symbol* receive;
struct _paramCustom_receive* r;
int nopresets;
} t_paramCustom;
@@ -66,7 +66,7 @@ static void paramCustom_anything(t_paramCustom *x, t_symbol *selector, int argc,
static void paramCustom_free(t_paramCustom *x)
{
- if (x->receive) pd_unbind(&x->r->x_obj.ob_pd, x->receive);
+ //if (x->receive) pd_unbind(&x->r->x_obj.ob_pd, x->receive);
if (x->param) param_unregister(x->param);
@@ -83,8 +83,9 @@ static void paramClass_get(t_paramClass *x, t_symbol** s, int* ac, t_atom** av)
*/
// SPECIAL PARAM SAVE FUNCTION
-static void paramCustom_save(t_paramCustom *x, t_binbuf* bb, int f) {
+static void paramCustom_save(t_paramCustom_receive *r, t_binbuf* bb, int f) {
+ t_paramCustom* x = r->owner;
// f = -1 for the main save file
// f => 0 if it is a preset
if ( f >= 0 && x->nopresets) return;
@@ -134,9 +135,15 @@ static void* paramCustom_new(t_symbol *s, int ac, t_atom *av)
// FIND THE NO PRESET TAG: /nps
x->nopresets = tof_find_symbol(gensym("/nps"), ac-1, av+1);
+ // Set up param proxy
+ t_paramCustom_receive *r = (t_paramCustom_receive *)pd_new(paramCustom_receive_class);
+ x->r = r;
+ r->owner = x;
+ // BIND RECEIVER
+ //pd_bind(&r->x_obj.ob_pd, x->receive );
- x->param = param_register(x,root,path, NULL,\
+ x->param = param_register(r,root,path, NULL,\
(t_paramSaveMethod) paramCustom_save,NULL);
if (!x->param) return NULL;
@@ -147,9 +154,8 @@ static void* paramCustom_new(t_symbol *s, int ac, t_atom *av)
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);
+ //x->receive = gensym(receiver);
+
freebytes(receiver, l * sizeof(*receiver));
#ifdef PARAMDEBUG
@@ -161,13 +167,7 @@ static void* paramCustom_new(t_symbol *s, int ac, t_atom *av)
x->bb = NULL;
- // Set up receive proxy
- t_paramCustom_receive *r = (t_paramCustom_receive *)pd_new(paramCustom_receive_class);
- x->r = r;
- r->owner = x;
- // BIND RECEIVER
- pd_bind(&r->x_obj.ob_pd, x->receive );
diff --git a/src/paramFile.h b/src/paramFile.h
index 42d568b..66d016c 100644
--- a/src/paramFile.h
+++ b/src/paramFile.h
@@ -100,56 +100,69 @@ static void paramFile_do_load(t_paramFile* x, t_float f) {
t_symbol* filename = paramFile_makefilename(x,f);
post("Reading: %s",filename->s_name);
- int r_error;
- //t_symbol* filename = param_makefilename(basename, n);
+ t_symbol* root = x->root;
+
+ t_param* pp = get_param_list(root);
+ t_param* p;
+
+ if (pp) {
+ int r_error;
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;
+ t_symbol* s;
+
while (bb_ac--) {
if (bb_av->a_type == A_SEMI) {
if ( IS_A_SYMBOL(av,0) && ac > 1) {
+ /*
+ #ifdef LOCAL
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
+ t_symbol* s = gensym(param_buf_temp_a);
+ #else
+ t_symbol* s = atom_getsymbol(av);
+ #endif
+ */
+ s = atom_getsymbol(av);
+ p = pp;
+ while(p && p->path != s) p=p->next;
- // 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);
+
+ if (p) {
+ if ( ac > 3 && IS_A_SYMBOL(av,1) && atom_getsymbol(av+1) == &s_symbol) {
+ // STUPID MANAGEMENT OF SYMBOLS WITH SPACES
+ // 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(p->x, &s_symbol, 1, stupid_atom);
+ freebytes(stupid_atom, sizeof(*stupid_atom));
+
+ } else {
+ pd_forwardmess(p->x, ac-1, av+1);
+ }
}
}
@@ -165,6 +178,9 @@ static void paramFile_do_load(t_paramFile* x, t_float f) {
binbuf_free(bbuf);
if ( r_error) pd_error(x, "%s: read failed", filename->s_name);
+ }
+
+
x->working = 0;
diff --git a/src/paramGui.h b/src/paramGui.h
index 0a6e918..ecac8f1 100644
--- a/src/paramGui.h
+++ b/src/paramGui.h
@@ -31,6 +31,7 @@ typedef struct _paramGui
t_symbol* s_symbolatom;
t_symbol* s_sym;
t_symbol* s_text;
+ t_symbol* s_cnv;
//t_symbol* target;
//t_class* empty_s;
@@ -49,10 +50,33 @@ static void paramGui_bang(t_paramGui *x) {
// Clear the canvas
pd_typedmess((t_pd*)x->childcanvas,x->s_clear,0,NULL);
+
+
int pos_x = 0;
int pos_y = 0;
t_atom atoms[22]; // This should be the maximum number of atoms
+ // PINK HEADER
+ SETSYMBOL(&atoms[0],x->s_obj);
+ SETFLOAT(&atoms[1],pos_x);
+ SETFLOAT(&atoms[2],pos_y);
+ SETSYMBOL(&atoms[3],x->s_cnv);
+ SETFLOAT(&atoms[4],15);
+ SETFLOAT(&atoms[5],200);
+ SETFLOAT(&atoms[6],20);
+ SETSYMBOL(&atoms[7],x->s_empty);
+ SETSYMBOL(&atoms[8],x->s_empty);
+ SETSYMBOL(&atoms[9],x->path);
+ SETFLOAT(&atoms[10],2);
+ SETFLOAT(&atoms[11],12);
+ SETFLOAT(&atoms[12],0);
+ SETFLOAT(&atoms[13],8);
+ SETFLOAT(&atoms[14],-258401);
+ SETFLOAT(&atoms[15],-262144);
+ SETFLOAT(&atoms[16],0);
+ pd_forwardmess((t_pd*)x->childcanvas, 17, atoms);
+ pos_y = pos_y + 23;
+
t_param* p = get_param_list(x->root);
int ac;
t_atom* av;
@@ -71,6 +95,8 @@ static void paramGui_bang(t_paramGui *x) {
t_atom* av_got;
t_symbol* s_got;
+
+
while (p) {
gui_built = 1;
if (p->GUI && (strncmp(p->path->s_name,x->path->s_name,x->path_l)==0)) {
@@ -103,6 +129,9 @@ static void paramGui_bang(t_paramGui *x) {
shortpath = gensym(p->path->s_name + x->path_l);
}
+
+
+
type = atom_getsymbol(av);
if ( type == x->s_nbx ) {
SETSYMBOL(&atoms[0],x->s_obj);
@@ -302,6 +331,7 @@ static void *paramGui_new(t_symbol *s, int ac, t_atom *av) {
x->s_symbolatom = gensym("symbolatom");
x->s_sym = gensym("sym");
x->s_text = gensym("text");
+ x->s_cnv = gensym("cnv");
diff --git a/src/paramRoute.h b/src/paramRoute.h
index b5d862f..c336367 100644
--- a/src/paramRoute.h
+++ b/src/paramRoute.h
@@ -12,32 +12,47 @@ typedef struct _paramRoute
t_symbol* s_empty;
t_canvas* canvas;
t_symbol* root;
-
+ t_symbol* previousSymbol;
+ t_symbol* target;
} t_paramRoute;
static void paramRoute_anything(t_paramRoute *x, t_symbol *s, int ac, t_atom *av) {
+ t_param* p = get_param_list(x->root);
- // t_symbol* path;
- t_symbol* target;
-
if (ac) {
- 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);
- //path = gensym(param_buf_temp_b);
- strcat(param_buf_temp_a, param_buf_temp_b);
- target = gensym(param_buf_temp_a);
-
- if (target->s_thing) {
- pd_forwardmess(target->s_thing, ac, av);
- } else {
- outlet_anything(x->x_outlet,s,ac,av);
- }
+ if ( p != NULL && s->s_name[0] == '/' && strlen(s->s_name) > 1) {
+
+
+
+
+ if (x->previousSymbol != s) {
+ param_buf_temp_a[0] = '\0';
+ #ifdef LOCAL
+ strcpy(param_buf_temp_a, x->root->s_name);
+ strcat(param_buf_temp_a, x->path->s_name);
+ strcat(param_buf_temp_b, s->s_name+1);
+ //strcat(param_buf_temp_a, param_buf_temp_b);
+ x->target = gensym(param_buf_temp_a);
+ #else
+ strcpy(param_buf_temp_a, x->path->s_name);
+ strcat(param_buf_temp_a, s->s_name+1);
+ x->target = gensym(param_buf_temp_a);
+ #endif
+ x->previousSymbol = s;
+ }
+
+ while (p && p->path != x->target) p=p->next;
+
+ if (p) {
+ pd_forwardmess(p->x, ac, av);
+ } else {
+ outlet_anything(x->x_outlet,s,ac,av);
+ }
+
+
} else {
outlet_anything(x->x_outlet,s,ac,av);
}
@@ -59,6 +74,8 @@ static void *paramRoute_new(t_symbol *s, int ac, t_atom *av) {
x->s_load = gensym("load");
x->s_empty = gensym("");
+ x->target = NULL;
+ x->previousSymbol = NULL;
// GET THE CURRENT CANVAS
t_canvas *canvas=tof_get_canvas();