1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
|
#include "qcc.h"
#include "gui.h"
//common gui things
pbool fl_hexen2;
pbool fl_autohighlight;
pbool fl_compileonstart;
pbool fl_showall;
pbool fl_log;
char parameters[16384];
char progssrcname[256];
char progssrcdir[256];
int qccpersisthunk = 1;
void GoToDefinition(char *name)
{
QCC_def_t *def;
QCC_dfunction_t *fnc;
char *strip; //trim whitespace (for convieniance).
while (*name <= ' ' && *name)
name++;
for (strip = name + strlen(name)-1; *strip; strip++)
{
if (*strip <= ' ')
*strip = '\0';
else //got some part of a word
break;
}
if (!globalstable.numbuckets)
{
GUI_DialogPrint("Not found", "You need to compile first.");
return;
}
def = QCC_PR_GetDef(NULL, name, NULL, false, 0, false);
if (def)
{
if (def->type->type == ev_function && def->constant)
{
fnc = &functions[((int *)qcc_pr_globals)[def->ofs]];
if (fnc->first_statement>=0 && fnc->s_file)
{
EditFile(fnc->s_file+strings, statement_linenums[fnc->first_statement]);
return;
}
}
if (!def->s_file)
GUI_DialogPrint("Not found", "Global definition of var was not specified.");
else
EditFile(def->s_file+strings, def->s_line-1);
}
else
GUI_DialogPrint("Not found", "Global instance of var was not found.");
}
//this function takes the windows specified commandline and strips out all the options menu items.
void GUI_ParseCommandLine(char *args)
{
int paramlen=0;
int l, p;
char *next;
while(*args)
{
while (*args <= ' ' && *args)
args++;
for (next = args; *next>' '; next++)
;
strncpy(parameters+paramlen, args, next-args);
parameters[paramlen+next-args] = '\0';
l = strlen(parameters+paramlen)+1;
if (!strnicmp(parameters+paramlen, "-O", 2) || !strnicmp(parameters+paramlen, "/O", 2))
{ //strip out all -O
if (parameters[paramlen+2])
{
if (parameters[paramlen+2] >= '0' && parameters[paramlen+2] <= '3')
{
p = parameters[paramlen+2]-'0';
for (l = 0; optimisations[l].enabled; l++)
{
if (optimisations[l].optimisationlevel<=p)
optimisations[l].flags |= FLAG_SETINGUI;
else
optimisations[l].flags &= ~FLAG_SETINGUI;
}
}
else if (!strncmp(parameters+paramlen+2, "no-", 3))
{
if (parameters[paramlen+5])
{
for (p = 0; optimisations[p].enabled; p++)
if ((*optimisations[p].abbrev && !strcmp(parameters+paramlen+5, optimisations[p].abbrev)) || !strcmp(parameters+paramlen+5, optimisations[p].fullname))
{
optimisations[p].flags &= ~FLAG_SETINGUI;
break;
}
if (!optimisations[p].enabled)
{
parameters[paramlen+next-args] = ' ';
paramlen += l;
}
}
}
else
{
for (p = 0; optimisations[p].enabled; p++)
if ((*optimisations[p].abbrev && !strcmp(parameters+paramlen+2, optimisations[p].abbrev)) || !strcmp(parameters+paramlen+2, optimisations[p].fullname))
{
optimisations[p].flags |= FLAG_SETINGUI;
break;
}
if (!optimisations[p].enabled)
{
parameters[paramlen+next-args] = ' ';
paramlen += l;
}
}
}
}
/*
else if (!strnicmp(parameters+paramlen, "-Fno-kce", 8) || !strnicmp(parameters+paramlen, "/Fno-kce", 8)) //keywords stuph
{
fl_nokeywords_coexist = true;
}
else if (!strnicmp(parameters+paramlen, "-Fkce", 5) || !strnicmp(parameters+paramlen, "/Fkce", 5))
{
fl_nokeywords_coexist = false;
}
else if (!strnicmp(parameters+paramlen, "-Facc", 5) || !strnicmp(parameters+paramlen, "/Facc", 5))
{
fl_acc = true;
}
else if (!strnicmp(parameters+paramlen, "-autoproto", 10) || !strnicmp(parameters+paramlen, "/autoproto", 10))
{
fl_autoprototype = true;
}
*/
else if (!strnicmp(parameters+paramlen, "-showall", 8) || !strnicmp(parameters+paramlen, "/showall", 8))
{
fl_showall = true;
}
else if (!strnicmp(parameters+paramlen, "-ah", 3) || !strnicmp(parameters+paramlen, "/ah", 3))
{
fl_autohighlight = true;
}
else if (!strnicmp(parameters+paramlen, "-ac", 3) || !strnicmp(parameters+paramlen, "/ac", 3))
{
fl_compileonstart = true;
}
else if (!strnicmp(parameters+paramlen, "-log", 4) || !strnicmp(parameters+paramlen, "/log", 4))
{
fl_log = true;
}
else if (!strnicmp(parameters+paramlen, "-srcfile", 8) || !strnicmp(parameters+paramlen, "/srcfile", 8))
{
while (*next == ' ')
next++;
l = 0;
while (*next != ' ' && *next)
progssrcname[l++] = *next++;
progssrcname[l] = 0;
}
else if (!strnicmp(parameters+paramlen, "-T", 2) || !strnicmp(parameters+paramlen, "/T", 2)) //the target
{
if (!strnicmp(parameters+paramlen+2, "h2", 2))
{
fl_hexen2 = true;
}
else
{
fl_hexen2 = false;
parameters[paramlen+next-args] = ' ';
paramlen += l;
}
}
else
{
parameters[paramlen+next-args] = ' ';
paramlen += l;
}
args=next;
}
if (paramlen)
parameters[paramlen-1] = '\0';
else
*parameters = '\0';
}
void GUI_SetDefaultOpts(void)
{
int i;
for (i = 0; compiler_flag[i].enabled; i++) //enabled is a pointer
{
if (compiler_flag[i].flags & FLAG_ASDEFAULT)
compiler_flag[i].flags |= FLAG_SETINGUI;
else
compiler_flag[i].flags &= ~FLAG_SETINGUI;
}
for (i = 0; optimisations[i].enabled; i++) //enabled is a pointer
{
if (optimisations[i].flags & FLAG_ASDEFAULT)
optimisations[i].flags |= FLAG_SETINGUI;
else
optimisations[i].flags &= ~FLAG_SETINGUI;
}
}
void GUI_RevealOptions(void)
{
int i;
for (i = 0; compiler_flag[i].enabled; i++) //enabled is a pointer
{
if (fl_showall && compiler_flag[i].flags & FLAG_HIDDENINGUI)
compiler_flag[i].flags &= ~FLAG_HIDDENINGUI;
}
for (i = 0; optimisations[i].enabled; i++) //enabled is a pointer
{
if (fl_showall && optimisations[i].flags & FLAG_HIDDENINGUI)
optimisations[i].flags &= ~FLAG_HIDDENINGUI;
if (optimisations[i].flags & FLAG_HIDDENINGUI) //hidden optimisations are disabled as default
optimisations[i].optimisationlevel = 4;
}
}
int GUI_BuildParms(char *args, char **argv)
{
static char param[2048];
int paramlen = 0;
int argc;
char *next;
int i;
argc = 1;
argv[0] = "fteqcc";
while(*args)
{
while (*args <= ' '&& *args)
args++;
for (next = args; *next>' '; next++)
;
strncpy(param+paramlen, args, next-args);
param[paramlen+next-args] = '\0';
argv[argc++] = param+paramlen;
paramlen += strlen(param+paramlen)+1;
args=next;
}
if (fl_hexen2)
{
strcpy(param+paramlen, "-Th2");
argv[argc++] = param+paramlen;
paramlen += strlen(param+paramlen)+1;
}
for (i = 0; optimisations[i].enabled; i++) //enabled is a pointer
{
if (optimisations[i].flags & FLAG_SETINGUI)
sprintf(param+paramlen, "-O%s", optimisations[i].abbrev);
else
sprintf(param+paramlen, "-Ono-%s", optimisations[i].abbrev);
argv[argc++] = param+paramlen;
paramlen += strlen(param+paramlen)+1;
}
for (i = 0; compiler_flag[i].enabled; i++) //enabled is a pointer
{
if (compiler_flag[i].flags & FLAG_SETINGUI)
sprintf(param+paramlen, "-F%s", compiler_flag[i].abbrev);
else
sprintf(param+paramlen, "-Fno-%s", compiler_flag[i].abbrev);
argv[argc++] = param+paramlen;
paramlen += strlen(param+paramlen)+1;
}
/* while(*args)
{
while (*args <= ' '&& *args)
args++;
for (next = args; *next>' '; next++)
;
strncpy(param+paramlen, args, next-args);
param[paramlen+next-args] = '\0';
argv[argc++] = param+paramlen;
paramlen += strlen(param+paramlen)+1;
args=next;
}*/
if (*progssrcname)
{
argv[argc++] = "-srcfile";
argv[argc++] = progssrcname;
}
if (*progssrcdir)
{
argv[argc++] = "-src";
argv[argc++] = progssrcdir;
}
return argc;
}
|