qgenada_B_mapper.py 3.8 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#
# (C) Semantix Information Technologies.
#
# Copyright 2014-2015 IB Krates <info@krates.ee>
#       QGenc code generator integration
#
# Semantix Information Technologies is licensing the code of the
# Data Modelling Tools (DMT) in the following dual-license mode:
#
# Commercial Developer License:
#       The DMT Commercial Developer License is the suggested version
# to use for the development of proprietary and/or commercial software.
# This version is for developers/companies who do not want to comply
# with the terms of the GNU Lesser General Public License version 2.1.
#
# GNU LGPL v. 2.1:
#       This version of DMT is the one to use for the development of
# applications, when you are willing to comply with the terms of the
# GNU Lesser General Public License version 2.1.
#
# Note that in both cases, there are no charges (royalties) for the
# generated code.
#
'''
This is the implementation of the code mapper for Ada code.
As initially envisioned, ASSERT technology is not supposed
to support manually-made systems. A migration path, however,
that allows legacy hand-written code and modelling-tool
generated code to co-exist, can be beneficial in allowing
for a smooth transition. To that end, this backend (as well as
the C one) are written.

This is a backend for Semantix's code generator B (aadl2glueC).

Ada is a member of the asynchronous "club" (SDL, etc);
The subsystem developer (or rather, the APLC developer) is using
native Ada code to work with code generated by modelling tools.
To that end, this backend creates "glue" functions for input and
output parameters, which have Ada callable interfaces.
'''

# from commonPy.utility import panic
# from recursiveMapper import RecursiveMapper
# from asynchronousTool import ASynchronousToolGlueGenerator

from . import c_B_mapper
47
48
from ..commonPy.asnAST import AsnBasicNode, AsnSequence, AsnSet, AsnEnumerated, AsnSequenceOf, AsnSetOf, AsnChoice
from ..commonPy.asnParser import AST_Lookup, AST_Leaftypes
49
50
51
52
53
54
55
56

isAsynchronous = True
cBackend = None


# All the ada B mapper is now Obsolete, we are using ASN1SCC for Dumpables


57
def OnStartup(unused_modelingLanguage: str, asnFile: str, outputDir: str, maybeFVname: str, useOSS: bool) -> None:
58
59
60
61
62
63
64
    global cBackend
    # 2009-02-10: Since we now use ASN1SCC structures as dumpables (even for Ada)
    # we no longer need these Ada-specific Dumpable structures.
    cBackend = c_B_mapper.C_GlueGenerator()
    cBackend.OnStartup("C", asnFile, outputDir, maybeFVname, useOSS)


65
def OnBasic(nodeTypename: str, node: AsnBasicNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
66
67
68
    cBackend.OnBasic(nodeTypename, node, leafTypeDict, names)


69
def OnSequence(nodeTypename: str, node: AsnSequence, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
70
71
72
    cBackend.OnSequence(nodeTypename, node, leafTypeDict, names)


73
def OnSet(nodeTypename: str, node: AsnSet, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
74
75
76
    cBackend.OnSet(nodeTypename, node, leafTypeDict, names)  # pragma: nocover


77
def OnEnumerated(nodeTypename: str, node: AsnEnumerated, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
78
79
80
    cBackend.OnEnumerated(nodeTypename, node, leafTypeDict, names)


81
def OnSequenceOf(nodeTypename: str, node: AsnSequenceOf, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
82
83
84
    cBackend.OnSequenceOf(nodeTypename, node, leafTypeDict, names)


85
def OnSetOf(nodeTypename: str, node: AsnSetOf, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
86
87
88
    cBackend.OnSetOf(nodeTypename, node, leafTypeDict, names)  # pragma: nocover


89
def OnChoice(nodeTypename: str, node: AsnChoice, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
90
91
92
    cBackend.OnChoice(nodeTypename, node, leafTypeDict, names)


93
def OnShutdown(unused_modelingLanguage: str, asnFile: str, maybeFVname: str) -> None:
94
    cBackend.OnShutdown("C", asnFile, maybeFVname)