Commit 71134c44 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Render signal and external procedures in a textbox

parent ee3f4f1c
......@@ -93,11 +93,11 @@ def parse_scene(scene, full_model=False):
pr_data.append('ENDBLOCK;')
Indent.indent -= 1
pr_data.append('ENDSYSTEM;')
#print '\n'.join(pr_data)
else:
for each in scene.processes:
pr_data.extend(generate(each))
#pr_data.extend(generate(each))
return list(generate(each))
for each in chain(scene.texts, scene.procs, scene.start):
pr_data.extend(generate(each))
......
......@@ -70,6 +70,31 @@ def _block(ast, scene):
for each in ast.parent.text_areas:
# Sytem level may contain text areas with signal definitions, etc.
top_level.append(render(each, scene))
if not ast.parent.text_areas:
# If signals are declared outside from a textbox, create one
signals = ["signal {si[name]}{param};\n".format(si=sig,
param=('(' + sig['type'].ReferencedTypeName.replace('-', '_') + ')')
if 'type' in sig else '')
for sig in ast.parent.signals]
procedures = ["procedure {proc.inputString};\n{fpar}\nexternal;\n"
.format(proc=proc,
fpar="\n".join
([" fpar {direc} {fpar[name]} {asn1};"
.format(fpar=fpar,
direc="in"
if fpar['direction']=='in'
else 'in/out',
asn1=fpar['type']
.ReferencedTypeName.replace('-', '_'))
for fpar in proc.fpar]))
for proc in ast.parent.procedures]
if signals or procedures:
text_area = ogAST.TextArea()
text_area.inputString = "{}\n\n{}".format('\n'.join(signals),
'\n'.join(procedures))
text_area.pos_x = scene.itemsBoundingRect().width()
text_area.pos_y = scene.itemsBoundingRect().y() + 10
top_level.append(render(text_area, scene))
return top_level
......
......@@ -904,7 +904,7 @@ class System(object):
self.filename = None
# Reference to top-level AST
self.ast = None
# list of SIGNAL declarations: [{'name': str, 'type': str}]
# list of SIGNAL declarations: [{'name': str, 'type': asn1type}]
# (Supporting only one parameter)
self.signals = []
# list of ogAST.Procedure
......
......@@ -2498,7 +2498,7 @@ def system_definition(root, parent):
if not asn1_files:
asn1_files = textarea.asn1_files
else:
errors.append('All ASN.1 Files must be set in the same text area')
errors.append('ASN.1 Files must be set in a single text area')
errors.extend(err)
warnings.extend(warn)
system.text_areas.append(textarea)
......@@ -2511,8 +2511,9 @@ def system_definition(root, parent):
# set_global_DV(asn1_files)
# except TypeError as err:
# errors.append(str(err))
system.ast.asn1Modules = DV.asn1Modules
system.ast.asn1_filenames = asn1_files
if asn1_files:
system.ast.asn1Modules = DV.asn1Modules
system.ast.asn1_filenames = asn1_files
for each in signals:
sig, err, warn = signal(each)
errors.extend(err)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment