[C++-sig] Exposing Enums with same values
Anand, Kumar
kanand at qualcomm.com
Wed Jul 26 03:08:22 CEST 2006
Hi,
I am trying to expose an Enum (defined in C++) to Python using Boost
Python.
//type.cpp file
// Please note that the 2 of the enums have the same value.
typedef enum {
HOST_TYPE_AT = 1,
HOST_TYPE_AP = 0,
HOST_TYPE_COMMON = 0
HOST_TYPE_INVALID = 2
} HWM_HostType;
//boost_type.cpp
#include <boost/python.hpp>
#include <boost/python/class.hpp>
#include <boost/python/scope.hpp>
#include "type.cpp"
namespace bp = boost::python;
BOOST_PYTHON_MODULE (Boost_Test)
{
bp::enum_< HWM_HostType >(" HWM_HostType ")
.value("HOST_TYPE_AT ", HOST_TYPE_AT)
.value("HOST_TYPE_AP ", HOST_TYPE_AP)
.value("HOST_TYPE_COMMON ", HOST_TYPE_COMMON)
.value("HOST_TYPE_INVALID ", HOST_TYPE_INVALID)
.export_values()
;
}
//Build goes fine. SO FAR SO GOOD!! But when I use it in Python I get an
error.
//my python script
import Boost_Test
print Boost_Test.HOST_TYPE_AT
print Boost_Test.HOST_TYPE_AP
print Boost_Test.HOST_TYPE_COMMON
AttributeError: 'module' object has no attribute HOST_TYPE_COMMON'
Any suggestions? When I try to assign different values to the enums,
everything works fine.
Thanks
Kumar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20060725/b128da57/attachment.htm>
More information about the Cplusplus-sig
mailing list