mirror of
https://git.wuffs.org/MWCC
synced 2025-12-14 15:46:16 +00:00
let's commit all this before my VM blows up and nukes my work
This commit is contained in:
@@ -1,27 +1,636 @@
|
||||
/**
|
||||
P 1F458 | _UCBCachePrecompiledHeader
|
||||
P 1F4F8 | _UCBLoadObjectData
|
||||
P 1F5BC | _UCBStoreObjectData
|
||||
P 1F860 | _UCBFreeObjectData
|
||||
P 1F90C | _UCBDisplayLines
|
||||
P 1F980 | _UCBBeginSubCompile
|
||||
P 1F9F0 | _UCBEndSubCompile
|
||||
P 1FA60 | _UCBGetPrecompiledHeaderSpec
|
||||
P 1FD38 | _UCBGetResourceFile
|
||||
P 1FDA8 | _UCBPutResourceFile
|
||||
1FE18 | _UnitNameToSBMName__FP6OSSpecP4File
|
||||
P 1FEA0 | _UCBLookUpUnit
|
||||
P 20544 | _UCBSBMfiles
|
||||
P 20594 | _UCBStoreUnit
|
||||
P 20848 | _UCBReleaseUnit
|
||||
P 208C8 | _UCBUnitNameToFileName
|
||||
P 20978 | _UCBOSAlert
|
||||
P 20A50 | _UCBOSErrorMessage
|
||||
P 20B38 | _UCBGetModifiedFiles
|
||||
P 20BBC | _UCBGetSuggestedObjectFileSpec
|
||||
P 20C78 | _UCBGetStoredObjectFileSpec
|
||||
P 20D4C | _UCBGetFrameworkCount
|
||||
P 20DB0 | _UCBGetFrameworkInfo
|
||||
P 20E48 | ___ct__23CWCompilerLinkerContextFv
|
||||
P 20FEC | ___dt__23CWCompilerLinkerContextFv
|
||||
*/
|
||||
#include "cmdline.h"
|
||||
#include "plugin_internal.h"
|
||||
|
||||
extern char STSbuf[256];
|
||||
|
||||
CWResult UCBCachePrecompiledHeader(CWPluginContext context, const CWFileSpec *filespec, CWMemHandle pchhandle) {
|
||||
if (optsCmdLine.verbose > 3)
|
||||
CLPrint("Callback: %s\n", "UCBCachePrecompiledHeader");
|
||||
|
||||
OSSpec spec;
|
||||
Handle handle;
|
||||
OS_FSSpec_To_OSSpec(filespec, &spec);
|
||||
UCBSecretDetachHandle(context, pchhandle, &handle);
|
||||
CacheIncludeFile(&spec, handle, 1);
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CWResult UCBLoadObjectData(CWPluginContext context, SInt32 whichfile, CWMemHandle *objectdata) {
|
||||
if (optsCmdLine.verbose > 3)
|
||||
CLPrint("Callback: %s\n", "UCBLoadObjectData");
|
||||
|
||||
File *file = Files_GetFile(&gTarg->files, whichfile);
|
||||
if (!file)
|
||||
return cwErrUnknownFile;
|
||||
|
||||
if (file->objectdata) {
|
||||
UCBSecretAttachHandle(context, file->objectdata, objectdata);
|
||||
return cwNoErr;
|
||||
} else {
|
||||
return cwErrRequestFailed;
|
||||
}
|
||||
}
|
||||
|
||||
CWResult UCBStoreObjectData(CWPluginContext context, SInt32 whichfile, CWObjectData *object) {
|
||||
if (optsCmdLine.verbose > 3)
|
||||
CLPrint("Callback: %s\n", "UCBStoreObjectData");
|
||||
|
||||
if (CheckForUserBreak())
|
||||
return cwErrUserCanceled;
|
||||
|
||||
File *filedata = Files_GetFile(&gTarg->files, whichfile);
|
||||
if (!filedata)
|
||||
return cwErrUnknownFile;
|
||||
|
||||
if (!object->objectfile) {
|
||||
Handle objecthand;
|
||||
Handle browsehand;
|
||||
UCBSecretDetachHandle(context, object->objectdata, &objecthand);
|
||||
UCBSecretDetachHandle(context, object->browsedata, &browsehand);
|
||||
filedata->objectdata = objecthand;
|
||||
filedata->browsedata = browsehand;
|
||||
UCBSecretAttachHandle(context, objecthand, &object->objectdata);
|
||||
UCBSecretAttachHandle(context, browsehand, &object->browsedata);
|
||||
} else {
|
||||
if (filedata->outfileowner && filedata->outfileowner != CmdLineStageMask_Cg) {
|
||||
#line 240
|
||||
DO_INTERNAL_ERROR("Cannot store object file spec for '%s'\n", filedata->srcfilename);
|
||||
}
|
||||
OS_FSSpec_To_OSSpec(object->objectfile, &filedata->outfss);
|
||||
filedata->wroteToDisk |= CmdLineStageMask_Cg;
|
||||
}
|
||||
|
||||
filedata->codesize = object->codesize;
|
||||
filedata->udatasize = object->udatasize;
|
||||
filedata->idatasize = object->idatasize;
|
||||
filedata->compiledlines = object->compiledlines;
|
||||
if (filedata->dropinflags & kGeneratesrsrcs)
|
||||
filedata->hasresources = 1;
|
||||
else
|
||||
filedata->hasobjectcode = 1;
|
||||
filedata->recompileDependents = object->dependencyCount && object->interfaceChanged;
|
||||
OS_GetTime(&filedata->outmoddate);
|
||||
if (object->reserved1)
|
||||
filedata->filetype = object->reserved1;
|
||||
|
||||
if (object->reserved2) {
|
||||
char *newname = reinterpret_cast<char *>(object->reserved2);
|
||||
CWFileInfo fi;
|
||||
if (OS_MakeSpec(newname, &filedata->srcfss, NULL) || OS_Status(&filedata->srcfss)) {
|
||||
fi.fullsearch = 1;
|
||||
fi.dependencyType = cwNoDependency;
|
||||
fi.isdependentoffile = -1;
|
||||
fi.suppressload = 1;
|
||||
if (UCBFindAndLoadFile(context, newname, &fi) == cwNoErr) {
|
||||
OS_FSSpec_To_OSSpec(&fi.filespec, &filedata->srcfss);
|
||||
} else {
|
||||
char *fnptr = OS_GetFileNamePtr(newname);
|
||||
if (fnptr != newname) {
|
||||
fi.fullsearch = 1;
|
||||
fi.dependencyType = cwNoDependency;
|
||||
fi.isdependentoffile = -1;
|
||||
fi.suppressload = 1;
|
||||
if (UCBFindAndLoadFile(context, fnptr, &fi) == cwNoErr) {
|
||||
OS_FSSpec_To_OSSpec(&fi.filespec, &filedata->srcfss);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CWResult UCBFreeObjectData(CWPluginContext context, SInt32 whichfile, CWMemHandle objectdata) {
|
||||
if (optsCmdLine.verbose > 3)
|
||||
CLPrint("Callback: %s\n", "UCBFreeObjectData");
|
||||
|
||||
File *file = Files_GetFile(&gTarg->files, whichfile);
|
||||
if (!file)
|
||||
return cwErrUnknownFile;
|
||||
|
||||
if (file->objectdata) {
|
||||
DisposeHandle(file->objectdata);
|
||||
file->objectdata = NULL;
|
||||
return cwNoErr;
|
||||
} else {
|
||||
return cwErrInvalidParameter;
|
||||
}
|
||||
}
|
||||
|
||||
CWResult UCBDisplayLines(CWPluginContext context, SInt32 nlines) {
|
||||
ShowWorking(12);
|
||||
|
||||
if (optsCmdLine.verbose > 3)
|
||||
CLPrint("Callback: %s\n", "UCBDisplayLines");
|
||||
|
||||
if (CheckForUserBreak())
|
||||
return cwErrUserCanceled;
|
||||
else
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CWResult UCBBeginSubCompile(CWPluginContext context, SInt32 whichfile, CWPluginContext *subContext) {
|
||||
if (optsCmdLine.verbose > 3)
|
||||
CLPrint("Callback: %s\n", "UCBBeginSubCompile");
|
||||
|
||||
#line 372
|
||||
DO_INTERNAL_ERROR("UCBBeginSubCompile not implemented");
|
||||
return cwErrRequestFailed;
|
||||
}
|
||||
|
||||
CWResult UCBEndSubCompile(CWPluginContext subContext) {
|
||||
if (optsCmdLine.verbose > 3)
|
||||
CLPrint("Callback: %s\n", "UCBEndSubCompile");
|
||||
|
||||
#line 384
|
||||
DO_INTERNAL_ERROR("UCBEndSubCompile not implemented");
|
||||
return cwErrRequestFailed;
|
||||
}
|
||||
|
||||
CWResult UCBGetPrecompiledHeaderSpec(CWPluginContext context, CWFileSpec *pchspec, const char *intarget) {
|
||||
if (optsCmdLine.verbose > 3)
|
||||
CLPrint("Callback: %s\n", "UCBGetPrecompiledHeaderSpec");
|
||||
|
||||
CWCompilerLinkerContext *c;
|
||||
int err;
|
||||
OSSpec outfss;
|
||||
File *file;
|
||||
const CWObjectFlags *cof;
|
||||
char target[256];
|
||||
|
||||
if (context->pluginType == CWDROPINCOMPILERTYPE || context->pluginType == CWDROPINLINKERTYPE)
|
||||
c = static_cast<CWCompilerLinkerContext *>(context);
|
||||
else
|
||||
return cwErrInvalidCallback;
|
||||
|
||||
file = Files_GetFile(&gTarg->files, c->whichfile);
|
||||
#line 420
|
||||
OPTION_ASSERT(file != NULL);
|
||||
|
||||
cof = Plugin_CL_GetObjectFlags(file->compiler);
|
||||
if (!file->outfilename[0]) {
|
||||
if (intarget) {
|
||||
if (optsCompiler.canonicalIncludes)
|
||||
strcpy(target, intarget);
|
||||
else if (OS_CanonPath(intarget, target) != noErr)
|
||||
return cwErrInvalidParameter;
|
||||
|
||||
err = OS_MakeSpecWithPath(&file->srcfss.path, target, 0, &outfss);
|
||||
if (err) {
|
||||
CLReportOSError(CLStr97, err, target);
|
||||
return cwErrRequestFailed;
|
||||
}
|
||||
|
||||
if (!file->outfileowner || file->outfileowner == CmdLineStageMask_Cg) {
|
||||
file->outfileowner = CmdLineStageMask_Cg;
|
||||
OS_SpecToStringRelative(&outfss, NULL, file->outfilename, sizeof(file->outfilename));
|
||||
}
|
||||
|
||||
if (optsCmdLine.verbose)
|
||||
CLReport(CLStr16, "precompiled ", OS_SpecToStringRelative(&outfss, NULL, STSbuf, sizeof(STSbuf)));
|
||||
} else {
|
||||
OS_MakeSpecWithPath(&gTarg->outputDirectory, file->srcfilename, optsCompiler.relPathInOutputDir == 0, &outfss);
|
||||
OS_NameSpecSetExtension(&outfss.name, optsCompiler.pchFileExt[0] ? optsCompiler.pchFileExt : cof->pchFileExt);
|
||||
|
||||
if (!file->outfileowner || file->outfileowner == CmdLineStageMask_Cg) {
|
||||
file->outfileowner = CmdLineStageMask_Cg;
|
||||
OS_NameSpecToString(&outfss.name, file->outfilename, sizeof(file->outfilename));
|
||||
}
|
||||
|
||||
CLReport(CLStr59, OS_SpecToStringRelative(&outfss, NULL, STSbuf, sizeof(STSbuf)));
|
||||
}
|
||||
|
||||
OS_OSSpec_To_FSSpec(&outfss, pchspec);
|
||||
} else {
|
||||
err = OS_MakeSpecWithPath(&gTarg->outputDirectory, file->outfilename, 0, &outfss);
|
||||
if (err) {
|
||||
CLReportOSError(CLStr97, err, file->outfilename);
|
||||
return cwErrRequestFailed;
|
||||
}
|
||||
|
||||
OS_OSSpec_To_FSSpec(&outfss, pchspec);
|
||||
|
||||
if (intarget)
|
||||
CLReport(CLStr60, OS_SpecToStringRelative(&outfss, NULL, STSbuf, sizeof(STSbuf)), intarget);
|
||||
}
|
||||
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CWResult UCBGetResourceFile(CWPluginContext context, CWFileSpec *filespec) {
|
||||
if (optsCmdLine.verbose > 3)
|
||||
CLPrint("Callback: %s\n", "UCBGetResourceFile");
|
||||
|
||||
#line 514
|
||||
DO_INTERNAL_ERROR("UCBGetResourceFile not implemented");
|
||||
return cwErrRequestFailed;
|
||||
}
|
||||
|
||||
CWResult UCBPutResourceFile(CWPluginContext context, const char *prompt, const char *name, CWFileSpec *filespec) {
|
||||
if (optsCmdLine.verbose > 3)
|
||||
CLPrint("Callback: %s\n", "UCBPutResourceFile");
|
||||
|
||||
#line 529
|
||||
DO_INTERNAL_ERROR("UCBPutResourceFile not implemented");
|
||||
return cwErrRequestFailed;
|
||||
}
|
||||
|
||||
static int UnitNameToSBMName(OSSpec *spec, File *srcfile) {
|
||||
const CWObjectFlags *cof;
|
||||
int err;
|
||||
|
||||
cof = Plugin_CL_GetObjectFlags(srcfile->compiler);
|
||||
err = OS_NameSpecChangeExtension(
|
||||
&spec->name,
|
||||
cof->pchFileExt ? cof->pchFileExt : ".sbm",
|
||||
cof->pchFileExt ? (cof->pchFileExt[0] == '.') : 0
|
||||
);
|
||||
return err;
|
||||
}
|
||||
|
||||
CWResult UCBLookUpUnit(CWPluginContext context, const char *name, Boolean isdependency, const void **unitdata, SInt32 *unitdatalength) {
|
||||
if (optsCmdLine.verbose > 3)
|
||||
CLPrint("Callback: %s\n", "UCBLookUpUnit");
|
||||
|
||||
CWFileInfo includeinfo;
|
||||
OSSpec unitspec;
|
||||
OSSpec sbmspec;
|
||||
time_t unittime;
|
||||
UInt32 unitmactime;
|
||||
char sbmpath[256];
|
||||
int err;
|
||||
CWCompilerLinkerContext *c;
|
||||
File *srcfile;
|
||||
File *sbmfile;
|
||||
|
||||
if (context->pluginType == CWDROPINCOMPILERTYPE || context->pluginType == CWDROPINLINKERTYPE)
|
||||
c = static_cast<CWCompilerLinkerContext *>(context);
|
||||
else
|
||||
return cwErrInvalidCallback;
|
||||
|
||||
srcfile = Files_GetFile(&gTarg->files, c->whichfile);
|
||||
#line 591
|
||||
OPTION_ASSERT(srcfile != NULL);
|
||||
|
||||
*unitdata = NULL;
|
||||
*unitdatalength = 0;
|
||||
|
||||
if (optsCompiler.sbmState == OptsCompilerSbmState_1 || optsCompiler.sbmState == OptsCompilerSbmState_3) {
|
||||
if (clState.pluginDebug)
|
||||
CLPrint("UCBLookUpUnit: sbmState == sbmRebuild or sbmClean; failing\n");
|
||||
return cwErrSBMNotFound;
|
||||
}
|
||||
|
||||
includeinfo.fullsearch = 1;
|
||||
includeinfo.dependencyType = isdependency ? cwNormalDependency : cwNoDependency;
|
||||
includeinfo.isdependentoffile = -1;
|
||||
includeinfo.suppressload = 1;
|
||||
if (UCBFindAndLoadFile(context, name, &includeinfo) != cwNoErr) {
|
||||
if (clState.pluginDebug)
|
||||
CLPrint("UCBLookUpUnit: could not find source '%s'; failing\n", name);
|
||||
return cwErrFileNotFound;
|
||||
}
|
||||
|
||||
OS_FSSpec_To_OSSpec(&includeinfo.filespec, &unitspec);
|
||||
sbmspec = unitspec;
|
||||
err = UnitNameToSBMName(&sbmspec, srcfile);
|
||||
if (err) {
|
||||
if (clState.pluginDebug)
|
||||
CLPrint("UCBLookUpUnit: could not make precompiled unit spec for '%s' (%s)\n", name, OS_GetErrText(err));
|
||||
return cwErrRequestFailed;
|
||||
}
|
||||
|
||||
if (optsCompiler.sbmPath[0]) {
|
||||
sbmspec.path = clState.sbmPathSpec;
|
||||
OS_SpecToString(&sbmspec, sbmpath, sizeof(sbmpath));
|
||||
if (clState.pluginDebug)
|
||||
CLPrint("UCBLookUpUnit: Only looking at '%s'\n", sbmpath);
|
||||
} else {
|
||||
OS_NameSpecToString(&sbmspec.name, sbmpath, sizeof(sbmpath));
|
||||
if (clState.pluginDebug)
|
||||
CLPrint("UCBLookUpUnit: searching paths for '%s'\n", sbmpath);
|
||||
}
|
||||
|
||||
includeinfo.fullsearch = 1;
|
||||
includeinfo.dependencyType = isdependency ? cwNormalDependency : cwNoDependency;
|
||||
includeinfo.isdependentoffile = -1;
|
||||
includeinfo.suppressload = 0;
|
||||
if (UCBFindAndLoadFile(context, sbmpath, &includeinfo) != cwNoErr || !includeinfo.filedata) {
|
||||
if (clState.pluginDebug)
|
||||
CLPrint("UCBLookUpUnit: could not find or load precompiled unit file '%s'; failing\n", sbmpath);
|
||||
return cwErrFileNotFound;
|
||||
}
|
||||
|
||||
OS_FSSpec_To_OSSpec(&includeinfo.filespec, &sbmspec);
|
||||
if (includeinfo.filedatatype != cwFileTypePrecompiledHeader) {
|
||||
CLPrint("UCBLookUpUnit: file '%s' does not appear to be precompiled\n", OS_SpecToString(&sbmspec, STSbuf, sizeof(STSbuf)));
|
||||
UCBReleaseFileText(context, includeinfo.filedata);
|
||||
return cwErrRequestFailed;
|
||||
}
|
||||
|
||||
OS_GetFileTime(&unitspec, NULL, &unittime);
|
||||
OS_TimeToMac(unittime, &unitmactime);
|
||||
if (unitmactime != *reinterpret_cast<const UInt32 *>(includeinfo.filedata)) {
|
||||
if (clState.pluginDebug)
|
||||
CLPrint(
|
||||
"UCBLookUpUnit: file '%s' does not have internal timestamp that matches source unit's timestamp (0x%8x != 0x%8x)\n",
|
||||
OS_SpecToString(&sbmspec, STSbuf, sizeof(STSbuf)),
|
||||
unitmactime,
|
||||
*reinterpret_cast<const UInt32 *>(includeinfo.filedata));
|
||||
UCBReleaseFileText(context, includeinfo.filedata);
|
||||
return cwErrRequestFailed;
|
||||
}
|
||||
|
||||
sbmfile = Files_FindFile(&gTarg->pchs, &sbmspec);
|
||||
if (!sbmfile) {
|
||||
sbmfile = File_New();
|
||||
sbmfile->srcfss = unitspec;
|
||||
OS_SpecToString(&sbmfile->srcfss, sbmfile->srcfilename, sizeof(sbmfile->srcfilename));
|
||||
sbmfile->outfss = sbmspec;
|
||||
OS_SpecToString(&sbmfile->outfss, sbmfile->outfilename, sizeof(sbmfile->outfilename));
|
||||
sbmfile->compiler = srcfile->compiler;
|
||||
sbmfile->outfileowner = CmdLineStageMask_Cg;
|
||||
sbmfile->writeToDisk = srcfile->writeToDisk;
|
||||
sbmfile->dropinflags = srcfile->dropinflags;
|
||||
sbmfile->objectflags = srcfile->objectflags;
|
||||
sbmfile->mappingflags = srcfile->mappingflags;
|
||||
Deps_Initialize(&sbmfile->deps, &gTarg->incls);
|
||||
if (!Files_AddFile(&gTarg->pchs, sbmfile))
|
||||
return cwErrRequestFailed;
|
||||
}
|
||||
|
||||
if (clState.pluginDebug)
|
||||
CLPrint("UCBLookUpUnit: success for '%s'\n", name);
|
||||
|
||||
if (optsCmdLine.verbose)
|
||||
CLReport(CLStr62, "unit symbol table", OS_SpecToStringRelative(&sbmspec, NULL, STSbuf, sizeof(STSbuf)));
|
||||
|
||||
*unitdata = includeinfo.filedata;
|
||||
*unitdatalength = includeinfo.filedatalength;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CWResult UCBSBMfiles(CWPluginContext context, short libref) {
|
||||
if (optsCmdLine.verbose > 3)
|
||||
CLPrint("Callback: %s\n", "UCBSBMfiles");
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CWResult UCBStoreUnit(CWPluginContext context, const char *inunitname, CWMemHandle unitdata, CWDependencyTag dependencytag) {
|
||||
if (optsCmdLine.verbose > 3)
|
||||
CLPrint("Callback: %s\n", "UCBStoreUnit");
|
||||
|
||||
char unitname[256];
|
||||
OSSpec sbmspec;
|
||||
int err;
|
||||
Handle h;
|
||||
OSHandle unithand;
|
||||
OSFileHandle fhand;
|
||||
CWCompilerLinkerContext *c;
|
||||
File *srcfile;
|
||||
|
||||
if (optsCompiler.canonicalIncludes) {
|
||||
strcpy(unitname, inunitname);
|
||||
} else if (OS_CanonPath(inunitname, unitname)) {
|
||||
return cwErrInvalidParameter;
|
||||
}
|
||||
|
||||
if (optsCompiler.sbmState == OptsCompilerSbmState_0 || optsCompiler.sbmState == OptsCompilerSbmState_1) {
|
||||
if (context->pluginType == CWDROPINCOMPILERTYPE || context->pluginType == CWDROPINLINKERTYPE)
|
||||
c = static_cast<CWCompilerLinkerContext *>(context);
|
||||
else
|
||||
return cwErrInvalidCallback;
|
||||
|
||||
srcfile = Files_GetFile(&gTarg->files, c->whichfile);
|
||||
#line 791
|
||||
OPTION_ASSERT(srcfile != NULL);
|
||||
|
||||
if (optsCompiler.sbmPath[0]) {
|
||||
err = OS_MakeSpecWithPath(&clState.sbmPathSpec, unitname, 1, &sbmspec);
|
||||
if (err) {
|
||||
if (clState.pluginDebug)
|
||||
CLPrint("UCBStoreUnit: '%s' is a bad unit name (%s)\n", unitname, OS_GetErrText(err));
|
||||
return cwErrInvalidParameter;
|
||||
}
|
||||
} else {
|
||||
err = OS_MakeFileSpec(unitname, &sbmspec);
|
||||
if (err) {
|
||||
if (clState.pluginDebug)
|
||||
CLPrint("UCBStoreUnit: '%s' is a bad filename (%s)\n", unitname, OS_GetErrText(err));
|
||||
return cwErrInvalidParameter;
|
||||
}
|
||||
}
|
||||
|
||||
err = UnitNameToSBMName(&sbmspec, srcfile);
|
||||
if (err) {
|
||||
if (clState.pluginDebug)
|
||||
CLPrint("UCBStoreUnit: could not make precompiled unit form of '%s' (%s)\n", unitname, OS_GetErrText(err));
|
||||
return cwErrInvalidParameter;
|
||||
}
|
||||
|
||||
if (optsCmdLine.verbose)
|
||||
CLReport(CLStr61, "unit symbol table", OS_SpecToStringRelative(&sbmspec, NULL, STSbuf, sizeof(STSbuf)));
|
||||
|
||||
UCBSecretDetachHandle(context, unitdata, &h);
|
||||
OS_DestroyMacHandle(h, &unithand);
|
||||
err = OS_NewFileHandle(&sbmspec, &unithand, 1, &fhand);
|
||||
if (err || (err = OS_FreeFileHandle(&fhand))) {
|
||||
CLReportOSError(CLStr18, err, "precompiled unit", OS_SpecToStringRelative(&sbmspec, NULL, STSbuf, sizeof(STSbuf)));
|
||||
return cwErrRequestFailed;
|
||||
}
|
||||
}
|
||||
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CWResult UCBReleaseUnit(CWPluginContext context, void *unitdata) {
|
||||
if (optsCmdLine.verbose > 3)
|
||||
CLPrint("Callback: %s\n", "UCBReleaseUnit");
|
||||
|
||||
if (!unitdata)
|
||||
return cwErrRequestFailed;
|
||||
return UCBReleaseFileText(context, static_cast<const char *>(unitdata));
|
||||
}
|
||||
|
||||
CWResult UCBUnitNameToFileName(CWPluginContext context, const char *unitname, char *filename) {
|
||||
if (optsCmdLine.verbose > 3)
|
||||
CLPrint("Callback: %s\n", "UCBUnitNameToFileName");
|
||||
|
||||
strcpy(filename, unitname);
|
||||
if (!OS_EqualPath(filename + strlen(filename) - 2, ".p"))
|
||||
strcat(filename, ".p");
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CWResult UCBOSAlert(CWPluginContext context, const char *message, OSErr errorcode) {
|
||||
if (optsCmdLine.verbose > 3)
|
||||
CLPrint("Callback: %s\n", "UCBOSAlert");
|
||||
if (CheckForUserBreak())
|
||||
return cwErrUserCanceled;
|
||||
|
||||
char errormessage[256];
|
||||
GetSysErrText(errorcode, errormessage);
|
||||
CLStyledMessageDispatch(
|
||||
static_cast<shellContextType *>(context->shellContext)->plugin,
|
||||
NULL,
|
||||
errorcode,
|
||||
CLStyledMessageDispatch_Type4,
|
||||
"%\n(%)\n",
|
||||
message ? message : "",
|
||||
errormessage
|
||||
);
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CWResult UCBOSErrorMessage(CWPluginContext context, const char *message, OSErr errorcode) {
|
||||
if (optsCmdLine.verbose > 3)
|
||||
CLPrint("Callback: %s\n", "UCBOSErrorMessage");
|
||||
if (!errorcode)
|
||||
return cwNoErr;
|
||||
if (CheckForUserBreak())
|
||||
return cwErrUserCanceled;
|
||||
|
||||
char errormessage[256];
|
||||
GetSysErrText(errorcode, errormessage);
|
||||
CLStyledMessageDispatch(
|
||||
static_cast<shellContextType *>(context->shellContext)->plugin,
|
||||
NULL,
|
||||
errorcode,
|
||||
CLStyledMessageDispatch_Type4,
|
||||
"%\n%\n",
|
||||
message ? message : "",
|
||||
errormessage
|
||||
);
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CWResult UCBGetModifiedFiles(CWPluginContext context, SInt32 *modifiedFileCount, const SInt32 **modifiedFiles) {
|
||||
if (optsCmdLine.verbose > 3)
|
||||
CLPrint("Callback: %s\n", "UCBGetModifiedFiles");
|
||||
|
||||
*modifiedFileCount = 0;
|
||||
#line 949
|
||||
DO_INTERNAL_ERROR("CWGetModifiedFiles not implemented!\n");
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CWResult UCBGetSuggestedObjectFileSpec(CWPluginContext context, SInt32 whichfile, CWFileSpec *fileSpec) {
|
||||
if (optsCmdLine.verbose > 3)
|
||||
CLPrint("Callback: %s\n", "UCBGetSuggestedObjectFileSpec");
|
||||
|
||||
File *file;
|
||||
if (!(file = Files_GetFile(&gTarg->files, whichfile)))
|
||||
return cwErrUnknownFile;
|
||||
|
||||
if (!GetOutputFile(file, CmdLineStageMask_Cg))
|
||||
return cwErrRequestFailed;
|
||||
|
||||
OS_OSSpec_To_FSSpec(&file->outfss, fileSpec);
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CWResult UCBGetStoredObjectFileSpec(CWPluginContext context, SInt32 whichfile, CWFileSpec *fileSpec) {
|
||||
if (optsCmdLine.verbose > 3)
|
||||
CLPrint("Callback: %s\n", "UCBGetStoredObjectFileSpec");
|
||||
|
||||
File *file;
|
||||
if (!(file = Files_GetFile(&gTarg->files, whichfile)))
|
||||
return cwErrUnknownFile;
|
||||
if (file->outfileowner != CmdLineStageMask_Cg) {
|
||||
#line 993
|
||||
DO_INTERNAL_ERROR("Lost stored object file spec for '%s'\n", file->srcfilename);
|
||||
return cwErrRequestFailed;
|
||||
} else {
|
||||
OS_OSSpec_To_FSSpec(&file->outfss, fileSpec);
|
||||
return cwNoErr;
|
||||
}
|
||||
}
|
||||
|
||||
CWResult UCBGetFrameworkCount(CWPluginContext context, SInt32 *frameworkCount) {
|
||||
if (optsCmdLine.verbose > 3)
|
||||
CLPrint("Callback: %s\n", "UCBGetFrameworkCount");
|
||||
|
||||
*frameworkCount = Frameworks_GetCount();
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CWResult UCBGetFrameworkInfo(CWPluginContext context, SInt32 whichFramework, CWFrameworkInfo *frameworkInfo) {
|
||||
if (optsCmdLine.verbose > 3)
|
||||
CLPrint("Callback: %s\n", "UCBGetFrameworkCount");
|
||||
|
||||
Paths_FWInfo *info;
|
||||
if ((info = Frameworks_GetInfo(whichFramework))) {
|
||||
OS_OSSpec_To_FSSpec(&info->fileSpec, &frameworkInfo->fileSpec);
|
||||
strncpy(frameworkInfo->version, info->version.s, sizeof(frameworkInfo->version));
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
return cwErrFileNotFound;
|
||||
}
|
||||
|
||||
CWCompilerLinkerCallbacks sCompilerLinkerCallbacks = {
|
||||
UCBCachePrecompiledHeader,
|
||||
UCBLoadObjectData,
|
||||
UCBStoreObjectData,
|
||||
UCBFreeObjectData,
|
||||
UCBDisplayLines,
|
||||
UCBBeginSubCompile,
|
||||
UCBEndSubCompile,
|
||||
UCBGetPrecompiledHeaderSpec,
|
||||
UCBGetResourceFile,
|
||||
UCBPutResourceFile,
|
||||
UCBLookUpUnit,
|
||||
UCBSBMfiles,
|
||||
UCBStoreUnit,
|
||||
UCBReleaseUnit,
|
||||
UCBUnitNameToFileName,
|
||||
UCBOSErrorMessage,
|
||||
UCBOSAlert,
|
||||
UCBGetModifiedFiles,
|
||||
UCBGetSuggestedObjectFileSpec,
|
||||
UCBGetStoredObjectFileSpec,
|
||||
NULL,
|
||||
UCBGetFrameworkCount,
|
||||
UCBGetFrameworkInfo
|
||||
};
|
||||
|
||||
CWCompilerLinkerContext::CWCompilerLinkerContext()
|
||||
:
|
||||
CWPluginPrivateContext(clState.plugintype, sizeof(CWCompilerLinkerContext)) {
|
||||
targetinfo = static_cast<CWTargetInfo *>(xmalloc("context", sizeof(CWTargetInfo)));
|
||||
memset(targetinfo, 0, sizeof(CWTargetInfo));
|
||||
|
||||
if (gTarg) {
|
||||
targetinfo->targetCPU = gTarg->cpu;
|
||||
targetinfo->targetOS = gTarg->os;
|
||||
} else {
|
||||
targetinfo->targetOS = targetOSAny;
|
||||
targetinfo->targetCPU = targetCPUAny;
|
||||
}
|
||||
|
||||
whichfile = 0;
|
||||
memset(&sourcefile, 0, sizeof(sourcefile));
|
||||
sourcetext = NULL;
|
||||
sourcetextsize = 0;
|
||||
|
||||
preprocess = 0;
|
||||
autoprecompile = 0;
|
||||
precompile = 0;
|
||||
cachingPCH = 0;
|
||||
debuginfo = 0;
|
||||
fileID = 0;
|
||||
memset(&browseoptions, 0, sizeof(browseoptions));
|
||||
reserved = NULL;
|
||||
sequenceID = 0;
|
||||
parentPB = NULL;
|
||||
targetStorage = NULL;
|
||||
texthandle = NULL;
|
||||
memset(&targetinfo_V7, 0, sizeof(targetinfo_V7));
|
||||
|
||||
callbacks = &sCompilerLinkerCallbacks;
|
||||
}
|
||||
|
||||
CWCompilerLinkerContext::~CWCompilerLinkerContext() {
|
||||
xfree(targetinfo);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,13 +1,220 @@
|
||||
/*
|
||||
P 9C50 | _UCBParserAddAccessPath
|
||||
P 9DE4 | _UCBParserSwapAccessPaths
|
||||
P 9E90 | _UCBParserSetNamedPreferences
|
||||
P 9F50 | _UCBParserSetFileOutputName
|
||||
P A03C | _UCBParserSetOutputFileDirectory
|
||||
P A110 | _UCBParserAddOverlay1Group
|
||||
P A1EC | _UCBParserAddOverlay1
|
||||
P A2D0 | _UCBParserAddSegment
|
||||
P A364 | _UCBParserSetSegment
|
||||
P A400 | ___ct__15CWParserContextFv
|
||||
P A480 | ___dt__15CWParserContextFv
|
||||
*/
|
||||
#include "cmdline.h"
|
||||
#include "plugin_internal.h"
|
||||
|
||||
extern char STSbuf[256];
|
||||
|
||||
CWResult UCBParserAddAccessPath(CWPluginContext context, const CWNewAccessPathInfo *api) {
|
||||
OSSpec oss;
|
||||
Paths *paths;
|
||||
Path *path;
|
||||
int err;
|
||||
|
||||
if ((err = OS_FSSpec_To_OSSpec(&api->pathSpec, &oss))) {
|
||||
context->callbackOSError = OS_MacError(err);
|
||||
return cwErrInvalidParameter;
|
||||
}
|
||||
|
||||
if (optsCmdLine.verbose > 2)
|
||||
CLReport(CLStr77, " search path", OS_PathSpecToString(&oss.path, STSbuf, sizeof(STSbuf)));
|
||||
|
||||
if ((api->type & cwAccessPathTypeFlag1) == 0)
|
||||
paths = &gTarg->sysPaths;
|
||||
else
|
||||
paths = &gTarg->userPaths;
|
||||
path = Path_New(&oss.path);
|
||||
|
||||
path->flags = api->type & cwAccessPathTypeFlag2;
|
||||
if ((api->position >= 0) ? (Paths_InsertPath(paths, api->position, path) == 0) : (Paths_AddPath(paths, path) == 0))
|
||||
return cwErrRequestFailed;
|
||||
|
||||
if (api->recursive) {
|
||||
Paths_GatherRecurse(path);
|
||||
if (CheckForUserBreak())
|
||||
return cwErrUserCanceled;
|
||||
}
|
||||
|
||||
if (!(api->type & cwAccessPathTypeFlag1))
|
||||
static_cast<shellContextType *>(context->shellContext)->systemAccessPathsChanged = 1;
|
||||
else
|
||||
static_cast<shellContextType *>(context->shellContext)->userAccessPathsChanged = 1;
|
||||
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CWResult UCBParserSwapAccessPaths(CWPluginContext context) {
|
||||
Path *tmp;
|
||||
UInt16 idx;
|
||||
|
||||
for (idx = 0; idx < Paths_Count(&gTarg->sysPaths); idx++) {
|
||||
tmp = Paths_GetPath(&gTarg->sysPaths, idx);
|
||||
if (!(tmp->flags & cwAccessPathTypeFlag2)) {
|
||||
Paths_AddPath(&gTarg->userPaths, tmp);
|
||||
Paths_RemovePath(&gTarg->sysPaths, idx);
|
||||
idx--;
|
||||
}
|
||||
}
|
||||
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
int (*PrefPanelsChangedCallback)(const char *);
|
||||
|
||||
CWResult UCBParserSetNamedPreferences(CWPluginContext context, const char *panelName, Handle paneldata) {
|
||||
PrefPanel *panel;
|
||||
|
||||
panel = Prefs_FindPanel(panelName);
|
||||
if (!panel) {
|
||||
panel = PrefPanel_New(panelName, *paneldata, GetHandleSize(paneldata));
|
||||
if (!panel || !Prefs_AddPanel(panel))
|
||||
return cwErrRequestFailed;
|
||||
} else {
|
||||
if (!PrefPanel_PutHandle(panel, paneldata))
|
||||
return cwErrRequestFailed;
|
||||
}
|
||||
|
||||
if (PrefPanelsChangedCallback)
|
||||
PrefPanelsChangedCallback(panelName);
|
||||
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CWResult UCBParserSetFileOutputName(CWPluginContext context, SInt32 position, short which, const char *outfilename) {
|
||||
if (position < 0)
|
||||
return cwErrInvalidParameter;
|
||||
|
||||
File *file = Files_GetFile(&gTarg->files, position);
|
||||
if (!file)
|
||||
return cwErrUnknownFile;
|
||||
|
||||
if (file->outfileowner)
|
||||
CLReportError(CLStr103, file->srcfilename, file->outfilename);
|
||||
|
||||
strcpy(file->outfilename, outfilename);
|
||||
if (which == 1)
|
||||
file->outfileowner = CmdLineStageMask_Cg;
|
||||
else if (which == 2)
|
||||
file->outfileowner = CmdLineStageMask_Pp;
|
||||
else if (which == 3)
|
||||
file->outfileowner = CmdLineStageMask_Ds;
|
||||
else
|
||||
return cwErrInvalidParameter;
|
||||
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CWResult UCBParserSetOutputFileDirectory(CWPluginContext context, const CWFileSpec *idefss) {
|
||||
OSSpec fss;
|
||||
int err;
|
||||
|
||||
if ((err = OS_FSSpec_To_OSSpec(idefss, &fss))) {
|
||||
context->callbackOSError = OS_MacError(err);
|
||||
return cwErrInvalidParameter;
|
||||
}
|
||||
|
||||
gTarg->outputDirectory = fss.path;
|
||||
context->outputFileDirectory = *idefss;
|
||||
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CWResult UCBParserAddOverlay1Group(CWPluginContext context, const char *name, const CWAddr64 *addr, SInt32 *newGroupNumber) {
|
||||
if (gTarg->linkmodel != LinkModel2)
|
||||
return cwErrInvalidCallback;
|
||||
|
||||
OvlGroup *grp;
|
||||
OvlAddr oaddr;
|
||||
oaddr.hi = addr->hi;
|
||||
oaddr.lo = addr->lo;
|
||||
|
||||
grp = OvlGroup_New(name, oaddr);
|
||||
if (!grp)
|
||||
return cwErrRequestFailed;
|
||||
if (!Overlays_AddOvlGroup(&gTarg->linkage.overlays, grp, newGroupNumber))
|
||||
return cwErrRequestFailed;
|
||||
|
||||
++context->numOverlayGroups;
|
||||
if (optsCmdLine.verbose > 2)
|
||||
CLReport(CLStr79, name, oaddr.hi, oaddr.lo);
|
||||
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CWResult UCBParserAddOverlay1(CWPluginContext context, const char *name, SInt32 groupNumber, SInt32 *newOverlayNumber) {
|
||||
if (gTarg->linkmodel != LinkModel2)
|
||||
return cwErrInvalidCallback;
|
||||
|
||||
OvlGroup *grp;
|
||||
Overlay *ovl;
|
||||
|
||||
grp = Overlays_GetOvlGroup(&gTarg->linkage.overlays, groupNumber);
|
||||
if (!grp)
|
||||
return cwErrRequestFailed;
|
||||
ovl = Overlay_New(name);
|
||||
if (!ovl)
|
||||
return cwErrOutOfMemory;
|
||||
if (!OvlGroup_AddOverlay(grp, ovl, newOverlayNumber))
|
||||
return cwErrOutOfMemory;
|
||||
|
||||
if (optsCmdLine.verbose > 2)
|
||||
CLReport(CLStr78, name, grp->name);
|
||||
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CWResult UCBParserAddSegment(CWPluginContext context, const char *name, short attrs, SInt32 *newSegmentNumber) {
|
||||
if (gTarg->linkmodel != LinkModel1)
|
||||
return cwErrInvalidCallback;
|
||||
|
||||
Segment *seg;
|
||||
UInt16 index;
|
||||
|
||||
seg = Segment_New(name, attrs);
|
||||
if (!Segments_AddSegment(&gTarg->linkage.segs, seg, &index))
|
||||
return cwErrRequestFailed;
|
||||
|
||||
*newSegmentNumber = index;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CWResult UCBParserSetSegment(CWPluginContext context, SInt32 segmentNumber, const char *name, short attrs) {
|
||||
if (gTarg->linkmodel != LinkModel1)
|
||||
return cwErrInvalidCallback;
|
||||
|
||||
Segment *seg = Segments_GetSegment(&gTarg->linkage.segs, segmentNumber);
|
||||
if (!seg)
|
||||
return cwErrUnknownSegment;
|
||||
|
||||
strncpy(seg->name, name, sizeof(seg->name));
|
||||
seg->name[sizeof(seg->name) - 1] = 0;
|
||||
seg->attrs = attrs;
|
||||
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
static CWParserCallbacks parser_cb = {
|
||||
UCBParserAddAccessPath,
|
||||
UCBParserSwapAccessPaths,
|
||||
UCBParserSetNamedPreferences,
|
||||
UCBParserSetFileOutputName,
|
||||
UCBParserSetOutputFileDirectory,
|
||||
UCBParserAddOverlay1Group,
|
||||
UCBParserAddOverlay1,
|
||||
UCBParserAddSegment,
|
||||
UCBParserSetSegment
|
||||
};
|
||||
|
||||
CWParserContext::CWParserContext() : CWPluginPrivateContext(CWDROPINPARSERTYPE, -1) {
|
||||
args = NULL;
|
||||
os = 0;
|
||||
cpu = 0;
|
||||
numPlugins = 0;
|
||||
plugins = NULL;
|
||||
numPanels = 0;
|
||||
panelNames = NULL;
|
||||
panel_args = NULL;
|
||||
plugin_args = NULL;
|
||||
callbacks = &parser_cb;
|
||||
}
|
||||
|
||||
CWParserContext::~CWParserContext() {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user