CFBridgingReleaseas we don’t use ARC
variable tNSStringObj as ObjcObject put PointerToObjcObject(tCFStringRef) into tNSStringObj variable tString as String put StringFromNSString(tNSStringObj) into tString
if element 1 of tMIDINotificationIDnSize = 4 then PointerToMIDIObjectPropertyChangeNotification(tMIDIObjectPropertyChangeNotification,pMIDINotifyStructPtr, element 2 of tMIDINotificationIDnSize ) put element 5 of tMIDIObjectPropertyChangeNotification into tCFStringRef put PointerToObjcObject(tCFStringRef) into tNSStringObj put StringFromNSString(tNSStringObj) into tString
PointerToObjcObject(tCFStringRef) into tNSStringObj
Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x00006f436e696780 Exception Note: EXC_CORPSE_NOTIFY VM Regions Near 0x6f436e696780: MALLOC_LARGE_REUSABLE 0000000118d64000-000000011a806000 [ 26.6M] rw-/rwx SM=PRV --> STACK GUARD 000070000a8f3000-000070000a8f4000 [ 4K] ---/rwx SM=NUL stack guard for thread 7 Application Specific Information: objc_msgSend() selector name: retain Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libobjc.A.dylib 0x00007fff9ce4f05d objc_msgSend + 29 1 com.runrev.livecode 0x0000000105e91b5d MCObjcObjectCreateWithId + 61 2 com.runrev.livecode 0x0000000105eecf04 ffi_call_unix64 + 76 3 com.runrev.livecode 0x0000000105eed75b 0x105e50000 + 644955 4 com.runrev.livecode 0x0000000105ef9980 0x105e50000 + 694656 5 com.runrev.livecode 0x0000000105ef93c1 0x105e50000 + 693185
[4, 20, 6225980, 2, <foreign pointer 0x7fff375ae130>]all of the other elements appear to be working correct. Testing for null before StringFromNSString makes no difference, if I comment out
put PointerToObjcObject(tCFStringRef) into tNSStringObjit doesn't crash.
*** error for object 0x7f8d24b029e0: pointer being freed was not allocated
Here's an example of what is getting logged:
[1, 0, 0, 3, 144, 74, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
element  is Uint32 (packet count), Uint32,Uint32 (2&3 should be Uint64 TimeStamp),  Uint16 byte count of MIDIMessage - 3 bytes that follow,  Uint8 144 is NoteOn Channel 1,  Uint8 is NoteNum 74 (E5 I think),  Uint8 is Velocity ... the rest are where the next packet would be if the first value was 2.
Trying to send data back to the engine is still making me bonkers, the only thing that really works (except for the crashes when I send a bunch of messages in a row, which I think is a threading or sync issue) is logging the data, which isn't very useful.
I noticed that in the Dictionary both Execute Script and Send Script have this note:
Note: An error is thrown if this syntax is used in a context where access to script objects is not allowed.
public handler getIntegerFromFourCharCode(in pStr as String) returns optional any variable tUint32 as Uint32 put (the code of char 4 of pStr) * 256 * 256 * 256 into tUint32 put tUint32 + ((the code of char 3 of pStr) * 256 * 256) into tUint32 put tUint32 + ((the code of char 2 of pStr) * 256 ) into tUint32 put tUint32 + (the code of char 1 of pStr) into tUint32 return tUint32 end handler