[C++-sig] typedef'd unnamed enum / pyste

Nicodemus nicodemus at esss.com.br
Wed Nov 17 00:22:50 CET 2004


Hi Jonh,

Sorry about the delay: as usual, it's hard to find time to work on pyste 
or answering questions on the list. Sorry again. :(

The only way currently in Pyste to export unnamed enums is using 
AllFromHeader. Althought it is deprecated, it should work just fine for 
your case. The code it generates is different thought:

    scope().attr("cover_none") = (int)cover_none;
    scope().attr("cover_full") = (int)cover_full;
    scope().attr("cover_shift") = (int)cover_shift;
    scope().attr("cover_size") = (int)cover_size;
    scope().attr("cover_mask") = (int)cover_mask;

If you want to actually have an enum named "cover", you will have to 
export it just like you did.

Regards,
Bruno.

John Hunter wrote:

>>>>>>"Roman" == Roman Yakovenko <roman.yakovenko at gmail.com> writes:
>>>>>>
>
>    >> 
>    >> typedef unsigned char cover_type; //----cover_type
>
>    Roman> Pyste is right cover_type is typedef to unsigned char. You
>    Roman> try to expose it as enum ???  You made a mistake.
>
>Yes, I'm a moron.  Thanks!
>
>
>    typedef unsigned char cover_type;    //----cover_type
>    enum
>    {
>        cover_shift = 8,                 //----cover_shift
>        cover_size  = 1 << cover_shift,  //----cover_size 
>        cover_mask  = cover_size - 1,    //----cover_mask 
>        cover_none  = 0,                 //----cover_none 
>        cover_full  = cover_mask         //----cover_full 
>    };
>
>    Roman> Enum( "cover_mask", "agg_basics.h" ) should work
>
>It doesn't.  I was, however, able to do it manually with
>
>module_code("""    
>    enum_<int>("cover")
>        .value("cover_shift", agg::cover_shift)
>        .value("cover_size",  agg::cover_size)
>        .value("cover_mask",  agg::cover_mask)
>        .value("cover_none",  agg::cover_none)
>        .value("cover_full",  agg::cover_full)                        
>        ;
>        """)
>
>but as always, I'm looking for the best pyste/boost::python way to do
>it, so any other suggestions on the best way to export unnamed enums
>in pyste welcome!
>
>Thanks,
>JDH
>_______________________________________________
>C++-sig mailing list
>C++-sig at python.org
>http://mail.python.org/mailman/listinfo/c++-sig
>
>




More information about the Cplusplus-sig mailing list