Two things spring instantly to mind (thanks for the reminder)
1) A patch has been submitted that tries very cleverly to allow out params to be omitted. This sounds like it's worth pursuing. 2) iPy's Reference type is something that I looked into implementing which would (or could) allow the wrapper to function more like (or just the same as) the C# being wrapped, writing the value directly on the given out param.

Oh, boy; I'm starting to get excited by the possibilities.
Thanks all,
Barton

On 01/23/2013 06:23 AM, b...@fie.us wrote:
Out of curiosity Barton, could you pass "None" rather than constructing 
instances?  Or does it truly need the argument to have a type in order to disambiguate 
overloaded methods?

Also, it is my understanding that in iPy, out parameters are often omitted from 
the method's arguments.  But in Python.Net they remain in the header.  I assume 
this is because removing the out parameters potentially creates a lot of 
ambiguity between overloads?

I'm wondering if it might be appropriate for PythonNet to define a type to make 
it possible to remove ambiguity.

i.e.:
c#:
public bool DoJob(int data1, int data2, out string result) { …}

python:
doer = Doer()
doResult = doer.DoJob(1,2,clr.OutParam(string))
if (doResult[0]):
    print(doResult[1])
else:
    print("error")

The key being: python net will never ever never let an OutParam object through 
to the clr.  Therefore, the following should throw an exception.

clr.OutParam(clr.OutParam)

Therefore, you would never run into reflective ambiguity.

On Jan 23, 2013, at 5:52 AM, Barton <bar...@bcdesignswell.com> wrote:

The Python.Runtime is a bit tricky when it comes to out parameters:
In C# DateTime.TryParse(String, out DateTime) becomes

d = DateTime(0)    # just a dummy to call the method on
d2 = DateTime(0) # another dummy to satisfy the out parameter (could be the 
same instance, d)
# d3 is were the result is passed out
result, d3 = d.TryParse("2013/01/22", d2)
d3.ToString()
u'1/22/2013 12:00:00 AM'
# this is the same behavior as iPy


I can't test this - I'm on Linux, but:
Here you've given the type (class)
from System.Windows.Media.Imaging import BitmapSource
bitmapsrc = BitmapSource
print bitmapsrc
cam = xiCam()
cam.OpenDevice(0)
cam.SetParam(PRM.BUFFER_POLICY, BUFF_POLICY.SAFE)
cam.SetParam(PRM.IMAGE_DATA_FORMAT,  IMG_FORMAT.MONO8)
cam.StartAcquisition()
timeout = 1000
bitmapsrc = cam.GetImage(bitmapsrc, timeout)
cam.StopAcquisition()
##

Console output:
<class 'System.Windows.Media.Imaging.BitmapSource'>

What you need is an instance, perhaps:
bitmapsrc = BitmapSource() # or something to that effect.

On 01/22/2013 11:58 AM, Daniel Krause wrote:
from System.Windows.Media.Imaging import BitmapSource
bitmapsrc = BitmapSource
print bitmapsrc
cam = xiCam()
cam.OpenDevice(0)
cam.SetParam(PRM.BUFFER_POLICY, BUFF_POLICY.SAFE)
cam.SetParam(PRM.IMAGE_DATA_FORMAT,  IMG_FORMAT.MONO8)
cam.StartAcquisition()
timeout = 1000
bitmapsrc = cam.GetImage(bitmapsrc, timeout)
cam.StopAcquisition()
##

Console output:
<class 'System.Windows.Media.Imaging.BitmapSource'>
_________________________________________________
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet


_________________________________________________
Python.NET mailing list - PythonDotNet@python.org
http://mail.python.org/mailman/listinfo/pythondotnet

Reply via email to