Commit c3293307 authored by Maxime Perrotin's avatar Maxime Perrotin

Add skeleton for vm_if templates

parent 385ead7e
......@@ -259,14 +259,17 @@ package body TASTE.Backend.Code_Generators is
declare
-- Path is where the template files are located
Path : constant String := Full_Name (Current);
-- Do_Func is true if there is a template for the
-- generation of a function template
Do_Func : constant Boolean :=
Exists (Path & "/function-filename.tmplt");
-- Do_Func is true if there is a template for the
-- Do_Make is true if there is a template for the
-- generation of a build script/Makefile template
Do_Make : constant Boolean :=
Exists (Path & "/makefile-filename.tmplt");
-- File_Name is the output file to generate,
-- as parsed from the template file
File_Name : constant String :=
......@@ -275,34 +278,35 @@ package body TASTE.Backend.Code_Generators is
Strip_String (Parse
(Path & "/function-filename.tmplt", File_Tmpl))
else "");
-- User can define the name of the build script
-- to generate.. Typycally, for a function, "Makefile"
-- to generate (typically, for a function, "Makefile")
Make_Name : constant String :=
(if Do_Make
then
Strip_String (Parse
(Path & "/makefile-filename.tmplt", File_Tmpl))
else "");
-- Present_F is True if the function file already exists
Present_F : constant Boolean :=
(File_Name /= "" and Exists (Output_Dir & File_Name));
-- Present_M is True if the Makefile already exists
Present_M : constant Boolean :=
(Make_Name /= "" and Exists (Output_Dir & Make_Name));
-- Data needed to process trigger.tmplt
Trig_Tmpl : constant Translate_Set :=
+Assoc ("Name", Each.Name)
& Assoc ("Language",
Language_Spelling (Each))
& Assoc ("Is_Type", Each.Is_Type)
& Assoc ("Instance_Of",
Each.Instance_Of.Value_Or (US ("")))
& Assoc ("C_Middleware",
Model.Configuration.Use_POHIC)
& Assoc ("Filename_Is_Present",
Present_F)
& Assoc ("Makefile_Is_Present",
Present_M);
+Assoc ("Name", Each.Name)
& Assoc ("Language", Language_Spelling (Each))
& Assoc ("Is_Type", Each.Is_Type)
& Assoc ("Instance_Of",
Each.Instance_Of.Value_Or (US ("")))
& Assoc ("C_Middleware", Model.Configuration.Use_POHIC)
& Assoc ("Filename_Is_Present", Present_F)
& Assoc ("Makefile_Is_Present", Present_M);
-- Trigger is set to True by the template
Trigger : constant Boolean :=
(Exists (Path & "/trigger.tmplt")
......@@ -317,10 +321,6 @@ package body TASTE.Backend.Code_Generators is
Path => Path & "/",
Output_Lang => Output_Lang,
Output_Sub => Output_Sub);
else
null; -- Too much noise
-- Put_Info ("Nothing to generate from templates in "
-- & Path);
end if;
end;
end loop;
......
@@-- The following tags are available in this template:
@@--
@@-- @_Name_@ : The name of the function
@_LOWER:Name_@_vm_if.c
@@-- The following tags are available in this template:
@@--
@@-- @_Name_@ : The name of the function
@@-- @_Language_@ : The implementation language
@@-- @_List_Of_PIs_@ : List of all Provided Interfaces (just names)
@@-- @_List_Of_RIs_@ : List of all Required Interfaces (just names)
@@-- @_List_Of_Sync_PIs@ : List of synchronous Provided Interfaces
@@-- @_List_Of_Sync_RIs@ : List of synchronous Required Interfaces
@@-- @_List_Of_ASync_PIs@ : List of asynchronous Provided Interfaces
@@-- @_List_Of_ASync_RIs@ : List of asynchronous Required Interfaces
@@-- @_ASN1_Modules_@ : List of ASN.1 Modules names
@@-- @_ASN1_Files_@ : List of ASN.1 Files with path
@@-- @_Timers_@ : List of timers (just names)
@@-- @_Has_Context_@ : Flag, True if there are context parameters
@@-- @_CP_Names_@ : List of Context Parameter names
@@-- @_CP_Types_@ : List of Context Parameter types
@@-- @_Provided_Interfaces_@ : From template: Provided interfaces with params
@@-- @_Required_Interfaces_@ : From template: Required interfaces with params
@@-- @_Property_Names_@ : List of User-defined properties (names)
@@-- @_Property_Values_@ : List of User-defined properties (values)
@@-- @_Is_Type_@ : Flag, True if function is a component type
@@-- @_Instance_Of_@ : Optional name of component type
/* Body file for function @_Name_@
* Generated by TASTE on @_NOW_@
* You can edit this file, it will not be overwritten
* 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"
void init_@_LOWER:Name_@()
{
}
@@TABLE@@
@_Provided_Interfaces_@
@@END_TABLE@@
@@-- 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
@@-- @_Param_Names_@ : List of parameter names
@@-- @_Param_Types_@ : |_ Corresponding parameter types
@@-- @_Param_Directions_@ : |_ Corresponding direction
@@IF@@ @_EXIST:Param_Names_@
void @_LOWER:Parent_Function_@_@_LOWER:Name_@(
@@INLINE( \()(,\n )(\)\n)@@
@@TABLE@@
@@IF@@ @_Param_Directions_@ = "PARAM_IN"
void *IN_@_LOWER:Param_Names_@, size_t IN_@_LOWER:Param_Names_@_len
@@ELSE@@
void *OUT_@_LOWER:Param_Names_@, size_t *OUT_@_LOWER:Param_Names_@_len
@@END_IF@@
@@END_TABLE@@
@@END_INLINE@@
@@ELSE@@
void @_LOWER:Parent_Function_@_@_LOWER:Name_@()
@@END_IF@@
{
}
@@-- This template must return either TRUE or something else (meaning FALSE)
@@-- It is used to determine if the other templates in this folder will be
@@-- processed or ignored.
@@-- One folder can contain two templates: one for a function, and one for
@@-- a corresponding makefile (or build script)
@@-- The name of the function is read from template "function-filename.tmplt"
@@-- The name of the makefile is read from template "makefile-filename.tmplt"
@@-- These files are optional, if absent no error is raised
@@-- The following tags are available in this template:
@@--
@@-- @_Name_@ : The name of the function
@@-- @_Is_Type_@ : True if function type
@@-- @_Instance_Of_@ : Name of instance or empty string
@@-- @_Language_@ : Implementation language for the function
@@-- @_Filename_Is_Present_@ : True if target function output already exists
@@-- @_Makefile_Is_Present_@ : True if target build script already exists
@@-- @_C_Middleware_@ : True if middleware is in C (e.g. PO-HI-C)
@@IF@@ not @_Is_Type_@ and (@_Language_@ = "C" or @_Language_@ = "GUI" or @_Language_@ = "Ada" or @_Language_@ = "VDM" or @_Language_@ = "QGenAda" or @_Language_@ = "QGenC" or @_Language_@ = "RTDS" or @_Language_@ = "CPP" or @_Language_@ = "SDL" or @_Language_@ = "MicroPython")
TRUE
@@END_IF@@
@@-- The following tags are available in this template:
@@--
@@-- @_Name_@ : The name of the function
@_LOWER:Name_@_vm_if.h
@@-- The following tags are available in this template:
@@--
@@-- @_Name_@ : The name of the function
@@-- @_Language_@ : The implementation language
@@-- @_List_Of_PIs_@ : List of all Provided Interfaces (just names)
@@-- @_List_Of_RIs_@ : List of all Required Interfaces (just names)
@@-- @_List_Of_Sync_PIs@ : List of synchronous Provided Interfaces
@@-- @_List_Of_Sync_RIs@ : List of synchronous Required Interfaces
@@-- @_List_Of_ASync_PIs@ : List of asynchronous Provided Interfaces
@@-- @_List_Of_ASync_RIs@ : List of asynchronous Required Interfaces
@@-- @_ASN1_Modules_@ : List of ASN.1 Modules names
@@-- @_ASN1_Files_@ : List of ASN.1 Files with path
@@-- @_Timers_@ : List of timers (just names)
@@-- @_Has_Context_@ : Flag, True if there are context parameters
@@-- @_CP_Names_@ : List of Context Parameter names
@@-- @_CP_Types_@ : List of Context Parameter types
@@-- @_Provided_Interfaces_@ : From template: Provided interfaces with params
@@-- @_Required_Interfaces_@ : From template: Required interfaces with params
@@-- @_Property_Names_@ : List of User-defined properties (names)
@@-- @_Property_Values_@ : List of User-defined properties (values)
@@-- @_Is_Type_@ : Flag, True if function is a component type
@@-- @_Instance_Of_@ : Optional name of component type
/* Header file for function @_Name_@ in @_Language_@ language
* Generated by TASTE on @_NOW_@
* Context Parameters present : @_YES_NO:Has_Context_@
* Provided interfaces : @_List_Of_PIs_@
* Required interfaces : @_List_Of_RIs_@
* User-defined properties for this function:
@@TABLE@@
* |_ @_Property_Names_@ = @_Property_Values_@
@@END_TABLE@@
* DO NOT EDIT THIS FILE, IT WILL BE OVERWRITTEN DURING THE BUILD
*/
#pragma once
#ifdef __unix__
#include <stdlib.h>
#include <stdio.h>
#else
typedef unsigned size_t;
#endif
#ifdef __cplusplus
extern "C" {
#endif
// C_ASN1_Types contains the signatures for ASN.1 Encoding/Decoding
#include "C_ASN1_Types.h"
// Function initialization - calls user startup code of all dependent functions
void init_@_LOWER:Name_@();
@@IF@@ @_Language_@ = "Ada" or @_Language_@ = "QGenAda"
extern void adainit();
@@END_IF@@
/* Provided interfaces */
@@TABLE@@
@_Provided_Interfaces_@
@@END_TABLE@@
/* Required interfaces */
@@TABLE@@
@_Required_Interfaces_@
@@END_TABLE@@
#ifdef __cplusplus
}
#endif
@@-- 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
@@-- @_Param_Names_@ : List of parameter names
@@-- @_Param_Types_@ : |_ Corresponding parameter types
@@-- @_Param_Directions_@ : |_ Corresponding direction
@@INLINE@@
@@IF@@ @_Direction_@ = "PI"
void @_LOWER:Parent_Function_@_@_LOWER:Name_@(
@@ELSE@@
// Check invoke_ri for required interface @_Name_@(
@@END_IF@@
@@INLINE(, )@@
@@TABLE@@
@@IF@@ @_Param_Directions_@ = "PARAM_IN"
void *IN_@_LOWER:Param_Names_@, size_t IN_@_LOWER:Param_Names_@_len
@@ELSE@@
void *OUT_@_LOWER:Param_Names_@, size_t *OUT_@_LOWER:Param_Names_@_len
@@END_IF@@
@@END_TABLE@@
@@END_INLINE@@
);
@@END_INLINE@@
@@-- This template must return either TRUE or something else (meaning FALSE)
@@-- It is used to determine if the other templates in this folder will be
@@-- processed or ignored.
@@-- One folder can contain two templates: one for a function, and one for
@@-- a corresponding makefile (or build script)
@@-- The name of the function is read from template "function-filename.tmplt"
@@-- The name of the makefile is read from template "makefile-filename.tmplt"
@@-- These files are optional, if absent no error is raised
@@-- The following tags are available in this template:
@@--
@@-- @_Name_@ : The name of the function
@@-- @_Is_Type_@ : True if function type
@@-- @_Instance_Of_@ : Name of instance or empty string
@@-- @_Language_@ : Implementation language for the function
@@-- @_Filename_Is_Present_@ : True if target function output already exists
@@-- @_Makefile_Is_Present_@ : True if target build script already exists
@@-- @_C_Middleware_@ : True if middleware is in C (e.g. PO-HI-C)
@@IF@@ not @_Is_Type_@ and (@_Language_@ = "C" or @_Language_@ = "GUI" or @_Language_@ = "Ada" or @_Language_@ = "VDM" or @_Language_@ = "QGenAda" or @_Language_@ = "QGenC" or @_Language_@ = "RTDS" or @_Language_@ = "CPP" or @_Language_@ = "SDL" or @_Language_@ = "MicroPython")
TRUE
@@END_IF@@
Markdown is supported
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