[IronPython] Exposing C++/CLI template classes to ironpython

"Bernhard Mäder" NoNuschk at gmx.net
Sun Dec 31 09:15:16 PST 2006


Hello all

I'm starting to work with ironpython and have successfully exported some .NET classes into an extension library.

Now I'm trying to get some C++ template classes to work with ironpython. I'm doing something like this:

// This is our C++ class.
template<typename T> struct cpp_klass
{
   T foo() { return T(); }
}

// This wraps the class for a specific T
public ref class klass_uint8
{
    typedef cpp_klass<unsigned char> klass_t;
    klass_t * _klass;

    klass_uint8() : _klass(new klass_t()) {};
    ~klass_uint8() {delete _klass;}

    unsigned char foo()
    {
        return _klass.foo();
    }
};

This works but has do be done for each version of T. I'm about to write a big macro that does it for all cpp_class<T> versions, but don't think this will be a nice solution... Is there a better way to do it?

Or would it be possible to load CPython extension DLLs with ironpython? If yes, I could use boost.python to get the exports done.

Thanks for any help!

cheers
Bernhard
-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer


More information about the users mailing list