summaryrefslogtreecommitdiff
path: root/includes/parser.h
blob: ae28feec9494ea718ad4b14d88e4cced9aa170d6 (plain)
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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
#pragma once

#include "cw_common.h"
#include "pref_structs.h"
#include "option_system.h"

enum {
    PRAGMA_FLAGS_0,
    PRAGMA_FLAGS_1
};
enum {
    PR_UNSET = 0, // this is the only one we know the name of (from asserts)
    PR_ON = 1,
    PR_OFF = 2,
    PR_AUTO = 3,
    PR_RESET = 4
};

typedef struct {
    void *value;
    const char *pragma;
    int flags;
} Pragma; // assumed name

enum {
    CLPStr0 = 0,
    CLPStr1 = 1,
    CLPStr2 = 2,
    CLPStr3 = 3,
    CLPStr4 = 4,
    CLPStr5 = 5,
    CLPStr6 = 6,
    CLPStr7 = 7,
    CLPStr8 = 8,
    CLPStr9 = 9,
    CLPStr10 = 10,
    CLPStr11 = 11,
    CLPStr12 = 12,
    CLPStr13 = 13,
    CLPStr14 = 14,
    CLPStr15 = 15,
    CLPStr16 = 16,
    CLPStr17 = 17,
    CLPStr18 = 18,
    CLPStr19_UnknownOptionX = 19,
    CLPStr20_UnknownOptionX_ExpectedOneOfX = 20,
    CLPStr21_OptionObsolete = 21,
    CLPStr22_OptionObsoleteWithHelp = 22,
    CLPStr23_OptionXSubstitutedWithX = 23,
    CLPStr24_OptionDeprecated = 24,
    CLPStr25_OptionDeprecatedWithHelp = 25,
    CLPStr26_OptionIgnored = 26,
    CLPStr27_OptionIgnoredWithText = 27,
    CLPStr28_WarningText = 28,
    CLPStr29_OptionHasNoEffect = 29,
    CLPStr30_OptionShouldNotBeSpecifiedMultipleTimes = 30,
    CLPStr31_OptionOverridesEffect = 31,
    CLPStr32_OptionOverridesEffectWithHelp = 32,
    CLPStr33_NoDefaultHandlerSetUpForX_Ignoring = 33,
    CLPStr34_ArgumentsExpected = 34,
    CLPStr35_TokenXNotExpected = 35,
    CLPStr36_UnexpectedAdditionalArgumentX = 36,
    CLPStr37 = 37,
    CLPStr38_NoHelpAvailableForOptionX = 38,
    CLPStr39 = 39,
    CLPStr40 = 40,
    CLPStr41 = 41,
    CLPStr42 = 42,
    CLPStr43 = 43,
    CLPStr44 = 44,
    CLPStr45 = 45,
    CLPStr46 = 46,
    CLPStr47 = 47,
    CLPStr48 = 48,
    CLPStr49 = 49,
    CLPStr50 = 50,
    CLPStr51 = 51,
    CLPStr52 = 52,
    CLPStr53 = 53,
    CLPStr54 = 54,
    CLPStr55 = 55,
    CLPStr56 = 56,
    CLPStr57 = 57,
    CLPStr58 = 58,
    CLPStr59 = 59,
    CLPStr60 = 60,
    CLPStr61 = 61,
    CLPStr62 = 62,
    CLPStr63 = 63,
    CLPStr64 = 64,
    CLPStr65 = 65,
    CLPStr66 = 66,
    CLPStr67 = 67,
    CLPStr68 = 68,
    CLPStr69 = 69,
    CLPStr70 = 70,
    CLPStr71 = 71,
    CLPStr72 = 72,
    CLPStr73 = 73,
    CLPStr74 = 74,
    CLPStr75 = 75,
    CLPStr76 = 76,
    CLPStr77 = 77,
    CLPStr78 = 78
};

// State

typedef struct {
    char *name;
    void *ptr;
    SInt32 size;
} PrefDataPanel; // assumed name

