1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
|
#include "plugin_internal.h"
static CWCompilerLinkerContext *GetContext(CWPluginContext context) {
if (context && (context->pluginType == CWDROPINCOMPILERTYPE || context->pluginType == CWDROPINLINKERTYPE))
return static_cast<CWCompilerLinkerContext *>(context);
else
return 0;
}
CW_CALLBACK CWIsPrecompiling(CWPluginContext context, Boolean* isPrecompiling) {
CWCompilerLinkerContext *cl;
if (!isPrecompiling)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
*isPrecompiling = cl->precompile;
return cwNoErr;
}
CW_CALLBACK CWIsAutoPrecompiling(CWPluginContext context, Boolean* isAutoPrecompiling) {
CWCompilerLinkerContext *cl;
if (!isAutoPrecompiling)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
*isAutoPrecompiling = cl->autoprecompile;
return cwNoErr;
}
CW_CALLBACK CWIsPreprocessing(CWPluginContext context, Boolean* isPreprocessing) {
CWCompilerLinkerContext *cl;
if (!isPreprocessing)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
*isPreprocessing = cl->preprocess;
return cwNoErr;
}
CW_CALLBACK CWIsGeneratingDebugInfo(CWPluginContext context, Boolean* isGenerating) {
CWCompilerLinkerContext *cl;
if (!isGenerating)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
*isGenerating = cl->debuginfo;
return cwNoErr;
}
CW_CALLBACK CWIsCachingPrecompiledHeaders(CWPluginContext context, Boolean* isCaching) {
CWCompilerLinkerContext *cl;
if (!isCaching)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
*isCaching = cl->cachingPCH;
return cwNoErr;
}
CW_CALLBACK CWGetBrowseOptions(CWPluginContext context, CWBrowseOptions* browseOptions) {
CWCompilerLinkerContext *cl;
if (!browseOptions)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
*browseOptions = cl->browseoptions;
return cwNoErr;
}
CW_CALLBACK CWGetBuildSequenceNumber(CWPluginContext context, SInt32* sequenceNumber) {
CWCompilerLinkerContext *cl;
if (!sequenceNumber)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
*sequenceNumber = cl->sequenceID;
return cwNoErr;
}
CW_CALLBACK CWGetTargetInfo(CWPluginContext context, CWTargetInfo* targetInfo) {
CWCompilerLinkerContext *cl;
if (!targetInfo)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
if (cl->apiVersion >= 10) {
*targetInfo = *cl->targetinfo;
} else if (cl->apiVersion >= 8) {
CWTargetInfo *ti = cl->targetinfo;
targetInfo->outputType = ti->outputType;
targetInfo->outfile = ti->outfile;
targetInfo->symfile = ti->symfile;
targetInfo->runfile = ti->runfile;
targetInfo->linkType = ti->linkType;
targetInfo->canRun = ti->canRun;
targetInfo->canDebug = ti->canDebug;
targetInfo->targetCPU = ti->targetCPU;
targetInfo->targetOS = ti->targetOS;
#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS
targetInfo->outfileCreator = ti->outfileCreator;
targetInfo->outfileType = ti->outfileType;
targetInfo->debuggerCreator = ti->debuggerCreator;
targetInfo->runHelperCreator = ti->runHelperCreator;
#endif
} else {
memset(targetInfo, 0, sizeof(CWTargetInfo));
if (CWFileSpecNotEmpty(&cl->targetinfo_V7.outfile))
targetInfo->outputType = linkOutputFile;
else
targetInfo->outputType = linkOutputNone;
targetInfo->outfile = cl->targetinfo_V7.outfile;
targetInfo->symfile = cl->targetinfo_V7.symfile;
targetInfo->runfile = cl->targetinfo_V7.outfile;
targetInfo->linkType = cl->targetinfo_V7.linkType;
targetInfo->canRun = cl->targetinfo_V7.canRun;
targetInfo->canDebug = cl->targetinfo_V7.canDebug;
#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS
targetInfo->debuggerCreator = cl->targetinfo_V7.debuggerCreator;
targetInfo->runHelperCreator = cl->targetinfo_V7.runHelperCreator;
#endif
}
return cwNoErr;
}
CW_CALLBACK CWSetTargetInfo(CWPluginContext context, CWTargetInfo* targetInfo) {
CWCompilerLinkerContext *cl;
if (!targetInfo)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
if (cl->apiVersion >= 10) {
*cl->targetinfo = *targetInfo;
} else if (cl->apiVersion >= 8) {
CWTargetInfo *ti = cl->targetinfo;
ti->outputType = targetInfo->outputType;
ti->outfile = targetInfo->outfile;
ti->symfile = targetInfo->symfile;
ti->runfile = targetInfo->runfile;
ti->linkType = targetInfo->linkType;
ti->canRun = targetInfo->canRun;
ti->canDebug = targetInfo->canDebug;
ti->targetCPU = targetInfo->targetCPU;
ti->targetOS = targetInfo->targetOS;
#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS
ti->outfileCreator = targetInfo->outfileCreator;
ti->outfileType = targetInfo->outfileType;
ti->debuggerCreator = targetInfo->debuggerCreator;
ti->runHelperCreator = targetInfo->runHelperCreator;
#endif
} else {
cl->targetinfo_V7.outfile = targetInfo->outfile;
cl->targetinfo_V7.symfile = targetInfo->symfile;
cl->targetinfo_V7.linkType = targetInfo->linkType;
cl->targetinfo_V7.canRun = targetInfo->canRun;
cl->targetinfo_V7.canDebug = targetInfo->canDebug;
#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS
cl->targetinfo_V7.useRunHelperApp = targetInfo->runHelperCreator != 0;
cl->targetinfo_V7.debuggerCreator = targetInfo->debuggerCreator;
cl->targetinfo_V7.runHelperCreator = targetInfo->runHelperCreator;
#endif
}
return cwNoErr;
}
CW_CALLBACK CWGetMainFileNumber(CWPluginContext context, SInt32* fileNumber) {
CWCompilerLinkerContext *cl;
if (!fileNumber)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
*fileNumber = cl->whichfile;
return cwNoErr;
}
CW_CALLBACK CWGetMainFileID(CWPluginContext context, short* fileID) {
CWCompilerLinkerContext *cl;
if (!fileID)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
*fileID = cl->fileID;
return cwNoErr;
}
CW_CALLBACK CWGetMainFileSpec(CWPluginContext context, CWFileSpec* fileSpec) {
CWCompilerLinkerContext *cl;
if (!fileSpec)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
*fileSpec = cl->sourcefile;
return cwNoErr;
}
CW_CALLBACK CWGetMainFileText(CWPluginContext context, const char** text, SInt32* textLength) {
CWCompilerLinkerContext *cl;
if (!text)
return cwErrInvalidParameter;
if (!textLength)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
*text = cl->sourcetext;
*textLength = cl->sourcetextsize;
return cwNoErr;
}
CW_CALLBACK CWLoadObjectData(CWPluginContext context, SInt32 whichfile, CWMemHandle* objectdata) {
CWCompilerLinkerContext *cl;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
return cl->callbacks->cbLoadObjectData(cl, whichfile, objectdata);
}
CW_CALLBACK CWStoreObjectData(CWPluginContext context, SInt32 whichfile, CWObjectData* object) {
CWCompilerLinkerContext *cl;
if (!object)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
return cl->callbacks->cbStoreObjectData(cl, whichfile, object);
}
CW_CALLBACK CWFreeObjectData(CWPluginContext context, SInt32 whichfile, CWMemHandle objectdata) {
CWCompilerLinkerContext *cl;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
return cl->callbacks->cbFreeObjectData(cl, whichfile, objectdata);
}
CW_CALLBACK CWGetSuggestedObjectFileSpec(CWPluginContext context, SInt32 whichfile, CWFileSpec* fileSpec) {
CWCompilerLinkerContext *cl;
if (!fileSpec)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
if (context->apiVersion < 10)
return cwErrInvalidCallback;
return cl->callbacks->cbGetSuggestedObjectFileSpec(cl, whichfile, fileSpec);
}
CW_CALLBACK CWGetStoredObjectFileSpec(CWPluginContext context, SInt32 whichfile, CWFileSpec* fileSpec) {
CWCompilerLinkerContext *cl;
if (!fileSpec)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
if (context->apiVersion < 10)
return cwErrInvalidCallback;
return cl->callbacks->cbGetStoredObjectFileSpec(cl, whichfile, fileSpec);
}
CW_CALLBACK CWDisplayLines(CWPluginContext context, SInt32 nlines) {
CWCompilerLinkerContext *cl;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
return cl->callbacks->cbDisplayLines(cl, nlines);
}
CW_CALLBACK CWGetResourceFile(CWPluginContext context, CWFileSpec* filespec) {
CWCompilerLinkerContext *cl;
if (!filespec)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
return cl->callbacks->cbGetResourceFile(cl, filespec);
}
CW_CALLBACK CWPutResourceFile(CWPluginContext context, const char* prompt, const char* name, CWFileSpec* filespec) {
CWCompilerLinkerContext *cl;
if (!prompt)
return cwErrInvalidParameter;
if (!name)
return cwErrInvalidParameter;
if (!filespec)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
return cl->callbacks->cbPutResourceFile(cl, prompt, name, filespec);
}
CW_CALLBACK CWCachePrecompiledHeader(CWPluginContext context, const CWFileSpec* filespec, CWMemHandle pchhandle) {
CWCompilerLinkerContext *cl;
if (!filespec)
return cwErrInvalidParameter;
if (!pchhandle)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
return cl->callbacks->cbCachePrecompiledHeader(cl, filespec, pchhandle);
}
CW_CALLBACK CWGetPrecompiledHeaderSpec(CWPluginContext context, CWFileSpec *pchspec, const char *target) {
CWCompilerLinkerContext *cl;
if (!pchspec)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
return cl->callbacks->cbGetPrecompiledHeaderSpec(cl, pchspec, target);
}
CW_CALLBACK CWBeginSubCompile(CWPluginContext context, SInt32 whichfile, CWPluginContext* subContext) {
CWCompilerLinkerContext *cl;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
return cl->callbacks->cbBeginSubCompile(cl, whichfile, subContext);
}
CW_CALLBACK CWEndSubCompile(CWPluginContext subContext) {
CWCompilerLinkerContext *cl;
if (!(cl = GetContext(subContext)))
return cwErrInvalidCallback;
return cl->callbacks->cbEndSubCompile(subContext);
}
CW_CALLBACK CWLookUpUnit(CWPluginContext context, const char* name, Boolean isdependency, const void** unitdata, SInt32* unitdatalength) {
CWCompilerLinkerContext *cl;
if (!name)
return cwErrInvalidParameter;
if (!unitdata)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
return cl->callbacks->cbLookUpUnit(cl, name, isdependency, unitdata, unitdatalength);
}
CW_CALLBACK CWSBMfiles(CWPluginContext context, short libref) {
CWCompilerLinkerContext *cl;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
return cl->callbacks->cbSBMfiles(cl, libref);
}
CW_CALLBACK CWStoreUnit(CWPluginContext context, const char* unitname, CWMemHandle unitdata, CWDependencyTag dependencytag) {
CWCompilerLinkerContext *cl;
if (!unitname)
return cwErrInvalidParameter;
if (!unitdata)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
return cl->callbacks->cbStoreUnit(cl, unitname, unitdata, dependencytag);
}
CW_CALLBACK CWReleaseUnit(CWPluginContext context, void* unitdata) {
CWCompilerLinkerContext *cl;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
return cl->callbacks->cbReleaseUnit(cl, unitdata);
}
CW_CALLBACK CWUnitNameToFileName(CWPluginContext context, const char* unitname, char* filename) {
CWCompilerLinkerContext *cl;
if (!unitname)
return cwErrInvalidParameter;
if (!filename)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
return cl->callbacks->cbUnitNameToFileName(cl, unitname, filename);
}
CW_CALLBACK CWGetTargetStorage(CWPluginContext context, void** storage) {
CWCompilerLinkerContext *cl;
if (!storage)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
if (cl->apiVersion >= 8) {
*storage = cl->targetStorage;
return cwNoErr;
} else {
return cwErrRequestFailed;
}
}
CW_CALLBACK CWSetTargetStorage(CWPluginContext context, void* storage) {
CWCompilerLinkerContext *cl;
if (!storage)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
if (cl->apiVersion >= 8) {
cl->targetStorage = storage;
return cwNoErr;
} else {
return cwErrRequestFailed;
}
}
CW_CALLBACK CWOSErrorMessage(CWPluginContext context, const char *msg, OSErr errorcode) {
CWCompilerLinkerContext *cl;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
return cl->callbacks->cbOSErrorMessage(cl, msg, errorcode);
}
CW_CALLBACK CWOSAlert(CWPluginContext context, const char* message, OSErr errorcode) {
CWCompilerLinkerContext *cl;
if (!message)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
return cl->callbacks->cbOSAlert(cl, message, errorcode);
}
CW_CALLBACK CWGetModifiedFiles(CWPluginContext context, SInt32* modifiedFileCount, const SInt32** modifiedFiles) {
CWCompilerLinkerContext *cl;
if (!modifiedFileCount)
return cwErrInvalidParameter;
if (!modifiedFiles)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
if (context->apiVersion < 9)
return cwErrInvalidCallback;
return cl->callbacks->cbGetModifiedFiles(cl, modifiedFileCount, modifiedFiles);
}
CW_CALLBACK CWGetCommandLineArgs(CWPluginContext context, const char** commandLineArgs) {
CWCompilerLinkerContext *cl;
if (!commandLineArgs)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
if (cl->apiVersion < 11)
return cwErrInvalidCallback;
if (!cl->commandLineArgs && cl->callbacks->cbGetRuntimeSettings(cl))
return cwErrRequestFailed;
*commandLineArgs = cl->commandLineArgs;
return cwNoErr;
}
CW_CALLBACK CWGetWorkingDirectory(CWPluginContext context, CWFileSpec* workingDirectorySpec) {
CWCompilerLinkerContext *cl;
if (!workingDirectorySpec)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
if (cl->apiVersion < 11)
return cwErrInvalidCallback;
if (!cl->commandLineArgs && cl->callbacks->cbGetRuntimeSettings(cl))
return cwErrRequestFailed;
*workingDirectorySpec = *cl->workingDirectorySpec;
return cwNoErr;
}
CW_CALLBACK CWGetEnvironmentVariableCount(CWPluginContext context, SInt32* count) {
CWCompilerLinkerContext *cl;
if (!count)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
if (cl->apiVersion < 11)
return cwErrInvalidCallback;
if (!cl->commandLineArgs && cl->callbacks->cbGetRuntimeSettings(cl))
return cwErrRequestFailed;
*count = cl->numEnvironmentVariables;
return cwNoErr;
}
CW_CALLBACK CWGetEnvironmentVariable(CWPluginContext context, SInt32 index, const char** name, const char** value) {
CWCompilerLinkerContext *cl;
if (!name)
return cwErrInvalidParameter;
if (!value)
return cwErrInvalidParameter;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
if (cl->apiVersion < 11)
return cwErrInvalidCallback;
if (!cl->commandLineArgs && cl->callbacks->cbGetRuntimeSettings(cl))
return cwErrRequestFailed;
if (index < 0 || index >= cl->numEnvironmentVariables)
return cwErrInvalidParameter;
*name = cl->environmentVariables[index].name;
*value = cl->environmentVariables[index].value;
return cwNoErr;
}
CW_CALLBACK CWGetFrameworkCount(CWPluginContext context, SInt32* frameworkCount) {
CWCompilerLinkerContext *cl;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
if (cl->apiVersion < 11)
return cwErrInvalidCallback;
if (!cl->commandLineArgs && cl->callbacks->cbGetFrameworkCount(cl, frameworkCount))
return cwErrRequestFailed;
return cwNoErr;
}
CW_CALLBACK CWGetFrameworkInfo(CWPluginContext context, SInt32 whichFramework, CWFrameworkInfo* frameworkInfo) {
CWCompilerLinkerContext *cl;
if (!(cl = GetContext(context)))
return cwErrInvalidCallback;
if (cl->apiVersion < 11)
return cwErrInvalidCallback;
if (!cl->commandLineArgs && cl->callbacks->cbGetFrameworkInfo(cl, whichFramework, frameworkInfo))
return cwErrRequestFailed;
return cwNoErr;
}
|