1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
/******************************************************
*
* closebang - implementation file
*
* copyleft (c) IOhannes m zmölnig
*
* 1901:forum::für::umläute:2016
*
* institute of electronic music and acoustics (iem)
*
******************************************************
*
* license: GNU General Public License v.2 (or later)
*
******************************************************/
/*
* this object send out a bang when an abstraction was loaded
* (but before the parent abstraction continues to load)
* usage:
* + it can be used to create abstractions with dynamic numbers of iolets
* nice, eh?
*/
#include "iemguts.h"
/* need g_canvas.h for loadbang-actions */
#include "g_canvas.h"
#ifndef LB_CLOSE
# warning compiling against a version of Pd without closebang support
# define LB_CLOSE 2
#endif
/* ------------------------- closebang ---------------------------- */
static t_class *closebang_class;
typedef struct _closebang
{
t_object x_obj;
} t_closebang;
static void closebang_loadbang(t_closebang *x, t_float type) {
if(LB_CLOSE == (int)type)
outlet_bang(x->x_obj.ob_outlet);
}
static void *closebang_new(void)
{
t_closebang *x = (t_closebang *)pd_new(closebang_class);
outlet_new(&x->x_obj, &s_bang);
return (x);
}
void closebang_setup(void)
{
iemguts_boilerplate("[closebang]", 0);
#if (PD_MINOR_VERSION < 47)
verbose(0, "[closebang] has been compiled against an incompatible version of Pd, proceeding anyway...");
#endif
closebang_class = class_new(gensym("closebang"), (t_newmethod)closebang_new, 0,
sizeof(t_closebang), CLASS_NOINLET, 0);
if(iemguts_check_atleast_pdversion(0,47,0))
class_addmethod(closebang_class, (t_method)closebang_loadbang, gensym("loadbang"), A_DEFFLOAT, 0);
else
error("[closebang] requires Pd>=0.47");
}
|