WinDevLib
WinDevLib copied to clipboard
Status on Delegates?
I am using CreateThreadpoolIO, it takes a callback function as its second argument. My understanding was tB introduced delegates to strngly type function pointers in API declares. But I also saw you post about some bugs int he changelog, although that seemed to be regarding delgates in UDTs.
Is there a blocker or is it a gap or is it something you haven't had time for.
WinDevLib is the main reason I use tB at the moment, it is like more readable C++
There's currently several bugs in tB related to delegates; I had started adding them in many places (but certainly not everywhere, as nearly all of WDL was written before tB added them) and have since added quite a few delegate definitions, but right now using them as method arguments is disabled:
**Update (v8.7.485, 16 Jan 2025):**
-All delegate-using UDTs, APIs, and macros disabled again pending fix of tB issues:
https://github.com/twinbasic/twinbasic/issues/1999 Can't declare Delegates outside of module they're declared in for packages
https://github.com/twinbasic/twinbasic/issues/1890 Project compiler constants not applied to packages
https://discord.com/channels/927638153546829845/1293249305355747409 Delegates in interfaces in packages thoroughly broken
(Re number 2: For legacy compatibility they're going to be optional, though enabled by default)
So I haven't been prioritizing going back to define more yet, and have disabled the API definitions that were using them. Once those are fixed it will be a higher priority, but still yes it will take me some time to get to everything; I'll set up definitions and provisioning for the threadpoolapiset.h functions next update, but it will be e.g.
Public Delegate Sub TP_WIN32_IO_CALLBACK (ByVal Instance As LongPtr, ByVal Context As LongPtr, ByVal Overlapped As LongPtr, ByVal IoResult As Long, ByVal NumberOfBytesTransferred As LongPtr, ByVal Io As LongPtr)
' #If WINDEVLIB_NO_DELEGATES Then
Public DeclareWide PtrSafe Function CreateThreadpoolIo Lib "kernel32" (ByVal fl As LongPtr, ByVal pfnio As LongPtr, pv As Any, pcbe As TP_CALLBACK_ENVIRON) As LongPtr
' #Else
' Public DeclareWide PtrSafe Function CreateThreadpoolIo Lib "kernel32" (ByVal fl As LongPtr, ByVal pfnio As TP_WIN32_IO_CALLBACK, pv As Any, pcbe As TP_CALLBACK_ENVIRON) As LongPtr
' #End If
so the Delegate will be available, but not enabled in the API def until the bugs in tB are fixed. You'd still be able to use it indirectly; e.g. declare Dim pfn As TP_WIN32_IO_CALLBACK = AddressOf MyCallback and then pass that to the LongPtr argument.
Let me know if there's any other areas you want prioritized.