ocarina.py 2.2 KB
Newer Older
yoogx's avatar
yoogx committed
1
#! /usr/bin/python
2
3
4
5
6
7
8
9
10
11
'''
:mod:`ocarina` -- Python binding to the Ocarina AADL processor
==============================================================

.. moduleauthor:: Jerome Hugues

This module provides direct access to top-level functions of Ocarina
to load, parse, instantiate AADL models, and to invoke backends.

'''
yoogx's avatar
yoogx committed
12
13
14
15

################################################################################
import libocarina_python; # Ocarina bindings

yoogx's avatar
yoogx committed
16
17
class Enum(tuple): __getattr__ = tuple.index

yoogx's avatar
yoogx committed
18
19
20
21
22
23
24
25
26
27
28
29
################################################################################
def version ():
    '''Print Ocarina version'''
    libocarina_python.version();

################################################################################
def status ():
    '''Print Ocarina status'''
    libocarina_python.status();

################################################################################
def load (filename):
yoogx's avatar
yoogx committed
30
31
32
33
34
35
36
37
38
39
    '''Load a file

    :param filename: name of the file to be loaded, following Ocarina search path
    :type filename: string

    E.g. to load "foo.aadl":

    >>> load("foo.aadl");

    '''
yoogx's avatar
yoogx committed
40
41
42
43
44
45
46
47
48
    libocarina_python.load (filename);

################################################################################
def analyze ():
    '''Analyze models'''
    libocarina_python.analyze ();

################################################################################
def instantiate (root_system):
49
50
51
52
53
54
    '''Instantiate model, starting from root_system

    :param root_system: name of the root system to instantiate
    :type root_system: string

    '''
yoogx's avatar
yoogx committed
55
56
57
    libocarina_python.instantiate (root_system);

################################################################################
yoogx's avatar
yoogx committed
58
59
Backends = Enum ([ "polyorb_hi_ada", "polyorb_hi_c"]);
'''Supported backends'''
60
# Note, this list should match backend names as specific in Ocarina CLI
yoogx's avatar
yoogx committed
61

yoogx's avatar
yoogx committed
62
def generate (generator):
yoogx's avatar
yoogx committed
63
    '''Generate code
yoogx's avatar
yoogx committed
64

yoogx's avatar
yoogx committed
65
66
67
    :param generator: one supported backends, from :data:`Backends`

    For instance, to use the PolyORB-HI/Ada backend, you may use the following
yoogx's avatar
yoogx committed
68

yoogx's avatar
yoogx committed
69
70
71
    >>> generate (Backends.polyorb_hi_ada);
    '''
    libocarina_python.generate (Backends[generator]);
yoogx's avatar
yoogx committed
72
73
74

################################################################################