#!/usr/bin/perl #* #******************************************************************************* #* Copyright (C) 2006, International Business Machines #* Corporation and others. All Rights Reserved. #******************************************************************************* #* #* file name: genheaders.pl #* encoding: US-ASCII #* tab size: 8 (not used) #* indentation:4 #* #* Created by: Ram Viswanadha #* #* This tool filters the deprecated.html and friends file generated by Doxygen and generates udarft.h #* udeprctd.h and uobslete.h #* use File::Find; use File::Basename; use IO::File; use Cwd; use File::Copy; use Getopt::Long; use File::Path; use File::Copy; $draftHeaderName = "udraft.h"; $draftAppend = "DRAFT_API_DO_NOT_USE"; $draftDefine = "U_HIDE_DRAFT_API"; $deprecatedHeaderName = "udeprctd.h"; $deprecatedAppend = "DEPRECATED_API_DO_NOT_USE"; $deprecatedDefine = "U_HIDE_DEPRECATED_API"; $obsoleteHeaderName = "uobslete.h"; $obsoleteAppend = "OBSOLETE_API_DO_NOT_USE"; $obsoleteDefine = "U_HIDE_OBSOLETE_API"; $systemHeaderName = "usystem.h"; $systemAppend = "SYSTEM_API_DO_NOT_USE"; $systemDefine = "U_HIDE_SYSTEM_API"; $internalHeaderName = "uinternal.h"; $internalAppend = "INTERNAL_API_DO_NOT_USE"; $internalDefine = "U_HIDE_INTERNAL_API"; $versionAppend=""; #run the program main(); #--------------------------------------------------------------------- # The main program sub main(){ GetOptions( "--srcdir=s" => \$srcDir, "--destdir=s" => \$destDir, "--version=s" => \$version, "--exclusion-list=s" => \$exclude, ); usage() unless defined $srcDir; usage() unless defined $destDir; usage() unless defined $version; usage() unless defined $exclude; $draftFile = "$srcDir/draft.html"; $deprecatedFile = "$srcDir/deprecated.html"; $obsoleteFile = "$srcDir/obsolete.html"; $systemFile = "$srcDir/system.html"; $internalFile = "$srcDir/internal.html"; $versionAppend = $version; $versionAppend=~ s/\./_/; $excludeFH = IO::File->new($exclude,"r") or die "could not open the file $exclude for reading: $! \n"; my %exclude; while (defined ($line = <$excludeFH>)){ $line =~ s/^\s+//; $line =~ s/\s+\n$//; $exclude{$line}="EXCLUDE"; } writeFile($draftFile, $draftHeaderName, $destDir, $draftAppend, $draftDefine, \%exclude); writeFile($deprecatedFile, $deprecatedHeaderName, $destDir, $deprecatedAppend, $deprecatedDefine, \%exclude); writeFile($obsoleteFile, $obsoleteHeaderName, $destDir, $obsoleteAppend, $obsoleteDefine, \%exclude); writeFile($systemFile, $systemHeaderName, $destDir, $systemAppend, $systemDefine, \%exclude); writeFile($internalFile, $internalHeaderName, $destDir, $internalAppend, $internalDefine, \%exclude); } #----------------------------------------------------------------------- sub getHeaderDef{ ($headerName) = @_; $headerDef = uc($headerName); # this is building the constant for #define $headerDef =~ s/\./_/; return $headerDef; } #----------------------------------------------------------------------- sub writeFile{ ($infile,$outfile,$destDir, $symbolAppend, $symbolDef, $exclude) = @_; $outfile = $destDir."/".$outfile; $inFH = IO::File->new($infile,"r") or die "could not open the file $infile for reading: $! \n"; $outFH = IO::File->new($outfile,"w") or die "could not open the file $outfile for writing: $! \n"; $headerDef = getHeaderDef($outFileName); printHeader($outFH, $outFileName, $headerDef, $symbolDef); parseWriteFile($inFH, $outFH, $symbolAppend, $exclude); printFooter($outFH, $headerDef, $symbolDef); close($inFH); close($outFH); } #----------------------------------------------------------------------- sub printHeader{ ($outFH, $headername, $HEADERDEF, $symbolDef) = @_; #We will print our copyright here + warnings print $outFH <)){ #just process C APIs for now if($line =~ /\/ ){ #special cases if( ($line =~ /LEUnicode/)|| ($line =~ /LanguageCodes/) || ($line =~ /ScriptCodes/) || ($line =~ /\:+/) || ($line =~ /Class/) ){ next; } #
Global utrans_unregister
#
Global UnicodeString::kInvariant
# the below regular expression works for both the above formats. $line=~ m/\.*\(.*)\<\/dt\>/; my $value = $1; $value =~ s/\<\/a\>\s*//g; $value =~ s/^\s+//; $value =~ s/\s+$//; #print "$exclude->{$value}\n"; if($exclude->{$value} eq "EXCLUDE"){ #print "$value $exclude->{$value}\n"; next; } #next if(isStringAllCaps($value)==1); $realSymbol = $value."_".$versionAppend; $nonExSymbol = $value."_".$symbolAppend; $disableRenaming{$value} = $nonExSymbol; $enableRenaming{$realSymbol} = $nonExSymbol; #print "$value $realSymbol $nonExSymbol\n"; } } print "size of disableRenaming: " . keys( %disableRenaming) . ".\n"; print "size of enableRenaming: " . keys( %enableRenaming) . ".\n"; print $outFH "# if U_DISABLE_RENAMING\n"; foreach $key (sort (keys(%disableRenaming))) { print $outFH "# define $key $disableRenaming{$key}\n"; delete($disableRenaming{$key}); } print $outFH "# else\n"; foreach $key (sort (keys(%enableRenaming))) { print $outFH "# define $key $enableRenaming{$key}\n"; delete($enableRenaming{$key}); } print $outFH "# endif /* U_DISABLE_RENAMING */\n"; } #----------------------------------------------------------------------- sub isStringAllCaps{ ($string) = @_; @str = split(//, $string); foreach $val (@str){ $ret = 1; if(($val ne "_") && !($val =~ /[A-Z]/)){ #print "$val\n"; $ret = 0; } } return $ret; } #----------------------------------------------------------------------- sub printFooter{ ($outFH, $headerDef, $symbolDef ) = @_; #print the footer print $outFH < --destdir= --version= --exclusion-list= e.g.: genheaders.pl --srcdir=/source/common/docs/html --destdir=/source/common/unicode --version=2.8 --exclusion-list=exclude.txt END exit(0); }