summaryrefslogtreecommitdiff
path: root/command_line/PluginLib/Src/Library/CWParserPluginsPrivate.cpp
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2023-01-15 12:14:05 +0000
committerAsh Wolf <ninji@wuffs.org>2023-01-15 12:14:05 +0000
commit35d488e972a9dd75ce3867c000405f128b79c615 (patch)
treee3319a23d9aa0d4725f88a99fdd5131488a334a9 /command_line/PluginLib/Src/Library/CWParserPluginsPrivate.cpp
parent8078e7f897aaae9b492b22475060052d68b9c547 (diff)
downloadMWCC-35d488e972a9dd75ce3867c000405f128b79c615.tar.gz
MWCC-35d488e972a9dd75ce3867c000405f128b79c615.zip
reorganise things a bit to align further with the actual names/structure
Diffstat (limited to 'command_line/PluginLib/Src/Library/CWParserPluginsPrivate.cpp')
-rw-r--r--command_line/PluginLib/Src/Library/CWParserPluginsPrivate.cpp207
1 files changed, 207 insertions, 0 deletions
diff --git a/command_line/PluginLib/Src/Library/CWParserPluginsPrivate.cpp b/command_line/PluginLib/Src/Library/CWParserPluginsPrivate.cpp
new file mode 100644
index 0000000..6973b4d
--- /dev/null
+++ b/command_line/PluginLib/Src/Library/CWParserPluginsPrivate.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 **bdate, const char **btime) {
+ CWParserContext *pc;
+ if (!(pc = GetContext(context)))
+ return cwErrInvalidCallback;
+ if (!bdate)
+ return cwErrInvalidParameter;
+ if (!btime)
+ return cwErrInvalidParameter;
+ *bdate = pc->build_date;
+ *btime = 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, Handle 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);
+}