function.tmplt 3.29 KB
Newer Older
1
2
3
4
5
@@-- The documentation of the templates is there:
@@-- https://taste.tuxfamily.org/wiki/index.php?title=Kazoo_Templates_Documentation
@@-- If you are using vim, go over the URL and pres gx in to follow the link
@@-- If you have no internet access you can also use (with vim) Ctrl-W-f or gf in vim to open the text doc:
@@-- $HOME/tool-inst/share/kazoo/doc/templates_skeletons_sub_function.ascii
6
7
8
9
10
11
12
13
14
15
16
/* Body file for function @_Name_@
 * Generated by TASTE on @_NOW_@
 * Provided interfaces : @_List_Of_PIs_@
 * Required interfaces : @_List_Of_RIs_@
 * User-defined properties for this function:
@@TABLE@@
 *   |_ @_Property_Names_@ = @_Property_Values_@
@@END_TABLE@@
 * Timers              : @_Timers_@
 */
#include "@_LOWER:Name_@_vm_if.h"
Maxime Perrotin's avatar
Maxime Perrotin committed
17
@@IF@@ @_PIs_Have_Params_@
18
#include "C_ASN1_Types.h"
Maxime Perrotin's avatar
Maxime Perrotin committed
19
@@END_IF@@
Maxime Perrotin's avatar
Maxime Perrotin committed
20
21
22
#ifdef __unix__
   #include <stdio.h>
#endif
23

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
@@SET@@ SDL_Target_Language=""

@@IF@@ @_Language_@ = Ada
@@SET@@ SDL_Target_Language="Ada"
@@ELSIF@@ @_Language_@ = SDL
@@SET@@ SDL_Target_Language="Ada"
@@TABLE@@
@@IF@@ @_Property_Names_@ = "TASTE_IV_Properties::Default_CodeGen" and @_Property_Values_@ = ada
@@SET@@ SDL_Target_Language="Ada"
@@ELSIF@@ @_Property_Names_@ = "TASTE_IV_Properties::Default_CodeGen" and @_Property_Values_@ = c
@@SET@@ SDL_Target_Language="C"
@@END_IF@@
@@END_TABLE@@
@@END_IF@@

@@IF@@ @_SDL_Target_Language_@ = "Ada"
Maxime Perrotin's avatar
Maxime Perrotin committed
40
extern void adainit(void);
41
42
@@ELSIF@@ @_SDL_Target_Language_@ = "C"
extern void CInit@_CAPITALIZE:Name_@(void);
Maxime Perrotin's avatar
Maxime Perrotin committed
43
@@END_IF@@
44

Maxime Perrotin's avatar
Maxime Perrotin committed
45
46
47
@@TABLE@@
extern void init_@_LOWER:Sync_RIs_Parent_@(void);
extern unsigned @_LOWER:Sync_RIs_Parent_@_initialized;
taste's avatar
taste committed
48
@@IF@@ not @_Use_POHIC_@
49
50
#include "@_LOWER:Sync_RIs_Parent_@_vm_if.h"
@@END_IF@@
taste's avatar
taste committed
51
@@END_TABLE@@
Maxime Perrotin's avatar
Maxime Perrotin committed
52
unsigned @_LOWER:Name_@_initialized = 0;
Maxime Perrotin's avatar
Maxime Perrotin committed
53
void init_@_LOWER:Name_@(void)
54
{
55
   if (0 == @_LOWER:Name_@_initialized) {
Maxime Perrotin's avatar
Maxime Perrotin committed
56
      @_LOWER:Name_@_initialized = 1;
57
@@IF@@ @_Language_@ /= "Ada" and @_Language_@ /= "SDL" and @_Language_@ /= "QGenAda"
58
      // Call user code startup function
59
      @@IF@@ @_Language_@ = "QGenC"
Daniel Tuulik's avatar
Daniel Tuulik committed
60
61
      @_LOWER:Name_@_PI_@_List_Of_PIs_@_startup();
      @@ELSE@@
62
      extern void @_LOWER:Name_@_startup(void);
63
      @_LOWER:Name_@_startup();
Daniel Tuulik's avatar
Daniel Tuulik committed
64
      @@END_IF@@
65
@@ELSIF@@ @_Language_@ = Ada or @_Language_@ = SDL
66
@@IF@@ @_SDL_Target_Language_@ = "Ada"
67
68
      // Initialize Ada runtime to call elaboration functions
      adainit();
69
70
71
72
@@ELSIF@@ @_SDL_Target_Language_@ = "C"
      // Initialize C to call elaboration functions
      CInit@_CAPITALIZE:Name_@();
@@END_IF@@
73
@@END_IF@@
74
@@IF@@ @_EXIST:Sync_RIs_Parent_@
75
76
      // Iterate over all synchronous RIs, and call their parent's
      // init function. Multiple calls are prevented by the "init" guard.
77
@@END_IF@@
78
@@TABLE@@
Maxime Perrotin's avatar
Maxime Perrotin committed
79
80
81
      if (0 == @_LOWER:Sync_RIs_Parent_@_initialized) {
          init_@_LOWER:Sync_RIs_Parent_@();
      }
82
@@END_TABLE@@
Maxime Perrotin's avatar
Maxime Perrotin committed
83
#ifdef __unix__
84
      puts ("[TASTE] Initialization completed for function @_Name_@");
Maxime Perrotin's avatar
Maxime Perrotin committed
85
#endif
86
87
88
      @@-- Value is set to 2 only once the function is fully initialized
      @@-- This was used to prevent RI calls during startup, but this
      @@-- is not needed anymore at runtime since this is now allowed
Maxime Perrotin's avatar
Maxime Perrotin committed
89
      @_LOWER:Name_@_initialized = 2;
90
   }
91
}
92
93
94
@@-- For blackbox devices, don't generate the PI functions, they will be
@@-- generated as skeleton functions. The init function only must be there.
@@IF@@ @_Language_@ /= "Blackbox_C"
95
@_Provided_Interfaces_@
96
@@END_IF@@