File: check_api_completeness.sh

package info (click to toggle)
plplot 5.10.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 26,280 kB
  • ctags: 13,512
  • sloc: ansic: 83,001; xml: 27,081; ada: 18,878; cpp: 15,966; tcl: 11,651; python: 7,075; f90: 7,058; ml: 6,974; java: 6,665; perl: 5,029; sh: 2,210; makefile: 199; lisp: 75; sed: 25; fortran: 7
file content (176 lines) | stat: -rwxr-xr-x 5,119 bytes parent folder | download | duplicates (2)
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
#!/bin/bash
# This Linux-only script creates a sorted list of our API from several
# independent locations within our source tree and finds all the 
# inconsistencies between them.

# This script should be run from the top-level source tree.

# Prepare API list from include/plplot.h to be compared with all others.
# Be sure to remove officially deprecated functions.
grep '^#define.*pl.*c_pl' include/plplot.h |\
grep -v plParseInternalOpts |\
tr '\t' " " |\
tr -s " " |\
cut --delimiter=" " --fields=2 |\
grep -v 'plclr$' |\
grep -v 'plcol$' |\
grep -v 'plhls$' |\
grep -v 'plpage$' |\
grep -v 'plrgb$' |\
grep -v 'plrgb1$' |\
sort \
>| /tmp/plplot_api.txt

case $1 in
  docbook)
    # Prepare API list from doc/docbook/src/api.xml
    # and compare with previous
    echo "documentation API differences (if any)"
    grep '<sect1.*id="pl.*".*renderas="sect.*">$' doc/docbook/src/api.xml |\
    cut --delimiter='"' --fields=2 |\
    sort |\
    diff -au /tmp/plplot_api.txt -
  ;;
  
  swig)
    # Prepare API list from bindings/swig-support/plplotcapi.i
    # and compare with previous
    echo "swig API differences (if any)"
    # The grep -v '[A-Z]' stanza gets rid of some of the non-public API that
    # is exposed for the swig-generated bindings, and similarly for the list
    # of commands that are excluded.  The grep -v stanzas also get rid of
    # deprecated API that is mentioned but excluded with #if 0 ... #endif
    
    grep '^pl.*(' bindings/swig-support/plplotcapi.i |\
    cut --delimiter='(' --fields=1 |\
    grep -v '[A-Z]' |\
    grep -v pl_cmd |\
    grep -v pldid2pc |\
    grep -v pldip2dc |\
    grep -v plf2eval |\
    grep -v plf2eval2 |\
    grep -v plf2evalr |\
    grep -v plfcont |\
    grep -v plfshade |\
    grep -v plgesc |\
    grep -v plgfile |\
    grep -v plsexit |\
    grep -v plsfile |\
    grep -v plsxwin |\
    grep -v pltr0f |\
    grep -v pltr2f |\
    grep -v pltr2p |\
    grep -v 'plhls$' |\
    grep -v 'plrgb$' |\
    grep -v 'plrgb1$' |\
    sort |\
    diff -au /tmp/plplot_api.txt -
  ;;

  java)
    # Prepare API list from bindings/java/PLStream.java
    # and compare with previous.
    echo "java API differences (if any)"
    # The grep -v '[A-Z]' stanza gets rid of some of the non-public API that
    # is exposed.
    # Also get rid of the deprecated plhls from the comparison.
    grep 'plplotjavac.pl.*(' bindings/java/PLStream.java |\
    cut --delimiter='(' --fields=1 |\
    cut --delimiter='.' --fields=2 |\
    sort -u |\
    grep -v '[A-Z]' |\
    grep -v 'plhls$' |\
    diff -au /tmp/plplot_api.txt -
  ;;

  octave)
    # Prepare API list from bindings/octave/plplot_octave.h.in
    # and compare with previous.
    echo "octave API differences (if any)"
    grep '^#define.*pl.*c_pl' bindings/octave/plplot_octave.h.in |\
    grep -v plParseInternalOpts |\
    tr '\t' " " |\
    tr -s " " |\
    cut --delimiter=" " --fields=2 |\
    sort |\
    diff -au /tmp/plplot_api.txt -
  ;;
  
  f95)
    # Prepare API list from bindings/f95/plstubs.h
    # and compare with previous
    echo "f95 API differences (if any)"
    # After obtaining the basic name with paranthesis appended, we get rid of
    # that paranthesis and any trailing "_", and "7".  We then do a unique
    # sort to get rid of duplicates, and specifically exclude some added special
    # fortran functions (whose original form may have had a "7" appended).
    # We also remove the plhls, plrgb, and plrgb1 deprecated functions.
    grep 'FNAME.*,pl.*)' bindings/f95/plstubs.h |\
    cut --delimiter="," --fields=2 |\
    sed -e 's?)??' -e 's?_$??' -e 's?7$??' |\
    sort -u |\
    grep -v plclr |\
    grep -v 'plcol$' |\
    grep -v plcon0 |\
    grep -v plcon1 |\
    grep -v plcon2 |\
    grep -v plscmap1l2 |\
    grep -v plscmap1la2 |\
    grep -v plshade0 |\
    grep -v plshade2 |\
    grep -v plshades0 |\
    grep -v plshades1 |\
    grep -v plshades2 |\
    grep -v plvec0 |\
    grep -v plvec1 |\
    grep -v plvec2 |\
    grep -v 'plhls$' |\
    grep -v 'plrgb$' |\
    grep -v 'plrgb1$' |\
    diff -au /tmp/plplot_api.txt - 
  ;;
  
  c++)
    # Prepare API list from bindings/c++/plstream.h
    # and compare with previous.
    echo "c++ API differences (if any)"
    grep 'plstream::' bindings/c++/plstream.cc |\
    grep -v '//' |\
    grep '(' |\
    cut --delimiter='(' --fields=1 |\
    cut --delimiter=':' --fields=3 |\
    sed 's/[^ ]*/pl&/' |\
    sort -u |\
    grep -v '[A-Z]' |\
    diff -au /tmp/plplot_api.txt -
  ;;

  tcl)
    # Prepare API list from bindings/tcl/plapi.tpl
    echo "tcl API differences (if any)"
    ( grep '^pltclcmd' bindings/tcl/plapi.tpl |\
      cut --delimiter=' ' --fields=2  && \
      grep '{"pl' bindings/tcl/tclAPI.c | \
      cut --delimiter='"' --fields=2 \
    ) | \
    sort -u | \
    diff -au /tmp/plplot_api.txt - 
  ;;

  all)
    $0 docbook
    $0 swig
    $0 java
    $0 octave
    $0 f95
    $0 c++
    $0 tcl
  ;;

  *)
  echo "First argument was $1"
  echo "Instead, it must be one of the following:"
  echo "docbook, swig, java, octave, f95, c++, tcl or all"
  ;;
esac
#rm /tmp/plplot_api.txt