Skip to content
Snippets Groups Projects
Commit ca33e6db authored by Guillem Bartrina's avatar Guillem Bartrina
Browse files

now you can create local private abstractions. usage: [ab bash-<name>]

parent 0bda995a
No related branches found
No related tags found
4 merge requests!5752.15.0 release candidate,!574Draft: 2.15.0 release candidate,!560feature - private abstractions [ab],!483WIP: private patch abstractions [ab]. first approach
...@@ -1970,8 +1970,11 @@ static int ab_check_cycle(t_ab_definition *current, t_ab_definition *parent, int ...@@ -1970,8 +1970,11 @@ static int ab_check_cycle(t_ab_definition *current, t_ab_definition *parent, int
} }
else else
{ {
int len = strlen(current->ad_name->s_name); char *hash = strrchr(current->ad_name->s_name, '#');
sprintf(path+pathlen, "[ab %s]<-", current->ad_name->s_name); if(!hash) hash = current->ad_name->s_name;
else hash += 1;
int len = strlen(hash);
sprintf(path+pathlen, "[ab %s]<-", hash);
pathlen += (len+7); pathlen += (len+7);
int i, cycle = 0; int i, cycle = 0;
for(i = 0; !cycle && i < current->ad_numdep; i++) for(i = 0; !cycle && i < current->ad_numdep; i++)
...@@ -2235,6 +2238,31 @@ static void canvas_abpush(t_canvas *x, t_symbol *s, int argc, t_atom *argv) ...@@ -2235,6 +2238,31 @@ static void canvas_abpush(t_canvas *x, t_symbol *s, int argc, t_atom *argv)
pd_free(x); pd_free(x);
} }
static int ab_is_local(t_canvas *x, t_symbol *s)
{
int num;
char *name = s->s_name, *end;
if((end = strchr(name, '-')))
{
*end = '\0';
num = atoi(name);
*end = '-';
return (num == canvas_getdollarzero(x));
}
return (0);
}
static t_symbol *ab_extend_name(t_canvas *x, t_symbol *s)
{
char res[MAXPDSTRING], *beg = strchr(s->s_name, '-');
t_canvas *next = canvas_getrootfor(x);
if(next->gl_isab)
sprintf(res, "%s#$0-%s", next->gl_absource->ad_name->s_name, beg+1);
else
sprintf(res, "$0-%s", beg+1);
return gensym(res);
}
static int abframe = 0; static int abframe = 0;
static void canvas_abframe(t_canvas *x, t_float val) static void canvas_abframe(t_canvas *x, t_float val)
{ {
...@@ -2263,6 +2291,9 @@ static void *ab_new(t_symbol *s, int argc, t_atom *argv) ...@@ -2263,6 +2291,9 @@ static void *ab_new(t_symbol *s, int argc, t_atom *argv)
t_symbol *name = (argc ? argv[0].a_w.w_symbol : gensym("(ab)")); t_symbol *name = (argc ? argv[0].a_w.w_symbol : gensym("(ab)"));
t_ab_definition *source; t_ab_definition *source;
if(ab_is_local(c, name))
name = ab_extend_name(c, name);
if(!(source = canvas_find_ab(c, name))) if(!(source = canvas_find_ab(c, name)))
{ {
t_binbuf *b = binbuf_new(); t_binbuf *b = binbuf_new();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment