Type Definition libpd_sys::t_libpd_messagehook
source · [−]pub type t_libpd_messagehook = Option<unsafe extern "C" fn(recv: *const c_char, msg: *const c_char, argc: c_int, argv: *mut t_atom)>;Expand description
typed message hook signature, recv is the source receiver name and msg is the typed message name: a message like [; foo bar 1 2 a b( will trigger a function call like libpd_messagehook(“foo”, “bar”, 4, argv) argc is the list length and vector argv contains the list elements which can be accessed using the atom accessor functions, ex: int i; for (i = 0; i < argc; i++) { t_atom *a = &argv[n]; if (libpd_is_float(a)) { float x = libpd_get_float(a); // do something with float x } else if (libpd_is_symbol(a)) { char *s = libpd_get_symbol(a); // do something with c string s } } note: check for both float and symbol types as atom may also be a pointer