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

Merge branch 'port-vanilla-send-methods'

parents 2485ed36 52f936b4
No related branches found
No related tags found
1 merge request!420"send" methods for int, float, and value from Vanilla
Pipeline #2178 passed
...@@ -30,19 +30,29 @@ static void *pdint_new(t_floatarg f) ...@@ -30,19 +30,29 @@ static void *pdint_new(t_floatarg f)
static void pdint_bang(t_pdint *x) static void pdint_bang(t_pdint *x)
{ {
outlet_float(x->x_obj.ob_outlet, (t_float)(int)(x->x_f)); outlet_float(x->x_obj.ob_outlet, (t_float)(int64_t)(x->x_f));
} }
static void pdint_float(t_pdint *x, t_float f) static void pdint_float(t_pdint *x, t_float f)
{ {
outlet_float(x->x_obj.ob_outlet, (t_float)(int)(x->x_f = f)); outlet_float(x->x_obj.ob_outlet, (t_float)(int64_t)(x->x_f = f));
} }
static void pdint_send(t_pdint *x, t_symbol *s)
{
if (s->s_thing)
pd_float(s->s_thing, (t_float)(int64_t)x->x_f);
else pd_error(x, "%s: no such object", s->s_name);
}
void pdint_setup(void) void pdint_setup(void)
{ {
pdint_class = class_new(gensym("int"), (t_newmethod)pdint_new, 0, pdint_class = class_new(gensym("int"), (t_newmethod)pdint_new, 0,
sizeof(t_pdint), 0, A_DEFFLOAT, 0); sizeof(t_pdint), 0, A_DEFFLOAT, 0);
class_addcreator((t_newmethod)pdint_new, gensym("i"), A_DEFFLOAT, 0); class_addcreator((t_newmethod)pdint_new, gensym("i"), A_DEFFLOAT, 0);
class_addmethod(pdint_class, (t_method)pdint_send, gensym("send"),
A_SYMBOL, 0);
class_addbang(pdint_class, pdint_bang); class_addbang(pdint_class, pdint_bang);
class_addfloat(pdint_class, pdint_float); class_addfloat(pdint_class, pdint_float);
} }
...@@ -85,11 +95,20 @@ static void pdfloat_float(t_pdfloat *x, t_float f) ...@@ -85,11 +95,20 @@ static void pdfloat_float(t_pdfloat *x, t_float f)
outlet_float(x->x_obj.ob_outlet, x->x_f = f); outlet_float(x->x_obj.ob_outlet, x->x_f = f);
} }
static void pdfloat_send(t_pdfloat *x, t_symbol *s)
{
if (s->s_thing)
pd_float(s->s_thing, x->x_f);
else pd_error(x, "%s: no such object", s->s_name);
}
void pdfloat_setup(void) void pdfloat_setup(void)
{ {
pdfloat_class = class_new(gensym("float"), (t_newmethod)pdfloat_new, 0, pdfloat_class = class_new(gensym("float"), (t_newmethod)pdfloat_new, 0,
sizeof(t_pdfloat), 0, A_FLOAT, 0); sizeof(t_pdfloat), 0, A_FLOAT, 0);
class_addcreator((t_newmethod)pdfloat_new2, gensym("f"), A_DEFFLOAT, 0); class_addcreator((t_newmethod)pdfloat_new2, gensym("f"), A_DEFFLOAT, 0);
class_addmethod(pdfloat_class, (t_method)pdfloat_send, gensym("send"),
A_SYMBOL, 0);
class_addbang(pdfloat_class, pdfloat_bang); class_addbang(pdfloat_class, pdfloat_bang);
class_addfloat(pdfloat_class, (t_method)pdfloat_float); class_addfloat(pdfloat_class, (t_method)pdfloat_float);
} }
...@@ -2020,6 +2039,21 @@ static void value_float(t_value *x, t_float f) ...@@ -2020,6 +2039,21 @@ static void value_float(t_value *x, t_float f)
*x->x_floatstar = f; *x->x_floatstar = f;
} }
/* set method */
static void value_symbol2(t_value *x, t_symbol *s)
{
value_release(x->x_sym);
x->x_sym = s;
x->x_floatstar = value_get(s);
}
static void value_send(t_value *x, t_symbol *s)
{
if (s->s_thing)
pd_float(s->s_thing, *x->x_floatstar);
else pd_error(x, "%s: no such object", s->s_name);
}
static void value_ff(t_value *x) static void value_ff(t_value *x)
{ {
value_release(x->x_sym); value_release(x->x_sym);
...@@ -2033,6 +2067,9 @@ static void value_setup(void) ...@@ -2033,6 +2067,9 @@ static void value_setup(void)
class_addcreator((t_newmethod)value_new, gensym("v"), A_DEFSYM, 0); class_addcreator((t_newmethod)value_new, gensym("v"), A_DEFSYM, 0);
class_addbang(value_class, value_bang); class_addbang(value_class, value_bang);
class_addfloat(value_class, value_float); class_addfloat(value_class, value_float);
class_addmethod(value_class, (t_method)value_symbol2, gensym("symbol2"),
A_DEFSYM, 0);
class_addmethod(value_class, (t_method)value_send, gensym("send"), A_SYMBOL, 0);
vcommon_class = class_new(gensym("value"), 0, 0, vcommon_class = class_new(gensym("value"), 0, 0,
sizeof(t_vcommon), CLASS_PD, 0); sizeof(t_vcommon), CLASS_PD, 0);
class_addfloat(vcommon_class, vcommon_float); class_addfloat(vcommon_class, vcommon_float);
......
#N canvas 126 96 749 571 12; #N canvas 732 89 749 571 12;
#X obj 465 281 r \$0-result; #X obj 465 281 r \$0-result;
#X obj 212 239 bng 31 250 50 0 empty empty Run_all 39 13 0 12 -262144 #X obj 212 239 bng 31 250 50 0 empty empty Run_all 39 13 0 12 -262144
-1 -1; -1 -1;
...@@ -52,6 +52,9 @@ is handy for some binbuf tests.; ...@@ -52,6 +52,9 @@ is handy for some binbuf tests.;
#X obj 127 172 print Done; #X obj 127 172 print Done;
#X obj 198 1701 rtest wrap~_compatibility_bug; #X obj 198 1701 rtest wrap~_compatibility_bug;
#X obj 198 1756 rtest select_bang; #X obj 198 1756 rtest select_bang;
#X obj 198 1811 rtest float_send_method;
#X obj 198 1866 rtest int_send_method;
#X obj 198 1921 rtest value_send_method;
#X connect 0 0 27 0; #X connect 0 0 27 0;
#X connect 1 0 4 0; #X connect 1 0 4 0;
#X connect 2 0 42 0; #X connect 2 0 42 0;
...@@ -89,3 +92,6 @@ is handy for some binbuf tests.; ...@@ -89,3 +92,6 @@ is handy for some binbuf tests.;
#X connect 42 3 3 0; #X connect 42 3 3 0;
#X connect 43 0 44 0; #X connect 43 0 44 0;
#X connect 45 0 46 0; #X connect 45 0 46 0;
#X connect 46 0 47 0;
#X connect 47 0 48 0;
#X connect 48 0 49 0;
#N canvas 237 121 450 300 12;
#X obj 57 22 inlet;
#X obj 57 51 ../utils/send-method-wrapper float;
#X obj 57 80 outlet;
#X connect 0 0 1 0;
#X connect 1 0 2 0;
#N canvas 237 121 450 300 12;
#X obj 57 22 inlet;
#X obj 57 80 outlet;
#X obj 57 51 ../utils/send-method-wrapper int;
#X connect 0 0 2 0;
#X connect 2 0 1 0;
#N canvas 237 121 450 300 12;
#X obj 57 22 inlet;
#X obj 57 100 outlet;
#X obj 57 61 ../utils/send-method-wrapper value \$0-dummy;
#X connect 0 0 2 0;
#X connect 2 0 1 0;
#N canvas 24 73 846 509 12;
#X obj 78 23 inlet;
#X obj 78 431 outlet;
#X obj 239 168 unpost;
#X obj 78 274 f;
#X obj 239 240 list;
#X obj 78 60 trigger bang bang bang bang;
#X obj 323 168 loadbang;
#X msg 323 197 1;
#X obj 239 330 list append [\$1] should accept "send" method for non-local
sending of its stored value;
#X obj 78 383 list append "send" method of \$1 should send its stored
value wirelessly to the given receiver symbol;
#X obj 96 239 r \$0-the-value;
#X msg 239 109 send \$0-the-value;
#X text 272 139 1) Check for method error;
#X text 83 209 2) check value arrived;
#X text 366 197 (loadbang left inlet since [value] doesn't have a 2nd
inlet for storage);
#X obj 278 239 \$1 \$2;
#X obj 239 269 list length;
#X obj 239 298 == 0;
#X text 207 20 A convenience wrapper for float/int/value_send_method
tests;
#X connect 0 0 5 0;
#X connect 2 0 4 0;
#X connect 2 1 15 0;
#X connect 3 0 9 0;
#X connect 4 0 16 0;
#X connect 5 0 3 0;
#X connect 5 1 4 0;
#X connect 5 2 11 0;
#X connect 5 3 4 1;
#X connect 6 0 7 0;
#X connect 7 0 15 0;
#X connect 8 0 1 0;
#X connect 9 0 1 0;
#X connect 10 0 3 1;
#X connect 11 0 2 0;
#X connect 16 0 17 0;
#X connect 17 0 8 0;
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