summaryrefslogtreecommitdiff
path: root/UCLTMain.c
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2022-10-11 03:18:42 +0100
committerAsh Wolf <ninji@wuffs.org>2022-10-11 03:18:42 +0100
commit26b57fbea1a969ef6405365ff78391e9d3605621 (patch)
treeb6f14f5c083d0fbb42c5495eea7c74099ff45315 /UCLTMain.c
parent7d4bee5f8f28b72610c8518e5cb9dc145c68b816 (diff)
downloadMWCC-26b57fbea1a969ef6405365ff78391e9d3605621.tar.gz
MWCC-26b57fbea1a969ef6405365ff78391e9d3605621.zip
add cmakelists for CLion, tons and tons of reorganisation using new info from the Pro8 compiler
Diffstat (limited to '')
-rw-r--r--UCLTMain.c130
1 files changed, 68 insertions, 62 deletions
diff --git a/UCLTMain.c b/UCLTMain.c
index 7da89af..22359dc 100644
--- a/UCLTMain.c
+++ b/UCLTMain.c
@@ -1,6 +1,6 @@
#include "UCWInterface.h"
-static short CLT_dummymain() {
+static short CLT_dummymain(void *context) {
return 0;
}
@@ -18,9 +18,9 @@ static short CLT_GetDropInFlags(const DropInFlags **flags, long *flagsSize) {
return 0;
}
-static short CLT_GetDropInName(const char **dropInName) {
+static short CLT_GetDropInName(const char **dropinName) {
static const char *sDropInName = "Command-Line Driver";
- *dropInName = sDropInName;
+ *dropinName = sDropInName;
return 0;
}
@@ -73,7 +73,7 @@ static short CLT_GetVersionInfo(const VersionInfo **versioninfo) {
return 0;
}
-static short CLT_GetFileTypeMappings(const OSFileTypeMappingList **mappingList) {
+static short CLT_GetFileTypeMappings(const OSFileTypeMappingList **mappinglist) {
static const OSFileTypeMapping ftmes[2] = {
{CWFOURCHAR('B','r','w','s'), "DubL", 4, 0, 0},
{CWFOURCHAR('M','M','P','r'), "looc", 4, 0, 0}
@@ -82,7 +82,7 @@ static short CLT_GetFileTypeMappings(const OSFileTypeMappingList **mappingList)
2,
ftmes
};
- *mappingList = &ftml;
+ *mappinglist = &ftml;
return 0;
}
@@ -102,14 +102,15 @@ static int RegisterStaticCmdLinePlugin() {
return RegisterStaticPlugin(&clcb);
}
-const char *STR12000[100]; // TODO do me later
+// TODO do me later - this comes from CmdLine/Project/Resources/CLErrors.r
+const char *STR12000[100];
static int RegisterCmdLineResources() {
return RegisterResource("Command-line strings", 12000, &STR12000);
}
-static int special_debug(unsigned char flag, char *) {
- if (flag) {
+static int special_debug(unsigned char pre, char *) {
+ if (pre) {
SetupDebuggingTraps();
return 1;
} else {
@@ -117,8 +118,8 @@ static int special_debug(unsigned char flag, char *) {
}
}
-static int special_plugin_debug(unsigned char flag, char *) {
- if (flag) {
+static int special_plugin_debug(unsigned char pre, char *) {
+ if (pre) {
clState.pluginDebug = 1;
return 1;
} else {
@@ -126,8 +127,8 @@ static int special_plugin_debug(unsigned char flag, char *) {
}
}
-static int special_stdout_base(unsigned char flag, char *) {
- if (flag) {
+static int special_stdout_base(unsigned char pre, char *) {
+ if (pre) {
return 1;
} else {
return clState.stdoutBase != 0;
@@ -135,9 +136,9 @@ static int special_stdout_base(unsigned char flag, char *) {
}
struct SpecialOption {
- const char *name;
- char **location;
- int (*callback)(unsigned char a, char *b);
+ const char *optname;
+ char **argp;
+ int (*func)(unsigned char a, char *b);
};
static struct SpecialOption special_options[3] = {
{"", 0, special_debug},
@@ -146,16 +147,16 @@ static struct SpecialOption special_options[3] = {
};
void Main_PreParse(int *pArgc, char ***pArgv) {
- int i;
- struct SpecialOption *opt;
+ struct SpecialOption *so;
+ int idx;
if (*pArgc > 1) {
restart:
- for (i = 0, opt = &special_options[0]; i < 3; i++, opt++) {
- if (!strcmp(opt->name, (*pArgv)[1])) {
- if (opt->location) {
- *opt->location = (*pArgv)[2];
- opt->callback(1, *opt->location);
+ for (idx = 0, so = &special_options[0]; idx < 3; idx++, so++) {
+ if (!strcmp(so->optname, (*pArgv)[1])) {
+ if (so->argp) {
+ *so->argp = (*pArgv)[2];
+ so->func(1, *so->argp);
(*pArgv)[1] = (*pArgv)[0];
(*pArgc)--;
(*pArgv)++;
@@ -164,7 +165,7 @@ void Main_PreParse(int *pArgc, char ***pArgv) {
(*pArgc)--;
(*pArgv)++;
} else {
- opt->callback(1, 0);
+ so->func(1, 0);
(*pArgv)[1] = (*pArgv)[0];
(*pArgc)--;
(*pArgv)++;
@@ -173,21 +174,21 @@ void Main_PreParse(int *pArgc, char ***pArgv) {
}
}
- if ((*pArgc) > 1 && i < 3)
+ if ((*pArgc) > 1 && idx < 3)
goto restart;
}
}
void Main_PassSpecialArgs(void *unk1, void *unk2) {
- int i;
- struct SpecialOption *opt;
-
- for (i = 0; i < 3; i++) {
- opt = &special_options[i];
- if (opt->callback(0, 0)) {
- AppendArgumentList(unk1, unk2, opt->name);
- if (opt->location)
- AppendArgumentList(unk1, unk2, (*opt->location) ? *opt->location : "");
+ struct SpecialOption *so;
+ int idx;
+
+ for (idx = 0; idx < 3; idx++) {
+ so = &special_options[idx];
+ if (so->func(0, 0)) {
+ AppendArgumentList(unk1, unk2, so->optname);
+ if (so->argp)
+ AppendArgumentList(unk1, unk2, (*so->argp) ? *so->argp : "");
}
}
}
@@ -201,11 +202,11 @@ PCmdLineLinker optsLinker;
int Main_Initialize(int argc, const char **argv) {
static char secret[8];
- char buf[256];
+ char exename[256];
OS_InitProgram(&argc, &argv);
memset(&clState, 0, sizeof(CLState));
- special_options[0].name = secret;
+ special_options[0].optname = secret;
secret[7] = 0;
secret[4] = 'b';
secret[1] = '-';
@@ -224,7 +225,7 @@ int Main_Initialize(int argc, const char **argv) {
return 0;
}
-int Main_Terminate(int code) {
+int Main_Terminate(int exitcode) {
if (MainInitialized) {
Plugins_Term();
License_Terminate();
@@ -232,11 +233,14 @@ int Main_Terminate(int code) {
IO_Terminate();
MainInitialized = 0;
}
- return code;
+ return exitcode;
}
static int Main_ParseCommandLine() {
// TODO: clState, Plugins, gTarg, ...
+ long vislang;
+ int x, y;
+ CWCommandLineArgs myargs;
}
static int Main_SetupParamBlock() {
@@ -246,39 +250,41 @@ static int Main_SetupParamBlock() {
static int Main_ResolveProject() {
// TODO: Various project things
+ int err;
+ long startTime, endTime;
}
-static int UpdatePCmdLineFromVersion(const PCmdLine *oldVer, PCmdLine *newVer) {
+static int UpdatePCmdLineFromVersion(const PCmdLine *given, PCmdLine *target) {
static unsigned char warned;
- short ver = oldVer->version;
- *newVer = *oldVer;
+ short version = given->version;
+ *target = *given;
// TODO: clState
return 0;
}
-static int UpdatePCmdLineEnvirFromVersion(const PCmdLineEnvir *oldVer, PCmdLineEnvir *newVer) {
+static int UpdatePCmdLineEnvirFromVersion(const PCmdLineEnvir *given, PCmdLineEnvir *target) {
static unsigned char warned;
- short ver = oldVer->version;
- *newVer = *oldVer;
+ short version = given->version;
+ *target = *given;
// TODO: clState
return 0;
}
-static int UpdatePCmdLineCompilerFromVersion(const PCmdLineCompiler *oldVer, PCmdLineCompiler *newVer) {
+static int UpdatePCmdLineCompilerFromVersion(const PCmdLineCompiler *given, PCmdLineCompiler *target) {
static unsigned char warned;
- short ver = oldVer->version;
- *newVer = *oldVer;
+ short version = given->version;
+ *target = *given;
// TODO: clState
return 0;
}
-static int UpdatePCmdLineLinkerFromVersion(const PCmdLineLinker *oldVer, PCmdLineLinker *newVer) {
+static int UpdatePCmdLineLinkerFromVersion(const PCmdLineLinker *given, PCmdLineLinker *target) {
static unsigned char warned;
- short ver = oldVer->version;
- *newVer = *oldVer;
+ short version = given->version;
+ *target = *given;
// TODO: clState
return 0;
@@ -286,12 +292,12 @@ static int UpdatePCmdLineLinkerFromVersion(const PCmdLineLinker *oldVer, PCmdLin
static int UpdatePrefPanels(const char *name) {
PrefPanel *panel;
- Handle handle;
+ Handle h;
if (!name || !ustrcmp(name, "CmdLine Panel")) {
- if ((panel = Prefs_FindPanel("CmdLine Panel")) && (handle = PrefPanel_GetHandle(panel))) {
+ if ((panel = Prefs_FindPanel("CmdLine Panel")) && (h = PrefPanel_GetHandle(panel))) {
if (name) {
- if (!UpdatePCmdLineFromVersion((PCmdLine *) *handle, &optsCmdLine))
+ if (!UpdatePCmdLineFromVersion((PCmdLine *) *h, &optsCmdLine))
return 0;
}
} else {
@@ -301,9 +307,9 @@ static int UpdatePrefPanels(const char *name) {
}
if (!name || !ustrcmp(name, "CmdLine Environment")) {
- if ((panel = Prefs_FindPanel("CmdLine Environment")) && (handle = PrefPanel_GetHandle(panel))) {
+ if ((panel = Prefs_FindPanel("CmdLine Environment")) && (h = PrefPanel_GetHandle(panel))) {
if (name) {
- if (!UpdatePCmdLineEnvirFromVersion((PCmdLineEnvir *) *handle, &optsEnvir))
+ if (!UpdatePCmdLineEnvirFromVersion((PCmdLineEnvir *) *h, &optsEnvir))
return 0;
}
} else {
@@ -313,9 +319,9 @@ static int UpdatePrefPanels(const char *name) {
}
if (!name || !ustrcmp(name, "CmdLine Compiler Panel")) {
- if ((panel = Prefs_FindPanel("CmdLine Compiler Panel")) && (handle = PrefPanel_GetHandle(panel))) {
+ if ((panel = Prefs_FindPanel("CmdLine Compiler Panel")) && (h = PrefPanel_GetHandle(panel))) {
if (name) {
- if (!UpdatePCmdLineCompilerFromVersion((PCmdLineCompiler *) *handle, &optsCompiler))
+ if (!UpdatePCmdLineCompilerFromVersion((PCmdLineCompiler *) *h, &optsCompiler))
return 0;
}
} else {
@@ -325,9 +331,9 @@ static int UpdatePrefPanels(const char *name) {
}
if (!name || !ustrcmp(name, "CmdLine Linker Panel")) {
- if ((panel = Prefs_FindPanel("CmdLine Linker Panel")) && (handle = PrefPanel_GetHandle(panel))) {
+ if ((panel = Prefs_FindPanel("CmdLine Linker Panel")) && (h = PrefPanel_GetHandle(panel))) {
if (name) {
- if (!UpdatePCmdLineLinkerFromVersion((PCmdLineLinker *) *handle, &optsLinker))
+ if (!UpdatePCmdLineLinkerFromVersion((PCmdLineLinker *) *h, &optsLinker))
return 0;
}
} else {
@@ -340,19 +346,19 @@ static int UpdatePrefPanels(const char *name) {
}
static int SetupCmdLinePrefPanels() {
- int result;
+ int ret;
PrefPanelsChangedCallback = UpdatePrefPanels;
- result = Prefs_AddPanel(
+ ret = Prefs_AddPanel(
PrefPanel_New("CmdLine Environment", &optsEnvir, sizeof(PCmdLineEnvir))
);
- result |= (
+ ret |= (
Prefs_AddPanel(PrefPanel_New("CmdLine Panel", 0, sizeof(PCmdLine)))
&& Prefs_AddPanel(PrefPanel_New("CmdLine Compiler Panel", 0, sizeof(PCmdLineCompiler)))
&& Prefs_AddPanel(PrefPanel_New("CmdLine Linker Panel", 0, sizeof(PCmdLineLinker)))
);
- return result;
+ return ret;
}
static int Main_SetupContext() {