1 # This awk program checks the arguments and return value compatibility
7 # allowed types for arguments
10 arg_type["double"]= 1;
14 arg_type["unsigned"]= 1;
15 arg_type["const char*"]= 1;
16 arg_type["const std::string&"]= 1;
18 arg_type["double&"]= 1;
19 arg_type["float&"]= 1;
21 arg_type["short&"]= 1;
22 arg_type["unsigned&"]= 1;
23 arg_type["std::string&"]= 1;
24 arg_type["const MEDMEM::MESH&"]= 1;
25 arg_type["const MEDMEM::MESH*"]= 1;
26 arg_type["const MEDMEM::FIELD<double>*"]= 1;
27 arg_type["const MEDMEM::FIELD<double>&"]= 1;
28 arg_type["MEDMEM::FIELD<double>*&"]= 1;
29 arg_type["const std::vector<double>&"]= 1;
30 arg_type["const std::vector<std::vector<double> >&"]= 1;
31 arg_type["std::vector<double>&"]= 1;
32 arg_type["std::vector<double>*&"]= 1;
33 arg_type["const MEDMEM::FIELD<int>*"]= 1;
34 arg_type["const MEDMEM::FIELD<int>&"]= 1;
35 arg_type["MEDMEM::FIELD<int>*&"]= 1;
36 arg_type["const std::vector<int>&"]= 1;
37 arg_type["std::vector<int>*&"]= 1;
38 arg_type["std::vector<int>&"]= 1;
41 # allowed types for return values
45 rtn_type["double"]= 1;
49 rtn_type["unsigned"]= 1;
50 rtn_type["const char*"]= 1;
52 rtn_type["std::string"]= 1;
53 rtn_type["const MEDMEM::MESH&"]= 1;
54 rtn_type["MEDMEM::MESH&"]= 1;
55 rtn_type["MEDMEM::MESH*"]= 1;
56 rtn_type["const MEDMEM::MESH*"]= 1;
57 rtn_type["const MEDMEM::FIELD<double>*"]= 1;
58 rtn_type["MEDMEM::FIELD<double>*"]= 1;
59 rtn_type["MEDMEM::FIELD<double>&"]= 1;
60 rtn_type["const MEDMEM::FIELD<double>&"]= 1;
61 rtn_type["std::vector<double>*"]= 1;
62 rtn_type["std::vector<double>"]= 1;
63 rtn_type["std::vector<std::vector<double> >*"]= 1;
64 rtn_type["const MEDMEM::FIELD<int>*"]= 1;
65 rtn_type["MEDMEM::FIELD<int>*"]= 1;
66 rtn_type["MEDMEM::FIELD<int>&"]= 1;
67 rtn_type["const MEDMEM::FIELD<int>&"]= 1;
68 rtn_type["std::vector<int>*"]= 1;
71 # record sep is ");\n" whith blanks all around, and optional "(" at the beginning
72 RS="[(]?[ \t]*[)][ \t]*;[ \t]*\n?"
73 FS="[ \t]*[(,][ \t]*" # field sep is either "(" or "," surrounded by blanks
76 # --------------------- treatment 1 ----------------------------------
78 # extract from fields types, function name, and argument's names
82 print "Function : ",$0 >> "parse_result" # print for debug
83 for (i=1; i<=NF; i++) {
84 print "\t-> ",i," : ",$i >> "parse_result"
87 # check if returned type ($1) is one of the accepted types (rtn_type)
88 for (cpptype in rtn_type) {
89 if ( substr($1,1,length(cpptype)) == cpptype ) {
90 # if compatible, store returned type and function name
92 name[1]=substr($1,length(cpptype)+1)
93 sub("^[ \t]*","",name[1]) # get rid of leading blanks
99 # for each argument ($i), check if it is compatible (belongs to arg_type)
100 for (i=2; i<=NF; i++) {
102 split($i,tab,"=") # get rid of default value
104 for (cpptype in arg_type) {
105 if ( substr(item,1,length(cpptype)) == cpptype ) {
106 # if compatible, store argument type and name
108 name[i]=substr(item,length(cpptype)+1)
109 sub("^[ \t]*","",name[i]) # get rid of leading blanks
110 if ( length(name[i]) == 0 ) # automatic name if argument's name wasn't precised
111 name[i]=sprintf("_arg%d",i-1)
116 ok*=ok2 # ok=0 if one of the type is not compatible
119 # print compatibility
120 if ( $0 !~ class_name ) { # constructor are not considered, but we don't print it
121 if ( ok == 0){ # if one of the c++ type is not compatible
122 printf " [KO] : %s",$0
125 printf " [OK] : %s",$0
128 printf "(" # if there is no argument, parenthesis was suppressed, so we add it for printing
132 if ( ok == 0) # pass to the next function if one of the c++ type is not compatible