diff options
author | Ash Wolf <ninji@wuffs.org> | 2022-10-14 23:15:32 +0100 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2022-10-14 23:15:32 +0100 |
commit | 775b6861666af36d317fb577cf489e2c6377f878 (patch) | |
tree | 2ae8c829eb861c85a6e2b5acf42f51919a0d78f2 | |
parent | b8df05413a4e8b299de07b915cddce73a3bb16e3 (diff) | |
download | MWCC-775b6861666af36d317fb577cf489e2c6377f878.tar.gz MWCC-775b6861666af36d317fb577cf489e2c6377f878.zip |
add tons of stuff
32 files changed, 4014 insertions, 687 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d619b06..810b938 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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; diff --git a/Parameter.c b/Parameter.c index 9d6b08e..95bde45 100644 --- a/Parameter.c +++ b/Parameter.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) - char curparam[4096]; char *descparam = &curparam[0]; char *helpparam = &curparam[1024]; diff --git a/command_line/CmdLine/Src/CLMain.c b/command_line/CmdLine/Src/CLMain.c index 065ae5b..f8247c4 100644 --- a/command_line/CmdLine/Src/CLMain.c +++ b/command_line/CmdLine/Src/CLMain.c @@ -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, diff --git a/command_line/CmdLine/Src/MacEmul/Files.c b/command_line/CmdLine/Src/MacEmul/Files.c index 5246ee2..9a9cb60 100644 --- a/command_line/CmdLine/Src/MacEmul/Files.c +++ b/command_line/CmdLine/Src/MacEmul/Files.c @@ -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; diff --git a/command_line/CmdLine/Src/MacEmul/Resources.c b/command_line/CmdLine/Src/MacEmul/Resources.c index fcbed0b..796ed43 100644 --- a/command_line/CmdLine/Src/MacEmul/Resources.c +++ b/command_line/CmdLine/Src/MacEmul/Resources.c @@ -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, diff --git a/command_line/CmdLine/Src/OSLib/MacFileTypes.c b/command_line/CmdLine/Src/OSLib/MacFileTypes.c index 5c9cb1c..05a2ae9 100644 --- a/command_line/CmdLine/Src/OSLib/MacFileTypes.c +++ b/command_line/CmdLine/Src/OSLib/MacFileTypes.c @@ -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 *); diff --git a/command_line/CmdLine/Src/OSLib/MacSpecs.c b/command_line/CmdLine/Src/OSLib/MacSpecs.c index defcab1..ece3d96 100644 --- a/command_line/CmdLine/Src/OSLib/MacSpecs.c +++ b/command_line/CmdLine/Src/OSLib/MacSpecs.c @@ -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; diff --git a/command_line/CmdLine/Src/OSLib/StringUtils.c b/command_line/CmdLine/Src/OSLib/StringUtils.c index 4ede522..9d5d110 100644 --- a/command_line/CmdLine/Src/OSLib/StringUtils.c +++ b/command_line/CmdLine/Src/OSLib/StringUtils.c @@ -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) { diff --git a/includes/ParserErrors.r b/includes/ParserErrors.r new file mode 100644 index 0000000..8e6b14d --- /dev/null +++ b/includes/ParserErrors.r @@ -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 +}; diff --git a/includes/common.h b/includes/common.h index 6a0b12c..760be22 100644 --- a/includes/common.h +++ b/includes/common.h @@ -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 diff --git a/includes/mwcc_decomp.h b/includes/mwcc_decomp.h index 52f25c6..c5fa000 100644 --- a/includes/mwcc_decomp.h +++ b/includes/mwcc_decomp.h @@ -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; @@ -1565,43 +1151,6 @@ 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); extern int Opt_DummyLinkerSettingRoutine(const char *var, const char *val); @@ -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,73 +1180,14 @@ 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); extern void CLPReportWarning_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,33 +1211,23 @@ 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 } diff --git a/includes/option_system.h b/includes/option_system.h new file mode 100644 index 0000000..521213b --- /dev/null +++ b/includes/option_system.h @@ -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 diff --git a/includes/plugin.h b/includes/plugin.h new file mode 100644 index 0000000..76b17cc --- /dev/null +++ b/includes/plugin.h @@ -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 diff --git a/includes/plugin_internal.h b/includes/plugin_internal.h new file mode 100644 index 0000000..be84406 --- /dev/null +++ b/includes/plugin_internal.h @@ -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
\ No newline at end of file diff --git a/sdk_hdrs/CWPlugins.h b/sdk_hdrs/CWPlugins.h index b3dbd2a..ecd690b 100755 --- a/sdk_hdrs/CWPlugins.h +++ b/sdk_hdrs/CWPlugins.h @@ -1 +1 @@ -/*
* CWPlugins.h - Common declarations for Metrowerks CodeWarriorª plugins
*
* Copyright © 1995-1997 Metrowerks, Inc. All rights reserved.
*
*/
#ifndef __CWPlugins_H__
#define __CWPlugins_H__
#ifdef __MWERKS__
# pragma once
#endif
#define CWPLUGIN_HOST_MACOS 1
#define CWPLUGIN_HOST_WIN32 2
#define CWPLUGIN_HOST_SOLARIS 3
#define CWPLUGIN_HOST_LINUX 4
#ifndef CWPLUGIN_HOST
# ifdef WIN32
# define CWPLUGIN_HOST CWPLUGIN_HOST_WIN32
# elif defined(macintosh)
# define CWPLUGIN_HOST CWPLUGIN_HOST_MACOS
# elif defined(__sun__)
# define CWPLUGIN_HOST CWPLUGIN_HOST_SOLARIS
# elif defined(__linux__)
# define CWPLUGIN_HOST CWPLUGIN_HOST_LINUX
# else
# error
# endif
#endif
#define CWPLUGIN_API_MACOS 1
#define CWPLUGIN_API_WIN32 2
#define CWPLUGIN_API_UNIX 3
#ifndef CWPLUGIN_API
# ifdef WIN32
# define CWPLUGIN_API CWPLUGIN_API_WIN32
# elif defined(macintosh)
# define CWPLUGIN_API CWPLUGIN_API_MACOS
# elif defined(__sun__) || defined(__linux__)
# define CWPLUGIN_API CWPLUGIN_API_UNIX
# else
# error
# endif
#endif
/*
** Radix 256 notation where a 32-bit integer is created from four
** ASCII characters. A four-character constant of this form, say
** 'ABCD', must always be represented with the same pattern, 0x41424344
** in this case, regardless of big/little endian issues.
*/
typedef long CWFourCharType;
#define CWFOURCHAR(a, b, c, d) \
(((CWFourCharType) ((a) & 0xff) << 24) \
| ((CWFourCharType) ((b) & 0xff) << 16) \
| ((CWFourCharType) ((c) & 0xff) << 8) \
| ((CWFourCharType) ((d) & 0xff)))
#if CWPLUGIN_API == CWPLUGIN_API_UNIX
#include <sys/param.h>
#endif
#ifndef CW_USE_PRAGMA_EXPORT
#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS
#define CW_USE_PRAGMA_EXPORT 1
#else
#define CW_USE_PRAGMA_EXPORT 0
#endif
#endif
#ifndef CW_USE_PRAGMA_IMPORT
#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS
#define CW_USE_PRAGMA_IMPORT 1
#else
#define CW_USE_PRAGMA_IMPORT 0
#endif
#endif
#ifdef __MWERKS__
#pragma options align=mac68k
#endif
#ifdef _MSC_VER
#pragma pack(push,2)
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if CW_USE_PRAGMA_IMPORT
#pragma import on
#endif
/* These constants specify the action the IDE is asking the plugin to execute */
enum {
reqInitialize = -2, /* called when the plugin is loaded */
reqTerminate = -1, /* called when the plugin is unloaded */
reqIdle = -100, /* called periodically to allow for plugin tasks EP 6/24/98 */
reqAbout = -101, /* called to ask plugin to display about dialog EP 6/24/98 */
reqPrefsChange = -102 /* called when an associated pref panel changes EP 6/24/98 */
};
/* Used in CWFileInfo.dependencyType to indicate what type of make */
/* dependency to establish between files */
typedef enum CWDependencyType {
cwNoDependency, /* do not establish a dependency */
cwNormalDependency, /* recompile dependent whenever prereq changes */
cwInterfaceDependency /* recompile only if interface to file changes */
} CWDependencyType;
/* Used in CWFileInfo.filedatatype to indicate the type of data in a loaded file */
enum {
cwFileTypeUnknown, /* unknown binary data */
cwFileTypeText, /* normal text file */
cwFileTypePrecompiledHeader /* cached precompiled header */
};
/* constant for CWFileInfo.isdependentoffile */
#define kCurrentCompiledFile -1L
/* constant for CWStorePluginData/CWGetPluginData */
#define kTargetGlobalPluginData -1L
/* constant for CWNewProjectEntryInfo link order, segment, and overlay values */
#define kDefaultLinkPosition -1L
/* Selectors for CWFindLogicalDirectory */
enum {
kIDEDirectorySelector = 1, /* parent directory of IDE application; "bin" folder on Win32 */
kCodeWarriorDirectorySelector, /* root CodeWarrior directory */
kSystemDirectorySelector, /* system directory */
kProjectDirectorySelector, /* parent directory of current project */
kProjectDataDirectorySelector, /* project data directory */
kTargetDataDirectorySelector, /* target data directory (within project data directory) */
kTargetObjectCodeDirectorySelector, /* object code directory (within target data directory) */
kDebuggerCacheDirectorySelector, /* "CW Debugging Cache" directory */
kHelperAppsDirectorySelector, /* "(Helper Apps)" directory */
kPluginsDirectorySelector, /* "CodeWarrior Plugins" (Mac) or "plugins" (Win32) directory */
kPluginParentDirectorySelector, /* parent directory of current plugin */
kStationeryDirectorySelector, /* "(Project Stationery)" directory */
kRADStationeryDirectorySelector, /* "RAD Stationery" directory */
kLocalizedResourcesDirectorySelector /* "resources" directory */
};
/* CWPluginContext is a magic cookie passed to all plugins. It must */
/* be passed back to all IDE callbacks */
typedef struct CWPluginPrivateContext* CWPluginContext;
/* CWResult is the error/status result returned by all IDE API routine. */
/* The most common errors are returned directly. For OS-specific errors, the */
/* CWResult is cwErrOSError, and the OS-specific error can be obtained by */
/* calling CWGetOSError() */
typedef long CWResult;
/* CWMemHandle is an abstraction for memory used in some parts */
/* of the plugin API. API routines must be used to allocate */
/* and free CWMemHandles, or to convert them to pointers. */
typedef struct CWMemHandlePrivateStruct* CWMemHandle;
/* Used to identify custom data associated by a plugin with */
/* a project file or a target as a whole. Must be a four character */
/* constant. All lower case constants are reserved by the IDE */
typedef unsigned long CWDataType;
/* Some information used in the compiler/linker API is platform-dependent */
/* We use some typedefs to isolate the differences */
/* CWFileSpec contains the native platform file specifier. */
/* CWFileName contains the string type for a native file name */
/* CWFileTime contains the native platform file timestamp */
/* CWOSResult contains the native platform error return value */
/* CWResult contains an API routine error/status result */
/* CW_CALLBACK is a macro defining the calling convention and return type for */
/* IDE callback routines. */
/* CW_PLUGINENTRY is a macro defining the calling convention and return type for */
/* plugin entry points. */
/* CWSUCCESS is a macro that evaluates to true when given a CWResult indicating an */
/* routine succeeded */
#if CWPLUGIN_API == CWPLUGIN_API_MACOS
typedef FSSpec CWFileSpec;
typedef char CWFileName[32];
typedef unsigned long CWFileTime;
typedef OSErr CWOSResult;
#elif CWPLUGIN_API == CWPLUGIN_API_WIN32
typedef unsigned char Boolean;
typedef struct CWFileSpec { char path[MAX_PATH]; } CWFileSpec;
typedef char CWFileName[65];
typedef FILETIME CWFileTime;
typedef DWORD CWOSResult;
#elif CWPLUGIN_API == CWPLUGIN_API_UNIX
#define MAX_PATH MAXPATHLEN
#ifndef __MACTYPES__
typedef unsigned char Boolean;
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
typedef struct CWFileSpec { char path[MAX_PATH]; } CWFileSpec;
typedef char CWFileName[65];
typedef time_t CWFileTime;
typedef int CWOSResult;
#else
#error Unknown plugin API!
#endif
#define CWSUCCESS(result) ((result) == 0)
#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS
#define CW_CALLBACK pascal CWResult
#define CW_CALLBACK_PTR(function_name) pascal CWResult (function_name)
#define CWPLUGIN_ENTRY(function_name) pascal short (function_name)
#elif CWPLUGIN_HOST == CWPLUGIN_HOST_WIN32
#define CW_CALLBACK CWResult __stdcall
#define CW_CALLBACK_PTR(function_name) CWResult (__stdcall function_name)
#define CWPLUGIN_ENTRY(function_name) short (__stdcall function_name)
#elif CWPLUGIN_HOST==CWPLUGIN_HOST_SOLARIS || CWPLUGIN_HOST==CWPLUGIN_HOST_LINUX
#define CW_CALLBACK CWResult
#define CW_CALLBACK_PTR(function_name) CWResult (function_name)
#define CWPLUGIN_ENTRY(function_name) short (function_name)
#else
#error Unknown plugin host!
#endif
/* information returned by CWFindAndLoadFile */
typedef struct CWFileInfo {
Boolean fullsearch; /* [<-] do we do a full search of paths for file */
char dependencyType; /* [<-] type CWDependencyType */
long isdependentoffile; /* [<-] this file is a dependent of file id */
/* (zero based) or -1L if of current file */
Boolean suppressload; /* [<-] find but don't load the file */
Boolean padding; /* [**] structure padding */
const char* filedata; /* [->] point to the file text/data, or NULL */
long filedatalength; /* [->] length of filedata */
short filedatatype; /* [->] type of data pointed to by filedata */
/* the remaining members are valid only when called by compilers */
short fileID; /* [->] use in browse records and dependencies */
CWFileSpec filespec; /* [->] specifies the file on disk */
Boolean alreadyincluded; /* [->] TRUE if already included in current compile */
Boolean recordbrowseinfo; /* [->] record browse info for this file? */
} CWFileInfo;
/* information maintained by the IDE for each segment in the project */
typedef struct CWProjectSegmentInfo {
char name[32]; /* segment name */
short attributes; /* segment attributes */
} CWProjectSegmentInfo;
/* 64 bit address */
typedef struct CWAddr64 {
long lo; /* low order longword of address */
long hi; /* high order longword of address */
} CWAddr64;
/* describes an overlay group, Use CWGetOverlayGroup1Info to iterate over overlay groups */
typedef struct CWOverlay1GroupInfo {
char name[256]; /* overlay group name */
CWAddr64 address; /* load address */
long numoverlays; /* number of overlays in this group */
} CWOverlay1GroupInfo;
/* describes an overlay, use CWGetOverlay1Info to iterate over overlays */
typedef struct CWOverlay1Info {
char name[256]; /* name of this overlay */
long numfiles; /* number of files in the overlay */
} CWOverlay1Info;
/* describes a file in an overlay, use CWGetOverlayFile1Info to iterate over files. Use */
/* whichfile in calls taking a file number, e.g. CWLoadObjectData or CWGetFileInfo */
typedef struct CWOverlay1FileInfo {
long whichfile; /* flat file number */
} CWOverlay1FileInfo;
/*
* All compiler errors or warnings which occur at some specific location in some
* source file are identified by a CWMessageRef structure. This structure
* provides sufficient information for the development environment to locate
* and display the exact position associated with a message. For each message,
* the compiler provides:
*
* errorstring: contains a description of the error, e.g. "syntax error"
* errorline: contains a subset of the text containing the error
* errorlevel: indicates if the "error" is an error, warning, or informational message
* CWMessageRef: further info so the IDE can perform two tasks:
* - Display a summary of each message, with the "error token"
* underlined within the compiler-provided errorline. This
* information is provided by the tokenoffset and tokenlength
* fields. If tokenLength is zero then no underlining is performed.
*
* - Open the file containing the error and select the full
* text of the error. This information is provided by the
* selectionoffset and selectionlength fields.
*/
typedef struct CWMessageRef
{
CWFileSpec sourcefile; /* file containing error */
long linenumber; /* error linenumber in file */
short tokenoffset; /* offset into errorline of token underline */
short tokenlength; /* length of error token to be underlined */
long selectionoffset; /* start of error for text selection */
long selectionlength; /* length of error for text selection */
} CWMessageRef;
/* message types, used for errorlevel parameter to message routines */
enum {
messagetypeInfo, /* informational only */
messagetypeWarning, /* warning message */
messagetypeError /* error message */
};
/* information maintained by the IDE for each file in the project */
typedef struct CWProjectFileInfo
{
CWFileSpec filespec; /* CW_FileSpec of file in project */
CWFileTime moddate; /* date source file was last modified */
short segment; /* segment number of file */
Boolean hasobjectcode; /* file has object code to be linked */
Boolean hasresources; /* file has resources to be linked */
Boolean isresourcefile; /* file -is- a resource file to be linked */
Boolean weakimport; /* file has "Import Weak" flag set */
Boolean initbefore; /* file has "Init Before" flag set */
Boolean gendebug; /* file has generate debug info on */
CWFileTime objmoddate; /* date object code was last modified */
CWFileName dropinname; /* name of dropin used to process this file */
short fileID; /* fileID to use in browse records */
Boolean recordbrowseinfo; /* record browse info for this file? */
Boolean reserved; /* reserved and used internally */
#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS
/* some Macintosh-specific information */
OSType filetype; /* MacOS file type */
OSType filecreator; /* MacOS file creator */
#endif
Boolean hasunitdata; /* file has associated unit data (Pascal) */
Boolean mergeintooutput; /* file has "Merge Into Output" flag set */
unsigned long unitdatadependencytag; /* dependency tag (i.e. checksum) of unit data (Pascal) */
} CWProjectFileInfo;
typedef struct CWNewTextDocumentInfo
{
const char* documentname; /* name for new document, can be NULL */
CWMemHandle text; /* initial text for document */
Boolean markDirty; /* mark doc as needing to be saved? */
} CWNewTextDocumentInfo;
typedef struct CWNewProjectEntryInfo
{ /* use kDefaultLinkPosition to get default link order, overlay, or segment */
long position; /* optional link order position */
long segment; /* optional segment number */
long overlayGroup; /* optional overlay group number */
long overlay; /* optional overlay number */
const char* groupPath; /* optional fully qualified path to file group */
Boolean mergeintooutput; /* set merge into output flag? */
Boolean weakimport; /* set weak import flag? */
Boolean initbefore; /* set initbefore flag? */
} CWNewProjectEntryInfo;
typedef struct CWIDEInfo
{
unsigned short majorVersion;
unsigned short minorVersion;
unsigned short bugFixVersion;
unsigned short buildVersion;
unsigned short dropinAPIVersion;
} CWIDEInfo;
/* Structures for getting the list of access paths. */
/* The callback does the filtering on the host flags, so the list returned */
/* will only contain the paths that are enabled for the host platform. */
/* There are separate APIs to get the Mac OS X framework style access paths. */
typedef enum CWAccessPathType {
cwSystemPath,
cwUserPath
} CWAccessPathType;
typedef struct CWAccessPathInfo
{
CWFileSpec pathSpec;
Boolean recursive;
long subdirectoryCount;
} CWAccessPathInfo;
typedef struct CWAccessPathListInfo
{
long systemPathCount;
long userPathCount;
Boolean alwaysSearchUserPaths;
Boolean convertPaths;
} CWAccessPathListInfo;
/* Structures for getting the list of Mac OS X framework access paths. */
/* The callback does the filtering on the host flags, so the list returned */
/* will only contain the Mac OS X framework style paths that are enabled for */
/* the host platform. */
/* There are separate APIs to get the traditional style access paths. */
typedef struct CWFrameworkAccessPathInfo
{
CWFileSpec pathSpec;
Boolean framework;
} CWFrameworkAccessPathInfo;
typedef struct CWFrameworkAccessPathListInfo
{
long systemPathCount;
long userPathCount;
Boolean alwaysSearchUserPaths;
Boolean convertPaths;
Boolean requireFrameworkIncludes;
} CWFrameworkAccessPathListInfo;
/* constants for different types of plugins */
/* Used in the dropintype in the DropInFlags, as well as for the MacOS file type */
enum
{
CWDROPINLINKERTYPE = CWFOURCHAR('L','i','n','k'), /* type for DropIn linkers */
CWDROPINCOMPILERTYPE= CWFOURCHAR('C','o','m','p'), /* type for DropIn compilers */
CWDROPINPREFSTYPE = CWFOURCHAR('P','a','n','L'), /* type for DropIn panels */
CWDROPINPREFSTYPE_1 = CWFOURCHAR('P','a','n','l'), /* type for 1.x IDE DropIn panels */
CWDROPINVCSTYPE = CWFOURCHAR('V','C','S',' '), /* type for DropIn version control */
CWDROPINCOMTYPE = CWFOURCHAR('C','O','M',' ') /* type for COM-only plugins */
};
typedef long CWPluginType; // one of the above types
/* Format of 'Flag' resources, or data returned by dropin's GetDropinFlags entry */
/* point. */
/* */
/* For the version 2 of these resource, we renamed the 'apiversion' field to */
/* 'earliestCompatibleAPIVersion' and added the 'newestAPIVersion' field. */
/* This allows plugins to support more than one API version and therefore run */
/* under more than one version of the IDE. The CWGetAPIVersion call should be used */
/* to determine what API version the IDE is using to talk to a plugin. */
#define kCurrentDropInFlagsVersion 2
typedef struct DropInFlags {
short rsrcversion; /* version number of resource */
CWDataType dropintype; /* dropin type (compiler, panel, etc) */
/* earliest API support by this plugin */
unsigned short earliestCompatibleAPIVersion;
unsigned long dropinflags; /* capability flags */
CWDataType edit_language; /* language */
unsigned short newestAPIVersion; /* newest API version supported */
} DropInFlags, **DropInFlagsHandle;
#define kCurrentCWPanelListVersion 1
typedef struct CWPanelList {
short version;
short count;
const char** names;
} CWPanelList;
#define kCurrentCWFamilyListVersion 1
#define kCurrentCWFamilyResourceVersion 1
typedef struct CWFamily {
CWDataType type;
const char* name;
} CWFamily;
typedef struct CWFamilyList {
short version;
short count;
CWFamily* families;
} CWFamilyList;
typedef struct CWFamilyResource {
short version;
CWDataType type;
unsigned char name[64];
} CWFamilyResource;
#define kCurrentCWHelpInfoVersion 1
typedef struct CWHelpInfo {
short version;
const char* helpFileName;
} CWHelpInfo;
#define kCurrentCWRelativePathVersion 1
typedef enum CWRelativePathFormat
{
format_Generic = 0, // Simple name, not platform-specific
format_Mac, // Uses : as separator :: for parent directory
format_Win, // Uses \ as separator .. for parent directory
format_Unix // Uses / as separator .. for parent directory
} CWRelativePathFormat;
typedef enum CWRelativePathTypes
{
type_Absolute = 0,
type_Project,
type_Compiler,
type_System,
type_UserDefined
} CWRelativePathTypes;
typedef struct CWRelativePath
{
short version; // version number
unsigned char pathType; // use CWRelativePathTypes
unsigned char pathFormat; // use CWRelativePathFormat
char userDefinedTree[256]; // user-defined tree name
char pathString[512]; // actual path string
} CWRelativePath;
/*
*
*/
#define kCurrentCWPluginInfoVersion 1
typedef struct CWPluginInfo
{
short version; // struct version number
const char* companyName; // i.e. Metrowerks
const char* pluginName; // Defaults to Dropin->GetName()
const char* pluginDisplayName;
const char* familyName; // i.e. Java
unsigned short majorIDEVersion; // Version of IDE Required
unsigned short minorIDEVersion;
} CWPluginInfo;
/* Declaration of plugin entry points that must be implemented by non-MacOS plugins */
/* It can also be implemented for MacOS plugins instead of having a 'Flag' resource */
CWPLUGIN_ENTRY (CWPlugin_GetDropInFlags)(const DropInFlags**, long* flagsSize);
/* Declaration of plugin entry points that may optionally be implemented by plugins */
/* These entry points override the corresponding resources on MacOS */
CWPLUGIN_ENTRY (CWPlugin_GetDropInName)(const char** dropInName);
CWPLUGIN_ENTRY (CWPlugin_GetDisplayName)(const char** displayName);
CWPLUGIN_ENTRY (CWPlugin_GetPanelList)(const CWPanelList** panelList);
CWPLUGIN_ENTRY (CWPlugin_GetFamilyList)(const CWFamilyList** familyList);
CWPLUGIN_ENTRY (CWPlugin_GetHelpInfo)(const CWHelpInfo** helpInfo);
/* Declaration of info plugin entry point that must be implemented by all COM plugins */
CWPLUGIN_ENTRY (CWPlugin_GetPluginInfo)(const CWPluginInfo** pluginInfo);
/* Callback declarations: these callbacks are supported for all CodeWarrior plugins */
/* Get the action the IDE is requesting of the plugin */
CW_CALLBACK CWGetPluginRequest(CWPluginContext context, long* request);
/* Call when finished handling a request, just before returning to the shell */
CW_CALLBACK CWDonePluginRequest(CWPluginContext, CWResult resultCode);
/* Get the version number of API used by the IDE to talk to the plugin */
CW_CALLBACK CWGetAPIVersion(CWPluginContext context, long* version);
/* Get information about the IDE being used */
CW_CALLBACK CWGetIDEInfo(CWPluginContext context, CWIDEInfo* info);
/* Get the OS error associated with the last callback */
CW_CALLBACK CWGetCallbackOSError(CWPluginContext context, CWOSResult* error);
/* Set the OS error associated with a failed plugin request */
CW_CALLBACK CWSetPluginOSError(CWPluginContext context, CWOSResult);
/* Get the file specifier for the current project */
CW_CALLBACK CWGetProjectFile(CWPluginContext context, CWFileSpec* projectSpec);
/* Get the directory where the IDE stores target-specific generated data */
CW_CALLBACK CWGetTargetDataDirectory(CWPluginContext context, CWFileSpec* targetDataDirectorySpec);
/* Get the name of the current target in the current project */
CW_CALLBACK CWGetTargetName(CWPluginContext context, char* name, short maxLength);
/* Get the directory where output files should be stored */
CW_CALLBACK CWGetOutputFileDirectory(CWPluginContext context, CWFileSpec* outputFileDirectory);
/* Get the number of files in the current project */
CW_CALLBACK CWGetProjectFileCount(CWPluginContext context, long* count);
/* Get information about a particular file in the project */
CW_CALLBACK CWGetFileInfo(CWPluginContext context, long whichfile, Boolean checkFileLocation, CWProjectFileInfo* fileinfo);
/* Search for a file by name on the current file's access paths. */
CW_CALLBACK CWFindAndLoadFile(CWPluginContext context, const char* filename, CWFileInfo *fileinfo);
/* Get the access paths for the current target */
CW_CALLBACK CWGetAccessPathListInfo(CWPluginContext context, CWAccessPathListInfo* pathListInfo);
CW_CALLBACK CWGetAccessPathInfo(CWPluginContext context, CWAccessPathType pathType, long whichPath, CWAccessPathInfo* pathInfo);
CW_CALLBACK CWGetAccessPathSubdirectory(CWPluginContext context, CWAccessPathType pathType, long whichPath, long whichSubdirectory, CWFileSpec* subdirectory);
CW_CALLBACK CWGetFrameworkAccessPathListInfo(CWPluginContext context, CWFrameworkAccessPathListInfo* pathListInfo);
CW_CALLBACK CWGetFrameworkAccessPathInfo(CWPluginContext context, CWAccessPathType pathType, long whichPath, CWFrameworkAccessPathInfo* pathInfo);
/* Get file text, from the editor, include file cache, or by reading the file */
CW_CALLBACK CWGetFileText(CWPluginContext context, const CWFileSpec* filespec, const char** text, long* textLength, short* filedatatype);
/* Release file text returned by CWFindAndLoadFile and CWGetFileText */
CW_CALLBACK CWReleaseFileText(CWPluginContext context, const char* text);
/* Get information about a project segment */
CW_CALLBACK CWGetSegmentInfo(CWPluginContext context, long whichsegment, CWProjectSegmentInfo* segmentinfo);
/* Get the number of overlay groups in the target */
CW_CALLBACK CWGetOverlay1GroupsCount(CWPluginContext context, long* count);
/* Get information about a project overlay group */
CW_CALLBACK CWGetOverlay1GroupInfo(CWPluginContext context, long whichgroup, CWOverlay1GroupInfo* groupinfo);
/* Get information about an overlay within a group */
CW_CALLBACK CWGetOverlay1Info(CWPluginContext context, long whichgroup, long whichoverlay, CWOverlay1Info* overlayinfo);
/* Get information about a file in an overlay */
CW_CALLBACK CWGetOverlay1FileInfo(CWPluginContext context, long whichgroup, long whichoverlay, long whichoverlayfile, CWOverlay1FileInfo* fileinfo);
/* Report a error, warning, or informational message */
CW_CALLBACK CWReportMessage(CWPluginContext context, const CWMessageRef* msgRef, const char *line1, const char *line2, short errorlevel, long errorNumber);
/* Display an alert. May actually be put in a message, depending on the plugin request */
CW_CALLBACK CWAlert(CWPluginContext context, const char* msg1, const char* msg2, const char* msg3, const char* msg4);
/* Display one or two status messages to the user */
CW_CALLBACK CWShowStatus(CWPluginContext context, const char *line1, const char *line2);
/* Give to the IDE to handle events and check if user has canceled this operation */
CW_CALLBACK CWUserBreak(CWPluginContext context);
/* Return stored preference data, referenced by name. Typically used for preference */
/* panel settings. */
CW_CALLBACK CWGetNamedPreferences(CWPluginContext context, const char* prefsname, CWMemHandle* prefsdata);
/* Store data referenced by a data type and file number */
CW_CALLBACK CWStorePluginData(CWPluginContext context, long whichfile, CWDataType type, CWMemHandle prefsdata);
/* Return stored data referenced by a data type and file number */
CW_CALLBACK CWGetPluginData(CWPluginContext context, long whichfile, CWDataType type, CWMemHandle* prefsdata);
/* Inform the IDE that a file modification date has changed. isGenerated is for use */
/* by compiler and linker plugins only */
CW_CALLBACK CWSetModDate(CWPluginContext context, const CWFileSpec* filespec, CWFileTime* moddate, Boolean isGenerated);
/* Ask the IDE to add a file to the current target in the current project. isGenerated */
/* is for use by compiler plugins only. */
CW_CALLBACK CWAddProjectEntry(CWPluginContext context, const CWFileSpec* fileSpec, Boolean isGenerated, const CWNewProjectEntryInfo* projectEntryInfo, long* whichfile);
/* Ask the IDE to remove a file from the current target (link-order/segment/overlay) in the current project. */
/* If it's the last target that contains the file, it would be removed from the file list. */
CW_CALLBACK CWRemoveProjectEntry(CWPluginContext context, const CWFileSpec* fileSpec);
/* Create a new editor window, supplying initial text and an optional document name */
CW_CALLBACK CWCreateNewTextDocument(CWPluginContext, const CWNewTextDocumentInfo* docinfo);
/* Allocate memory. Permanent memory is not freed until the plugin is unloaded. */
/* Temporary memory is freed after each plugin request completes. */
CW_CALLBACK CWAllocateMemory(CWPluginContext context, long size, Boolean isPermanent, void** ptr);
/* Free memory allocated via CWAllocateMemory */
CW_CALLBACK CWFreeMemory(CWPluginContext context, void* ptr, Boolean isPermanent);
/* Allocate a memory handle of the requested size. All handles are automatically */
/* freed at the end of each compiler/linker request. useTempMemory is MacOS-specific*/
CW_CALLBACK CWAllocMemHandle(CWPluginContext context, long size, Boolean useTempMemory, CWMemHandle* handle);
/* Free a memory handle */
CW_CALLBACK CWFreeMemHandle(CWPluginContext context, CWMemHandle handle);
/* Return the current size of a memory handle */
CW_CALLBACK CWGetMemHandleSize(CWPluginContext context, CWMemHandle handle, long* size);
/* Resize an existing memory handle */
CW_CALLBACK CWResizeMemHandle(CWPluginContext context, CWMemHandle handle, long newSize);
/* To obtain a pointer to the block, you must lock the handle */
/* moveHi is MacOS-specific */
CW_CALLBACK CWLockMemHandle(CWPluginContext context, CWMemHandle handle, Boolean moveHi, void** ptr);
/* Unlock a memory handle, the pointer returned by locking the handle may no */
/* longer be valid */
CW_CALLBACK CWUnlockMemHandle(CWPluginContext context, CWMemHandle handle);
#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS
/* Utility function to map MacOS error codes to a CWResult code. Plugins */
/* may internally generate OSErrs, but need to return CWResult to the */
/* CodeWarrior IDE */
CW_CALLBACK CWMacOSErrToCWResult(CWPluginContext context, OSErr err);
#endif
/* Turn off the built in PP window manager while the plugin displays a dialog */
CW_CALLBACK CWPreDialog(CWPluginContext context);
/* Turn on the built in PP window manager after the plugin is through with its */
/* dialog */
CW_CALLBACK CWPostDialog(CWPluginContext context);
/* Notify the IDE that the plugin will be performing actions on a file */
CW_CALLBACK CWPreFileAction(CWPluginContext context, const CWFileSpec *theFile);
/* Notify the IDE that the plugin is finished performing actions on a file */
CW_CALLBACK CWPostFileAction(CWPluginContext context, const CWFileSpec *theFile);
CW_CALLBACK CWResolveRelativePath(CWPluginContext context, const CWRelativePath* relativePath, CWFileSpec* fileSpec, Boolean create);
CW_CALLBACK CWFindLogicalDirectory(CWPluginContext context, long selector, CWFileSpec *dirSpec);
CW_CALLBACK CWOpenFileInEditor(CWPluginContext context, const CWFileSpec *fileSpec);
#if CWPLUGIN_HOST==CWPLUGIN_HOST_SOLARIS || CWPLUGIN_HOST==CWPLUGIN_HOST_LINUX
/* Forward declarations */
struct ICodeWarriorApp;
struct ICodeWarriorProject;
struct ICodeWarriorDesign;
struct ICodeWarriorTarget;
#endif /* CWPLUGIN_HOST==CWPLUGIN_HOST_SOLARIS || CWPLUGIN_HOST==CWPLUGIN_HOST_LINUX */
/* Get the IDE application COM interface. Fails if called from any thread */
/* other than the main IDE thread, e.g. a build thread. */
CW_CALLBACK CWGetCOMApplicationInterface(CWPluginContext context, struct ICodeWarriorApp **app);
/* Get the current project COM interface. Adds a reference upon return. */
/* Only succeeds if the plugin is being called in the context of a */
/* particular project. Fails if called from any thread */
/* other than the main IDE thread, e.g. a build thread. */
CW_CALLBACK CWGetCOMProjectInterface(CWPluginContext context, struct ICodeWarriorProject **project);
/* Get the current design COM interface. Adds a reference upon return. */
/* Only succeeds if the plugin is being called in the context of a */
/* particular target that is associated with a design. */
/* Fails if called from any thread other than the main IDE thread, */
/* e.g. a build thread. */
CW_CALLBACK CWGetCOMDesignInterface(CWPluginContext context, struct ICodeWarriorDesign **design);
/* Get the current target COM interface. Adds a reference upon return. */
/* Only succeeds if the plugin is being called in the context of a */
/* particular target. Fails if called from any thread */
/* other than the main IDE thread, e.g. a build thread. */
CW_CALLBACK CWGetCOMTargetInterface(CWPluginContext context, struct ICodeWarriorTarget **target);
#if CW_USE_PRAGMA_IMPORT
#pragma import reset
#endif
#ifdef __cplusplus
}
#endif
#ifdef _MSC_VER
#pragma pack(pop)
#endif
#ifdef __MWERKS__
#pragma options align=reset
#endif
#endif /* __CWPlugins_H__ */
\ No newline at end of file +/*
* CWPlugins.h - Common declarations for Metrowerks CodeWarrior� plugins
*
* Copyright � 1995-1997 Metrowerks, Inc. All rights reserved.
*
*/
#include "common.h"
#ifndef __CWPlugins_H__
#define __CWPlugins_H__
#ifdef __MWERKS__
# pragma once
#endif
#define CWPLUGIN_HOST_MACOS 1
#define CWPLUGIN_HOST_WIN32 2
#define CWPLUGIN_HOST_SOLARIS 3
#define CWPLUGIN_HOST_LINUX 4
#ifndef CWPLUGIN_HOST
# ifdef WIN32
# define CWPLUGIN_HOST CWPLUGIN_HOST_WIN32
# elif defined(macintosh)
# define CWPLUGIN_HOST CWPLUGIN_HOST_MACOS
# elif defined(__sun__)
# define CWPLUGIN_HOST CWPLUGIN_HOST_SOLARIS
# elif defined(__linux__) || defined(__CLION_IDE__)
# define CWPLUGIN_HOST CWPLUGIN_HOST_LINUX
# else
# error
# endif
#endif
#define CWPLUGIN_API_MACOS 1
#define CWPLUGIN_API_WIN32 2
#define CWPLUGIN_API_UNIX 3
#ifndef CWPLUGIN_API
# ifdef WIN32
# define CWPLUGIN_API CWPLUGIN_API_WIN32
# elif defined(macintosh)
# define CWPLUGIN_API CWPLUGIN_API_MACOS
# elif defined(__sun__) || defined(__linux__) || defined(__CLION_IDE__)
# define CWPLUGIN_API CWPLUGIN_API_UNIX
# else
# error
# endif
#endif
/*
** Radix 256 notation where a 32-bit integer is created from four
** ASCII characters. A four-character constant of this form, say
** 'ABCD', must always be represented with the same pattern, 0x41424344
** in this case, regardless of big/little endian issues.
*/
typedef SInt32 CWFourCharType;
#define CWFOURCHAR(a, b, c, d) \
(((CWFourCharType) ((a) & 0xff) << 24) \
| ((CWFourCharType) ((b) & 0xff) << 16) \
| ((CWFourCharType) ((c) & 0xff) << 8) \
| ((CWFourCharType) ((d) & 0xff)))
#if CWPLUGIN_API == CWPLUGIN_API_UNIX
#include <sys/param.h>
#endif
#ifndef CW_USE_PRAGMA_EXPORT
#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS
#define CW_USE_PRAGMA_EXPORT 1
#else
#define CW_USE_PRAGMA_EXPORT 0
#endif
#endif
#ifndef CW_USE_PRAGMA_IMPORT
#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS
#define CW_USE_PRAGMA_IMPORT 1
#else
#define CW_USE_PRAGMA_IMPORT 0
#endif
#endif
#ifdef __MWERKS__
#pragma options align=mac68k
#endif
#ifdef _MSC_VER
#pragma pack(push,2)
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if CW_USE_PRAGMA_IMPORT
#pragma import on
#endif
/* These constants specify the action the IDE is asking the plugin to execute */
enum {
reqInitialize = -2, /* called when the plugin is loaded */
reqTerminate = -1, /* called when the plugin is unloaded */
reqIdle = -100, /* called periodically to allow for plugin tasks EP 6/24/98 */
reqAbout = -101, /* called to ask plugin to display about dialog EP 6/24/98 */
reqPrefsChange = -102 /* called when an associated pref panel changes EP 6/24/98 */
};
/* Used in CWFileInfo.dependencyType to indicate what type of make */
/* dependency to establish between files */
typedef enum CWDependencyType {
cwNoDependency, /* do not establish a dependency */
cwNormalDependency, /* recompile dependent whenever prereq changes */
cwInterfaceDependency /* recompile only if interface to file changes */
} CWDependencyType;
/* Used in CWFileInfo.filedatatype to indicate the type of data in a loaded file */
enum {
cwFileTypeUnknown, /* unknown binary data */
cwFileTypeText, /* normal text file */
cwFileTypePrecompiledHeader /* cached precompiled header */
};
/* constant for CWFileInfo.isdependentoffile */
#define kCurrentCompiledFile -1L
/* constant for CWStorePluginData/CWGetPluginData */
#define kTargetGlobalPluginData -1L
/* constant for CWNewProjectEntryInfo link order, segment, and overlay values */
#define kDefaultLinkPosition -1L
/* Selectors for CWFindLogicalDirectory */
enum {
kIDEDirectorySelector = 1, /* parent directory of IDE application; "bin" folder on Win32 */
kCodeWarriorDirectorySelector, /* root CodeWarrior directory */
kSystemDirectorySelector, /* system directory */
kProjectDirectorySelector, /* parent directory of current project */
kProjectDataDirectorySelector, /* project data directory */
kTargetDataDirectorySelector, /* target data directory (within project data directory) */
kTargetObjectCodeDirectorySelector, /* object code directory (within target data directory) */
kDebuggerCacheDirectorySelector, /* "CW Debugging Cache" directory */
kHelperAppsDirectorySelector, /* "(Helper Apps)" directory */
kPluginsDirectorySelector, /* "CodeWarrior Plugins" (Mac) or "plugins" (Win32) directory */
kPluginParentDirectorySelector, /* parent directory of current plugin */
kStationeryDirectorySelector, /* "(Project Stationery)" directory */
kRADStationeryDirectorySelector, /* "RAD Stationery" directory */
kLocalizedResourcesDirectorySelector /* "resources" directory */
};
/* CWPluginContext is a magic cookie passed to all plugins. It must */
/* be passed back to all IDE callbacks */
typedef struct CWPluginPrivateContext* CWPluginContext;
/* CWResult is the error/status result returned by all IDE API routine. */
/* The most common errors are returned directly. For OS-specific errors, the */
/* CWResult is cwErrOSError, and the OS-specific error can be obtained by */
/* calling CWGetOSError() */
typedef SInt32 CWResult;
/* CWMemHandle is an abstraction for memory used in some parts */
/* of the plugin API. API routines must be used to allocate */
/* and free CWMemHandles, or to convert them to pointers. */
typedef struct CWMemHandlePrivateStruct* CWMemHandle;
/* Used to identify custom data associated by a plugin with */
/* a project file or a target as a whole. Must be a four character */
/* constant. All lower case constants are reserved by the IDE */
typedef UInt32 CWDataType;
/* Some information used in the compiler/linker API is platform-dependent */
/* We use some typedefs to isolate the differences */
/* CWFileSpec contains the native platform file specifier. */
/* CWFileName contains the string type for a native file name */
/* CWFileTime contains the native platform file timestamp */
/* CWOSResult contains the native platform error return value */
/* CWResult contains an API routine error/status result */
/* CW_CALLBACK is a macro defining the calling convention and return type for */
/* IDE callback routines. */
/* CW_PLUGINENTRY is a macro defining the calling convention and return type for */
/* plugin entry points. */
/* CWSUCCESS is a macro that evaluates to true when given a CWResult indicating an */
/* routine succeeded */
#if CWPLUGIN_API == CWPLUGIN_API_MACOS
typedef FSSpec CWFileSpec;
typedef char CWFileName[32];
typedef unsigned long CWFileTime;
typedef OSErr CWOSResult;
#elif CWPLUGIN_API == CWPLUGIN_API_WIN32
typedef unsigned char Boolean;
typedef struct CWFileSpec { char path[MAX_PATH]; } CWFileSpec;
typedef char CWFileName[65];
typedef FILETIME CWFileTime;
typedef DWORD CWOSResult;
#elif CWPLUGIN_API == CWPLUGIN_API_UNIX
#define MAX_PATH MAXPATHLEN
#ifndef __MACTYPES__
typedef unsigned char Boolean;
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
typedef struct CWFileSpec { char path[MAX_PATH]; } CWFileSpec;
typedef char CWFileName[65];
typedef time_t CWFileTime;
typedef int CWOSResult;
#else
#error Unknown plugin API!
#endif
#define CWSUCCESS(result) ((result) == 0)
#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS
#define CW_CALLBACK pascal CWResult
#define CW_CALLBACK_PTR(function_name) pascal CWResult (function_name)
#define CWPLUGIN_ENTRY(function_name) pascal short (function_name)
#elif CWPLUGIN_HOST == CWPLUGIN_HOST_WIN32
#define CW_CALLBACK CWResult __stdcall
#define CW_CALLBACK_PTR(function_name) CWResult (__stdcall function_name)
#define CWPLUGIN_ENTRY(function_name) short (__stdcall function_name)
#elif CWPLUGIN_HOST==CWPLUGIN_HOST_SOLARIS || CWPLUGIN_HOST==CWPLUGIN_HOST_LINUX
#define CW_CALLBACK CWResult
#define CW_CALLBACK_PTR(function_name) CWResult (function_name)
#define CWPLUGIN_ENTRY(function_name) short (function_name)
#else
#error Unknown plugin host!
#endif
/* information returned by CWFindAndLoadFile */
typedef struct CWFileInfo {
Boolean fullsearch; /* [<-] do we do a full search of paths for file */
char dependencyType; /* [<-] type CWDependencyType */
SInt32 isdependentoffile; /* [<-] this file is a dependent of file id */
/* (zero based) or -1L if of current file */
Boolean suppressload; /* [<-] find but don't load the file */
Boolean padding; /* [**] structure padding */
const char* filedata; /* [->] point to the file text/data, or NULL */
SInt32 filedatalength; /* [->] length of filedata */
short filedatatype; /* [->] type of data pointed to by filedata */
/* the remaining members are valid only when called by compilers */
short fileID; /* [->] use in browse records and dependencies */
CWFileSpec filespec; /* [->] specifies the file on disk */
Boolean alreadyincluded; /* [->] TRUE if already included in current compile */
Boolean recordbrowseinfo; /* [->] record browse info for this file? */
} CWFileInfo;
/* information maintained by the IDE for each segment in the project */
typedef struct CWProjectSegmentInfo {
char name[32]; /* segment name */
short attributes; /* segment attributes */
} CWProjectSegmentInfo;
/* 64 bit address */
typedef struct CWAddr64 {
SInt32 lo; /* low order longword of address */
SInt32 hi; /* high order longword of address */
} CWAddr64;
/* describes an overlay group, Use CWGetOverlayGroup1Info to iterate over overlay groups */
typedef struct CWOverlay1GroupInfo {
char name[256]; /* overlay group name */
CWAddr64 address; /* load address */
SInt32 numoverlays; /* number of overlays in this group */
} CWOverlay1GroupInfo;
/* describes an overlay, use CWGetOverlay1Info to iterate over overlays */
typedef struct CWOverlay1Info {
char name[256]; /* name of this overlay */
SInt32 numfiles; /* number of files in the overlay */
} CWOverlay1Info;
/* describes a file in an overlay, use CWGetOverlayFile1Info to iterate over files. Use */
/* whichfile in calls taking a file number, e.g. CWLoadObjectData or CWGetFileInfo */
typedef struct CWOverlay1FileInfo {
SInt32 whichfile; /* flat file number */
} CWOverlay1FileInfo;
/*
* All compiler errors or warnings which occur at some specific location in some
* source file are identified by a CWMessageRef structure. This structure
* provides sufficient information for the development environment to locate
* and display the exact position associated with a message. For each message,
* the compiler provides:
*
* errorstring: contains a description of the error, e.g. "syntax error"
* errorline: contains a subset of the text containing the error
* errorlevel: indicates if the "error" is an error, warning, or informational message
* CWMessageRef: further info so the IDE can perform two tasks:
* - Display a summary of each message, with the "error token"
* underlined within the compiler-provided errorline. This
* information is provided by the tokenoffset and tokenlength
* fields. If tokenLength is zero then no underlining is performed.
*
* - Open the file containing the error and select the full
* text of the error. This information is provided by the
* selectionoffset and selectionlength fields.
*/
typedef struct CWMessageRef
{
CWFileSpec sourcefile; /* file containing error */
SInt32 linenumber; /* error linenumber in file */
short tokenoffset; /* offset into errorline of token underline */
short tokenlength; /* length of error token to be underlined */
SInt32 selectionoffset; /* start of error for text selection */
SInt32 selectionlength; /* length of error for text selection */
} CWMessageRef;
/* message types, used for errorlevel parameter to message routines */
enum {
messagetypeInfo, /* informational only */
messagetypeWarning, /* warning message */
messagetypeError /* error message */
};
/* information maintained by the IDE for each file in the project */
typedef struct CWProjectFileInfo
{
CWFileSpec filespec; /* CW_FileSpec of file in project */
CWFileTime moddate; /* date source file was last modified */
short segment; /* segment number of file */
Boolean hasobjectcode; /* file has object code to be linked */
Boolean hasresources; /* file has resources to be linked */
Boolean isresourcefile; /* file -is- a resource file to be linked */
Boolean weakimport; /* file has "Import Weak" flag set */
Boolean initbefore; /* file has "Init Before" flag set */
Boolean gendebug; /* file has generate debug info on */
CWFileTime objmoddate; /* date object code was last modified */
CWFileName dropinname; /* name of dropin used to process this file */
short fileID; /* fileID to use in browse records */
Boolean recordbrowseinfo; /* record browse info for this file? */
Boolean reserved; /* reserved and used internally */
#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS
/* some Macintosh-specific information */
OSType filetype; /* MacOS file type */
OSType filecreator; /* MacOS file creator */
#endif
Boolean hasunitdata; /* file has associated unit data (Pascal) */
Boolean mergeintooutput; /* file has "Merge Into Output" flag set */
UInt32 unitdatadependencytag; /* dependency tag (i.e. checksum) of unit data (Pascal) */
} CWProjectFileInfo;
typedef struct CWNewTextDocumentInfo
{
const char* documentname; /* name for new document, can be NULL */
CWMemHandle text; /* initial text for document */
Boolean markDirty; /* mark doc as needing to be saved? */
} CWNewTextDocumentInfo;
typedef struct CWNewProjectEntryInfo
{ /* use kDefaultLinkPosition to get default link order, overlay, or segment */
SInt32 position; /* optional link order position */
SInt32 segment; /* optional segment number */
SInt32 overlayGroup; /* optional overlay group number */
SInt32 overlay; /* optional overlay number */
const char* groupPath; /* optional fully qualified path to file group */
Boolean mergeintooutput; /* set merge into output flag? */
Boolean weakimport; /* set weak import flag? */
Boolean initbefore; /* set initbefore flag? */
} CWNewProjectEntryInfo;
typedef struct CWIDEInfo
{
unsigned short majorVersion;
unsigned short minorVersion;
unsigned short bugFixVersion;
unsigned short buildVersion;
unsigned short dropinAPIVersion;
} CWIDEInfo;
/* Structures for getting the list of access paths. */
/* The callback does the filtering on the host flags, so the list returned */
/* will only contain the paths that are enabled for the host platform. */
/* There are separate APIs to get the Mac OS X framework style access paths. */
typedef enum CWAccessPathType {
cwSystemPath,
cwUserPath
} CWAccessPathType;
typedef struct CWAccessPathInfo
{
CWFileSpec pathSpec;
Boolean recursive;
SInt32 subdirectoryCount;
} CWAccessPathInfo;
typedef struct CWAccessPathListInfo
{
SInt32 systemPathCount;
SInt32 userPathCount;
Boolean alwaysSearchUserPaths;
Boolean convertPaths;
} CWAccessPathListInfo;
/* Structures for getting the list of Mac OS X framework access paths. */
/* The callback does the filtering on the host flags, so the list returned */
/* will only contain the Mac OS X framework style paths that are enabled for */
/* the host platform. */
/* There are separate APIs to get the traditional style access paths. */
typedef struct CWFrameworkAccessPathInfo
{
CWFileSpec pathSpec;
Boolean framework;
} CWFrameworkAccessPathInfo;
typedef struct CWFrameworkAccessPathListInfo
{
SInt32 systemPathCount;
SInt32 userPathCount;
Boolean alwaysSearchUserPaths;
Boolean convertPaths;
Boolean requireFrameworkIncludes;
} CWFrameworkAccessPathListInfo;
/* constants for different types of plugins */
/* Used in the dropintype in the DropInFlags, as well as for the MacOS file type */
enum
{
CWDROPINLINKERTYPE = CWFOURCHAR('L','i','n','k'), /* type for DropIn linkers */
CWDROPINCOMPILERTYPE= CWFOURCHAR('C','o','m','p'), /* type for DropIn compilers */
CWDROPINPREFSTYPE = CWFOURCHAR('P','a','n','L'), /* type for DropIn panels */
CWDROPINPREFSTYPE_1 = CWFOURCHAR('P','a','n','l'), /* type for 1.x IDE DropIn panels */
CWDROPINVCSTYPE = CWFOURCHAR('V','C','S',' '), /* type for DropIn version control */
CWDROPINCOMTYPE = CWFOURCHAR('C','O','M',' ') /* type for COM-only plugins */
};
typedef SInt32 CWPluginType; // one of the above types
/* Format of 'Flag' resources, or data returned by dropin's GetDropinFlags entry */
/* point. */
/* */
/* For the version 2 of these resource, we renamed the 'apiversion' field to */
/* 'earliestCompatibleAPIVersion' and added the 'newestAPIVersion' field. */
/* This allows plugins to support more than one API version and therefore run */
/* under more than one version of the IDE. The CWGetAPIVersion call should be used */
/* to determine what API version the IDE is using to talk to a plugin. */
#define kCurrentDropInFlagsVersion 2
typedef struct DropInFlags {
short rsrcversion; /* version number of resource */
CWDataType dropintype; /* dropin type (compiler, panel, etc) */
/* earliest API support by this plugin */
unsigned short earliestCompatibleAPIVersion;
UInt32 dropinflags; /* capability flags */
CWDataType edit_language; /* language */
unsigned short newestAPIVersion; /* newest API version supported */
} DropInFlags, **DropInFlagsHandle;
#define kCurrentCWPanelListVersion 1
typedef struct CWPanelList {
short version;
short count;
const char** names;
} CWPanelList;
#define kCurrentCWFamilyListVersion 1
#define kCurrentCWFamilyResourceVersion 1
typedef struct CWFamily {
CWDataType type;
const char* name;
} CWFamily;
typedef struct CWFamilyList {
short version;
short count;
CWFamily* families;
} CWFamilyList;
typedef struct CWFamilyResource {
short version;
CWDataType type;
unsigned char name[64];
} CWFamilyResource;
#define kCurrentCWHelpInfoVersion 1
typedef struct CWHelpInfo {
short version;
const char* helpFileName;
} CWHelpInfo;
#define kCurrentCWRelativePathVersion 1
typedef enum CWRelativePathFormat
{
format_Generic = 0, // Simple name, not platform-specific
format_Mac, // Uses : as separator :: for parent directory
format_Win, // Uses \ as separator .. for parent directory
format_Unix // Uses / as separator .. for parent directory
} CWRelativePathFormat;
typedef enum CWRelativePathTypes
{
type_Absolute = 0,
type_Project,
type_Compiler,
type_System,
type_UserDefined
} CWRelativePathTypes;
typedef struct CWRelativePath
{
short version; // version number
unsigned char pathType; // use CWRelativePathTypes
unsigned char pathFormat; // use CWRelativePathFormat
char userDefinedTree[256]; // user-defined tree name
char pathString[512]; // actual path string
} CWRelativePath;
/*
*
*/
#define kCurrentCWPluginInfoVersion 1
typedef struct CWPluginInfo
{
short version; // struct version number
const char* companyName; // i.e. Metrowerks
const char* pluginName; // Defaults to Dropin->GetName()
const char* pluginDisplayName;
const char* familyName; // i.e. Java
unsigned short majorIDEVersion; // Version of IDE Required
unsigned short minorIDEVersion;
} CWPluginInfo;
/* Declaration of plugin entry points that must be implemented by non-MacOS plugins */
/* It can also be implemented for MacOS plugins instead of having a 'Flag' resource */
CWPLUGIN_ENTRY (CWPlugin_GetDropInFlags)(const DropInFlags**, SInt32* flagsSize);
/* Declaration of plugin entry points that may optionally be implemented by plugins */
/* These entry points override the corresponding resources on MacOS */
CWPLUGIN_ENTRY (CWPlugin_GetDropInName)(const char** dropInName);
CWPLUGIN_ENTRY (CWPlugin_GetDisplayName)(const char** displayName);
CWPLUGIN_ENTRY (CWPlugin_GetPanelList)(const CWPanelList** panelList);
CWPLUGIN_ENTRY (CWPlugin_GetFamilyList)(const CWFamilyList** familyList);
CWPLUGIN_ENTRY (CWPlugin_GetHelpInfo)(const CWHelpInfo** helpInfo);
/* Declaration of info plugin entry point that must be implemented by all COM plugins */
CWPLUGIN_ENTRY (CWPlugin_GetPluginInfo)(const CWPluginInfo** pluginInfo);
/* Callback declarations: these callbacks are supported for all CodeWarrior plugins */
/* Get the action the IDE is requesting of the plugin */
CW_CALLBACK CWGetPluginRequest(CWPluginContext context, SInt32* request);
/* Call when finished handling a request, just before returning to the shell */
CW_CALLBACK CWDonePluginRequest(CWPluginContext, CWResult resultCode);
/* Get the version number of API used by the IDE to talk to the plugin */
CW_CALLBACK CWGetAPIVersion(CWPluginContext context, SInt32* version);
/* Get information about the IDE being used */
CW_CALLBACK CWGetIDEInfo(CWPluginContext context, CWIDEInfo* info);
/* Get the OS error associated with the last callback */
CW_CALLBACK CWGetCallbackOSError(CWPluginContext context, CWOSResult* error);
/* Set the OS error associated with a failed plugin request */
CW_CALLBACK CWSetPluginOSError(CWPluginContext context, CWOSResult);
/* Get the file specifier for the current project */
CW_CALLBACK CWGetProjectFile(CWPluginContext context, CWFileSpec* projectSpec);
/* Get the directory where the IDE stores target-specific generated data */
CW_CALLBACK CWGetTargetDataDirectory(CWPluginContext context, CWFileSpec* targetDataDirectorySpec);
/* Get the name of the current target in the current project */
CW_CALLBACK CWGetTargetName(CWPluginContext context, char* name, short maxLength);
/* Get the directory where output files should be stored */
CW_CALLBACK CWGetOutputFileDirectory(CWPluginContext context, CWFileSpec* outputFileDirectory);
/* Get the number of files in the current project */
CW_CALLBACK CWGetProjectFileCount(CWPluginContext context, SInt32* count);
/* Get information about a particular file in the project */
CW_CALLBACK CWGetFileInfo(CWPluginContext context, SInt32 whichfile, Boolean checkFileLocation, CWProjectFileInfo* fileinfo);
/* Search for a file by name on the current file's access paths. */
CW_CALLBACK CWFindAndLoadFile(CWPluginContext context, const char* filename, CWFileInfo *fileinfo);
/* Get the access paths for the current target */
CW_CALLBACK CWGetAccessPathListInfo(CWPluginContext context, CWAccessPathListInfo* pathListInfo);
CW_CALLBACK CWGetAccessPathInfo(CWPluginContext context, CWAccessPathType pathType, SInt32 whichPath, CWAccessPathInfo* pathInfo);
CW_CALLBACK CWGetAccessPathSubdirectory(CWPluginContext context, CWAccessPathType pathType, SInt32 whichPath, SInt32 whichSubdirectory, CWFileSpec* subdirectory);
CW_CALLBACK CWGetFrameworkAccessPathListInfo(CWPluginContext context, CWFrameworkAccessPathListInfo* pathListInfo);
CW_CALLBACK CWGetFrameworkAccessPathInfo(CWPluginContext context, CWAccessPathType pathType, SInt32 whichPath, CWFrameworkAccessPathInfo* pathInfo);
/* Get file text, from the editor, include file cache, or by reading the file */
CW_CALLBACK CWGetFileText(CWPluginContext context, const CWFileSpec* filespec, const char** text, SInt32* textLength, short* filedatatype);
/* Release file text returned by CWFindAndLoadFile and CWGetFileText */
CW_CALLBACK CWReleaseFileText(CWPluginContext context, const char* text);
/* Get information about a project segment */
CW_CALLBACK CWGetSegmentInfo(CWPluginContext context, SInt32 whichsegment, CWProjectSegmentInfo* segmentinfo);
/* Get the number of overlay groups in the target */
CW_CALLBACK CWGetOverlay1GroupsCount(CWPluginContext context, SInt32* count);
/* Get information about a project overlay group */
CW_CALLBACK CWGetOverlay1GroupInfo(CWPluginContext context, SInt32 whichgroup, CWOverlay1GroupInfo* groupinfo);
/* Get information about an overlay within a group */
CW_CALLBACK CWGetOverlay1Info(CWPluginContext context, SInt32 whichgroup, SInt32 whichoverlay, CWOverlay1Info* overlayinfo);
/* Get information about a file in an overlay */
CW_CALLBACK CWGetOverlay1FileInfo(CWPluginContext context, SInt32 whichgroup, SInt32 whichoverlay, SInt32 whichoverlayfile, CWOverlay1FileInfo* fileinfo);
/* Report a error, warning, or informational message */
CW_CALLBACK CWReportMessage(CWPluginContext context, const CWMessageRef* msgRef, const char *line1, const char *line2, short errorlevel, SInt32 errorNumber);
/* Display an alert. May actually be put in a message, depending on the plugin request */
CW_CALLBACK CWAlert(CWPluginContext context, const char* msg1, const char* msg2, const char* msg3, const char* msg4);
/* Display one or two status messages to the user */
CW_CALLBACK CWShowStatus(CWPluginContext context, const char *line1, const char *line2);
/* Give to the IDE to handle events and check if user has canceled this operation */
CW_CALLBACK CWUserBreak(CWPluginContext context);
/* Return stored preference data, referenced by name. Typically used for preference */
/* panel settings. */
CW_CALLBACK CWGetNamedPreferences(CWPluginContext context, const char* prefsname, CWMemHandle* prefsdata);
/* Store data referenced by a data type and file number */
CW_CALLBACK CWStorePluginData(CWPluginContext context, SInt32 whichfile, CWDataType type, CWMemHandle prefsdata);
/* Return stored data referenced by a data type and file number */
CW_CALLBACK CWGetPluginData(CWPluginContext context, SInt32 whichfile, CWDataType type, CWMemHandle* prefsdata);
/* Inform the IDE that a file modification date has changed. isGenerated is for use */
/* by compiler and linker plugins only */
CW_CALLBACK CWSetModDate(CWPluginContext context, const CWFileSpec* filespec, CWFileTime* moddate, Boolean isGenerated);
/* Ask the IDE to add a file to the current target in the current project. isGenerated */
/* is for use by compiler plugins only. */
CW_CALLBACK CWAddProjectEntry(CWPluginContext context, const CWFileSpec* fileSpec, Boolean isGenerated, const CWNewProjectEntryInfo* projectEntryInfo, SInt32* whichfile);
/* Ask the IDE to remove a file from the current target (link-order/segment/overlay) in the current project. */
/* If it's the last target that contains the file, it would be removed from the file list. */
CW_CALLBACK CWRemoveProjectEntry(CWPluginContext context, const CWFileSpec* fileSpec);
/* Create a new editor window, supplying initial text and an optional document name */
CW_CALLBACK CWCreateNewTextDocument(CWPluginContext, const CWNewTextDocumentInfo* docinfo);
/* Allocate memory. Permanent memory is not freed until the plugin is unloaded. */
/* Temporary memory is freed after each plugin request completes. */
CW_CALLBACK CWAllocateMemory(CWPluginContext context, SInt32 size, Boolean isPermanent, void** ptr);
/* Free memory allocated via CWAllocateMemory */
CW_CALLBACK CWFreeMemory(CWPluginContext context, void* ptr, Boolean isPermanent);
/* Allocate a memory handle of the requested size. All handles are automatically */
/* freed at the end of each compiler/linker request. useTempMemory is MacOS-specific*/
CW_CALLBACK CWAllocMemHandle(CWPluginContext context, SInt32 size, Boolean useTempMemory, CWMemHandle* handle);
/* Free a memory handle */
CW_CALLBACK CWFreeMemHandle(CWPluginContext context, CWMemHandle handle);
/* Return the current size of a memory handle */
CW_CALLBACK CWGetMemHandleSize(CWPluginContext context, CWMemHandle handle, SInt32* size);
/* Resize an existing memory handle */
CW_CALLBACK CWResizeMemHandle(CWPluginContext context, CWMemHandle handle, SInt32 newSize);
/* To obtain a pointer to the block, you must lock the handle */
/* moveHi is MacOS-specific */
CW_CALLBACK CWLockMemHandle(CWPluginContext context, CWMemHandle handle, Boolean moveHi, void** ptr);
/* Unlock a memory handle, the pointer returned by locking the handle may no */
/* longer be valid */
CW_CALLBACK CWUnlockMemHandle(CWPluginContext context, CWMemHandle handle);
#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS
/* Utility function to map MacOS error codes to a CWResult code. Plugins */
/* may internally generate OSErrs, but need to return CWResult to the */
/* CodeWarrior IDE */
CW_CALLBACK CWMacOSErrToCWResult(CWPluginContext context, OSErr err);
#endif
/* Turn off the built in PP window manager while the plugin displays a dialog */
CW_CALLBACK CWPreDialog(CWPluginContext context);
/* Turn on the built in PP window manager after the plugin is through with its */
/* dialog */
CW_CALLBACK CWPostDialog(CWPluginContext context);
/* Notify the IDE that the plugin will be performing actions on a file */
CW_CALLBACK CWPreFileAction(CWPluginContext context, const CWFileSpec *theFile);
/* Notify the IDE that the plugin is finished performing actions on a file */
CW_CALLBACK CWPostFileAction(CWPluginContext context, const CWFileSpec *theFile);
CW_CALLBACK CWResolveRelativePath(CWPluginContext context, const CWRelativePath* relativePath, CWFileSpec* fileSpec, Boolean create);
CW_CALLBACK CWFindLogicalDirectory(CWPluginContext context, SInt32 selector, CWFileSpec *dirSpec);
CW_CALLBACK CWOpenFileInEditor(CWPluginContext context, const CWFileSpec *fileSpec);
#if CWPLUGIN_HOST==CWPLUGIN_HOST_SOLARIS || CWPLUGIN_HOST==CWPLUGIN_HOST_LINUX
/* Forward declarations */
struct ICodeWarriorApp;
struct ICodeWarriorProject;
struct ICodeWarriorDesign;
struct ICodeWarriorTarget;
#endif /* CWPLUGIN_HOST==CWPLUGIN_HOST_SOLARIS || CWPLUGIN_HOST==CWPLUGIN_HOST_LINUX */
/* Get the IDE application COM interface. Fails if called from any thread */
/* other than the main IDE thread, e.g. a build thread. */
CW_CALLBACK CWGetCOMApplicationInterface(CWPluginContext context, struct ICodeWarriorApp **app);
/* Get the current project COM interface. Adds a reference upon return. */
/* Only succeeds if the plugin is being called in the context of a */
/* particular project. Fails if called from any thread */
/* other than the main IDE thread, e.g. a build thread. */
CW_CALLBACK CWGetCOMProjectInterface(CWPluginContext context, struct ICodeWarriorProject **project);
/* Get the current design COM interface. Adds a reference upon return. */
/* Only succeeds if the plugin is being called in the context of a */
/* particular target that is associated with a design. */
/* Fails if called from any thread other than the main IDE thread, */
/* e.g. a build thread. */
CW_CALLBACK CWGetCOMDesignInterface(CWPluginContext context, struct ICodeWarriorDesign **design);
/* Get the current target COM interface. Adds a reference upon return. */
/* Only succeeds if the plugin is being called in the context of a */
/* particular target. Fails if called from any thread */
/* other than the main IDE thread, e.g. a build thread. */
CW_CALLBACK CWGetCOMTargetInterface(CWPluginContext context, struct ICodeWarriorTarget **target);
#if CW_USE_PRAGMA_IMPORT
#pragma import reset
#endif
#ifdef __cplusplus
}
#endif
#ifdef _MSC_VER
#pragma pack(pop)
#endif
#ifdef __MWERKS__
#pragma options align=reset
#endif
#endif /* __CWPlugins_H__ */
\ No newline at end of file diff --git a/sdk_hdrs/DropInCompilerLinker.h b/sdk_hdrs/DropInCompilerLinker.h index 8551a86..4dd87f6 100755 --- a/sdk_hdrs/DropInCompilerLinker.h +++ b/sdk_hdrs/DropInCompilerLinker.h @@ -1 +1 @@ -/*
* DropInCompilerLinker.h - Drop-In Interface for Metrowerks CodeWarriorª Compilers and Linkers
*
* Copyright © 1996 Metrowerks, Inc. All rights reserved.
*
*/
#ifndef __DROPINCOMPILERLINKER_H__
#define __DROPINCOMPILERLINKER_H__
#ifdef __MWERKS__
# pragma once
#endif
#ifndef __CWPlugins_H__
#include "CWPlugins.h"
#endif
#ifndef __COMPILERMAPPING_H__
#include "CompilerMapping.h"
#endif
#ifdef __MWERKS__
#pragma options align=mac68k
#endif
#ifdef _MSC_VER
#pragma pack(push,2)
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if CW_USE_PRAGMA_IMPORT
#pragma import on
#endif
/* this is the current version number of the API documented herein */
#define DROPINCOMPILERLINKERAPIVERSION_4 4
#define DROPINCOMPILERLINKERAPIVERSION_5 5
#define DROPINCOMPILERLINKERAPIVERSION_6 6
#define DROPINCOMPILERLINKERAPIVERSION_7 7
#define DROPINCOMPILERLINKERAPIVERSION_8 8
#define DROPINCOMPILERLINKERAPIVERSION_9 9
#define DROPINCOMPILERLINKERAPIVERSION_10 10
#define DROPINCOMPILERLINKERAPIVERSION_11 11
#define DROPINCOMPILERLINKERAPIVERSION_12 12
#define DROPINCOMPILERLINKERAPIVERSION_13 13
#define DROPINCOMPILERLINKERAPIVERSION DROPINCOMPILERLINKERAPIVERSION_13
/* deprecated request codes */
enum {
reqInitCompiler = reqInitialize, /* (called when compiler is loaded) */
reqTermCompiler = reqTerminate, /* (called when compiler is unloaded) */
reqInitLinker = reqInitialize, /* (called when linker is loaded) */
reqTermLinker = reqTerminate /* (called when linker is unloaded) */
};
/* request codes (common) */
enum {
reqTargetCompileEnded = -17, /* Sent when target's compile phase ends */
reqTargetCompileStarted = -16, /* Sent when target's compile phase starts */
reqTargetLinkEnded = -15, /* Sent when the link has ended */
reqTargetLinkStarted = -14, /* Sent when the link starts */
reqFileListBuildEnded = -13, /* Sent when the group file build ends */
reqFileListBuildStarted = -12, /* Sent when the group file build starts */
reqSubProjectBuildEnded = -11, /* Sent when subproject's build ends */
reqSubProjectBuildStarted = -10, /* Sent when subproject's build starts */
reqTargetBuildEnded = -9, /* Sent when target's build ends */
reqTargetBuildStarted = -8, /* Sent when target's build starts */
reqProjectBuildEnded = -7, /* Sent when project build ends */
reqProjectBuildStarted = -6, /* Sent when project build starts */
reqTargetLoaded = -5, /* called when the "keeps target info" flag is set */
reqTargetPrefsChanged = -4, /* called when the "keeps target info" flag is set */
reqTargetUnloaded = -3 /* called when the "keeps target info" flag is set */
};
/* requests codes (compilers) */
enum {
reqCompile = 0, /* compile/precompile/preprocess source file */
/* and return results */
reqMakeParse, /* used internally by Metrowerks */
reqCompDisassemble, /* disassemble a specific file in the project */
reqCheckSyntax, /* check syntax, but don't generate code */
reqPreprocessForDebugger /* when preprocess, don't open window w/results */
};
/* requests codes (linkers) */
enum {
reqLink = 0, /* link project and generate executable or library */
reqDisassemble, /* disassemble a specific file in the project */
reqTargetInfo, /* get info about the generated executable */
reqPreRun /* give linker a last chance to modify target info */
};
/* Returned as part of CWFileInfo to indicate the */
/* type of data pointed to by the filedata pointer */
enum {
filetypeText, /* data is text */
filetypeUnknown /* unknown type, could be precompiled header */
};
/* executable linkage types, used in CWTargetInfo.linkType */
enum {
exelinkageFlat, /* flat executable */
exelinkageSegmented, /* uses 68K code segments */
exelinkageOverlay1 /* uses overlay groups and overlays */
};
/* output file type, used in CWTargetInfo.outputType */
enum {
linkOutputNone, /* linker produces no output */
linkOutputFile, /* linker produces a file */
linkOutputDirectory /* linker produces a directory */
};
/* Constants for the targetCPU field of the CWTargetInfo struct */
enum {
targetCPU68K = CWFOURCHAR('6','8','k',' '),
targetCPUPowerPC = CWFOURCHAR('p','p','c',' '),
targetCPUi80x86 = CWFOURCHAR('8','0','8','6'),
targetCPUMips = CWFOURCHAR('m','i','p','s'),
targetCPUNECv800 = CWFOURCHAR('v','8','0','0'),
targetCPUEmbeddedPowerPC = CWFOURCHAR('e','P','P','C'),
targetCPUARM = CWFOURCHAR('a','r','m',' '),
targetCPUSparc = CWFOURCHAR('s','p','r','c'),
targetCPUIA64 = CWFOURCHAR('I','A','6','4'),
targetCPUAny = CWFOURCHAR('*','*','*','*'),
targetCPUMCORE = CWFOURCHAR('m','c','o','r'),
targetCPU_Intent = CWFOURCHAR('n','t','n','t')
};
/* Constants for the targetOS field of the CWTargetInfo struct */
enum {
targetOSMacintosh = CWFOURCHAR('m','a','c',' '),
targetOSWindows = CWFOURCHAR('w','i','n','t'),
targetOSNetware = CWFOURCHAR('n','l','m',' '),
targetOSMagicCap = CWFOURCHAR('m','c','a','p'),
targetOSOS9 = CWFOURCHAR('o','s','9',' '),
targetOSEmbeddedABI = CWFOURCHAR('E','A','B','I'),
targetOSJava = CWFOURCHAR('j','a','v','a'), /* java (no VM specification) */
targetOSJavaMS = CWFOURCHAR('j','v','m','s'), /* Microsoft VM */
targetOSJavaSun = CWFOURCHAR('j','v','s','n'), /* Sun VM */
targetOSJavaMRJ = CWFOURCHAR('j','v','m','r'), /* MRJ VM */
targetOSJavaMW = CWFOURCHAR('j','v','m','w'), /* Metrowerks VM */
targetOSPalm = CWFOURCHAR('p','a','l','m'),
targetOSGTD5 = CWFOURCHAR('g','t','d','5'),
targetOSSolaris = CWFOURCHAR('s','l','r','s'),
targetOSLinux = CWFOURCHAR('l','n','u','x'),
targetOSAny = CWFOURCHAR('*','*','*','*'),
targetOS_Intent = CWFOURCHAR('n','t','n','t')
};
/* linker flags, as used in member dropinflags of DropInFlags struct returned by linkers */
enum {
cantDisassemble = 1L << 31, /* this linker doesn't support 'Disassemble' */
isPostLinker = 1L << 30, /* this is a post linker */
linkAllowDupFileNames = 1L << 29, /* allow multiple project files with the same name */
linkMultiTargAware = 1L << 28, /* the linker can be used with multiple targets */
isPreLinker = 1L << 27, /* this is a pre linker */
linkerUsesTargetStorage = 1L << 26, /* the linker keeps storage per target */
linkerUnmangles = 1L << 25, /* The linker supports unmangling. */
magicCapLinker = 1L << 24, /* Pre- or post-linker is used for MagicCap */
linkAlwaysReload = 1L << 23, /* Always reload the linker before request */
linkRequiresProjectBuildStartedMsg = 1L << 22, /* Linker listens for a Project Build Started/Ended message */
linkRequiresTargetBuildStartedMsg = 1L << 21, /* Linker listens for a Target Build Started/Ended message */
linkRequiresSubProjectBuildStartedMsg = 1L << 20, /* Linker listens for a Sub Project Build Started/Ended message */
linkRequiresFileListBuildStartedMsg = 1L << 19, /* Linker listens for a File List Build Started/Ended message */
linkRequiresTargetLinkStartedMsg = 1L << 18, /* Linker listens for a Target Link Started/Ended message */
linkerWantsPreRunRequest = 1L << 17, /* Linker wants to be sent the pre-run request */
linkerGetTargetInfoThreadSafe = 1L << 16, /* GetTargetInfo call doesn't use any globals, etc. */
linkerUsesCaseInsensitiveSymbols = 1L << 15, /* All languages used by linker contain case insensitive browser symbols */
linkerDisasmRequiresPreprocess = 1L << 14, /* (obsolete) file must be preprocesed before being passed to linker for disasm */
linkerUsesFrameworks = 1L << 13, /* target uses frameworks; enables framework-style file searching */
linkerInitializeOnMainThread = 1L << 12 /* The Linker needs to be intialized on the main thread. */
/* remaining flags are reserved for future use and should be zero-initialized */
};
/* ways to store dependency returned as CWFileSpec in StoreObjectData */
enum {
cwAccessAbsolute,
cwAccessPathRelative,
cwAccessFileName,
cwAccessFileRelative
};
/* specifies what browser information compilers should generate */
/* they should always generate records for globals and functions */
typedef struct CWBrowseOptions {
Boolean recordClasses; /* [<-] do we record info for classes */
Boolean recordEnums; /* [<-] do we record info for enums */
Boolean recordMacros; /* [<-] do we record info for macros */
Boolean recordTypedefs; /* [<-] do we record info for typedefs */
Boolean recordConstants; /* [<-] do we record info for constants */
Boolean recordTemplates; /* [<-] do we record info for templates */
Boolean recordUndefinedFunctions; /* [<-] do we record info for undefined functions */
long reserved1; /* reserved space */
long reserved2; /* reserved space */
} CWBrowseOptions;
/* A dependency tag is associated with unit data in the StoreUnitData callback. It should */
/* change whenever unit data has changed in a way that forces its dependents to be rebuilt. */
/* Typically, it is just a checksum on the unit data. */
typedef unsigned long CWDependencyTag;
/* dependency information passed back in StoreObjectData */
typedef struct CWDependencyInfo {
long fileIndex; /* Another project entry. -1 => use fileSpec */
CWFileSpec fileSpec; /* location of file. Only used if fileIndex < 0 */
short fileSpecAccessType; /* One of cwAccessAbsolute, etc. above. Only */
/* used is specifying via fileSpec. */
short dependencyType; /* cwNormalDependency or cwInterfaceDependency. */
/* Values defined in CWPlugins.h */
} CWDependencyInfo;
/* information used when calling StoreObjectData */
typedef struct CWObjectData {
CWMemHandle objectdata; /* Handle to generated object code, */
/* resource data, or preprocessed text */
CWMemHandle browsedata; /* Handle to generated browse data */
long reserved1; /* reserved for future use, set to zero */
long codesize; /* size of generated code */
long udatasize; /* size of uninitialized data */
long idatasize; /* size of initialized data */
long compiledlines; /* number of lines of source compiled */
Boolean interfaceChanged; /* recompile interface dependents? */
long reserved2; /* reserved for future use, set to zero */
void* compilecontext; /* used internally by Metrowerks */
CWDependencyInfo* dependencies; /* optional array of dependencies */
short dependencyCount; /* overrides those collected by IDE */
CWFileSpec* objectfile; /* external object code file (i.e. .o file) */
} CWObjectData;
/* characteristics of a link target */
typedef struct CWTargetInfo {
short outputType; /* outputs file, directory, or nothing */
CWFileSpec outfile; /* generated executable file/folder spec */
CWFileSpec symfile; /* generated debug file spec */
CWFileSpec runfile; /* file to run, can be same or different from outfile */
short linkType; /* flat, segmented, or overlays */
Boolean canRun; /* "Run" can be performed on this target */
Boolean canDebug; /* "Run with Debugger" can be performed on this target */
CWDataType targetCPU; /* target CPU architecture (e.g. 68K, PowerPC, x86, MIPS)*/
CWDataType targetOS; /* target OS (e.g. MacOS, Windows, Unix) */
#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS
OSType outfileCreator; /* file creator, if outputType == linkOutputFile */
OSType outfileType; /* file type, if outputType == linkOutputFile */
OSType debuggerCreator; /* file creator of debugger for this target */
OSType runHelperCreator; /* creator of helper app to use when running this file. */
#endif
#if CWPLUGIN_HOST == CWPLUGIN_HOST_WIN32
Boolean runHelperIsRegKey; /* true if runHelperName is a registry key */
Boolean debugHelperIsRegKey;/* true if debugHelperName is a registry key */
char args[512]; /* command line arguments */
char runHelperName[512]; /* full path to the run helper executable or a reg key */
Boolean runHelperRequiresURL;/* Indicates whether the outfile must be converted to */
/* a file scheme URL before being passed to the run */
/* helper app */
char reserved2;
char debugHelperName[512];/* full path to the debug helper executable or a reg key*/
#endif
// We need the args for Solaris
#if (CWPLUGIN_HOST == CWPLUGIN_HOST_SOLARIS || CWPLUGIN_HOST == CWPLUGIN_HOST_LINUX)
char args[512]; /* command line arguments */
char runHelperName[512]; /* Relative path name from (Helper Apps) to run helper program */
Boolean runHelperRequiresURL; /* Indicates whether the outfile must be converted to */
/* a file scheme URL before being passed to the run */
/* helper app */
char reserved2[3];
char debugHelperName[512]; /* Relative path name from (Helper Apps) to debug helper */
#endif
CWFileSpec linkAgainstFile; /* file parent targets link against (e.g. lib file) */
} CWTargetInfo;
typedef struct CWUnmangleInfo {
void* targetStorage;
const char* mangledName;
char* unmangleBuff;
long unmangleBuffSize;
unsigned short browserClassID;
unsigned char browserLang;
unsigned char filler1;
} CWUnmangleInfo;
/* Types used to get compiler-specific browser symbol information. */
typedef struct CWCompilerBrSymbol {
char symName[32];
char symUIName[32];
} CWCompilerBrSymbol;
typedef struct CWCompilerBrSymbolList {
short count;
CWCompilerBrSymbol items[1];
} CWCompilerBrSymbolList;
typedef struct CWCompilerBrSymbolInfo {
void* targetStorage;
CWCompilerBrSymbolList* symList; /* [<-] Compiler should put a pointer to the read-only list here.*/
} CWCompilerBrSymbolInfo;
typedef struct CWFrameworkInfo {
CWFileSpec fileSpec; /* location of ".framework" directory */
char version[256]; /* which version directory to use; if empty use "Current" sym link */
} CWFrameworkInfo;
/*** Declaration of plugin entry points that must be implemented by non-MacOS plugins ***/
/*** It can also be implemented by a MacOS plugin to override the 'Targ' resource ***/
CWPLUGIN_ENTRY (CWPlugin_GetTargetList)(const struct CWTargetList**);
/*** Optional entry points ***/
CWPLUGIN_ENTRY (CWPlugin_GetDefaultMappingList)(const struct CWExtMapList**);
CWPLUGIN_ENTRY (Helper_Unmangle)(CWUnmangleInfo*);
CWPLUGIN_ENTRY (Helper_GetCompilerBrSymbols)(CWCompilerBrSymbolInfo*);
/*** callbacks to the IDE, in addition to those in CWPlugins.h ***/
CW_CALLBACK CWIsPrecompiling(CWPluginContext context, Boolean* isPrecompiling);
CW_CALLBACK CWIsAutoPrecompiling(CWPluginContext context, Boolean* isAutoPrecompiling);
CW_CALLBACK CWIsPreprocessing(CWPluginContext context, Boolean* isPreprocessing);
CW_CALLBACK CWIsGeneratingDebugInfo(CWPluginContext context, Boolean* isGenerating);
CW_CALLBACK CWIsCachingPrecompiledHeaders(CWPluginContext context, Boolean* isCaching);
CW_CALLBACK CWGetBrowseOptions(CWPluginContext context, CWBrowseOptions* browseOptions);
CW_CALLBACK CWGetBuildSequenceNumber(CWPluginContext context, long* sequenceNumber);
CW_CALLBACK CWGetTargetInfo(CWPluginContext context, CWTargetInfo* targetInfo);
CW_CALLBACK CWSetTargetInfo(CWPluginContext context, CWTargetInfo* targetInfo);
CW_CALLBACK CWGetTargetStorage(CWPluginContext context, void** storage);
CW_CALLBACK CWSetTargetStorage(CWPluginContext context, void* storage);
CW_CALLBACK CWGetMainFileNumber(CWPluginContext context, long* fileNumber);
CW_CALLBACK CWGetMainFileID(CWPluginContext context, short* fileID);
CW_CALLBACK CWGetMainFileSpec(CWPluginContext context, CWFileSpec* fileSpec);
CW_CALLBACK CWGetMainFileText(CWPluginContext context, const char** text, long* textLength);
CW_CALLBACK CWCachePrecompiledHeader(CWPluginContext context, const CWFileSpec* filespec, CWMemHandle pchhandle);
CW_CALLBACK CWLoadObjectData(CWPluginContext context, long whichfile, CWMemHandle* objectdata);
CW_CALLBACK CWFreeObjectData(CWPluginContext context, long whichfile, CWMemHandle objectdata);
CW_CALLBACK CWStoreObjectData(CWPluginContext context, long whichfile, CWObjectData* object);
CW_CALLBACK CWGetSuggestedObjectFileSpec(CWPluginContext context, long whichfile, CWFileSpec* fileSpec);
CW_CALLBACK CWGetStoredObjectFileSpec(CWPluginContext context, long whichfile, CWFileSpec* fileSpec);
CW_CALLBACK CWDisplayLines(CWPluginContext context, long nlines);
CW_CALLBACK CWBeginSubCompile(CWPluginContext context, long whichfile, CWPluginContext* subContext);
CW_CALLBACK CWEndSubCompile(CWPluginContext subContext);
CW_CALLBACK CWGetPrecompiledHeaderSpec(CWPluginContext context, CWFileSpec *pchspec, const char *target);
CW_CALLBACK CWGetResourceFile(CWPluginContext context, CWFileSpec* filespec);
CW_CALLBACK CWPutResourceFile(CWPluginContext context, const char* prompt, const char* name, CWFileSpec* filespec);
/* Metrowerks Pascal support */
CW_CALLBACK CWLookUpUnit(CWPluginContext context, const char* name, Boolean isdependency, const void** unitdata, long* unitdatalength);
CW_CALLBACK CWSBMfiles(CWPluginContext context, short libref);
CW_CALLBACK CWStoreUnit(CWPluginContext context, const char* unitname, CWMemHandle unitdata, CWDependencyTag dependencytag);
CW_CALLBACK CWReleaseUnit(CWPluginContext context, void* unitdata);
CW_CALLBACK CWUnitNameToFileName(CWPluginContext context, const char* unitname, char* filename);
/* obsolete, for MacOS backward compatibility only */
#if CWPLUGIN_API == CWPLUGIN_API_MACOS
CW_CALLBACK CWOSAlert(CWPluginContext context, const char* message, OSErr errorcode);
CW_CALLBACK CWOSErrorMessage(CWPluginContext context, const char *msg, OSErr errorcode);
#endif
CW_CALLBACK CWGetModifiedFiles(CWPluginContext context, long* modifiedFileCount, const long** modifiedFiles);
/* Get information from the "Runtime Settings" panel */
CW_CALLBACK CWGetCommandLineArgs(CWPluginContext context, const char** commandLineArgs);
CW_CALLBACK CWGetWorkingDirectory(CWPluginContext context, CWFileSpec* workingDirectorySpec);
CW_CALLBACK CWGetEnvironmentVariableCount(CWPluginContext context, long* count);
CW_CALLBACK CWGetEnvironmentVariable(CWPluginContext context, long index, const char** name, const char** value);
CW_CALLBACK CWGetFrameworkCount(CWPluginContext context, long* frameworkCount);
CW_CALLBACK CWGetFrameworkInfo(CWPluginContext context, long whichFramework, CWFrameworkInfo* frameworkInfo);
CW_CALLBACK CWGetFrameworkSharedLibrary(CWPluginContext context, long whichFramework, CWFileSpec* frameworkSharedLibrary);
#if CW_USE_PRAGMA_IMPORT
#pragma import reset
#endif
#ifdef __cplusplus
}
#endif
#ifdef _MSC_VER
#pragma pack(pop,2)
#endif
#ifdef __MWERKS__
#pragma options align=reset
#endif
#endif /* __DROPINCOMPILERLINKER_H__ */
\ No newline at end of file +/*
* DropInCompilerLinker.h - Drop-In Interface for Metrowerks CodeWarrior� Compilers and Linkers
*
* Copyright � 1996 Metrowerks, Inc. All rights reserved.
*
*/
#ifndef __DROPINCOMPILERLINKER_H__
#define __DROPINCOMPILERLINKER_H__
#ifdef __MWERKS__
# pragma once
#endif
#ifndef __CWPlugins_H__
#include "CWPlugins.h"
#endif
#ifndef __COMPILERMAPPING_H__
#include "CompilerMapping.h"
#endif
#ifdef __MWERKS__
#pragma options align=mac68k
#endif
#ifdef _MSC_VER
#pragma pack(push,2)
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if CW_USE_PRAGMA_IMPORT
#pragma import on
#endif
/* this is the current version number of the API documented herein */
#define DROPINCOMPILERLINKERAPIVERSION_4 4
#define DROPINCOMPILERLINKERAPIVERSION_5 5
#define DROPINCOMPILERLINKERAPIVERSION_6 6
#define DROPINCOMPILERLINKERAPIVERSION_7 7
#define DROPINCOMPILERLINKERAPIVERSION_8 8
#define DROPINCOMPILERLINKERAPIVERSION_9 9
#define DROPINCOMPILERLINKERAPIVERSION_10 10
#define DROPINCOMPILERLINKERAPIVERSION_11 11
#define DROPINCOMPILERLINKERAPIVERSION_12 12
#define DROPINCOMPILERLINKERAPIVERSION_13 13
#define DROPINCOMPILERLINKERAPIVERSION DROPINCOMPILERLINKERAPIVERSION_13
/* deprecated request codes */
enum {
reqInitCompiler = reqInitialize, /* (called when compiler is loaded) */
reqTermCompiler = reqTerminate, /* (called when compiler is unloaded) */
reqInitLinker = reqInitialize, /* (called when linker is loaded) */
reqTermLinker = reqTerminate /* (called when linker is unloaded) */
};
/* request codes (common) */
enum {
reqTargetCompileEnded = -17, /* Sent when target's compile phase ends */
reqTargetCompileStarted = -16, /* Sent when target's compile phase starts */
reqTargetLinkEnded = -15, /* Sent when the link has ended */
reqTargetLinkStarted = -14, /* Sent when the link starts */
reqFileListBuildEnded = -13, /* Sent when the group file build ends */
reqFileListBuildStarted = -12, /* Sent when the group file build starts */
reqSubProjectBuildEnded = -11, /* Sent when subproject's build ends */
reqSubProjectBuildStarted = -10, /* Sent when subproject's build starts */
reqTargetBuildEnded = -9, /* Sent when target's build ends */
reqTargetBuildStarted = -8, /* Sent when target's build starts */
reqProjectBuildEnded = -7, /* Sent when project build ends */
reqProjectBuildStarted = -6, /* Sent when project build starts */
reqTargetLoaded = -5, /* called when the "keeps target info" flag is set */
reqTargetPrefsChanged = -4, /* called when the "keeps target info" flag is set */
reqTargetUnloaded = -3 /* called when the "keeps target info" flag is set */
};
/* requests codes (compilers) */
enum {
reqCompile = 0, /* compile/precompile/preprocess source file */
/* and return results */
reqMakeParse, /* used internally by Metrowerks */
reqCompDisassemble, /* disassemble a specific file in the project */
reqCheckSyntax, /* check syntax, but don't generate code */
reqPreprocessForDebugger /* when preprocess, don't open window w/results */
};
/* requests codes (linkers) */
enum {
reqLink = 0, /* link project and generate executable or library */
reqDisassemble, /* disassemble a specific file in the project */
reqTargetInfo, /* get info about the generated executable */
reqPreRun /* give linker a last chance to modify target info */
};
/* Returned as part of CWFileInfo to indicate the */
/* type of data pointed to by the filedata pointer */
enum {
filetypeText, /* data is text */
filetypeUnknown /* unknown type, could be precompiled header */
};
/* executable linkage types, used in CWTargetInfo.linkType */
enum {
exelinkageFlat, /* flat executable */
exelinkageSegmented, /* uses 68K code segments */
exelinkageOverlay1 /* uses overlay groups and overlays */
};
/* output file type, used in CWTargetInfo.outputType */
enum {
linkOutputNone, /* linker produces no output */
linkOutputFile, /* linker produces a file */
linkOutputDirectory /* linker produces a directory */
};
/* Constants for the targetCPU field of the CWTargetInfo struct */
enum {
targetCPU68K = CWFOURCHAR('6','8','k',' '),
targetCPUPowerPC = CWFOURCHAR('p','p','c',' '),
targetCPUi80x86 = CWFOURCHAR('8','0','8','6'),
targetCPUMips = CWFOURCHAR('m','i','p','s'),
targetCPUNECv800 = CWFOURCHAR('v','8','0','0'),
targetCPUEmbeddedPowerPC = CWFOURCHAR('e','P','P','C'),
targetCPUARM = CWFOURCHAR('a','r','m',' '),
targetCPUSparc = CWFOURCHAR('s','p','r','c'),
targetCPUIA64 = CWFOURCHAR('I','A','6','4'),
targetCPUAny = CWFOURCHAR('*','*','*','*'),
targetCPUMCORE = CWFOURCHAR('m','c','o','r'),
targetCPU_Intent = CWFOURCHAR('n','t','n','t')
};
/* Constants for the targetOS field of the CWTargetInfo struct */
enum {
targetOSMacintosh = CWFOURCHAR('m','a','c',' '),
targetOSWindows = CWFOURCHAR('w','i','n','t'),
targetOSNetware = CWFOURCHAR('n','l','m',' '),
targetOSMagicCap = CWFOURCHAR('m','c','a','p'),
targetOSOS9 = CWFOURCHAR('o','s','9',' '),
targetOSEmbeddedABI = CWFOURCHAR('E','A','B','I'),
targetOSJava = CWFOURCHAR('j','a','v','a'), /* java (no VM specification) */
targetOSJavaMS = CWFOURCHAR('j','v','m','s'), /* Microsoft VM */
targetOSJavaSun = CWFOURCHAR('j','v','s','n'), /* Sun VM */
targetOSJavaMRJ = CWFOURCHAR('j','v','m','r'), /* MRJ VM */
targetOSJavaMW = CWFOURCHAR('j','v','m','w'), /* Metrowerks VM */
targetOSPalm = CWFOURCHAR('p','a','l','m'),
targetOSGTD5 = CWFOURCHAR('g','t','d','5'),
targetOSSolaris = CWFOURCHAR('s','l','r','s'),
targetOSLinux = CWFOURCHAR('l','n','u','x'),
targetOSAny = CWFOURCHAR('*','*','*','*'),
targetOS_Intent = CWFOURCHAR('n','t','n','t')
};
/* linker flags, as used in member dropinflags of DropInFlags struct returned by linkers */
enum {
cantDisassemble = 1L << 31, /* this linker doesn't support 'Disassemble' */
isPostLinker = 1L << 30, /* this is a post linker */
linkAllowDupFileNames = 1L << 29, /* allow multiple project files with the same name */
linkMultiTargAware = 1L << 28, /* the linker can be used with multiple targets */
isPreLinker = 1L << 27, /* this is a pre linker */
linkerUsesTargetStorage = 1L << 26, /* the linker keeps storage per target */
linkerUnmangles = 1L << 25, /* The linker supports unmangling. */
magicCapLinker = 1L << 24, /* Pre- or post-linker is used for MagicCap */
linkAlwaysReload = 1L << 23, /* Always reload the linker before request */
linkRequiresProjectBuildStartedMsg = 1L << 22, /* Linker listens for a Project Build Started/Ended message */
linkRequiresTargetBuildStartedMsg = 1L << 21, /* Linker listens for a Target Build Started/Ended message */
linkRequiresSubProjectBuildStartedMsg = 1L << 20, /* Linker listens for a Sub Project Build Started/Ended message */
linkRequiresFileListBuildStartedMsg = 1L << 19, /* Linker listens for a File List Build Started/Ended message */
linkRequiresTargetLinkStartedMsg = 1L << 18, /* Linker listens for a Target Link Started/Ended message */
linkerWantsPreRunRequest = 1L << 17, /* Linker wants to be sent the pre-run request */
linkerGetTargetInfoThreadSafe = 1L << 16, /* GetTargetInfo call doesn't use any globals, etc. */
linkerUsesCaseInsensitiveSymbols = 1L << 15, /* All languages used by linker contain case insensitive browser symbols */
linkerDisasmRequiresPreprocess = 1L << 14, /* (obsolete) file must be preprocesed before being passed to linker for disasm */
linkerUsesFrameworks = 1L << 13, /* target uses frameworks; enables framework-style file searching */
linkerInitializeOnMainThread = 1L << 12 /* The Linker needs to be intialized on the main thread. */
/* remaining flags are reserved for future use and should be zero-initialized */
};
/* ways to store dependency returned as CWFileSpec in StoreObjectData */
enum {
cwAccessAbsolute,
cwAccessPathRelative,
cwAccessFileName,
cwAccessFileRelative
};
/* specifies what browser information compilers should generate */
/* they should always generate records for globals and functions */
typedef struct CWBrowseOptions {
Boolean recordClasses; /* [<-] do we record info for classes */
Boolean recordEnums; /* [<-] do we record info for enums */
Boolean recordMacros; /* [<-] do we record info for macros */
Boolean recordTypedefs; /* [<-] do we record info for typedefs */
Boolean recordConstants; /* [<-] do we record info for constants */
Boolean recordTemplates; /* [<-] do we record info for templates */
Boolean recordUndefinedFunctions; /* [<-] do we record info for undefined functions */
SInt32 reserved1; /* reserved space */
SInt32 reserved2; /* reserved space */
} CWBrowseOptions;
/* A dependency tag is associated with unit data in the StoreUnitData callback. It should */
/* change whenever unit data has changed in a way that forces its dependents to be rebuilt. */
/* Typically, it is just a checksum on the unit data. */
typedef UInt32 CWDependencyTag;
/* dependency information passed back in StoreObjectData */
typedef struct CWDependencyInfo {
SInt32 fileIndex; /* Another project entry. -1 => use fileSpec */
CWFileSpec fileSpec; /* location of file. Only used if fileIndex < 0 */
short fileSpecAccessType; /* One of cwAccessAbsolute, etc. above. Only */
/* used is specifying via fileSpec. */
short dependencyType; /* cwNormalDependency or cwInterfaceDependency. */
/* Values defined in CWPlugins.h */
} CWDependencyInfo;
/* information used when calling StoreObjectData */
typedef struct CWObjectData {
CWMemHandle objectdata; /* Handle to generated object code, */
/* resource data, or preprocessed text */
CWMemHandle browsedata; /* Handle to generated browse data */
SInt32 reserved1; /* reserved for future use, set to zero */
SInt32 codesize; /* size of generated code */
SInt32 udatasize; /* size of uninitialized data */
SInt32 idatasize; /* size of initialized data */
SInt32 compiledlines; /* number of lines of source compiled */
Boolean interfaceChanged; /* recompile interface dependents? */
SInt32 reserved2; /* reserved for future use, set to zero */
void* compilecontext; /* used internally by Metrowerks */
CWDependencyInfo* dependencies; /* optional array of dependencies */
short dependencyCount; /* overrides those collected by IDE */
CWFileSpec* objectfile; /* external object code file (i.e. .o file) */
} CWObjectData;
/* characteristics of a link target */
typedef struct CWTargetInfo {
short outputType; /* outputs file, directory, or nothing */
CWFileSpec outfile; /* generated executable file/folder spec */
CWFileSpec symfile; /* generated debug file spec */
CWFileSpec runfile; /* file to run, can be same or different from outfile */
short linkType; /* flat, segmented, or overlays */
Boolean canRun; /* "Run" can be performed on this target */
Boolean canDebug; /* "Run with Debugger" can be performed on this target */
CWDataType targetCPU; /* target CPU architecture (e.g. 68K, PowerPC, x86, MIPS)*/
CWDataType targetOS; /* target OS (e.g. MacOS, Windows, Unix) */
#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS
OSType outfileCreator; /* file creator, if outputType == linkOutputFile */
OSType outfileType; /* file type, if outputType == linkOutputFile */
OSType debuggerCreator; /* file creator of debugger for this target */
OSType runHelperCreator; /* creator of helper app to use when running this file. */
#endif
#if CWPLUGIN_HOST == CWPLUGIN_HOST_WIN32
Boolean runHelperIsRegKey; /* true if runHelperName is a registry key */
Boolean debugHelperIsRegKey;/* true if debugHelperName is a registry key */
char args[512]; /* command line arguments */
char runHelperName[512]; /* full path to the run helper executable or a reg key */
Boolean runHelperRequiresURL;/* Indicates whether the outfile must be converted to */
/* a file scheme URL before being passed to the run */
/* helper app */
char reserved2;
char debugHelperName[512];/* full path to the debug helper executable or a reg key*/
#endif
// We need the args for Solaris
#if (CWPLUGIN_HOST == CWPLUGIN_HOST_SOLARIS || CWPLUGIN_HOST == CWPLUGIN_HOST_LINUX)
char args[512]; /* command line arguments */
char runHelperName[512]; /* Relative path name from (Helper Apps) to run helper program */
Boolean runHelperRequiresURL; /* Indicates whether the outfile must be converted to */
/* a file scheme URL before being passed to the run */
/* helper app */
char reserved2[3];
char debugHelperName[512]; /* Relative path name from (Helper Apps) to debug helper */
#endif
CWFileSpec linkAgainstFile; /* file parent targets link against (e.g. lib file) */
} CWTargetInfo;
typedef struct CWUnmangleInfo {
void* targetStorage;
const char* mangledName;
char* unmangleBuff;
SInt32 unmangleBuffSize;
unsigned short browserClassID;
unsigned char browserLang;
unsigned char filler1;
} CWUnmangleInfo;
/* Types used to get compiler-specific browser symbol information. */
typedef struct CWCompilerBrSymbol {
char symName[32];
char symUIName[32];
} CWCompilerBrSymbol;
typedef struct CWCompilerBrSymbolList {
short count;
CWCompilerBrSymbol items[1];
} CWCompilerBrSymbolList;
typedef struct CWCompilerBrSymbolInfo {
void* targetStorage;
CWCompilerBrSymbolList* symList; /* [<-] Compiler should put a pointer to the read-only list here.*/
} CWCompilerBrSymbolInfo;
typedef struct CWFrameworkInfo {
CWFileSpec fileSpec; /* location of ".framework" directory */
char version[256]; /* which version directory to use; if empty use "Current" sym link */
} CWFrameworkInfo;
/*** Declaration of plugin entry points that must be implemented by non-MacOS plugins ***/
/*** It can also be implemented by a MacOS plugin to override the 'Targ' resource ***/
CWPLUGIN_ENTRY (CWPlugin_GetTargetList)(const struct CWTargetList**);
/*** Optional entry points ***/
CWPLUGIN_ENTRY (CWPlugin_GetDefaultMappingList)(const struct CWExtMapList**);
CWPLUGIN_ENTRY (Helper_Unmangle)(CWUnmangleInfo*);
CWPLUGIN_ENTRY (Helper_GetCompilerBrSymbols)(CWCompilerBrSymbolInfo*);
/*** callbacks to the IDE, in addition to those in CWPlugins.h ***/
CW_CALLBACK CWIsPrecompiling(CWPluginContext context, Boolean* isPrecompiling);
CW_CALLBACK CWIsAutoPrecompiling(CWPluginContext context, Boolean* isAutoPrecompiling);
CW_CALLBACK CWIsPreprocessing(CWPluginContext context, Boolean* isPreprocessing);
CW_CALLBACK CWIsGeneratingDebugInfo(CWPluginContext context, Boolean* isGenerating);
CW_CALLBACK CWIsCachingPrecompiledHeaders(CWPluginContext context, Boolean* isCaching);
CW_CALLBACK CWGetBrowseOptions(CWPluginContext context, CWBrowseOptions* browseOptions);
CW_CALLBACK CWGetBuildSequenceNumber(CWPluginContext context, SInt32* sequenceNumber);
CW_CALLBACK CWGetTargetInfo(CWPluginContext context, CWTargetInfo* targetInfo);
CW_CALLBACK CWSetTargetInfo(CWPluginContext context, CWTargetInfo* targetInfo);
CW_CALLBACK CWGetTargetStorage(CWPluginContext context, void** storage);
CW_CALLBACK CWSetTargetStorage(CWPluginContext context, void* storage);
CW_CALLBACK CWGetMainFileNumber(CWPluginContext context, SInt32* fileNumber);
CW_CALLBACK CWGetMainFileID(CWPluginContext context, short* fileID);
CW_CALLBACK CWGetMainFileSpec(CWPluginContext context, CWFileSpec* fileSpec);
CW_CALLBACK CWGetMainFileText(CWPluginContext context, const char** text, SInt32* textLength);
CW_CALLBACK CWCachePrecompiledHeader(CWPluginContext context, const CWFileSpec* filespec, CWMemHandle pchhandle);
CW_CALLBACK CWLoadObjectData(CWPluginContext context, SInt32 whichfile, CWMemHandle* objectdata);
CW_CALLBACK CWFreeObjectData(CWPluginContext context, SInt32 whichfile, CWMemHandle objectdata);
CW_CALLBACK CWStoreObjectData(CWPluginContext context, SInt32 whichfile, CWObjectData* object);
CW_CALLBACK CWGetSuggestedObjectFileSpec(CWPluginContext context, SInt32 whichfile, CWFileSpec* fileSpec);
CW_CALLBACK CWGetStoredObjectFileSpec(CWPluginContext context, SInt32 whichfile, CWFileSpec* fileSpec);
CW_CALLBACK CWDisplayLines(CWPluginContext context, SInt32 nlines);
CW_CALLBACK CWBeginSubCompile(CWPluginContext context, SInt32 whichfile, CWPluginContext* subContext);
CW_CALLBACK CWEndSubCompile(CWPluginContext subContext);
CW_CALLBACK CWGetPrecompiledHeaderSpec(CWPluginContext context, CWFileSpec *pchspec, const char *target);
CW_CALLBACK CWGetResourceFile(CWPluginContext context, CWFileSpec* filespec);
CW_CALLBACK CWPutResourceFile(CWPluginContext context, const char* prompt, const char* name, CWFileSpec* filespec);
/* Metrowerks Pascal support */
CW_CALLBACK CWLookUpUnit(CWPluginContext context, const char* name, Boolean isdependency, const void** unitdata, SInt32* unitdatalength);
CW_CALLBACK CWSBMfiles(CWPluginContext context, short libref);
CW_CALLBACK CWStoreUnit(CWPluginContext context, const char* unitname, CWMemHandle unitdata, CWDependencyTag dependencytag);
CW_CALLBACK CWReleaseUnit(CWPluginContext context, void* unitdata);
CW_CALLBACK CWUnitNameToFileName(CWPluginContext context, const char* unitname, char* filename);
/* obsolete, for MacOS backward compatibility only */
#if CWPLUGIN_API == CWPLUGIN_API_MACOS
CW_CALLBACK CWOSAlert(CWPluginContext context, const char* message, OSErr errorcode);
CW_CALLBACK CWOSErrorMessage(CWPluginContext context, const char *msg, OSErr errorcode);
#endif
CW_CALLBACK CWGetModifiedFiles(CWPluginContext context, SInt32* modifiedFileCount, const SInt32** modifiedFiles);
/* Get information from the "Runtime Settings" panel */
CW_CALLBACK CWGetCommandLineArgs(CWPluginContext context, const char** commandLineArgs);
CW_CALLBACK CWGetWorkingDirectory(CWPluginContext context, CWFileSpec* workingDirectorySpec);
CW_CALLBACK CWGetEnvironmentVariableCount(CWPluginContext context, SInt32* count);
CW_CALLBACK CWGetEnvironmentVariable(CWPluginContext context, SInt32 index, const char** name, const char** value);
CW_CALLBACK CWGetFrameworkCount(CWPluginContext context, SInt32* frameworkCount);
CW_CALLBACK CWGetFrameworkInfo(CWPluginContext context, SInt32 whichFramework, CWFrameworkInfo* frameworkInfo);
CW_CALLBACK CWGetFrameworkSharedLibrary(CWPluginContext context, SInt32 whichFramework, CWFileSpec* frameworkSharedLibrary);
#if CW_USE_PRAGMA_IMPORT
#pragma import reset
#endif
#ifdef __cplusplus
}
#endif
#ifdef _MSC_VER
#pragma pack(pop,2)
#endif
#ifdef __MWERKS__
#pragma options align=reset
#endif
#endif /* __DROPINCOMPILERLINKER_H__ */
\ No newline at end of file diff --git a/unsorted/IO.c b/unsorted/IO.c new file mode 100644 index 0000000..7ef3cb1 --- /dev/null +++ b/unsorted/IO.c @@ -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; +} diff --git a/unsorted/ParserErrors.c b/unsorted/ParserErrors.c new file mode 100644 index 0000000..172e04c --- /dev/null +++ b/unsorted/ParserErrors.c @@ -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); +} diff --git a/ParserFace.c b/unsorted/ParserFace.c index 7ce84e5..24f3213 100644 --- a/ParserFace.c +++ b/unsorted/ParserFace.c @@ -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 - return result; + 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; + + 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; + } + } - // TODO pTool + 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); diff --git a/unsorted/ParserHelpers-cc.c b/unsorted/ParserHelpers-cc.c new file mode 100644 index 0000000..d56fe4d --- /dev/null +++ b/unsorted/ParserHelpers-cc.c @@ -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; +} diff --git a/unsorted/ParserHelpers.c b/unsorted/ParserHelpers.c new file mode 100644 index 0000000..c8d4c55 --- /dev/null +++ b/unsorted/ParserHelpers.c @@ -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; +} diff --git a/unsorted/Projects.c b/unsorted/Projects.c new file mode 100644 index 0000000..72b06b1 --- /dev/null +++ b/unsorted/Projects.c @@ -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; +} diff --git a/unsorted/StaticParserGlue.c b/unsorted/StaticParserGlue.c new file mode 100644 index 0000000..4673c27 --- /dev/null +++ b/unsorted/StaticParserGlue.c @@ -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); +} diff --git a/unsorted/Targets.c b/unsorted/Targets.c new file mode 100644 index 0000000..b4307ff --- /dev/null +++ b/unsorted/Targets.c @@ -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; +} diff --git a/unsorted/ToolHelpers-cc.c b/unsorted/ToolHelpers-cc.c new file mode 100644 index 0000000..dd0bc92 --- /dev/null +++ b/unsorted/ToolHelpers-cc.c @@ -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; +} diff --git a/unsorted/ToolHelpers.c b/unsorted/ToolHelpers.c new file mode 100644 index 0000000..1942072 --- /dev/null +++ b/unsorted/ToolHelpers.c @@ -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; +} diff --git a/unsorted/uContext1.cpp b/unsorted/uContext1.cpp new file mode 100644 index 0000000..7ac712d --- /dev/null +++ b/unsorted/uContext1.cpp @@ -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; + } +} + diff --git a/unsorted/uContextCL.cpp b/unsorted/uContextCL.cpp new file mode 100644 index 0000000..2c0a0c7 --- /dev/null +++ b/unsorted/uContextCL.cpp @@ -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; +} diff --git a/unsorted/uContextParser.cpp b/unsorted/uContextParser.cpp new file mode 100644 index 0000000..be1aa0a --- /dev/null +++ b/unsorted/uContextParser.cpp @@ -0,0 +1,207 @@ +#include "plugin_internal.h" + +static CWParserContext *GetContext(CWPluginContext context) { + if (context && (context->pluginType == CWDROPINPARSERTYPE)) + return static_cast<CWParserContext *>(context); + else + return 0; +} + +CW_CALLBACK CWParserGetBuildDate(CWPluginContext context, const char **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); +} diff --git a/unsorted/uContextSecret.cpp b/unsorted/uContextSecret.cpp new file mode 100644 index 0000000..b33ca81 --- /dev/null +++ b/unsorted/uContextSecret.cpp @@ -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; +} |