I don't really know. The main app is compiled with Xojo (another OO Basic implementation). I have found that producing dylibs I have the best results when I compile my PB dylib with the ProcedureCDLL rather than ProcedureDLL.
I have tries both Prototype and PrototypeC in defining my prototypes.
The calling convention is to have a setup, my example is thus:
Code: Select all
; DLL Callbacks
ProcedureCDLL SetCallbacks(*cStr, *cDbl, *cInt)
*cbstr = *cStr
*cbdbl = *cDbl
*cbint = *cInt
CallString("This is my å∂ƒ©˙∆˚¬…æ test string and I will add a number of lines to it.")
CallInteger(1324567)
CallDouble(1234.56789)
EndProcedure
The three pointers are set as global variables at the beginning of the PB source file. My prototypes are setup as thus:
Code: Select all
; Prototypes - Pre defined functions (copy of the xojo declaration)
Prototype XojoString(msg.s) ; A Xojo function (delegate)
Prototype XojoDouble(msg.s) ; A Xojo function (delegate)
Prototype XojoInteger(msg.s) ; A Xojo function (delegate)
You will see that they are all set as strings because they fail otherwise. I originally had them thus:
Code: Select all
; Prototypes - Pre defined functions (copy of the xojo declaration)
Prototype XojoString(msg.s) ; A Xojo function (delegate)
Prototype XojoDouble(msg.d) ; A Xojo function (delegate)
Prototype XojoInteger(msg.i) ; A Xojo function (delegate)
If it is not inappropriate here, my Xojo code is:
Code: Select all
Declare Sub SetCallbacks Lib "../Resources/callBackTest.dylib" (pSt As Ptr, pDbl As Ptr, pInt As Ptr)
' Set callbacks
Dim p1, p2, p3 As Ptr
p1 = AddressOf MyStringCall
p2 = AddressOf MyDoubleCall
p3 = AddressOf MyIntegerCall
SetCallbacks(p1, p2, p3)
which, according to Xojo, is the correct way of defining the call in to the routine. I know this to be true as I use PB a lot to create dylibs for my Xojo programs.
What is not making any sense to me is that my PB callback works fine if I send a string back. What is not working is a callback with a double or integer value. Then the Xojo app just crashes.
Hopefully, my answer will give some indication of the calling convention being used by Xojo. If not, please ask a more specific question so that I can give a better answer.
Thanks, again, for your help.