]>
git.saurik.com Git - apple/icu.git/blob - icuSources/tools/gendraft/genheaders.pl
3 #*******************************************************************************
4 #* Copyright (C) 2006, International Business Machines
5 #* Corporation and others. All Rights Reserved.
6 #*******************************************************************************
8 #* file name: genheaders.pl
10 #* tab size: 8 (not used)
13 #* Created by: Ram Viswanadha
15 #* This tool filters the deprecated.html and friends file generated by Doxygen and generates udarft.h
16 #* udeprctd.h and uobslete.h
28 $draftHeaderName = "udraft.h";
29 $draftAppend = "DRAFT_API_DO_NOT_USE";
30 $draftDefine = "U_HIDE_DRAFT_API";
32 $deprecatedHeaderName = "udeprctd.h";
33 $deprecatedAppend = "DEPRECATED_API_DO_NOT_USE";
34 $deprecatedDefine = "U_HIDE_DEPRECATED_API";
36 $obsoleteHeaderName = "uobslete.h";
37 $obsoleteAppend = "OBSOLETE_API_DO_NOT_USE";
38 $obsoleteDefine = "U_HIDE_OBSOLETE_API";
40 $systemHeaderName = "usystem.h";
41 $systemAppend = "SYSTEM_API_DO_NOT_USE";
42 $systemDefine = "U_HIDE_SYSTEM_API";
44 $internalHeaderName = "uintrnal.h";
45 $internalAppend = "INTERNAL_API_DO_NOT_USE";
46 $internalDefine = "U_HIDE_INTERNAL_API";
52 #---------------------------------------------------------------------
57 "--srcdir=s" => \
$srcDir,
58 "--destdir=s" => \
$destDir,
59 "--version=s" => \
$version,
60 "--exclusion-list=s" => \
$exclude,
61 "--include-types" => \
$includeTypes
63 usage
() unless defined $srcDir;
64 usage
() unless defined $destDir;
65 usage
() unless defined $version;
66 usage
() unless defined $exclude;
67 $draftFile = "$srcDir/draft.html";
68 $deprecatedFile = "$srcDir/deprecated.html";
69 $obsoleteFile = "$srcDir/obsolete.html";
70 $systemFile = "$srcDir/system.html";
71 $internalFile = "$srcDir/internal.html";
73 $versionAppend = $version;
74 $versionAppend=~ s/\./_/;
75 $excludeFH = IO
::File-
>new($exclude,"r")
76 or die "could not open the file $exclude for reading: $! \n";
78 while (defined ($line = <$excludeFH>)){
79 next if( $line =~ /^#/);
82 $exclude{$line}="EXCLUDE";
85 writeFile
($draftFile, $draftHeaderName, $destDir, $draftAppend, $draftDefine, \
%exclude);
86 writeFile
($deprecatedFile, $deprecatedHeaderName, $destDir, $deprecatedAppend, $deprecatedDefine, \
%exclude);
87 writeFile
($obsoleteFile, $obsoleteHeaderName, $destDir, $obsoleteAppend, $obsoleteDefine, \
%exclude);
88 writeFile
($systemFile, $systemHeaderName, $destDir, $systemAppend, $systemDefine, \
%exclude);
89 writeFile
($internalFile, $internalHeaderName, $destDir, $internalAppend, $internalDefine, \
%exclude);
92 #-----------------------------------------------------------------------
95 $headerDef = uc($headerName); # this is building the constant for #define
96 $headerDef =~ s/\./_/;
100 #-----------------------------------------------------------------------
102 ($infile,$outfile,$destDir, $symbolAppend, $symbolDef, $exclude) = @_;
104 $headerDef = getHeaderDef
($outfile);
106 $outfile = $destDir."/".$outfile;
108 $inFH = IO
::File-
>new($infile,"r")
109 or die "could not open the file $infile for reading: $! \n";
110 $outFH = IO
::File-
>new($outfile,"w")
111 or die "could not open the file $outfile for writing: $! \n";
113 #print "$headerDef>>> $outfile\n";
114 printHeader
($outFH, $outFileName, $headerDef, $symbolDef);
115 parseWriteFile
($inFH, $outFH, $symbolAppend, $exclude);
116 printFooter
($outFH, $headerDef, $symbolDef);
121 #-----------------------------------------------------------------------
123 ($outFH, $headername, $HEADERDEF, $symbolDef) = @_;
124 ($DAY, $MONTH, $YEAR) = (localtime)[3,4,5];
126 #We will print our copyright here + warnings
127 print $outFH <<END_HEADER_COMMENT;
129 *******************************************************************************
130 * Copyright (C) 2004-$YEAR, International Business Machines
131 * Corporation and others. All Rights Reserved.
132 *******************************************************************************
134 * file name: $headername
136 * tab size: 8 (not used)
139 * Created by: genheaders.pl, a perl script written by Ram Viswanadha
141 * Contains data for commenting out APIs.
142 * Gets included by umachine.h
144 * THIS FILE IS MACHINE-GENERATED, DON'T PLAY WITH IT IF YOU DON'T KNOW WHAT
145 * YOU ARE DOING, OTHERWISE VERY BAD THINGS WILL HAPPEN!
156 #-----------------------------------------------------------------------
158 ($inFH, $outFH, $symbolAppend, $exclude) = @_;
161 while (defined ($line = <$inFH>)){
162 #just process C APIs for now
163 if($line =~ /\<dt\>/ ){
165 if( ($line =~ /LEUnicode/)|| ($line =~ /LanguageCodes/) ||
166 ($line =~ /ScriptCodes/) || ($line =~ /\:+/) ||
167 ($line =~ /Class/) ){
170 #<dt>Global <a class="el" href="utrans_8h.html#a21">utrans_unregister</a> </dt>
171 #<dt>Global <a class="el" href="classUnicodeString.html#w1w0">UnicodeString::kInvariant</a> </dt>
172 # the below regular expression works for both the above formats.
173 $line=~ m/\<dt\>.*\<a class=\".*\" href=\".*\">(.*)\<\/dt\
>/;
175 $value =~ s/\<\/a\>\s*//g
;
178 #print "$exclude->{$value}\n";
179 if($exclude->{$value} eq "EXCLUDE"){
180 #print "$value $exclude->{$value}\n";
183 #print "$value $realSymbol $nonExSymbol\n";
184 next if(isStringAcceptable
($value)==1);
185 $realSymbol = $value."_".$versionAppend;
186 $nonExSymbol = $value."_".$symbolAppend;
187 $disableRenaming{$value} = $nonExSymbol;
188 $enableRenaming{$realSymbol} = $nonExSymbol;
189 #print "$value $realSymbol $nonExSymbol\n";
193 print "size of disableRenaming: " . keys( %disableRenaming) . ".\n";
194 print "size of enableRenaming: " . keys( %enableRenaming) . ".\n";
195 print $outFH "# if U_DISABLE_RENAMING\n";
196 foreach $key (sort (keys(%disableRenaming))) {
197 print $outFH "# define $key $disableRenaming{$key}\n";
198 delete($disableRenaming{$key});
200 print $outFH "# else\n";
201 foreach $key (sort (keys(%enableRenaming))) {
202 print $outFH "# define $key $enableRenaming{$key}\n";
203 delete($enableRenaming{$key});
205 print $outFH "# endif /* U_DISABLE_RENAMING */\n";
207 #-----------------------------------------------------------------------
208 sub isStringAcceptable
{
210 @str = split(//, $string);
213 if(($val ne "_") && !($val =~ /[0-9A-Z]/)){
218 #print "$string : $ret\n";
219 if(!(defined $includeTypes)){
220 if($ret==0 && $str[0] eq 'U'){
227 #-----------------------------------------------------------------------
230 ($outFH, $headerDef, $symbolDef ) = @_;
232 print $outFH <<END_FOOTER;
234 #endif /* $symbolDef */
235 #endif /* $headerDef */
239 #-----------------------------------------------------------------------
246 --destdir
=<directory
>
247 --version
=<current version of ICU
>
248 --exclusion-list
=<file name
>
250 e
.g
.: genheaders
.pl
--srcdir
=<icu
>/source/common
/docs/html
--destdir
=<icu
>/source/common
/unicode
--version
=2.8 --exclusion-list
=exclude
.txt