Salome HOME
Deleted deprecated code
[modules/yacs.git] / src / wrappergen / src / parse5.awk
1 # Copyright (C) 2006-2016  CEA/DEN, EDF R&D
2 #
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.
7 #
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.
12 #
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
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 # This awk program generates the catalog for C++ components
21 #
22 BEGIN { 
23 #
24 # file name generation
25   catalog_file="catalog.xml"
26   print "<?xml version='1.0' encoding='us-ascii' ?>\n" > catalog_file
27
28   print "<!-- XML component catalog -->\n"\
29         "<begin-catalog>\n"\
30         "  <component-list>" >> catalog_file
31
32   print "    <component>\n"\
33         "      <component-name>"class_name"</component-name>\n"\
34         "      <component-username>"class_name"</component-username>\n"\
35         "      <component-type>Solver</component-type>\n"\
36         "      <component-author>""</component-author>\n"\
37         "      <component-version>1.0</component-version>\n"\
38         "      <component-comment></component-comment>\n"\
39         "      <component-icone>"class_name".png</component-icone>\n"\
40         "      <component-impltype>1</component-impltype>\n"\
41         "      <component-interface-list>" >> catalog_file
42
43   print "        <component-interface-name>"class_name"</component-interface-name>\n"\
44         "        <component-interface-comment>No comment</component-interface-comment>\n"\
45         "        <component-service-list>"\
46         "\n" >> catalog_file
47
48   type_in = 1
49   type_out = 2
50
51   type_arg["int"]= type_in
52   type_arg["double"]= type_in
53   type_arg["float"]= type_in
54   type_arg["long"]= type_in
55   type_arg["short"]= type_in
56   type_arg["unsigned"]= type_in
57   type_arg["const char*"]= type_in
58   type_arg["const std::string&"]= type_in
59   type_arg["const std::vector<double>&"]= type_in
60
61   type_arg["int&"]= type_out
62   type_arg["double&"]= type_out
63   type_arg["float&"]= type_out
64   type_arg["long&"]= type_out
65   type_arg["short&"]= type_out
66   type_arg["unsigned&"]= type_out
67   type_arg["std::string&"]= type_out
68   type_arg["std::vector<double>&"]= type_out
69
70 #
71 #
72 # record sep is ");\n" whith blanks all around, and optional "(" at the beginning
73   RS="[(]?[   ]*[)][   ]*;[   ]*\n?"  
74   FS="[   ]*[(,][   ]*"  # field sep is either "(" or "," surrounded by blanks 
75 }
76
77 # --------------------- treatment 1 ----------------------------------
78 #
79 #  extract from fields types, function name, and argument's names
80 #
81 {
82   nitems = split($0, items);
83   for (i=1; i<=nitems; i++) {
84     split(items[i], j, " ");
85     l=0; for (k in j) {l++;}
86     k=j[1];
87     for (ll=2; ll<l; ll++) k=k " " j[ll];
88     type[i] = k;
89     name[i] = j[ll];
90     way[i] = type_arg[k];
91   }
92
93   print "          <component-service>\n"\
94         "            <service-name>"name[1]"</service_name>\n"\
95         "            <service-author></service-author>\n"\
96         "            <service-version></service-version>\n"\
97         "            <service-comment></service-comment>\n"\
98         "            <service-by-default>0</service-by-default>\n"\
99         >> catalog_file
100
101   print "            <inParameter-list>" >> catalog_file
102   for (i=2; i<=nitems; i++)
103       if (way[i] == type_in) {
104          print "              <inParameter>\n"\
105                "                <inParameter-name>"name[i]"</inParameter-name>\n"\
106                "                <inParameter-type>"type[i]"</inParameter-type>\n"\
107                "                <inParameter-comment></inParameter-comment>\n"\
108                "              </inParameter>" >> catalog_file
109          }
110   print "            <inParameter-list>\n" >> catalog_file
111
112   print "            <outParameter-list>" >> catalog_file
113
114   if (type[1] != "void")
115       print "              <outParameter>\n"\
116             "                <outParameter-name>return</outParameter-name>\n"\
117             "                <outParameter-type>"type[1]"</outParameter-type>\n"\
118             "                <outParameter-comment></outParameter-comment>\n"\
119             "              </outParameter>" >> catalog_file
120
121   for (i=2; i<=nitems; i++)
122       if (way[i] == type_out) {
123          print "              <outParameter>\n"\
124                "                <outParameter-name>"name[i]"</outParameter-name>\n"\
125                "                <outParameter-type>"type[i]"</outParameter-type>\n"\
126                "                <outParameter-comment></outParameter-comment>\n"\
127                "              </outParameter>" >> catalog_file
128          }
129   print "            <outParameter-list>\n" >> catalog_file
130
131   print "         </component-service>\n" >> catalog_file
132 }
133 #
134 END {
135   print "        </component-service-list>\n"\
136         "      </component-interface-list>\n"\
137         "    </component>\n"\
138         "  </component-list>\n"\
139         "</begin-catalog>" >> catalog_file
140 }