]>
git.saurik.com Git - apple/icu.git/blob - icuSources/tools/genren/genren.pl
3 #*******************************************************************************
4 #* Copyright (C) 2001-2004, International Business Machines
5 #* Corporation and others. All Rights Reserved.
6 #*******************************************************************************
8 #* file name: genren.pl
10 #* tab size: 8 (not used)
13 #* Created by: Vladimir Weinstein
16 #* Used to generate renaming headers.
17 #* Run on UNIX platforms (linux) in order to catch all the exports
19 $headername = 'urename.h';
21 $path = substr($0, 0, rindex($0, "/")+1)."../../common/unicode/uversion.h";
23 (-e
$path) || die "Cannot find uversion.h";
25 open(UVERSION
, $path);
28 if(/\#define U_ICU_VERSION_SUFFIX/) {
30 s/\#define U_ICU_VERSION_SUFFIX //;
31 $U_ICU_VERSION_SUFFIX = "$_";
36 while($ARGV[0] =~ /^-/) { # detects whether there are any arguments
37 $_ = shift @ARGV; # extracts the argument for processing
38 /^-v/ && ($VERBOSE++, next); # verbose
39 /^-h/ && (&printHelpMsgAndExit
, next); # help
40 /^-o/ && (($headername = shift (@ARGV)), next); # output file
41 /^-S/ && (($U_ICU_VERSION_SUFFIX = shift(@ARGV)), next); # pick the suffix
42 warn("Invalid option $_\n");
47 warn "No libraries, exiting...\n";
51 #$headername = "uren".substr($ARGV[0], 6, index(".", $ARGV[0])-7).".h";
53 $HEADERDEF = uc($headername); # this is building the constant for #define
54 $HEADERDEF =~ s/\./_/;
57 open HEADER
, ">$headername"; # opening a header file
59 #We will print our copyright here + warnings
60 print HEADER
<<"EndOfHeaderComment";
62 *******************************************************************************
63 * Copyright (C) 2002-2004, International Business Machines
64 * Corporation and others. All Rights Reserved.
65 *******************************************************************************
67 * file name: $headername
69 * tab size: 8 (not used)
72 * Created by: Perl script written by Vladimir Weinstein
74 * Contains data for renaming ICU exports.
75 * Gets included by umachine.h
77 * THIS FILE IS MACHINE-GENERATED, DON'T PLAY WITH IT IF YOU DON'T KNOW WHAT
78 * YOU ARE DOING, OTHERWISE VERY BAD THINGS WILL HAPPEN!
84 /* Uncomment the following line to disable renaming on platforms
85 that do not use Autoconf. */
86 /* #define U_DISABLE_RENAMING 1 */
88 #if !U_DISABLE_RENAMING
91 for(;@ARGV; shift(@ARGV)) {
92 @NMRESULT = `nm -Cg -f s $ARGV[0]`;
94 warn "Couldn't do 'nm' for $ARGV[0], continuing...\n";
95 next; # Couldn't do nm for the file
97 splice @NMRESULT, 0, 6;
99 foreach (@NMRESULT) { # Process every line of result and stuff it in $_
100 ($_, $address, $type) = split(/\|/);
101 &verbose
( "type: \"$type\" ");
102 if(!($type =~ /[UAwW?]/)) {
103 if(/@@/) { # These would be imports
104 &verbose
( "Import: $_ \"$type\"\n");
105 } elsif (/::/) { # C++ methods, stuff class name in associative array
106 &verbose
( "C++ method: $_\n");
107 ## icu_2_0::CharString::~CharString(void) -> CharString
108 @CppName = split(/::/); ## remove scope stuff
110 ## MessageFormat virtual table -> MessageFormat
111 @CppName = split(/ /, $CppName[1]); ## remove debug stuff
113 ## ures_getUnicodeStringByIndex(UResourceBundle -> ures_getUnicodeStringByIndex
114 @CppName = split(/\(/, $CppName[0]); ## remove function args
115 $CppClasses{$CppName[0]}++;
116 } elsif ( /\(/) { # These are strange functions
119 print STDERR
"Skipped strange mangled function $_\n";
120 } else { # This is regular C function
121 &verbose
( "C func: $_\n");
122 @funcname = split(/[\(\s+]/);
123 $CFuncs{$funcname[0]}++;
126 &verbose
( "Skipped: $_ $1\n");
131 print HEADER
"\n/* C exports renaming data */\n\n";
132 foreach(sort keys(%CFuncs)) {
133 print HEADER
"#define $_ $_$U_ICU_VERSION_SUFFIX\n";
136 print HEADER
"/* C++ class names renaming defines */\n\n";
137 print HEADER
"#ifdef XP_CPLUSPLUS\n";
138 print HEADER
"#if !U_HAVE_NAMESPACE\n\n";
139 foreach(sort keys(%CppClasses)) {
140 print HEADER
"#define $_ $_$U_ICU_VERSION_SUFFIX\n";
142 print HEADER
"\n#endif\n";
143 print HEADER
"#endif\n";
144 print HEADER
"\n#endif\n";
145 print HEADER
"\n#endif\n";
156 sub printHelpMsgAndExit
{
157 print STDERR
<<"EndHelpText";
158 Usage: $0 [OPTIONS] LIBRARY_FILES
162 -o - output file name (defaults to 'urename.h'
163 -S - suffix (defaults to _MAJOR_MINOR of current ICU version)
164 Will produce a renaming .h file