1 # Copyright (C) 2006-2022 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # This awk program checks the arguments and return value compatibility
26 # allowed types for arguments
29 arg_type["double"]= 1;
33 arg_type["unsigned"]= 1;
34 arg_type["const char*"]= 1;
35 arg_type["const std::string&"]= 1;
37 arg_type["double&"]= 1;
38 arg_type["float&"]= 1;
40 arg_type["short&"]= 1;
41 arg_type["unsigned&"]= 1;
42 arg_type["std::string&"]= 1;
43 arg_type["const MEDMEM::MESH&"]= 1;
44 arg_type["const MEDMEM::MESH*"]= 1;
45 arg_type["const MEDMEM::FIELD<double>*"]= 1;
46 arg_type["const MEDMEM::FIELD<double>&"]= 1;
47 arg_type["MEDMEM::FIELD<double>*&"]= 1;
48 arg_type["const std::vector<double>&"]= 1;
49 arg_type["const std::vector<std::vector<double> >&"]= 1;
50 arg_type["std::vector<double>&"]= 1;
51 arg_type["std::vector<double>*&"]= 1;
52 arg_type["const MEDMEM::FIELD<int>*"]= 1;
53 arg_type["const MEDMEM::FIELD<int>&"]= 1;
54 arg_type["MEDMEM::FIELD<int>*&"]= 1;
55 arg_type["const std::vector<int>&"]= 1;
56 arg_type["std::vector<int>*&"]= 1;
57 arg_type["std::vector<int>&"]= 1;
60 # allowed types for return values
64 rtn_type["double"]= 1;
68 rtn_type["unsigned"]= 1;
69 rtn_type["const char*"]= 1;
71 rtn_type["std::string"]= 1;
72 rtn_type["const MEDMEM::MESH&"]= 1;
73 rtn_type["MEDMEM::MESH&"]= 1;
74 rtn_type["MEDMEM::MESH*"]= 1;
75 rtn_type["const MEDMEM::MESH*"]= 1;
76 rtn_type["const MEDMEM::FIELD<double>*"]= 1;
77 rtn_type["MEDMEM::FIELD<double>*"]= 1;
78 rtn_type["MEDMEM::FIELD<double>&"]= 1;
79 rtn_type["const MEDMEM::FIELD<double>&"]= 1;
80 rtn_type["std::vector<double>*"]= 1;
81 rtn_type["std::vector<double>"]= 1;
82 rtn_type["std::vector<std::vector<double> >*"]= 1;
83 rtn_type["const MEDMEM::FIELD<int>*"]= 1;
84 rtn_type["MEDMEM::FIELD<int>*"]= 1;
85 rtn_type["MEDMEM::FIELD<int>&"]= 1;
86 rtn_type["const MEDMEM::FIELD<int>&"]= 1;
87 rtn_type["std::vector<int>*"]= 1;
90 # record sep is ");\n" whith blanks all around, and optional "(" at the beginning
91 RS="[(]?[ \t]*[)][ \t]*;[ \t]*\n?"
92 FS="[ \t]*[(,][ \t]*" # field sep is either "(" or "," surrounded by blanks
95 # --------------------- treatment 1 ----------------------------------
97 # extract from fields types, function name, and argument's names
101 print "Function : ",$0 >> "parse_result" # print for debug
102 for (i=1; i<=NF; i++) {
103 print "\t-> ",i," : ",$i >> "parse_result"
106 # check if returned type ($1) is one of the accepted types (rtn_type)
107 for (cpptype in rtn_type) {
108 if ( substr($1,1,length(cpptype)) == cpptype ) {
109 # if compatible, store returned type and function name
111 name[1]=substr($1,length(cpptype)+1)
112 sub("^[ \t]*","",name[1]) # get rid of leading blanks
118 # for each argument ($i), check if it is compatible (belongs to arg_type)
119 for (i=2; i<=NF; i++) {
121 split($i,tab,"=") # get rid of default value
123 for (cpptype in arg_type) {
124 if ( substr(item,1,length(cpptype)) == cpptype ) {
125 # if compatible, store argument type and name
127 name[i]=substr(item,length(cpptype)+1)
128 sub("^[ \t]*","",name[i]) # get rid of leading blanks
129 if ( length(name[i]) == 0 ) # automatic name if argument's name wasn't precised
130 name[i]=sprintf("_arg%d",i-1)
135 ok*=ok2 # ok=0 if one of the type is not compatible
138 # print compatibility
139 if ( $0 !~ class_name ) { # constructor are not considered, but we don't print it
140 if ( ok == 0){ # if one of the c++ type is not compatible
141 printf " [KO] : %s",$0
144 printf " [OK] : %s",$0
147 printf "(" # if there is no argument, parenthesis was suppressed, so we add it for printing
151 if ( ok == 0) # pass to the next function if one of the c++ type is not compatible