typedef struct {
    OSType TYPE;
    OSType LANG;
    OSType CPU;
    OSType OS;
    int numPrefPanels;
    char **prefPanels;
    char *toolInfo;
    char *copyright;
    int numOptionLists;
    OptionList **optionLists;
    int numPrefDataPanels;
    PrefDataPanel *prefDataPanels;
    int (*PreParse)();
    int (*MidParse)();
    int (*PostParse)();
} ParserTool; // assumed name

typedef struct {
    struct CWPluginPrivateContext *context;
    char helpKey[64];
    SInt32 helpFlags;
    UInt16 ioCols;
    UInt16 ioRows;
    CWCommandLineArgs *args;
    const ToolVersionInfo *toolVersion;
    int numPlugins;
    const CLPluginInfo *plugins;
    int numPanels;
    const char **panelNames;
    OSType cpu;
    OSType os;
    char lastoutputname[256];
    SInt32 currentSegment;
    SInt32 currentOverlayGroup;
    SInt32 currentOverlay;
    int possibleFiles;
    int userSpecifiedFiles;
    int unusedFiles;
    Boolean hadAnyOutput;
    Boolean hadErrors;
    Boolean showHelp;
    Boolean underIDE;
    Boolean alwaysUsePaths;
    Boolean noOptions;
    Boolean printedVersion;
    Boolean passingArgs;
    Boolean disToFile;
    Boolean ppToFile;
    Boolean initBefore;
    Boolean weakImport;
    Boolean mergeIntoOutput;
    Boolean success;
    Boolean ignoreUnknown;
    UInt8 unused[2];
} ParseOptsType; // assumed name

#ifdef __cplusplus
extern "C" {
#endif

/********************************/
/* IO.c */
extern void ShowTextHandle(const char *description, Handle text);
extern void ShowVersion(Boolean decorate);

/********************************/
/* OptimizerHelpers.c */
extern Pragma irPragmas[];

extern int SetPragmaOptimizationsToUnspecified(const char *opt, void *, const char *, int);
extern int SetOptFlags(const char *opt, void *str, const char *, int flags);
extern int DisplayOptimizationOptions();

/********************************/
/* ParserErrors.c */
extern void CLPReportError_V(const char *format, va_list ap);
extern void CLPReportWarning_V(const char *format, va_list ap);
extern void CLPReport_V(const char *format, va_list ap);
extern void CLPStatus_V(const char *format, va_list ap);
extern void CLPAlert_V(const char *format, va_list ap);
extern void CLPOSAlert_V(const char *format, SInt32 err, va_list ap);
extern char *CLPGetErrorString(SInt16 errid, char *buffer);
extern void CLPReportError(SInt16 errid, ...);
extern void CLPReportWarning(SInt16 errid, ...);
extern void CLPReport(SInt16 errid, ...);
extern void CLPAlert(SInt16 errid, ...);
extern void CLPOSAlert(SInt16 errid, SInt16 err, ...);
extern void CLPProgress(SInt16 errid, ...);
extern void CLPStatus(SInt16 errid, ...);
extern void CLPFatalError(const char *format, ...);

/********************************/
/* ParserFace.c */
extern const char *failedCallback;
extern jmp_buf exit_plugin;
extern ParseOptsType parseopts;

extern Handle Parser_FindPrefPanel(const char *name);
extern SInt32 Parser_StorePanels(struct CWPluginPrivateContext *context);
extern CWPLUGIN_ENTRY (CWParser_GetDropInFlags)(const DropInFlags **flags, SInt32 *flagsSize);
extern CWPLUGIN_ENTRY (CWParser_GetDropInName)(const char **dropinName);
extern CWPLUGIN_ENTRY (CWParser_GetDisplayName)(const char **displayName);
extern CWPLUGIN_ENTRY (CWParser_GetPanelList)(const CWPanelList **panelList);
extern CWPLUGIN_ENTRY (CWParser_GetTargetList)(const CWTargetList **targetList);
extern CWPLUGIN_ENTRY (CWParser_GetVersionInfo)(const VersionInfo **versioninfo);
extern CWPLUGIN_ENTRY (Parser_SupportsPlugin)(const struct CLPluginInfo *pluginfo, OSType cpu, OSType os, Boolean *isSupported);
extern CWPLUGIN_ENTRY (Parser_SupportsPanels)(int numPanels, const char **panelNames, Boolean *isSupported);
extern CWPLUGIN_ENTRY (parser_main)(struct CWPluginPrivateContext *context);

/********************************/
/* ParserGlue-mach-ppc-c.c */
extern PCmdLine pCmdLine;
extern PCmdLineCompiler pCmdLineCompiler;
extern PCmdLineLinker pCmdLineLinker;
extern PFrontEndC pFrontEndC;
extern PWarningC pWarningC;
extern PGlobalOptimizer pGlobalOptimizer;
extern PBackEnd pBackEnd;
extern PDisassembler pDisassembler;
extern PMachOLinker pLinker;
extern PMachOProject pMachOProject;
extern PCLTExtras pCLTExtras;

/********************************/
/* ParserHelpers.c */
extern SInt16 lastStage;
extern Boolean dashIMinusMovesPaths;
extern Boolean usedDashIMinus;
extern Boolean namingSysPaths;

extern int FindFileInPath(const char *filename, OSSpec *fss);
extern char *GetEnvVar(const char *name, Boolean warn, const char **match);
extern int Opt_AddAccessPath(const char *opt, void *var, const char *arg, int flags);
extern int Opt_AddFrameworkPath(const char *opt, void *var, const char *arg, int flags);
extern int Opt_AddFramework(const char *opt, void *var, const char *arg, int flags);
extern void ListParseMessage(void (*errprint)(const char *, va_list), const char *envvar, SInt16 id, ...);
extern int AddAccessPathList(const char *list, char sep1, char sep2, int source, char *text, Boolean system, SInt32 position, Boolean recursive);
extern int Opt_FindAndAddFile(const char *opt, void *var, const char *arg, int flags);
extern int Opt_FindAndAddFileRef(const char *opt, void *var, const char *arg);
extern int Opt_AddUnixLibraryFile(const char *opt, void *var, const char *arg);
extern int AddFileList(const char *list, char sep1, char sep2, int source, char *text, SInt32 position);
extern int IsFileInOutputDirectory(const OSSpec *file);
extern void GetCFileNameInOutputDirectory(const char *input, char *name, int maxlen);
extern void GetPFileNameInOutputDirectory(const char *input, unsigned char *name, int len);
extern void AddStringLenToHandle(Handle *h, const char *str, int len);
extern void AddStringToHandle(Handle *h, const char *str);
extern int Opt_PrintVersion(const char *opt, void *var, const char *arg, int flags);
extern void GetFirstSourceFilenameBase(char *buffer, char *defaul);
extern int Opt_SavePrefs(const char *opt, void *var, const char *arg, int flags);
extern int ParseNumber(const char *arg, Boolean emit_error, SInt32 *ret, const char **endptr);
extern int Opt_MaybeMoveAccessPaths(const char *opt, void *var, const char *arg, int flags);

/********************************/
/* ParserHelpers-cc.c */
extern Handle definesHandle;

extern int Opt_AddStringToDefines(const char *opt, void *str, const char *param, int flags);
extern int Opt_DefineSymbol(const char *var, const char *value);
extern int Opt_UndefineSymbol(const char *opt, void *, const char *arg, int flags);
extern int Opt_AddPrefixFile(const char *opt, void *handle, const char *filename, int flags);
extern int Opt_PragmaTrueFalse(const char *, void *flag, const char *, int flags);
extern int Opt_PragmaFalseTrue(const char *, void *flag, const char *, int flags);
extern int Opt_PragmaOnOff(const char *, void *flag, const char *arg);
extern int Opt_PragmaOffOn(const char *, void *flag, const char *arg);
extern int SetupPragmas(const Pragma *pragmas);

/********************************/
/* Projects.c */
extern int GetFileCount();
extern void SetFileOutputName(SInt32 position, SInt16 which, char *outfilename);
extern int AddFileToProject(OSSpec *oss, SInt16 which, char *outfilename, Boolean exists, SInt32 position);
extern Boolean GetFileInfo(SInt32 position, OSSpec *spec, char *plugin);
extern int AddAccessPath(OSPathSpec *oss, SInt16 type, SInt32 position, Boolean recursive);
extern int MoveSystemPathsIntoUserList();
extern void AddVirtualFile(const char *filename, Handle *text);
extern void GetOutputFileDirectory(OSPathSpec *dir);
extern void SetOutputFileDirectory(OSPathSpec *dir);
extern void AddOverlayGroup(const char *name, CWAddr64 *addr, SInt32 *groupnum, SInt32 *overlaynum);
extern void AddOverlay(SInt32 groupnum, const char *name, SInt32 *overlaynum);
extern void AddSegment(const char *name, SInt16 attrs, SInt32 *segmentnum);
extern void ChangeSegment(SInt32 segmentnum, const char *name, SInt16 attrs);
extern int GetSegment(SInt32 segmentnum, char *name, SInt16 *attrs);

/********************************/
/* TargetOptimizer-ppc-mach.c */
extern char schedule_ppc_default;

extern int TargetSetOptFlags(short val, Boolean set);
extern void TargetDisplayOptimizationOptions(Handle txt);
extern void TargetSetPragmaOptimizationsToUnspecified();

/********************************/
/* TargetWarningHelpers-ppc-cc.c */
extern Pragma warningPragmas[];

extern int TargetSetWarningFlags(short val, Boolean set);
extern void TargetDisplayWarningOptions(Handle txt);

/********************************/
/* Targets.c */
extern ParserTool *pTool;

extern int SetParserToolInfo(ParserTool *tool);
extern Boolean ParserToolMatchesPlugin(OSType type, OSType lang, OSType cpu, OSType os);
extern Boolean ParserToolHandlesPanels(int numPanels, const char **panelNames);
extern Boolean SetupParserToolOptions();

/********************************/
/* ToolHelpers.c */
enum {
    OutputOrdering0 = 0,
    OutputOrdering1 = 1,
    OutputOrdering2 = 2
};
extern char linkerOutputFilename[256];
extern Boolean setLinkerOutputFilename;
extern Boolean setOutputDirectory;
extern SInt16 outputOrdering;

extern int Opt_HandleOutputName(const char *opt, void *, const char *filename, int flags);
extern int ValidateToolState(Boolean mustHaveFiles);
extern void ToolReportMessage(SInt16 errid, SInt16 type, va_list va);
extern void ToolReportWarning(SInt16 id, ...);
extern void ToolReportError(SInt16 id, ...);
extern void ToolReportOSError(SInt16 id, int err, ...);
extern void ToolReportInfo(SInt16 id, ...);
extern int Opt_DoNotLink(const char *opt, void *var, const char *arg);
extern int Opt_IncreaseVerbosity(const char *opt, void *var, const char *arg, int flags);
extern int Opt_SetStage(const char *opt, void *str, const char *arg, int flags);
extern int Opt_RedirectStream(const char *opt, void *file, const char *filename);

/********************************/
/* ToolHelpers-cc.c */
extern int Opt_DummyLinkerRoutine(const char *opt, void *, const char *, int);
extern int Opt_DummyLinkerSettingRoutine(const char *var, const char *val);
extern void FinishCompilerTool();

/********************************/
/* Utils.c */
extern int my_tolower(char c);
extern int my_isdigit(char c);
extern int my_isalpha(char c);
extern int my_isalnum(char c);
extern int my_isxdigit(char c);
extern char *Utils_SpellList(char *list, char *buffer, char opts);
extern int Utils_CompareOptionString(const char *a, const char *b, int cased, int sticky);

/********************************/
/* WarningHelpers.c */
extern int SetWarningFlags(const char *opt, void *str, const char *, int flags);
extern int DisplayWarningOptions();

#ifdef __cplusplus
extern "C" }
#endif