I've been adding AppleScript support to my app. Didn't get any responses on cocoa@apple-dev.groups.io, and applescript-implementors is dead, so I'll try here.
Returning some objects to a script shows them as the wrong class. Like here's the AppleEvent when I request "keyword 1 of document 1":
<NSAppleEventDescriptor: 'core'\'getd'{ '----':'obj '{ 'form':'indx', 'want':'Keyw', 'seld':1, 'from':'obj '{ 'form':'indx', 'want':'docu', 'seld':1, 'from':null() } }, &'csig':65536 }>
Looks good. Now here's the object specifier as seen in my app's log when I have NSScriptingDebugLogLevel set to 1:
Result: <NSAppleEventDescriptor: 'obj '{ 'from':'obj '{ 'from':null(), 'want':'docu', 'form':'name', 'seld':'utxt'("_Untitled") }, 'want':', 'form':'name', 'seld':'utxt'(" test picts 2") }>
Notice the malformed value for the 2nd 'want'. It should be 'want':'Keyw', but it's 'want':'
Looking at the returned object in Script Debugger shows the same thing when I view as AEPrint:
'obj '{ 'form':'name', 'want':', 'seld':'utxt'(" test picts 2"), 'from':'obj '{ 'form':'name', 'want':'docu', 'seld':'utxt'("_Untitled"), 'from':[0x0,104003f "Image Chest"] } }
And viewed as Best shows:
asset "test picts 2" of document "_Untitled"
The class should be "keyword" not "asset". Why is AppleScript being annoying?