interface.tmplt 3.41 KB
Newer Older
1
2
3
4
5
6
@@-- The following tags are available in this template:
@@--
@@-- @_Name_@                : The name of the interface
@@-- @_Direction_@           : "PI" or "RI"
@@-- @_Kind_@                : The RCM Kind
@@-- @_Parent_Function_@     : The name of the function
Maxime Perrotin's avatar
Maxime Perrotin committed
7
@@-- @_Language_@            : The implementation language of the function
8
9
@@-- @_Property_Names_@      : All AADL properties (names) associated to the function
@@-- @_Property_Values_@     : ... and corresponding values
10
11
12
@@-- @_Param_Names_@         : List of parameter names
@@-- @_Param_Types_@         :   |_ Corresponding parameter types
@@-- @_Param_Directions_@    :   |_ Corresponding direction
Maxime Perrotin's avatar
Maxime Perrotin committed
13
@@-- @_Param_Encodings_@     :   |_ Corresponding encoding (Default, Native, UPER, ACN)
14
@@IF@@ @_EXIST:Param_Names_@
Maxime Perrotin's avatar
Maxime Perrotin committed
15
void @_LOWER:Parent_Function_@_@_LOWER:Name_@
16
@@INLINE(      \()(,\n       )(\)\n)@@
Maxime Perrotin's avatar
Maxime Perrotin committed
17
18
   @@TABLE@@
      @@IF@@ @_Param_Directions_@ = "PARAM_IN"
Maxime Perrotin's avatar
Maxime Perrotin committed
19
         void *IN_@_LOWER:Param_Names_@, size_t IN_@_LOWER:Param_Names_@_len
Maxime Perrotin's avatar
Maxime Perrotin committed
20
     @@ELSE@@
Maxime Perrotin's avatar
Maxime Perrotin committed
21
         void *OUT_@_LOWER:Param_Names_@, size_t *OUT_@_LOWER:Param_Names_@_len
Maxime Perrotin's avatar
Maxime Perrotin committed
22
23
     @@END_IF@@
   @@END_TABLE@@
24
@@END_INLINE@@
25
{
Maxime Perrotin's avatar
Maxime Perrotin committed
26

27
@@TABLE@@    @@-- decode input parameters into static variables
Maxime Perrotin's avatar
Maxime Perrotin committed
28
@@IF@@ @_Param_Directions_@ = "PARAM_IN"
29
   static asn1Scc@_REPLACE_ALL(-/_):Param_Types_@ IN_@_UPPER:Param_Names_@;
Maxime Perrotin's avatar
Maxime Perrotin committed
30
31
32
@@ELSE@@
   static asn1Scc@_REPLACE_ALL(-/_):Param_Types_@ OUT_@_UPPER:Param_Names_@;
@@END_IF@@
33
#ifdef __unix__
Maxime Perrotin's avatar
Maxime Perrotin committed
34
@@IF@@ @_Param_Directions_@ = "PARAM_IN"
35
   asn1Scc@_REPLACE_ALL(-/_):Param_Types_@_Initialize(&IN_@_UPPER:Param_Names_@);
Maxime Perrotin's avatar
Maxime Perrotin committed
36
37
38
@@ELSE@@
   asn1Scc@_REPLACE_ALL(-/_):Param_Types_@_Initialize(&OUT_@_UPPER:Param_Names_@);
@@END_IF@@
39
#endif
Maxime Perrotin's avatar
Maxime Perrotin committed
40
41
@@IF@@ @_Param_Directions_@ = "PARAM_IN"
   if (0 != Decode_@_Param_Encodings_@_@_REPLACE_ALL(-/_):Param_Types_@ (&IN_@_UPPER:Param_Names_@, IN_@_LOWER:Param_Names_@, IN_@_LOWER:Param_Names_@_len)) {
42
43
44
45
46
      #ifdef __unix__
         puts("Error decoding @_Param_Types_@ in function @_LOWER:Parent_Function_@_@_LOWER:Name_@");
      #endif
      return;
   }
Maxime Perrotin's avatar
Maxime Perrotin committed
47
@@END_IF@@
48
49
@@END_TABLE@@

Maxime Perrotin's avatar
Maxime Perrotin committed
50
51
52
53
54
55
56
57
58
59
60
61
62
   //  Declare user code function as external (it may not have a .h if it is in Ada)
   extern void @_LOWER:Parent_Function_@_PI_@_LOWER:Name_@
@@INLINE(      \()(,\n       )(\);\n)@@
   @@TABLE@@
      @@IF@@ @_Param_Directions_@ = "PARAM_IN"
         const asn1Scc@_REPLACE_ALL(-/_):Param_Types_@ *
     @@ELSE@@
         asn1Scc@_REPLACE_ALL(-/_):Param_Types_@ *
     @@END_IF@@
   @@END_TABLE@@
@@END_INLINE@@

   // Call user code
63
64
65
66
67
68
69
70
71
72
   @_LOWER:Parent_Function_@_PI_@_LOWER:Name_@
@@INLINE(      \()(,\n       )(\);\n)@@
   @@TABLE@@
      @@IF@@ @_Param_Directions_@ = "PARAM_IN"
         &IN_@_UPPER:Param_Names_@
     @@ELSE@@
         &OUT_@_UPPER:Param_Names_@
     @@END_IF@@
   @@END_TABLE@@
@@END_INLINE@@
Maxime Perrotin's avatar
Maxime Perrotin committed
73
74
75
76
77
78

@@TABLE@@    @@-- encode output parameters
@@IF@@ @_Param_Directions_@ = "PARAM_OUT"
   *OUT_@_LOWER:Param_Names_@_len = Encode_@_Param_Encodings_@_@_REPLACE_ALL(-/_):Param_Types_@ (OUT_@_LOWER:Param_Names_@, sizeof (asn1Scc@_REPLACE_ALL(-/_):Param_Types_@), &OUT_@_UPPER:Param_Names_@);
@@END_IF@@
@@END_TABLE@@
79
80
81
}
@@ELSE@@   @@-- parameterless functions
void @_LOWER:Parent_Function_@_@_LOWER:Name_@()
82
{
Maxime Perrotin's avatar
Maxime Perrotin committed
83
84
   //  Directly call user code, no parameters to pass
   //  This could be done directly from the concurrency glue...
Maxime Perrotin's avatar
Maxime Perrotin committed
85
   extern void @_LOWER:Parent_Function_@_PI_@_LOWER:Name_@(void);
Maxime Perrotin's avatar
Maxime Perrotin committed
86
87
   @_LOWER:Parent_Function_@_PI_@_LOWER:Name_@();
   // puts ("@_LOWER:Parent_Function_@_@_LOWER:Name_@ called");
88
}
Maxime Perrotin's avatar
Maxime Perrotin committed
89
@@END_IF@@