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/uContextParser.cpp | |
parent | b8df05413a4e8b299de07b915cddce73a3bb16e3 (diff) | |
download | MWCC-775b6861666af36d317fb577cf489e2c6377f878.tar.gz MWCC-775b6861666af36d317fb577cf489e2c6377f878.zip |
add tons of stuff
Diffstat (limited to '')
-rw-r--r-- | unsorted/uContextParser.cpp | 207 |
1 files changed, 207 insertions, 0 deletions
diff --git a/unsorted/uContextParser.cpp b/unsorted/uContextParser.cpp new file mode 100644 index 0000000..be1aa0a --- /dev/null +++ b/unsorted/uContextParser.cpp @@ -0,0 +1,207 @@ +#include "plugin_internal.h" + +static CWParserContext *GetContext(CWPluginContext context) { + if (context && (context->pluginType == CWDROPINPARSERTYPE)) + return static_cast<CWParserContext *>(context); + else + return 0; +} + +CW_CALLBACK CWParserGetBuildDate(CWPluginContext context, const char **buildDate, const char **buildTime) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!buildDate) + return cwErrInvalidParameter; + if (!buildTime) + return cwErrInvalidParameter; + *buildDate = pc->build_date; + *buildTime = pc->build_time; + return cwNoErr; +} + +CW_CALLBACK CWParserGetCommandLine(CWPluginContext context, CWCommandLineArgs **args) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!args) + return cwErrInvalidParameter; + *args = pc->args; + return cwNoErr; +} + +CW_CALLBACK CWParserGetTargetInfo(CWPluginContext context, CWDataType *cpu, CWDataType *os) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!cpu) + return cwErrInvalidParameter; + if (!os) + return cwErrInvalidParameter; + *cpu = pc->cpu; + *os = pc->os; + return cwNoErr; +} + +CW_CALLBACK CWParserGetToolInfo(CWPluginContext context, const ToolVersionInfo **toolVersionInfo) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!toolVersionInfo) + return cwErrInvalidParameter; + *toolVersionInfo = pc->build_tool; + return cwNoErr; +} + +CW_CALLBACK CWParserGetPlugins(CWPluginContext context, int *numPlugins, const CLPluginInfo **pluginInfo) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!numPlugins) + return cwErrInvalidParameter; + if (!pluginInfo) + return cwErrInvalidParameter; + *numPlugins = pc->numPlugins; + *pluginInfo = pc->plugins; + return cwNoErr; +} + +CW_CALLBACK CWParserGetPanels(CWPluginContext context, int *numPanels, const char ***panelNames) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!numPanels) + return cwErrInvalidParameter; + if (!panelNames) + return cwErrInvalidParameter; + *numPanels = pc->numPanels; + *panelNames = pc->panelNames; + return cwNoErr; +} + +CW_CALLBACK CWParserStoreCommandLineForPanel(CWPluginContext context, int index, const CWCommandLineArgs *args) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (index < 0 || index >= pc->numPanels) + return cwErrInvalidParameter; + if (!args) + return cwErrInvalidParameter; + pc->panel_args[index] = *args; + return cwNoErr; +} + +CW_CALLBACK CWParserStoreCommandLineForPlugin(CWPluginContext context, int index, const CWCommandLineArgs *args) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (index < 0 || index >= pc->numPlugins) + return cwErrInvalidParameter; + if (!args) + return cwErrInvalidParameter; + pc->plugin_args[index] = *args; + return cwNoErr; +} + +CW_CALLBACK CWParserSetNamedPreferences(CWPluginContext context, const char *panelName, CWMemHandle paneldata) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!panelName) + return cwErrInvalidParameter; + return pc->callbacks->cbParserSetNamedPreferences(pc, panelName, paneldata); +} + +CW_CALLBACK CWParserAddAccessPath(CWPluginContext context, const CWNewAccessPathInfo *api) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!api) + return cwErrInvalidParameter; + return pc->callbacks->cbParserAddAccessPath(pc, api); +} + +CW_CALLBACK CWParserSwapAccessPaths(CWPluginContext context) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + return pc->callbacks->cbParserSwapAccessPaths(pc); +} + +CW_CALLBACK CWParserSetOutputFileDirectory(CWPluginContext context, const CWFileSpec *idefss) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!idefss) + return cwErrInvalidParameter; + return pc->callbacks->cbParserSetOutputFileDirectory(pc, idefss); +} + +CW_CALLBACK CWParserSetFileOutputName(CWPluginContext context, SInt32 position, short which, const char *outfilename) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!outfilename) + return cwErrInvalidParameter; + return pc->callbacks->cbParserSetFileOutputName(pc, position, which, outfilename); +} + +CW_CALLBACK CWParserAddOverlay1Group(CWPluginContext context, const char *name, const CWAddr64 *addr, SInt32 *newGroupNumber) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!name) + return cwErrInvalidParameter; + if (!addr) + return cwErrInvalidParameter; + if (!newGroupNumber) + return cwErrInvalidParameter; + return pc->callbacks->cbParserAddOverlay1Group(pc, name, addr, newGroupNumber); +} + +CW_CALLBACK CWParserAddOverlay1(CWPluginContext context, const char *name, SInt32 groupNumber, SInt32 *newOverlayNumber) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!name) + return cwErrInvalidParameter; + if (!newOverlayNumber) + return cwErrInvalidParameter; + return pc->callbacks->cbParserAddOverlay1(pc, name, groupNumber, newOverlayNumber); +} + +CW_CALLBACK CWParserAddSegment(CWPluginContext context, const char *name, short attrs, SInt32 *newSegmentNumber) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!name) + return cwErrInvalidParameter; + if (!newSegmentNumber) + return cwErrInvalidParameter; + return pc->callbacks->cbParserAddSegment(pc, name, attrs, newSegmentNumber); +} + +CW_CALLBACK CWParserSetSegment(CWPluginContext context, SInt32 segmentNumber, const char *name, short attrs) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!name) + return cwErrInvalidParameter; + return pc->callbacks->cbParserSetSegment(pc, segmentNumber, name, attrs); +} + +CW_CALLBACK CWParserCreateVirtualFile(CWPluginContext context, const char *name, CWMemHandle text) { + CWNewTextDocumentInfo info; + info.documentname = name; + info.text = text; + info.markDirty = 1; + return CWCreateNewTextDocument(context, &info); +} + +CW_CALLBACK CWParserDisplayTextHandle(CWPluginContext context, const char *name, CWMemHandle text) { + CWNewTextDocumentInfo info; + info.documentname = name; + info.text = text; + info.markDirty = 0; + return CWCreateNewTextDocument(context, &info); +} |