Commit 1f2f28b4 authored by Damien George's avatar Damien George
Browse files

Initual support for MicroPython

parent e1607674
#
# (C) Semantix Information Technologies.
#
# 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 C 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 Ada one) are written.
This is a backend for Semantix's code generator B (aadl2glueC).
C is a member of the asynchronous "club" (SDL, etc);
The subsystem developer (or rather, the APLC developer) is using
native C/C++ code to work with code generated by modelling tools.
To that end, this backend creates "glue" functions for input and
output parameters, which have C callable interfaces.
'''
from typing import List
from ..commonPy.utility import panic
from ..commonPy.asnAST import (
sourceSequenceLimit, isSequenceVariable, targetSequenceLimit,
AsnInt, AsnReal, AsnBool, AsnSequenceOrSet, AsnSequenceOrSetOf,
AsnChoice, AsnOctetString, AsnEnumerated, AsnNode)
from ..commonPy.asnParser import AST_Lookup, AST_Leaftypes
from ..commonPy.recursiveMapper import RecursiveMapper
from .asynchronousTool import ASynchronousToolGlueGenerator
from .c_B_mapper import C_GlueGenerator
mpyBackend = None
class MicroPython_GlueGenerator(C_GlueGenerator):
pass
def OnStartup(modelingLanguage: str, asnFile: str, outputDir: str, maybeFVname: str, useOSS: bool) -> None:
global mpyBackend
mpyBackend = MicroPython_GlueGenerator()
mpyBackend.OnStartup("C", asnFile, outputDir, maybeFVname, useOSS)
def OnBasic(nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
mpyBackend.OnBasic(nodeTypename, node, leafTypeDict, names)
def OnSequence(nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
mpyBackend.OnSequence(nodeTypename, node, leafTypeDict, names)
def OnSet(nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
mpyBackend.OnSet(nodeTypename, node, leafTypeDict, names)
def OnEnumerated(nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
mpyBackend.OnEnumerated(nodeTypename, node, leafTypeDict, names)
def OnSequenceOf(nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
mpyBackend.OnSequenceOf(nodeTypename, node, leafTypeDict, names)
def OnSetOf(nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
mpyBackend.OnSetOf(nodeTypename, node, leafTypeDict, names)
def OnChoice(nodeTypename: str, node: AsnNode, leafTypeDict: AST_Leaftypes, names: AST_Lookup) -> None:
mpyBackend.OnChoice(nodeTypename, node, leafTypeDict, names)
def OnShutdown(modelingLanguage: str, asnFile: str, maybeFVname: str) -> None:
mpyBackend.OnShutdown(modelingLanguage, asnFile, maybeFVname)
......@@ -97,6 +97,7 @@ from .B_mappers import qgenc_B_mapper
from .B_mappers import rtds_B_mapper
from .B_mappers import scade6_B_mapper
from .B_mappers import simulink_B_mapper
from .B_mappers import micropython_async_B_mapper
from .B_mappers import vhdl_B_mapper
from .B_mappers.module_protos import Sync_B_Mapper, Async_B_Mapper
......@@ -120,6 +121,7 @@ sys.modules['commonPy2'] = commonPy2
g_async_mappers = {
'C': c_B_mapper,
'MicroPython': micropython_async_B_mapper,
'Ada': ada_B_mapper,
'SDL': sdl_B_mapper,
'OG': og_B_mapper,
......
Supports Markdown
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