diff options
Diffstat (limited to 'macosx/tkMacOSXHLEvents.c')
-rw-r--r-- | macosx/tkMacOSXHLEvents.c | 70 |
1 files changed, 48 insertions, 22 deletions
diff --git a/macosx/tkMacOSXHLEvents.c b/macosx/tkMacOSXHLEvents.c index 76af976..8e1fff5 100644 --- a/macosx/tkMacOSXHLEvents.c +++ b/macosx/tkMacOSXHLEvents.c @@ -48,7 +48,7 @@ typedef struct AppleEventInfo { static int MissedAnyParameters(const AppleEvent *theEvent); static int ReallyKillMe(Tcl_Event *eventPtr, int flags); -static void ProcessAppleEvent(ClientData clientData); +static void ProcessAppleEvent(void *clientData); /* * Names of the procedures which can be used to process AppleEvents. @@ -59,6 +59,7 @@ static const char launchURLProc[] = "::tk::mac::LaunchURL"; static const char printDocProc[] = "::tk::mac::PrintDocument"; static const char scriptFileProc[] = "::tk::mac::DoScriptFile"; static const char scriptTextProc[] = "::tk::mac::DoScriptText"; +static const char getSdefProc[] = "::tk::mac::GetDynamicSdef"; #pragma mark TKApplication(TKHLEvents) @@ -114,7 +115,7 @@ static const char scriptTextProc[] = "::tk::mac::DoScriptText"; if (_eventInterp && Tcl_FindCommand(_eventInterp, "::tk::mac::OpenApplication", NULL, 0)){ int code = Tcl_EvalEx(_eventInterp, "::tk::mac::OpenApplication", - -1, TCL_EVAL_GLOBAL); + TCL_INDEX_NONE, TCL_EVAL_GLOBAL); if (code != TCL_OK) { Tcl_BackgroundException(_eventInterp, code); } @@ -131,7 +132,7 @@ static const char scriptTextProc[] = "::tk::mac::DoScriptText"; if (_eventInterp && Tcl_FindCommand(_eventInterp, "::tk::mac::ReopenApplication", NULL, 0)) { int code = Tcl_EvalEx(_eventInterp, "::tk::mac::ReopenApplication", - -1, TCL_EVAL_GLOBAL); + TCL_INDEX_NONE, TCL_EVAL_GLOBAL); if (code != TCL_OK){ Tcl_BackgroundException(_eventInterp, code); } @@ -147,7 +148,7 @@ static const char scriptTextProc[] = "::tk::mac::DoScriptText"; if (_eventInterp && Tcl_FindCommand(_eventInterp, "::tk::mac::ShowPreferences", NULL, 0)){ int code = Tcl_EvalEx(_eventInterp, "::tk::mac::ShowPreferences", - -1, TCL_EVAL_GLOBAL); + TCL_INDEX_NONE, TCL_EVAL_GLOBAL); if (code != TCL_OK) { Tcl_BackgroundException(_eventInterp, code); } @@ -210,7 +211,7 @@ static const char scriptTextProc[] = "::tk::mac::DoScriptText"; AppleEventInfo *AEInfo = (AppleEventInfo *)ckalloc(sizeof(AppleEventInfo)); Tcl_DString *openCommand = &AEInfo->command; Tcl_DStringInit(openCommand); - Tcl_DStringAppend(openCommand, openDocumentProc, -1); + Tcl_DStringAppend(openCommand, openDocumentProc, TCL_INDEX_NONE); utf8 = Tcl_GetEncoding(NULL, "utf-8"); for (index = 1; index <= count; index++) { @@ -226,7 +227,8 @@ static const char scriptTextProc[] = "::tk::mac::DoScriptText"; if (fileURL == nil) { continue; } - Tcl_ExternalToUtfDString(utf8, [[fileURL path] UTF8String], -1, &pathName); + (void)Tcl_ExternalToUtfDString(utf8, [[fileURL path] UTF8String], TCL_INDEX_NONE, + &pathName); Tcl_DStringAppendElement(openCommand, Tcl_DStringValue(&pathName)); Tcl_DStringFree(&pathName); } @@ -237,11 +239,10 @@ static const char scriptTextProc[] = "::tk::mac::DoScriptText"; AEInfo->procedure = openDocumentProc; AEInfo->replyEvent = nil; AEInfo->retryCount = 0; - if (Tcl_FindCommand(_eventInterp, "::tk::mac::OpenDocuments", NULL, 0)){ - ProcessAppleEvent((ClientData)AEInfo); + ProcessAppleEvent((void *)AEInfo); } else { - Tcl_CreateTimerHandler(500, ProcessAppleEvent, (ClientData)AEInfo); + Tcl_CreateTimerHandler(500, ProcessAppleEvent, (void *)AEInfo); } } @@ -256,13 +257,13 @@ static const char scriptTextProc[] = "::tk::mac::DoScriptText"; (void)replyEvent; Tcl_DStringInit(printCommand); - Tcl_DStringAppend(printCommand, printDocProc, -1); + Tcl_DStringAppend(printCommand, printDocProc, TCL_INDEX_NONE); Tcl_DStringAppendElement(printCommand, printFile); AEInfo->interp = _eventInterp; AEInfo->procedure = printDocProc; AEInfo->replyEvent = nil; AEInfo->retryCount = 0; - ProcessAppleEvent((ClientData)AEInfo); + ProcessAppleEvent((void *)AEInfo); } - (void) handleDoScriptEvent: (NSAppleEventDescriptor *)event @@ -318,13 +319,13 @@ static const char scriptTextProc[] = "::tk::mac::DoScriptText"; AppleEventInfo *AEInfo = (AppleEventInfo *)ckalloc(sizeof(AppleEventInfo)); Tcl_DString *scriptFileCommand = &AEInfo->command; Tcl_DStringInit(scriptFileCommand); - Tcl_DStringAppend(scriptFileCommand, scriptFileProc, -1); + Tcl_DStringAppend(scriptFileCommand, scriptFileProc, TCL_INDEX_NONE); Tcl_DStringAppendElement(scriptFileCommand, [[fileURL path] UTF8String]); AEInfo->interp = _eventInterp; AEInfo->procedure = scriptFileProc; AEInfo->replyEvent = nil; AEInfo->retryCount = 0; - ProcessAppleEvent((ClientData)AEInfo); + ProcessAppleEvent((void *)AEInfo); } } } else if (noErr == AEGetParamPtr(theDesc, keyDirectObject, typeUTF8Text, &type, @@ -344,17 +345,17 @@ static const char scriptTextProc[] = "::tk::mac::DoScriptText"; AppleEventInfo *AEInfo = (AppleEventInfo *)ckalloc(sizeof(AppleEventInfo)); Tcl_DString *scriptTextCommand = &AEInfo->command; Tcl_DStringInit(scriptTextCommand); - Tcl_DStringAppend(scriptTextCommand, scriptTextProc, -1); + Tcl_DStringAppend(scriptTextCommand, scriptTextProc, TCL_INDEX_NONE); Tcl_DStringAppendElement(scriptTextCommand, data); AEInfo->interp = _eventInterp; AEInfo->procedure = scriptTextProc; AEInfo->retryCount = 0; if (Tcl_FindCommand(AEInfo->interp, AEInfo->procedure, NULL, 0)) { AEInfo->replyEvent = replyEvent; - ProcessAppleEvent((ClientData)AEInfo); + ProcessAppleEvent(AEInfo); } else { AEInfo->replyEvent = nil; - ProcessAppleEvent((ClientData)AEInfo); + ProcessAppleEvent(AEInfo); } } } @@ -372,13 +373,29 @@ static const char scriptTextProc[] = "::tk::mac::DoScriptText"; (void)replyEvent; Tcl_DStringInit(launchCommand); - Tcl_DStringAppend(launchCommand, launchURLProc, -1); + Tcl_DStringAppend(launchCommand, launchURLProc, TCL_INDEX_NONE); Tcl_DStringAppendElement(launchCommand, cURL); AEInfo->interp = _eventInterp; AEInfo->procedure = launchURLProc; AEInfo->replyEvent = nil; AEInfo->retryCount = 0; - ProcessAppleEvent((ClientData)AEInfo); + ProcessAppleEvent((void *)AEInfo); +} + +- (void)handleGetSDEFEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent { + AppleEventInfo *AEInfo = (AppleEventInfo *)ckalloc(sizeof(AppleEventInfo)); + Tcl_DString *sdefCommand = &AEInfo->command; + (void)event; + (void)replyEvent; + + Tcl_DStringInit(sdefCommand); + Tcl_DStringAppend(sdefCommand, getSdefProc, TCL_INDEX_NONE); + AEInfo->interp = _eventInterp; + AEInfo->procedure = getSdefProc; + AEInfo->replyEvent = nil; + AEInfo->retryCount = 0; + ProcessAppleEvent((void *)AEInfo); + } @end @@ -409,7 +426,7 @@ static const char scriptTextProc[] = "::tk::mac::DoScriptText"; */ static void ProcessAppleEvent( - ClientData clientData) + void *clientData) { int code; AppleEventInfo *AEInfo = (AppleEventInfo*) clientData; @@ -439,7 +456,7 @@ static void ProcessAppleEvent( Tcl_DStringLength(&AEInfo->command), TCL_EVAL_GLOBAL); if (AEInfo->replyEvent && code >= 0) { - int reslen; + Tcl_Size reslen; const char *result = Tcl_GetStringFromObj(Tcl_GetObjResult(AEInfo->interp), &reslen); if (code == TCL_OK) { @@ -518,6 +535,15 @@ TkMacOSXInitAppleEvents( andSelector:@selector(handleURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL]; + /* + * We do not load our sdef dynamically but this event handler + * is required to silence error messages from inline execution + * of AppleScript at the Objective-C level. + */ + [aeManager setEventHandler:NSApp + andSelector:@selector(handleGetSDEFEvent:withReplyEvent:) + forEventClass:'ascr' andEventID:'gsdf']; + } } @@ -597,7 +623,7 @@ ReallyKillMe( Tcl_Exit(0); } - int code = Tcl_EvalEx(interp, "::tk::mac::Quit", -1, TCL_EVAL_GLOBAL); + int code = Tcl_EvalEx(interp, "::tk::mac::Quit", TCL_INDEX_NONE, TCL_EVAL_GLOBAL); if (code != TCL_OK) { /* @@ -637,7 +663,7 @@ MissedAnyParameters( typeWildCard, &returnedType, NULL, 0, &actualSize); return (err != errAEDescNotFound); -} +} /* * Local Variables: |