[C++-sig] Re: is_polymorphic and unions

spex66 at gmx.net spex66 at gmx.net
Wed Jul 23 00:59:56 CEST 2003


Hi Dave,

thanks for your fast helping hand :)
(don't know how to respond in thread from a mail-client?!?)

>> solution to (1) is obviously splitting... sigh -> any chance to got this
as
>> a feature from pyste, Nicodemus?
>
>The current CVS includes support for "--multiple":
>http://tinyurl.com/hp3j
as far as I could see, its a splitting at header-file level... that's not
enough in my case. Maybe a hardcore classlevel would be a nice option, too?


>> This conversion requires a reinterpret_cast, a C-style cast or
>> function-style cast
>
>This is an msvc bug which preserves top-level constness of arguments
>in function (pointer) types.  If you can redeclare the offending
>function as:
>
>  short SRM_ChangeCoordinateSRF(SRM_SRF_Parameters_Pair, const
SRM_Coordinate *,SRM_Coordinate *);

I'm a little bit challenged with C++ actually :/
Do you mean 'redeclare' in its original position in the header-file (srm.h
in this case)?
If so... in exactly the way you give the example, or the original

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
);

style (deleting first occur of const)?

Or have I to redeclare it in the mSedris.cpp (build from pyste)... dumb as I
am (belonging to C++ of course), I've tried to include your line in front of


BOOST_PYTHON_MODULE(mSedris)

but my VC6 told me that's not the right solution
sorry for that kind of question-level... I'm happy to make my first steps
with boost.python.object... the examples looks terrific!!!

>
>you can still make the first parameter const in the function
>*definition* without upsetting the compiler.  If you can't change the
>declaration of 'whatever' you'll have to resort to forcibly casting
>the offending function pointer.
>
>I suppose Pyste could be patched to do this for you...

This would be great :)



>> :::::::::::::::::::::::::::::::::::
>> ERROR::>>
>> error C2504: in ..../type_traits/is_polymorphic.hpp (79) ---> problem of
a
>> union
>
>What's the complete error message for that line?

here it comes (followed by matching pyste-result, and original
header-file-snippets) parts translated from german VC6 messages into matching english one:

..\..\..\boost/type_traits/is_polymorphic.hpp(26) : error C2569: 'type' :
enum/union cannot be used as a base class
C:\arwa\dev\sedris_sdk_3.1.2\include\srm_types.h(5165) : see reference to
class template instantiation 'type' being compiled
        ..\..\..\boost/type_traits/is_polymorphic.hpp(79) : see reference to
class template instantiation 'boost::detail::is_polymorphic_imp1<union
SRM_SRF_Parameters::type>' being compiled
        ..\..\..\boost/type_traits/is_polymorphic.hpp(84) : see reference to
class template instantiation  'boost::detail::is_polymorphic_imp<union
SRM_SRF_Parameters::type>' being compiled
        ..\..\..\boost/python/object/make_ptr_instance.hpp(37) : see
reference to class template instantiation 'boost::is_polymorphic<union
SRM_SRF_Parameters::type>' being compiled
        ..\..\..\boost/python/object/make_ptr_instance.hpp(30) : see
reference to class template instantiation 'struct _typeobject *__cdecl
boost::python::objects::make_ptr_instance<union SRM_SRF_Parameters::type,struct
boost::python::objects::pointer_holder<union SRM_SRF_Parameters::type *,union
SRM_SRF_Parameters::type> >::get_class_object_impl(volatile const
SRM_SRF_Parameters::type *)' being compiled

PYSTE-AGAIN::>>
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)
;


SOURCE-AGAIN::>>
typedef struct
{
    SRM_Dimensionality dimensionality;
    union
    {
        SRM_SRF_Parameters_2D two_d;
        SRM_SRF_Parameters_3D three_d;
    } parameters;
} SRM_SRF_Parameters;

I have not reproduce the 
>>          mpl::and_<is_class<T>, is_polymorphic<T> >
stuff. But from my memory, trying this last time... do you mean to replace
occurences only from is_polymorphic<T> or also is_polymorphic<Target> //
is_polymorphic<Source> // is_polymorphic<Base> in the same style? Thats what I
have tried last time (plus # include <boost/mpl/and.hpp>)



::::::::::::::::::::
And a new kind of compiler-error, maybe time to use boost.array?


::::::::::::::::::::::::::::::::::
PYSTE::>>

class_< SRM_Matrix_3x3 >("SRM_Matrix_3x3", init<  >())
	.def(init< const SRM_Matrix_3x3 & >())
	.def_readwrite("mat", &SRM_Matrix_3x3::mat)
;

::::::::::::::::::::::::::::::::::
ERROR::>>
..\..\..\boost/python/data_members.hpp(68) : 
error C2440: '=' : 'const double [3][3]' cannot convert in 'double [3][3]'
        Es gibt keinen Kontext, in dem diese Konvertierung moeglich ist
        ..\..\..\boost/python/data_members.hpp(55) : 
        	Bei der Kompilierung der Member-Funktion 
'struct _object *__cdecl boost::python::detail::member<
			double [3][3],
			struct SRM_Matrix_3x3,
			struct boost::python::default_call_policies
			>::set(double (SRM_Matrix_3x3::*)[3][3],
				   struct _object *,
				   struct _object *,
				   const struct boost::python::default_call_policies &)'
der Klassenvorlage

::::::::::::::::::::::::::::::::::
SOURCE::>>
typedef struct
{
    SRM_Long_Float mat[3][3];
} SRM_Matrix_3x3;


thanks again for your help and your time, but as it is in software-project
life... time is the REAL bottleneck, *sigh*

but building wonders and miracles in zero-time is the real thrill :)

Peter
(=PA=)






More information about the Cplusplus-sig mailing list