68 - The name |
68 - The name |
69 - The data type |
69 - The data type |
70 - The default modifier which can be "none", "negated", "rising" or "falling" |
70 - The default modifier which can be "none", "negated", "rising" or "falling" |
71 """ |
71 """ |
72 |
72 |
73 StdBlckLibs = {libname : LoadProject(tc6fname)[0] |
73 StdBlckLibs = {libname: LoadProject(tc6fname)[0] |
74 for libname, tc6fname in StdTC6Libs} |
74 for libname, tc6fname in StdTC6Libs} |
75 StdBlckLst = [{"name" : libname, "list": |
75 StdBlckLst = [{"name": libname, "list": |
76 [GetBlockInfos(pous) for pous in lib.getpous()]} |
76 [GetBlockInfos(pous) for pous in lib.getpous()]} |
77 for libname, lib in StdBlckLibs.iteritems()] |
77 for libname, lib in StdBlckLibs.iteritems()] |
78 |
78 |
79 #------------------------------------------------------------------------------- |
79 #------------------------------------------------------------------------------- |
80 # Test identifier |
80 # Test identifier |
174 |
174 |
175 Standard_Functions_Decl = [] |
175 Standard_Functions_Decl = [] |
176 Current_section = None |
176 Current_section = None |
177 |
177 |
178 translate = { |
178 translate = { |
179 "extensible" : lambda x: {"yes":True, "no":False}[x], |
179 "extensible": lambda x: {"yes":True, "no":False}[x], |
180 "inputs" : lambda x:csv_input_translate(x,variables,baseinputnumber), |
180 "inputs": lambda x:csv_input_translate(x,variables,baseinputnumber), |
181 "outputs":lambda x:[("OUT",x,"none")]} |
181 "outputs":lambda x:[("OUT",x,"none")]} |
182 |
182 |
183 for fields in table: |
183 for fields in table: |
184 if fields[1]: |
184 if fields[1]: |
185 # If function section name given |
185 # If function section name given |
187 words = fields[0].split('"') |
187 words = fields[0].split('"') |
188 if len(words) > 1: |
188 if len(words) > 1: |
189 section_name = words[1] |
189 section_name = words[1] |
190 else: |
190 else: |
191 section_name = fields[0] |
191 section_name = fields[0] |
192 Current_section = {"name" : section_name, "list" : []} |
192 Current_section = {"name": section_name, "list": []} |
193 Standard_Functions_Decl.append(Current_section) |
193 Standard_Functions_Decl.append(Current_section) |
194 Function_decl_list = [] |
194 Function_decl_list = [] |
195 if Current_section: |
195 if Current_section: |
196 Function_decl = dict([(champ, val) for champ, val in zip(fonctions, fields[1:]) if champ]) |
196 Function_decl = dict([(champ, val) for champ, val in zip(fonctions, fields[1:]) if champ]) |
197 baseinputnumber = int(Function_decl.get("baseinputnumber",1)) |
197 baseinputnumber = int(Function_decl.get("baseinputnumber",1)) |
199 for param, value in Function_decl.iteritems(): |
199 for param, value in Function_decl.iteritems(): |
200 if param in translate: |
200 if param in translate: |
201 Function_decl[param] = translate[param](value) |
201 Function_decl[param] = translate[param](value) |
202 Function_decl["type"] = "function" |
202 Function_decl["type"] = "function" |
203 |
203 |
204 if Function_decl["name"].startswith('*') or Function_decl["name"].endswith('*') : |
204 if Function_decl["name"].startswith('*') or Function_decl["name"].endswith('*'): |
205 input_ovrloading_types = GetSubTypes(Function_decl["inputs"][0][1]) |
205 input_ovrloading_types = GetSubTypes(Function_decl["inputs"][0][1]) |
206 output_types = GetSubTypes(Function_decl["outputs"][0][1]) |
206 output_types = GetSubTypes(Function_decl["outputs"][0][1]) |
207 else: |
207 else: |
208 input_ovrloading_types = [None] |
208 input_ovrloading_types = [None] |
209 output_types = [None] |
209 output_types = [None] |
228 funcdeclin = funcdeclname |
228 funcdeclin = funcdeclname |
229 |
229 |
230 for outype in output_types: |
230 for outype in output_types: |
231 if outype != None: |
231 if outype != None: |
232 decl_tpl = Function_decl["outputs"][0] |
232 decl_tpl = Function_decl["outputs"][0] |
233 Function_decl["outputs"] = [ (decl_tpl[0] , outype, decl_tpl[2])] |
233 Function_decl["outputs"] = [ (decl_tpl[0], outype, decl_tpl[2])] |
234 if funcdeclname_orig.endswith('*'): |
234 if funcdeclname_orig.endswith('*'): |
235 funcdeclout = funcdeclin + '_' + outype |
235 funcdeclout = funcdeclin + '_' + outype |
236 else: |
236 else: |
237 funcdeclout = funcdeclin |
237 funcdeclout = funcdeclin |
238 else: |
238 else: |
242 # apply filter given in "filter" column |
242 # apply filter given in "filter" column |
243 filter_name = Function_decl["filter"] |
243 filter_name = Function_decl["filter"] |
244 store = True |
244 store = True |
245 for (InTypes, OutTypes) in ANY_TO_ANY_FILTERS.get(filter_name,[]): |
245 for (InTypes, OutTypes) in ANY_TO_ANY_FILTERS.get(filter_name,[]): |
246 outs = reduce(lambda a,b: a or b, |
246 outs = reduce(lambda a,b: a or b, |
247 map(lambda testtype : IsOfType( |
247 map(lambda testtype: IsOfType( |
248 Function_decl["outputs"][0][1], |
248 Function_decl["outputs"][0][1], |
249 testtype), OutTypes)) |
249 testtype), OutTypes)) |
250 inps = reduce(lambda a,b: a or b, |
250 inps = reduce(lambda a,b: a or b, |
251 map(lambda testtype : IsOfType( |
251 map(lambda testtype: IsOfType( |
252 Function_decl["inputs"][0][1], |
252 Function_decl["inputs"][0][1], |
253 testtype), InTypes)) |
253 testtype), InTypes)) |
254 if inps and outs and Function_decl["outputs"][0][1] != Function_decl["inputs"][0][1]: |
254 if inps and outs and Function_decl["outputs"][0][1] != Function_decl["inputs"][0][1]: |
255 store = True |
255 store = True |
256 break |
256 break |
257 else: |
257 else: |
258 store = False |
258 store = False |
259 if store : |
259 if store: |
260 # create the copy of decl dict to be appended to section |
260 # create the copy of decl dict to be appended to section |
261 Function_decl_copy = Function_decl.copy() |
261 Function_decl_copy = Function_decl.copy() |
262 Current_section["list"].append(Function_decl_copy) |
262 Current_section["list"].append(Function_decl_copy) |
263 else: |
263 else: |
264 raise "First function must be in a category" |
264 raise "First function must be in a category" |