diff options
author | Ash Wolf <ninji@wuffs.org> | 2022-10-14 23:15:32 +0100 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2022-10-14 23:15:32 +0100 |
commit | 775b6861666af36d317fb577cf489e2c6377f878 (patch) | |
tree | 2ae8c829eb861c85a6e2b5acf42f51919a0d78f2 /unsorted/ParserFace.c | |
parent | b8df05413a4e8b299de07b915cddce73a3bb16e3 (diff) | |
download | MWCC-775b6861666af36d317fb577cf489e2c6377f878.tar.gz MWCC-775b6861666af36d317fb577cf489e2c6377f878.zip |
add tons of stuff
Diffstat (limited to '')
-rw-r--r-- | unsorted/ParserFace.c (renamed from ParserFace.c) | 156 |
1 files changed, 114 insertions, 42 deletions
diff --git a/ParserFace.c b/unsorted/ParserFace.c index 7ce84e5..24f3213 100644 --- a/ParserFace.c +++ b/unsorted/ParserFace.c @@ -1,31 +1,14 @@ -#include "UCWInterface.h" +#include "mwcc_decomp.h" +const char *failedCallback; +jmp_buf exit_plugin; struct ParseOptsType parseopts; -// TODO move me imports -extern CWResult CWSecretGetNamedPreferences(CWPluginContext context, const char *name, Handle *pHandle); -extern CWResult CWParserSetNamedPreferences(CWPluginContext context, const char *name, Handle pHandle); -extern CWResult CWParserGetCommandLine(CWPluginContext context, CWCommandLineArgs **pArgs); -extern CWResult CWParserGetToolInfo(CWPluginContext context, struct ToolVersionInfo **pToolVersion); -extern CWResult CWParserGetTargetInfo(CWPluginContext context, unsigned long *pCpu, unsigned long *pOs); -extern CWResult CWParserGetPanels(CWPluginContext context, int *pNumPanels, char ***pPanelNames); -extern CWResult CWParserGetPlugins(CWPluginContext context, int *pNumPlugins, struct CLPluginInfo **pPlugins); -extern void/*?*/ CWGetPluginRequest(CWPluginContext context, long *request); -extern void/*?*/ CWDonePluginRequest(CWPluginContext context, CWResult result); -extern void *pTool; -extern void SetupParserToolOptions(); -extern void CLPReportError(short code, ...); -extern unsigned char ParserToolMatchesPlugin(unsigned long plugintype, unsigned long language, unsigned long cpu, unsigned long os); -extern unsigned char ParserToolHandlesPanels(int numPanels, char **panelNames); -// TODO move me imports - -char *failedCallback; - static CWResult SetupParamBlock(CWPluginContext context) { - struct PCmdLineEnvir cle; - Handle h; - int x; CWResult result; + int x; + Handle h; + PCmdLineEnvir cle; memset(&parseopts, 0, sizeof(parseopts)); parseopts.context = context; @@ -34,7 +17,7 @@ static CWResult SetupParamBlock(CWPluginContext context) { if (result) return result; - cle = **((struct PCmdLineEnvir **) h); + cle = **((PCmdLineEnvir **) h); parseopts.underIDE = cle.underIDE; parseopts.ioRows = cle.rows; parseopts.ioCols = cle.cols; @@ -80,28 +63,80 @@ static CWResult SetupOptions(CWPluginContext context) { static CWResult Parse(CWPluginContext context) { CWResult result; - // TODO - return result; + parseopts.success = 1; + parseopts.currentSegment = 1; + parseopts.currentOverlayGroup = 0; + parseopts.currentOverlay = 0; + + Arg_InitToolArgs(&linkargs); + Arg_InitToolArgs(&prelinkargs); + Arg_InitToolArgs(&postlinkargs); + + if (pTool->PreParse) + parseopts.success &= pTool->PreParse(); + + Arg_Init(parseopts.args->argc, parseopts.args->argv); + parseopts.noOptions = Arg_IsEmpty(); + parseopts.success &= Options_Parse(Options_GetOptions(), OFLAGS_1) && !parseopts.hadErrors; + Arg_Reset(); + + result = Parser_StorePanels(context); + if (result) + return result; + + if (pTool->MidParse && parseopts.success) + parseopts.success &= pTool->MidParse(); + + result = Parser_StorePanels(context); + if (result) + return result; + + if (parseopts.showHelp && parseopts.success) + parseopts.success &= Options_DisplayHelp(); + + Arg_Reset(); + if (parseopts.success) + parseopts.success &= Options_Parse(Options_GetOptions(), 0) && !parseopts.hadErrors; + + if (pTool->PostParse && parseopts.success) + parseopts.success &= pTool->PostParse(); + + Arg_Terminate(); + + return (parseopts.success && !parseopts.hadErrors) ? cwNoErr : cwErrRequestFailed; } -Handle Parser_FindPrefPanel(char *name) { - Handle h; +Handle Parser_FindPrefPanel(const char *name) { int idx; + Handle h; + + for (idx = 0; idx < pTool->numPrefDataPanels; idx++) { + if (!ustrcmp(name, pTool->prefDataPanels[idx].name)) { + h = NewHandle(pTool->prefDataPanels[idx].size); + if (!h) + return NULL; + + HLock(h); + memcpy(*h, pTool->prefDataPanels[idx].ptr, pTool->prefDataPanels[idx].size); + HUnlock(h); + return h; + } + } - // TODO pTool + return NULL; } CWResult Parser_StorePanels(CWPluginContext context) { int idx; CWResult result; - char *name; + const char *name; Handle h; for (idx = 0; idx < parseopts.numPanels; idx++) { name = parseopts.panelNames[idx]; h = Parser_FindPrefPanel(name); if (h) { - result = CWParserSetNamedPreferences(parseopts.context, name, h); + result = CWParserSetNamedPreferences(parseopts.context, name, (CWMemHandle) h); if (result) { CLPReportError(68, name); return result; @@ -109,14 +144,53 @@ CWResult Parser_StorePanels(CWPluginContext context) { } } - return 0; + return cwNoErr; } static CWResult StoreResults(CWPluginContext context) { - // TODO Arg + int idx; // r25 + CWResult result; + CWCommandLineArgs args; + UInt32 id; // r8 + UInt32 lg; // r10 + + result = Parser_StorePanels(context); + if (result) + return result; + + for (idx = 0; idx < parseopts.numPlugins; idx++) { + if (parseopts.plugins[idx].plugintype == CWDROPINLINKERTYPE && parseopts.plugins[idx].storeCommandLine) { + if (parseopts.plugins[idx].dropinflags & isPreLinker) { + Arg_ToolArgsForPlugin(&prelinkargs, &args); + } else if (parseopts.plugins[idx].dropinflags & isPostLinker) { + Arg_ToolArgsForPlugin(&postlinkargs, &args); + } else { + Arg_ToolArgsForPlugin(&linkargs, &args); + } + result = CWParserStoreCommandLineForPlugin(parseopts.context, idx, &args); + if (result) + return result; + } else if (parseopts.plugins[idx].storeCommandLine) { + id = parseopts.plugins[idx].plugintype; + lg = parseopts.plugins[idx].language; + fprintf(stderr, + "*** No support for %c%c%c%c/%c%c%c%c tool\n", + (id & 0xFF000000) >> 24, + (id & 0x00FF0000) >> 16, + (id & 0x0000FF00) >> 8, + (id & 0x000000FF), + (lg & 0xFF000000) >> 24, + (lg & 0x00FF0000) >> 16, + (lg & 0x0000FF00) >> 8, + (lg & 0x000000FF) + ); + } + } + + return cwNoErr; } -short CWParser_GetDropInFlags(const DropInFlags **flags, long *flagsSize) { +short CWParser_GetDropInFlags(const DropInFlags **flags, SInt32 *flagsSize) { static const DropInFlags sFlags = { kCurrentDropInFlagsVersion, CWFOURCHAR('P','a','r','s'), @@ -143,7 +217,7 @@ short CWParser_GetDisplayName(const char **displayName) { } short CWParser_GetPanelList(const CWPanelList **panelList) { - static const CWPanelList sPanelList = { + static CWPanelList sPanelList = { kCurrentCWFamilyListVersion, 0, 0 @@ -153,9 +227,9 @@ short CWParser_GetPanelList(const CWPanelList **panelList) { } short CWParser_GetTargetList(const CWTargetList **targetList) { - static const unsigned long sCPU = '****'; - static const unsigned long sOS = '****'; - static const CWTargetList sTargetList = { + static CWDataType sCPU = '****'; + static CWDataType sOS = '****'; + static CWTargetList sTargetList = { kCurrentCWTargetListVersion, 1, &sCPU, @@ -179,16 +253,14 @@ short Parser_SupportsPlugin(struct CLPluginInfo *pluginfo, CWDataType cpu, CWDat return 0; } -short Parser_SupportsPanels(int numPanels, char **panelNames, Boolean *isSupported) { +short Parser_SupportsPanels(int numPanels, const char **panelNames, Boolean *isSupported) { *isSupported = ParserToolHandlesPanels(numPanels, panelNames); return 0; } -jmp_buf exit_plugin; - short parser_main(CWPluginContext context) { - long request; CWResult result; + SInt32 request; CWGetPluginRequest(context, &request); result = setjmp(exit_plugin); |