mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-14 17:24:01 +00:00
ICU-961 Useful stuff for the Mac
X-SVN-Rev: 5009
This commit is contained in:
parent
98dba22c6c
commit
8d6f6463d2
10 changed files with 2036 additions and 0 deletions
18
icu4c/as_is/codewarrior/mac/Carbon.r
Normal file
18
icu4c/as_is/codewarrior/mac/Carbon.r
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Permit this Carbon application to launch on OS X
|
||||
*
|
||||
* (c) 1997-2000 Metrowerks Corp.
|
||||
*
|
||||
* Questions and comments to:
|
||||
* <mailto:support@metrowerks.com>
|
||||
* <http://www.metrowerks.com/>
|
||||
*/
|
||||
|
||||
|
||||
/*----------------------------carb Carbon on OS X launch information --------------------------*/
|
||||
type 'carb' {
|
||||
};
|
||||
|
||||
|
||||
resource 'carb'(0) {
|
||||
};
|
265
icu4c/as_is/codewarrior/mac/mac_gencnval.cpp
Normal file
265
icu4c/as_is/codewarrior/mac/mac_gencnval.cpp
Normal file
|
@ -0,0 +1,265 @@
|
|||
/**
|
||||
* File: mac_gencnval.cpp
|
||||
*
|
||||
* Mac Codewarrior plugin version of gencnval.
|
||||
*
|
||||
* Sean K. Todd (stodd@broadjump.com)
|
||||
* Marty Saxton (msaxton@broadjump.com)
|
||||
*/
|
||||
|
||||
// local headers
|
||||
#include "mac_utils.h"
|
||||
//#include "cmemory.h"
|
||||
//#include "utypes.h"
|
||||
|
||||
// Toolbox headers
|
||||
#include "TextUtils.h"
|
||||
|
||||
//#include <string>
|
||||
|
||||
// global variables
|
||||
CWPluginContext gPluginContext;
|
||||
|
||||
extern "C" {
|
||||
int main( int argc, char* argv[]);
|
||||
//pascal OSErr FSpGetFullPath(const FSSpec *spec, short *fullPathLength, Handle *fullPath);
|
||||
}
|
||||
|
||||
|
||||
// plugin compiler exports.
|
||||
#if CW_USE_PRAGMA_EXPORT
|
||||
#pragma export on
|
||||
#endif
|
||||
|
||||
// define what file types are handled
|
||||
// hmm don't want to associate any file extensions with this compiler
|
||||
// it only works on convrtrs.txt
|
||||
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetDefaultMappingList)( const CWExtMapList** defaultMappingList)
|
||||
{
|
||||
static CWExtensionMapping sExtension = { 'TEXT', ".txt", 0 };
|
||||
static CWExtMapList sExtensionMapList = { kCurrentCWExtMapListVersion, 1, &sExtension };
|
||||
|
||||
*defaultMappingList = &sExtensionMapList;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
|
||||
// define what operations this plugin handles
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetDropInFlags)( const DropInFlags** flags, long* flagsSize)
|
||||
{
|
||||
static const DropInFlags sFlags = {
|
||||
kCurrentDropInFlagsVersion,
|
||||
CWDROPINCOMPILERTYPE,
|
||||
DROPINCOMPILERLINKERAPIVERSION,
|
||||
( kGeneratescode | kCompMultiTargAware | kCompAlwaysReload),
|
||||
Lang_MISC,
|
||||
DROPINCOMPILERLINKERAPIVERSION
|
||||
};
|
||||
*flags = &sFlags;
|
||||
*flagsSize = sizeof(sFlags);
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
// define what platforms are supported by this plugin
|
||||
//
|
||||
// '****' - specifies any type
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetTargetList)( const CWTargetList** targetList)
|
||||
{
|
||||
static CWDataType sCPU = '****';
|
||||
static CWDataType sOS = '****';
|
||||
static CWTargetList sTargetList = { kCurrentCWTargetListVersion, 1, &sCPU, 1, &sOS };
|
||||
*targetList = &sTargetList;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
// define the plugin's onscreen name
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetDropInName)( const char** dropinName)
|
||||
{
|
||||
static const char* sDropInName = "gencnval";
|
||||
*dropinName = sDropInName;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
#if CW_USE_PRAGMA_EXPORT
|
||||
#pragma export off
|
||||
#endif
|
||||
|
||||
static CWResult Compile( CWPluginContext context)
|
||||
{
|
||||
// get the FileSpec of the file being processed
|
||||
CWResult err = CWGetMainFileSpec( context, &gSourceFile);
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
|
||||
// get the index of the file to process, from the target link order
|
||||
long fileNum;
|
||||
err = CWGetMainFileNumber( context, &fileNum);
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
|
||||
// get the name of the source file to compile
|
||||
gSourceFileName = p2c_strdup( gSourceFile.name);
|
||||
|
||||
if (gSourceFileName == NULL)
|
||||
return cwErrOutOfMemory;
|
||||
|
||||
// get the user specified directory from the Target Settings panel (if one exists)
|
||||
err = CWGetOutputFileDirectory( gPluginContext, &gOutputFile);
|
||||
|
||||
if (!CWSUCCESS(err)) {
|
||||
// else generate the output file into the project target's data directory
|
||||
err = CWGetSuggestedObjectFileSpec( context, fileNum, &gOutputFile);
|
||||
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
}
|
||||
|
||||
/* // set the destination directory
|
||||
Handle destH = 0;
|
||||
short len = 0;
|
||||
|
||||
OSErr theErr = FSpGetFullPath( &gOutputFile, &len, &destH );
|
||||
|
||||
char* theDestPath;
|
||||
char pathBuffer[1024];
|
||||
|
||||
if( destH ) {
|
||||
|
||||
::HLock(destH);
|
||||
|
||||
uprv_memcpy(pathBuffer, ((char*)(*destH)), len);
|
||||
pathBuffer[len] = 0;
|
||||
theDestPath = pathBuffer;
|
||||
|
||||
::DisposeHandle(destH);
|
||||
destH = 0;
|
||||
}
|
||||
|
||||
|
||||
// get the source directory
|
||||
Handle srcH = 0;
|
||||
len = 0;
|
||||
|
||||
theErr = FSpGetFullPath( &gSourceFile, &len, &srcH );
|
||||
|
||||
char* theSrcPath;
|
||||
char srcBuffer[1024];
|
||||
|
||||
if( srcH ) {
|
||||
|
||||
::HLock(srcH);
|
||||
|
||||
uprv_memcpy(srcBuffer, ((char*)(*srcH)), len);
|
||||
srcBuffer[len] = 0;
|
||||
theSrcPath = srcBuffer;
|
||||
|
||||
::DisposeHandle(srcH);
|
||||
srcH = 0;
|
||||
|
||||
// truncate file name from full path string
|
||||
std::string str = theSrcPath;
|
||||
str = str.substr( 0, str.find_last_of( ":" ) + 1);
|
||||
std::strcpy(theSrcPath, str.c_str());
|
||||
}
|
||||
*/
|
||||
// set the destination directory
|
||||
char* theDestPath = "";
|
||||
char pathBuffer[1024];
|
||||
|
||||
get_path_string( &theDestPath, pathBuffer, &gOutputFile, false);
|
||||
|
||||
// set the source directory
|
||||
char* theSrcPath = "";
|
||||
char srcBuffer[1024];
|
||||
|
||||
get_path_string( &theSrcPath, srcBuffer, &gSourceFile, true);
|
||||
|
||||
int argc = 5;
|
||||
char* argv[] = { "gencnval", "-d", theDestPath, "-s", theSrcPath };
|
||||
|
||||
if ( setjmp( exit_jump) == 0) {
|
||||
|
||||
// Need to test that we can locate our file here so we don't
|
||||
// have to in fopen(). That way, we won't get error messages
|
||||
// from makeconv.c when .dat files (that we don't care about)
|
||||
// aren't found.
|
||||
// err = LocateFile(gPluginContext, gSourceFileName, gSourceFile);
|
||||
|
||||
if ( main( argc, argv) != 0)
|
||||
err = cwErrRequestFailed;
|
||||
}
|
||||
else {
|
||||
// evidently the good old exit function got called.
|
||||
if ( exit_status != 0)
|
||||
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);
|
||||
}
|
||||
else {
|
||||
// an error occured, delete the output file, which might be a partial file.
|
||||
if ( gOutputFile.name[0] != 0) {
|
||||
::FSpDelete(&gOutputFile);
|
||||
}
|
||||
}
|
||||
|
||||
delete[] gSourceFileName;
|
||||
gSourceFileName = NULL;
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
||||
// main entry-point for makeconv compiler plugin
|
||||
pascal short gencnval_compiler( CWPluginContext context)
|
||||
{
|
||||
short result = cwNoErr;
|
||||
long request;
|
||||
|
||||
// Get the value indicating the task the IDE is currently asking the
|
||||
// plugin to perform and make sure no error was evoked.
|
||||
if ( CWGetPluginRequest( context, &request) != cwNoErr)
|
||||
return cwErrRequestFailed;
|
||||
|
||||
gPluginContext = context;
|
||||
result = cwNoErr;
|
||||
|
||||
// dispatch on compiler request
|
||||
switch (request)
|
||||
{
|
||||
case reqInitCompiler: break; // compiler has just been loaded into memory
|
||||
|
||||
case reqTermCompiler: break; // compiler is about to be unloaded from memory
|
||||
|
||||
case reqCompile:
|
||||
/* compile a source file */
|
||||
result = Compile( context);
|
||||
break;
|
||||
|
||||
default:
|
||||
result = cwErrRequestFailed;
|
||||
break;
|
||||
}
|
||||
|
||||
gPluginContext = 0;
|
||||
return (result);
|
||||
}
|
||||
|
258
icu4c/as_is/codewarrior/mac/mac_gennames.cpp
Normal file
258
icu4c/as_is/codewarrior/mac/mac_gennames.cpp
Normal file
|
@ -0,0 +1,258 @@
|
|||
/**
|
||||
* File: mac_gennames.cpp
|
||||
*
|
||||
* Mac Codewarrior plugin version of gennames.
|
||||
*
|
||||
* Sean K. Todd (stodd@broadjump.com)
|
||||
* Marty Saxton (msaxton@broadjump.com)
|
||||
*/
|
||||
|
||||
// local headers
|
||||
#include "mac_utils.h"
|
||||
//#include "cmemory.h"
|
||||
//#include "utypes.h"
|
||||
|
||||
// Toolbox headers
|
||||
#include "TextUtils.h"
|
||||
|
||||
//#include <string>
|
||||
|
||||
// global variables
|
||||
CWPluginContext gPluginContext;
|
||||
|
||||
extern "C" {
|
||||
int main( int argc, char* argv[]);
|
||||
//pascal OSErr FSpGetFullPath(const FSSpec *spec, short *fullPathLength, Handle *fullPath);
|
||||
}
|
||||
|
||||
|
||||
// plugin compiler exports.
|
||||
#if CW_USE_PRAGMA_EXPORT
|
||||
#pragma export on
|
||||
#endif
|
||||
|
||||
// define what file types are handled
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetDefaultMappingList)( const CWExtMapList** defaultMappingList)
|
||||
{
|
||||
static CWExtensionMapping sExtension = { 'TEXT', ".txt", 0 };
|
||||
static CWExtMapList sExtensionMapList = { kCurrentCWExtMapListVersion, 1, &sExtension };
|
||||
*defaultMappingList = &sExtensionMapList;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
// define what operations this plugin handles
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetDropInFlags)( const DropInFlags** flags, long* flagsSize)
|
||||
{
|
||||
static const DropInFlags sFlags = {
|
||||
kCurrentDropInFlagsVersion,
|
||||
CWDROPINCOMPILERTYPE,
|
||||
DROPINCOMPILERLINKERAPIVERSION,
|
||||
(kGeneratescode | kCompMultiTargAware | kCompAlwaysReload),
|
||||
Lang_MISC,
|
||||
DROPINCOMPILERLINKERAPIVERSION
|
||||
};
|
||||
|
||||
*flags = &sFlags;
|
||||
*flagsSize = sizeof(sFlags);
|
||||
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
// define what platforms are supported by this plugin
|
||||
//
|
||||
// '****' - specifies any type
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetTargetList)( const CWTargetList** targetList)
|
||||
{
|
||||
static CWDataType sCPU = '****';
|
||||
static CWDataType sOS = '****';
|
||||
static CWTargetList sTargetList = { kCurrentCWTargetListVersion, 1, &sCPU, 1, &sOS };
|
||||
|
||||
*targetList = &sTargetList;
|
||||
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
// define the plugin's onscreen name
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetDropInName)( const char** dropinName)
|
||||
{
|
||||
static const char* sDropInName = "gennames";
|
||||
*dropinName = sDropInName;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
#if CW_USE_PRAGMA_EXPORT
|
||||
#pragma export off
|
||||
#endif
|
||||
|
||||
static CWResult Compile( CWPluginContext context)
|
||||
{
|
||||
// get the FileSpec of the file being processed
|
||||
CWResult err = CWGetMainFileSpec( context, &gSourceFile);
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
|
||||
// get the index of the file to process, from the target link order
|
||||
long fileNum;
|
||||
err = CWGetMainFileNumber( context, &fileNum);
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
|
||||
// get the name of the source file to compile
|
||||
gSourceFileName = p2c_strdup( gSourceFile.name);
|
||||
|
||||
if (gSourceFileName == NULL)
|
||||
return cwErrOutOfMemory;
|
||||
|
||||
// get the user specified directory from the Target Settings panel (if one exists)
|
||||
err = CWGetOutputFileDirectory( gPluginContext, &gOutputFile);
|
||||
|
||||
if (!CWSUCCESS(err)) {
|
||||
// else generate the output file into the project target's data directory
|
||||
err = CWGetSuggestedObjectFileSpec( context, fileNum, &gOutputFile);
|
||||
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
}
|
||||
|
||||
/* // set the destination directory
|
||||
Handle destH = 0;
|
||||
short len = 0;
|
||||
|
||||
OSErr theErr = FSpGetFullPath( &gOutputFile, &len, &destH );
|
||||
|
||||
char* theDestPath;
|
||||
char pathBuffer[1024];
|
||||
|
||||
if( destH ) {
|
||||
|
||||
::HLock(destH);
|
||||
|
||||
uprv_memcpy(pathBuffer, ((char*)(*destH)), len);
|
||||
pathBuffer[len] = 0;
|
||||
theDestPath = pathBuffer;
|
||||
|
||||
::DisposeHandle(destH);
|
||||
destH = 0;
|
||||
}
|
||||
|
||||
// get the source directory
|
||||
Handle srcH = 0;
|
||||
len = 0;
|
||||
|
||||
theErr = FSpGetFullPath( &gSourceFile, &len, &srcH );
|
||||
|
||||
char* theSrcPath;
|
||||
char srcBuffer[1024];
|
||||
|
||||
if( srcH ) {
|
||||
|
||||
::HLock(srcH);
|
||||
|
||||
uprv_memcpy(srcBuffer, ((char*)(*srcH)), len);
|
||||
srcBuffer[len] = 0;
|
||||
theSrcPath = srcBuffer;
|
||||
|
||||
::DisposeHandle(srcH);
|
||||
srcH = 0;
|
||||
}
|
||||
*/
|
||||
// set the destination directory
|
||||
char* theDestPath = "";
|
||||
char pathBuffer[1024];
|
||||
|
||||
get_path_string( &theDestPath, pathBuffer, &gOutputFile, false);
|
||||
|
||||
// set the source directory
|
||||
char* theSrcPath = "";
|
||||
char srcBuffer[1024];
|
||||
|
||||
get_path_string( &theSrcPath, srcBuffer, &gSourceFile, false);
|
||||
|
||||
int argc = 4;
|
||||
char* argv[] = { "gennames", "-d", theDestPath, theSrcPath };
|
||||
|
||||
if ( setjmp(exit_jump) == 0) {
|
||||
|
||||
// Need to test that we can locate our file here so we don't
|
||||
// have to in fopen(). That way, we won't get error messages
|
||||
// from gennames.c when .dat files (that we don't care about)
|
||||
// aren't found.
|
||||
// err = LocateFile(gPluginContext, gSourceFileName, gSourceFile);
|
||||
|
||||
if ( main(argc, argv) != 0)
|
||||
err = cwErrRequestFailed;
|
||||
}
|
||||
else {
|
||||
// evidently the good old exit function got called.
|
||||
if ( exit_status != 0)
|
||||
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);
|
||||
}
|
||||
else {
|
||||
// an error occured, delete the output file, which might be a partial file.
|
||||
if ( gOutputFile.name[0] != 0) {
|
||||
::FSpDelete( &gOutputFile);
|
||||
}
|
||||
}
|
||||
|
||||
delete[] gSourceFileName;
|
||||
gSourceFileName = NULL;
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
||||
// main entry-point for gennames compiler plugin
|
||||
pascal short gennames_compiler( CWPluginContext context)
|
||||
{
|
||||
short result = cwNoErr;
|
||||
long request;
|
||||
|
||||
// Get the value indicating the task the IDE is currently asking the
|
||||
// plugin to perform and make sure no error was evoked.
|
||||
if ( CWGetPluginRequest( context, &request) != cwNoErr)
|
||||
return cwErrRequestFailed;
|
||||
|
||||
gPluginContext = context;
|
||||
result = cwNoErr;
|
||||
|
||||
// dispatch on compiler request
|
||||
switch (request)
|
||||
{
|
||||
case reqInitCompiler: break; // compiler has just been loaded into memory
|
||||
|
||||
case reqTermCompiler: break; // compiler is about to be unloaded from memory
|
||||
|
||||
case reqCompile:
|
||||
/* compile a source file */
|
||||
result = Compile( context);
|
||||
break;
|
||||
|
||||
default:
|
||||
result = cwErrRequestFailed;
|
||||
break;
|
||||
}
|
||||
|
||||
gPluginContext = 0;
|
||||
return (result);
|
||||
}
|
||||
|
275
icu4c/as_is/codewarrior/mac/mac_genprops.cpp
Normal file
275
icu4c/as_is/codewarrior/mac/mac_genprops.cpp
Normal file
|
@ -0,0 +1,275 @@
|
|||
/**
|
||||
* File: mac_genprops.cpp
|
||||
*
|
||||
* Mac Codewarrior plugin version of genprops.
|
||||
*
|
||||
* Because of the different natures of the commandline genprops and a CodeWarrior plugin compiler,
|
||||
* uprops.dat will be generated multiple times (how many times depends on the number of files
|
||||
* being processed by the compiler). This is because genprops has hardcoded the processing of each
|
||||
* file when it is run but the compiler wrapper of genprops calls genprops for each individual
|
||||
* file. Therefore, as each file is 'compiled', all of the files are processed by genprops. The
|
||||
* final output isn't affected (since a new file will replace the old one), only the efficiency
|
||||
* by which the files are processed. This extra time isn't noticable with only a few files. One
|
||||
* workaround to this problem would be to only include one of the files in the project target.
|
||||
* The downside of this approach is that the other files being processed wouldn't be directly
|
||||
* accessable from the project window and it would appear to the user that only one file was
|
||||
* being processed when in fact multiple files were used to produce uprops.dat.
|
||||
*
|
||||
* Sean K. Todd (stodd@broadjump.com)
|
||||
* Marty Saxton (msaxton@broadjump.com)
|
||||
*/
|
||||
|
||||
// local headers
|
||||
#include "mac_utils.h"
|
||||
//#include "cmemory.h"
|
||||
//#include "utypes.h"
|
||||
|
||||
// Toolbox headers
|
||||
#include "TextUtils.h"
|
||||
|
||||
//#include <string>
|
||||
|
||||
// global variables
|
||||
CWPluginContext gPluginContext;
|
||||
|
||||
extern "C" {
|
||||
int main(int argc, char* argv[]);
|
||||
//pascal OSErr FSpGetFullPath(const FSSpec *spec, short *fullPathLength, Handle *fullPath);
|
||||
}
|
||||
|
||||
|
||||
// plugin compiler exports.
|
||||
#if CW_USE_PRAGMA_EXPORT
|
||||
#pragma export on
|
||||
#endif
|
||||
|
||||
// define what file types are handled
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetDefaultMappingList)( const CWExtMapList** defaultMappingList)
|
||||
{
|
||||
static CWExtensionMapping sExtension = { 'TEXT', ".txt", 0 };
|
||||
static CWExtMapList sExtensionMapList = { kCurrentCWExtMapListVersion, 1, &sExtension };
|
||||
*defaultMappingList = &sExtensionMapList;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
// define what operations this plugin handles
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetDropInFlags)( const DropInFlags** flags, long* flagsSize)
|
||||
{
|
||||
static const DropInFlags sFlags = {
|
||||
kCurrentDropInFlagsVersion,
|
||||
CWDROPINCOMPILERTYPE,
|
||||
DROPINCOMPILERLINKERAPIVERSION,
|
||||
(kGeneratescode | kCompMultiTargAware | kCompAlwaysReload),
|
||||
Lang_MISC,
|
||||
DROPINCOMPILERLINKERAPIVERSION
|
||||
};
|
||||
|
||||
*flags = &sFlags;
|
||||
*flagsSize = sizeof(sFlags);
|
||||
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
// define what platforms are supported by this plugin
|
||||
//
|
||||
// '****' - specifies any type
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetTargetList)( const CWTargetList** targetList)
|
||||
{
|
||||
static CWDataType sCPU = '****';
|
||||
static CWDataType sOS = '****';
|
||||
static CWTargetList sTargetList = { kCurrentCWTargetListVersion, 1, &sCPU, 1, &sOS };
|
||||
|
||||
*targetList = &sTargetList;
|
||||
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
// define the plugin's onscreen name
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetDropInName)( const char** dropinName)
|
||||
{
|
||||
static const char* sDropInName = "genprops";
|
||||
*dropinName = sDropInName;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
#if CW_USE_PRAGMA_EXPORT
|
||||
#pragma export off
|
||||
#endif
|
||||
|
||||
static CWResult Compile( CWPluginContext context)
|
||||
{
|
||||
// get the FileSpec of the file being processed
|
||||
CWResult err = CWGetMainFileSpec( context, &gSourceFile);
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
|
||||
// get the index of the file to process, from the target link order
|
||||
long fileNum;
|
||||
err = CWGetMainFileNumber( context, &fileNum);
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
|
||||
// get the name of the source file to compile
|
||||
gSourceFileName = p2c_strdup( gSourceFile.name);
|
||||
|
||||
if ( gSourceFileName == NULL)
|
||||
return cwErrOutOfMemory;
|
||||
|
||||
// get the user specified directory from the Target Settings panel (if one exists)
|
||||
err = CWGetOutputFileDirectory( gPluginContext, &gOutputFile);
|
||||
|
||||
if (!CWSUCCESS(err)) {
|
||||
// else generate the output file into the project target's data directory
|
||||
err = CWGetSuggestedObjectFileSpec( context, fileNum, &gOutputFile);
|
||||
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
}
|
||||
|
||||
/* // set the destination directory
|
||||
Handle destH = 0;
|
||||
short len = 0;
|
||||
|
||||
OSErr theErr = FSpGetFullPath( &gOutputFile, &len, &destH );
|
||||
|
||||
char* theDestPath;
|
||||
char pathBuffer[1024];
|
||||
|
||||
if( destH ) {
|
||||
|
||||
::HLock(destH);
|
||||
|
||||
uprv_memcpy(pathBuffer, ((char*)(*destH)), len);
|
||||
pathBuffer[len] = 0;
|
||||
theDestPath = pathBuffer;
|
||||
|
||||
::DisposeHandle(destH);
|
||||
destH = 0;
|
||||
}
|
||||
|
||||
// get the source directory
|
||||
Handle srcH = 0;
|
||||
len = 0;
|
||||
|
||||
theErr = FSpGetFullPath( &gSourceFile, &len, &srcH );
|
||||
|
||||
char* theSrcPath;
|
||||
char srcBuffer[1024];
|
||||
|
||||
if( srcH ) {
|
||||
|
||||
::HLock(srcH);
|
||||
|
||||
uprv_memcpy(srcBuffer, ((char*)(*srcH)), len);
|
||||
srcBuffer[len] = 0;
|
||||
theSrcPath = srcBuffer;
|
||||
|
||||
::DisposeHandle(srcH);
|
||||
srcH = 0;
|
||||
|
||||
// truncate file name from full path string
|
||||
std::string str = theSrcPath;
|
||||
str = str.substr( 0, str.find_last_of( ":" ) + 1);
|
||||
std::strcpy(theSrcPath, str.c_str());
|
||||
}
|
||||
*/
|
||||
// set the destination directory
|
||||
char* theDestPath = "";
|
||||
char pathBuffer[1024];
|
||||
|
||||
get_path_string( &theDestPath, pathBuffer, &gOutputFile, false);
|
||||
|
||||
// set the source directory
|
||||
char* theSrcPath = "";
|
||||
char srcBuffer[1024];
|
||||
|
||||
get_path_string( &theSrcPath, srcBuffer, &gSourceFile, true);
|
||||
|
||||
int argc = 5;
|
||||
char* argv[] = { "genprops", "-d", theDestPath, "-s", theSrcPath, };
|
||||
|
||||
if ( setjmp( exit_jump) == 0) {
|
||||
|
||||
// Need to test that we can locate our file here so we don't
|
||||
// have to in fopen(). That way, we won't get error messages
|
||||
// from genprops.c when .dat files (that we don't care about)
|
||||
// aren't found.
|
||||
// err = LocateFile( gPluginContext, gSourceFileName, gSourceFile);
|
||||
|
||||
if ( main( argc, argv) != 0)
|
||||
err = cwErrRequestFailed;
|
||||
}
|
||||
else {
|
||||
// evidently the good old exit function got called.
|
||||
if ( exit_status != 0)
|
||||
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);
|
||||
}
|
||||
else {
|
||||
// an error occured, delete the output file, which might be a partial file.
|
||||
if ( gOutputFile.name[0] != 0) {
|
||||
::FSpDelete( &gOutputFile);
|
||||
}
|
||||
}
|
||||
|
||||
delete[] gSourceFileName;
|
||||
gSourceFileName = NULL;
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
||||
// main entry-point for genprops compiler plugin
|
||||
pascal short genprops_compiler( CWPluginContext context)
|
||||
{
|
||||
short result = cwNoErr;
|
||||
long request;
|
||||
|
||||
// Get the value indicating the task the IDE is currently asking the
|
||||
// plugin to perform and make sure no error was evoked.
|
||||
if ( CWGetPluginRequest( context, &request) != cwNoErr)
|
||||
return cwErrRequestFailed;
|
||||
|
||||
gPluginContext = context;
|
||||
result = cwNoErr;
|
||||
|
||||
// dispatch on compiler request
|
||||
switch (request)
|
||||
{
|
||||
case reqInitCompiler: break; // compiler has just been loaded into memory
|
||||
|
||||
case reqTermCompiler: break; // compiler is about to be unloaded from memory
|
||||
|
||||
case reqCompile:
|
||||
/* compile a source file */
|
||||
result = Compile( context);
|
||||
break;
|
||||
|
||||
default:
|
||||
result = cwErrRequestFailed;
|
||||
break;
|
||||
}
|
||||
|
||||
gPluginContext = 0;
|
||||
return (result);
|
||||
}
|
||||
|
226
icu4c/as_is/codewarrior/mac/mac_genrb.cpp
Normal file
226
icu4c/as_is/codewarrior/mac/mac_genrb.cpp
Normal file
|
@ -0,0 +1,226 @@
|
|||
/**
|
||||
* File: mac_genrb.cpp
|
||||
*
|
||||
* Mac Codewarrior plugin version of genrb.
|
||||
*
|
||||
*
|
||||
* Sean K. Todd (stodd@broadjump.com)
|
||||
* Marty Saxton (msaxton@broadjump.com)
|
||||
*/
|
||||
|
||||
// local headers
|
||||
#include "mac_utils.h"
|
||||
//#include "cmemory.h"
|
||||
//#include "utypes.h"
|
||||
|
||||
// Toolbox headers
|
||||
#include "TextUtils.h"
|
||||
#include <string.h>
|
||||
//#include <string>
|
||||
|
||||
// global variables
|
||||
CWPluginContext gPluginContext;
|
||||
|
||||
extern "C" {
|
||||
int main(int argc, char* argv[]);
|
||||
//pascal OSErr FSpGetFullPath(const FSSpec *spec, short *fullPathLength, Handle *fullPath);
|
||||
}
|
||||
|
||||
|
||||
// plugin compiler exports.
|
||||
#if CW_USE_PRAGMA_EXPORT
|
||||
#pragma export on
|
||||
#endif
|
||||
|
||||
// define what file types are handled
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetDefaultMappingList)( const CWExtMapList** defaultMappingList)
|
||||
{
|
||||
static CWExtensionMapping sExtension = { 'TEXT', ".txt", 0 };
|
||||
static CWExtMapList sExtensionMapList = { kCurrentCWExtMapListVersion, 1, &sExtension };
|
||||
|
||||
*defaultMappingList = &sExtensionMapList;
|
||||
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
// define what operations this plugin handles
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetDropInFlags)( const DropInFlags** flags, long* flagsSize)
|
||||
{
|
||||
static const DropInFlags sFlags = {
|
||||
kCurrentDropInFlagsVersion,
|
||||
CWDROPINCOMPILERTYPE,
|
||||
DROPINCOMPILERLINKERAPIVERSION,
|
||||
( kGeneratescode | kCompMultiTargAware | kCompAlwaysReload),
|
||||
Lang_MISC,
|
||||
DROPINCOMPILERLINKERAPIVERSION
|
||||
};
|
||||
|
||||
*flags = &sFlags;
|
||||
*flagsSize = sizeof(sFlags);
|
||||
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
// define what platforms are supported by this plugin
|
||||
//
|
||||
// '****' - specifies any type
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetTargetList)( const CWTargetList** targetList)
|
||||
{
|
||||
static CWDataType sCPU = '****';
|
||||
static CWDataType sOS = '****';
|
||||
static CWTargetList sTargetList = { kCurrentCWTargetListVersion, 1, &sCPU, 1, &sOS };
|
||||
*targetList = &sTargetList;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
// define the plugin's onscreen name
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetDropInName)( const char** dropinName)
|
||||
{
|
||||
static const char* sDropInName = "genrb";
|
||||
*dropinName = sDropInName;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
#if CW_USE_PRAGMA_EXPORT
|
||||
#pragma export off
|
||||
#endif
|
||||
|
||||
static CWResult Compile( CWPluginContext context)
|
||||
{
|
||||
// get the FileSpec of the file being processed
|
||||
CWResult err = CWGetMainFileSpec( context, &gSourceFile);
|
||||
if ( !CWSUCCESS( err))
|
||||
return (err);
|
||||
|
||||
// get the index of the file to process, from the target link order
|
||||
long fileNum;
|
||||
err = CWGetMainFileNumber( context, &fileNum);
|
||||
if ( !CWSUCCESS( err))
|
||||
return (err);
|
||||
|
||||
// get the name of the source file to compile
|
||||
gSourceFileName = p2c_strdup( gSourceFile.name);
|
||||
|
||||
if ( gSourceFileName == NULL)
|
||||
return cwErrOutOfMemory;
|
||||
|
||||
// get the user specified directory from the Target Settings panel (if one exists)
|
||||
err = CWGetOutputFileDirectory(gPluginContext, &gOutputFile);
|
||||
|
||||
if ( !CWSUCCESS(err)) {
|
||||
// else generate the output file into the project target's data directory
|
||||
err = CWGetSuggestedObjectFileSpec( context, fileNum, &gOutputFile);
|
||||
|
||||
if ( !CWSUCCESS(err))
|
||||
return (err);
|
||||
}
|
||||
|
||||
// set the destination directory
|
||||
char* theDestPath = "";
|
||||
char pathBuffer[1024];
|
||||
|
||||
get_path_string( &theDestPath, pathBuffer, &gOutputFile, false);
|
||||
|
||||
// set the source directory
|
||||
char* theSrcPath = "";
|
||||
char srcBuffer[1024];
|
||||
|
||||
get_path_string( &theSrcPath, srcBuffer, &gSourceFile, true);
|
||||
|
||||
// chop off the trailing colon
|
||||
if ( theSrcPath && *theSrcPath && theSrcPath[ std::strlen( theSrcPath )-1 ] == ':' )
|
||||
theSrcPath[ strlen( theSrcPath )-1 ] = 0;
|
||||
|
||||
int argc = 6;
|
||||
char* argv[] = { "genrb", "-d", theDestPath, "-s", theSrcPath, gSourceFileName };
|
||||
|
||||
if ( setjmp( exit_jump) == 0) {
|
||||
|
||||
// Need to test that we can locate our file here so we don't
|
||||
// have to in fopen(). That way, we won't get error messages
|
||||
// from genrb.c when .dat files (that we don't care about)
|
||||
// aren't found.
|
||||
// err = LocateFile(gPluginContext, gSourceFileName, gSourceFile);
|
||||
|
||||
if ( main( argc, argv) != 0)
|
||||
err = cwErrRequestFailed;
|
||||
}
|
||||
else {
|
||||
// evidently the good old exit function got called.
|
||||
if ( exit_status != 0)
|
||||
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);
|
||||
} else {
|
||||
// an error occured, delete the output file, which might be a partial file.
|
||||
if ( gOutputFile.name[0] != 0) {
|
||||
::FSpDelete(&gOutputFile);
|
||||
}
|
||||
}
|
||||
|
||||
delete[] gSourceFileName;
|
||||
gSourceFileName = NULL;
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
||||
// main entry-point for genrb compiler plugin
|
||||
pascal short genrb_compiler( CWPluginContext context)
|
||||
{
|
||||
short result = cwNoErr;
|
||||
long request;
|
||||
|
||||
// Get the value indicating the task the IDE is currently asking the
|
||||
// plugin to perform and make sure no error was evoked.
|
||||
if ( CWGetPluginRequest( context, &request) != cwNoErr)
|
||||
return cwErrRequestFailed;
|
||||
|
||||
gPluginContext = context;
|
||||
result = cwNoErr;
|
||||
|
||||
/* dispatch on compiler request */
|
||||
switch (request)
|
||||
{
|
||||
case reqInitCompiler:
|
||||
/* compiler has just been loaded into memory */
|
||||
break;
|
||||
|
||||
case reqTermCompiler:
|
||||
/* compiler is about to be unloaded from memory */
|
||||
break;
|
||||
|
||||
case reqCompile:
|
||||
/* compile a source file */
|
||||
result = Compile( context);
|
||||
break;
|
||||
|
||||
default:
|
||||
result = cwErrRequestFailed;
|
||||
break;
|
||||
}
|
||||
|
||||
gPluginContext = 0;
|
||||
/* return result code */
|
||||
return (result);
|
||||
}
|
||||
|
256
icu4c/as_is/codewarrior/mac/mac_gentz.cpp
Normal file
256
icu4c/as_is/codewarrior/mac/mac_gentz.cpp
Normal file
|
@ -0,0 +1,256 @@
|
|||
/**
|
||||
* File: mac_gentz.cpp
|
||||
*
|
||||
* Mac Codewarrior plugin version of gentz.
|
||||
*
|
||||
* Sean K. Todd (stodd@broadjump.com)
|
||||
* Marty Saxton (msaxton@broadjump.com)
|
||||
*/
|
||||
|
||||
// local headers
|
||||
#include "mac_utils.h"
|
||||
//#include "cmemory.h"
|
||||
//#include "utypes.h"
|
||||
|
||||
// Toolbox headers
|
||||
#include "TextUtils.h"
|
||||
|
||||
// global variables
|
||||
CWPluginContext gPluginContext;
|
||||
|
||||
extern "C" {
|
||||
int main( int argc, char* argv[]);
|
||||
//pascal OSErr FSpGetFullPath(const FSSpec *spec, short *fullPathLength, Handle *fullPath);
|
||||
}
|
||||
|
||||
|
||||
// plugin compiler exports.
|
||||
#if CW_USE_PRAGMA_EXPORT
|
||||
#pragma export on
|
||||
#endif
|
||||
|
||||
// define what file types are handled
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetDefaultMappingList)( const CWExtMapList** defaultMappingList)
|
||||
{
|
||||
static CWExtensionMapping sExtension = { 'TEXT', ".txt", 0 };
|
||||
static CWExtMapList sExtensionMapList = { kCurrentCWExtMapListVersion, 1, &sExtension };
|
||||
*defaultMappingList = &sExtensionMapList;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
// define what operations this plugin handles
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetDropInFlags)( const DropInFlags** flags, long* flagsSize)
|
||||
{
|
||||
static const DropInFlags sFlags = {
|
||||
kCurrentDropInFlagsVersion,
|
||||
CWDROPINCOMPILERTYPE,
|
||||
DROPINCOMPILERLINKERAPIVERSION,
|
||||
( kGeneratescode | kCompMultiTargAware | kCompAlwaysReload),
|
||||
Lang_MISC,
|
||||
DROPINCOMPILERLINKERAPIVERSION
|
||||
};
|
||||
|
||||
*flags = &sFlags;
|
||||
*flagsSize = sizeof(sFlags);
|
||||
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
// define what platforms are supported by this plugin
|
||||
//
|
||||
// '****' - specifies any type
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetTargetList)( const CWTargetList** targetList)
|
||||
{
|
||||
static CWDataType sCPU = '****';
|
||||
static CWDataType sOS = '****';
|
||||
static CWTargetList sTargetList = { kCurrentCWTargetListVersion, 1, &sCPU, 1, &sOS };
|
||||
|
||||
*targetList = &sTargetList;
|
||||
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
// define the plugin's onscreen name
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetDropInName)( const char** dropinName)
|
||||
{
|
||||
static const char* sDropInName = "gentz";
|
||||
*dropinName = sDropInName;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
#if CW_USE_PRAGMA_EXPORT
|
||||
#pragma export off
|
||||
#endif
|
||||
|
||||
static CWResult Compile( CWPluginContext context)
|
||||
{
|
||||
// get the FileSpec of the file being processed
|
||||
CWResult err = CWGetMainFileSpec( context, &gSourceFile);
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
|
||||
// get the index of the file to process, from the target link order
|
||||
long fileNum;
|
||||
err = CWGetMainFileNumber( context, &fileNum);
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
|
||||
// get the name of the source file to compile
|
||||
gSourceFileName = p2c_strdup( gSourceFile.name);
|
||||
|
||||
if ( gSourceFileName == NULL)
|
||||
return cwErrOutOfMemory;
|
||||
|
||||
// get the user specified directory from the Target Settings panel (if one exists)
|
||||
err = CWGetOutputFileDirectory( gPluginContext, &gOutputFile);
|
||||
|
||||
if (!CWSUCCESS(err)) {
|
||||
// else generate the output file into the project target's data directory
|
||||
err = CWGetSuggestedObjectFileSpec( context, fileNum, &gOutputFile);
|
||||
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
}
|
||||
|
||||
/* // set the destination directory
|
||||
Handle destH = 0;
|
||||
short len = 0;
|
||||
|
||||
OSErr theErr = FSpGetFullPath( &gOutputFile, &len, &destH );
|
||||
|
||||
char* theDestPath;
|
||||
char pathBuffer[1024];
|
||||
|
||||
if( destH ) {
|
||||
|
||||
::HLock(destH);
|
||||
|
||||
uprv_memcpy(pathBuffer, ((char*)(*destH)), len);
|
||||
pathBuffer[len] = 0;
|
||||
theDestPath = pathBuffer;
|
||||
|
||||
::DisposeHandle(destH);
|
||||
destH = 0;
|
||||
}
|
||||
|
||||
// get the source directory
|
||||
Handle srcH = 0;
|
||||
len = 0;
|
||||
|
||||
theErr = FSpGetFullPath( &gSourceFile, &len, &srcH );
|
||||
|
||||
char* theSrcPath;
|
||||
char srcBuffer[1024];
|
||||
|
||||
if( srcH ) {
|
||||
|
||||
::HLock(srcH);
|
||||
|
||||
uprv_memcpy( srcBuffer, ((char*)(*srcH)), len);
|
||||
srcBuffer[len] = 0;
|
||||
theSrcPath = srcBuffer;
|
||||
|
||||
::DisposeHandle(srcH);
|
||||
srcH = 0;
|
||||
}
|
||||
*/
|
||||
// set the destination directory
|
||||
char* theDestPath = "";
|
||||
char pathBuffer[1024];
|
||||
|
||||
get_path_string( &theDestPath, pathBuffer, &gOutputFile, false);
|
||||
|
||||
// set the source directory
|
||||
char* theSrcPath = "";
|
||||
char srcBuffer[1024];
|
||||
|
||||
get_path_string( &theSrcPath, srcBuffer, &gSourceFile, false);
|
||||
|
||||
int argc = 4;
|
||||
char* argv[] = { "gentz", "-d", theDestPath, theSrcPath };
|
||||
|
||||
if ( setjmp( exit_jump) == 0) {
|
||||
|
||||
// Need to test that we can locate our file here so we don't
|
||||
// have to in fopen(). That way, we won't get error messages
|
||||
// from gentz.c when .dat files (that we don't care about)
|
||||
// aren't found.
|
||||
// err = LocateFile(gPluginContext, gSourceFileName, gSourceFile);
|
||||
|
||||
if ( main( argc, argv) != 0)
|
||||
err = cwErrRequestFailed;
|
||||
}
|
||||
else {
|
||||
// evidently the good old exit function got called.
|
||||
if ( exit_status != 0)
|
||||
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);
|
||||
}
|
||||
else {
|
||||
// an error occured, delete the output file, which might be a partial file.
|
||||
if ( gOutputFile.name[0] != 0) {
|
||||
::FSpDelete( &gOutputFile);
|
||||
}
|
||||
}
|
||||
|
||||
delete[] gSourceFileName;
|
||||
gSourceFileName = NULL;
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
||||
// main entry-point for gentz compiler plugin
|
||||
pascal short gentz_compiler( CWPluginContext context)
|
||||
{
|
||||
short result = cwNoErr;
|
||||
long request;
|
||||
|
||||
// Get the value indicating the task the IDE is currently asking the
|
||||
// plugin to perform and make sure no error was evoked.
|
||||
if ( CWGetPluginRequest( context, &request) != cwNoErr)
|
||||
return cwErrRequestFailed;
|
||||
|
||||
gPluginContext = context;
|
||||
result = cwNoErr;
|
||||
|
||||
// dispatch on compiler request
|
||||
switch (request)
|
||||
{
|
||||
case reqInitCompiler: break; // compiler has just been loaded into memory
|
||||
|
||||
case reqTermCompiler: break; // compiler is about to be unloaded from memory
|
||||
|
||||
case reqCompile:
|
||||
/* compile a source file */
|
||||
result = Compile( context);
|
||||
break;
|
||||
|
||||
default:
|
||||
result = cwErrRequestFailed;
|
||||
break;
|
||||
}
|
||||
|
||||
gPluginContext = 0;
|
||||
return (result);
|
||||
}
|
||||
|
206
icu4c/as_is/codewarrior/mac/mac_genuca.cpp
Normal file
206
icu4c/as_is/codewarrior/mac/mac_genuca.cpp
Normal file
|
@ -0,0 +1,206 @@
|
|||
/**
|
||||
* File: mac_genuca.cpp
|
||||
*
|
||||
* Mac Codewarrior plugin version of genuca.
|
||||
*
|
||||
* Sean K. Todd (stodd@broadjump.com)
|
||||
* Marty Saxton (msaxton@broadjump.com)
|
||||
*/
|
||||
|
||||
// local headers
|
||||
#include "mac_utils.h"
|
||||
|
||||
// Toolbox headers
|
||||
#include "TextUtils.h"
|
||||
|
||||
// global variables
|
||||
CWPluginContext gPluginContext;
|
||||
|
||||
extern "C" {
|
||||
int main( int argc, char* argv[]);
|
||||
}
|
||||
|
||||
|
||||
// plugin compiler exports.
|
||||
#if CW_USE_PRAGMA_EXPORT
|
||||
#pragma export on
|
||||
#endif
|
||||
|
||||
// define what file types are handled
|
||||
// hmm don't want to associate any file extensions with this compiler
|
||||
// it only works on convrtrs.txt
|
||||
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetDefaultMappingList)( const CWExtMapList** defaultMappingList)
|
||||
{
|
||||
static CWExtensionMapping sExtension = { 'TEXT', ".txt", 0 };
|
||||
static CWExtMapList sExtensionMapList = { kCurrentCWExtMapListVersion, 1, &sExtension };
|
||||
|
||||
*defaultMappingList = &sExtensionMapList;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
|
||||
// define what operations this plugin handles
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetDropInFlags)( const DropInFlags** flags, long* flagsSize)
|
||||
{
|
||||
static const DropInFlags sFlags = {
|
||||
kCurrentDropInFlagsVersion,
|
||||
CWDROPINCOMPILERTYPE,
|
||||
DROPINCOMPILERLINKERAPIVERSION,
|
||||
( kGeneratescode | kCompMultiTargAware | kCompAlwaysReload),
|
||||
Lang_MISC,
|
||||
DROPINCOMPILERLINKERAPIVERSION
|
||||
};
|
||||
*flags = &sFlags;
|
||||
*flagsSize = sizeof(sFlags);
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
// define what platforms are supported by this plugin
|
||||
//
|
||||
// '****' - specifies any type
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetTargetList)( const CWTargetList** targetList)
|
||||
{
|
||||
static CWDataType sCPU = '****';
|
||||
static CWDataType sOS = '****';
|
||||
static CWTargetList sTargetList = { kCurrentCWTargetListVersion, 1, &sCPU, 1, &sOS };
|
||||
*targetList = &sTargetList;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
// define the plugin's onscreen name
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetDropInName)( const char** dropinName)
|
||||
{
|
||||
static const char* sDropInName = "genuca";
|
||||
*dropinName = sDropInName;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
#if CW_USE_PRAGMA_EXPORT
|
||||
#pragma export off
|
||||
#endif
|
||||
|
||||
static CWResult Compile( CWPluginContext context)
|
||||
{
|
||||
// get the FileSpec of the file being processed
|
||||
CWResult err = CWGetMainFileSpec( context, &gSourceFile);
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
|
||||
// get the index of the file to process, from the target link order
|
||||
long fileNum;
|
||||
err = CWGetMainFileNumber( context, &fileNum);
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
|
||||
// get the name of the source file to compile
|
||||
gSourceFileName = p2c_strdup( gSourceFile.name);
|
||||
|
||||
if (gSourceFileName == NULL)
|
||||
return cwErrOutOfMemory;
|
||||
|
||||
// get the user specified directory from the Target Settings panel (if one exists)
|
||||
err = CWGetOutputFileDirectory( gPluginContext, &gOutputFile);
|
||||
|
||||
if (!CWSUCCESS(err)) {
|
||||
// else generate the output file into the project target's data directory
|
||||
err = CWGetSuggestedObjectFileSpec( context, fileNum, &gOutputFile);
|
||||
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
}
|
||||
|
||||
// set the destination directory
|
||||
char* theDestPath = "";
|
||||
char pathBuffer[1024];
|
||||
|
||||
get_path_string( &theDestPath, pathBuffer, &gOutputFile, false);
|
||||
|
||||
// set the source directory
|
||||
char* theSrcPath = "";
|
||||
char srcBuffer[1024];
|
||||
|
||||
get_path_string( &theSrcPath, srcBuffer, &gSourceFile, true);
|
||||
|
||||
int argc = 5;
|
||||
char* argv[] = { "genuca", "-d", theDestPath, "-s", theSrcPath };
|
||||
|
||||
if ( setjmp( exit_jump) == 0) {
|
||||
|
||||
if ( main( argc, argv) != 0)
|
||||
err = cwErrRequestFailed;
|
||||
}
|
||||
else {
|
||||
// evidently the good old exit function got called.
|
||||
if ( exit_status != 0)
|
||||
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);
|
||||
}
|
||||
else {
|
||||
// an error occured, delete the output file, which might be a partial file.
|
||||
if ( gOutputFile.name[0] != 0) {
|
||||
::FSpDelete(&gOutputFile);
|
||||
}
|
||||
}
|
||||
|
||||
delete[] gSourceFileName;
|
||||
gSourceFileName = NULL;
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
||||
// main entry-point for makeconv compiler plugin
|
||||
pascal short genuca_compiler( CWPluginContext context)
|
||||
{
|
||||
short result = cwNoErr;
|
||||
long request;
|
||||
|
||||
// Get the value indicating the task the IDE is currently asking the
|
||||
// plugin to perform and make sure no error was evoked.
|
||||
if ( CWGetPluginRequest( context, &request) != cwNoErr)
|
||||
return cwErrRequestFailed;
|
||||
|
||||
gPluginContext = context;
|
||||
result = cwNoErr;
|
||||
|
||||
// dispatch on compiler request
|
||||
switch (request)
|
||||
{
|
||||
case reqInitCompiler: break; // compiler has just been loaded into memory
|
||||
|
||||
case reqTermCompiler: break; // compiler is about to be unloaded from memory
|
||||
|
||||
case reqCompile:
|
||||
/* compile a source file */
|
||||
result = Compile( context);
|
||||
break;
|
||||
|
||||
default:
|
||||
result = cwErrRequestFailed;
|
||||
break;
|
||||
}
|
||||
|
||||
gPluginContext = 0;
|
||||
return (result);
|
||||
}
|
||||
|
263
icu4c/as_is/codewarrior/mac/mac_makeconv.cpp
Normal file
263
icu4c/as_is/codewarrior/mac/mac_makeconv.cpp
Normal file
|
@ -0,0 +1,263 @@
|
|||
/**
|
||||
* File: mac_makeconv.cpp
|
||||
*
|
||||
* Mac Codewarrior plugin version of makeconv.
|
||||
*
|
||||
* Sean K. Todd (stodd@broadjump.com)
|
||||
* Marty Saxton (msaxton@broadjump.com)
|
||||
*/
|
||||
|
||||
// local headers
|
||||
#include "mac_utils.h"
|
||||
//#include "cmemory.h"
|
||||
//#include "utypes.h"
|
||||
|
||||
// Toolbox headers
|
||||
#include "TextUtils.h"
|
||||
|
||||
//#include <string>
|
||||
|
||||
// global variables
|
||||
CWPluginContext gPluginContext;
|
||||
|
||||
extern "C" {
|
||||
int main( int argc, char* argv[]);
|
||||
//pascal OSErr FSpGetFullPath(const FSSpec *spec, short *fullPathLength, Handle *fullPath);
|
||||
}
|
||||
|
||||
|
||||
// plugin compiler exports.
|
||||
#if CW_USE_PRAGMA_EXPORT
|
||||
#pragma export on
|
||||
#endif
|
||||
|
||||
// define what file types are handled
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetDefaultMappingList)( const CWExtMapList** defaultMappingList)
|
||||
{
|
||||
static CWExtensionMapping sExtension = { 'TEXT', ".ucm", 0 };
|
||||
static CWExtMapList sExtensionMapList = { kCurrentCWExtMapListVersion, 1, &sExtension };
|
||||
*defaultMappingList = &sExtensionMapList;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
// define what operations this plugin handles
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetDropInFlags)( const DropInFlags** flags, long* flagsSize)
|
||||
{
|
||||
static const DropInFlags sFlags = {
|
||||
kCurrentDropInFlagsVersion,
|
||||
CWDROPINCOMPILERTYPE,
|
||||
DROPINCOMPILERLINKERAPIVERSION,
|
||||
( kGeneratescode | kCompMultiTargAware | kCompAlwaysReload),
|
||||
Lang_MISC,
|
||||
DROPINCOMPILERLINKERAPIVERSION
|
||||
};
|
||||
|
||||
*flags = &sFlags;
|
||||
*flagsSize = sizeof(sFlags);
|
||||
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
// define what platforms are supported by this plugin
|
||||
//
|
||||
// '****' - specifies any type
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetTargetList)( const CWTargetList** targetList)
|
||||
{
|
||||
static CWDataType sCPU = '****';
|
||||
static CWDataType sOS = '****';
|
||||
static CWTargetList sTargetList = { kCurrentCWTargetListVersion, 1, &sCPU, 1, &sOS };
|
||||
|
||||
*targetList = &sTargetList;
|
||||
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
// define the plugin's onscreen name
|
||||
CWPLUGIN_ENTRY( CWPlugin_GetDropInName)( const char** dropinName)
|
||||
{
|
||||
static const char* sDropInName = "makeconv";
|
||||
*dropinName = sDropInName;
|
||||
return cwNoErr;
|
||||
}
|
||||
|
||||
#if CW_USE_PRAGMA_EXPORT
|
||||
#pragma export off
|
||||
#endif
|
||||
|
||||
static CWResult Compile( CWPluginContext context)
|
||||
{
|
||||
// get the FileSpec of the file being processed
|
||||
CWResult err = CWGetMainFileSpec( context, &gSourceFile);
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
|
||||
// get the index of the file to process, from the target link order
|
||||
long fileNum;
|
||||
err = CWGetMainFileNumber( context, &fileNum);
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
|
||||
// get the name of the source file to compile
|
||||
gSourceFileName = p2c_strdup( gSourceFile.name);
|
||||
|
||||
if ( gSourceFileName == NULL)
|
||||
return cwErrOutOfMemory;
|
||||
|
||||
// get the user specified directory from the Target Settings panel (if one exists)
|
||||
err = CWGetOutputFileDirectory( gPluginContext, &gOutputFile);
|
||||
|
||||
if (!CWSUCCESS(err)) {
|
||||
// else generate the output file into the project target's data directory
|
||||
err = CWGetSuggestedObjectFileSpec( context, fileNum, &gOutputFile);
|
||||
|
||||
if (!CWSUCCESS(err))
|
||||
return (err);
|
||||
}
|
||||
|
||||
/* // set the destination directory
|
||||
Handle destH = 0;
|
||||
short len = 0;
|
||||
|
||||
OSErr theErr = FSpGetFullPath( &gOutputFile, &len, &destH );
|
||||
|
||||
char* theDestPath;
|
||||
char pathBuffer[1024];
|
||||
|
||||
if( destH ) {
|
||||
|
||||
::HLock(destH);
|
||||
|
||||
uprv_memcpy(pathBuffer, ((char*)(*destH)), len);
|
||||
pathBuffer[len] = 0;
|
||||
theDestPath = pathBuffer;
|
||||
|
||||
::DisposeHandle(destH);
|
||||
destH = 0;
|
||||
}
|
||||
|
||||
// get the source directory
|
||||
Handle srcH = 0;
|
||||
len = 0;
|
||||
|
||||
theErr = FSpGetFullPath( &gSourceFile, &len, &srcH );
|
||||
|
||||
char* theSrcPath;
|
||||
char srcBuffer[1024];
|
||||
|
||||
if( srcH ) {
|
||||
|
||||
::HLock(srcH);
|
||||
|
||||
uprv_memcpy(srcBuffer, ((char*)(*srcH)), len);
|
||||
srcBuffer[len] = 0;
|
||||
theSrcPath = srcBuffer;
|
||||
|
||||
::DisposeHandle(srcH);
|
||||
srcH = 0;
|
||||
|
||||
// truncate file name from full path string
|
||||
// std::string str = theSrcPath;
|
||||
// str = str.substr( 0, str.find_last_of( ":" ) + 1);
|
||||
// std::strcpy(theSrcPath, str.c_str());
|
||||
}
|
||||
*/
|
||||
// set the destination directory
|
||||
char* theDestPath = "";
|
||||
char pathBuffer[1024];
|
||||
|
||||
get_path_string( &theDestPath, pathBuffer, &gOutputFile, false);
|
||||
|
||||
// set the source directory
|
||||
char* theSrcPath = "";
|
||||
char srcBuffer[1024];
|
||||
|
||||
get_path_string( &theSrcPath, srcBuffer, &gSourceFile, false);
|
||||
|
||||
int argc = 4;
|
||||
char* argv[] = { "makeconv", "-d", theDestPath, theSrcPath };
|
||||
|
||||
if ( setjmp( exit_jump) == 0) {
|
||||
|
||||
// Need to test that we can locate our file here so we don't
|
||||
// have to in fopen(). That way, we won't get error messages
|
||||
// from makeconv.c when .dat files (that we don't care about)
|
||||
// aren't found.
|
||||
// err = LocateFile(gPluginContext, gSourceFileName, gSourceFile);
|
||||
|
||||
if ( main( argc, argv) != 0)
|
||||
err = cwErrRequestFailed;
|
||||
}
|
||||
else {
|
||||
// evidently the good old exit function got called.
|
||||
if ( exit_status != 0)
|
||||
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);
|
||||
}
|
||||
else {
|
||||
// an error occured, delete the output file, which might be a partial file.
|
||||
if ( gOutputFile.name[0] != 0) {
|
||||
::FSpDelete( &gOutputFile);
|
||||
}
|
||||
}
|
||||
|
||||
delete[] gSourceFileName;
|
||||
gSourceFileName = NULL;
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
||||
// main entry-point for makeconv compiler plugin
|
||||
pascal short makeconv_compiler( CWPluginContext context)
|
||||
{
|
||||
short result = cwNoErr;
|
||||
long request;
|
||||
|
||||
// Get the value indicating the task the IDE is currently asking the
|
||||
// plugin to perform and make sure no error was evoked.
|
||||
if ( CWGetPluginRequest( context, &request) != cwNoErr)
|
||||
return cwErrRequestFailed;
|
||||
|
||||
gPluginContext = context;
|
||||
result = cwNoErr;
|
||||
|
||||
// dispatch on compiler request
|
||||
switch (request)
|
||||
{
|
||||
case reqInitCompiler: break; // compiler has just been loaded into memory
|
||||
|
||||
case reqTermCompiler: break; // compiler is about to be unloaded from memory
|
||||
|
||||
case reqCompile:
|
||||
/* compile a source file */
|
||||
result = Compile( context);
|
||||
break;
|
||||
|
||||
default:
|
||||
result = cwErrRequestFailed;
|
||||
break;
|
||||
}
|
||||
|
||||
gPluginContext = 0;
|
||||
return (result);
|
||||
}
|
||||
|
221
icu4c/as_is/codewarrior/mac/mac_utils.cpp
Normal file
221
icu4c/as_is/codewarrior/mac/mac_utils.cpp
Normal file
|
@ -0,0 +1,221 @@
|
|||
/**
|
||||
* File: mac_utils.cpp
|
||||
*
|
||||
* Routines
|
||||
* --------
|
||||
*
|
||||
* get_path_string
|
||||
* FSpGetFileSize
|
||||
* p2c_strdup
|
||||
* exit
|
||||
*
|
||||
* Description
|
||||
* -----------
|
||||
*
|
||||
* Contains functions needed for Macintosh versions of command-line compilers
|
||||
*
|
||||
* Authors
|
||||
* -------
|
||||
*
|
||||
* Sean K. Todd (stodd@broadjump.com)
|
||||
* Marty Saxton (msaxton@broadjump.com)
|
||||
*/
|
||||
|
||||
#include "mac_utils.h"
|
||||
|
||||
// icu headers
|
||||
#include "cmemory.h"
|
||||
#include "utypes.h"
|
||||
|
||||
// msl headers
|
||||
#include <string>
|
||||
|
||||
|
||||
extern "C" pascal OSErr FSpGetFullPath( const FSSpec *spec, short *fullPathLength, Handle *fullPath);
|
||||
|
||||
CWFileSpec gOutputFile;
|
||||
CWFileSpec gSourceFile;
|
||||
char* gDestPath = NULL;
|
||||
char* gSourceFileName = NULL;
|
||||
|
||||
/**
|
||||
* get_path_string
|
||||
*
|
||||
* Creates a string with the full path (with or without the file name) from
|
||||
* a FSSpec. Command-line tools expect full paths but Macs deal with files
|
||||
* via filespecs. The limitation to using full paths is that it is possible
|
||||
* to have two mounted volumes with the same name on a Mac. Filespecs can
|
||||
* distinguish between the two (by using volume reference numbers) but full
|
||||
* paths cannot.
|
||||
*
|
||||
*/
|
||||
|
||||
void get_path_string( char** oPath,
|
||||
char oPathBuffer[],
|
||||
CWFileSpec* iFileSpec,
|
||||
bool doTruncate
|
||||
)
|
||||
{
|
||||
Handle theHandle = 0;
|
||||
short len = 0;
|
||||
|
||||
OSErr theErr = FSpGetFullPath( iFileSpec, &len, &theHandle );
|
||||
|
||||
if ( theHandle && !theErr) {
|
||||
|
||||
::HLock( theHandle);
|
||||
|
||||
uprv_memcpy( oPathBuffer, ( static_cast< char*>( *theHandle)), len);
|
||||
oPathBuffer[ len ] = 0;
|
||||
*oPath = oPathBuffer;
|
||||
|
||||
::DisposeHandle( theHandle);
|
||||
theHandle = 0;
|
||||
|
||||
if ( doTruncate) {
|
||||
// truncate file name from full path string
|
||||
std::string str = *oPath;
|
||||
str = str.substr( 0, str.find_last_of( ":" ) + 1);
|
||||
std::strcpy( *oPath, str.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* FSpGetFileSize
|
||||
*
|
||||
* This function code was derived from code in MoreFilesExtras.h which is part
|
||||
* of 'MoreFiles' (Apple Sample Code).
|
||||
*
|
||||
*/
|
||||
|
||||
pascal OSErr FSpGetFileSize( const FSSpec* spec, long* dataSize, long* rsrcSize)
|
||||
{
|
||||
HParamBlockRec pb;
|
||||
|
||||
pb.fileParam.ioNamePtr = const_cast< StringPtr>( spec->name);
|
||||
pb.fileParam.ioVRefNum = spec->vRefNum;
|
||||
pb.fileParam.ioFVersNum = 0;
|
||||
pb.fileParam.ioDirID = spec->parID;
|
||||
pb.fileParam.ioFDirIndex = 0;
|
||||
|
||||
OSErr error = PBHGetFInfoSync( &pb);
|
||||
|
||||
if ( noErr == error ) {
|
||||
*dataSize = pb.fileParam.ioFlLgLen;
|
||||
*rsrcSize = pb.fileParam.ioFlRLgLen;
|
||||
}
|
||||
|
||||
return ( error );
|
||||
}
|
||||
|
||||
/**
|
||||
* p2c_strdup
|
||||
*
|
||||
* Creates a duplicate c string from a pascal string.
|
||||
*
|
||||
* NOTE: The user is responsible for calling delete[]
|
||||
* when he/she is finished using the string in
|
||||
* order to prevent a memory leak.
|
||||
*
|
||||
*/
|
||||
|
||||
char* p2c_strdup( StringPtr pstr)
|
||||
{
|
||||
size_t len = pstr[0];
|
||||
char* cstr = new char[1 + len];
|
||||
|
||||
if ( cstr != NULL) {
|
||||
::BlockMoveData( pstr + 1, cstr, len);
|
||||
cstr[len] = '\0';
|
||||
}
|
||||
return cstr;
|
||||
}
|
||||
|
||||
/**
|
||||
* exit
|
||||
*
|
||||
* simply throw us out of here!
|
||||
*/
|
||||
|
||||
jmp_buf exit_jump;
|
||||
int exit_status = 0;
|
||||
|
||||
void std::exit( int status)
|
||||
{
|
||||
exit_status = status;
|
||||
longjmp( exit_jump, -1);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*
|
||||
StringPtr c2p_strcpy( StringPtr pstr, const char* cstr)
|
||||
{
|
||||
size_t len = ::strlen(cstr);
|
||||
if (len > 255) len = 255;
|
||||
BlockMoveData(cstr, pstr + 1, len);
|
||||
pstr[0] = len;
|
||||
return pstr;
|
||||
}
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/*
|
||||
CWResult LocateFile(CWPluginContext context, const char* filename, FSSpec& file)
|
||||
{
|
||||
// prefill the CWFileInfo struct
|
||||
CWFileInfo fileinfo;
|
||||
BlockZero(&fileinfo, sizeof(fileinfo));
|
||||
// memset(&fileinfo, 0, sizeof(fileinfo));
|
||||
fileinfo.fullsearch = true;
|
||||
fileinfo.suppressload = true;
|
||||
fileinfo.dependencyType = cwNormalDependency;
|
||||
fileinfo.isdependentoffile = kCurrentCompiledFile;
|
||||
|
||||
// locate the file name using the project's access paths
|
||||
CWResult err = CWFindAndLoadFile(context, filename, &fileinfo);
|
||||
if (err == cwNoErr) {
|
||||
file = fileinfo.filespec;
|
||||
} else if (err == cwErrFileNotFound) {
|
||||
char errmsg[200];
|
||||
sprintf(errmsg, "Can't locate file \"%s\".", filename);
|
||||
CWResult callbackResult = CWReportMessage(context, 0, errmsg, 0, messagetypeError, 0);
|
||||
}
|
||||
|
||||
return (err);
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* Substitute for standard fopen, treats certain filenames specially,
|
||||
* and also considers the mode argument. If a file is being opened
|
||||
* for reading, the file is assumed to be locateable using CodeWarrior's
|
||||
* standard access paths. If it's for writing, the file is opened in
|
||||
* the current project's output directory.
|
||||
*/
|
||||
/*
|
||||
extern "C" FILE * FSp_fopen(ConstFSSpecPtr spec, const char * open_mode);
|
||||
|
||||
|
||||
FILE* std::fopen(const char* filename, const char *mode)
|
||||
{
|
||||
FSSpec filespec;
|
||||
CWResult err = noErr;
|
||||
do {
|
||||
if (filename == gSourcePath || strcmp(filename, gSourcePath) == 0) {
|
||||
// opening the main source file.
|
||||
filespec = gSourceFile;
|
||||
} else if (mode[0] == 'w') {
|
||||
// if an output file, open it in the current compilation's output directory.
|
||||
c2p_strcpy(filespec.name, filename);
|
||||
filespec.vRefNum = gOutputFile.vRefNum;
|
||||
filespec.parID = gOutputFile.parID;
|
||||
c2p_strcpy(gOutputFile.name, filename);
|
||||
} else {
|
||||
// an input file, use CodeWarrior's search paths to find the named source file.
|
||||
// err = LocateFile(gPluginContext, filename, filespec);
|
||||
}
|
||||
} while (0);
|
||||
// if all went well, we have a file to open.
|
||||
return (err == noErr ? FSp_fopen(&filespec, mode) : NULL);
|
||||
}
|
||||
*/
|
48
icu4c/as_is/codewarrior/mac/mac_utils.h
Normal file
48
icu4c/as_is/codewarrior/mac/mac_utils.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* File: mac_utils.h
|
||||
*
|
||||
* Functions needed for Macintosh versions of command-line compilers
|
||||
*
|
||||
* Sean K. Todd (stodd@broadjump.com)
|
||||
* Marty Saxton (msaxton@broadjump.com)
|
||||
*/
|
||||
|
||||
|
||||
// Toolbox headers
|
||||
#include <Files.h>
|
||||
#include <MacTypes.h>
|
||||
|
||||
// MSL headers
|
||||
#include <stdlib.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
// CodeWarrior Plugin SDK headers
|
||||
#include <CWPlugins.h>
|
||||
#include <CWPLuginErrors.h>
|
||||
#include <DropInCompilerLinker.h>
|
||||
#include <CompilerMapping.h>
|
||||
|
||||
// external variables
|
||||
extern jmp_buf exit_jump;
|
||||
extern int exit_status;
|
||||
extern char* gSourceFileName;
|
||||
extern char* gDestPath;
|
||||
extern CWFileSpec gSourceFile;
|
||||
extern CWFileSpec gOutputFile;
|
||||
|
||||
|
||||
void get_path_string( char** oPath,
|
||||
char oPathBuffer[],
|
||||
CWFileSpec* iFileSpec,
|
||||
bool doTruncate
|
||||
);
|
||||
|
||||
pascal OSErr FSpGetFileSize( const FSSpec *spec, long *dataSize, long *rsrcSize);
|
||||
|
||||
char* p2c_strdup( StringPtr pstr);
|
||||
|
||||
void std::exit( int status);
|
||||
|
||||
|
||||
//CWResult LocateFile(CWPluginContext context, const char* filename, FSSpec& file);
|
||||
//StringPtr c2p_strcpy(StringPtr pstr, const char* cstr);
|
Loading…
Add table
Reference in a new issue