From: Alex P. <ale...@gm...> - 2011-09-27 11:03:09
|
This works 100%: enum node_type {NODE_BS=0,NODE_MS=1}; Just tried with latest stable swig. On Monday 26 September 2011 17:10:40 Bailey Miller wrote: > Thanks, > > Tried that, but no-go. The python wrapper generated by SWIG defines the > enums like: > monkey = _interface.monkey. > > So when i import, interface.monkey is the correct way to get a reference. > > On Mon, Sep 26, 2011 at 5:00 PM, Anil Gurnani <ani...@gm...>wrote: > > Based on the scenario you describe - I think the code in Python should > > be: **** > > > > ** ** > > > > >> handle = interface.noise("test", 2, > > >> interface.animal.monkey)**** > > > > ** ** > > > > ** ** > > > > ** ** > > > > *From:* Bailey Miller [mailto:bai...@gm...] > > *Sent:* Monday, September 26, 2011 7:38 PM > > *To:* swi...@li... > > *Subject:* [Swig-user] enums as function arguments**** > > > > ** ** > > > > Hello, thanks in advance for any help.**** > > > > ** ** > > > > 1)**** > > > > I have a c++ header file which contains an enumeration:**** > > > > *enum animal { monkey, chimp, ... };***** > > > > ** ** > > > > The header file also contains a function definition:**** > > > > *int noise (const char* name, int number_of_noses, animal a);***** > > > > ** ** > > > > SWIG generates an interface, and correctly makes the enumerated values > > available, but when I try to use the function in python:**** > > > > >> handle = interface.noise("test", 2, interface.monkey)**** > > > > ** ** > > > > Python says that I am using the wrong type or number of arguments and > > kindly lists the available prototypes. It does not seem that SWIG is > > getting the typemapping correct. Any tips?**** > > > > ** ** |