Skip to content

Commit ba54754

Browse files
committed
Add Remote Parameter int mode
Provides callbacks that expect integer values with an integer without needing a cast on the ruby/qml side. Resolves an issue with the automation view: zynaddsubfx/zyn-fusion-issues#399
1 parent 4adc3c5 commit ba54754

File tree

1 file changed

+16
-0
lines changed
  • src/mruby-widget-lib/src

1 file changed

+16
-0
lines changed

src/mruby-widget-lib/src/gem.c

+16
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,16 @@ remote_cb_127(const char *msg, remote_cb_data *cb)
746746
mrb_funcall(cb->mrb, cb->cb, "call", 1, mrb_float_value(cb->mrb,cb_val));
747747
}
748748

749+
static void
750+
remote_cb_pure_int(const char *msg, remote_cb_data *cb)
751+
{
752+
mrb_assert(!strcmp("i",rtosc_argument_string(msg)) || !strcmp("c",rtosc_argument_string(msg)));
753+
754+
int cb_val = rtosc_argument(msg, 0).i;
755+
756+
mrb_funcall(cb->mrb, cb->cb, "call", 1, mrb_fixnum_value(cb_val));
757+
}
758+
749759
static void
750760
remote_cb_int(const char *msg, remote_cb_data *cb)
751761
{
@@ -813,11 +823,17 @@ remote_cb(const char *msg, void *data)
813823
assert(valid_type(*args));
814824
remote_cb_data *cb = (remote_cb_data*) data;
815825
int nil = mrb_obj_equal(cb->mrb, mrb_nil_value(), cb->mode);
826+
mrb_sym norm_sym = mrb_intern_lit(cb->mrb, "normal_int");
827+
int norm_int = mrb_obj_equal(cb->mrb,
828+
mrb_symbol_value(norm_sym),
829+
cb->mode);
816830
const char *arg_str = rtosc_argument_string(msg);
817831
if(!strcmp("i", arg_str) && nil)
818832
remote_cb_127(msg, cb);
819833
else if(!strcmp("c", arg_str))
820834
remote_cb_127(msg, cb);
835+
else if(!strcmp("i", arg_str) && norm_int)
836+
remote_cb_pure_int(msg, cb);
821837
else if(!strcmp("i", arg_str))
822838
remote_cb_int(msg, cb);
823839
else if(!strcmp("f", arg_str)) {

0 commit comments

Comments
 (0)