Skip to content

Is it possible to create Non-Generic Delegates in IronPython without CTypes? #1735

Answered by slozier
Hubbl3 asked this question in Q&A
Discussion options

You must be logged in to vote

Digging through the codebase a bit it looks like you can create non-generic delegates in at least two ways:

clr.AddReference("Microsoft.Dynamic")
from Microsoft.Scripting.Generation import Snippets
EnumWindowsProc = Snippets.Shared.DefineDelegate("MyDelegate", bool, IntPtr, IntPtr)

clr.AddReference("IronPython")
from IronPython.Runtime.Operations import PythonOps
EnumWindowsProc = PythonOps.MakeNewCustomDelegate(System.Array[System.Type]([IntPtr, IntPtr, bool]))

I wonder if one of these would be a good fit for a helper in clrtype (probably the Snippets version)...

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Hubbl3
Comment options

Answer selected by slozier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants