mirror of https://git.wuffs.org/MWCC
add tons of stuff
This commit is contained in:
parent
b8df05413a
commit
775b686166
|
@ -47,4 +47,9 @@ add_executable(mwcc
|
|||
command_line/CmdLine/Src/CLPrefs.c
|
||||
command_line/CmdLine/Src/CLTarg.c
|
||||
command_line/CmdLine/Src/CLToolExec.c
|
||||
command_line/CmdLine/Src/CLWriteObjectFile.c)
|
||||
command_line/CmdLine/Src/CLWriteObjectFile.c
|
||||
unsorted/ParserFace.c
|
||||
unsorted/uContext1.cpp
|
||||
unsorted/uContextCL.cpp
|
||||
unsorted/uContextParser.cpp
|
||||
unsorted/uContextSecret.cpp unsorted/StaticParserGlue.c unsorted/ParserHelpers.c unsorted/ToolHelpers.c unsorted/ParserHelpers-cc.c unsorted/ToolHelpers-cc.c unsorted/IO.c unsorted/Projects.c unsorted/Targets.c unsorted/ParserErrors.c)
|
||||
|
|
23
Option.c
23
Option.c
|
@ -1,7 +1,5 @@
|
|||
#include "includes/mwcc_decomp.h"
|
||||
|
||||
#define OPTION_ASSERT(cond) do { if (!(cond)) { printf("%s:%u: failed assertion\n", __FILE__, __LINE__); abort(); } } while(0)
|
||||
|
||||
#define MAXSTACK 8
|
||||
|
||||
int oStackPtr;
|
||||
|
@ -413,27 +411,6 @@ static Boolean Option_IsEndingLevel(int level, ArgToken *tok) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
enum {
|
||||
OFLAGS_1 = 1,
|
||||
OFLAGS_2 = 2,
|
||||
OFLAGS_4 = 4,
|
||||
OFLAGS_8 = 8,
|
||||
OFLAGS_10 = 0x10,
|
||||
OFLAGS_20 = 0x20,
|
||||
OFLAGS_40 = 0x40,
|
||||
OFLAGS_80 = 0x80
|
||||
};
|
||||
enum {
|
||||
PFLAGS_1 = 1,
|
||||
PFLAGS_2 = 2,
|
||||
PFLAGS_4 = 4,
|
||||
PFLAGS_8 = 8,
|
||||
PFLAGS_10 = 0x10,
|
||||
PFLAGS_20 = 0x20,
|
||||
PFLAGS_40 = 0x40,
|
||||
PFLAGS_80 = 0x80
|
||||
};
|
||||
|
||||
int Option_Parse(Option *opt, int oflags) {
|
||||
int ret;
|
||||
int pushed;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#include "includes/mwcc_decomp.h"
|
||||
|
||||
#define OPTION_ASSERT(cond) do { if (!(cond)) { printf("%s:%u: failed assertion\n", __FILE__, __LINE__); abort(); } } while(0)
|
||||
|
||||
char curparam[4096];
|
||||
char *descparam = &curparam[0];
|
||||
char *helpparam = &curparam[1024];
|
||||
|
|
|
@ -71,8 +71,8 @@ static SInt16 CLT_GetPanelList(const CWPanelList **panelList) {
|
|||
}
|
||||
|
||||
static SInt16 CLT_GetTargetList(const CWTargetList **targetList) {
|
||||
static FourCharCode sCPU = CWFOURCHAR('*','*','*','*');
|
||||
static FourCharCode sOS = CWFOURCHAR('*','*','*','*');
|
||||
static FourCharCode sCPU = targetCPUAny;
|
||||
static FourCharCode sOS = targetOSAny;
|
||||
static CWTargetList sTargetList = {
|
||||
kCurrentCWTargetListVersion,
|
||||
1,
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#include "mwcc_decomp.h"
|
||||
|
||||
#define OPTION_ASSERT(cond) do { if (!(cond)) { printf("%s:%u: failed assertion\n", __FILE__, __LINE__); abort(); } } while(0)
|
||||
|
||||
typedef struct MacFileInfo {
|
||||
UInt32 ioFlCrDat;
|
||||
UInt32 ioFlMdDat;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#include "mwcc_decomp.h"
|
||||
|
||||
#define OPTION_ASSERT(cond) do { if (!(cond)) { printf("%s:%u: failed assertion\n", __FILE__, __LINE__); abort(); } } while(0)
|
||||
|
||||
// Fork Attributes
|
||||
enum {
|
||||
mapReadOnly = 0x80,
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#include "oslib.h"
|
||||
|
||||
#define OPTION_ASSERT(cond) do { if (!(cond)) { printf("%s:%u: failed assertion\n", __FILE__, __LINE__); abort(); } } while(0)
|
||||
|
||||
static OSFileTypeMappings *defaultList;
|
||||
static OSFileTypeMappings **fmList = &defaultList;
|
||||
int (*__OS_ExtendedGetMacFileTypeHook)(const OSSpec *, OSType *);
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
extern char STSbuf[256];
|
||||
|
||||
#define OPTION_ASSERT(cond) do { if (!(cond)) { printf("%s:%u: failed assertion\n", __FILE__, __LINE__); abort(); } } while(0)
|
||||
|
||||
typedef struct DirNode {
|
||||
char *name;
|
||||
unsigned int dirID;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#include "oslib.h"
|
||||
#include "macemul.h"
|
||||
|
||||
#define OPTION_ASSERT(cond) do { if (!(cond)) { printf("%s:%u: failed assertion\n", __FILE__, __LINE__); abort(); } } while(0)
|
||||
|
||||
static char pfbuf[256];
|
||||
|
||||
StringPtr _pstrcpy(StringPtr dst, ConstStringPtr src) {
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
static const char *STR12010[79] = {
|
||||
"Option missing",
|
||||
"Command-line argument '%.15s...%.15s' is much too long, maximum accepted length is %d characters",
|
||||
"Parameter for '%s' missing",
|
||||
"Numeric constant '%s' overflowed 32-bit range",
|
||||
"Invalid %sconstant '%s'",
|
||||
"Numeric constant %lu is out of the legal range %lu - %lu",
|
||||
"Numeric constant %lu is out of the legal range %lu - %lu; clipping to %lu",
|
||||
"Four-char type '%s' is too long, expected maximum four characters",
|
||||
"String constant '%.16s...%.16s' too long, expected maximum %ld characters",
|
||||
"Identifier '%s' cannot start with a digit",
|
||||
"Identifier '%s' cannot contain the character '%c'",
|
||||
"Expected 'on' or 'off', but got '%s'",
|
||||
"Filename or directory '...%32s' is too long, expected maximum %ld characters",
|
||||
"Directory '...%32s' combined with filename '...%32s' is too long, maximum path is %ld characters",
|
||||
"File '%s' does not exist",
|
||||
"'%s' is a directory or volume, filename expected",
|
||||
"'%s' does not refer to a directory",
|
||||
"File path '%s' not accepted\n(%s)",
|
||||
"Unknown option '%s'",
|
||||
"Unknown option '%s'; expected one of '%s'",
|
||||
"Option is obsolete",
|
||||
"Option is obsolete; %s",
|
||||
"Option '%s' substituted with %s",
|
||||
"Option deprecated; accepted this time",
|
||||
"Option deprecated, accepted this time; use '%s' instead",
|
||||
"Option ignored",
|
||||
"Option ignored;\n%s",
|
||||
"%s",
|
||||
"Option has no effect on this target",
|
||||
"Option should not be specified multiple times",
|
||||
"Option overrides the effect of '%s'; only one of '%s' should be specified",
|
||||
"Option overrides the effect of '%s'; only one of '%s' should be specified;\n%s",
|
||||
"No default handler set up for '%s', ignoring",
|
||||
"Argument(s) expected",
|
||||
"Token '%s' not expected",
|
||||
"Unexpected additional argument '%s'",
|
||||
"Encountered extraneous arguments",
|
||||
"No help available for option '%s'",
|
||||
"Empty (zero-length) argument not accepted",
|
||||
"Variable name missing",
|
||||
"Only one output filename allowed; '%s' not accepted",
|
||||
"Output filenames found without source; '%s' not accepted",
|
||||
"Multiple outputs expected, output is ambiguous; '%s' not accepted",
|
||||
"Specified file '%s' not found",
|
||||
"Specified directory '%s' not found",
|
||||
"'%s' is a filename, not a directory; not accepted",
|
||||
"'%s' is a directory, not a filename; not accepted",
|
||||
"Library search found shared library '%s' instead of export library '%s.LIB'",
|
||||
"No library file found matching 'lib%s{%s}' or '%s'",
|
||||
"Redudant use of '%c%s%s'; linker always searches library paths;\ntypically one finds, e.g., libXXX.a with '%c%sXXX'",
|
||||
"Empty filename in library list ignored",
|
||||
"Environment variable '%s' not found",
|
||||
"In environment variable '%s':",
|
||||
"Option name expected for 'opt'",
|
||||
"Token '%s' ignored",
|
||||
"Token '%s[...%s]' was truncated to %d characters",
|
||||
"Expected %s, but got %s",
|
||||
"No output expected from this process, ignoring output name '%s'",
|
||||
"Only one output directory allowed, '%s' not accepted",
|
||||
"Storing browse info for '%s' in '%s'",
|
||||
"All linker output will be created in the same directory; ignoring path for '%s'",
|
||||
"Option overrides previously specified optimizations",
|
||||
"Could not initialize command line parser",
|
||||
"Output filename '%s' is invalid",
|
||||
"Truncated output filename '%s' to %d characters",
|
||||
"Output directory '%s' cannot be found",
|
||||
"Cannot add access path '%s'",
|
||||
"Cannot set preferences for '%s'",
|
||||
"Some of the files specified could not be found; build aborted",
|
||||
"Nothing to do: no source or object files specified",
|
||||
"Contents of %s:",
|
||||
"Overlays not supported on this target",
|
||||
"Segments not supported on this target",
|
||||
"Cannot open %s file '%s'",
|
||||
"",
|
||||
"The file \"%s\" may be ignored unless it has one of the following\nextensions: \"%s\"",
|
||||
"Not using non-text file '%s' as optional argument",
|
||||
"Cannot redirect stream to '%s' (%s)",
|
||||
0
|
||||
};
|
|
@ -32,6 +32,18 @@
|
|||
|
||||
// ----------
|
||||
// MacTypes.h
|
||||
#ifdef __MWERKS__
|
||||
typedef unsigned char UInt8;
|
||||
typedef signed char SInt8;
|
||||
typedef unsigned short UInt16;
|
||||
typedef signed short SInt16;
|
||||
typedef unsigned long UInt32;
|
||||
typedef signed long SInt32;
|
||||
typedef unsigned long long UInt64;
|
||||
typedef signed long long SInt64;
|
||||
|
||||
typedef long Size;
|
||||
#else
|
||||
typedef uint8_t UInt8;
|
||||
typedef int8_t SInt8;
|
||||
typedef uint16_t UInt16;
|
||||
|
@ -41,9 +53,11 @@ typedef int32_t SInt32;
|
|||
typedef uint64_t UInt64;
|
||||
typedef int64_t SInt64;
|
||||
|
||||
typedef int32_t Size;
|
||||
#endif
|
||||
|
||||
typedef char *Ptr;
|
||||
typedef Ptr *Handle;
|
||||
typedef int32_t Size;
|
||||
|
||||
typedef SInt16 OSErr;
|
||||
typedef SInt32 OSStatus;
|
||||
|
@ -73,6 +87,7 @@ enum {
|
|||
nilHandleErr = -109, // pointer was nil
|
||||
memLockedErr = -117,
|
||||
dirNFErr = -120,
|
||||
userCanceledErr = -128,
|
||||
inputOutOfBounds = -190,
|
||||
resNotFound = -192, // resource not found
|
||||
resFNotFound = -193, // resource file not found
|
||||
|
|
|
@ -2,294 +2,14 @@
|
|||
#include "common.h"
|
||||
#include "oslib.h"
|
||||
#include "macemul.h"
|
||||
#include "plugin.h"
|
||||
|
||||
#define OPTION_ASSERT(cond) do { if (!!(cond) == 0) { printf("%s:%u: failed assertion\n", __FILE__, __LINE__); abort(); } } while(0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/********************************/
|
||||
/* Option Fuckery */
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=packed
|
||||
#endif
|
||||
typedef struct PARAM_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
struct PARAM_T *next;
|
||||
} PARAM_T;
|
||||
typedef struct MASK_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
char size;
|
||||
UInt32 ormask;
|
||||
UInt32 andmask;
|
||||
void *num;
|
||||
} MASK_T;
|
||||
typedef struct STRING_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
SInt16 maxlen;
|
||||
Boolean pstring;
|
||||
char *str;
|
||||
} STRING_T;
|
||||
typedef struct SET_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
char size;
|
||||
UInt32 value;
|
||||
char *num;
|
||||
} SET_T;
|
||||
typedef struct SETSTRING_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
char *value;
|
||||
char pstring;
|
||||
void *var;
|
||||
} SETSTRING_T;
|
||||
typedef struct GENERIC_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
int (*parse)(const char *opt, void *var, const char *pstr, int flags);
|
||||
void *var;
|
||||
char *help;
|
||||
} GENERIC_T;
|
||||
typedef struct SETTING_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
int (*parse)(const char *a, const char *b); // TODO name these args
|
||||
char *valuename;
|
||||
} SETTING_T;
|
||||
typedef struct TOGGLE_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
char size;
|
||||
UInt32 mask;
|
||||
void *num;
|
||||
} TOGGLE_T;
|
||||
typedef struct NUM_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
char size;
|
||||
char fit;
|
||||
UInt32 lo;
|
||||
UInt32 hi;
|
||||
void *num;
|
||||
} NUM_T;
|
||||
typedef struct FILEPATH_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
char fflags;
|
||||
char *defaultstr;
|
||||
void *filename;
|
||||
int maxlen;
|
||||
} FILEPATH_T;
|
||||
typedef struct IFARG_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
PARAM_T *parg;
|
||||
char *helpa;
|
||||
PARAM_T *pnone;
|
||||
char *helpn;
|
||||
} IFARG_T;
|
||||
typedef struct ONOFF_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
unsigned char *var;
|
||||
} ONOFF_T;
|
||||
typedef struct OFFON_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
unsigned char *var;
|
||||
} OFFON_T;
|
||||
typedef struct FTYPE_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
OSType *fc;
|
||||
Boolean iscreator;
|
||||
} FTYPE_T;
|
||||
typedef struct OptionList {
|
||||
char *help;
|
||||
int flags;
|
||||
struct Option **list;
|
||||
} OptionList;
|
||||
typedef struct Option {
|
||||
char *names;
|
||||
int avail;
|
||||
PARAM_T *param;
|
||||
OptionList *sub;
|
||||
OptionList *conflicts;
|
||||
char *help;
|
||||
} Option;
|
||||
enum {
|
||||
HELPFLAGS_1 = 1,
|
||||
HELPFLAGS_IGNORED = 2,
|
||||
HELPFLAGS_OBSOLETE = 4,
|
||||
HELPFLAGS_DEPRECATED = 8,
|
||||
HELPFLAGS_SECRET = 0x10,
|
||||
HELPFLAGS_MEANINGLESS = 0x20,
|
||||
HELPFLAGS_COMPATIBLE = 0x40,
|
||||
HELPFLAGS_NORMAL = 0x80, // andmask = 0xE?
|
||||
HELPFLAGS_SPACES = 0x100,
|
||||
HELPFLAGS_TOOL = 0x200,
|
||||
HELPFLAGS_TOOL_THIS = 0x400,
|
||||
HELPFLAGS_TOOL_OTHER = 0x800,
|
||||
HELPFLAGS_TOOL_BOTH = 0xC00,
|
||||
HELPFLAGS_1000 = 0x1000,
|
||||
HELPFLAGS_2000 = 0x2000,
|
||||
HELPFLAGS_USAGE = 0x4000,
|
||||
HELPFLAGS_8000 = 0x8000
|
||||
};
|
||||
enum {
|
||||
OTF_GLOBAL = 1,
|
||||
OTF2 = 2,
|
||||
OTF_CASED = 4,
|
||||
OTF_OBSOLETE = 8,
|
||||
OTF_SUBSTITUTED = 0x10,
|
||||
OTF_DEPRECATED = 0x20,
|
||||
OTF_TOOL_LINKER = 0x40,
|
||||
OTF_TOOL_DISASSEMBLER = 0x80,
|
||||
OTF_TOOL_COMPILER = 0x100,
|
||||
OTF_TOOL_MASK = OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER | OTF_TOOL_COMPILER,
|
||||
OTF200 = 0x200,
|
||||
OTF400 = 0x400,
|
||||
OTF700 = 0x700,
|
||||
OTF_IGNORED = 0x800,
|
||||
OTFC00 = 0xC00,
|
||||
OTF_SECRET = 0x1000,
|
||||
OTF2000 = 0x2000,
|
||||
OTF_COMPATIBILITY = 0x4000,
|
||||
OTF8000 = 0x8000,
|
||||
OTF10000 = 0x10000,
|
||||
OTF20000 = 0x20000,
|
||||
OTF40000 = 0x40000,
|
||||
OTF_WARNING = 0x80000,
|
||||
OTF_SLFLAGS_8 = 0x100000,
|
||||
OTF_SLFLAGS_10 = 0x200000,
|
||||
OTF_SLFLAGS_20 = 0x400000,
|
||||
OTF_SLFLAGS_MASK = OTF_SLFLAGS_8 | OTF_SLFLAGS_10 | OTF_SLFLAGS_20,
|
||||
OTF_MEANINGLESS = 0x800000,
|
||||
OTF_ALL_HIDDEN_BY_DEFAULT = OTF_OBSOLETE | OTF_DEPRECATED | OTF_IGNORED | OTF_SECRET | OTF_MEANINGLESS,
|
||||
OTF1000000 = 0x1000000,
|
||||
OTF2000000 = 0x2000000,
|
||||
OTF4000000 = 0x4000000,
|
||||
OTF8000000 = 0x8000000,
|
||||
OTF10000000 = 0x10000000,
|
||||
OTF20000000 = 0x20000000,
|
||||
OTF40000000 = 0x40000000,
|
||||
OTF80000000 = 0x80000000
|
||||
};
|
||||
|
||||
enum {
|
||||
PARAMWHICH_None = 0,
|
||||
PARAMWHICH_FTypeCreator = 1,
|
||||
PARAMWHICH_FilePath = 2,
|
||||
PARAMWHICH_Number = 3,
|
||||
PARAMWHICH_String = 4,
|
||||
PARAMWHICH_Id = 5,
|
||||
PARAMWHICH_Sym = 6,
|
||||
PARAMWHICH_OnOff = 7,
|
||||
PARAMWHICH_OffOn = 8,
|
||||
PARAMWHICH_Mask = 9,
|
||||
PARAMWHICH_Toggle = 0xA,
|
||||
PARAMWHICH_Set = 0xB,
|
||||
PARAMWHICH_SetString = 0xC,
|
||||
PARAMWHICH_Generic = 0xD,
|
||||
PARAMWHICH_IfArg = 0xE,
|
||||
PARAMWHICH_Setting = 0xF,
|
||||
PARAMWHICH_MAX = 0x10
|
||||
};
|
||||
enum {
|
||||
PARAMFLAGS_1 = 1,
|
||||
PARAMFLAGS_2 = 2,
|
||||
PARAMFLAGS_3 = 3,
|
||||
PARAMFLAGS_4 = 4,
|
||||
PARAMFLAGS_8 = 8,
|
||||
PARAMFLAGS_10 = 0x10,
|
||||
PARAMFLAGS_12 = 0x12
|
||||
};
|
||||
enum {
|
||||
PARAMPARSEFLAGS_0 = 0,
|
||||
PARAMPARSEFLAGS_1 = 1,
|
||||
PARAMPARSEFLAGS_2 = 2,
|
||||
PARAMPARSEFLAGS_4 = 4,
|
||||
PARAMPARSEFLAGS_8 = 8,
|
||||
PARAMPARSEFLAGS_10 = 0x10,
|
||||
PARAMPARSEFLAGS_20 = 0x20,
|
||||
PARAMPARSEFLAGS_40 = 0x40,
|
||||
PARAMPARSEFLAGS_80 = 0x80,
|
||||
PARAMPARSEFLAGS_100 = 0x100
|
||||
};
|
||||
enum {
|
||||
SLFLAGS_1 = 1,
|
||||
SLFLAGS_2 = 2,
|
||||
SLFLAGS_4 = 4, // displays =...
|
||||
SLFLAGS_8 = 8, // displays [no] -- produces e.g. [no]err[or] | [no]iserr[or], [no]implicit[conv]
|
||||
SLFLAGS_10 = 0x10, // displays [-]
|
||||
SLFLAGS_20 = 0x20, // displays [no-]
|
||||
SLFLAGS_40 = 0x40
|
||||
};
|
||||
enum {
|
||||
LISTFLAGS_NONE = 0,
|
||||
LISTFLAGS_2 = 2,
|
||||
LISTFLAGS_4 = 4,
|
||||
LISTFLAGS_COMPILER = 0x100,
|
||||
LISTFLAGS_LINKER = 0x200,
|
||||
LISTFLAGS_DISASSEMBLER = 0x400,
|
||||
LISTFLAGS_TOOL_MASK = LISTFLAGS_COMPILER | LISTFLAGS_LINKER | LISTFLAGS_DISASSEMBLER
|
||||
};
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=reset
|
||||
#endif
|
||||
|
||||
#define CWFOURCHAR(a, b, c, d) \
|
||||
(((OSType) ((a) & 0xff) << 24) \
|
||||
| ((OSType) ((b) & 0xff) << 16) \
|
||||
| ((OSType) ((c) & 0xff) << 8) \
|
||||
| ((OSType) ((d) & 0xff)))
|
||||
|
||||
struct IDEAccessPath {
|
||||
FSSpec pathSpec;
|
||||
Boolean recursive;
|
||||
SInt32 subdirectoryCount;
|
||||
FSSpec *subdirectories;
|
||||
};
|
||||
|
||||
struct IDEAccessPathList {
|
||||
SInt32 userPathCount;
|
||||
struct IDEAccessPath *userPaths;
|
||||
SInt32 systemPathCount;
|
||||
struct IDEAccessPath *systemPaths;
|
||||
unsigned char alwaysSearchUserPaths;
|
||||
unsigned char convertPaths;
|
||||
};
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=mac68k
|
||||
#endif
|
||||
|
@ -314,179 +34,10 @@ typedef struct CWObjectFlags {
|
|||
OSType depFileType;
|
||||
} CWObjectFlags;
|
||||
|
||||
typedef struct CWIDEInfo {
|
||||
UInt16 majorVersion;
|
||||
UInt16 minorVersion;
|
||||
UInt16 bugFixVersion;
|
||||
UInt16 buildVersion;
|
||||
UInt16 dropinAPIVersion;
|
||||
} CWIDEInfo;
|
||||
|
||||
typedef struct DropInFlags {
|
||||
SInt16 rsrcversion;
|
||||
OSType dropintype;
|
||||
UInt16 earliestCompatibleAPIVersion;
|
||||
UInt32 dropinflags;
|
||||
OSType edit_language;
|
||||
UInt16 newestAPIVersion;
|
||||
} DropInFlags;
|
||||
|
||||
typedef struct CWPanelList {
|
||||
SInt16 version;
|
||||
SInt16 count;
|
||||
const char **names;
|
||||
} CWPanelList;
|
||||
|
||||
typedef struct CWFamily {
|
||||
OSType type;
|
||||
const char *name;
|
||||
} CWFamily;
|
||||
|
||||
typedef struct CWFamilyList {
|
||||
SInt16 version;
|
||||
SInt16 count;
|
||||
CWFamily *families;
|
||||
} CWFamilyList;
|
||||
|
||||
typedef struct CWTargetList {
|
||||
SInt16 version;
|
||||
SInt16 cpuCount;
|
||||
OSType *cpus;
|
||||
SInt16 osCount;
|
||||
OSType *oss;
|
||||
} CWTargetList;
|
||||
|
||||
typedef struct CWExtensionMapping {
|
||||
OSType type;
|
||||
char extension[32];
|
||||
UInt32 flags;
|
||||
} CWExtensionMapping;
|
||||
|
||||
typedef struct CWExtMapList {
|
||||
SInt16 version;
|
||||
SInt16 nMappings;
|
||||
CWExtensionMapping *mappings;
|
||||
} CWExtMapList;
|
||||
|
||||
typedef struct CWHelpInfo {
|
||||
SInt16 version;
|
||||
const char *helpFileName;
|
||||
} CWHelpInfo;
|
||||
|
||||
#define kCurrentDropInFlagsVersion 2
|
||||
#define kCurrentCWPanelListVersion 1
|
||||
#define kCurrentCWFamilyListVersion 1
|
||||
#define kCurrentCWFamilyResourceVersion 1
|
||||
#define kCurrentCWHelpInfoVersion 1
|
||||
#define kCurrentCWPluginInfoVersion 1
|
||||
#define kCurrentCWTargetListVersion 1
|
||||
#define kCurrentCWTargetListResourceVersion 1
|
||||
|
||||
enum {
|
||||
CWDROPINCOMPILERTYPE = CWFOURCHAR('C', 'o', 'm', 'p'),
|
||||
CWDROPINLINKERTYPE = CWFOURCHAR('L', 'i', 'n', 'k')
|
||||
};
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=reset
|
||||
#endif
|
||||
|
||||
struct CW_BasePluginCallbacks {
|
||||
void (*cbGetFileInfo)();
|
||||
void (*cbFindAndLoadFile)();
|
||||
void (*cbGetFileText)();
|
||||
void (*cbReleaseFileText)();
|
||||
void (*cbGetSegmentInfo)();
|
||||
void (*cbGetOverlay1GroupInfo)();
|
||||
void (*cbGetOverlay1Info)();
|
||||
void (*cbGetOverlay1FileInfo)();
|
||||
void (*cbReportMessage)();
|
||||
void (*cbAlert)();
|
||||
void (*cbShowStatus)();
|
||||
void (*cbUserBreak)();
|
||||
void (*cbGetNamedPreferences)();
|
||||
void (*cbStorePluginData)();
|
||||
void (*cbGetPluginData)();
|
||||
void (*cbSetModDate)();
|
||||
void (*cbAddProjectEntry)();
|
||||
void (*cbCreateNewTextDocument)();
|
||||
void (*cbAllocateMemory)();
|
||||
void (*cbFreeMemory)();
|
||||
void (*cbAllocMemHandle)();
|
||||
void (*cbFreeMemHandle)();
|
||||
void (*cbGetMemHandleSize)();
|
||||
void (*cbResizeMemHandle)();
|
||||
void (*cbLockMemHandle)();
|
||||
void (*cbUnlockMemHandle)();
|
||||
void *cbInternal[8];
|
||||
void (*cbGetTargetName)();
|
||||
void (*cbCacheAccessPathList)();
|
||||
void (*cbPreDialog)();
|
||||
void (*cbPostDialog)();
|
||||
void (*cbPreFileAction)();
|
||||
void (*cbPostFileAction)();
|
||||
void (*cbCheckoutLicense)();
|
||||
void (*cbCheckinLicense)();
|
||||
void (*cbResolveRelativePath)();
|
||||
};
|
||||
struct CWCompilerLinkerCallbacks {
|
||||
void (*cbCachePrecompiledHeader)();
|
||||
void (*cbLoadObjectData)();
|
||||
void (*cbStoreObjectData)();
|
||||
void (*cbFreeObjectData)();
|
||||
void (*cbDisplayLines)();
|
||||
void (*cbBeginSubCompile)();
|
||||
void (*cbEndSubCompile)();
|
||||
void (*cbGetPrecompiledHeaderSpec)();
|
||||
void (*cbPutResourceFile)();
|
||||
void (*cbGetResourceFile)();
|
||||
void (*cbLookUpUnit)();
|
||||
void (*cbSBMfiles)();
|
||||
void (*cbStoreUnit)();
|
||||
void (*cbReleaseUnit)();
|
||||
void (*cbUnitNameToFileName)();
|
||||
void (*cbOSErrorMessage)();
|
||||
void (*cbOSAlert)();
|
||||
void (*cbGetModifiedFiles)();
|
||||
void (*cbGetSuggestedObjectFileSpec)();
|
||||
void (*cbGetStoredObjectFileSpec)();
|
||||
void (*cbGetRuntimeSettings)();
|
||||
void (*cbGetFrameworkCount)();
|
||||
void (*cbGetFrameworkInfo)();
|
||||
void (*cbGetFrameworkSharedLibrary)();
|
||||
};
|
||||
struct CWParserCallbacks {
|
||||
void (*cbParserAddAccessPath)();
|
||||
void (*cbParserSwapAccessPaths)();
|
||||
void (*cbParserSetNamedPreferences)();
|
||||
void (*cbParserSetFileOutputName)();
|
||||
void (*cbParserSetOutputFileDirectory)();
|
||||
void (*cbParserAddOverlay1Group)();
|
||||
void (*cbParserAddOverlay1)();
|
||||
void (*cbParserAddSegment)();
|
||||
void (*cbParserSetSegment)();
|
||||
};
|
||||
|
||||
struct CWPluginPrivateContext {
|
||||
SInt32 request;
|
||||
SInt32 apiVersion;
|
||||
void *shellContext;
|
||||
void *pluginStorage;
|
||||
FSSpec projectFile;
|
||||
FSSpec outputFileDirectory;
|
||||
OSType shellSignature;
|
||||
OSType pluginType;
|
||||
SInt32 numFiles;
|
||||
SInt32 numOverlayGroups;
|
||||
OSErr callbackOSError;
|
||||
OSErr pluginOSError;
|
||||
CWIDEInfo *shellInfo;
|
||||
struct IDEAccessPathList *accessPathList;
|
||||
SInt32 dontEatEvents;
|
||||
FSSpec *targetDataDirectorySpec;
|
||||
SInt32 reserved[17];
|
||||
struct CW_BasePluginCallbacks *callbacks;
|
||||
};
|
||||
|
||||
// Pref panels
|
||||
#ifdef __MWERKS__
|
||||
|
@ -498,6 +49,17 @@ enum {
|
|||
OptsCmdLineState_2 = 2,
|
||||
OptsCmdLineState_3 = 3
|
||||
};
|
||||
enum {
|
||||
CmdLineStage_Cg = 1,
|
||||
CmdLineStage_Pp = 2,
|
||||
CmdLineStage_Ds = 3
|
||||
};
|
||||
enum {
|
||||
CmdLineStageMask_Pp = 1,
|
||||
CmdLineStageMask_Cg = 2,
|
||||
CmdLineStageMask_Ds = 4,
|
||||
CmdLineStageMask_Dp = 8
|
||||
};
|
||||
typedef struct PCmdLine {
|
||||
SInt16 version;
|
||||
SInt16 state;
|
||||
|
@ -667,12 +229,6 @@ typedef struct {
|
|||
Str255 symfilename;
|
||||
} PCLTExtras;
|
||||
|
||||
typedef struct CWCommandLineArgs {
|
||||
int argc;
|
||||
char **argv;
|
||||
char **envp;
|
||||
} CWCommandLineArgs;
|
||||
|
||||
typedef struct VersionInfo {
|
||||
UInt16 major;
|
||||
UInt16 minor;
|
||||
|
@ -680,7 +236,7 @@ typedef struct VersionInfo {
|
|||
UInt16 build;
|
||||
} VersionInfo;
|
||||
|
||||
typedef struct CLPluginInfo {
|
||||
/*typedef struct CLPluginInfo {
|
||||
OSType plugintype;
|
||||
OSType language;
|
||||
SInt32 dropinflags;
|
||||
|
@ -694,7 +250,7 @@ typedef struct ToolVersionInfo {
|
|||
char *tool;
|
||||
char *copyright;
|
||||
char *version;
|
||||
} ToolVersionInfo;
|
||||
} ToolVersionInfo;*/
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=reset
|
||||
#endif
|
||||
|
@ -707,11 +263,11 @@ struct ParseOptsType {
|
|||
UInt16 ioCols;
|
||||
UInt16 ioRows;
|
||||
CWCommandLineArgs *args;
|
||||
ToolVersionInfo *toolVersion;
|
||||
const ToolVersionInfo *toolVersion;
|
||||
int numPlugins;
|
||||
CLPluginInfo *plugins;
|
||||
const CLPluginInfo *plugins;
|
||||
int numPanels;
|
||||
char **panelNames;
|
||||
const char **panelNames;
|
||||
OSType cpu;
|
||||
OSType os;
|
||||
char lastoutputname[256];
|
||||
|
@ -763,7 +319,7 @@ typedef struct {
|
|||
} CLState; // assumed name
|
||||
|
||||
typedef struct BasePluginCallbacks {
|
||||
SInt16 (*main)(void *context);
|
||||
SInt16 (*main)(CWPluginContext context);
|
||||
SInt16 (*GetDropInFlags)(const DropInFlags **flags, SInt32 *flagsSize);
|
||||
SInt16 (*GetDisplayName)(const char **displayName);
|
||||
SInt16 (*GetDropInName)(const char **dropInName);
|
||||
|
@ -804,12 +360,12 @@ typedef struct {
|
|||
char *toolInfo;
|
||||
char *copyright;
|
||||
int numOptionLists;
|
||||
OptionList **optionLists;
|
||||
struct OptionList **optionLists;
|
||||
int numPrefDataPanels;
|
||||
PrefDataPanel *prefDataPanels;
|
||||
int (*PreParse)(); // sig?
|
||||
int (*MidParse)(); // sig?
|
||||
int (*PostParse)(); // sig?
|
||||
int (*PreParse)();
|
||||
int (*MidParse)();
|
||||
int (*PostParse)();
|
||||
} ParserTool; // assumed name
|
||||
|
||||
// I think this is internally defined in its .c file
|
||||
|
@ -985,7 +541,7 @@ typedef struct CLTargetInfo {
|
|||
OSSpec runfile;
|
||||
OSSpec linkAgainstFile;
|
||||
} CLTargetInfo;
|
||||
typedef struct CWTargetInfo {
|
||||
/*typedef struct CWTargetInfo {
|
||||
SInt16 outputType;
|
||||
FSSpec outfile;
|
||||
FSSpec symfile;
|
||||
|
@ -1000,7 +556,7 @@ typedef struct CWTargetInfo {
|
|||
OSType debuggerCreator;
|
||||
OSType runHelperCreator;
|
||||
FSSpec linkAgainstFile;
|
||||
} CWTargetInfo;
|
||||
} CWTargetInfo;*/
|
||||
typedef struct Target {
|
||||
struct BuildInfo {
|
||||
UInt32 linesCompiled;
|
||||
|
@ -1186,8 +742,10 @@ typedef struct Project {
|
|||
Target *targets;
|
||||
OSSpec projectDirectory;
|
||||
} Project;
|
||||
#ifndef __cplusplus
|
||||
extern int Proj_Initialize(Project *this);
|
||||
extern int Proj_Terminate(Project *this);
|
||||
#endif
|
||||
|
||||
/********************************/
|
||||
/* command_line/CmdLine/Src/CLLicenses.c */
|
||||
|
@ -1300,8 +858,8 @@ extern void Paths_CopyRecurseFSS(FSSpec *fss, Paths *paths, UInt16 count);
|
|||
//static Boolean CheckForFileInFrameworkDir(char *out, const char *framework_path, OSPathSpec *osps, const char *fname);
|
||||
//static Boolean CheckForFileInFramework(char *out, int i, const char *fname);
|
||||
extern Boolean MakeFrameworkPath(char *out, const char *filename, OSPathSpec **globalpath);
|
||||
extern Boolean Frameworks_AddPath(const OSPathSpec *oss);
|
||||
extern Boolean Frameworks_AddFramework(const char *frameworkName, const char *version, Boolean flag);
|
||||
extern void Frameworks_AddPath(const OSPathSpec *oss);
|
||||
extern int Frameworks_AddFramework(const char *frameworkName, const char *version, Boolean flag);
|
||||
extern void Framework_GetEnvInfo();
|
||||
extern int Frameworks_GetCount();
|
||||
extern Paths_FWInfo *Frameworks_GetInfo(int which);
|
||||
|
@ -1315,6 +873,7 @@ extern OSErr GetMacFileType(const FSSpec *fss, void *a); // TODO sig
|
|||
|
||||
/********************************/
|
||||
/* command_line/CmdLine/Src/Project/CLFiles.c */
|
||||
#ifndef __cplusplus
|
||||
extern File *File_New();
|
||||
extern void File_Free(File *file);
|
||||
extern Boolean Files_Initialize(Files *this);
|
||||
|
@ -1329,9 +888,11 @@ extern void VFiles_Terminate(VFile **list);
|
|||
extern VFile *VFile_New(const char *name, OSHandle *data);
|
||||
extern Boolean VFiles_Add(VFile **list, VFile *entry);
|
||||
extern VFile *VFiles_Find(VFile *list, const char *name);
|
||||
#endif
|
||||
|
||||
/********************************/
|
||||
/* command_line/CmdLine/Src/Project/CLOverlays.c */
|
||||
#ifndef __cplusplus
|
||||
extern Boolean Overlays_Initialize(Overlays *this);
|
||||
extern Boolean Overlays_Terminate(Overlays *this);
|
||||
extern Boolean Overlays_AddOvlGroup(Overlays *this, OvlGroup *grp, SInt32 *grpnum);
|
||||
|
@ -1350,6 +911,7 @@ extern void Overlay_Delete(Overlay *oly);
|
|||
extern Boolean Overlay_AddFile(Overlay *oly, SInt32 filenum, SInt32 *filnum);
|
||||
extern SInt32 Overlay_GetFile(Overlay *oly, SInt32 filnul);
|
||||
extern SInt32 Overlay_CountFiles(Overlay *oly);
|
||||
#endif
|
||||
|
||||
/********************************/
|
||||
/* command_line/CmdLine/Src/Project/CLSegs.c */
|
||||
|
@ -1488,12 +1050,12 @@ extern int DisplayWarningOptions();
|
|||
|
||||
/********************************/
|
||||
/* StaticParserGlue.c */
|
||||
extern int RegisterStaticParserResources();
|
||||
extern int RegisterStaticParserPlugins();
|
||||
extern int RegisterStaticParserResources();
|
||||
|
||||
/********************************/
|
||||
/* ParserFace.c */
|
||||
extern Handle Parser_FindPrefPanel(char *name);
|
||||
extern Handle Parser_FindPrefPanel(const char *name);
|
||||
extern SInt32 Parser_StorePanels(struct CWPluginPrivateContext *context);
|
||||
extern SInt16 CWParser_GetDropInFlags(const DropInFlags **flags, SInt32 *flagsSize);
|
||||
extern SInt16 CWParser_GetDropInName(const char **dropinName);
|
||||
|
@ -1502,20 +1064,23 @@ extern SInt16 CWParser_GetPanelList(const CWPanelList **panelList);
|
|||
extern SInt16 CWParser_GetTargetList(const CWTargetList **targetList);
|
||||
extern SInt16 CWParser_GetVersionInfo(const VersionInfo **versioninfo);
|
||||
extern SInt16 Parser_SupportsPlugin(struct CLPluginInfo *pluginfo, OSType cpu, OSType os, Boolean *isSupported);
|
||||
extern SInt16 Parser_SupportsPanels(int numPanels, char **panelNames, Boolean *isSupported);
|
||||
extern SInt16 Parser_SupportsPanels(int numPanels, const char **panelNames, Boolean *isSupported);
|
||||
extern SInt16 parser_main(struct CWPluginPrivateContext *context);
|
||||
|
||||
extern const char *failedCallback;
|
||||
extern jmp_buf exit_plugin;
|
||||
extern struct ParseOptsType parseopts;
|
||||
|
||||
/********************************/
|
||||
/* ParserHelpers.c */
|
||||
extern SInt16 lastStage;
|
||||
|
||||
extern int FindFileInPath(const char *filename, OSSpec *fss);
|
||||
extern char *GetEnvVar(const char *name, Boolean warn, char **match);
|
||||
//static Boolean MatchesExtension(const char *list, const char *filename);
|
||||
extern char *GetEnvVar(const char *name, Boolean warn, const char **match);
|
||||
extern int Opt_AddAccessPath(const char *opt, void *var, const char *arg);
|
||||
extern int Opt_AddFrameworkPath(const char *opt, void *var, const char *arg);
|
||||
extern int Opt_AddFramework(const char *opt, void *var, const char *arg);
|
||||
extern void ListParseMessage(void *errprint, const char *envvar, SInt16 id); // TODO funcptr sig - same as CLPReportWarning_V, CLPReportError_V
|
||||
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);
|
||||
extern int Opt_FindAndAddFileRef(const char *opt, void *var, const char *arg);
|
||||
|
@ -1524,8 +1089,8 @@ extern int AddFileList(const char *list, char sep1, char sep2, int source, char
|
|||
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 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);
|
||||
extern void GetFirstSourceFilenameBase(char *buffer, char *defaul);
|
||||
extern int Opt_SavePrefs(const char *opt, void *var, const char *arg);
|
||||
|
@ -1534,21 +1099,42 @@ extern int Opt_MaybeMoveAccessPaths(const char *opt, void *var, const char *arg)
|
|||
|
||||
/********************************/
|
||||
/* ToolHelpers.c */
|
||||
enum {
|
||||
OutputOrdering0 = 0,
|
||||
OutputOrdering1 = 1,
|
||||
OutputOrdering2 = 2
|
||||
};
|
||||
extern SInt16 outputOrdering;
|
||||
extern Boolean setOutputDirectory;
|
||||
|
||||
extern int Opt_HandleOutputName(const char *opt, void *, const char *filename);
|
||||
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, ...);
|
||||
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);
|
||||
extern int Opt_SetStage(const char *opt, void *str, const char *arg, void *unk);
|
||||
// lots of the Opt_ funcs have weird sigs, need to double check them
|
||||
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);
|
||||
|
||||
/********************************/
|
||||
/* ParserHelpers-cc.c */
|
||||
extern Handle definesHandle;
|
||||
|
||||
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;
|
||||
|
@ -1564,43 +1150,6 @@ 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);
|
||||
|
||||
/********************************/
|
||||
/* Arguments.c */
|
||||
typedef struct {
|
||||
SInt16 val;
|
||||
char *text;
|
||||
} ArgToken;
|
||||
enum {
|
||||
ATK_0,
|
||||
ATK_1,
|
||||
ATK_2,
|
||||
ATK_3,
|
||||
ATK_4,
|
||||
ATK_5
|
||||
};
|
||||
typedef struct {
|
||||
int argc;
|
||||
int nargv;
|
||||
char **argv;
|
||||
} anon0_50;
|
||||
|
||||
extern void Arg_Init(int theargc, char **theargv);
|
||||
extern void Arg_Terminate();
|
||||
extern void Arg_Reset();
|
||||
extern void Arg_Stop(ArgToken *where);
|
||||
extern ArgToken *Arg_PeekToken();
|
||||
extern ArgToken *Arg_UsedToken();
|
||||
extern int Arg_IsEmpty();
|
||||
extern ArgToken *Arg_GetToken();
|
||||
extern ArgToken *Arg_UndoToken();
|
||||
extern const char *Arg_GetTokenName(ArgToken *tok);
|
||||
extern const char *Arg_GetTokenText(ArgToken *tok, char *buffer, int maxlen, unsigned char warn);
|
||||
extern void Arg_InitToolArgs(anon0_50 *ta);
|
||||
extern void Arg_AddToToolArgs(anon0_50 *ta, SInt16 tokval, char *toktxt);
|
||||
extern void Arg_FinishToolArgs(anon0_50 *ta);
|
||||
extern void Arg_ToolArgsForPlugin(anon0_50 *ta, struct CWCommandLineArgs *args);
|
||||
extern void Arg_FreeToolArgs(anon0_50 *ta);
|
||||
|
||||
/********************************/
|
||||
/* ToolHelpers-cc.c */
|
||||
extern int Opt_DummyLinkerRoutine(const char *opt);
|
||||
|
@ -1618,12 +1167,12 @@ 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(const OSPathSpec *oss, SInt16 type, SInt32 position, Boolean recursive);
|
||||
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(const OSPathSpec *dir);
|
||||
extern void AddOverlayGroup(const char *name, OvlAddr *addr, SInt32 *groupnum, SInt32 *overlaynum);
|
||||
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);
|
||||
|
@ -1631,72 +1180,13 @@ extern int GetSegment(SInt32 segmentnum, char *name, SInt16 *attrs);
|
|||
|
||||
/********************************/
|
||||
/* 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();
|
||||
|
||||
/********************************/
|
||||
/* Option.c */
|
||||
typedef struct {
|
||||
void *first;
|
||||
void *second;
|
||||
} Opt50;
|
||||
typedef struct {
|
||||
Option *opt;
|
||||
char *curopt;
|
||||
} Opt52;
|
||||
typedef struct {
|
||||
union {
|
||||
Opt50 v;
|
||||
OptionList *lst;
|
||||
Opt52 o;
|
||||
char *param;
|
||||
} e;
|
||||
SInt16 flags;
|
||||
} Opt48;
|
||||
//static void Option_PushList(OptionList *lst);
|
||||
//static void Option_PushOpt(Option *opt, const char *optname);
|
||||
//static void Option_PopOpt(const char *optname);
|
||||
//static void Option_PopList();
|
||||
extern void Args_InitStack();
|
||||
extern int Args_StackSize();
|
||||
extern void Args_Push(SInt16 flags, void *first, void *second);
|
||||
extern Opt48 *Args_Pop(SInt16 flags);
|
||||
extern void Args_SpellStack(char *buffer, SInt16 flags);
|
||||
extern void Args_AddToToolArgs(anon0_50 *ta);
|
||||
extern void Options_Init();
|
||||
extern OptionList *Options_GetOptions();
|
||||
extern void Options_SortOptions();
|
||||
//static void Options_AddOption(Option *opt);
|
||||
extern int Options_AddList(OptionList *optlst);
|
||||
extern int Options_AddLists(OptionList **optlst);
|
||||
//static void Options_Reset(OptionList *optlst);
|
||||
//static void Option_SpellList(char *buffer, OptionList *conflicts, int flags);
|
||||
extern int Option_ForTool(Option *opt, int which);
|
||||
extern int Option_ThisTool();
|
||||
extern int Option_ForThisTool(Option *opt);
|
||||
extern int Option_AlsoPassedToTool(Option *opt, int which);
|
||||
extern int Option_AlsoPassedFromThisTool(Option *opt);
|
||||
//static Boolean Option_ContinuesThisLevel(int level, ArgToken *tok);
|
||||
//static Boolean Option_IsEndingThisLevel(int level, ArgToken *tok);
|
||||
//static Boolean Option_IsEndingLevel(int level, ArgToken *tok);
|
||||
extern int Option_Parse(Option *opt, int oflags);
|
||||
//static int Option_MatchString(char *list, char *str, int flags, int *result);
|
||||
//static Option *Option_Lookup(OptionList *search, void *unk, int *flags);
|
||||
//static int Options_DoParse(OptionList *search, int flags);
|
||||
extern int Options_Parse(OptionList *options, int flags);
|
||||
extern int Option_ParseDefaultOption(OptionList *options);
|
||||
extern void Option_ParamError(SInt16 id, va_list ap);
|
||||
extern void Option_ParamWarning(SInt16 id, va_list ap);
|
||||
extern void Option_OptionError(SInt16 id, va_list ap);
|
||||
extern void Option_OptionWarning(SInt16 id, va_list ap);
|
||||
extern void Option_Error(SInt16 id, ...);
|
||||
extern void Option_Warning(SInt16 id, ...);
|
||||
extern int Options_Help(const char *keyword);
|
||||
extern int Option_Help(const char *opt);
|
||||
extern int Options_DisplayHelp();
|
||||
|
||||
/********************************/
|
||||
/* ParserErrors.c */
|
||||
extern void CLPReportError_V(const char *format, va_list ap);
|
||||
|
@ -1705,7 +1195,7 @@ 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 void CLPGetErrorString(SInt16 errid, char *buffer);
|
||||
extern char *CLPGetErrorString(SInt16 errid, char *buffer);
|
||||
extern void CLPReportError(SInt16 errid, ...);
|
||||
extern void CLPReportWarning(SInt16 errid, ...);
|
||||
extern void CLPReport(SInt16 errid, ...);
|
||||
|
@ -1721,32 +1211,22 @@ extern char curopt[1024];
|
|||
/* Utils.c */
|
||||
// something is weird with these parameters
|
||||
// they're supposed to be just "char"...
|
||||
#ifdef UNSIGNED_CHAR_FOR_MY_UTILS
|
||||
extern int my_tolower(unsigned char c);
|
||||
extern int my_isdigit(unsigned char c);
|
||||
extern int my_isalpha(unsigned char c);
|
||||
extern int my_isalnum(unsigned char c);
|
||||
extern int my_isxdigit(unsigned char c);
|
||||
#else
|
||||
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);
|
||||
#endif
|
||||
extern char *Utils_SpellList(char *list, char *buffer, char opts);
|
||||
extern int Utils_CompareOptionString(const char *a, const char *b, int cased, int sticky);
|
||||
|
||||
/********************************/
|
||||
/* Parameter.c */
|
||||
extern void Param_DescHelp(PARAM_T *param, const char **desc, const char **help, const char **defaul);
|
||||
extern int Param_Compare(PARAM_T *param);
|
||||
extern int Params_Parse(PARAM_T *param, int flags);
|
||||
extern void Param_Error(SInt16 id, ...);
|
||||
extern void Param_Warning(SInt16 id, ...);
|
||||
|
||||
/********************************/
|
||||
/* Help.c */
|
||||
extern int Help_Option(struct OptionList *lst, struct Option *opt, int subprint, const char *keyword);
|
||||
extern void Help_Options(struct OptionList *lst, int subprint, const char *keyword);
|
||||
extern void Help_Usage();
|
||||
extern void Help_Null();
|
||||
extern void Help_Init();
|
||||
extern void Help_Line(char ch);
|
||||
extern void Help_Term();
|
||||
|
||||
/********************************/
|
||||
/* */
|
||||
|
||||
|
@ -1798,10 +1278,11 @@ extern void COS_FileGetFSSpecInfo(const FSSpec *spec, SInt16 *vRefNum, SInt32 *d
|
|||
extern void COS_FileGetPathName(char *buffer, const FSSpec *spec, SInt32 *mdDat);
|
||||
extern Boolean COS_EqualFileSpec(const FSSpec *a, const FSSpec *b);
|
||||
|
||||
#include "option_system.h"
|
||||
|
||||
|
||||
// TODO sort me
|
||||
extern Project *gProj;
|
||||
extern ParserTool *pTool;
|
||||
extern PCmdLine optsCmdLine;
|
||||
extern PCmdLineEnvir optsEnvir;
|
||||
extern PCmdLineCompiler optsCompiler;
|
||||
|
@ -1826,6 +1307,10 @@ extern char *MAINOPTCHAR;
|
|||
extern char *SEPOPTSTR;
|
||||
extern char compat;
|
||||
extern anon0_50 linkargs;
|
||||
extern anon0_50 prelinkargs;
|
||||
extern anon0_50 postlinkargs;
|
||||
extern PCmdLine pCmdLine;
|
||||
extern PCmdLineCompiler pCmdLineCompiler;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -0,0 +1,413 @@
|
|||
#pragma once
|
||||
#include "common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=packed
|
||||
#endif
|
||||
enum {
|
||||
OptParseError = 0,
|
||||
OptParseSuccess = 1
|
||||
};
|
||||
|
||||
typedef struct PARAM_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
struct PARAM_T *next;
|
||||
} PARAM_T;
|
||||
typedef struct MASK_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
char size;
|
||||
UInt32 ormask;
|
||||
UInt32 andmask;
|
||||
void *num;
|
||||
} MASK_T;
|
||||
typedef struct STRING_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
SInt16 maxlen;
|
||||
Boolean pstring;
|
||||
char *str;
|
||||
} STRING_T;
|
||||
typedef struct SET_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
char size;
|
||||
UInt32 value;
|
||||
char *num;
|
||||
} SET_T;
|
||||
typedef struct SETSTRING_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
char *value;
|
||||
char pstring;
|
||||
void *var;
|
||||
} SETSTRING_T;
|
||||
typedef struct GENERIC_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
|
||||
int (*parse)(const char *opt, void *var, const char *pstr, int flags);
|
||||
|
||||
void *var;
|
||||
char *help;
|
||||
} GENERIC_T;
|
||||
typedef struct SETTING_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
|
||||
int (*parse)(const char *a, const char *b); // TODO name these args
|
||||
char *valuename;
|
||||
} SETTING_T;
|
||||
typedef struct TOGGLE_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
char size;
|
||||
UInt32 mask;
|
||||
void *num;
|
||||
} TOGGLE_T;
|
||||
typedef struct NUM_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
char size;
|
||||
char fit;
|
||||
UInt32 lo;
|
||||
UInt32 hi;
|
||||
void *num;
|
||||
} NUM_T;
|
||||
typedef struct FILEPATH_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
char fflags;
|
||||
char *defaultstr;
|
||||
void *filename;
|
||||
int maxlen;
|
||||
} FILEPATH_T;
|
||||
typedef struct IFARG_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
PARAM_T *parg;
|
||||
char *helpa;
|
||||
PARAM_T *pnone;
|
||||
char *helpn;
|
||||
} IFARG_T;
|
||||
typedef struct ONOFF_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
unsigned char *var;
|
||||
} ONOFF_T;
|
||||
typedef struct OFFON_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
unsigned char *var;
|
||||
} OFFON_T;
|
||||
typedef struct FTYPE_T {
|
||||
char which;
|
||||
char flags;
|
||||
char *myname;
|
||||
PARAM_T *next;
|
||||
OSType *fc;
|
||||
Boolean iscreator;
|
||||
} FTYPE_T;
|
||||
typedef struct OptionList {
|
||||
char *help;
|
||||
int flags;
|
||||
struct Option **list;
|
||||
} OptionList;
|
||||
typedef struct Option {
|
||||
char *names;
|
||||
int avail;
|
||||
PARAM_T *param;
|
||||
OptionList *sub;
|
||||
OptionList *conflicts;
|
||||
char *help;
|
||||
} Option;
|
||||
enum {
|
||||
HELPFLAGS_1 = 1,
|
||||
HELPFLAGS_IGNORED = 2,
|
||||
HELPFLAGS_OBSOLETE = 4,
|
||||
HELPFLAGS_DEPRECATED = 8,
|
||||
HELPFLAGS_SECRET = 0x10,
|
||||
HELPFLAGS_MEANINGLESS = 0x20,
|
||||
HELPFLAGS_COMPATIBLE = 0x40,
|
||||
HELPFLAGS_NORMAL = 0x80, // andmask = 0xE?
|
||||
HELPFLAGS_SPACES = 0x100,
|
||||
HELPFLAGS_TOOL = 0x200,
|
||||
HELPFLAGS_TOOL_THIS = 0x400,
|
||||
HELPFLAGS_TOOL_OTHER = 0x800,
|
||||
HELPFLAGS_TOOL_BOTH = 0xC00,
|
||||
HELPFLAGS_1000 = 0x1000,
|
||||
HELPFLAGS_2000 = 0x2000,
|
||||
HELPFLAGS_USAGE = 0x4000,
|
||||
HELPFLAGS_8000 = 0x8000
|
||||
};
|
||||
enum {
|
||||
OTF_GLOBAL = 1,
|
||||
OTF2 = 2,
|
||||
OTF_CASED = 4,
|
||||
OTF_OBSOLETE = 8,
|
||||
OTF_SUBSTITUTED = 0x10,
|
||||
OTF_DEPRECATED = 0x20,
|
||||
OTF_TOOL_LINKER = 0x40,
|
||||
OTF_TOOL_DISASSEMBLER = 0x80,
|
||||
OTF_TOOL_COMPILER = 0x100,
|
||||
OTF_TOOL_MASK = OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER | OTF_TOOL_COMPILER,
|
||||
OTF200 = 0x200,
|
||||
OTF400 = 0x400,
|
||||
OTF700 = 0x700,
|
||||
OTF_IGNORED = 0x800,
|
||||
OTFC00 = 0xC00,
|
||||
OTF_SECRET = 0x1000,
|
||||
OTF2000 = 0x2000,
|
||||
OTF_COMPATIBILITY = 0x4000,
|
||||
OTF8000 = 0x8000,
|
||||
OTF10000 = 0x10000,
|
||||
OTF20000 = 0x20000,
|
||||
OTF40000 = 0x40000,
|
||||
OTF_WARNING = 0x80000,
|
||||
OTF_SLFLAGS_8 = 0x100000,
|
||||
OTF_SLFLAGS_10 = 0x200000,
|
||||
OTF_SLFLAGS_20 = 0x400000,
|
||||
OTF_SLFLAGS_MASK = OTF_SLFLAGS_8 | OTF_SLFLAGS_10 | OTF_SLFLAGS_20,
|
||||
OTF_MEANINGLESS = 0x800000,
|
||||
OTF_ALL_HIDDEN_BY_DEFAULT = OTF_OBSOLETE | OTF_DEPRECATED | OTF_IGNORED | OTF_SECRET | OTF_MEANINGLESS,
|
||||
OTF1000000 = 0x1000000,
|
||||
OTF2000000 = 0x2000000,
|
||||
OTF4000000 = 0x4000000,
|
||||
OTF8000000 = 0x8000000,
|
||||
OTF10000000 = 0x10000000,
|
||||
OTF20000000 = 0x20000000,
|
||||
OTF40000000 = 0x40000000,
|
||||
OTF80000000 = 0x80000000
|
||||
};
|
||||
|
||||
enum {
|
||||
PARAMWHICH_None = 0,
|
||||
PARAMWHICH_FTypeCreator = 1,
|
||||
PARAMWHICH_FilePath = 2,
|
||||
PARAMWHICH_Number = 3,
|
||||
PARAMWHICH_String = 4,
|
||||
PARAMWHICH_Id = 5,
|
||||
PARAMWHICH_Sym = 6,
|
||||
PARAMWHICH_OnOff = 7,
|
||||
PARAMWHICH_OffOn = 8,
|
||||
PARAMWHICH_Mask = 9,
|
||||
PARAMWHICH_Toggle = 0xA,
|
||||
PARAMWHICH_Set = 0xB,
|
||||
PARAMWHICH_SetString = 0xC,
|
||||
PARAMWHICH_Generic = 0xD,
|
||||
PARAMWHICH_IfArg = 0xE,
|
||||
PARAMWHICH_Setting = 0xF,
|
||||
PARAMWHICH_MAX = 0x10
|
||||
};
|
||||
enum {
|
||||
PARAMFLAGS_1 = 1,
|
||||
PARAMFLAGS_2 = 2,
|
||||
PARAMFLAGS_3 = 3,
|
||||
PARAMFLAGS_4 = 4,
|
||||
PARAMFLAGS_8 = 8,
|
||||
PARAMFLAGS_10 = 0x10,
|
||||
PARAMFLAGS_12 = 0x12
|
||||
};
|
||||
enum {
|
||||
PARAMPARSEFLAGS_0 = 0,
|
||||
PARAMPARSEFLAGS_1 = 1,
|
||||
PARAMPARSEFLAGS_2 = 2,
|
||||
PARAMPARSEFLAGS_4 = 4,
|
||||
PARAMPARSEFLAGS_8 = 8,
|
||||
PARAMPARSEFLAGS_10 = 0x10,
|
||||
PARAMPARSEFLAGS_20 = 0x20,
|
||||
PARAMPARSEFLAGS_40 = 0x40,
|
||||
PARAMPARSEFLAGS_80 = 0x80,
|
||||
PARAMPARSEFLAGS_100 = 0x100
|
||||
};
|
||||
enum {
|
||||
SLFLAGS_1 = 1,
|
||||
SLFLAGS_2 = 2,
|
||||
SLFLAGS_4 = 4, // displays =...
|
||||
SLFLAGS_8 = 8, // displays [no] -- produces e.g. [no]err[or] | [no]iserr[or], [no]implicit[conv]
|
||||
SLFLAGS_10 = 0x10, // displays [-]
|
||||
SLFLAGS_20 = 0x20, // displays [no-]
|
||||
SLFLAGS_40 = 0x40
|
||||
};
|
||||
enum {
|
||||
LISTFLAGS_NONE = 0,
|
||||
LISTFLAGS_2 = 2,
|
||||
LISTFLAGS_4 = 4,
|
||||
LISTFLAGS_COMPILER = 0x100,
|
||||
LISTFLAGS_LINKER = 0x200,
|
||||
LISTFLAGS_DISASSEMBLER = 0x400,
|
||||
LISTFLAGS_TOOL_MASK = LISTFLAGS_COMPILER | LISTFLAGS_LINKER | LISTFLAGS_DISASSEMBLER
|
||||
};
|
||||
|
||||
enum {
|
||||
OFLAGS_1 = 1,
|
||||
OFLAGS_2 = 2,
|
||||
OFLAGS_4 = 4,
|
||||
OFLAGS_8 = 8,
|
||||
OFLAGS_10 = 0x10,
|
||||
OFLAGS_20 = 0x20,
|
||||
OFLAGS_40 = 0x40,
|
||||
OFLAGS_80 = 0x80
|
||||
};
|
||||
enum {
|
||||
PFLAGS_1 = 1,
|
||||
PFLAGS_2 = 2,
|
||||
PFLAGS_4 = 4,
|
||||
PFLAGS_8 = 8,
|
||||
PFLAGS_10 = 0x10,
|
||||
PFLAGS_20 = 0x20,
|
||||
PFLAGS_40 = 0x40,
|
||||
PFLAGS_80 = 0x80
|
||||
};
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=reset
|
||||
#endif
|
||||
|
||||
/********************************/
|
||||
/* Arguments.c */
|
||||
typedef struct {
|
||||
SInt16 val;
|
||||
char *text;
|
||||
} ArgToken;
|
||||
enum {
|
||||
ATK_0,
|
||||
ATK_1,
|
||||
ATK_2,
|
||||
ATK_3,
|
||||
ATK_4,
|
||||
ATK_5
|
||||
};
|
||||
typedef struct {
|
||||
int argc;
|
||||
int nargv;
|
||||
char **argv;
|
||||
} anon0_50;
|
||||
|
||||
extern void Arg_Init(int theargc, char **theargv);
|
||||
extern void Arg_Terminate();
|
||||
extern void Arg_Reset();
|
||||
extern void Arg_Stop(ArgToken *where);
|
||||
extern ArgToken *Arg_PeekToken();
|
||||
extern ArgToken *Arg_UsedToken();
|
||||
extern int Arg_IsEmpty();
|
||||
extern ArgToken *Arg_GetToken();
|
||||
extern ArgToken *Arg_UndoToken();
|
||||
extern const char *Arg_GetTokenName(ArgToken *tok);
|
||||
extern const char *Arg_GetTokenText(ArgToken *tok, char *buffer, int maxlen, unsigned char warn);
|
||||
extern void Arg_InitToolArgs(anon0_50 *ta);
|
||||
extern void Arg_AddToToolArgs(anon0_50 *ta, SInt16 tokval, char *toktxt);
|
||||
extern void Arg_FinishToolArgs(anon0_50 *ta);
|
||||
extern void Arg_ToolArgsForPlugin(anon0_50 *ta, struct CWCommandLineArgs *args);
|
||||
extern void Arg_FreeToolArgs(anon0_50 *ta);
|
||||
|
||||
/********************************/
|
||||
/* Option.c */
|
||||
typedef struct {
|
||||
void *first;
|
||||
void *second;
|
||||
} Opt50;
|
||||
typedef struct {
|
||||
Option *opt;
|
||||
char *curopt;
|
||||
} Opt52;
|
||||
typedef struct {
|
||||
union {
|
||||
Opt50 v;
|
||||
OptionList *lst;
|
||||
Opt52 o;
|
||||
char *param;
|
||||
} e;
|
||||
SInt16 flags;
|
||||
} Opt48;
|
||||
//static void Option_PushList(OptionList *lst);
|
||||
//static void Option_PushOpt(Option *opt, const char *optname);
|
||||
//static void Option_PopOpt(const char *optname);
|
||||
//static void Option_PopList();
|
||||
extern void Args_InitStack();
|
||||
extern int Args_StackSize();
|
||||
extern void Args_Push(SInt16 flags, void *first, void *second);
|
||||
extern Opt48 *Args_Pop(SInt16 flags);
|
||||
extern void Args_SpellStack(char *buffer, SInt16 flags);
|
||||
extern void Args_AddToToolArgs(anon0_50 *ta);
|
||||
extern void Options_Init();
|
||||
extern OptionList *Options_GetOptions();
|
||||
extern void Options_SortOptions();
|
||||
//static void Options_AddOption(Option *opt);
|
||||
extern int Options_AddList(OptionList *optlst);
|
||||
extern int Options_AddLists(OptionList **optlst);
|
||||
//static void Options_Reset(OptionList *optlst);
|
||||
//static void Option_SpellList(char *buffer, OptionList *conflicts, int flags);
|
||||
extern int Option_ForTool(Option *opt, int which);
|
||||
extern int Option_ThisTool();
|
||||
extern int Option_ForThisTool(Option *opt);
|
||||
extern int Option_AlsoPassedToTool(Option *opt, int which);
|
||||
extern int Option_AlsoPassedFromThisTool(Option *opt);
|
||||
//static Boolean Option_ContinuesThisLevel(int level, ArgToken *tok);
|
||||
//static Boolean Option_IsEndingThisLevel(int level, ArgToken *tok);
|
||||
//static Boolean Option_IsEndingLevel(int level, ArgToken *tok);
|
||||
extern int Option_Parse(Option *opt, int oflags);
|
||||
//static int Option_MatchString(char *list, char *str, int flags, int *result);
|
||||
//static Option *Option_Lookup(OptionList *search, void *unk, int *flags);
|
||||
//static int Options_DoParse(OptionList *search, int flags);
|
||||
extern int Options_Parse(OptionList *options, int flags);
|
||||
extern int Option_ParseDefaultOption(OptionList *options);
|
||||
extern void Option_ParamError(SInt16 id, va_list ap);
|
||||
extern void Option_ParamWarning(SInt16 id, va_list ap);
|
||||
extern void Option_OptionError(SInt16 id, va_list ap);
|
||||
extern void Option_OptionWarning(SInt16 id, va_list ap);
|
||||
extern void Option_Error(SInt16 id, ...);
|
||||
extern void Option_Warning(SInt16 id, ...);
|
||||
extern int Options_Help(const char *keyword);
|
||||
extern int Option_Help(const char *opt);
|
||||
extern int Options_DisplayHelp();
|
||||
|
||||
/********************************/
|
||||
/* Parameter.c */
|
||||
extern void Param_DescHelp(PARAM_T *param, const char **desc, const char **help, const char **defaul);
|
||||
extern int Param_Compare(PARAM_T *param);
|
||||
extern int Params_Parse(PARAM_T *param, int flags);
|
||||
extern void Param_Error(SInt16 id, ...);
|
||||
extern void Param_Warning(SInt16 id, ...);
|
||||
|
||||
/********************************/
|
||||
/* Help.c */
|
||||
extern int Help_Option(struct OptionList *lst, struct Option *opt, int subprint, const char *keyword);
|
||||
extern void Help_Options(struct OptionList *lst, int subprint, const char *keyword);
|
||||
extern void Help_Usage();
|
||||
extern void Help_Null();
|
||||
extern void Help_Init();
|
||||
extern void Help_Line(char ch);
|
||||
extern void Help_Term();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,201 @@
|
|||
#pragma once
|
||||
#include "CWPlugins.h"
|
||||
#include "CWPluginErrors.h"
|
||||
#include "DropInCompilerLinker.h"
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=mac68k
|
||||
#endif
|
||||
|
||||
#if CWPLUGIN_API == CWPLUGIN_API_MACOS
|
||||
#define CWFileSpecNotEmpty(specPtr) ((specPtr)->name[0] != 0)
|
||||
#elif CWPLUGIN_API == CWPLUGIN_API_WIN32
|
||||
#define CWFileSpecNotEmpty(specPtr) ((specPtr)->path[0] != 0)
|
||||
#elif CWPLUGIN_API == CWPLUGIN_API_UNIX
|
||||
#define CWFileSpecNotEmpty(specPtr) ((specPtr)->path[0] != 0)
|
||||
#endif
|
||||
|
||||
enum {
|
||||
CWDROPINPARSERTYPE = CWFOURCHAR('P','a','r','s')
|
||||
};
|
||||
|
||||
typedef struct IDEAccessPath {
|
||||
FSSpec pathSpec;
|
||||
Boolean recursive;
|
||||
SInt32 subdirectoryCount;
|
||||
FSSpec *subdirectories;
|
||||
} IDEAccessPath;
|
||||
|
||||
typedef struct IDEAccessPathList {
|
||||
SInt32 userPathCount;
|
||||
IDEAccessPath *userPaths;
|
||||
SInt32 systemPathCount;
|
||||
IDEAccessPath *systemPaths;
|
||||
Boolean alwaysSearchUserPaths;
|
||||
Boolean convertPaths;
|
||||
} IDEAccessPathList;
|
||||
|
||||
enum {
|
||||
cwAccessPathTypeFlag2 = 2
|
||||
};
|
||||
typedef struct CWNewAccessPathInfo {
|
||||
CWFileSpec pathSpec;
|
||||
SInt32 position;
|
||||
Boolean recursive;
|
||||
CWAccessPathType type;
|
||||
} CWNewAccessPathInfo;
|
||||
|
||||
typedef struct CWTargetInfoV7 {
|
||||
CWFileSpec outfile;
|
||||
CWFileSpec symfile;
|
||||
short linkType;
|
||||
Boolean canRun;
|
||||
Boolean canDebug;
|
||||
Boolean useRunHelperApp;
|
||||
char reserved1;
|
||||
CWDataType debuggerCreator;
|
||||
CWDataType runHelperCreator;
|
||||
SInt32 reserved2[2];
|
||||
} CWTargetInfoV7;
|
||||
|
||||
typedef struct CWEnvVarInfo {
|
||||
char *name;
|
||||
char *value;
|
||||
} CWEnvVarInfo;
|
||||
|
||||
typedef struct CWCommandLineArgs {
|
||||
int argc;
|
||||
char **argv;
|
||||
char **envp;
|
||||
} CWCommandLineArgs;
|
||||
|
||||
typedef struct ToolVersionInfo {
|
||||
char *company;
|
||||
char *product;
|
||||
char *tool;
|
||||
char *copyright;
|
||||
char *version;
|
||||
} ToolVersionInfo;
|
||||
|
||||
typedef struct CLPluginInfo {
|
||||
OSType plugintype;
|
||||
OSType language;
|
||||
SInt32 dropinflags;
|
||||
char *version;
|
||||
Boolean storeCommandLine;
|
||||
} CLPluginInfo;
|
||||
|
||||
struct CW_BasePluginCallbacks {
|
||||
CWResult (*cbGetFileInfo)(CWPluginContext, SInt32, Boolean, CWProjectFileInfo *);
|
||||
CWResult (*cbFindAndLoadFile)(CWPluginContext, const char *, CWFileInfo *);
|
||||
CWResult (*cbGetFileText)(CWPluginContext, const CWFileSpec *, const char **, SInt32 *, short *);
|
||||
CWResult (*cbReleaseFileText)(CWPluginContext, const char *);
|
||||
CWResult (*cbGetSegmentInfo)(CWPluginContext, SInt32, CWProjectSegmentInfo *);
|
||||
CWResult (*cbGetOverlay1GroupInfo)(CWPluginContext, SInt32, CWOverlay1GroupInfo *);
|
||||
CWResult (*cbGetOverlay1Info)(CWPluginContext, SInt32, SInt32, CWOverlay1Info *);
|
||||
CWResult (*cbGetOverlay1FileInfo)(CWPluginContext, SInt32, SInt32, SInt32, CWOverlay1FileInfo *);
|
||||
CWResult (*cbReportMessage)(CWPluginContext, const CWMessageRef *, const char *, const char *, short, SInt32);
|
||||
CWResult (*cbAlert)(CWPluginContext, const char *, const char *, const char *, const char *);
|
||||
CWResult (*cbShowStatus)(CWPluginContext, const char *, const char *);
|
||||
CWResult (*cbUserBreak)(CWPluginContext);
|
||||
CWResult (*cbGetNamedPreferences)(CWPluginContext, const char *, CWMemHandle *);
|
||||
CWResult (*cbStorePluginData)(CWPluginContext, SInt32, CWDataType, CWMemHandle);
|
||||
CWResult (*cbGetPluginData)(CWPluginContext, SInt32, CWDataType, CWMemHandle *);
|
||||
CWResult (*cbSetModDate)(CWPluginContext, const CWFileSpec *, CWFileTime *, Boolean);
|
||||
CWResult (*cbAddProjectEntry)(CWPluginContext, const CWFileSpec *, Boolean, const CWNewProjectEntryInfo *, SInt32 *);
|
||||
CWResult (*cbCreateNewTextDocument)(CWPluginContext, const CWNewTextDocumentInfo *);
|
||||
CWResult (*cbAllocateMemory)(CWPluginContext, SInt32, Boolean, void **);
|
||||
CWResult (*cbFreeMemory)(CWPluginContext, void *, Boolean);
|
||||
CWResult (*cbAllocMemHandle)(CWPluginContext, SInt32, Boolean, CWMemHandle *);
|
||||
CWResult (*cbFreeMemHandle)(CWPluginContext, CWMemHandle);
|
||||
CWResult (*cbGetMemHandleSize)(CWPluginContext, CWMemHandle, SInt32 *);
|
||||
CWResult (*cbResizeMemHandle)(CWPluginContext, CWMemHandle, SInt32);
|
||||
CWResult (*cbLockMemHandle)(CWPluginContext, CWMemHandle, Boolean, void **);
|
||||
CWResult (*cbUnlockMemHandle)(CWPluginContext, CWMemHandle);
|
||||
void *cbInternal[8];
|
||||
CWResult (*cbGetTargetName)(CWPluginContext, char *, short);
|
||||
CWResult (*cbCacheAccessPathList)(CWPluginContext);
|
||||
CWResult (*cbPreDialog)(CWPluginContext);
|
||||
CWResult (*cbPostDialog)(CWPluginContext);
|
||||
CWResult (*cbPreFileAction)(CWPluginContext, const CWFileSpec *);
|
||||
CWResult (*cbPostFileAction)(CWPluginContext, const CWFileSpec *);
|
||||
CWResult (*cbCheckoutLicense)(CWPluginContext, const char *, const char *, SInt32, void *, SInt32 *);
|
||||
CWResult (*cbCheckinLicense)(CWPluginContext, SInt32);
|
||||
CWResult (*cbResolveRelativePath)(CWPluginContext, const CWRelativePath *, CWFileSpec *, Boolean);
|
||||
};
|
||||
|
||||
struct CWCompilerLinkerCallbacks {
|
||||
CWResult (*cbCachePrecompiledHeader)(CWPluginContext, const CWFileSpec *, CWMemHandle);
|
||||
CWResult (*cbLoadObjectData)(CWPluginContext, SInt32, CWMemHandle *);
|
||||
CWResult (*cbStoreObjectData)(CWPluginContext, SInt32, CWObjectData *);
|
||||
CWResult (*cbFreeObjectData)(CWPluginContext, SInt32, CWMemHandle);
|
||||
CWResult (*cbDisplayLines)(CWPluginContext, SInt32);
|
||||
CWResult (*cbBeginSubCompile)(CWPluginContext, SInt32, CWPluginContext *);
|
||||
CWResult (*cbEndSubCompile)(CWPluginContext);
|
||||
CWResult (*cbGetPrecompiledHeaderSpec)(CWPluginContext, CWFileSpec *, const char *);
|
||||
CWResult (*cbGetResourceFile)(CWPluginContext, CWFileSpec *);
|
||||
CWResult (*cbPutResourceFile)(CWPluginContext, const char *, const char *, CWFileSpec *);
|
||||
CWResult (*cbLookUpUnit)(CWPluginContext, const char *, Boolean, const void **, SInt32 *);
|
||||
CWResult (*cbSBMfiles)(CWPluginContext, short);
|
||||
CWResult (*cbStoreUnit)(CWPluginContext, const char *, CWMemHandle, CWDependencyTag);
|
||||
CWResult (*cbReleaseUnit)(CWPluginContext, void *);
|
||||
CWResult (*cbUnitNameToFileName)(CWPluginContext, const char *, char *);
|
||||
CWResult (*cbOSErrorMessage)(CWPluginContext, const char *, OSErr);
|
||||
CWResult (*cbOSAlert)(CWPluginContext, const char *, OSErr);
|
||||
CWResult (*cbGetModifiedFiles)(CWPluginContext, SInt32 *, const SInt32 **);
|
||||
CWResult (*cbGetSuggestedObjectFileSpec)(CWPluginContext, SInt32, CWFileSpec *);
|
||||
CWResult (*cbGetStoredObjectFileSpec)(CWPluginContext, SInt32, CWFileSpec *);
|
||||
CWResult (*cbGetRuntimeSettings)(CWPluginContext);
|
||||
CWResult (*cbGetFrameworkCount)(CWPluginContext, SInt32 *);
|
||||
CWResult (*cbGetFrameworkInfo)(CWPluginContext, SInt32, CWFrameworkInfo *);
|
||||
CWResult (*cbGetFrameworkSharedLibrary)(CWPluginContext);
|
||||
};
|
||||
|
||||
struct CWParserCallbacks {
|
||||
CWResult (*cbParserAddAccessPath)(CWPluginContext, const CWNewAccessPathInfo *);
|
||||
CWResult (*cbParserSwapAccessPaths)(CWPluginContext);
|
||||
CWResult (*cbParserSetNamedPreferences)(CWPluginContext, const char *, CWMemHandle);
|
||||
CWResult (*cbParserSetFileOutputName)(CWPluginContext, SInt32, short, const char *);
|
||||
CWResult (*cbParserSetOutputFileDirectory)(CWPluginContext, const CWFileSpec *);
|
||||
CWResult (*cbParserAddOverlay1Group)(CWPluginContext, const char *, const CWAddr64 *, SInt32 *);
|
||||
CWResult (*cbParserAddOverlay1)(CWPluginContext, const char *, SInt32, SInt32 *);
|
||||
CWResult (*cbParserAddSegment)(CWPluginContext, const char *, short, SInt32 *);
|
||||
CWResult (*cbParserSetSegment)(CWPluginContext, SInt32, const char *, short);
|
||||
};
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=reset
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
CW_CALLBACK CWCheckoutLicense(CWPluginContext context, const char *a, const char *b, SInt32 c, void *d, SInt32 *cookiePtr);
|
||||
CW_CALLBACK CWCheckinLicense(CWPluginContext context, SInt32 cookie);
|
||||
CW_CALLBACK CWSecretAttachHandle(CWPluginContext context, Handle handle, CWMemHandle *memHandle);
|
||||
CW_CALLBACK CWSecretDetachHandle(CWPluginContext context, CWMemHandle memHandle, Handle *handle);
|
||||
CW_CALLBACK CWSecretPeekHandle(CWPluginContext context, CWMemHandle memHandle, Handle *handle);
|
||||
CW_CALLBACK CWSecretGetNamedPreferences(CWPluginContext context, const char *prefsname, Handle *prefsdata);
|
||||
|
||||
CW_CALLBACK CWParserGetBuildDate(CWPluginContext context, const char **buildDate, const char **buildTime);
|
||||
CW_CALLBACK CWParserGetCommandLine(CWPluginContext context, CWCommandLineArgs **args);
|
||||
CW_CALLBACK CWParserGetTargetInfo(CWPluginContext context, CWDataType *cpu, CWDataType *os);
|
||||
CW_CALLBACK CWParserGetToolInfo(CWPluginContext context, const ToolVersionInfo **toolVersionInfo);
|
||||
CW_CALLBACK CWParserGetPlugins(CWPluginContext context, int *numPlugins, const CLPluginInfo **pluginInfo);
|
||||
CW_CALLBACK CWParserGetPanels(CWPluginContext context, int *numPanels, const char ***panelNames);
|
||||
CW_CALLBACK CWParserStoreCommandLineForPanel(CWPluginContext context, int index, const CWCommandLineArgs *args);
|
||||
CW_CALLBACK CWParserStoreCommandLineForPlugin(CWPluginContext context, int index, const CWCommandLineArgs *args);
|
||||
CW_CALLBACK CWParserAddAccessPath(CWPluginContext context, const CWNewAccessPathInfo *api);
|
||||
CW_CALLBACK CWParserSwapAccessPaths(CWPluginContext context);
|
||||
CW_CALLBACK CWParserSetNamedPreferences(CWPluginContext context, const char *panelName, CWMemHandle paneldata);
|
||||
CW_CALLBACK CWParserSetFileOutputName(CWPluginContext context, SInt32 position, short which, const char *outfilename);
|
||||
CW_CALLBACK CWParserSetOutputFileDirectory(CWPluginContext context, const CWFileSpec *idefss);
|
||||
CW_CALLBACK CWParserAddOverlay1Group(CWPluginContext context, const char *name, const CWAddr64 *addr, SInt32 *newGroupNumber);
|
||||
CW_CALLBACK CWParserAddOverlay1(CWPluginContext context, const char *name, SInt32 groupNumber, SInt32 *newOverlayNumber);
|
||||
CW_CALLBACK CWParserAddSegment(CWPluginContext context, const char *name, short attrs, SInt32 *newSegmentNumber);
|
||||
CW_CALLBACK CWParserSetSegment(CWPluginContext context, SInt32 segmentNumber, const char *name, short attrs);
|
||||
CW_CALLBACK CWParserCreateVirtualFile(CWPluginContext context, const char *name, CWMemHandle text);
|
||||
CW_CALLBACK CWParserDisplayTextHandle(CWPluginContext context, const char *name, CWMemHandle text);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,84 @@
|
|||
#pragma once
|
||||
#include "plugin.h"
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=mac68k
|
||||
#endif
|
||||
struct CWPluginPrivateContext {
|
||||
CWPluginPrivateContext();
|
||||
~CWPluginPrivateContext();
|
||||
|
||||
SInt32 request;
|
||||
SInt32 apiVersion;
|
||||
void *shellContext;
|
||||
void *pluginStorage;
|
||||
CWFileSpec projectFile;
|
||||
CWFileSpec outputFileDirectory;
|
||||
SInt32 shellSignature;
|
||||
SInt32 pluginType;
|
||||
SInt32 numFiles;
|
||||
SInt32 numOverlayGroups;
|
||||
OSErr callbackOSError;
|
||||
OSErr pluginOSError;
|
||||
CWIDEInfo *shellInfo;
|
||||
IDEAccessPathList *accessPathList;
|
||||
SInt32 dontEatEvents;
|
||||
CWFileSpec *targetDataDirectorySpec;
|
||||
SInt32 reserved[17];
|
||||
CW_BasePluginCallbacks *callbacks;
|
||||
};
|
||||
|
||||
struct CWCompilerLinkerContext : CWPluginPrivateContext {
|
||||
CWCompilerLinkerContext();
|
||||
~CWCompilerLinkerContext();
|
||||
|
||||
SInt32 whichfile;
|
||||
CWFileSpec sourcefile;
|
||||
const char *sourcetext;
|
||||
SInt32 sourcetextsize;
|
||||
Boolean precompile;
|
||||
Boolean autoprecompile;
|
||||
Boolean preprocess;
|
||||
Boolean cachingPCH;
|
||||
Boolean debuginfo;
|
||||
SInt16 fileID;
|
||||
CWBrowseOptions browseoptions;
|
||||
Boolean recordbrowseinfo;
|
||||
void *reserved;
|
||||
SInt32 sequenceID;
|
||||
CWCompilerLinkerContext *parentPB;
|
||||
void *targetStorage;
|
||||
SInt32 reservedcompiler[7];
|
||||
CWMemHandle texthandle;
|
||||
CWTargetInfoV7 targetinfo_V7;
|
||||
CWTargetInfo *targetinfo;
|
||||
const char *commandLineArgs;
|
||||
CWFileSpec *workingDirectorySpec;
|
||||
SInt32 numEnvironmentVariables;
|
||||
CWEnvVarInfo *environmentVariables;
|
||||
SInt32 workingDirectoryError;
|
||||
SInt32 reservedlinker[2];
|
||||
CWCompilerLinkerCallbacks *callbacks;
|
||||
};
|
||||
|
||||
struct CWParserContext : CWPluginPrivateContext {
|
||||
CWParserContext();
|
||||
~CWParserContext();
|
||||
|
||||
CWCommandLineArgs *args;
|
||||
CWDataType cpu;
|
||||
CWDataType os;
|
||||
const char *build_date;
|
||||
const char *build_time;
|
||||
const ToolVersionInfo *build_tool;
|
||||
int numPlugins;
|
||||
CLPluginInfo *plugins;
|
||||
int numPanels;
|
||||
const char **panelNames;
|
||||
CWCommandLineArgs *plugin_args;
|
||||
CWCommandLineArgs *panel_args;
|
||||
CWParserCallbacks *callbacks;
|
||||
};
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=reset
|
||||
#endif
|
|
@ -0,0 +1,192 @@
|
|||
* - has issues
|
||||
|
||||
DONE CLStaticMain.c
|
||||
DONE ClientGlue.c
|
||||
DONE CLMain.c
|
||||
DONE* MacEmul/Resources.c
|
||||
STUB Envir/CLErrors.c
|
||||
DONE* MacEmul/ResourceStrings.c
|
||||
---- Plugins/CLPlugins.c
|
||||
---- Callbacks/CLParserCallbacks_v1.cpp
|
||||
STUB CLIO.c
|
||||
STUB CLToolExec.c
|
||||
DONE OSLib/Posix.c
|
||||
DONE OSLib/StringExtras.c
|
||||
DONE OSLib/Generic.c
|
||||
---- Project/CLProj.c
|
||||
---- CLLicenses.c
|
||||
DONE OSLib/MemUtils.c
|
||||
---- CLPluginRequests.cpp
|
||||
DONE MacEmul/LowMem.c
|
||||
---- CLFileOps.c
|
||||
---- CLPrefs.c
|
||||
---- CLTarg.c
|
||||
---- Project/CLAccessPaths.c
|
||||
DONE OSLib/MacSpecs.c
|
||||
DONE OSLib/StringUtils.c
|
||||
DONE MacEmul/Memory.c
|
||||
DONE MacEmul/File.c
|
||||
DONE MacEmul/TextUtils.c
|
||||
---- ?? AddFileTypeMappingList, SetMacFileType, ...
|
||||
---- Project/CLFiles.c
|
||||
---- Project/CLOverlays.c
|
||||
---- Project/CLSegs.c
|
||||
---- Callbacks/CLDropinCallbacks_V10.cpp
|
||||
DONE OSLib/MacFileTypes.c
|
||||
DONE OSLib/FileHandles.c
|
||||
---- Callbacks/CLCompilerLinkerDropin_V10.cpp
|
||||
---- CLDependencies.c
|
||||
---- CLWriteObjectFile.c
|
||||
---- CLBrowser.c
|
||||
---- CLIncludeFileCache.c
|
||||
---- CLLoadAndCache.c
|
||||
DONE MacEmul/ErrMgr.c
|
||||
---- ?? Counterpart of cc-macosx-ppc-mw.c
|
||||
(Includes RegisterStaticTargetResources, GetStaticTarget, ...)
|
||||
---- ?? Counterpart of ParserGlue-macosx-ppc-cc.c
|
||||
(Includes RegisterStaticParserToolInfo and all the option lists)
|
||||
---- ?? Counterpart of cc-macosx-ppc.c
|
||||
(Includes RegisterStaticCompilerPlugin, RegisterCompilerResources)
|
||||
---- ?? Counterpart of machimp-macosx-ppc.c
|
||||
(Includes RegisterStaticLibImporterPlugin, RegisterLibImporterResources)
|
||||
---- TargetOptimizer-ppc-mach.c
|
||||
---- OptimizerHelpers.c
|
||||
---- ?? TargetSetWarningFlags, TargetDisplayWarningOptions
|
||||
---- WarningHelpers.c
|
||||
|
||||
---- CCompiler.c
|
||||
---- CParser.c
|
||||
---- CompilerTools.c
|
||||
---- CodeGenOptPPC.c
|
||||
---- IrOptimizer.c
|
||||
---- CodeGen.c
|
||||
---- CPrep.c
|
||||
---- CScope.c
|
||||
---- CMachine.c
|
||||
---- CExpr.c
|
||||
---- CFunc.c
|
||||
---- CTemplateNew.c
|
||||
STUB CError.c
|
||||
---- ObjGenMachO.c
|
||||
---- CDecl.c
|
||||
---- CMangler.c
|
||||
---- CSOM.c
|
||||
---- CABI.c
|
||||
---- CInit.c
|
||||
---- CClass.c
|
||||
---- CIRTransform.c
|
||||
---- CObjC.c
|
||||
---- CInline.c
|
||||
---- CPrepTokenizer.c
|
||||
---- CTemplateTools.c
|
||||
---- IroPointerAnalysis.c
|
||||
---- InstrSelection.c
|
||||
---- IroFlowgraph.c
|
||||
---- IroLinearForm.c
|
||||
---- IroUtil.c
|
||||
---- IroCSE.c
|
||||
---- IroPropagate.c
|
||||
---- IROUseDef.c
|
||||
---- InlineAsmPPC.c
|
||||
---- IroDump.c
|
||||
---- IroTransform.c
|
||||
---- IroVars.c
|
||||
---- IroEval.c
|
||||
---- IroJump.c
|
||||
---- IroRangePropagation.c
|
||||
---- IroEmptyLoop.c
|
||||
---- IroUnrollLoop.c
|
||||
---- IroLoop.c
|
||||
---- IroExprRegeneration.c
|
||||
---- IroSubable.c
|
||||
---- RegisterInfo.c
|
||||
---- TOC.c
|
||||
---- StackFrame.c
|
||||
---- Register.sc
|
||||
PART PCode.c
|
||||
---- Switch.c
|
||||
---- ValueNumbering.c
|
||||
---- PCodeUtilities.c
|
||||
---- Operands.c
|
||||
---- Exceptions.c
|
||||
---- ?? Dumping (DumpIR, DumpExpression, ...)
|
||||
---- COptimizer.c
|
||||
---- GlobalOptimizer.c
|
||||
---- PCodeListing.c
|
||||
---- Peephole.c
|
||||
---- Scheduler.c
|
||||
---- Coloring.c
|
||||
---- PCodeAssembly.c
|
||||
---- Intrinsics.c
|
||||
---- PPCError.c
|
||||
---- CExpr2.c
|
||||
DONE* CInt64.c
|
||||
---- CPrec.c
|
||||
---- CBrowse.c
|
||||
---- CPreprocess.c
|
||||
---- FuncLevelAsmPPC.c
|
||||
---- CException.c
|
||||
---- CTemplateClass.c
|
||||
---- ScanFloat.c
|
||||
---- CExprConvMatch.c
|
||||
---- CRTTI.c
|
||||
---- CObjCModern.c
|
||||
---- InlineAsm.c
|
||||
---- Unmangle.c
|
||||
---- MachO.c
|
||||
---- GenStabs.c
|
||||
---- CTemplateFunc.c
|
||||
---- IroMalloc.c
|
||||
STUB PCodeInfo.c
|
||||
---- StructMoves.c
|
||||
---- FunctionCalls.c
|
||||
---- IroBitVect.c
|
||||
---- InlineAsmRegistersPPC.c
|
||||
---- InlineAsmMnemonicsPPC.c
|
||||
---- InlineAsmRegisters.c
|
||||
---- Alias.c
|
||||
---- LoopDetection.c
|
||||
---- CopyPropagation.c
|
||||
---- CodeMotion.c
|
||||
---- StrengthReduction.c
|
||||
---- LoopOptimization.c
|
||||
---- ConstantPropagation.c
|
||||
---- AddPropagation.c
|
||||
---- UseDefChains.c
|
||||
---- LoadDeletion.c
|
||||
---- VectorArraysToRegs.c
|
||||
---- ?? computelivevariables, dead
|
||||
---- MachineSimulation604.c
|
||||
---- MachineSimulation603.e
|
||||
---- MachineSimulationAltiVec.c
|
||||
---- MachineSimulation7500.c
|
||||
---- MachineSimulation603e.c
|
||||
---- MachineSimulation750.c
|
||||
---- MachineSimulation601.c
|
||||
---- MachineSimulation821.c
|
||||
---- InterferenceGraph.c
|
||||
---- SpillCode.c
|
||||
---- GCCInlineAsm.c
|
||||
---- BitVectors.c
|
||||
DONE (debug) StaticParserGlue.c
|
||||
DONE (debug) ParserFace.c
|
||||
DONE* (debug) ParserHelpers.c
|
||||
DONE* (debug) ToolHelpers.c
|
||||
DONE (debug) ParserHelpers-cc.c
|
||||
DONE# (debug) Arguments.c
|
||||
DONE (debug) ToolHelpers-cc.c
|
||||
DONE (debug) IO.c
|
||||
DONE (debug) Projects.c
|
||||
DONE (debug) Targets.c
|
||||
DONE# (debug) Option.c
|
||||
DONE (debug) ParserErrors.c
|
||||
---- (debug) Utils.c
|
||||
DONE# (debug) Parameter.c
|
||||
DONE# (debug) Help.c
|
||||
DONE uContext1.cpp
|
||||
DONE uContextCL.cpp
|
||||
DONE uContextSecret.cpp
|
||||
---- ?? COS
|
||||
DONE uContextParser.cpp
|
||||
---- ?? Something import-related
|
||||
---- Various MSL objects
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,83 @@
|
|||
#include "mwcc_decomp.h"
|
||||
|
||||
void ShowTextHandle(const char *description, Handle text) {
|
||||
CWMemHandle mh;
|
||||
|
||||
if (!text)
|
||||
return;
|
||||
|
||||
if (description)
|
||||
CLPStatus(71, description);
|
||||
CWSecretAttachHandle(parseopts.context, text, &mh);
|
||||
CWParserDisplayTextHandle(parseopts.context, description, mh);
|
||||
}
|
||||
|
||||
void ShowVersion(Boolean decorate) {
|
||||
char *vplugin;
|
||||
char *valtplugin;
|
||||
const char *bdate;
|
||||
const char *btime;
|
||||
Handle txt;
|
||||
int x;
|
||||
|
||||
vplugin = 0;
|
||||
valtplugin = 0;
|
||||
if (parseopts.printedVersion)
|
||||
return;
|
||||
|
||||
txt = NewHandle(0);
|
||||
if (!txt) {
|
||||
fprintf(stderr, "\n*** Out of memory\n");
|
||||
exit(-23);
|
||||
}
|
||||
|
||||
for (x = 0; x < parseopts.numPlugins; x++) {
|
||||
if (parseopts.plugins[x].plugintype == CWFOURCHAR('c','l','d','r')) continue;
|
||||
if (parseopts.plugins[x].plugintype == CWFOURCHAR('P','a','r','s')) continue;
|
||||
|
||||
if (pTool->TYPE == parseopts.plugins[x].plugintype) {
|
||||
if (!vplugin && pTool->LANG == parseopts.plugins[x].language)
|
||||
vplugin = parseopts.plugins[x].version;
|
||||
else
|
||||
valtplugin = parseopts.plugins[x].version;
|
||||
}
|
||||
}
|
||||
|
||||
CWParserGetBuildDate(parseopts.context, &bdate, &btime);
|
||||
HPrintF(txt, "\n");
|
||||
if (parseopts.toolVersion) {
|
||||
HPrintF(
|
||||
txt,
|
||||
"%s.\n%s, %s\nAll rights reserved.\n%s\n",
|
||||
pTool->toolInfo,
|
||||
parseopts.toolVersion->copyright,
|
||||
parseopts.toolVersion->company,
|
||||
parseopts.toolVersion->version
|
||||
);
|
||||
} else {
|
||||
HPrintF(
|
||||
txt,
|
||||
"%s.\nCopyright (c)%s Metrowerks, Inc.\nAll rights reserved.\n%s\n",
|
||||
pTool->toolInfo,
|
||||
pTool->copyright,
|
||||
vplugin ? vplugin : valtplugin ? valtplugin : ""
|
||||
);
|
||||
}
|
||||
|
||||
HPrintF(txt, "Runtime Built: %s %s\n", bdate, btime);
|
||||
HPrintF(txt, "\n");
|
||||
|
||||
if (decorate) {
|
||||
HPrintF(
|
||||
txt,
|
||||
"Please enter '%s %chelp' for information about options.\n\n",
|
||||
OS_GetFileNamePtr(parseopts.args->argv[0]),
|
||||
MAINOPTCHAR[0]
|
||||
);
|
||||
}
|
||||
|
||||
ShowTextHandle(0, txt);
|
||||
DisposeHandle(txt);
|
||||
|
||||
parseopts.printedVersion = 1;
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
#include "mwcc_decomp.h"
|
||||
|
||||
static char errorbuf[1024];
|
||||
|
||||
void CLPReportError_V(const char *format, va_list ap) {
|
||||
vsprintf(errorbuf, format, ap);
|
||||
CWReportMessage(parseopts.context, NULL, errorbuf, NULL, messagetypeError, 0);
|
||||
parseopts.hadErrors = 1;
|
||||
}
|
||||
|
||||
void CLPReportWarning_V(const char *format, va_list ap) {
|
||||
vsprintf(errorbuf, format, ap);
|
||||
CWReportMessage(parseopts.context, NULL, errorbuf, NULL, messagetypeWarning, 0);
|
||||
}
|
||||
|
||||
void CLPReport_V(const char *format, va_list ap) {
|
||||
vsprintf(errorbuf, format, ap);
|
||||
CWReportMessage(parseopts.context, NULL, errorbuf, NULL, messagetypeInfo, 0);
|
||||
}
|
||||
|
||||
void CLPStatus_V(const char *format, va_list ap) {
|
||||
vsprintf(errorbuf, format, ap);
|
||||
CWShowStatus(parseopts.context, errorbuf, NULL);
|
||||
}
|
||||
|
||||
void CLPAlert_V(const char *format, va_list ap) {
|
||||
vsprintf(errorbuf, format, ap);
|
||||
CWAlert(parseopts.context, errorbuf, NULL, NULL, NULL);
|
||||
parseopts.hadErrors = 1;
|
||||
}
|
||||
|
||||
void CLPOSAlert_V(const char *format, SInt32 err, va_list ap) {
|
||||
vsprintf(errorbuf, format, ap);
|
||||
CWAlert(parseopts.context, errorbuf, "Operating system error:", OS_GetErrText(err), NULL);
|
||||
}
|
||||
|
||||
char *CLPGetErrorString(SInt16 errid, char *buffer) {
|
||||
getindstring(buffer, 12010, errid);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void CLPReportError(SInt16 errid, ...) {
|
||||
char format[256];
|
||||
va_list va;
|
||||
|
||||
CLPGetErrorString(errid, format);
|
||||
va_start(va, errid);
|
||||
CLPReportError_V(format, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
void CLPReportWarning(SInt16 errid, ...) {
|
||||
char format[256];
|
||||
va_list va;
|
||||
|
||||
CLPGetErrorString(errid, format);
|
||||
va_start(va, errid);
|
||||
CLPReportWarning_V(format, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
void CLPReport(SInt16 errid, ...) {
|
||||
char format[256];
|
||||
va_list va;
|
||||
|
||||
CLPGetErrorString(errid, format);
|
||||
va_start(va, errid);
|
||||
CLPReport_V(format, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
void CLPAlert(SInt16 errid, ...) {
|
||||
char format[256];
|
||||
va_list va;
|
||||
|
||||
CLPGetErrorString(errid, format);
|
||||
va_start(va, errid);
|
||||
CLPAlert_V(format, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
void CLPOSAlert(SInt16 errid, SInt16 err, ...) {
|
||||
char format[256];
|
||||
va_list va;
|
||||
|
||||
CLPGetErrorString(errid, format);
|
||||
va_start(va, err);
|
||||
CLPOSAlert_V(format, err, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
void CLPProgress(SInt16 errid, ...) {
|
||||
char format[256];
|
||||
va_list va;
|
||||
|
||||
CLPGetErrorString(errid, format);
|
||||
va_start(va, errid);
|
||||
CLPStatus_V(format, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
void CLPStatus(SInt16 errid, ...) {
|
||||
char format[256];
|
||||
va_list va;
|
||||
|
||||
CLPGetErrorString(errid, format);
|
||||
va_start(va, errid);
|
||||
CLPStatus_V(format, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
void CLPFatalError(const char *format, ...) {
|
||||
va_list va;
|
||||
|
||||
va_start(va, format);
|
||||
CLPAlert_V(format, va);
|
||||
va_end(va);
|
||||
longjmp(exit_plugin, -123);
|
||||
}
|
|
@ -1,31 +1,14 @@
|
|||
#include "UCWInterface.h"
|
||||
#include "mwcc_decomp.h"
|
||||
|
||||
const char *failedCallback;
|
||||
jmp_buf exit_plugin;
|
||||
struct ParseOptsType parseopts;
|
||||
|
||||
// TODO move me imports
|
||||
extern CWResult CWSecretGetNamedPreferences(CWPluginContext context, const char *name, Handle *pHandle);
|
||||
extern CWResult CWParserSetNamedPreferences(CWPluginContext context, const char *name, Handle pHandle);
|
||||
extern CWResult CWParserGetCommandLine(CWPluginContext context, CWCommandLineArgs **pArgs);
|
||||
extern CWResult CWParserGetToolInfo(CWPluginContext context, struct ToolVersionInfo **pToolVersion);
|
||||
extern CWResult CWParserGetTargetInfo(CWPluginContext context, unsigned long *pCpu, unsigned long *pOs);
|
||||
extern CWResult CWParserGetPanels(CWPluginContext context, int *pNumPanels, char ***pPanelNames);
|
||||
extern CWResult CWParserGetPlugins(CWPluginContext context, int *pNumPlugins, struct CLPluginInfo **pPlugins);
|
||||
extern void/*?*/ CWGetPluginRequest(CWPluginContext context, long *request);
|
||||
extern void/*?*/ CWDonePluginRequest(CWPluginContext context, CWResult result);
|
||||
extern void *pTool;
|
||||
extern void SetupParserToolOptions();
|
||||
extern void CLPReportError(short code, ...);
|
||||
extern unsigned char ParserToolMatchesPlugin(unsigned long plugintype, unsigned long language, unsigned long cpu, unsigned long os);
|
||||
extern unsigned char ParserToolHandlesPanels(int numPanels, char **panelNames);
|
||||
// TODO move me imports
|
||||
|
||||
char *failedCallback;
|
||||
|
||||
static CWResult SetupParamBlock(CWPluginContext context) {
|
||||
struct PCmdLineEnvir cle;
|
||||
Handle h;
|
||||
int x;
|
||||
CWResult result;
|
||||
int x;
|
||||
Handle h;
|
||||
PCmdLineEnvir cle;
|
||||
|
||||
memset(&parseopts, 0, sizeof(parseopts));
|
||||
parseopts.context = context;
|
||||
|
@ -34,7 +17,7 @@ static CWResult SetupParamBlock(CWPluginContext context) {
|
|||
if (result)
|
||||
return result;
|
||||
|
||||
cle = **((struct PCmdLineEnvir **) h);
|
||||
cle = **((PCmdLineEnvir **) h);
|
||||
parseopts.underIDE = cle.underIDE;
|
||||
parseopts.ioRows = cle.rows;
|
||||
parseopts.ioCols = cle.cols;
|
||||
|
@ -80,28 +63,80 @@ static CWResult SetupOptions(CWPluginContext context) {
|
|||
static CWResult Parse(CWPluginContext context) {
|
||||
CWResult result;
|
||||
|
||||
// TODO
|
||||
parseopts.success = 1;
|
||||
parseopts.currentSegment = 1;
|
||||
parseopts.currentOverlayGroup = 0;
|
||||
parseopts.currentOverlay = 0;
|
||||
|
||||
Arg_InitToolArgs(&linkargs);
|
||||
Arg_InitToolArgs(&prelinkargs);
|
||||
Arg_InitToolArgs(&postlinkargs);
|
||||
|
||||
if (pTool->PreParse)
|
||||
parseopts.success &= pTool->PreParse();
|
||||
|
||||
Arg_Init(parseopts.args->argc, parseopts.args->argv);
|
||||
parseopts.noOptions = Arg_IsEmpty();
|
||||
parseopts.success &= Options_Parse(Options_GetOptions(), OFLAGS_1) && !parseopts.hadErrors;
|
||||
Arg_Reset();
|
||||
|
||||
result = Parser_StorePanels(context);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (pTool->MidParse && parseopts.success)
|
||||
parseopts.success &= pTool->MidParse();
|
||||
|
||||
result = Parser_StorePanels(context);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (parseopts.showHelp && parseopts.success)
|
||||
parseopts.success &= Options_DisplayHelp();
|
||||
|
||||
Arg_Reset();
|
||||
if (parseopts.success)
|
||||
parseopts.success &= Options_Parse(Options_GetOptions(), 0) && !parseopts.hadErrors;
|
||||
|
||||
if (pTool->PostParse && parseopts.success)
|
||||
parseopts.success &= pTool->PostParse();
|
||||
|
||||
Arg_Terminate();
|
||||
|
||||
return (parseopts.success && !parseopts.hadErrors) ? cwNoErr : cwErrRequestFailed;
|
||||
}
|
||||
|
||||
Handle Parser_FindPrefPanel(char *name) {
|
||||
Handle h;
|
||||
Handle Parser_FindPrefPanel(const char *name) {
|
||||
int idx;
|
||||
Handle h;
|
||||
|
||||
// TODO pTool
|
||||
for (idx = 0; idx < pTool->numPrefDataPanels; idx++) {
|
||||
if (!ustrcmp(name, pTool->prefDataPanels[idx].name)) {
|
||||
h = NewHandle(pTool->prefDataPanels[idx].size);
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
HLock(h);
|
||||
memcpy(*h, pTool->prefDataPanels[idx].ptr, pTool->prefDataPanels[idx].size);
|
||||
HUnlock(h);
|
||||
return h;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CWResult Parser_StorePanels(CWPluginContext context) {
|
||||
int idx;
|
||||
CWResult result;
|
||||
char *name;
|
||||
const char *name;
|
||||
Handle h;
|
||||
|
||||
for (idx = 0; idx < parseopts.numPanels; idx++) {
|
||||
name = parseopts.panelNames[idx];
|
||||
h = Parser_FindPrefPanel(name);
|
||||
if (h) {
|
||||
result = CWParserSetNamedPreferences(parseopts.context, name, h);
|
||||
result = CWParserSetNamedPreferences(parseopts.context, name, (CWMemHandle) h);
|
||||
if (result) {
|
||||
CLPReportError(68, name);
|
||||
return result;
|
||||
|
@ -109,14 +144,53 @@ CWResult Parser_StorePanels(CWPluginContext context) {
|
|||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
static CWResult StoreResults(CWPluginContext context) {
|
||||
// TODO Arg
|
||||
int idx; // r25
|
||||
CWResult result;
|
||||
CWCommandLineArgs args;
|
||||
UInt32 id; // r8
|
||||
UInt32 lg; // r10
|
||||
|
||||
result = Parser_StorePanels(context);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
for (idx = 0; idx < parseopts.numPlugins; idx++) {
|
||||
if (parseopts.plugins[idx].plugintype == CWDROPINLINKERTYPE && parseopts.plugins[idx].storeCommandLine) {
|
||||
if (parseopts.plugins[idx].dropinflags & isPreLinker) {
|
||||
Arg_ToolArgsForPlugin(&prelinkargs, &args);
|
||||
} else if (parseopts.plugins[idx].dropinflags & isPostLinker) {
|
||||
Arg_ToolArgsForPlugin(&postlinkargs, &args);
|
||||
} else {
|
||||
Arg_ToolArgsForPlugin(&linkargs, &args);
|
||||
}
|
||||
result = CWParserStoreCommandLineForPlugin(parseopts.context, idx, &args);
|
||||
if (result)
|
||||
return result;
|
||||
} else if (parseopts.plugins[idx].storeCommandLine) {
|
||||
id = parseopts.plugins[idx].plugintype;
|
||||
lg = parseopts.plugins[idx].language;
|
||||
fprintf(stderr,
|
||||
"*** No support for %c%c%c%c/%c%c%c%c tool\n",
|
||||
(id & 0xFF000000) >> 24,
|
||||
(id & 0x00FF0000) >> 16,
|
||||
(id & 0x0000FF00) >> 8,
|
||||
(id & 0x000000FF),
|
||||
(lg & 0xFF000000) >> 24,
|
||||
(lg & 0x00FF0000) >> 16,
|
||||
(lg & 0x0000FF00) >> 8,
|
||||
(lg & 0x000000FF)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
short CWParser_GetDropInFlags(const DropInFlags **flags, long *flagsSize) {
|
||||
short CWParser_GetDropInFlags(const DropInFlags **flags, SInt32 *flagsSize) {
|
||||
static const DropInFlags sFlags = {
|
||||
kCurrentDropInFlagsVersion,
|
||||
CWFOURCHAR('P','a','r','s'),
|
||||
|
@ -143,7 +217,7 @@ short CWParser_GetDisplayName(const char **displayName) {
|
|||
}
|
||||
|
||||
short CWParser_GetPanelList(const CWPanelList **panelList) {
|
||||
static const CWPanelList sPanelList = {
|
||||
static CWPanelList sPanelList = {
|
||||
kCurrentCWFamilyListVersion,
|
||||
0,
|
||||
0
|
||||
|
@ -153,9 +227,9 @@ short CWParser_GetPanelList(const CWPanelList **panelList) {
|
|||
}
|
||||
|
||||
short CWParser_GetTargetList(const CWTargetList **targetList) {
|
||||
static const unsigned long sCPU = '****';
|
||||
static const unsigned long sOS = '****';
|
||||
static const CWTargetList sTargetList = {
|
||||
static CWDataType sCPU = '****';
|
||||
static CWDataType sOS = '****';
|
||||
static CWTargetList sTargetList = {
|
||||
kCurrentCWTargetListVersion,
|
||||
1,
|
||||
&sCPU,
|
||||
|
@ -179,16 +253,14 @@ short Parser_SupportsPlugin(struct CLPluginInfo *pluginfo, CWDataType cpu, CWDat
|
|||
return 0;
|
||||
}
|
||||
|
||||
short Parser_SupportsPanels(int numPanels, char **panelNames, Boolean *isSupported) {
|
||||
short Parser_SupportsPanels(int numPanels, const char **panelNames, Boolean *isSupported) {
|
||||
*isSupported = ParserToolHandlesPanels(numPanels, panelNames);
|
||||
return 0;
|
||||
}
|
||||
|
||||
jmp_buf exit_plugin;
|
||||
|
||||
short parser_main(CWPluginContext context) {
|
||||
long request;
|
||||
CWResult result;
|
||||
SInt32 request;
|
||||
|
||||
CWGetPluginRequest(context, &request);
|
||||
result = setjmp(exit_plugin);
|
|
@ -0,0 +1,158 @@
|
|||
#include "mwcc_decomp.h"
|
||||
|
||||
Handle definesHandle;
|
||||
|
||||
int Opt_AddStringToDefines(const char *opt, void *str, const char *param) {
|
||||
AddStringToHandle(&definesHandle, (const char *) str);
|
||||
if (param)
|
||||
AddStringToHandle(&definesHandle, param);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Opt_DefineSymbol(const char *var, const char *value) {
|
||||
char tmp[1024];
|
||||
|
||||
if (pTool->LANG == Lang_C_CPP || pTool->LANG == CWFOURCHAR('A','s','m',' ') || pTool->LANG == Lang_Rez) {
|
||||
sprintf(tmp, "#define %s %s\n", var, value ? value : "1");
|
||||
} else if (pTool->LANG == Lang_Pascal) {
|
||||
sprintf(tmp, "{$definec %s %s}\n", var, value ? value : "1");
|
||||
} else {
|
||||
sprintf(tmp, "Option '-D|d' is not supported with this plugin");
|
||||
CLPReportError(28, tmp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
AddStringToHandle(&definesHandle, tmp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Opt_UndefineSymbol(const char *opt, void *, const char *arg) {
|
||||
char tmp[300];
|
||||
|
||||
if (pTool->LANG == Lang_C_CPP || pTool->LANG == CWFOURCHAR('A','s','m',' ')) {
|
||||
sprintf(tmp, "#undef %s\n", arg);
|
||||
} else if (pTool->LANG == Lang_Pascal) {
|
||||
sprintf(tmp, "{$undefc %s}\n", arg);
|
||||
} else {
|
||||
sprintf(tmp, "Option -%s is not supported with this plugin", opt);
|
||||
CLPReportError(28, tmp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
AddStringToHandle(&definesHandle, tmp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Opt_AddPrefixFile(const char *opt, void *handle, const char *filename) {
|
||||
char tmp[300];
|
||||
|
||||
handle = !handle ? &definesHandle : handle;
|
||||
if (!filename[0])
|
||||
return 1;
|
||||
|
||||
if (pTool->LANG == Lang_C_CPP || pTool->LANG == CWFOURCHAR('A','s','m',' ')) {
|
||||
if (filename[0] == '<' && filename[strlen(filename) - 1] == '>') {
|
||||
snprintf(tmp, sizeof(tmp), "#include %s\n", filename);
|
||||
} else {
|
||||
snprintf(tmp, sizeof(tmp), "#include \"%s\"\n", filename);
|
||||
}
|
||||
} else if (pTool->LANG == Lang_Pascal) {
|
||||
snprintf(tmp, sizeof(tmp), "{$I+}\n{$I %s}\n{$I-}\n", filename);
|
||||
} else {
|
||||
sprintf(tmp, "Option -%s is not supported with this plugin", opt);
|
||||
CLPReportError(28, tmp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
AddStringToHandle((Handle *) handle, tmp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Opt_PragmaTrueFalse(const char *, void *flag, const char *, int flags) {
|
||||
if (flags & PARAMPARSEFLAGS_8)
|
||||
*((unsigned char *) flag) = PR_OFF;
|
||||
else
|
||||
*((unsigned char *) flag) = PR_ON;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Opt_PragmaFalseTrue(const char *, void *flag, const char *, int flags) {
|
||||
if (flags & PARAMPARSEFLAGS_8)
|
||||
*((unsigned char *) flag) = PR_ON;
|
||||
else
|
||||
*((unsigned char *) flag) = PR_OFF;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Opt_PragmaOnOff(const char *, void *flag, const char *arg) {
|
||||
if (!arg) {
|
||||
CLPReportError(34);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!ustrcmp(arg, "on")) {
|
||||
*((unsigned char *) flag) = PR_ON;
|
||||
} else if (!ustrcmp(arg, "off")) {
|
||||
*((unsigned char *) flag) = PR_OFF;
|
||||
} else {
|
||||
CLPReportError(12, arg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Opt_PragmaOffOn(const char *, void *flag, const char *arg) {
|
||||
if (!arg) {
|
||||
CLPReportError(34);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!ustrcmp(arg, "on")) {
|
||||
*((unsigned char *) flag) = PR_OFF;
|
||||
} else if (!ustrcmp(arg, "off")) {
|
||||
*((unsigned char *) flag) = PR_ON;
|
||||
} else {
|
||||
CLPReportError(12, arg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SetupPragmas(const Pragma *pragmas) {
|
||||
const char *set;
|
||||
char on;
|
||||
char off;
|
||||
char tmp[300];
|
||||
|
||||
while (pragmas->pragma) {
|
||||
if (pragmas->flags == PRAGMA_FLAGS_0 || pragmas->flags == PRAGMA_FLAGS_1) {
|
||||
set = 0;
|
||||
on = !(pragmas->flags == PRAGMA_FLAGS_1) ? PR_ON : PR_OFF;
|
||||
off = !(pragmas->flags == PRAGMA_FLAGS_1) ? PR_OFF : PR_ON;
|
||||
if (*((char *)pragmas->value) == on)
|
||||
set = "on";
|
||||
else if (*((char *)pragmas->value) == off)
|
||||
set = "off";
|
||||
else if (*((char *)pragmas->value) == PR_AUTO)
|
||||
set = "auto";
|
||||
else if (*((char *)pragmas->value) == PR_RESET)
|
||||
set = "reset";
|
||||
else
|
||||
#line 186
|
||||
OPTION_ASSERT(*((char *)pragmas->value) == PR_UNSET);
|
||||
|
||||
if (set) {
|
||||
snprintf(tmp, sizeof(tmp), "#pragma %s %s\n", pragmas->pragma, set);
|
||||
AddStringToHandle(&definesHandle, tmp);
|
||||
}
|
||||
} else {
|
||||
#line 195
|
||||
OPTION_ASSERT(!"Can't handle pragma");
|
||||
}
|
||||
pragmas++;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
|
@ -0,0 +1,534 @@
|
|||
#include "mwcc_decomp.h"
|
||||
#include <errno.h>
|
||||
|
||||
SInt16 lastStage;
|
||||
Boolean dashIMinusMovesPaths;
|
||||
Boolean usedDashIMinus;
|
||||
Boolean namingSysPaths;
|
||||
static char STSbuf[256];
|
||||
|
||||
int FindFileInPath(const char *filename, OSSpec *fss) {
|
||||
CWFileInfo fi;
|
||||
CWResult result;
|
||||
|
||||
fi.fullsearch = 1;
|
||||
fi.dependencyType = 0;
|
||||
fi.suppressload = 1;
|
||||
fi.isdependentoffile = kCurrentCompiledFile;
|
||||
|
||||
result = CWFindAndLoadFile(parseopts.context, filename, &fi);
|
||||
if (!result) {
|
||||
OS_FSSpec_To_OSSpec(&fi.filespec, fss);
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
char *GetEnvVar(const char *name, Boolean warn, const char **match) {
|
||||
const char *nptr;
|
||||
const char *last;
|
||||
char *ret;
|
||||
|
||||
nptr = name;
|
||||
last = name;
|
||||
while (*nptr) {
|
||||
ret = getenv(nptr);
|
||||
if (ret) {
|
||||
if (match)
|
||||
*match = nptr;
|
||||
return ret;
|
||||
}
|
||||
last = nptr;
|
||||
nptr = &nptr[1 + strlen(nptr)];
|
||||
}
|
||||
|
||||
if (warn)
|
||||
CLPReportWarning(52, last);
|
||||
*match = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Boolean MatchesExtension(const char *list, const char *filename) {
|
||||
char *fn;
|
||||
const char *eptr;
|
||||
const char *ptr;
|
||||
|
||||
fn = OS_GetFileNamePtr((char *) filename);
|
||||
eptr = strrchr(fn, '.');
|
||||
if (!eptr)
|
||||
return 0;
|
||||
if (!list)
|
||||
return 1;
|
||||
|
||||
ptr = eptr;
|
||||
while (*list) {
|
||||
if (*list == '|' && !*ptr)
|
||||
return 1;
|
||||
|
||||
if (my_tolower(*list) == my_tolower(*ptr)) {
|
||||
list++;
|
||||
ptr++;
|
||||
continue;
|
||||
}
|
||||
|
||||
while (*list && *list != '|')
|
||||
list++;
|
||||
if (*list)
|
||||
list++;
|
||||
ptr = eptr;
|
||||
}
|
||||
|
||||
return !*list && !*ptr;
|
||||
}
|
||||
|
||||
int Opt_AddAccessPath(const char *opt, void *var, const char *arg) {
|
||||
OSPathSpec spec;
|
||||
int err;
|
||||
|
||||
arg = arg ? arg : opt;
|
||||
if (!arg)
|
||||
return 0;
|
||||
if (!arg[0])
|
||||
return 1;
|
||||
|
||||
if (strlen(arg) >= 256) {
|
||||
CLPReportError(13, arg + strlen(arg) - 32, 256);
|
||||
return 0;
|
||||
}
|
||||
|
||||
err = OS_MakePathSpec(0, arg, &spec);
|
||||
if (err == ENOENT || err == ENOENT) {
|
||||
CLPReportWarning(45, arg);
|
||||
return 1;
|
||||
} else if (err != 0) {
|
||||
CLPOSAlert(45, err, arg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// this 'if' gets optimised unnecessarily
|
||||
if (!AddAccessPath(&spec, namingSysPaths, 0, var != NULL))
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Opt_AddFrameworkPath(const char *opt, void *var, const char *arg) {
|
||||
OSPathSpec spec;
|
||||
int err;
|
||||
|
||||
arg = arg ? arg : opt;
|
||||
if (!arg)
|
||||
return 0;
|
||||
if (!arg[0])
|
||||
return 1;
|
||||
|
||||
if (strlen(arg) >= 256) {
|
||||
CLPReportError(13, arg + strlen(arg) - 32, 256);
|
||||
return 0;
|
||||
}
|
||||
|
||||
err = OS_MakePathSpec(0, arg, &spec);
|
||||
if (err == ENOENT || err == ENOENT) {
|
||||
CLPReportWarning(45, arg);
|
||||
return 1;
|
||||
} else if (err != 0) {
|
||||
CLPOSAlert(45, err, arg);
|
||||
return 1;
|
||||
} else {
|
||||
Frameworks_AddPath(&spec);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int Opt_AddFramework(const char *opt, void *var, const char *arg) {
|
||||
if (!Frameworks_AddFramework(arg ? arg : opt, 0, 0))
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ListParseMessage(void (*errprint)(const char *, va_list), const char *envvar, SInt16 id, ...) {
|
||||
char buf[1024];
|
||||
va_list ap;
|
||||
|
||||
if (envvar && envvar[0])
|
||||
sprintf(buf, "In environment variable '%s':\n", envvar);
|
||||
else
|
||||
buf[0] = 0;
|
||||
|
||||
CLPGetErrorString(id, buf + strlen(buf));
|
||||
va_start(ap, id);
|
||||
errprint(buf, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
int AddAccessPathList(const char *list, char sep1, char sep2, int source, char *text, Boolean system, SInt32 position, Boolean recursive) {
|
||||
char tmp[256];
|
||||
Boolean recurse;
|
||||
OSPathSpec spec;
|
||||
int err;
|
||||
short type;
|
||||
char *ptr;
|
||||
|
||||
type = (Boolean) ((system == 1) ? 1 : 0) | (!source ? 0 : 2);
|
||||
recurse = (list[0] == '+');
|
||||
if (recurse)
|
||||
++list;
|
||||
|
||||
if (!strchr(list, sep1))
|
||||
sep1 = sep2;
|
||||
|
||||
while (*list) {
|
||||
ptr = tmp;
|
||||
while (*list && *list != sep1 && (ptr + 1) < &tmp[256]) {
|
||||
*(ptr++) = *(list++);
|
||||
}
|
||||
*ptr = 0;
|
||||
|
||||
if ((ptr + 1) >= &tmp[256]) {
|
||||
ListParseMessage(
|
||||
CLPReportError_V,
|
||||
(source == 1) ? text : NULL,
|
||||
9,
|
||||
tmp,
|
||||
tmp + strlen(tmp) - 16,
|
||||
256);
|
||||
return 0;
|
||||
}
|
||||
|
||||
err = OS_MakePathSpec(0, tmp, &spec);
|
||||
if (err) {
|
||||
ListParseMessage(
|
||||
CLPReportWarning_V,
|
||||
(source == 1) ? text : NULL,
|
||||
45,
|
||||
tmp);
|
||||
} else {
|
||||
AddAccessPath(&spec, type, position, recurse ^ recursive);
|
||||
}
|
||||
|
||||
if (*list)
|
||||
++list;
|
||||
recurse = *list == '+';
|
||||
if (recurse)
|
||||
++list;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Opt_FindAndAddFile(const char *opt, void *var, const char *arg) {
|
||||
OSSpec spec;
|
||||
int err;
|
||||
Boolean isfile;
|
||||
|
||||
arg = arg ? arg : opt;
|
||||
if (!arg)
|
||||
return 0;
|
||||
if (!*arg)
|
||||
return 1;
|
||||
|
||||
parseopts.userSpecifiedFiles++;
|
||||
err = OS_MakeSpec(arg, &spec, &isfile);
|
||||
if (!err)
|
||||
err = OS_Status(&spec);
|
||||
|
||||
if (!err && !isfile) {
|
||||
CLPReportError(47, arg);
|
||||
parseopts.unusedFiles++;
|
||||
return 0;
|
||||
} else if (err && err != ENOENT) {
|
||||
CLPOSAlert(44, err, arg);
|
||||
parseopts.unusedFiles++;
|
||||
return 0;
|
||||
} else if (err && parseopts.alwaysUsePaths) {
|
||||
err = FindFileInPath(arg, &spec) ? 0 : ENOENT;
|
||||
}
|
||||
|
||||
if (err) {
|
||||
CLPReportError(44, arg);
|
||||
parseopts.unusedFiles++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (var && !MatchesExtension((const char *) var, arg))
|
||||
CLPReportWarning(76, arg, var);
|
||||
|
||||
if (!AddFileToProject(&spec, lastStage, parseopts.lastoutputname, 1, -1)) {
|
||||
parseopts.unusedFiles++;
|
||||
return 0;
|
||||
} else {
|
||||
parseopts.lastoutputname[0] = 0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int Opt_FindAndAddFileRef(const char *opt, void *var, const char *arg) {
|
||||
OSSpec spec;
|
||||
int err;
|
||||
Boolean isfile;
|
||||
|
||||
arg = arg ? arg : opt;
|
||||
if (!arg)
|
||||
return 0;
|
||||
if (!*arg)
|
||||
return 1;
|
||||
|
||||
parseopts.userSpecifiedFiles++;
|
||||
if (var && !MatchesExtension((const char *) var, arg))
|
||||
CLPReportWarning(76, arg, var);
|
||||
|
||||
err = OS_MakeSpec(arg, &spec, &isfile);
|
||||
if (!err)
|
||||
err = OS_Status(&spec);
|
||||
|
||||
if (!err && !isfile) {
|
||||
CLPReportError(47, arg);
|
||||
parseopts.unusedFiles++;
|
||||
return 0;
|
||||
} else if (err && parseopts.alwaysUsePaths) {
|
||||
err = FindFileInPath(arg, &spec) ? 0 : ENOENT;
|
||||
}
|
||||
|
||||
if (!AddFileToProject(&spec, 0, 0, err == 0, -1)) {
|
||||
parseopts.unusedFiles++;
|
||||
return 0;
|
||||
} else {
|
||||
return AddAccessPath(&spec.path, 1, -1, 0) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
int Opt_AddUnixLibraryFile(const char *opt, void *var, const char *name) {
|
||||
OSSpec spec;
|
||||
Boolean failed;
|
||||
const char *eptr;
|
||||
const char *eend;
|
||||
char tmpname[64];
|
||||
|
||||
if (strlen(name) >= 56) {
|
||||
CLPReportError(13, name + strlen(name) - 32, 64);
|
||||
return 0;
|
||||
}
|
||||
|
||||
failed = 1;
|
||||
if (!var)
|
||||
var = ".lib|.a";
|
||||
|
||||
eptr = (const char *) var;
|
||||
while (eptr && *eptr) {
|
||||
eend = eptr;
|
||||
while (*eend && *eend != '|')
|
||||
++eend;
|
||||
|
||||
sprintf(tmpname, "lib%s%*.*s", name, eend - eptr, eend - eptr, eptr);
|
||||
if (FindFileInPath(tmpname, &spec)) {
|
||||
failed = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (*eend)
|
||||
eptr = eend + 1;
|
||||
else
|
||||
eptr = eend;
|
||||
}
|
||||
|
||||
if (failed) {
|
||||
failed = !FindFileInPath(name, &spec);
|
||||
if (failed)
|
||||
CLPReportError(49, name, var, name);
|
||||
}
|
||||
|
||||
if (!failed) {
|
||||
if (!AddFileToProject(&spec, 0, 0, 1, -1)) {
|
||||
parseopts.unusedFiles++;
|
||||
failed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return !failed;
|
||||
}
|
||||
|
||||
int AddFileList(const char *list, char sep1, char sep2, int source, char *text, SInt32 position) {
|
||||
char tmp[256];
|
||||
OSSpec spec;
|
||||
char *ptr;
|
||||
|
||||
if (!strchr(list, sep1))
|
||||
sep1 = sep2;
|
||||
|
||||
while (*list) {
|
||||
ptr = tmp;
|
||||
while (*list && *list != sep1 && (ptr + 1) < &tmp[256]) {
|
||||
*(ptr++) = *(list++);
|
||||
}
|
||||
*ptr = 0;
|
||||
|
||||
if ((ptr + 1) >= &tmp[256]) {
|
||||
ListParseMessage(
|
||||
CLPReportError_V,
|
||||
(source == 1) ? text : 0,
|
||||
9,
|
||||
tmp,
|
||||
tmp + strlen(tmp) - 16,
|
||||
256
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!FindFileInPath(tmp, &spec)) {
|
||||
if (OS_IsDir(&spec)) {
|
||||
ListParseMessage(
|
||||
CLPReportError_V,
|
||||
(source == 1) ? text : 0,
|
||||
16,
|
||||
tmp
|
||||
);
|
||||
} else {
|
||||
ListParseMessage(
|
||||
CLPReportWarning_V,
|
||||
(source == 1) ? text : 0,
|
||||
44,
|
||||
tmp
|
||||
);
|
||||
}
|
||||
} else {
|
||||
AddFileToProject(&spec, 0, 0, 1, position);
|
||||
}
|
||||
|
||||
if (*list)
|
||||
++list;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int IsFileInOutputDirectory(const OSSpec *file) {
|
||||
OSPathSpec outdir;
|
||||
GetOutputFileDirectory(&outdir);
|
||||
return OS_EqualPathSpec(&outdir, &file->path);
|
||||
}
|
||||
|
||||
void GetCFileNameInOutputDirectory(const char *input, char *name, int maxlen) {
|
||||
char filename[64];
|
||||
OSSpec spec;
|
||||
int err;
|
||||
|
||||
err = OS_MakeFileSpec(input, &spec);
|
||||
if (err) {
|
||||
CLPOSAlert(64, err, input);
|
||||
name[0] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsFileInOutputDirectory(&spec)) {
|
||||
CLPReportWarning(61, OS_SpecToStringRelative(&spec, 0, STSbuf, sizeof(STSbuf)));
|
||||
}
|
||||
|
||||
OS_NameSpecToString(&spec.name, filename, 256);
|
||||
if (strlen(filename) >= maxlen) {
|
||||
CLPReportWarning(65, filename, maxlen - 1);
|
||||
filename[maxlen - 1] = 0;
|
||||
}
|
||||
|
||||
strcpy(name, filename);
|
||||
}
|
||||
|
||||
void GetPFileNameInOutputDirectory(const char *input, unsigned char *name, int len) {
|
||||
GetCFileNameInOutputDirectory(input, (char *) name, len);
|
||||
c2pstr((char *) name);
|
||||
}
|
||||
|
||||
void AddStringLenToHandle(Handle *h, const char *str, int len) {
|
||||
SInt32 old;
|
||||
|
||||
if (!*h) {
|
||||
if ((*h = NewHandle(len + 1))) {
|
||||
HLock(*h);
|
||||
memcpy(**h, str, len);
|
||||
(**h)[len] = 0;
|
||||
HUnlock(*h);
|
||||
} else {
|
||||
exit(-23);
|
||||
}
|
||||
} else {
|
||||
old = GetHandleSize(*h) - 1;
|
||||
SetHandleSize(*h, old + len + 1);
|
||||
if (MemError() == noErr) {
|
||||
HLock(*h);
|
||||
memcpy(**h + old, str, len);
|
||||
(**h)[old + len] = 0;
|
||||
HUnlock(*h);
|
||||
} else {
|
||||
exit(-23);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AddStringToHandle(Handle *h, const char *str) {
|
||||
AddStringLenToHandle(h, str, strlen(str));
|
||||
}
|
||||
|
||||
int Opt_PrintVersion(const char *opt, void *var, const char *arg) {
|
||||
ShowVersion(0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void GetFirstSourceFilenameBase(char *buffer, char *defaul) {
|
||||
int cnt;
|
||||
OSSpec spec;
|
||||
char compiler[32];
|
||||
int x;
|
||||
char *ext;
|
||||
|
||||
cnt = GetFileCount();
|
||||
for (x = 0; x < cnt; x++) {
|
||||
if (GetFileInfo(x, &spec, compiler)) {
|
||||
if (compiler[0]) {
|
||||
if (!strstr(compiler, "Lib")) {
|
||||
OS_NameSpecToString(&spec.name, buffer, 256);
|
||||
ext = strrchr(buffer, '.');
|
||||
if (ext)
|
||||
*ext = 0;
|
||||
memmove(buffer, buffer, strlen(buffer) + 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
strcpy(buffer, defaul);
|
||||
}
|
||||
|
||||
int Opt_SavePrefs(const char *opt, void *var, const char *arg) {
|
||||
Parser_StorePanels(parseopts.context);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ParseNumber(const char *arg, Boolean emit_error, SInt32 *ret, const char **endptr) {
|
||||
char *end;
|
||||
|
||||
if (arg[0] == '0' && (arg[1] == 'x' || arg[1] == 'X')) {
|
||||
*ret = strtol(arg + 2, &end, 16);
|
||||
} else if (arg[0] == '0') {
|
||||
*ret = strtol(arg + 1, &end, 8);
|
||||
} else {
|
||||
*ret = strtol(arg, &end, 10);
|
||||
}
|
||||
|
||||
if (endptr)
|
||||
*endptr = end;
|
||||
|
||||
if (*end && emit_error) {
|
||||
CLPReportError(5, "", arg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Opt_MaybeMoveAccessPaths(const char *opt, void *var, const char *arg) {
|
||||
if (dashIMinusMovesPaths && !usedDashIMinus)
|
||||
MoveSystemPathsIntoUserList();
|
||||
return 1;
|
||||
}
|
|
@ -0,0 +1,242 @@
|
|||
#include "mwcc_decomp.h"
|
||||
|
||||
// TODO: figure out who defines this
|
||||
extern char STSbuf[256];
|
||||
|
||||
int GetFileCount() {
|
||||
SInt32 num;
|
||||
CWGetProjectFileCount(parseopts.context, &num);
|
||||
return num;
|
||||
}
|
||||
|
||||
void SetFileOutputName(SInt32 position, SInt16 which, char *outfilename) {
|
||||
CWResult result;
|
||||
if (outfilename && outfilename[0]) {
|
||||
result = CWParserSetFileOutputName(parseopts.context, position, which ? which : 1, outfilename);
|
||||
if (result) {
|
||||
failedCallback = "CWParserSetFileOutputName";
|
||||
longjmp(exit_plugin, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int AddFileToProject(OSSpec *oss, SInt16 which, char *outfilename, Boolean exists, SInt32 position) {
|
||||
CWFileSpec cws;
|
||||
CWNewProjectEntryInfo pei;
|
||||
CWResult result;
|
||||
int err;
|
||||
|
||||
err = OS_OSSpec_To_FSSpec(oss, &cws);
|
||||
if (err) {
|
||||
CLPOSAlert(44, err, OS_SpecToStringRelative(oss, 0, STSbuf, sizeof(STSbuf)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (position == -2) {
|
||||
pei.position = 0;
|
||||
} else if (position == -1) {
|
||||
CWGetProjectFileCount(parseopts.context, &pei.position);
|
||||
} else if (position == 0) {
|
||||
pei.position = -1;
|
||||
} else {
|
||||
pei.position = position;
|
||||
}
|
||||
|
||||
pei.segment = parseopts.currentSegment;
|
||||
pei.overlayGroup = parseopts.currentOverlayGroup;
|
||||
pei.overlay = parseopts.currentOverlay;
|
||||
pei.groupPath = NULL;
|
||||
pei.mergeintooutput = parseopts.mergeIntoOutput;
|
||||
pei.weakimport = parseopts.weakImport;
|
||||
pei.initbefore = parseopts.initBefore;
|
||||
result = CWAddProjectEntry(parseopts.context, &cws, exists == 0, &pei, &position);
|
||||
if (result) {
|
||||
failedCallback = "CWAddProjectEntry";
|
||||
longjmp(exit_plugin, result);
|
||||
}
|
||||
parseopts.initBefore = 0;
|
||||
parseopts.weakImport = 0;
|
||||
parseopts.mergeIntoOutput = 0;
|
||||
SetFileOutputName(position, which, outfilename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Boolean GetFileInfo(SInt32 position, OSSpec *spec, char *plugin) {
|
||||
CWProjectFileInfo pfi;
|
||||
if (CWGetFileInfo(parseopts.context, position, 1, &pfi))
|
||||
return 0;
|
||||
|
||||
OS_FSSpec_To_OSSpec(&pfi.filespec, spec);
|
||||
strncpy(plugin, pfi.dropinname, 32);
|
||||
plugin[31] = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int AddAccessPath(OSPathSpec *oss, SInt16 type, SInt32 position, Boolean recursive) {
|
||||
CWNewAccessPathInfo api;
|
||||
CWResult result;
|
||||
OSSpec spec;
|
||||
int err;
|
||||
CWAccessPathListInfo apli;
|
||||
|
||||
if ((err = OS_MakeSpecWithPath(oss, NULL, 0, &spec)) || (err = OS_OSSpec_To_FSSpec(&spec, &api.pathSpec))) {
|
||||
CLPOSAlert(45, err, OS_PathSpecToString(&spec.path, STSbuf, sizeof(STSbuf)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (position == -2) {
|
||||
api.position = 0;
|
||||
} else if (position == -1 || position == 0) {
|
||||
api.position = -1;
|
||||
} else if (position == -1) {
|
||||
result = CWGetAccessPathListInfo(parseopts.context, &apli);
|
||||
if (result) {
|
||||
failedCallback = "CWGetAccessPathListInfo";
|
||||
longjmp(exit_plugin, result);
|
||||
}
|
||||
if ((type & 1) == 1) {
|
||||
api.position = apli.systemPathCount;
|
||||
} else {
|
||||
api.position = apli.userPathCount;
|
||||
}
|
||||
} else {
|
||||
api.position = position;
|
||||
}
|
||||
|
||||
api.type = (type & 1) ? cwSystemPath : cwUserPath;
|
||||
api.type = api.type | (CWAccessPathType) ((type & 2) ? cwAccessPathTypeFlag2 : 0);
|
||||
api.recursive = recursive;
|
||||
|
||||
result = CWParserAddAccessPath(parseopts.context, &api);
|
||||
if (result) {
|
||||
failedCallback = "CWParserAddAccessPath";
|
||||
longjmp(exit_plugin, result);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int MoveSystemPathsIntoUserList() {
|
||||
CWResult result = CWParserSwapAccessPaths(parseopts.context);
|
||||
return result == cwNoErr;
|
||||
}
|
||||
|
||||
void AddVirtualFile(const char *filename, Handle *text) {
|
||||
CWResult result;
|
||||
CWMemHandle mh;
|
||||
|
||||
if (*text) {
|
||||
CWSecretAttachHandle(parseopts.context, *text, &mh);
|
||||
result = CWParserCreateVirtualFile(parseopts.context, filename, mh);
|
||||
if (result) {
|
||||
failedCallback = "CWParserCreateVirtualFile";
|
||||
longjmp(exit_plugin, result);
|
||||
}
|
||||
DisposeHandle(*text);
|
||||
*text = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void GetOutputFileDirectory(OSPathSpec *dir) {
|
||||
CWResult result;
|
||||
CWFileSpec idefss;
|
||||
OSSpec spec;
|
||||
|
||||
result = CWGetOutputFileDirectory(parseopts.context, &idefss);
|
||||
if (result) {
|
||||
failedCallback = "CWGetOutputFileDirectory";
|
||||
longjmp(exit_plugin, result);
|
||||
}
|
||||
|
||||
OS_FSSpec_To_OSSpec(&idefss, &spec);
|
||||
*dir = spec.path;
|
||||
}
|
||||
|
||||
void SetOutputFileDirectory(OSPathSpec *dir) {
|
||||
CWResult result;
|
||||
CWFileSpec idefss;
|
||||
OSSpec spec;
|
||||
|
||||
OS_MakeSpecWithPath(dir, NULL, 0, &spec);
|
||||
OS_OSSpec_To_FSSpec(&spec, &idefss);
|
||||
|
||||
result = CWParserSetOutputFileDirectory(parseopts.context, &idefss);
|
||||
if (result) {
|
||||
failedCallback = "CWParserSetOutputFileDirectory";
|
||||
longjmp(exit_plugin, result);
|
||||
}
|
||||
}
|
||||
|
||||
void AddOverlayGroup(const char *name, CWAddr64 *addr, SInt32 *groupnum, SInt32 *overlaynum) {
|
||||
CWResult result;
|
||||
|
||||
*overlaynum = -1;
|
||||
result = CWParserAddOverlay1Group(parseopts.context, name, addr, groupnum);
|
||||
if (result) {
|
||||
if (result == cwErrInvalidCallback) {
|
||||
CLPReportError(72);
|
||||
} else {
|
||||
failedCallback = "CWParserAddOverlay1Group";
|
||||
longjmp(exit_plugin, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AddOverlay(SInt32 groupnum, const char *name, SInt32 *overlaynum) {
|
||||
CWResult result;
|
||||
|
||||
result = CWParserAddOverlay1(parseopts.context, name, groupnum, overlaynum);
|
||||
if (result) {
|
||||
if (result == cwErrInvalidCallback) {
|
||||
CLPReportError(72);
|
||||
} else {
|
||||
failedCallback = "CWParserAddOverlay1";
|
||||
longjmp(exit_plugin, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AddSegment(const char *name, SInt16 attrs, SInt32 *segmentnum) {
|
||||
CWResult result;
|
||||
|
||||
result = CWParserAddSegment(parseopts.context, name, attrs, segmentnum);
|
||||
if (result) {
|
||||
if (result == cwErrInvalidCallback) {
|
||||
CLPReportError(73);
|
||||
} else {
|
||||
failedCallback = "CWParserAddSegment";
|
||||
longjmp(exit_plugin, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChangeSegment(SInt32 segmentnum, const char *name, SInt16 attrs) {
|
||||
CWResult result;
|
||||
|
||||
result = CWParserSetSegment(parseopts.context, segmentnum, name, attrs);
|
||||
if (result) {
|
||||
if (result == cwErrInvalidCallback) {
|
||||
CLPReportError(73);
|
||||
} else {
|
||||
failedCallback = "CWParserSetSegment";
|
||||
longjmp(exit_plugin, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int GetSegment(SInt32 segmentnum, char *name, SInt16 *attrs) {
|
||||
CWResult result;
|
||||
CWProjectSegmentInfo psi;
|
||||
|
||||
result = CWGetSegmentInfo(parseopts.context, segmentnum, &psi);
|
||||
if (result) {
|
||||
if (result == cwErrInvalidCallback) {
|
||||
CLPReportError(73);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
strcpy(name, psi.name);
|
||||
*attrs = psi.attributes;
|
||||
return 1;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
#include "mwcc_decomp.h"
|
||||
|
||||
static BasePluginCallbacks cb = {
|
||||
parser_main,
|
||||
CWParser_GetDropInFlags,
|
||||
CWParser_GetDisplayName,
|
||||
CWParser_GetDropInName,
|
||||
CWParser_GetPanelList,
|
||||
NULL,
|
||||
NULL,
|
||||
CWParser_GetVersionInfo,
|
||||
NULL
|
||||
};
|
||||
|
||||
static ParserPluginCallbacks pr_cb = {
|
||||
Parser_SupportsPlugin,
|
||||
Parser_SupportsPanels
|
||||
};
|
||||
|
||||
int RegisterStaticParserPlugins() {
|
||||
return RegisterStaticParserPlugin(&cb, &pr_cb);
|
||||
}
|
||||
|
||||
#include "ParserErrors.r"
|
||||
|
||||
int RegisterStaticParserResources() {
|
||||
return RegisterResource("Parser Strings", 12010, STR12010);
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
#include "mwcc_decomp.h"
|
||||
|
||||
ParserTool *pTool;
|
||||
|
||||
int SetParserToolInfo(ParserTool *tool) {
|
||||
pTool = tool;
|
||||
|
||||
#line 16
|
||||
OPTION_ASSERT(pTool->toolInfo && (parseopts.toolVersion || pTool->copyright));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Boolean ParserToolMatchesPlugin(OSType type, OSType lang, OSType cpu, OSType os) {
|
||||
if (!pTool) {
|
||||
CLPFatalError("No options loaded for command line\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (
|
||||
(type == CWFOURCHAR('*','*','*','*') || pTool->TYPE == CWFOURCHAR('*','*','*','*') || pTool->TYPE == type) &&
|
||||
(lang == CWFOURCHAR('*','*','*','*') || pTool->LANG == CWFOURCHAR('*','*','*','*') || pTool->LANG == lang) &&
|
||||
(cpu == targetCPUAny || pTool->CPU == targetCPUAny || pTool->CPU == cpu) &&
|
||||
(os == targetOSAny || pTool->OS == targetOSAny || pTool->OS == os)
|
||||
)
|
||||
{
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Boolean ParserToolHandlesPanels(int numPanels, const char **panelNames) {
|
||||
int idx;
|
||||
int scan;
|
||||
|
||||
if (!pTool)
|
||||
CLPFatalError("No options loaded for command line\n");
|
||||
|
||||
for (idx = 0; idx < numPanels; idx++) {
|
||||
for (scan = 0; scan < pTool->numPrefPanels; scan++) {
|
||||
if (!ustrcmp(pTool->prefPanels[scan], panelNames[idx]))
|
||||
break;
|
||||
}
|
||||
|
||||
if (scan >= pTool->numPrefPanels)
|
||||
break;
|
||||
}
|
||||
|
||||
if (idx >= numPanels)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
Boolean SetupParserToolOptions() {
|
||||
int idx;
|
||||
|
||||
Options_Init();
|
||||
for (idx = 0; idx < pTool->numOptionLists; idx++) {
|
||||
Options_AddList(pTool->optionLists[idx]);
|
||||
}
|
||||
Options_SortOptions();
|
||||
|
||||
return 1;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
#include "mwcc_decomp.h"
|
||||
|
||||
int Opt_DummyLinkerRoutine(const char *opt) {
|
||||
CLPFatalError("Calling linker option '%s'\n", opt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Opt_DummyLinkerSettingRoutine(const char *var, const char *val) {
|
||||
CLPFatalError("Calling linker settings option '%s'='%s'\n", var, val ? val : "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FinishCompilerTool() {
|
||||
SInt32 numfiles;
|
||||
|
||||
if (parseopts.lastoutputname[0]) {
|
||||
numfiles = GetFileCount();
|
||||
|
||||
if (pCmdLine.stages == CmdLineStageMask_Dp) {
|
||||
strcpy(pCmdLineCompiler.outMakefile, parseopts.lastoutputname);
|
||||
} else if (outputOrdering == OutputOrdering2) {
|
||||
if (parseopts.possibleFiles > 0 || parseopts.userSpecifiedFiles > 0)
|
||||
CLPReportError(41, parseopts.lastoutputname);
|
||||
else
|
||||
CLPReportError(42, parseopts.lastoutputname);
|
||||
} else {
|
||||
SetFileOutputName(numfiles - 1, lastStage, parseopts.lastoutputname);
|
||||
}
|
||||
|
||||
parseopts.lastoutputname[0] = 0;
|
||||
}
|
||||
|
||||
if (setOutputDirectory)
|
||||
pCmdLineCompiler.relPathInOutputDir = 0;
|
||||
}
|
|
@ -0,0 +1,289 @@
|
|||
#include "mwcc_decomp.h"
|
||||
#include <errno.h>
|
||||
|
||||
// TODO: figure out who defines this
|
||||
extern char STSbuf[256];
|
||||
|
||||
static Boolean setStage;
|
||||
SInt16 outputOrdering;
|
||||
Boolean setOutputDirectory;
|
||||
Boolean setLinkerOutputFilename;
|
||||
char linkerOutputFilename[256];
|
||||
|
||||
int Opt_HandleOutputName(const char *opt, void *, const char *filename) {
|
||||
OSSpec spec;
|
||||
int err;
|
||||
SInt32 result;
|
||||
Boolean isfile;
|
||||
|
||||
if (!filename)
|
||||
filename = opt;
|
||||
|
||||
if ((pCmdLine.state == OptsCmdLineState_3 || (pCmdLine.state == OptsCmdLineState_0 && pTool->TYPE == CWDROPINLINKERTYPE)) && pCmdLine.toDisk != 4) {
|
||||
if (setLinkerOutputFilename) {
|
||||
CLPReportError(41, filename);
|
||||
return 0;
|
||||
}
|
||||
setLinkerOutputFilename = 1;
|
||||
if (pTool->TYPE == CWDROPINCOMPILERTYPE) {
|
||||
strncpy(linkerOutputFilename, filename, 256);
|
||||
} else {
|
||||
OSSpec spec;
|
||||
int err;
|
||||
Boolean isfile;
|
||||
err = OS_MakeSpec(filename, &spec, &isfile);
|
||||
if (err) {
|
||||
CLPOSAlert(64, err, filename);
|
||||
return 0;
|
||||
}
|
||||
if (isfile)
|
||||
OS_NameSpecToString(&spec.name, linkerOutputFilename, 256);
|
||||
SetOutputFileDirectory(&spec.path);
|
||||
}
|
||||
return 1;
|
||||
} else {
|
||||
err = OS_MakeSpec(filename, &spec, &isfile);
|
||||
if (err) {
|
||||
CLPOSAlert(64, err, filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!err && !isfile) {
|
||||
FSSpec ofd;
|
||||
if (setOutputDirectory) {
|
||||
CLPReportError(59, filename);
|
||||
return 0;
|
||||
}
|
||||
setOutputDirectory = 1;
|
||||
|
||||
OS_OSSpec_To_FSSpec(&spec, &ofd);
|
||||
result = CWParserSetOutputFileDirectory(parseopts.context, &ofd);
|
||||
if (result) {
|
||||
failedCallback = "CWParserSetOutputFileDirectory";
|
||||
longjmp(exit_plugin, result);
|
||||
}
|
||||
return 1;
|
||||
} else {
|
||||
SInt32 index;
|
||||
CWProjectFileInfo pfi;
|
||||
if (parseopts.lastoutputname[0]) {
|
||||
CLPReportError(41, filename);
|
||||
return 0;
|
||||
}
|
||||
strncpy(parseopts.lastoutputname, filename, 256);
|
||||
if (pCmdLine.stages == CmdLineStageMask_Dp)
|
||||
return 1;
|
||||
|
||||
if (outputOrdering == OutputOrdering0 || outputOrdering == OutputOrdering1) {
|
||||
CWGetProjectFileCount(parseopts.context, &index);
|
||||
while (index-- > 0) {
|
||||
if (!CWGetFileInfo(parseopts.context, index, 0, &pfi) && pfi.filetype == CWFOURCHAR('T','E','X','T')) {
|
||||
outputOrdering = OutputOrdering1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (index <= 0) {
|
||||
CWGetProjectFileCount(parseopts.context, &index);
|
||||
if (index > 0)
|
||||
outputOrdering = OutputOrdering1;
|
||||
--index;
|
||||
}
|
||||
|
||||
if (outputOrdering == OutputOrdering0) {
|
||||
outputOrdering = OutputOrdering2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
SetFileOutputName(index, lastStage, parseopts.lastoutputname);
|
||||
parseopts.lastoutputname[0] = 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ValidateToolState(Boolean mustHaveFiles) {
|
||||
if (parseopts.noOptions) {
|
||||
pCmdLine.state = OptsCmdLineState_1;
|
||||
ShowVersion(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (parseopts.success) {
|
||||
if (!parseopts.userSpecifiedFiles) {
|
||||
if (!parseopts.hadAnyOutput) {
|
||||
if (mustHaveFiles) {
|
||||
CLPReportError(70);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if (mustHaveFiles)
|
||||
pCmdLine.state = OptsCmdLineState_1;
|
||||
return 1;
|
||||
}
|
||||
} else if (parseopts.unusedFiles > 0) {
|
||||
CLPReportError(69);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (pCmdLine.state == OptsCmdLineState_0 || (parseopts.userSpecifiedFiles > 0 && pCmdLine.state == OptsCmdLineState_1))
|
||||
pCmdLine.state = OptsCmdLineState_3;
|
||||
|
||||
if (!setStage) {
|
||||
pCmdLine.stages = CmdLineStageMask_Cg;
|
||||
if (pCmdLine.state == OptsCmdLineState_2)
|
||||
pCmdLine.toDisk |= 2;
|
||||
}
|
||||
|
||||
if (pCmdLine.state == OptsCmdLineState_3 && !(pCmdLine.stages & CmdLineStageMask_Cg))
|
||||
pCmdLine.state = OptsCmdLineState_2;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ToolReportMessage(SInt16 errid, SInt16 type, va_list va) {
|
||||
char str[256];
|
||||
char buf[1024];
|
||||
|
||||
GetIndString((StringPtr) str, 13000, errid);
|
||||
p2cstr((StringPtr) str);
|
||||
vsprintf(buf, str, va);
|
||||
CWReportMessage(parseopts.context, 0, buf, 0, type, 0);
|
||||
}
|
||||
|
||||
void ToolReportWarning(SInt16 id, ...) {
|
||||
va_list va;
|
||||
va_start(va, id);
|
||||
ToolReportMessage(id, messagetypeWarning, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
void ToolReportError(SInt16 id, ...) {
|
||||
va_list va;
|
||||
va_start(va, id);
|
||||
ToolReportMessage(id, messagetypeError, va);
|
||||
va_end(va);
|
||||
parseopts.hadErrors = 1;
|
||||
}
|
||||
|
||||
void ToolReportOSError(SInt16 id, int err, ...) {
|
||||
char str[256];
|
||||
char buf[1024];
|
||||
va_list va;
|
||||
|
||||
GetIndString((StringPtr) str, 13000, id);
|
||||
p2cstr((StringPtr) str);
|
||||
va_start(va, err);
|
||||
vsprintf(buf, str, va);
|
||||
va_end(va);
|
||||
CWAlert(parseopts.context, buf, OS_GetErrText(err), 0, 0);
|
||||
}
|
||||
|
||||
void ToolReportInfo(SInt16 id, ...) {
|
||||
va_list va;
|
||||
va_start(va, id);
|
||||
ToolReportMessage(id, messagetypeInfo, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
int Opt_DoNotLink(const char *opt, void *var, const char *arg) {
|
||||
if (pCmdLine.state == OptsCmdLineState_3 || pCmdLine.state == OptsCmdLineState_0 || pCmdLine.state == OptsCmdLineState_1)
|
||||
pCmdLine.state = OptsCmdLineState_2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Opt_IncreaseVerbosity(const char *opt, void *var, const char *arg) {
|
||||
if (pCmdLine.verbose)
|
||||
pCmdLine.verbose++;
|
||||
else
|
||||
pCmdLine.verbose = 2;
|
||||
|
||||
Parser_StorePanels(parseopts.context);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Opt_SetStage(const char *opt, void *str, const char *arg, int flags) {
|
||||
unsigned char *ptr;
|
||||
Boolean set;
|
||||
Boolean no;
|
||||
UInt16 flag;
|
||||
|
||||
ptr = (unsigned char *) str;
|
||||
// doesn't match - type issue with 'no'
|
||||
no = (Boolean) ((flags & PARAMPARSEFLAGS_8) >> 3);
|
||||
set = (Boolean) (no ^ 1);
|
||||
|
||||
while (*ptr) {
|
||||
if (*ptr == '+') {
|
||||
set = !no;
|
||||
} else if (*ptr == '-') {
|
||||
set = no;
|
||||
} else if (*ptr == '|') {
|
||||
set = (Boolean) (no ^ 1);
|
||||
} else {
|
||||
flag = (ptr[0] << 8) | ptr[1];
|
||||
setStage = 1;
|
||||
|
||||
switch (flag) {
|
||||
case 'Cg':
|
||||
if (set)
|
||||
pCmdLine.stages |= CmdLineStageMask_Cg;
|
||||
else
|
||||
pCmdLine.stages &= ~CmdLineStageMask_Cg;
|
||||
lastStage = CmdLineStage_Cg;
|
||||
break;
|
||||
case 'Ds':
|
||||
if (set)
|
||||
pCmdLine.stages |= CmdLineStageMask_Ds;
|
||||
else
|
||||
pCmdLine.stages &= ~CmdLineStageMask_Ds;
|
||||
lastStage = CmdLineStage_Ds;
|
||||
break;
|
||||
case 'Pp':
|
||||
if (set)
|
||||
pCmdLine.stages |= CmdLineStageMask_Pp;
|
||||
else
|
||||
pCmdLine.stages &= ~CmdLineStageMask_Pp;
|
||||
lastStage = CmdLineStage_Pp;
|
||||
break;
|
||||
case 'Dp':
|
||||
if (set)
|
||||
pCmdLine.stages |= CmdLineStageMask_Dp;
|
||||
else
|
||||
pCmdLine.stages &= ~CmdLineStageMask_Dp;
|
||||
break;
|
||||
default:
|
||||
CLPFatalError("Bad stage settings in %s (%c%c)\n", str, ptr[0], ptr[1]);
|
||||
}
|
||||
|
||||
++ptr;
|
||||
}
|
||||
|
||||
++ptr;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Opt_RedirectStream(const char *opt, void *file, const char *filename) {
|
||||
OSSpec spec;
|
||||
int err;
|
||||
FILE *nw;
|
||||
|
||||
err = OS_MakeFileSpec(filename, &spec);
|
||||
if (err) {
|
||||
CLPReportError(78, filename, OS_GetErrText(err));
|
||||
return 0;
|
||||
}
|
||||
|
||||
nw = freopen(OS_SpecToString(&spec, STSbuf, 256), "wt", (FILE *) file);
|
||||
if (!nw) {
|
||||
CLPReportError(78, filename, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
|
@ -0,0 +1,513 @@
|
|||
#include "plugin_internal.h"
|
||||
|
||||
// Forward declarations
|
||||
CWResult OSErrtoCWResult(OSErr err);
|
||||
|
||||
static Boolean ValidateContext(CWPluginContext context) {
|
||||
return context
|
||||
&& (context->shellSignature == CWFOURCHAR('C','W','I','E'))
|
||||
&& (context->request != reqInitialize)
|
||||
&& (context->request != reqTerminate)
|
||||
&& (context->request != reqIdle);
|
||||
}
|
||||
|
||||
static Boolean ValidateInitTermContext(CWPluginContext context) {
|
||||
return context
|
||||
&& (context->shellSignature == CWFOURCHAR('C','W','I','E'))
|
||||
&& ((context->request == reqInitialize)
|
||||
|| (context->request == reqTerminate)
|
||||
|| (context->request == reqIdle));
|
||||
}
|
||||
|
||||
static Boolean IsVCSContext(CWPluginContext context) {
|
||||
return context && (context->pluginType == CWDROPINVCSTYPE);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetPluginRequest(CWPluginContext context, SInt32 *request) {
|
||||
if (!ValidateContext(context) && !ValidateInitTermContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (request == NULL)
|
||||
return cwErrInvalidParameter;
|
||||
|
||||
*request = context->request;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetAPIVersion(CWPluginContext context, SInt32 *version) {
|
||||
if (!ValidateContext(context) && !ValidateInitTermContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (version == NULL)
|
||||
return cwErrInvalidParameter;
|
||||
|
||||
*version = context->apiVersion;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetIDEInfo(CWPluginContext context, CWIDEInfo *info) {
|
||||
if (!ValidateContext(context) && !ValidateInitTermContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (info == NULL)
|
||||
return cwErrInvalidParameter;
|
||||
|
||||
*info = *context->shellInfo;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetCallbackOSError(CWPluginContext context, CWOSResult *error) {
|
||||
if (!ValidateContext(context) && !ValidateInitTermContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (error == NULL)
|
||||
return cwErrInvalidParameter;
|
||||
|
||||
*error = context->callbackOSError;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWSetPluginOSError(CWPluginContext context, CWOSResult error) {
|
||||
if (!ValidateContext(context) && !ValidateInitTermContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
|
||||
context->pluginOSError = error;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetProjectFile(CWPluginContext context, CWFileSpec *projectSpec) {
|
||||
if (IsVCSContext(context) || !ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (projectSpec == NULL)
|
||||
return cwErrInvalidParameter;
|
||||
|
||||
*projectSpec = context->projectFile;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetTargetDataDirectory(CWPluginContext context, CWFileSpec *targetDataDirectorySpec) {
|
||||
if (IsVCSContext(context) || !ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (targetDataDirectorySpec == NULL)
|
||||
return cwErrInvalidParameter;
|
||||
if (context->targetDataDirectorySpec == NULL)
|
||||
return cwErrInvalidCallback;
|
||||
|
||||
*targetDataDirectorySpec = *context->targetDataDirectorySpec;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetTargetName(CWPluginContext context, char *name, short maxLength) {
|
||||
if (IsVCSContext(context) || !ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
|
||||
if (context->apiVersion >= 8)
|
||||
return context->callbacks->cbGetTargetName(context, name, maxLength);
|
||||
else
|
||||
return cwErrRequestFailed;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetProjectFileCount(CWPluginContext context, SInt32 *count) {
|
||||
if (IsVCSContext(context) || !ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (count == NULL)
|
||||
return cwErrInvalidParameter;
|
||||
|
||||
*count = context->numFiles;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetOutputFileDirectory(CWPluginContext context, CWFileSpec *outputFileDirectory) {
|
||||
if (IsVCSContext(context) || !ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (outputFileDirectory == NULL)
|
||||
return cwErrInvalidParameter;
|
||||
|
||||
*outputFileDirectory = context->outputFileDirectory;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetOverlay1GroupsCount(CWPluginContext context, SInt32 *count) {
|
||||
if (IsVCSContext(context) || !ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (count == NULL)
|
||||
return cwErrInvalidParameter;
|
||||
|
||||
*count = context->numOverlayGroups;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetFileInfo(CWPluginContext context, SInt32 whichfile, Boolean checkFileLocation, CWProjectFileInfo *fileinfo) {
|
||||
if (IsVCSContext(context) || !ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (fileinfo == NULL)
|
||||
return cwErrInvalidParameter;
|
||||
|
||||
return context->callbacks->cbGetFileInfo(context, whichfile, checkFileLocation, fileinfo);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWFindAndLoadFile(CWPluginContext context, const char *filename, CWFileInfo *fileinfo) {
|
||||
if (IsVCSContext(context) || !ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (filename == NULL)
|
||||
return cwErrInvalidParameter;
|
||||
if (fileinfo == NULL)
|
||||
return cwErrInvalidParameter;
|
||||
|
||||
return context->callbacks->cbFindAndLoadFile(context, filename, fileinfo);
|
||||
}
|
||||
|
||||
static CWResult EnsureCachedAccessPaths(CWPluginContext context) {
|
||||
if (!context->accessPathList) {
|
||||
CWResult res = context->callbacks->cbCacheAccessPathList(context);
|
||||
if (res)
|
||||
return res;
|
||||
if (!context->accessPathList)
|
||||
return cwErrRequestFailed;
|
||||
}
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetAccessPathListInfo(CWPluginContext context, CWAccessPathListInfo *pathListInfo) {
|
||||
if (!ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (pathListInfo == NULL)
|
||||
return cwErrInvalidParameter;
|
||||
if (context->apiVersion < 10)
|
||||
return cwErrInvalidCallback;
|
||||
CWResult res = EnsureCachedAccessPaths(context);
|
||||
if (res)
|
||||
return res;
|
||||
pathListInfo->systemPathCount = context->accessPathList->systemPathCount;
|
||||
pathListInfo->userPathCount = context->accessPathList->userPathCount;
|
||||
pathListInfo->alwaysSearchUserPaths = context->accessPathList->alwaysSearchUserPaths;
|
||||
pathListInfo->convertPaths = context->accessPathList->convertPaths;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetAccessPathInfo(CWPluginContext context, CWAccessPathType pathType, SInt32 whichPath, CWAccessPathInfo *pathInfo) {
|
||||
if (!ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (pathInfo == NULL)
|
||||
return cwErrInvalidParameter;
|
||||
if (context->apiVersion < 10)
|
||||
return cwErrInvalidCallback;
|
||||
CWResult res = EnsureCachedAccessPaths(context);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
IDEAccessPath *paths;
|
||||
SInt32 count;
|
||||
switch (pathType) {
|
||||
case cwSystemPath:
|
||||
paths = context->accessPathList->systemPaths;
|
||||
count = context->accessPathList->systemPathCount;
|
||||
break;
|
||||
case cwUserPath:
|
||||
paths = context->accessPathList->userPaths;
|
||||
count = context->accessPathList->userPathCount;
|
||||
break;
|
||||
default:
|
||||
return cwErrInvalidParameter;
|
||||
}
|
||||
|
||||
if (whichPath < 0 || whichPath >= count)
|
||||
return cwErrInvalidParameter;
|
||||
|
||||
IDEAccessPath *path = &paths[whichPath];
|
||||
pathInfo->pathSpec = path->pathSpec;
|
||||
pathInfo->recursive = path->recursive;
|
||||
pathInfo->subdirectoryCount = path->subdirectoryCount;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetAccessPathSubdirectory(CWPluginContext context, CWAccessPathType pathType, SInt32 whichPath,
|
||||
SInt32 whichSubdirectory, CWFileSpec *subdirectory) {
|
||||
if (!ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (subdirectory == NULL)
|
||||
return cwErrInvalidParameter;
|
||||
if (context->apiVersion < 10)
|
||||
return cwErrInvalidCallback;
|
||||
CWResult res = EnsureCachedAccessPaths(context);
|
||||
if (res)
|
||||
return res;
|
||||
|
||||
IDEAccessPath *paths;
|
||||
SInt32 count;
|
||||
switch (pathType) {
|
||||
case cwSystemPath:
|
||||
paths = context->accessPathList->systemPaths;
|
||||
count = context->accessPathList->systemPathCount;
|
||||
break;
|
||||
case cwUserPath:
|
||||
paths = context->accessPathList->userPaths;
|
||||
count = context->accessPathList->userPathCount;
|
||||
break;
|
||||
default:
|
||||
return cwErrInvalidParameter;
|
||||
}
|
||||
|
||||
if (whichPath < 0 || whichPath >= count)
|
||||
return cwErrInvalidParameter;
|
||||
|
||||
IDEAccessPath *path = &paths[whichPath];
|
||||
if (whichSubdirectory < 0 || whichSubdirectory >= path->subdirectoryCount)
|
||||
return cwErrInvalidParameter;
|
||||
|
||||
*subdirectory = path->subdirectories[whichSubdirectory];
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetFileText(CWPluginContext context, const CWFileSpec *filespec, const char **text, SInt32 *textLength,
|
||||
short *filedatatype) {
|
||||
if (!ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (!filespec)
|
||||
return cwErrInvalidParameter;
|
||||
if (!text)
|
||||
return cwErrInvalidParameter;
|
||||
if (!textLength)
|
||||
return cwErrInvalidParameter;
|
||||
if (!filedatatype)
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbGetFileText(context, filespec, text, textLength, filedatatype);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWReleaseFileText(CWPluginContext context, const char *text) {
|
||||
if (!ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
|
||||
if (text)
|
||||
return context->callbacks->cbReleaseFileText(context, text);
|
||||
else
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetSegmentInfo(CWPluginContext context, SInt32 whichsegment, CWProjectSegmentInfo *segmentinfo) {
|
||||
if (IsVCSContext(context) || !ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (!segmentinfo)
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbGetSegmentInfo(context, whichsegment, segmentinfo);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetOverlay1GroupInfo(CWPluginContext context, SInt32 whichgroup, CWOverlay1GroupInfo *groupinfo) {
|
||||
if (IsVCSContext(context) || !ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (!groupinfo)
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbGetOverlay1GroupInfo(context, whichgroup, groupinfo);
|
||||
}
|
||||
|
||||
CW_CALLBACK
|
||||
CWGetOverlay1Info(CWPluginContext context, SInt32 whichgroup, SInt32 whichoverlay, CWOverlay1Info *overlayinfo) {
|
||||
if (IsVCSContext(context) || !ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (!overlayinfo)
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbGetOverlay1Info(context, whichgroup, whichoverlay, overlayinfo);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetOverlay1FileInfo(CWPluginContext context, SInt32 whichgroup, SInt32 whichoverlay, SInt32 whichoverlayfile,
|
||||
CWOverlay1FileInfo *fileinfo) {
|
||||
if (IsVCSContext(context) || !ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (!fileinfo)
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbGetOverlay1FileInfo(context, whichgroup, whichoverlay, whichoverlayfile, fileinfo);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWReportMessage(CWPluginContext context, const CWMessageRef *msgRef, const char *line1, const char *line2,
|
||||
short errorlevel, SInt32 errorNumber) {
|
||||
if (!ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbReportMessage(context, msgRef, line1, line2, errorlevel, errorNumber);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWAlert(CWPluginContext context, const char *msg1, const char *msg2, const char *msg3, const char *msg4) {
|
||||
if (!ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbAlert(context, msg1, msg2, msg3, msg4);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWShowStatus(CWPluginContext context, const char *line1, const char *line2) {
|
||||
if (!ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbShowStatus(context, line1, line2);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWUserBreak(CWPluginContext context) {
|
||||
if (!ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbUserBreak(context);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetNamedPreferences(CWPluginContext context, const char *prefsname, CWMemHandle *prefsdata) {
|
||||
if (!ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (!prefsname)
|
||||
return cwErrInvalidParameter;
|
||||
if (!prefsdata)
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbGetNamedPreferences(context, prefsname, prefsdata);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWStorePluginData(CWPluginContext context, SInt32 whichfile, CWDataType type, CWMemHandle prefsdata) {
|
||||
if (!ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbStorePluginData(context, whichfile, type, prefsdata);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetPluginData(CWPluginContext context, SInt32 whichfile, CWDataType type, CWMemHandle *prefsdata) {
|
||||
if (!ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbGetPluginData(context, whichfile, type, prefsdata);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWSetModDate(CWPluginContext context, const CWFileSpec *filespec, CWFileTime *moddate, Boolean isGenerated) {
|
||||
if (IsVCSContext(context) || !ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (!filespec)
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbSetModDate(context, filespec, moddate, isGenerated);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWAddProjectEntry(CWPluginContext context, const CWFileSpec *fileSpec, Boolean isGenerated,
|
||||
const CWNewProjectEntryInfo *projectEntryInfo, SInt32 *whichfile) {
|
||||
if (IsVCSContext(context) || !ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (!fileSpec)
|
||||
return cwErrInvalidParameter;
|
||||
if (context->apiVersion < 8)
|
||||
return cwErrRequestFailed;
|
||||
return context->callbacks->cbAddProjectEntry(context, fileSpec, isGenerated, projectEntryInfo, whichfile);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWCreateNewTextDocument(CWPluginContext context, const CWNewTextDocumentInfo *docinfo) {
|
||||
if (!ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (!docinfo)
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbCreateNewTextDocument(context, docinfo);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWAllocateMemory(CWPluginContext context, SInt32 size, Boolean isPermanent, void **ptr) {
|
||||
if (!ValidateContext(context) && !ValidateInitTermContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (!ptr)
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbAllocateMemory(context, size, isPermanent, ptr);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWFreeMemory(CWPluginContext context, void *ptr, Boolean isPermanent) {
|
||||
if (!ValidateContext(context) && !ValidateInitTermContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (!ptr)
|
||||
return cwNoErr;
|
||||
return context->callbacks->cbFreeMemory(context, ptr, isPermanent);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWAllocMemHandle(CWPluginContext context, SInt32 size, Boolean useTempMemory, CWMemHandle *handle) {
|
||||
if (!ValidateContext(context) && !ValidateInitTermContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (!handle)
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbAllocMemHandle(context, size, useTempMemory, handle);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWFreeMemHandle(CWPluginContext context, CWMemHandle handle) {
|
||||
if (!ValidateContext(context) && !ValidateInitTermContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbFreeMemHandle(context, handle);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetMemHandleSize(CWPluginContext context, CWMemHandle handle, SInt32 *size) {
|
||||
if (!ValidateContext(context) && !ValidateInitTermContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (!size)
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbGetMemHandleSize(context, handle, size);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWResizeMemHandle(CWPluginContext context, CWMemHandle handle, SInt32 newSize) {
|
||||
if (!ValidateContext(context) && !ValidateInitTermContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbResizeMemHandle(context, handle, newSize);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWLockMemHandle(CWPluginContext context, CWMemHandle handle, Boolean moveHi, void **ptr) {
|
||||
if (!ValidateContext(context) && !ValidateInitTermContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (!ptr)
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbLockMemHandle(context, handle, moveHi, ptr);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWUnlockMemHandle(CWPluginContext context, CWMemHandle handle) {
|
||||
if (!ValidateContext(context) && !ValidateInitTermContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbUnlockMemHandle(context, handle);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWDonePluginRequest(CWPluginContext, CWResult resultCode) {
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWPreDialog(CWPluginContext context) {
|
||||
if (!ValidateContext(context) && !ValidateInitTermContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbPreDialog(context);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWPostDialog(CWPluginContext context) {
|
||||
if (!ValidateContext(context) && !ValidateInitTermContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbPostDialog(context);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWPreFileAction(CWPluginContext context, const CWFileSpec *theFile) {
|
||||
if (!ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbPreFileAction(context, theFile);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWPostFileAction(CWPluginContext context, const CWFileSpec *theFile) {
|
||||
if (!ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbPostFileAction(context, theFile);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWCheckoutLicense(CWPluginContext context, const char *a, const char *b, SInt32 c, void *d, SInt32 *cookiePtr) {
|
||||
if (!ValidateContext(context) && !ValidateInitTermContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbCheckoutLicense(context, a, b, c, d, cookiePtr);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWCheckinLicense(CWPluginContext context, SInt32 cookie) {
|
||||
if (!ValidateContext(context) && !ValidateInitTermContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbCheckinLicense(context, cookie);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWResolveRelativePath(CWPluginContext context, const CWRelativePath *relativePath, CWFileSpec *fileSpec, Boolean create) {
|
||||
if (!ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
if (relativePath == NULL)
|
||||
return cwErrInvalidParameter;
|
||||
if (fileSpec == NULL)
|
||||
return cwErrInvalidParameter;
|
||||
return context->callbacks->cbResolveRelativePath(context, relativePath, fileSpec, create);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWMacOSErrToCWResult(CWPluginContext context, OSErr err) {
|
||||
return OSErrtoCWResult(err);
|
||||
}
|
||||
|
||||
CWResult OSErrtoCWResult(OSErr err) {
|
||||
switch (err) {
|
||||
case noErr: return cwNoErr;
|
||||
case userCanceledErr: return cwErrUserCanceled;
|
||||
case paramErr: return cwErrInvalidParameter;
|
||||
case memFullErr: return cwErrOutOfMemory;
|
||||
case fnfErr: return cwErrFileNotFound;
|
||||
default: return cwErrRequestFailed;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,501 @@
|
|||
#include "plugin_internal.h"
|
||||
|
||||
static CWCompilerLinkerContext *GetContext(CWPluginContext context) {
|
||||
if (context && (context->pluginType == CWDROPINCOMPILERTYPE || context->pluginType == CWDROPINLINKERTYPE))
|
||||
return static_cast<CWCompilerLinkerContext *>(context);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWIsPrecompiling(CWPluginContext context, Boolean* isPrecompiling) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!isPrecompiling)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
*isPrecompiling = cl->precompile;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWIsAutoPrecompiling(CWPluginContext context, Boolean* isAutoPrecompiling) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!isAutoPrecompiling)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
*isAutoPrecompiling = cl->autoprecompile;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWIsPreprocessing(CWPluginContext context, Boolean* isPreprocessing) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!isPreprocessing)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
*isPreprocessing = cl->preprocess;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWIsGeneratingDebugInfo(CWPluginContext context, Boolean* isGenerating) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!isGenerating)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
*isGenerating = cl->debuginfo;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWIsCachingPrecompiledHeaders(CWPluginContext context, Boolean* isCaching) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!isCaching)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
*isCaching = cl->cachingPCH;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetBrowseOptions(CWPluginContext context, CWBrowseOptions* browseOptions) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!browseOptions)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
*browseOptions = cl->browseoptions;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetBuildSequenceNumber(CWPluginContext context, SInt32* sequenceNumber) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!sequenceNumber)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
*sequenceNumber = cl->sequenceID;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetTargetInfo(CWPluginContext context, CWTargetInfo* targetInfo) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!targetInfo)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
if (cl->apiVersion >= 10) {
|
||||
*targetInfo = *cl->targetinfo;
|
||||
} else if (cl->apiVersion >= 8) {
|
||||
CWTargetInfo *ti = cl->targetinfo;
|
||||
targetInfo->outputType = ti->outputType;
|
||||
targetInfo->outfile = ti->outfile;
|
||||
targetInfo->symfile = ti->symfile;
|
||||
targetInfo->runfile = ti->runfile;
|
||||
targetInfo->linkType = ti->linkType;
|
||||
targetInfo->canRun = ti->canRun;
|
||||
targetInfo->canDebug = ti->canDebug;
|
||||
targetInfo->targetCPU = ti->targetCPU;
|
||||
targetInfo->targetOS = ti->targetOS;
|
||||
#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS
|
||||
targetInfo->outfileCreator = ti->outfileCreator;
|
||||
targetInfo->outfileType = ti->outfileType;
|
||||
targetInfo->debuggerCreator = ti->debuggerCreator;
|
||||
targetInfo->runHelperCreator = ti->runHelperCreator;
|
||||
#endif
|
||||
} else {
|
||||
memset(targetInfo, 0, sizeof(CWTargetInfo));
|
||||
if (CWFileSpecNotEmpty(&cl->targetinfo_V7.outfile))
|
||||
targetInfo->outputType = linkOutputFile;
|
||||
else
|
||||
targetInfo->outputType = linkOutputNone;
|
||||
targetInfo->outfile = cl->targetinfo_V7.outfile;
|
||||
targetInfo->symfile = cl->targetinfo_V7.symfile;
|
||||
targetInfo->runfile = cl->targetinfo_V7.outfile;
|
||||
targetInfo->linkType = cl->targetinfo_V7.linkType;
|
||||
targetInfo->canRun = cl->targetinfo_V7.canRun;
|
||||
targetInfo->canDebug = cl->targetinfo_V7.canDebug;
|
||||
#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS
|
||||
targetInfo->debuggerCreator = cl->targetinfo_V7.debuggerCreator;
|
||||
targetInfo->runHelperCreator = cl->targetinfo_V7.runHelperCreator;
|
||||
#endif
|
||||
}
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWSetTargetInfo(CWPluginContext context, CWTargetInfo* targetInfo) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!targetInfo)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
if (cl->apiVersion >= 10) {
|
||||
*cl->targetinfo = *targetInfo;
|
||||
} else if (cl->apiVersion >= 8) {
|
||||
CWTargetInfo *ti = cl->targetinfo;
|
||||
ti->outputType = targetInfo->outputType;
|
||||
ti->outfile = targetInfo->outfile;
|
||||
ti->symfile = targetInfo->symfile;
|
||||
ti->runfile = targetInfo->runfile;
|
||||
ti->linkType = targetInfo->linkType;
|
||||
ti->canRun = targetInfo->canRun;
|
||||
ti->canDebug = targetInfo->canDebug;
|
||||
ti->targetCPU = targetInfo->targetCPU;
|
||||
ti->targetOS = targetInfo->targetOS;
|
||||
#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS
|
||||
ti->outfileCreator = targetInfo->outfileCreator;
|
||||
ti->outfileType = targetInfo->outfileType;
|
||||
ti->debuggerCreator = targetInfo->debuggerCreator;
|
||||
ti->runHelperCreator = targetInfo->runHelperCreator;
|
||||
#endif
|
||||
} else {
|
||||
cl->targetinfo_V7.outfile = targetInfo->outfile;
|
||||
cl->targetinfo_V7.symfile = targetInfo->symfile;
|
||||
cl->targetinfo_V7.linkType = targetInfo->linkType;
|
||||
cl->targetinfo_V7.canRun = targetInfo->canRun;
|
||||
cl->targetinfo_V7.canDebug = targetInfo->canDebug;
|
||||
#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS
|
||||
cl->targetinfo_V7.useRunHelperApp = targetInfo->runHelperCreator != 0;
|
||||
cl->targetinfo_V7.debuggerCreator = targetInfo->debuggerCreator;
|
||||
cl->targetinfo_V7.runHelperCreator = targetInfo->runHelperCreator;
|
||||
#endif
|
||||
}
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetMainFileNumber(CWPluginContext context, SInt32* fileNumber) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!fileNumber)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
*fileNumber = cl->whichfile;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetMainFileID(CWPluginContext context, short* fileID) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!fileID)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
*fileID = cl->fileID;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetMainFileSpec(CWPluginContext context, CWFileSpec* fileSpec) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!fileSpec)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
*fileSpec = cl->sourcefile;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetMainFileText(CWPluginContext context, const char** text, SInt32* textLength) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!text)
|
||||
return cwErrInvalidParameter;
|
||||
if (!textLength)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
*text = cl->sourcetext;
|
||||
*textLength = cl->sourcetextsize;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWLoadObjectData(CWPluginContext context, SInt32 whichfile, CWMemHandle* objectdata) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
return cl->callbacks->cbLoadObjectData(cl, whichfile, objectdata);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWStoreObjectData(CWPluginContext context, SInt32 whichfile, CWObjectData* object) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!object)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
return cl->callbacks->cbStoreObjectData(cl, whichfile, object);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWFreeObjectData(CWPluginContext context, SInt32 whichfile, CWMemHandle objectdata) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
return cl->callbacks->cbFreeObjectData(cl, whichfile, objectdata);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetSuggestedObjectFileSpec(CWPluginContext context, SInt32 whichfile, CWFileSpec* fileSpec) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!fileSpec)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
if (context->apiVersion < 10)
|
||||
return cwErrInvalidCallback;
|
||||
return cl->callbacks->cbGetSuggestedObjectFileSpec(cl, whichfile, fileSpec);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetStoredObjectFileSpec(CWPluginContext context, SInt32 whichfile, CWFileSpec* fileSpec) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!fileSpec)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
if (context->apiVersion < 10)
|
||||
return cwErrInvalidCallback;
|
||||
return cl->callbacks->cbGetStoredObjectFileSpec(cl, whichfile, fileSpec);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWDisplayLines(CWPluginContext context, SInt32 nlines) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
return cl->callbacks->cbDisplayLines(cl, nlines);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetResourceFile(CWPluginContext context, CWFileSpec* filespec) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!filespec)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
return cl->callbacks->cbGetResourceFile(cl, filespec);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWPutResourceFile(CWPluginContext context, const char* prompt, const char* name, CWFileSpec* filespec) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!prompt)
|
||||
return cwErrInvalidParameter;
|
||||
if (!name)
|
||||
return cwErrInvalidParameter;
|
||||
if (!filespec)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
return cl->callbacks->cbPutResourceFile(cl, prompt, name, filespec);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWCachePrecompiledHeader(CWPluginContext context, const CWFileSpec* filespec, CWMemHandle pchhandle) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!filespec)
|
||||
return cwErrInvalidParameter;
|
||||
if (!pchhandle)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
return cl->callbacks->cbCachePrecompiledHeader(cl, filespec, pchhandle);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetPrecompiledHeaderSpec(CWPluginContext context, CWFileSpec *pchspec, const char *target) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!pchspec)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
return cl->callbacks->cbGetPrecompiledHeaderSpec(cl, pchspec, target);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWBeginSubCompile(CWPluginContext context, SInt32 whichfile, CWPluginContext* subContext) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
return cl->callbacks->cbBeginSubCompile(cl, whichfile, subContext);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWEndSubCompile(CWPluginContext subContext) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!(cl = GetContext(subContext)))
|
||||
return cwErrInvalidCallback;
|
||||
return cl->callbacks->cbEndSubCompile(subContext);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWLookUpUnit(CWPluginContext context, const char* name, Boolean isdependency, const void** unitdata, SInt32* unitdatalength) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!name)
|
||||
return cwErrInvalidParameter;
|
||||
if (!unitdata)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
return cl->callbacks->cbLookUpUnit(cl, name, isdependency, unitdata, unitdatalength);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWSBMfiles(CWPluginContext context, short libref) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
return cl->callbacks->cbSBMfiles(cl, libref);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWStoreUnit(CWPluginContext context, const char* unitname, CWMemHandle unitdata, CWDependencyTag dependencytag) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!unitname)
|
||||
return cwErrInvalidParameter;
|
||||
if (!unitdata)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
return cl->callbacks->cbStoreUnit(cl, unitname, unitdata, dependencytag);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWReleaseUnit(CWPluginContext context, void* unitdata) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
return cl->callbacks->cbReleaseUnit(cl, unitdata);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWUnitNameToFileName(CWPluginContext context, const char* unitname, char* filename) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!unitname)
|
||||
return cwErrInvalidParameter;
|
||||
if (!filename)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
return cl->callbacks->cbUnitNameToFileName(cl, unitname, filename);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetTargetStorage(CWPluginContext context, void** storage) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!storage)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
if (cl->apiVersion >= 8) {
|
||||
*storage = cl->targetStorage;
|
||||
return cwNoErr;
|
||||
} else {
|
||||
return cwErrRequestFailed;
|
||||
}
|
||||
}
|
||||
|
||||
CW_CALLBACK CWSetTargetStorage(CWPluginContext context, void* storage) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!storage)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
if (cl->apiVersion >= 8) {
|
||||
cl->targetStorage = storage;
|
||||
return cwNoErr;
|
||||
} else {
|
||||
return cwErrRequestFailed;
|
||||
}
|
||||
}
|
||||
|
||||
CW_CALLBACK CWOSErrorMessage(CWPluginContext context, const char *msg, OSErr errorcode) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
return cl->callbacks->cbOSErrorMessage(cl, msg, errorcode);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWOSAlert(CWPluginContext context, const char* message, OSErr errorcode) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!message)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
return cl->callbacks->cbOSAlert(cl, message, errorcode);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetModifiedFiles(CWPluginContext context, SInt32* modifiedFileCount, const SInt32** modifiedFiles) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!modifiedFileCount)
|
||||
return cwErrInvalidParameter;
|
||||
if (!modifiedFiles)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
if (context->apiVersion < 9)
|
||||
return cwErrInvalidCallback;
|
||||
return cl->callbacks->cbGetModifiedFiles(cl, modifiedFileCount, modifiedFiles);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetCommandLineArgs(CWPluginContext context, const char** commandLineArgs) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!commandLineArgs)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
if (cl->apiVersion < 11)
|
||||
return cwErrInvalidCallback;
|
||||
if (!cl->commandLineArgs && cl->callbacks->cbGetRuntimeSettings(cl))
|
||||
return cwErrRequestFailed;
|
||||
*commandLineArgs = cl->commandLineArgs;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetWorkingDirectory(CWPluginContext context, CWFileSpec* workingDirectorySpec) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!workingDirectorySpec)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
if (cl->apiVersion < 11)
|
||||
return cwErrInvalidCallback;
|
||||
if (!cl->commandLineArgs && cl->callbacks->cbGetRuntimeSettings(cl))
|
||||
return cwErrRequestFailed;
|
||||
*workingDirectorySpec = *cl->workingDirectorySpec;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetEnvironmentVariableCount(CWPluginContext context, SInt32* count) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!count)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
if (cl->apiVersion < 11)
|
||||
return cwErrInvalidCallback;
|
||||
if (!cl->commandLineArgs && cl->callbacks->cbGetRuntimeSettings(cl))
|
||||
return cwErrRequestFailed;
|
||||
*count = cl->numEnvironmentVariables;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetEnvironmentVariable(CWPluginContext context, SInt32 index, const char** name, const char** value) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!name)
|
||||
return cwErrInvalidParameter;
|
||||
if (!value)
|
||||
return cwErrInvalidParameter;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
if (cl->apiVersion < 11)
|
||||
return cwErrInvalidCallback;
|
||||
if (!cl->commandLineArgs && cl->callbacks->cbGetRuntimeSettings(cl))
|
||||
return cwErrRequestFailed;
|
||||
if (index < 0 || index >= cl->numEnvironmentVariables)
|
||||
return cwErrInvalidParameter;
|
||||
*name = cl->environmentVariables[index].name;
|
||||
*value = cl->environmentVariables[index].value;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetFrameworkCount(CWPluginContext context, SInt32* frameworkCount) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
if (cl->apiVersion < 11)
|
||||
return cwErrInvalidCallback;
|
||||
if (!cl->commandLineArgs && cl->callbacks->cbGetFrameworkCount(cl, frameworkCount))
|
||||
return cwErrRequestFailed;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
CW_CALLBACK CWGetFrameworkInfo(CWPluginContext context, SInt32 whichFramework, CWFrameworkInfo* frameworkInfo) {
|
||||
CWCompilerLinkerContext *cl;
|
||||
if (!(cl = GetContext(context)))
|
||||
return cwErrInvalidCallback;
|
||||
if (cl->apiVersion < 11)
|
||||
return cwErrInvalidCallback;
|
||||
if (!cl->commandLineArgs && cl->callbacks->cbGetFrameworkInfo(cl, whichFramework, frameworkInfo))
|
||||
return cwErrRequestFailed;
|
||||
return cwNoErr;
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
#include "plugin_internal.h"
|
||||
|
||||
static Boolean ValidateContext(CWPluginContext context) {
|
||||
return context && (context->shellSignature == CWFOURCHAR('C','W','I','E'));
|
||||
}
|
||||
|
||||
typedef CWResult (*cbSecretAttachHandleType)(CWPluginContext, Handle, CWMemHandle *);
|
||||
typedef CWResult (*cbSecretDetachHandleType)(CWPluginContext, CWMemHandle, Handle *);
|
||||
typedef CWResult (*cbSecretPeekHandleType)(CWPluginContext, CWMemHandle, Handle *);
|
||||
typedef CWResult (*cbSecretGetNamedPreferencesType)(CWPluginContext, const char *, Handle *);
|
||||
|
||||
CW_CALLBACK CWSecretAttachHandle(CWPluginContext context, Handle handle, CWMemHandle *memHandle) {
|
||||
if (!ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
return ((cbSecretAttachHandleType) context->callbacks->cbInternal[0])(context, handle, memHandle);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWSecretDetachHandle(CWPluginContext context, CWMemHandle memHandle, Handle *handle) {
|
||||
if (!ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
return ((cbSecretDetachHandleType) context->callbacks->cbInternal[1])(context, memHandle, handle);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWSecretPeekHandle(CWPluginContext context, CWMemHandle memHandle, Handle *handle) {
|
||||
if (!ValidateContext(context))
|
||||
return cwErrInvalidParameter;
|
||||
return ((cbSecretPeekHandleType) context->callbacks->cbInternal[2])(context, memHandle, handle);
|
||||
}
|
||||
|
||||
CW_CALLBACK CWSecretGetNamedPreferences(CWPluginContext context, const char *prefsname, Handle *prefsdata) {
|
||||
if (!prefsdata)
|
||||
return cwErrInvalidParameter;
|
||||
|
||||
CWMemHandle memHandle;
|
||||
CWResult res = CWGetNamedPreferences(context, prefsname, &memHandle);
|
||||
if (!res)
|
||||
res = CWSecretDetachHandle(context, memHandle, prefsdata);
|
||||
return res;
|
||||
}
|
Loading…
Reference in New Issue