Commit b3157954 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files
parents d0508f89 c6ac6585
......@@ -141,6 +141,13 @@ The background pattern was downloaded from www.subtlepatterns.com
Changelog
=========
1.5.34 (05/2017)
- Fix statechart message selection box
1.5.33 (04/2017)
- Fix unicode issue with the simulation code
- Use -fPIC when building the simulation library
1.5.32 (04/2017)
- Unicode bugfixes in Ada backend
- Bugfix with SEQUENCE OF literals in Ada backend
......
......@@ -250,9 +250,9 @@ asn1.exe -Ada -typePrefix asn1Scc -equal {asn1}
asn1.exe -c -typePrefix asn1Scc -equal {asn1}'''.format(asn1=asn1_filenames)
simu_script += '''
gnatmake -gnat2012 -c *.adb
gnatmake -fPIC -gnat2012 -c *.adb
gnatbind -n -Llib{pr} {pr}
gnatmake -c -gnat2012 b~{pr}.adb
gnatmake -fPIC -c -gnat2012 b~{pr}.adb
gcc -shared -fPIC -o lib{pr}.so b~{pr}.o {pr}.o {asn1_mod} adaasn1rtl.o -lgnat
rm -f dataview-uniq.c dataview-uniq.h
asn2aadlPlus dataview-uniq.asn DataView.aadl
......@@ -513,23 +513,23 @@ package {process_name} is'''.format(generic=generic_spec,
# Functions to get gobal variables (length and value)
for var_name, (var_type, _) in process.variables.viewitems():
# Getters for external applications to view local variables via dll
process_level_decl.append("function l_{name}_value"
" return access {sort} "
"is ({prefix}.{name}'access) with Export,"
" Convention => C,"
' Link_Name => "{name}_value";'
process_level_decl.append(u"function l_{name}_value"
u" return access {sort} "
u"is ({prefix}.{name}'access) with Export,"
u" Convention => C,"
u' Link_Name => "{name}_value";'
.format(prefix=LPREFIX, name=var_name,
sort=type_name(var_type)))
# Setters for local variables
setter_decl = "procedure dll_set_l_{name}(value: access {sort})"\
setter_decl = u"procedure dll_set_l_{name}(value: access {sort})"\
.format(name=var_name, sort=type_name(var_type))
ads_template.append('{};'.format(setter_decl))
ads_template.append('pragma Export(C, dll_set_l_{name},'
ads_template.append(u'{};'.format(setter_decl))
ads_template.append(u'pragma Export(C, dll_set_l_{name},'
' "_set_{name}");'.format(name=var_name))
dll_api.append('{} is'.format(setter_decl))
dll_api.append('begin')
dll_api.append('{}.{} := value.all;'.format(LPREFIX, var_name))
dll_api.append('end dll_set_l_{};'.format(var_name))
dll_api.append(u'{} is'.format(setter_decl))
dll_api.append(u'begin')
dll_api.append(u'{}.{} := value.all;'.format(LPREFIX, var_name))
dll_api.append(u'end dll_set_l_{};'.format(var_name))
dll_api.append('')
# Generate the the code of the procedures
......
......@@ -569,7 +569,7 @@ def locked():
return g_statechart_lock
def create_dot_graph(root_ast, basic=False, scene=None):
def create_dot_graph(root_ast, basic=False, scene=None, view=None):
''' Return a dot.AGraph item, from an ogAST.Process or child entry
Set basic=True to generate a simple graph with at most one edge
between two states and no diamond nodes
......@@ -612,7 +612,7 @@ def create_dot_graph(root_ast, basic=False, scene=None):
else:
LOG.info ("Statechart settings read from configuration file")
if scene and scene.views():
if scene and view:
# Load and display a table for the user to filter out messages that
# are not relevant to display on the statechart - and make it lighter
# Repeat for substates, too.
......@@ -629,7 +629,7 @@ def create_dot_graph(root_ast, basic=False, scene=None):
ui_file = QtCore.QFile(":/statechart_cfg.ui")
ui_file.open(QtCore.QFile.ReadOnly)
dialog = loader.load(ui_file)
dialog.setParent (scene.views()[0], QtCore.Qt.Dialog)
dialog.setParent (view, QtCore.Qt.Dialog)
okButton = dialog.findChild(QtGui.QPushButton, "okButton")
rightButton = dialog.findChild(QtGui.QToolButton, "toRight")
leftButton = dialog.findChild(QtGui.QToolButton, "toLeft")
......
......@@ -666,7 +666,7 @@ def check_type_compatibility(primary, type_ref, context): # type: -> [warnings]
'''
Check if an ogAST.Primary (raw value, enumerated, ASN.1 Value...)
is compatible with a given type (type_ref is an ASN1Scc type)
Does not return anything if OK, otherwise raises TypeError
Possibly returns a list of warnings; can raises TypeError
'''
warnings = [] # function returns a list of warnings
assert type_ref is not None
......@@ -749,9 +749,10 @@ def check_type_compatibility(primary, type_ref, context): # type: -> [warnings]
if type_ref.__name__ != 'Apnd' and \
(len(primary.value) < int(basic_type.Min) or
len(primary.value) > int(basic_type.Max)):
#print traceback.print_stack()
raise TypeError(str(len(primary.value)) +
' elements in SEQUENCE OF, while constraint is [' +
str(basic_type.Min) + '..' + str(basic_type.Max) + ']')
' element(s) in SEQUENCE OF, while constraint is [' +
str(basic_type.Min) + ' .. ' + str(basic_type.Max) + ']')
for elem in primary.value:
warnings.extend(check_type_compatibility(elem,
basic_type.type,
......@@ -1039,7 +1040,7 @@ def fix_expression_types(expr, context): # type: -> [warnings]
# the type of the raw PrimSequenceOf can be set now
value.exprType.type = asn_type
if isinstance(expr, ogAST.ExprIn):
if isinstance(expr, (ogAST.ExprIn, ogAST.ExprAppend)):
return warnings
if not expr.right.is_raw and not expr.left.is_raw:
......@@ -1435,15 +1436,24 @@ def append_expression(root, context):
''' Append expression analysis '''
expr, errors, warnings = binary_expression(root, context)
left = find_basic_type(expr.left.exprType)
left = find_basic_type(expr.left.exprType)
right = find_basic_type(expr.right.exprType)
# check that both left and right are actual strings
for bty in (left, right):
if bty.kind != 'SequenceOfType' and not is_string(bty):
msg = 'Append can only be applied to types SequenceOf or String'
errors.append(error(root, msg))
break
else:
try:
warnings.extend(compare_types(left.type, right.type))
except TypeError as err:
errors.append(error(root, str(err)))
except AttributeError:
# The above only applies to Sequence of, not strings
pass
attrs = {'Min': str(int(right.Min) + int(left.Min)),
'Max': str(int(right.Max) + int(left.Max))}
# It is wrong to set the type as inheriting from the left side FIXME
......
......@@ -124,6 +124,7 @@ MODULES = [
# Define custom UserRoles
ANCHOR = Qt.UserRole + 1
try:
import LlvmGenerator
MODULES.append(LlvmGenerator)
......@@ -138,7 +139,7 @@ except ImportError:
__all__ = ['opengeode', 'SDL_Scene', 'SDL_View', 'parse']
__version__ = '1.5.32'
__version__ = '1.5.34'
if hasattr(sys, 'frozen'):
# Detect if we are running on Windows (py2exe-generated)
......@@ -425,6 +426,8 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
# Keep a track of highlighted symbols: { symbol: brush }
self.highlighted = {}
self.refresh_requested = False
# Flag indicating the presence of unsolved semantic errors in the model
self.semantic_errors = False
def close(self):
''' close function is needed by py.test-qt '''
......@@ -1026,11 +1029,13 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
self.refresh()
def sdl_to_statechart(self, basic=True):
''' Create a graphviz representation of the SDL model '''
def sdl_to_statechart(self, basic=True, view=None):
''' Create a graphviz representation of the SDL model
Optionally take a QGraphicsView to use as parent for modals '''
pr_raw = Pr.parse_scene(self)
pr_data = unicode('\n'.join(pr_raw))
ast, _, _ = ogParser.parse_pr(string=pr_data)
ast, _, err = ogParser.parse_pr(string=pr_data)
self.semantic_errors = True if err else False
try:
process_ast, = ast.processes
except ValueError:
......@@ -1046,7 +1051,8 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
# dot supports only vertically-aligned states, and fdp does not
# support curved edges and is buggy with pygraphviz anyway)
# Helper.flatten(process_ast)
return Statechart.create_dot_graph(process_ast, basic, scene=self)
return Statechart.create_dot_graph(process_ast, basic,
scene=self, view=view)
def export_branch_to_picture(self, symbol, filename, doc_format):
......@@ -1813,10 +1819,27 @@ class SDL_View(QtGui.QGraphicsView, object):
try:
if item.allow_nesting:
item.double_click()
ctx = unicode(item.context_name) #__class__.__name__.lower())
ctx = unicode(item.context_name)
if not isinstance(item.nested_scene, SDL_Scene):
item.nested_scene = \
msg_box = QtGui.QMessageBox(self)
msg_box.setWindowTitle('Create nested symbol')
msg_box.setText('Do you want to create a new sub-{} ?'
'\n\n'
'If you do, you can come back to the '
'current diagram using the up arrow '
'in the menu bar on the top of the '
'screen'
.format(item.context_name))
msg_box.setStandardButtons(QtGui.QMessageBox.Yes |
QtGui.QMessageBox.Cancel)
msg_box.setDefaultButton(QtGui.QMessageBox.Yes)
ret = msg_box.exec_()
if ret == QtGui.QMessageBox.Yes:
item.nested_scene = \
self.scene().create_subscene(ctx, self.scene())
else:
item.edit_text(self.mapToScene(evt.pos()))
return
self.go_down(item.nested_scene,
name=u"{} {}".format(ctx, unicode(item)))
else:
......@@ -1877,10 +1900,31 @@ class SDL_View(QtGui.QGraphicsView, object):
LOG.info('No scene - nothing to save')
return False
# check syntax and raise a big warning before saving
if not autosave:
self.messages_window.clear()
if not autosave and not scene.global_syntax_check():
# Propose to check semantics if the last check had errors
syntax_errors = None
if not autosave and (scene.semantic_errors
or not self.is_model_clean()):
msg_box = QtGui.QMessageBox(self)
msg_box.setIcon(QtGui.QMessageBox.Question)
msg_box.setWindowTitle('OpenGEODE - Check Semantics')
msg_box.setText("We recommend to make a semantic check of the "
"model now.\n\n"
"Choose Apply to perform this check "
"and Discard otherwise.")
msg_box.setStandardButtons(QtGui.QMessageBox.Apply
| QtGui.QMessageBox.Discard)
msg_box.setDefaultButton(QtGui.QMessageBox.Apply)
res = msg_box.exec_()
if res == QtGui.QMessageBox.Apply:
syntex_error = True if self.check_model() == "Syntax Errors" \
else False
# check syntax (if not done) and raise a big warning before saving
if syntax_errors is True or (syntax_errors is None
and not autosave
and not scene.global_syntax_check()):
LOG.error('Syntax errors must be fixed NOW '
'or you may not be able to reload the model')
msg_box = QtGui.QMessageBox(self)
......@@ -2060,22 +2104,24 @@ class SDL_View(QtGui.QGraphicsView, object):
self.messages_window.addItem("Checking syntax")
if not scene.global_syntax_check():
self.messages_window.addItem("Aborted. Fix syntax errors first")
return
return "Syntax Errors"
self.messages_window.addItem("No syntax errors")
self.messages_window.addItem("Checking semantics")
if scene.context not in ('process', 'state', 'procedure', 'block'):
# check can only be done on SDL diagrams
return
return "Non-SDL"
pr_raw = Pr.parse_scene(scene, full_model=True
if not self.readonly_pr else False)
pr_data = unicode('\n'.join(pr_raw))
if pr_data:
ast, warnings, errors = ogParser.parse_pr(files=self.readonly_pr,
string=pr_data)
scene.semantic_errors = True if errors else False
log_errors(self.messages_window, errors, warnings,
clearfirst=False)
self.update_asn1_dock.emit(ast)
return "Done"
def show_item(self, item):
'''
......@@ -2146,6 +2192,7 @@ class SDL_View(QtGui.QGraphicsView, object):
if pr_data:
ast, warnings, errors = ogParser.parse_pr(files=self.readonly_pr,
string=pr_data)
scene.semantic_errors = True if errors else False
process, = ast.processes
log_errors(self.messages_window, errors, warnings)
if len(errors) > 0:
......@@ -2340,7 +2387,7 @@ class OG_MainWindow(QtGui.QMainWindow, object):
# so the lock is necessary to prevent recursive execution
scene = self.view.top_scene()
try:
graph = scene.sdl_to_statechart()
graph = scene.sdl_to_statechart(view=self.view)
Statechart.render_statechart(self.statechart_scene,
graph)
self.statechart_view.refresh()
......
......@@ -7,9 +7,9 @@ opengeode testsc.pr --shared
cat dataview.asn >> dataview-uniq.asn
asn1.exe -Ada -typePrefix asn1Scc -equal dataview.asn
asn1.exe -c -typePrefix asn1Scc -equal dataview.asn
gnatmake -gnat2012 -c *.adb
gnatmake -gnat2012 -fPIC -c *.adb
gnatbind -n -Llibtestsc testsc
gnatmake -c -gnat2012 b~testsc.adb
gnatmake -c -fPIC -gnat2012 b~testsc.adb
gcc -shared -fPIC -o libtestsc.so b~testsc.o testsc.o ccsdssoissubnetwork.o ccsdssoissubnetworkinterfaces.o demo.o demointerfaces.o environment.o environmentinterfaces.o adaasn1rtl.o -lgnat
rm -f dataview-uniq.c dataview-uniq.h
asn2aadlPlus dataview-uniq.asn DataView.aadl
......
include ../shared.mk
all: test-ada test-llvm
edit:
$(OPENGEODE) test.pr
test-parse:
$(OPENGEODE) test.pr --check
test-ada:
$(OPENGEODE) test.pr --toAda
$(ASN1SCC) -Ada dataview.asn -typePrefix asn1Scc -equal
$(GNATMAKE) -O$(O) -c *.adb
$(GNATBIND) -n test.ali
gnat make test_ada.ada
simu:
$(OPENGEODE) test.pr --shared
./test_simu.sh
test-c:
$(OPENGEODE) test.pr --toC
$(ASN1SCC) -c dataview.asn -typePrefix asn1Scc -equal
$(CC) -O$(O) -c *.c
test-llvm:
$(OPENGEODE) test.pr --llvm -O$(O)
$(LLC) *.ll
$(CC) -O$(O) -c *.s
coverage:
coverage run -p $(OPENGEODE) test.pr --toAda
.PHONY: all edit test-parse test-ada test-llvm coverage simu
TASTE-Dataview DEFINITIONS ::=
BEGIN
MySeqOf ::= SEQUENCE (SIZE (3..10)) OF BOOLEAN
MyBoolean ::= BOOLEAN
END
system test;
/* CIF TEXT (164, 303), (356, 219) */
-- Text area for declarations and comments
use datamodel comment 'dataview.asn';
signal seqof1(MySeqOf);
/* CIF ENDTEXT */
channel c
from env to test with seqof1;
endchannel;
block test;
signalroute r
from env to test with seqof1;
connect c and r;
/* CIF PROCESS (202, 142), (150, 75) */
process test;
/* CIF TEXT (438, 271), (287, 140) */
dcl s1, s2 MySeqof;
dcl boo MyBoolean;
/* CIF ENDTEXT */
/* CIF START (198, 56), (70, 35) */
START;
/* CIF task (132, 111), (201, 35) */
task s2 := { true, true, false, true };
/* CIF PROCEDURECALL (157, 161), (152, 35) */
call writeln ( length (s1) )
/* CIF comment (329, 161), (189, 35) */
comment 'Uninitialized => will return 0';
/* CIF task (183, 216), (99, 35) */
task s1 := s2 (1,3)
/* CIF comment (302, 216), (284, 38) */
comment 'Minimum size
s1 (1, 3) := { true, false, true} provokes a bug';
/* CIF PROCEDURECALL (157, 271), (152, 35) */
call writeln ( length (s1) );
/* CIF task (149, 326), (167, 35) */
task s1 := s1 // { false };
/* CIF PROCEDURECALL (157, 381), (152, 35) */
call writeln ( length (s1) );
/* CIF task (170, 436), (126, 35) */
task s1 := s1 // {boo};
/* CIF PROCEDURECALL (157, 491), (152, 35) */
call writeln ( length (s1) );
/* CIF NEXTSTATE (198, 541), (70, 35) */
NEXTSTATE wait;
/* CIF state (596, 470), (70, 35) */
state wait;
endstate;
endprocess test;
endblock;
endsystem;
\ No newline at end of file
with text_io, test;
use text_io, test;
procedure test_ada is
begin
put_line ("hello");
end;
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