summaryrefslogtreecommitdiff
path: root/offapi/util/checknewapi.pl
blob: 69d79fc50cb128739628d427faf6d75c66621cc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#
# checknewapi - a perl script to check for new API's
# using two outputs from regview and dump the interscetion
# of new types
#
# Copyright 2000, 2010 Oracle and/or its affiliates.
#

if($#ARGV != 3)
{
    die "usage: checknewapi <new_type_library> <reference_type_library> <buildinfodescr> <fullpath_regview>\n";
}

-e "$ARGV[0]" || die "ERROR: type library \"$ARGV[0]\" does not exist\n";
-e "$ARGV[1]" || die "ERROR: reference type library \"$ARGV[1]\" does not exist\n";
-e "$ARGV[3]" || die "ERROR: invalid path to the regview tool \"$ARGV[3]\", please specify the full qualified path\n";

# debug flag
$DEBUG = 0;

$main::buildinfo = "$ARGV[2]";
$main::regview = "$ARGV[3]";
%{$main::reftypes} = ();
%{$main::currenttypes} = ();
%{$main::removedtypes} = ();

open ( FILEIN, "$main::regview \"$ARGV[0]\" |" ) || die "could not use content of current typelibrary \"$ARGV[0]\", regview doesn't work\n";

if ($DEBUG == 1)
{
    open( CURRENT, ">current_types.txt" ) || die "\nERROR: could not open current_types.txt for writing";
}

$first = 1;
$linebefore = "";
$published = 0;
$typeclass = "";
while (<FILEIN>)
{
    if ($first == 0) 
    {
        if ( $linebefore =~ m#type class: published (.+)# ) 
        {
            $published = 1;
            $typeclass = $1;
        } elsif ( $linebefore =~ m#type class: (.+)# ) 
        {
            $published = 0;
            $typeclass = $1;
        } else
        {
            $published = 0;
            $typeclass = "";
        }
    } else 
    {
        $first = 0;
    }

    if ( (!$typeclass eq "") && ($_ =~ m# *type name: \"([^\[.]+)\"#) ) 
    {
        if ($DEBUG == 1)
        {
            print CURRENT "$1\n";
        }
        if ( ! exists $main::currenttypes->{$1} )
        {
            $main::currenttypes->{$1} = { PUBLISHED => $published,
                                          TYPECLASS => $typeclass,
                                          COUNT => 1 };
#			print "### $main::currenttypes->{$1}->{PUBLISHED} $main::currenttypes->{$1}->{TYPECLASS} $main::currenttypes->{$1}->{COUNT}\n";
        }
    }
    $linebefore = $_;
}
close( FILEIN );
close( CURRENT );

open ( FILEIN, "$main::regview \"$ARGV[1]\" |" ) || die "could not use content of reference type library \"$ARGV[1]\", regview doesn't work\n";

if ($DEBUG == 1)
{
    open( REFERENCE, ">reference_types.txt" ) || die "\nERROR: could not open reference_types.txt for writing";
}

# reset variables
$first = 1;
$linebefore = "";
$published = 0;
$typeclass = "";
while (<FILEIN>)
{
    if ($first == 0) 
    {
        if ( $linebefore =~ m#type class: published (.+)# ) 
        {
            $published = 1;
            $typeclass = $1;
        } elsif ( $linebefore =~ m#type class: (.+)# ) 
        {
            $published = 0;
            $typeclass = $1;
        } else
        {
            $published = 0;
            $typeclass = "";
        }
    } else 
    {
        $first = 0;
    }

    if ( (!$typeclass eq "") && ($_ =~ m# *type name: \"([^\[.]+)\"#) ) 
    {
        if ($DEBUG == 1)
        {
            print REFERENCE "$1\n";
        }
        if ( ! exists $main::reftypes->{$1} )
        {
            $main::reftypes->{$1}++;
            
            if ( exists $main::currenttypes->{$1} )
            {
                $main::currenttypes->{$1}->{COUNT}++;
#				print "###### $main::currenttypes->{$1}->{PUBLISHED} $main::currenttypes->{$1}->{TYPECLASS} $main::currenttypes->{$1}->{COUNT}\n";
            } else 
            {
                if ($published == 0)
                {
                    $main::removedtypes->{$1} = { PUBLISHED => $published,
                                                  TYPECLASS => $typeclass };
                } else
                {
                    print "ERROR: type $1 is only in reference type library, this can't be happen\n"; 
                }
            }
        }
    }
    $linebefore = $_;
}
close( FILEIN );
close( REFERENCE );


@typekeys = keys %{$main::currenttypes};
$allunotypes = $#typekeys+1;
$newunotypes = 0;
$newpublished = 0;
$draftscount = 0;
$draftspublished = 0;
foreach $i ( sort @typekeys )
{
    if ( $main::currenttypes->{$i}->{COUNT} == 1 &&
         !("$main::currenttypes->{$i}->{TYPECLASS}" eq "module"))
    {
        $newunotypes++;
        my $t = $i;
        $t =~ s#/#\.#go;
        if ($main::currenttypes->{$i}->{PUBLISHED} == 1) 
        {
            print "published ";
            $newpublished++;
        }
        if ( $t =~ m#drafts\.com.+#)
        {
            $draftscount++;
            if ($main::currenttypes->{$i}->{PUBLISHED} == 1) 
            {
                $draftspublished++;
            }
        }
        print "$main::currenttypes->{$i}->{TYPECLASS} = $t\n";
    }
}

# count removed not yet published types
$removednotpublished = 0;

@removedtypekeys = keys %{$main::removedtypes};
foreach $i ( sort @removedtypekeys )
{
    $removednotpublished++;
    my $t = $i;
    $t =~ s#/#\.#go;
    print "removed not yet published $main::currenttypes->{$i}->{TYPECLASS} = $t\n";
}

print "\n=======================================================\n\n";
print "Summary [last check for $main::buildinfo]:\n\n";
print "Number of UNO types = $allunotypes\n";
print "Number of new UNO types = $newunotypes\n";
print "New and published types = $newpublished\n";
print "New and draft types = $draftscount\n";
print "New, draft and published = $draftspublished\n";
print "Removed and not published = $removednotpublished\n";

exit 0;