aboutsummaryrefslogtreecommitdiff
path: root/src/classtest.c
blob: 76f1269da175aa6c9b614131e3590ecb87fe06c4 (plain)
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
74
75
76

/******************************************************
 *
 * classtest - implementation file
 *
 * copyleft (c) IOhannes m zmölnig
 *
 *   2007:forum::für::umläute:2007
 *
 *   institute of electronic music and acoustics (iem)
 *
 ******************************************************
 *
 * license: GNU General Public License v.2
 *
 ******************************************************/


/* 
 * this object provides a way to send messages to upstream canvases
 * by default it sends messages to the containing canvas, but you can give the
 * "depth" as argument;
 * e.g. [classtest 1] will send messages to the parent of the containing canvas
 */

#include "m_pd.h"
#include "g_canvas.h"

int glist_getindex(t_glist *x, t_gobj *y);

/* ------------------------- classtest ---------------------------- */

static t_class *classtest_class;

typedef struct _classtest
{
  t_object  x_obj;
  t_outlet *x_out;
} t_classtest;

static void classtest_symbol(t_classtest *x, t_symbol*s)
{
  t_float result=0.;
  if(!pd_objectmaker) {
    pd_error(x, "[classtest]: couldn't find pd_objectmaker!");
    return;
  }
  if(0!=zgetfn(&pd_objectmaker, s))
    result=1.;

  outlet_float(x->x_out, result);



}

static void classtest_free(t_classtest *x)
{
  outlet_free(x->x_out);
}

static void *classtest_new(t_floatarg f)
{
  t_classtest *x = (t_classtest *)pd_new(classtest_class);

  x->x_out = outlet_new(&x->x_obj, &s_float);
  return (x);
}

void classtest_setup(void)
{
  classtest_class = class_new(gensym("classtest"), (t_newmethod)classtest_new,
                               (t_method)classtest_free, sizeof(t_classtest), 0, 
                              0);
  class_addsymbol(classtest_class, (t_method)classtest_symbol);
}