[C++-sig] Re: is_polymorphic and unions (was: Pyste and STL types)

spex66 at gmx.net spex66 at gmx.net
Tue Jul 22 17:54:15 CEST 2003


Hi Nicodemus
Hi Dave

I've read all your threads belonging to pyste / boost / union 

actually I've a project with a lot of such unions as you described. 

The project is from www.sedris.org for a standardised api for geometric &
georeferenced data... and I want to port them as quick as possible to python :)

so I'm using pyste--AllFromHeader('xxx.h') approach

36 hours from starting yesterday... I'm stuck with a sort of problems

(1) error C1204:Compiler limit:internal structure overflow (as described in
boost/faq)
(2) error C2664: problem with call_policy (?)
(3) error C2504: in ..../type_traits/is_polymorphic.hpp (79) ---> problem of
a union

solution to (1) is obviously splitting... sigh -> any chance to got this as
a feature from pyste, Nicodemus?

solution to (2) is pending... detailled description is following (also for
(3)):

:::::::::::::::::::::::::::::::::::
PYSTE::>> sedris.cpp 
    def("SRM_ChangeCoordinateSRF", &SRM_ChangeCoordinateSRF);

:::::::::::::::::::::::::::::::::::
ERROR::>>
boost/python/make_function.hpp(77) : error C2664: 
'struct boost::mpl::list4<short,
						  struct SRM_SRFParamsPair *,
						  struct SRM_Coordinate const *,
						  struct SRM_Coordinate *
						  > __cdecl boost::python::detail::get_signature(
short(__cdecl *)(struct SRM_SRFParamsPair *       ,const SRM_Coordinate
*,SRM_Coordinate *))' : 

can not convert parameter 1 from'
short (__cdecl *)(struct SRM_SRFParamsPair *const ,const SRM_Coordinate
*,SRM_Coordinate *)' 
	in 
short (__cdecl *)(struct SRM_SRFParamsPair *      ,const SRM_Coordinate
*,SRM_Coordinate *)' 

This conversion requires a reinterpret_cast, a C-style cast or
function-style cast

:::::::::::::::::::::::::::::::::::
SOURCE::>> for (2):

**snippet from file:: srm.h & srm_types.h**
EXPORT_DLL extern SRM_Status_Code
SRM_ChangeCoordinateSRF
(
    const SRM_SRF_Parameters_Pair  coord_op_params_ptr,
    const SRM_Coordinate          *source_coord_ptr,
          SRM_Coordinate          *dest_coord_ptr
);

typedef struct SRM_SRFParamsPair *SRM_SRF_Parameters_Pair;

typedef struct
{
    SRM_Dimensionality dimensionality;
    union
    {
        SRM_Coordinate_2D two_d;
        SRM_Coordinate_3D three_d;
    } coordinate;
} SRM_Coordinate;

**end of snippet from file:: srm.h & srm_types.h**


:::::::::::::::::::::::::::::::::::
PYSTE::>>sedris.cpp 
    class_< SRM_SRF_Parameters >("SRM_SRF_Parameters", init<  >())
        .def(init< const SRM_SRF_Parameters & >())
        .def_readwrite("dimensionality",
&SRM_SRF_Parameters::dimensionality)
        .def_readwrite("parameters", &SRM_SRF_Parameters::parameters)
    ;
:::::::::::::::::::::::::::::::::::
ERROR::>>
error C2504: in ..../type_traits/is_polymorphic.hpp (79) ---> problem of a
union

:::::::::::::::::::::::::::::::::::
SOURCE::>>for (3):
**snippet from file:: srm_types.h**

typedef struct
{
    SRM_Dimensionality dimensionality;
    union
    {
        SRM_SRF_Parameters_2D two_d;
        SRM_SRF_Parameters_3D three_d;
    } parameters;
} SRM_SRF_Parameters;

**end of snippet from file:: srm_types.h**


TRY&ERROR::>>
I've tried to adopt Dave's tip from 
http://mail.python.org/pipermail/c++-sig/2003-March/003607.html

> If so, then we have a bug in is_polymorphic.  If not, we should
> change all uses of is_polymorphic<T> in 
> 
>        boost/python/class.hpp
>        boost/python/object/class_converters.hpp
>        boost/python/object/inheritance.hpp
> 
> to:
>          mpl::and_<is_class<T>, is_polymorphic<T> >

putting #include for mpl::_and 
but boost wan't compile (if you need the error-trace, I will post it on
demand)

so I'm stuck with UNION, and have no C/C++ wrapper-idea cause of a massive
lack of C-knowledge... sorry hot-blood pythonista ;)


any hints to direct me to a path to the light is very appreciated!

thanks for your patience
Peter
(=PA=)





More information about the Cplusplus-sig mailing list