owenvallis/libmonome — pull request #2 by wrl (2013-01-10 00:41:02+00:00)
Title: move monome_led_functions_t->color into its own led_color function struct

this commit removes the "color" function from monome_led_functions_t and moves it into the new monome_led_color_functions_t.

this is something i've been meaning to do for a long time, actually, and makes chronome's color-setting support more in-line with the way i had structured libmonome from the beginning. namely, this isolates color functionality into its own struct so that devices can expose color functionality by setting the "led_color" pointer in monome_t.

my objective with that system was that, if a device sets one of those capability/callback structs, all of the function pointers would be set. it's "all-or-nothing": either you support all of the monome_t->led functions or you support none. the previous way that color was implemented created a pretty serious edge case where lots of devices (all non-chronomes) would have monome_t->led set but monome_t->led->color unset, and the REQUIRE() macro in libmonome.c would do nothing because it only checks the monome_t->led pointer.

the bug here is that sending a "color" message to a non-chronome would probably result in a segfault. so that's fixed now.