[flext] Strange inherited behavior

Spencer Russell spencer.f.russell at gmail.com
Fri Feb 11 05:51:36 CET 2011


I'm not sure if the problem I'm having stems from my lack of C++
knowledge(I'm more of an embedded C developer), or something that
Flext is doing specifically, so I thought I'd start here.

I'm writing a C++ library to interface with the Snyderphonics Manta
(www.snyderphonics.com), and writing a Flext object on top of that
library.

So my library provides a Manta class that has methods like SetPadLED,
SetPadLEDRow, SetPadLEDColumn, etc. It also has pure virtual functions
like PadEvent, which are called by the library when events happen, so
the idea is that to use the library you subclass the Manta object and
implement the event handling functions.

So my flext object inherits both form Manta and from flext_base, and
so far it's working pretty well.

The issue I'm having is that there's a private static
method(byteReverse()) of the Manta class that's called from a public
method(SetPadLEDRow), and for some reason when I call
Manta::SetPadLEDRow() from a method of my "manta" class (the flext
object), SetPadLEDRow is being called, but byteReverse is always
returning 0, for some reason. It's bizarre. I've tried making
byteReverse non-static and also protected instead of private, and it
doesn't seem to work.

The code is at http://gitorious.org/libmanta/libmanta/commits/master,
but I've reproduced the general structure below (minus all the flext
callback stuff, and a bunch more methods):

class Manta
{
   public:
      void SetPadLEDRow(LEDState state, int id, uint8_t mask);
   private:
      static uint8_t byteReverse(uint8_t inByte);
      uint8_t LEDMask[6];
}

class manta : public Manta, public flext_base
{
   protected:
      void SetPadLEDRow(t_symbol *state, int id, int mask);
}

// This function is set up to be called from incoming "row" messages
void manta::SetPadLEDRow(t_symbol *state, int id, int mask)
{
   LEDState parsedState = stateFromSymbol(state);
   Manta::SetPadLEDRow(parsedState, id, mask);
}

void Manta::SetPadLEDRow(LEDState state, int id, uint8_t mask)
{
   LEDMask[id] = byteReverse(mask);
   // this function is definitely being called from manta::SetPadLEDRow,
   // but byteReverse returns zero
}

Thanks for any help!

-spencer


More information about the flext mailing list