mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-05 08:09:15 +00:00
NPL, removed Disassembly code (moved to linker), now using CWStoreObjectData() to associate output file with compilation. This lets CodeWarrior delete the file when objects are removed, and regenerate when file is deleted externally.
This commit is contained in:
parent
29cc2584f2
commit
3d786077ea
@ -1,3 +1,20 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
mac_xpidl.cpp
|
||||
|
||||
@ -43,6 +60,7 @@ CWPluginContext gPluginContext;
|
||||
/* local variables */
|
||||
static CWFileSpec gSourceFile;
|
||||
static char* gSourcePath = NULL;
|
||||
static CWFileSpec gOutputFile;
|
||||
|
||||
extern "C" {
|
||||
pascal short xpidl_compiler(CWPluginContext context);
|
||||
@ -136,6 +154,11 @@ static CWResult Compile(CWPluginContext context)
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
|
||||
long fileNum;
|
||||
err = CWGetMainFileNumber(context, &fileNum);
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
|
||||
// the compiler only understands full path names.
|
||||
gSourcePath = p2c_strdup(gSourceFile.name);
|
||||
if (gSourcePath == NULL)
|
||||
@ -153,85 +176,52 @@ static CWResult Compile(CWPluginContext context)
|
||||
argv[argc++] = gSourcePath;
|
||||
|
||||
try {
|
||||
xpidl_main(argc, argv);
|
||||
if (xpidl_main(argc, argv) != 0)
|
||||
err = cwErrRequestFailed;
|
||||
} catch (int status) {
|
||||
// evidently the good old exit function got called.
|
||||
err = cwErrRequestFailed;
|
||||
}
|
||||
|
||||
// if the compilation succeeded, tell CodeWarrior about the output file.
|
||||
// this ensures several things: 1. if the output file is deleted by the user,
|
||||
// then the IDE will know to recompile it, which is good for dirty builds,
|
||||
// where the output files may be hand deleted; 2. if the user elects to remove
|
||||
// objects, the output files are deleted. Thanks to robv@metrowerks.com for
|
||||
// pointing this new CWPro4 API out.
|
||||
if (err == cwNoErr) {
|
||||
CWObjectData objectData;
|
||||
BlockZero(&objectData, sizeof(objectData));
|
||||
|
||||
// for fun, show how large the output file is in the data area.
|
||||
long dataSize, rsrcSize;
|
||||
if (FSpGetFileSize(&gOutputFile, &dataSize, &rsrcSize) == noErr)
|
||||
objectData.idatasize = dataSize;
|
||||
|
||||
// tell the IDE that this file was generated by the compiler.
|
||||
objectData.objectfile = &gOutputFile;
|
||||
|
||||
err = CWStoreObjectData(context, fileNum, &objectData);
|
||||
}
|
||||
|
||||
delete[] gSourcePath;
|
||||
gSourcePath = NULL;
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
// #define USE_FULL_PATH
|
||||
|
||||
static CWResult Disassemble(CWPluginContext context)
|
||||
{
|
||||
#if 0
|
||||
CWFileSpec sourceFile;
|
||||
CWResult err = CWGetMainFileSpec(context, &sourceFile);
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
|
||||
char* sourceName = p2c_strdup(sourceFile.name);
|
||||
char* dot = strrchr(sourceName, '.');
|
||||
if (dot != NULL)
|
||||
strcpy(dot + 1, "xpt");
|
||||
|
||||
err = CWGetOutputFileDirectory(gPluginContext, &gSourceFile);
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
|
||||
c2p_strcpy(gSourceFile.name, sourceName);
|
||||
|
||||
#ifdef USE_FULL_PATH
|
||||
gSourcePath = full_path_to(gSourceFile);
|
||||
#else
|
||||
gSourcePath = sourceName;
|
||||
#endif
|
||||
|
||||
XPIDLSettings settings = { kXPIDLSettingsVersion, kXPIDLModeTypelib, false, false };
|
||||
GetSettings(context, settings);
|
||||
|
||||
// build an argument list and call xpt_dump.
|
||||
int argc = 1;
|
||||
char* argv[] = { "xpt_dump", NULL, NULL, NULL };
|
||||
if (settings.verbose) argv[argc++] = "-v";
|
||||
argv[argc++] = gSourcePath;
|
||||
|
||||
try {
|
||||
xptdump_main(argc, argv);
|
||||
} catch (int status) {
|
||||
// evidently the good old exit function got called.
|
||||
err = cwErrRequestFailed;
|
||||
}
|
||||
|
||||
delete[] gSourcePath;
|
||||
gSourcePath = NULL;
|
||||
|
||||
if (err == noErr) {
|
||||
CWNewTextDocumentInfo info = {
|
||||
NULL,
|
||||
mac_console_handle,
|
||||
false
|
||||
};
|
||||
CWResizeMemHandle(context, mac_console_handle, mac_console_count);
|
||||
err = CWCreateNewTextDocument(context, &info);
|
||||
}
|
||||
|
||||
return (err);
|
||||
#else
|
||||
// the disassembly code has moved to the linker.
|
||||
return noErr;
|
||||
#endif
|
||||
}
|
||||
|
||||
static CWResult LocateFile(CWPluginContext context, const char* filename, FSSpec& file)
|
||||
{
|
||||
/* prefill the CWFileInfo struct */
|
||||
CWFileInfo fileinfo;
|
||||
memset(&fileinfo, 0, sizeof(fileinfo));
|
||||
BlockZero(&fileinfo, sizeof(fileinfo));
|
||||
// memset(&fileinfo, 0, sizeof(fileinfo));
|
||||
fileinfo.fullsearch = true;
|
||||
fileinfo.suppressload = true;
|
||||
fileinfo.dependencyType = cwNormalDependency;
|
||||
@ -265,15 +255,12 @@ FILE* std::fopen(const char* filename, const char *mode)
|
||||
if (filename == gSourcePath || strcmp(filename, gSourcePath) == 0) {
|
||||
// opening the main source file.
|
||||
filespec = gSourceFile;
|
||||
} else if (strncmp(mode, "w", 1) == 0) {
|
||||
// if an output file, try opening it in the current's project's
|
||||
CWFileSpec outputDir;
|
||||
CWResult err = CWGetOutputFileDirectory(gPluginContext, &outputDir);
|
||||
} else if (mode[0] == 'w') {
|
||||
// if an output file, try opening it in the current project's output directory.
|
||||
CWResult err = CWGetOutputFileDirectory(gPluginContext, &filespec);
|
||||
if (err == noErr) {
|
||||
c2p_strcpy(filespec.name, filename);
|
||||
filespec.vRefNum = outputDir.vRefNum;
|
||||
Boolean isDirectory;
|
||||
err = FSpGetDirectoryID(&outputDir, &filespec.parID, &isDirectory);
|
||||
gOutputFile = filespec;
|
||||
}
|
||||
} else {
|
||||
// an input file, use CodeWarrior's search paths to find the named source file.
|
||||
|
@ -1,3 +1,20 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
mac_xpidl.cpp
|
||||
|
||||
@ -43,6 +60,7 @@ CWPluginContext gPluginContext;
|
||||
/* local variables */
|
||||
static CWFileSpec gSourceFile;
|
||||
static char* gSourcePath = NULL;
|
||||
static CWFileSpec gOutputFile;
|
||||
|
||||
extern "C" {
|
||||
pascal short xpidl_compiler(CWPluginContext context);
|
||||
@ -136,6 +154,11 @@ static CWResult Compile(CWPluginContext context)
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
|
||||
long fileNum;
|
||||
err = CWGetMainFileNumber(context, &fileNum);
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
|
||||
// the compiler only understands full path names.
|
||||
gSourcePath = p2c_strdup(gSourceFile.name);
|
||||
if (gSourcePath == NULL)
|
||||
@ -153,85 +176,52 @@ static CWResult Compile(CWPluginContext context)
|
||||
argv[argc++] = gSourcePath;
|
||||
|
||||
try {
|
||||
xpidl_main(argc, argv);
|
||||
if (xpidl_main(argc, argv) != 0)
|
||||
err = cwErrRequestFailed;
|
||||
} catch (int status) {
|
||||
// evidently the good old exit function got called.
|
||||
err = cwErrRequestFailed;
|
||||
}
|
||||
|
||||
// if the compilation succeeded, tell CodeWarrior about the output file.
|
||||
// this ensures several things: 1. if the output file is deleted by the user,
|
||||
// then the IDE will know to recompile it, which is good for dirty builds,
|
||||
// where the output files may be hand deleted; 2. if the user elects to remove
|
||||
// objects, the output files are deleted. Thanks to robv@metrowerks.com for
|
||||
// pointing this new CWPro4 API out.
|
||||
if (err == cwNoErr) {
|
||||
CWObjectData objectData;
|
||||
BlockZero(&objectData, sizeof(objectData));
|
||||
|
||||
// for fun, show how large the output file is in the data area.
|
||||
long dataSize, rsrcSize;
|
||||
if (FSpGetFileSize(&gOutputFile, &dataSize, &rsrcSize) == noErr)
|
||||
objectData.idatasize = dataSize;
|
||||
|
||||
// tell the IDE that this file was generated by the compiler.
|
||||
objectData.objectfile = &gOutputFile;
|
||||
|
||||
err = CWStoreObjectData(context, fileNum, &objectData);
|
||||
}
|
||||
|
||||
delete[] gSourcePath;
|
||||
gSourcePath = NULL;
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
// #define USE_FULL_PATH
|
||||
|
||||
static CWResult Disassemble(CWPluginContext context)
|
||||
{
|
||||
#if 0
|
||||
CWFileSpec sourceFile;
|
||||
CWResult err = CWGetMainFileSpec(context, &sourceFile);
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
|
||||
char* sourceName = p2c_strdup(sourceFile.name);
|
||||
char* dot = strrchr(sourceName, '.');
|
||||
if (dot != NULL)
|
||||
strcpy(dot + 1, "xpt");
|
||||
|
||||
err = CWGetOutputFileDirectory(gPluginContext, &gSourceFile);
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
|
||||
c2p_strcpy(gSourceFile.name, sourceName);
|
||||
|
||||
#ifdef USE_FULL_PATH
|
||||
gSourcePath = full_path_to(gSourceFile);
|
||||
#else
|
||||
gSourcePath = sourceName;
|
||||
#endif
|
||||
|
||||
XPIDLSettings settings = { kXPIDLSettingsVersion, kXPIDLModeTypelib, false, false };
|
||||
GetSettings(context, settings);
|
||||
|
||||
// build an argument list and call xpt_dump.
|
||||
int argc = 1;
|
||||
char* argv[] = { "xpt_dump", NULL, NULL, NULL };
|
||||
if (settings.verbose) argv[argc++] = "-v";
|
||||
argv[argc++] = gSourcePath;
|
||||
|
||||
try {
|
||||
xptdump_main(argc, argv);
|
||||
} catch (int status) {
|
||||
// evidently the good old exit function got called.
|
||||
err = cwErrRequestFailed;
|
||||
}
|
||||
|
||||
delete[] gSourcePath;
|
||||
gSourcePath = NULL;
|
||||
|
||||
if (err == noErr) {
|
||||
CWNewTextDocumentInfo info = {
|
||||
NULL,
|
||||
mac_console_handle,
|
||||
false
|
||||
};
|
||||
CWResizeMemHandle(context, mac_console_handle, mac_console_count);
|
||||
err = CWCreateNewTextDocument(context, &info);
|
||||
}
|
||||
|
||||
return (err);
|
||||
#else
|
||||
// the disassembly code has moved to the linker.
|
||||
return noErr;
|
||||
#endif
|
||||
}
|
||||
|
||||
static CWResult LocateFile(CWPluginContext context, const char* filename, FSSpec& file)
|
||||
{
|
||||
/* prefill the CWFileInfo struct */
|
||||
CWFileInfo fileinfo;
|
||||
memset(&fileinfo, 0, sizeof(fileinfo));
|
||||
BlockZero(&fileinfo, sizeof(fileinfo));
|
||||
// memset(&fileinfo, 0, sizeof(fileinfo));
|
||||
fileinfo.fullsearch = true;
|
||||
fileinfo.suppressload = true;
|
||||
fileinfo.dependencyType = cwNormalDependency;
|
||||
@ -265,15 +255,12 @@ FILE* std::fopen(const char* filename, const char *mode)
|
||||
if (filename == gSourcePath || strcmp(filename, gSourcePath) == 0) {
|
||||
// opening the main source file.
|
||||
filespec = gSourceFile;
|
||||
} else if (strncmp(mode, "w", 1) == 0) {
|
||||
// if an output file, try opening it in the current's project's
|
||||
CWFileSpec outputDir;
|
||||
CWResult err = CWGetOutputFileDirectory(gPluginContext, &outputDir);
|
||||
} else if (mode[0] == 'w') {
|
||||
// if an output file, try opening it in the current project's output directory.
|
||||
CWResult err = CWGetOutputFileDirectory(gPluginContext, &filespec);
|
||||
if (err == noErr) {
|
||||
c2p_strcpy(filespec.name, filename);
|
||||
filespec.vRefNum = outputDir.vRefNum;
|
||||
Boolean isDirectory;
|
||||
err = FSpGetDirectoryID(&outputDir, &filespec.parID, &isDirectory);
|
||||
gOutputFile = filespec;
|
||||
}
|
||||
} else {
|
||||
// an input file, use CodeWarrior's search paths to find the named source file.
|
||||
|
Loading…
x
Reference in New Issue
Block a user