interface.tmplt 4.83 KB
Newer Older
1
2
@@-- The following tags are available in this template:
@@--
Maxime Perrotin's avatar
Maxime Perrotin committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
@@-- @_Name_@                   : The name of the interface
@@-- @_Direction_@              : "PI" or "RI"
@@-- @_Kind_@                   : The RCM Kind
@@-- @_Parent_Function_@        : The name of the function
@@-- @_Language_@               : The implementation language of the function
@@-- @_Property_Names_@         : All AADL properties (names) associated to the function
@@-- @_Property_Values_@        : ... and corresponding values
@@-- @_Param_Names_@            : List of parameter names
@@-- @_Param_Types_@            :   |_ Corresponding parameter types
@@-- @_Param_Directions_@       :   |_ Corresponding direction
@@-- @_Param_Encodings_@        :   |_ Corresponding encoding (Default, Native, UPER, ACN)
@@-- @_Remote_Function_Names_@  : Vector tag listing the connected interface(s)
@@-- @_Remote_Interface_Names_@ :   |_ Corresponding interface name
@@-- note, there are more tags, see in taste-interface_view.adb, in To_Template(Taste_Interface)
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
@@IF@@ @_EXIST:Param_Names_@
void @_LOWER:Parent_Function_@_RI_@_LOWER:Name_@
@@INLINE(      \()(,\n       )(\)\n)@@
   @@TABLE@@
      @@IF@@ @_Param_Directions_@ = "PARAM_IN"
         const asn1Scc@_REPLACE_ALL((-)/_):Param_Types_@ *IN_@_LOWER:Param_Names_@
      @@ELSE@@
         asn1Scc@_REPLACE_ALL((-)/_):Param_Types_@ *OUT_@_LOWER:Param_Names_@
      @@END_IF@@
   @@END_TABLE@@
@@END_INLINE@@
@@ELSE@@
void @_LOWER:Parent_Function_@_RI_@_LOWER:Name_@(void)
@@END_IF@@
{
Maxime Perrotin's avatar
Maxime Perrotin committed
32
33
34
35
36
37
38
39
40
41
42
43
44
   #ifdef __unix__
      // Log MSC data on Linux when environment variable is set
      static int innerMsc = -1;
      if (-1 == innerMsc)
         innerMsc = (NULL != getenv("TASTE_INNER_MSC"))?1:0;
      if (1 == innerMsc) {
         long long msc_time = getTimeInMilliseconds();
      @@TABLE'TERSE@@
         @@IF@@ @_Param_Directions_@ = PARAM_IN
         PrintASN1@_REPLACE_ALL(-/_):Param_Types_@ ("INNERDATA: @_LOWER:Name_@::@_REPLACE_ALL(-/_):Param_Types_@::@_LOWER:Param_Names_@", IN_@_LOWER:Param_Names_@);
         @@END_IF@@
      @@END_TABLE@@
         puts(""); // add newline
45
46
@@-- Had to comment the line below, because we miss the destination function (in place of gnc)
@@-- When we have multicast me need to to emit the line several times (and need to add support)
Maxime Perrotin's avatar
Maxime Perrotin committed
47
48
49
50
51
52
53
         @@TABLE@@
         // Log message to @_Remote_Function_Names_@ (corresponding PI: @_Remote_Interface_Names_@)
         printf ("INNER: @_LOWER:Parent_Function_@,@_LOWER:Remote_Function_Names_@,@_LOWER:Name_@,%lld\n", msc_time);
         @@END_TABLE@@
         fflush(stdout);
      }
   #endif
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
@@TABLE'TERSE@@
@@IF@@ @_Param_Directions_@ = PARAM_IN
   // Encode parameter @_Param_Names_@
   static char IN_buf_@_LOWER:Param_Names_@[sizeof(asn1Scc@_REPLACE_ALL(-/_):Param_Types_@)] = {0};
   int size_IN_buf_@_LOWER:Param_Names_@ =
      Encode_@_Param_Encodings_@_@_REPLACE_ALL(-/_):Param_Types_@
        (IN_buf_@_LOWER:Param_Names_@, sizeof(asn1Scc@_REPLACE_ALL(-/_):Param_Types_@), IN_@_LOWER:Param_Names_@);
   if (-1 == size_IN_buf_@_LOWER:Param_Names_@) {
      #ifdef __unix__
         puts ("[ERROR] ASN.1 Encoding failed in @_LOWER:Parent_Function_@_RI_@_LOWER:Name_@, parameter @_Param_Names_@");
      #endif
        /* Crash the application due to message loss */
        extern void abort (void);
        abort();
   }
@@END_IF@@
@@END_TABLE@@

@@TABLE'TERSE@@
@@IF@@ @_Param_Directions_@ = PARAM_OUT
74
   // Buffer for decoding parameter @_Param_Names_@
75
76
   static char OUT_buf_@_LOWER:Param_Names_@[sizeof(asn1Scc@_REPLACE_ALL(-/_):Param_Types_@)];
   size_t      size_OUT_buf_@_LOWER:Param_Names_@ = 0;
77
78
79
80
@@END_IF@@
@@END_TABLE@@

   // Call Middleware interface
81
82
83
84
@@IF@@ @_Param_Names'Length_@ = 0
   extern void vm_@_LOWER:Parent_Function_@_@_LOWER:Name_@(void);
   vm_@_LOWER:Parent_Function_@_@_LOWER:Name_@();
@@ELSE@@
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
   extern void vm_@_LOWER:Parent_Function_@_@_LOWER:Name_@
@@INLINE(     \()(,\n      )(\);\n)@@
   @@TABLE@@
      @@IF@@ @_Param_Directions_@ = "PARAM_IN"
         void *, size_t
      @@ELSE@@
         void *, size_t *
      @@END_IF@@
   @@END_TABLE@@
@@END_INLINE@@
   vm_@_LOWER:Parent_Function_@_@_LOWER:Name_@
@@INLINE(     \()(,\n      )(\);\n)@@
   @@TABLE@@
      @@IF@@ @_Param_Directions_@ = "PARAM_IN"
         IN_buf_@_LOWER:Param_Names_@, (size_t)size_IN_buf_@_LOWER:Param_Names_@
      @@ELSE@@
         OUT_buf_@_LOWER:Param_Names_@, &size_OUT_buf_@_LOWER:Param_Names_@
      @@END_IF@@
   @@END_TABLE@@
@@END_INLINE@@
105
@@END_IF@@
106

107
108
109
@@TABLE'TERSE@@
@@IF@@ @_Param_Directions_@ = PARAM_OUT
   // Decode parameter @_Param_Names_@
110
111
112
113
114
115
116
117
118
   if (0 != Decode_@_Param_Encodings_@_@_REPLACE_ALL(-/_):Param_Types_@
              (OUT_@_LOWER:Param_Names_@, OUT_buf_@_LOWER:Param_Names_@, size_OUT_buf_@_LOWER:Param_Names_@)) {
#ifdef __unix__
      puts ("[ERROR] ASN.1 Decoding failed in @_LOWER:Parent_Function_@_RI_@_LOWER:Name_@, parameter @_Param_Names_@");
#endif
      return;
  }
@@END_IF@@
@@END_TABLE@@
119
}