[IronPython] Interaction with other CLR code

Curt Hagenlocher curt at hagenlocher.org
Fri Aug 27 17:54:13 CEST 2004

I previously wrote:

> 1. How to handle properties?  If we were to map properties in a
> CLR interface onto Python properties, we wouldn't be able to
> handle indexed properties.

Of course, I've been spending too much time in IL lately, and
forgot that C# doesn't really handle indexed properties.  The
only property that can be indexed is the "Item" property, which
in C# has the flavor of overriding the [] operator.  Perhaps
this should be specially mapped onto __getitem__ and __setitem__.

VB apparently provides full support for indexed properties, but
I don't want to learn the syntax just to test this.

I've attached a ZIP archive that contains four files:
a new file DelegateMaker.cs, which contains most of the new code
a modified sys.cs, which contains the new function WrapObject
a test program consisting of two files: itest.cs and itest.py

Put DelegateMaker.cs into the Objects directory and add it either
to your VS.NET project or your makefile.  Replace sys.cs.  Build
the test dll with "csc /target:library itest.cs", then run the .py
file.  The .py file defines a class "foo", an instance of which is
wrapped in the "TestInterface" interface defined by itest.cs.  This
wrapper is then passed to the "DoTest" function also defined in 

One limitation of the current code is that the wrapper object
itself doesn't get along very nicely with IronPython.  You
really can't do anything with it other than pass it to other
CLR code.

I'd appreciate hearing of your experiences from anyone who tries
this out.

Curt Hagenlocher
curt at hagenlocher.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: InterfaceWrapper.zip
Type: application/x-zip-compressed
Size: 5946 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20040827/e83a9a08/attachment.bin>

More information about the Ironpython-users mailing list