__getitem__ and __setitem__ can be implemented by implementing an indexer in 
C#.  These will automatically be transformed.

To implement __getattribute__ / __setattr__ you can implement ICustomAttributes 
and intercept all attribute access.  You'll need to fall back to the type to 
get the default behavior, e.g. something like (see SystemState.cs for an 
approximate answer):

Return Ops.GetDynamicType(this).TryGetAttr(context, this, name, out value);

There's no way to implement just __getattr__, only __getattribute__.

Other special methods you can implement by name or by applying 
PythonName("__foo__") to the method. There are certain interfaces we'll 
recognize and transform for you automatically (IEnumerator -> next, ToString -> 
__str__, ICodeFormattable -> __repr__, IDescriptor -> __get__, and ICallable -> 
__call__).

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andrew
Sent: Tuesday, November 21, 2006 10:36 AM
To: users@lists.ironpython.com
Subject: Re: [IronPython] How to implement in C# ironpython extension?

Thank you for answer! I should to be more acurate.
How to implement in C# extension special methods:
__getitem__, __setitem__, __getattr__, __setattr__ and other special methods?

Thanks.


_______________________________________________
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to