[IronPython] Typing problem with vendor library?

Martin Maly Martin.Maly at microsoft.com
Sat Oct 14 00:07:15 CEST 2006


Int16 is a type: System.Int16 and I am calling its constructor, passing "output" as the value:  System.Int16(output), just like in Python you can call:  int(3.5), this is very similar, except constructing .NET System.Int16 type.

Martin

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of jeff sacksteder
Sent: Friday, October 13, 2006 2:39 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Typing problem with vendor library?

I'm finally getting back to this project. I do not know the Int16() function that you call. Can you elaborate?
On 7/20/06, Martin Maly < Martin.Maly at microsoft.com<mailto:Martin.Maly at microsoft.com>> wrote:

The problem is that the method is called with int as the last parameter, but the two overloads in question take "ref Int16" and "ref UInt16". So the conversion is happening in the opposite direction and IronPython cannot safely choose between Int16 and UInt16 given that the input is Int32. They are both narrowing conversions.



You can either select the method from Overloads, or cast the int to whichever type you want to use:



board.AIn(channel, mode, Int16(output))



Hope this helps

Martin



________________________________

From: users-bounces at lists.ironpython.com<mailto:users-bounces at lists.ironpython.com> [mailto: users-bounces at lists.ironpython.com<mailto:users-bounces at lists.ironpython.com>] On Behalf Of jeff sacksteder
Sent: Wednesday, July 19, 2006 9:54 PM
To: users at lists.ironpython.com<mailto:users at lists.ironpython.com>
Subject: [IronPython] Typing problem with vendor library?



I have a data-acquisition device whose vendor provides a dotnet library for software integration. The dynamic nature of IP is giving me a bit of a problem. To record data from the unit, I make a method call like this:

errorlevel = board.AIn(channel,mode,output)

It seems that the library wants to put an UInt16 value into the 'output' variable. I would not expect this to be a problem, but this produces...

TypeError: no overloads of AIn could match (int, Range, int)
  AIn(int, Range, Reference[Int16])
  AIn(int, Range, Reference[UInt16])

Surely an unsigned Int16 should be able to go into an Int32?

_______________________________________________
users mailing list
users at lists.ironpython.com<mailto:users at lists.ironpython.com>
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20061013/9c4fd3f7/attachment.html>


More information about the Ironpython-users mailing list