Skip to content
Snippets Groups Projects
Commit b2da3565 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

ported [getsize] from Pd-Vanilla 0.46

parent 0bb5c3bd
No related branches found
No related tags found
No related merge requests found
...@@ -816,7 +816,7 @@ typedef struct _getsize ...@@ -816,7 +816,7 @@ typedef struct _getsize
static void *getsize_new(t_symbol *templatesym, t_symbol *fieldsym) static void *getsize_new(t_symbol *templatesym, t_symbol *fieldsym)
{ {
t_getsize *x = (t_getsize *)pd_new(getsize_class); t_getsize *x = (t_getsize *)pd_new(getsize_class);
x->x_templatesym = canvas_makebindsym(templatesym); x->x_templatesym = template_getbindsym(templatesym);
x->x_fieldsym = fieldsym; x->x_fieldsym = fieldsym;
outlet_new(&x->x_obj, &s_float); outlet_new(&x->x_obj, &s_float);
return (x); return (x);
...@@ -824,44 +824,49 @@ static void *getsize_new(t_symbol *templatesym, t_symbol *fieldsym) ...@@ -824,44 +824,49 @@ static void *getsize_new(t_symbol *templatesym, t_symbol *fieldsym)
static void getsize_set(t_getsize *x, t_symbol *templatesym, t_symbol *fieldsym) static void getsize_set(t_getsize *x, t_symbol *templatesym, t_symbol *fieldsym)
{ {
x->x_templatesym = canvas_makebindsym(templatesym); x->x_templatesym = template_getbindsym(templatesym);
x->x_fieldsym = fieldsym; x->x_fieldsym = fieldsym;
} }
static void getsize_pointer(t_getsize *x, t_gpointer *gp) static void getsize_pointer(t_getsize *x, t_gpointer *gp)
{ {
int onset, type; int nitems, onset, type;
t_symbol *templatesym = x->x_templatesym, *fieldsym = x->x_fieldsym, t_symbol *templatesym, *fieldsym = x->x_fieldsym, *elemtemplatesym;
*elemtemplatesym; t_template *template;
t_template *template = template_findbyname(templatesym);
t_word *w; t_word *w;
t_array *array; t_array *array;
int elemsize;
t_gstub *gs = gp->gp_stub; t_gstub *gs = gp->gp_stub;
if (!template) if (!gpointer_check(gp, 0))
{ {
pd_error(x, "getsize: couldn't find template %s", templatesym->s_name); pd_error(x, "get: stale or empty pointer");
return; return;
} }
if (!template_find_field(template, fieldsym, if (*x->x_templatesym->s_name)
&onset, &type, &elemtemplatesym))
{ {
pd_error(x, "getsize: couldn't find array field %s", fieldsym->s_name); if ((templatesym = x->x_templatesym) !=
return; gpointer_gettemplatesym(gp))
{
pd_error(x, "elem %s: got wrong template (%s)",
templatesym->s_name, gpointer_gettemplatesym(gp)->s_name);
return;
}
} }
if (type != DT_ARRAY) else templatesym = gpointer_gettemplatesym(gp);
if (!(template = template_findbyname(templatesym)))
{ {
pd_error(x, "getsize: field %s not of type array", fieldsym->s_name); pd_error(x, "elem: couldn't find template %s", templatesym->s_name);
return; return;
} }
if (!gpointer_check(gp, 0)) if (!template_find_field(template, fieldsym,
&onset, &type, &elemtemplatesym))
{ {
pd_error(x, "get: stale or empty pointer"); pd_error(x, "getsize: couldn't find array field %s", fieldsym->s_name);
return; return;
} }
if (gpointer_gettemplatesym(gp) != x->x_templatesym) if (type != DT_ARRAY)
{ {
pd_error(x, "getsize %s: got wrong template (%s)", pd_error(x, "getsize: field %s not of type array", fieldsym->s_name);
x->x_templatesym->s_name, gpointer_gettemplatesym(gp)->s_name);
return; return;
} }
if (gs->gs_which == GP_ARRAY) w = gp->gp_un.gp_w; if (gs->gs_which == GP_ARRAY) w = gp->gp_un.gp_w;
......
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