[IronPython] Method Arguments

Dan Lash danlash at gmail.com
Wed Aug 11 22:58:23 CEST 2004


Is there a good way to get the constructor and/or method arguments in
IronPython? I've been trying to do some simple 3D (DirectX9) examples,
and some of the constructors/methods are throwing exceptions.

Here's some example code (DX9 SDK must be installed):
import sys
sys.LoadAssemblyByName("Microsoft.DirectX.Direct3D")
from Microsoft.DirectX.Direct3D.CustomVertex import *
from Microsoft.DirectX.Direct3D import *
from Microsoft.DirectX import *
from System.Windows.Forms import *
from System.Drawing import *

form = Form()

presentParams = PresentParameters()
presentParams.Windowed = True
presentParams.SwapEffect = SwapEffect.Discard

device = Device(0, DeviceType.Hardware, form,
CreateFlags.SoftwareVertexProcessing, presentParams)

device.Clear(ClearFlags.Target, Color.Blue, 1.0, 0)
device.BeginScene()
device.EndScene()
device.Present()


The device.Clear method has several overloaded versions of itself as
listed on the MSDN website:
public void Clear(ClearFlags, Color, float, int); 
public void Clear(ClearFlags, Color, float, int, Rectangle[]); 
public void Clear(ClearFlags, int, float, int); 
public void Clear(ClearFlags, int, float, int, Rectangle[]); 


After I run device.Clear.GetMaxArgs() it returns 5, but it doesn't say
which if the two overloaded versions with 5 arguments that it wants.
Is IronPython standardizing which method it is implimenting/calling?

The same problem shows up when I try to create a VertexBuffer who has
6 overloaded versions of its' constructor:
public VertexBuffer(Device, int, Usage, VertexFormats, Pool); 
public VertexBuffer(IDirect3DVertexBuffer9); 
public VertexBuffer(IDirect3DVertexBuffer9, Device, Usage,
VertexFormats, Pool);
public VertexBuffer(IDirect3DVertexBuffer9, Type, int, Device, Usage,
VertexFormats, Pool);
public VertexBuffer(IntPtr); 
public VertexBuffer(Type, int, Device, Usage, VertexFormats, Pool); 


On both the device.Clear and the VertexBuffer constructor, I've tried
every different combination I can think of to no avail. And IronPython
doesn't make it easy to see what the arguments are that it wants:
System.Exception: bad args to this method <method# Clear on
Microsoft.DirectX.Direct3D.Device>
  at IronPython.Objects.ReflectedMethodBase.Call(Object[] args)
  at IronPython.Objects.Ops.Call(Object func, Object arg0, Object
arg1, Object arg2, Object arg3)
  at input_15.Run(Frame frame)
  at IronPythonConsole.IronPython.DoInteractive()


So basically I'm wondering if there is a good way to figure out what
are the arguments to the version of the method that IronPython is
using.


Thanks guys,

-Dan



More information about the Ironpython-users mailing list