From 93f64df7a4eee1151d2b70d37ab17f04e58cbc46 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 13 Dec 2010 01:37:22 +0000 Subject: refactored x_misc.c into cputime.c loadband.c namecanvas.c realtime.c random.c svn path=/trunk/; revision=14600 --- externals/vanilla/namecanvas.c | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 externals/vanilla/namecanvas.c (limited to 'externals/vanilla/namecanvas.c') diff --git a/externals/vanilla/namecanvas.c b/externals/vanilla/namecanvas.c new file mode 100644 index 00000000..a6642dae --- /dev/null +++ b/externals/vanilla/namecanvas.c @@ -0,0 +1,52 @@ +/* Copyright (c) 1997-1999 Miller Puckette. +* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* misc. */ + +#include "m_pd.h" +#include "s_stuff.h" +#include +#include +#include +#ifdef UNISTD +#include +#include +#include +#include +#include +#endif +#ifdef MSW +#include +#include +#endif + +static t_class *namecanvas_class; + +typedef struct _namecanvas +{ + t_object x_obj; + t_symbol *x_sym; + t_pd *x_owner; +} t_namecanvas; + +static void *namecanvas_new(t_symbol *s) +{ + t_namecanvas *x = (t_namecanvas *)pd_new(namecanvas_class); + x->x_owner = (t_pd *)canvas_getcurrent(); + x->x_sym = s; + if (*s->s_name) pd_bind(x->x_owner, s); + return (x); +} + +static void namecanvas_free(t_namecanvas *x) +{ + if (*x->x_sym->s_name) pd_unbind(x->x_owner, x->x_sym); +} + +static void namecanvas_setup(void) +{ + namecanvas_class = class_new(gensym("namecanvas"), + (t_newmethod)namecanvas_new, (t_method)namecanvas_free, + sizeof(t_namecanvas), CLASS_NOINLET, A_DEFSYM, 0); +} -- cgit v1.2.1