equal
deleted
inserted
replaced
144 else: |
144 else: |
145 rtcalls += " pass\n\n" |
145 rtcalls += " pass\n\n" |
146 |
146 |
147 globalsection = self.GetSection("globals") |
147 globalsection = self.GetSection("globals") |
148 |
148 |
|
149 loc_dict = { |
|
150 "pyextname": pyextname, |
|
151 "globalstubs": globalstubs, |
|
152 "globalsection": globalsection, |
|
153 "rtcalls": rtcalls, |
|
154 } |
|
155 |
149 PyFileContent = """\ |
156 PyFileContent = """\ |
150 #!/usr/bin/env python |
157 #!/usr/bin/env python |
151 # -*- coding: utf-8 -*- |
158 # -*- coding: utf-8 -*- |
152 ## Code generated by Beremiz python mixin confnode |
159 ## Code generated by Beremiz python mixin confnode |
153 ## |
160 ## |
166 ## Beremiz python runtime calls |
173 ## Beremiz python runtime calls |
167 %(rtcalls)s |
174 %(rtcalls)s |
168 |
175 |
169 del __ext_name__ |
176 del __ext_name__ |
170 |
177 |
171 """ % locals() |
178 """ % loc_dict |
172 |
179 |
173 # write generated content to python file |
180 # write generated content to python file |
174 runtimefile_path = os.path.join(buildpath, |
181 runtimefile_path = os.path.join(buildpath, |
175 "runtime_%s.py" % location_str) |
182 "runtime_%s.py" % location_str) |
176 runtimefile = open(runtimefile_path, 'w') |
183 runtimefile = open(runtimefile_path, 'w') |
243 varpubfmt) % varinfo |
250 varpubfmt) % varinfo |
244 for varinfo in varinfos]) |
251 for varinfo in varinfos]) |
245 varinit = "\n".join([varinitonchangefmt % dict( |
252 varinit = "\n".join([varinitonchangefmt % dict( |
246 onchangelen=len(varinfo["onchangecode"]), **varinfo) |
253 onchangelen=len(varinfo["onchangecode"]), **varinfo) |
247 for varinfo in varinfos if varinfo["onchange"]]) |
254 for varinfo in varinfos if varinfo["onchange"]]) |
|
255 |
|
256 loc_dict = { |
|
257 "vardec": vardec, |
|
258 "varinit": varinit, |
|
259 "varret": varret, |
|
260 "varpub": varpub, |
|
261 "location_str": location_str, |
|
262 } |
248 |
263 |
249 # TODO : use config name obtained from model instead of default |
264 # TODO : use config name obtained from model instead of default |
250 # "config.h". User cannot change config name, but project imported |
265 # "config.h". User cannot change config name, but project imported |
251 # or created in older beremiz vesion could use different name. |
266 # or created in older beremiz vesion could use different name. |
252 PyCFileContent = """\ |
267 PyCFileContent = """\ |
276 } |
291 } |
277 |
292 |
278 void __publish_%(location_str)s(void){ |
293 void __publish_%(location_str)s(void){ |
279 %(varpub)s |
294 %(varpub)s |
280 } |
295 } |
281 """ % locals() |
296 """ % loc_dict |
282 |
297 |
283 Gen_PyCfile_path = os.path.join(buildpath, "PyCFile_%s.c" % location_str) |
298 Gen_PyCfile_path = os.path.join(buildpath, "PyCFile_%s.c" % location_str) |
284 pycfile = open(Gen_PyCfile_path, 'w') |
299 pycfile = open(Gen_PyCfile_path, 'w') |
285 pycfile.write(PyCFileContent) |
300 pycfile.write(PyCFileContent) |
286 pycfile.close() |
301 pycfile.close() |