I rewrote it a little bit using two different "classes" with two functions that have the "same name" (___.abc) at user-side.
' This script actually runs.
Uses "console"
' -------------------------------------------
'Begin Class 1
Type pseudoclass1
someVar As Long
Static abc As DWord '= Function_GetPtr(abc1)
End Type
Function abc1(ByVal pData As DWord, ByVal xxx As Long ) As Long
' this one awaits pointer
Local ME As pseudoclass1 At pData
Return xxx * 2 + ME.someVar - 1000
End Function
'End Class 1
' -------------------------------------------
Dim myObject1 As pseudoclass1
' have to set this manually here:
myObject1.abc = Function_GetPtr(abc1)
' -------------------------------------------
'Begin Class 2
Type pseudoclass2
otherVar As Long
Static abc As DWord ' = Function_GetPtr(abc2)
End Type
Function abc2( ByRef ME As pseudoclass2, ByVal xxx As Long ) As Long
' different approach to determine ME here...probably no good for nested types...
Return xxx * 2 + ME.otherVar - 2000
End Function
'End Class 2
' -------------------------------------------
Dim myObject2(3) As pseudoclass2
myObject2(1).abc = Function_GetPtr(abc2)
' Test
Long lResult
myObject1.someVar = 1000
myObject2(2).otherVar = 2000
Call myObject1.abc (VarPtr myObject1, 21) To lResult
PrintL lResult
Call_IfExists myObject2(2).abc ( myObject2(2), 21) To lResult
PrintL lResult
WaitKey
Now only needs some Begin-End-Closure around - so the Functions get embedded into the "Type" and the pointer gets set immediately (static the same to all objects of this "class" )
- and of course something that informs the "embedded" function which element of the Type currently to work with ("ME/THIS") would be better than to have pass always the var byref or its pointer.
Perhaps can be achieved through a different behavior of Call when passed function-ptr is part of "class"-structure - so identified as "method" -or even proceeding such without keyword "call"
Bookmarks