class library: Spawner - don't access PriorityQueue-array
[supercollider.git] / editors / scapp / SCService.mm
blob667c427c97be651e7dc835a066f483fc70df437d
1 //
2 //  SCService.m
3 //  SC3lang
4 //
5 //  Created by C. Ramakrishnan on Mon Oct 20 2003.
6 //  Copyright (c) 2003 __MyCompanyName__. All rights reserved.
7 //
9 #import "SCService.h"
11 #import "SCVirtualMachine.h"
12 #include "SCBase.h"
13 #include "PyrSymbol.h"
14 #include "PyrObject.h"
15 #include "PyrKernel.h"
16 #include "GC.h"
17 #include "VMGlobals.h"
19 #import <AppKit/NSPasteboard.h>
20 #include <pthread.h>
23 extern bool compiledOK;
24 extern pthread_mutex_t gLangMutex;
26 @implementation SCService
28 - (void)doExecuteService:(NSPasteboard *)pboard userData:(NSString *)data error:(NSString **)error
30     NSString *pboardString;
31         NSArray *types;
33         types = [pboard types];
35         // if there's a problem with the data passed to this method
36         if(![types containsObject:NSStringPboardType] ||
37         !(pboardString = [pboard stringForType:NSStringPboardType])) {
38                 *error = NSLocalizedString(@"Error: Pasteboard doesn't contain a string.",
39                 @"Pasteboard couldn't give a string.");
40                 return;
41         }   
42          
43         if (!compiledOK) {
44                 *error = NSLocalizedString(@"Error: SuperCollider library is not compiled.",
45                         @"Could not execute selection.");
46                 return;
47     }
49     const char *text = [pboardString UTF8String];
51     [[SCVirtualMachine sharedInstance] setCmdLine: text length: [pboardString length]];
52     
53     pthread_mutex_lock(&gLangMutex);
54     runLibrary(getsym("interpretPrintCmdLine"));
55     pthread_mutex_unlock(&gLangMutex);
57         return;
60 @end