2001-10-20 01:11:43 +00:00
|
|
|
#!/usr/bin/perl
|
2001-07-19 22:11:47 +00:00
|
|
|
#*
|
|
|
|
#*******************************************************************************
|
2003-06-09 22:45:28 +00:00
|
|
|
#* Copyright (C) 2001-2003, International Business Machines
|
2001-07-19 22:11:47 +00:00
|
|
|
#* Corporation and others. All Rights Reserved.
|
|
|
|
#*******************************************************************************
|
|
|
|
#*
|
|
|
|
#* file name: genren.pl
|
|
|
|
#* encoding: US-ASCII
|
|
|
|
#* tab size: 8 (not used)
|
|
|
|
#* indentation:4
|
|
|
|
#*
|
|
|
|
#* Created by: Vladimir Weinstein
|
|
|
|
#* 07/19/2001
|
|
|
|
#*
|
|
|
|
#* Used to generate renaming headers.
|
|
|
|
#* Run on UNIX platforms (linux) in order to catch all the exports
|
|
|
|
|
2001-07-21 05:23:27 +00:00
|
|
|
$headername = 'urename.h';
|
2001-07-19 22:11:47 +00:00
|
|
|
|
2001-07-25 20:21:54 +00:00
|
|
|
$path = substr($0, 0, rindex($0, "/")+1)."../../common/unicode/uversion.h";
|
|
|
|
|
|
|
|
(-e $path) || die "Cannot find uversion.h";
|
|
|
|
|
|
|
|
open(UVERSION, $path);
|
2001-10-20 01:11:43 +00:00
|
|
|
|
2001-07-25 20:21:54 +00:00
|
|
|
while(<UVERSION>) {
|
|
|
|
if(/\#define U_ICU_VERSION_SUFFIX/) {
|
|
|
|
chop;
|
|
|
|
s/\#define U_ICU_VERSION_SUFFIX //;
|
|
|
|
$U_ICU_VERSION_SUFFIX = "$_";
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
2001-07-19 22:11:47 +00:00
|
|
|
|
2001-07-21 05:23:27 +00:00
|
|
|
while($ARGV[0] =~ /^-/) { # detects whether there are any arguments
|
|
|
|
$_ = shift @ARGV; # extracts the argument for processing
|
|
|
|
/^-v/ && ($VERBOSE++, next); # verbose
|
|
|
|
/^-h/ && (&printHelpMsgAndExit, next); # help
|
|
|
|
/^-o/ && (($headername = shift (@ARGV)), next); # output file
|
|
|
|
/^-S/ && (($U_ICU_VERSION_SUFFIX = shift(@ARGV)), next); # pick the suffix
|
|
|
|
warn("Invalid option $_\n");
|
|
|
|
&printHelpMsgAndExit;
|
|
|
|
}
|
2001-07-19 22:11:47 +00:00
|
|
|
|
2001-07-21 05:23:27 +00:00
|
|
|
unless(@ARGV > 0) {
|
|
|
|
warn "No libraries, exiting...\n";
|
|
|
|
&printHelpMsgAndExit;
|
|
|
|
}
|
2001-07-19 22:11:47 +00:00
|
|
|
|
2001-07-21 05:23:27 +00:00
|
|
|
#$headername = "uren".substr($ARGV[0], 6, index(".", $ARGV[0])-7).".h";
|
|
|
|
|
|
|
|
$HEADERDEF = uc($headername); # this is building the constant for #define
|
|
|
|
$HEADERDEF =~ s/\./_/;
|
2001-07-19 22:11:47 +00:00
|
|
|
|
2001-07-21 05:23:27 +00:00
|
|
|
|
|
|
|
open HEADER, ">$headername"; # opening a header file
|
2001-07-19 22:11:47 +00:00
|
|
|
|
|
|
|
#We will print our copyright here + warnings
|
2001-07-21 05:23:27 +00:00
|
|
|
print HEADER <<"EndOfHeaderComment";
|
2001-07-19 22:11:47 +00:00
|
|
|
/*
|
|
|
|
*******************************************************************************
|
2003-06-09 22:45:28 +00:00
|
|
|
* Copyright (C) 2002-2003, International Business Machines
|
2001-07-19 22:11:47 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*******************************************************************************
|
|
|
|
*
|
2001-07-21 05:23:27 +00:00
|
|
|
* file name: $headername
|
2001-07-19 22:11:47 +00:00
|
|
|
* encoding: US-ASCII
|
|
|
|
* tab size: 8 (not used)
|
|
|
|
* indentation:4
|
|
|
|
*
|
|
|
|
* Created by: Perl script written by Vladimir Weinstein
|
|
|
|
*
|
2002-03-19 01:17:46 +00:00
|
|
|
* Contains data for renaming ICU exports.
|
2001-10-20 01:11:43 +00:00
|
|
|
* Gets included by umachine.h
|
2001-07-19 22:11:47 +00:00
|
|
|
*
|
|
|
|
* THIS FILE IS MACHINE-GENERATED, DON'T PLAY WITH IT IF YOU DON'T KNOW WHAT
|
|
|
|
* YOU ARE DOING, OTHERWISE VERY BAD THINGS WILL HAPPEN!
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef $HEADERDEF
|
2001-07-21 05:23:27 +00:00
|
|
|
#define $HEADERDEF
|
|
|
|
|
2002-02-13 20:29:16 +00:00
|
|
|
/* Uncomment the following line to disable renaming on platforms
|
|
|
|
that do not use Autoconf. */
|
2002-02-14 19:26:44 +00:00
|
|
|
/* #define U_DISABLE_RENAMING 1 */
|
2002-02-12 20:04:52 +00:00
|
|
|
|
2002-02-13 20:29:16 +00:00
|
|
|
#if !U_DISABLE_RENAMING
|
2001-07-21 05:23:27 +00:00
|
|
|
EndOfHeaderComment
|
|
|
|
|
|
|
|
for(;@ARGV; shift(@ARGV)) {
|
2001-07-23 20:57:07 +00:00
|
|
|
@NMRESULT = `nm -Cg -f s $ARGV[0]`;
|
2001-07-21 05:23:27 +00:00
|
|
|
if($?) {
|
|
|
|
warn "Couldn't do 'nm' for $ARGV[0], continuing...\n";
|
|
|
|
next; # Couldn't do nm for the file
|
|
|
|
}
|
2001-07-23 20:57:07 +00:00
|
|
|
splice @NMRESULT, 0, 6;
|
2001-07-21 05:23:27 +00:00
|
|
|
|
|
|
|
foreach (@NMRESULT) { # Process every line of result and stuff it in $_
|
2001-07-23 20:57:07 +00:00
|
|
|
($_, $address, $type) = split(/\|/);
|
2001-10-20 01:11:43 +00:00
|
|
|
&verbose( "type: \"$type\" ");
|
2001-10-23 17:43:56 +00:00
|
|
|
if(!($type =~ /[UAwW?]/)) {
|
2001-07-23 20:57:07 +00:00
|
|
|
if(/@@/) { # These would be imports
|
|
|
|
&verbose( "Import: $_ \"$type\"\n");
|
|
|
|
} elsif (/::/) { # C++ methods, stuff class name in associative array
|
|
|
|
&verbose( "C++ method: $_\n");
|
2001-10-20 01:11:43 +00:00
|
|
|
## icu_2_0::CharString::~CharString(void) -> CharString
|
|
|
|
@CppName = split(/::/); ## remove scope stuff
|
|
|
|
if(@CppName>1) {
|
|
|
|
## MessageFormat virtual table -> MessageFormat
|
|
|
|
@CppName = split(/ /, $CppName[1]); ## remove debug stuff
|
|
|
|
}
|
|
|
|
## ures_getUnicodeStringByIndex(UResourceBundle -> ures_getUnicodeStringByIndex
|
|
|
|
@CppName = split(/\(/, $CppName[0]); ## remove function args
|
2001-07-23 20:57:07 +00:00
|
|
|
$CppClasses{$CppName[0]}++;
|
2001-10-20 01:11:43 +00:00
|
|
|
} elsif ( /\(/) { # These are strange functions
|
2001-10-23 17:43:56 +00:00
|
|
|
print STDERR "$_\n";
|
|
|
|
} elsif ( /icu_/) {
|
|
|
|
print STDERR "Skipped strange mangled function $_\n";
|
2001-07-23 20:57:07 +00:00
|
|
|
} else { # This is regular C function
|
|
|
|
&verbose( "C func: $_\n");
|
|
|
|
@funcname = split(/[\(\s+]/);
|
|
|
|
$CFuncs{$funcname[0]}++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
&verbose( "Skipped: $_ $1\n");
|
2001-07-21 05:23:27 +00:00
|
|
|
}
|
2001-07-19 22:11:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-12 20:04:52 +00:00
|
|
|
print HEADER "\n/* C exports renaming data */\n\n";
|
2001-07-21 05:23:27 +00:00
|
|
|
foreach(sort keys(%CFuncs)) {
|
|
|
|
print HEADER "#define $_ $_$U_ICU_VERSION_SUFFIX\n";
|
|
|
|
}
|
2001-07-19 22:11:47 +00:00
|
|
|
|
2002-02-13 20:29:16 +00:00
|
|
|
print HEADER "/* C++ class names renaming defines */\n\n";
|
2001-10-20 01:11:43 +00:00
|
|
|
print HEADER "#ifdef XP_CPLUSPLUS\n";
|
2002-02-12 20:04:52 +00:00
|
|
|
print HEADER "#if !U_HAVE_NAMESPACE\n\n";
|
2001-07-21 05:23:27 +00:00
|
|
|
foreach(sort keys(%CppClasses)) {
|
2001-07-19 22:11:47 +00:00
|
|
|
print HEADER "#define $_ $_$U_ICU_VERSION_SUFFIX\n";
|
|
|
|
}
|
2002-02-12 20:04:52 +00:00
|
|
|
print HEADER "\n#endif\n";
|
2001-09-24 22:35:26 +00:00
|
|
|
print HEADER "#endif\n";
|
2002-02-12 20:04:52 +00:00
|
|
|
print HEADER "\n#endif\n";
|
|
|
|
print HEADER "\n#endif\n";
|
2001-07-19 22:11:47 +00:00
|
|
|
|
2001-07-21 05:23:27 +00:00
|
|
|
close HEADER;
|
|
|
|
|
|
|
|
sub verbose {
|
|
|
|
if($VERBOSE) {
|
|
|
|
print STDERR @_;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub printHelpMsgAndExit {
|
|
|
|
print STDERR <<"EndHelpText";
|
|
|
|
Usage: $0 [OPTIONS] LIBRARY_FILES
|
|
|
|
Options:
|
|
|
|
-v - verbose
|
|
|
|
-h - help
|
|
|
|
-o - output file name (defaults to 'urename.h'
|
|
|
|
-S - suffix (defaults to _MAJOR_MINOR of current ICU version)
|
|
|
|
Will produce a renaming .h file
|
|
|
|
|
|
|
|
EndHelpText
|
|
|
|
|
|
|
|
exit 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|