fix toolbar import
[ooovba.git] / offapi / util / checknewapi.pl
blobf8d46762f738fba2a66a18aaa30b242dd0eb414c
2 # checknewapi - a perl script to check for new API's
3 # using two outputs from regview and dump the interscetion
4 # of new types
6 # Copyright (c) 2005 Sun Microsystems, Inc.
9 if($#ARGV != 2)
11 die "usage: checknewapi <new_type_library> <reference_type_library> <buildinfodescr>\n";
14 -e "$ARGV[0]" || die "ERROR: type library \"$ARGV[0]\" does not exist\n";
15 -e "$ARGV[1]" || die "ERROR: reference type library \"$ARGV[1]\" does not exist\n";
17 # debug flag
18 $DEBUG = 0;
20 $main::buildinfo = "$ARGV[2]";
21 %{$main::reftypes} = ();
22 %{$main::currenttypes} = ();
23 %{$main::removedtypes} = ();
25 open ( FILEIN, "regview \"$ARGV[0]\" |" ) || die "could not use content of current typelibrary \"$ARGV[0]\", regview doesn't work\n";
27 if ($DEBUG == 1)
29 open( CURRENT, ">current_types.txt" ) || die "\nERROR: could not open current_types.txt for writing";
32 $first = 1;
33 $linebefore = "";
34 $published = 0;
35 $typeclass = "";
36 while (<FILEIN>)
38 if ($first == 0)
40 if ( $linebefore =~ m#type class: published (.+)# )
42 $published = 1;
43 $typeclass = $1;
44 } elsif ( $linebefore =~ m#type class: (.+)# )
46 $published = 0;
47 $typeclass = $1;
48 } else
50 $published = 0;
51 $typeclass = "";
53 } else
55 $first = 0;
58 if ( (!$typeclass eq "") && ($_ =~ m# *type name: \"([^\[.]+)\"#) )
60 if ($DEBUG == 1)
62 print CURRENT "$1\n";
64 if ( ! exists $main::currenttypes->{$1} )
66 $main::currenttypes->{$1} = { PUBLISHED => $published,
67 TYPECLASS => $typeclass,
68 COUNT => 1 };
69 # print "### $main::currenttypes->{$1}->{PUBLISHED} $main::currenttypes->{$1}->{TYPECLASS} $main::currenttypes->{$1}->{COUNT}\n";
72 $linebefore = $_;
74 close( FILEIN );
75 close( CURRENT );
77 open ( FILEIN, "regview \"$ARGV[1]\" |" ) || die "could not use content of reference type library \"$ARGV[1]\", regview doesn't work\n";
79 if ($DEBUG == 1)
81 open( REFERENCE, ">reference_types.txt" ) || die "\nERROR: could not open reference_types.txt for writing";
84 # reset variables
85 $first = 1;
86 $linebefore = "";
87 $published = 0;
88 $typeclass = "";
89 while (<FILEIN>)
91 if ($first == 0)
93 if ( $linebefore =~ m#type class: published (.+)# )
95 $published = 1;
96 $typeclass = $1;
97 } elsif ( $linebefore =~ m#type class: (.+)# )
99 $published = 0;
100 $typeclass = $1;
101 } else
103 $published = 0;
104 $typeclass = "";
106 } else
108 $first = 0;
111 if ( (!$typeclass eq "") && ($_ =~ m# *type name: \"([^\[.]+)\"#) )
113 if ($DEBUG == 1)
115 print REFERENCE "$1\n";
117 if ( ! exists $main::reftypes->{$1} )
119 $main::reftypes->{$1}++;
121 if ( exists $main::currenttypes->{$1} )
123 $main::currenttypes->{$1}->{COUNT}++;
124 # print "###### $main::currenttypes->{$1}->{PUBLISHED} $main::currenttypes->{$1}->{TYPECLASS} $main::currenttypes->{$1}->{COUNT}\n";
125 } else
127 if ($published == 0)
129 $main::removedtypes->{$1} = { PUBLISHED => $published,
130 TYPECLASS => $typeclass };
131 } else
133 print "ERROR: type $1 is only in reference type library, this can't be happen\n";
138 $linebefore = $_;
140 close( FILEIN );
141 close( REFERENCE );
144 @typekeys = keys %{$main::currenttypes};
145 $allunotypes = $#typekeys+1;
146 $newunotypes = 0;
147 $newpublished = 0;
148 $draftscount = 0;
149 $draftspublished = 0;
150 foreach $i ( sort @typekeys )
152 if ( $main::currenttypes->{$i}->{COUNT} == 1 &&
153 !("$main::currenttypes->{$i}->{TYPECLASS}" eq "module"))
155 $newunotypes++;
156 my $t = $i;
157 $t =~ s#/#\.#go;
158 if ($main::currenttypes->{$i}->{PUBLISHED} == 1)
160 print "published ";
161 $newpublished++;
163 if ( $t =~ m#drafts\.com.+#)
165 $draftscount++;
166 if ($main::currenttypes->{$i}->{PUBLISHED} == 1)
168 $draftspublished++;
171 print "$main::currenttypes->{$i}->{TYPECLASS} = $t\n";
175 # count removed not yet published types
176 $removednotpublished = 0;
178 @removedtypekeys = keys %{$main::removedtypes};
179 foreach $i ( sort @removedtypekeys )
181 $removednotpublished++;
182 my $t = $i;
183 $t =~ s#/#\.#go;
184 print "removed not yet published $main::currenttypes->{$i}->{TYPECLASS} = $t\n";
187 print "\n=======================================================\n\n";
188 print "Summary [last check for $main::buildinfo]:\n\n";
189 print "Number of UNO types = $allunotypes\n";
190 print "Number of new UNO types = $newunotypes\n";
191 print "New and published types = $newpublished\n";
192 print "New and draft types = $draftscount\n";
193 print "New, draft and published = $draftspublished\n";
194 print "Removed and not published = $removednotpublished\n";
196 exit 0;