<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi,<br>
I haven't tried your code, but there are currently 2 small issues with
clrtype.py I know of:<br>
<br>
1. You cannot use iterable for @returns and @accepts - see <a
href="http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=25448">http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=25448</a>
I think your issue is similar.<br>
<br>
2. You cannot use Python classes with clrtype.ClrClass metaclass in
@accepts and @returns.<br>
<br>
Both issues can be fixen in validate_clr_types function in clrtype.py.
Here is my version:<br>
<br>
def validate_clr_types(signature_types, var_signature = False):<br>
if not isinstance(signature_types, tuple):<br>
signature_types = (signature_types,)<br>
for t in signature_types:<br>
clr_type = clr.GetClrType(t)<br>
if t == Void:<br>
raise TypeError("Void cannot be used in signature")<br>
if clr.GetPythonType(clr_type) != t and \<br>
clr.GetPythonType(clr_type) != clr.GetPythonType(t):<br>
raise Exception, "Invalid CLR type %s" % str(t)<br>
if not var_signature:<br>
if clr_type.IsByRef:<br>
raise TypeError("Byref can only be used as arguments
and locals")<br>
# ArgIterator is not present in Silverlight<br>
if hasattr(System, "ArgIterator") and t ==
System.ArgIterator:<br>
raise TypeError("Stack-referencing types can only be
used as arguments and locals")<br>
<br>
--<br>
-- Lukáš<br>
<br>
Simon Segal wrote:
<blockquote
cite="mid:b16c60b10912171937n29f486d9v1925c5733e98c789@mail.gmail.com"
type="cite">I am curious as to how to define a
System.Collections.Generic.ICollection as per the below with
@clrtype.accepts and @clrtype.returns. Same question goes for
_clrfields where I want an ICollection<T> (c#) as a field.<br>
<br>
@property<br>
@clrtype.accepts()<br>
@clrtype.returns(ICollection[Order])<br>
def Orders(self): return self._orders<br>
<br>
@Orders.setter<br>
@clrtype.accepts(ICollection[Order])<br>
@clrtype.returns()<br>
def Orders(self, value): self._orders = value<br>
<br>
Thanks,<br>
<br>
Simon<br>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a>
<a class="moz-txt-link-freetext" href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a>
</pre>
</blockquote>
<br>
</body>
</html>