Commit 3ae8c88f authored by Maxime Perrotin's avatar Maxime Perrotin

Minor code cleanup

parent e09c200a
......@@ -80,7 +80,7 @@ void Call_asn2dataModel(FV * fv)
if (!file_exists(dataview_path, dataview_uniq)) {
printf
("[Information] %s/%s not found. Checking for dataview-uniq.asn\n",
("[INFO] %s/%s not found. Checking for dataview-uniq.asn\n",
dataview_path, dataview_uniq);
free(dataview_uniq);
dataview_uniq = make_string("dataview-uniq.asn");
......
/* Buildsupport is (c) 2008-2015 European Space Agency
/* Buildsupport is (c) 2008-2017 European Space Agency
* contact: maxime.perrotin@esa.int
* License is LGPL, check LICENSE file */
/* build_ada_skeletons.c
......@@ -6,23 +6,8 @@
this program generates empty Ada functions respecting the interfaces defined
in the interface view. it provides functions to invoke RI.
Note on the use of the Ada skeletons:
Generated functions for PI are called by C code with parameters passed as
pointers. In Ada, pointers are expressed using the "access" keyword instead
of "in" or "out". To access the variable values, the ".all" postfix can be
used. And to declare a variable for which an access is necessary, the type
must be "aliased". Complete example:
procedure Compute (my_input: access asn1sccT_SEQUENCE) is -- Provided interface
my_output: aliased T_INTEGER; -- Parameter of a Required Interface
begin
my_output := my_input.all.x + my_input.all.y;
required_interface (my_output'access); -- Call Required Interface
end Compute;
Copyright 2014-2015 IB Krates <info@krates.ee>
QGenc code generator integration
*/
#include <stdio.h>
......@@ -105,8 +90,8 @@ int ada_gw_preamble(FV * fv)
strcmp (cp->type.name, "Timer")) {
fprintf(ads,
"\t%s : asn1Scc%s := context_%s.%s_ctxt.%s;\n"
"\tpragma export(C, %s, \"%s_%s\");\n",
" %s : asn1Scc%s := context_%s.%s_ctxt.%s;\n"
" pragma Export(C, %s, \"%s_%s\");\n",
cp->name,
asn2underscore(cp->type.name, strlen(cp->type.name)),
fv->name,
......@@ -180,7 +165,7 @@ int Init_Ada_GW_Backend(FV * fv)
create_file(path, filename, &adb);
assert(NULL != adb);
} else
INFO ("** Information: User code not overwritten for function %s\n",
INFO ("[INFO] User code not overwritten for function %s\n",
fv->name);
free(path);
......@@ -231,10 +216,10 @@ void add_PI_to_Ada_gw(Interface * i)
return;
fprintf(ads,
"\t---------------------------------------------------------\n"
"\t-- Provided interface \"%s\"\n"
"\t---------------------------------------------------------\n"
"\tprocedure %s",
" -- ---------------------------------------------------- --\n"
" -- Provided interface \"%s\"\n"
" -- ---------------------------------------------------- --\n"
" procedure %s",
i->name,
i->name);
......@@ -255,15 +240,15 @@ void add_PI_to_Ada_gw(Interface * i)
}
fprintf(ads, ";\n");
fprintf(ads, "\tpragma export(C, %s, \"%s_PI_%s\");\n\n", i->name,
fprintf(ads, " pragma Export(C, %s, \"%s_PI_%s\");\n\n", i->name,
i->parent_fv->name, i->name);
if (NULL != adb) {
fprintf(adb,
"\t---------------------------------------------------------\n"
"\t-- Provided interface \"%s\"\n"
"\t---------------------------------------------------------\n"
"\tprocedure %s",
" -- ------------------------------------------------ --\n"
" -- Provided interface \"%s\"\n"
" -- ------------------------------------------------ --\n"
" procedure %s",
i->name,
i->name);
}
......@@ -276,12 +261,12 @@ void add_PI_to_Ada_gw(Interface * i)
if (NULL != adb) {
fprintf(adb,
" is\n\tpragma suppress (all_checks);"
"\n\tbegin\n\n");
" is\n pragma Suppress (All_Checks);"
"\n begin\n\n");
fprintf(adb,
"\t\tnull;"
" -- Replace \"null\" with your own code!\n\n\tend %s;\n\n",
" null;"
" -- Replace \"null\" with your own code!\n\n end %s;\n\n",
i->name);
}
......@@ -300,10 +285,10 @@ void add_RI_to_Ada_gw(Interface * i)
return;
fprintf(ads,
"\t---------------------------------------------------------\n"
"\t-- Required interface \"%s\"\n"
"\t---------------------------------------------------------\n"
"\tprocedure %s",
" -- --------------------------------------------------- --\n"
" -- Required interface \"%s\"\n"
" -- --------------------------------------------------- --\n"
" procedure %s",
i->name,
i->name);
......@@ -324,20 +309,17 @@ void add_RI_to_Ada_gw(Interface * i)
fprintf(ads, ";\n");
fprintf(ads, "\tpragma import(C, %s, \"%s_RI_%s\");\n", i->name,
fprintf(ads, " pragma Import(C, %s, \"%s_RI_%s\");\n", i->name,
i->parent_fv->name, i->name);
fprintf(ads, "\tprocedure RI%s", i->name);
fprintf(ads, " procedure RI%s", i->name);
if (NULL != ada_params) {
fprintf(ads, "(%s)", ada_params);
}
fprintf(ads, " renames %s;\n\n", i->name);
free(ada_params);
ada_params = NULL;
}
/* Add timer declarations to the Ada code skeletons */
......@@ -345,23 +327,23 @@ void Ada_Add_timers (FV *fv)
{
if (NULL != fv->timer_list) {
fprintf (ads,
"\t---------------------------------------------------------\n"
"\t-- Timers management --\n"
"\t---------------------------------------------------------\n"
" -- ------------------------------------------------ --\n"
" -- Timers management --\n"
" -- ------------------------------------------------ --\n"
"\n\n");
}
FOREACH(timer, String, fv->timer_list, {
fprintf(ads,
"\t-- This function is called when the timer \"%s\" expires\n"
"\tprocedure %s;\n"
"\tpragma export(C, %s, \"%s_PI_%s\");\n\n"
"\t-- Call this function to set (enable) the timer\n"
"\t-- Value is in milliseconds, and must be a multiple of 100\n"
"\tprocedure SET_%s(val: access asn1sccT_UInt32);\n\n"
"\tpragma import(C, SET_%s, \"%s_RI_SET_%s\");\n\n"
"\t-- Call this function to reset (disable) the timer\n"
"\tprocedure RESET_%s;\n\n"
"\tpragma import(C, RESET_%s, \"%s_RI_RESET_%s\");\n\n",
" -- This function is called when the timer \"%s\" expires\n"
" procedure %s;\n"
" pragma Export(C, %s, \"%s_PI_%s\");\n\n"
" -- Call this function to set (enable) the timer\n"
" -- Value is in milliseconds, and must be a multiple of 100\n"
" procedure Set_%s(val: access asn1sccT_UInt32);\n\n"
" pragma Import(C, Set_%s, \"%s_RI_SET_%s\");\n\n"
" -- Call this function to reset (disable) the timer\n"
" procedure Reset_%s;\n\n"
" pragma Import(C, Reset_%s, \"%s_RI_RESET_%s\");\n\n",
timer,
timer,
timer,
......@@ -377,11 +359,11 @@ void Ada_Add_timers (FV *fv)
timer);
if (NULL != adb) {
fprintf(adb,
"\t-- This function is called when the timer \"%s\" expires \n"
"\tprocedure %s is\n"
"\tbegin\n"
"\t null; -- Replace \"null\" with your own code!\n"
"\tend;\n\n",
" -- This function is called when the timer \"%s\" expires \n"
" procedure %s is\n"
" begin\n"
" null; -- Replace \"null\" with your own code!\n"
" end;\n\n",
timer,
timer);
}
......@@ -412,9 +394,9 @@ void GW_Ada_Backend(FV * fv)
* input queue of the process before executing continuous signals */
if(get_context()->polyorb_hi_c) {
fprintf(ads,
"\t-- TASTE API to check if the input queue is empty\n"
"\tprocedure check_queue(res: access asn1SccT_Boolean);\n"
"\tpragma import(C, check_queue, \"%s_RI_check_queue\");\n",
" -- TASTE API to check if the input queue is empty\n"
" procedure Check_Queue(res: access asn1SccT_Boolean);\n"
" pragma Import(C, Check_Queue, \"%s_RI_check_queue\");\n",
fv->name);
}
......
......@@ -91,7 +91,7 @@ int Init_Driver_GW_Backend(FV * fv)
if (!file_exists(path, filename))
create_file(path, filename, &driver_c);
else {
ERROR ("** Information: driver code not overwritten\n");
ERROR ("[INFO] driver code not overwritten\n");
driver_c = NULL;
}
......@@ -111,7 +111,7 @@ void close_driver_gw_files()
{
fprintf(driver_h, "\n#endif\n");
close_file(&driver_h);
close_file(&driver_c);
}
......
......@@ -41,11 +41,13 @@ void Create_script()
assert (NULL != script);
fprintf (script, "#!/bin/bash\n\n"
"# This script will build your TASTE system (by default with the C runtime).\n\n"
fprintf (script, "#!/bin/bash -e\n\n"
"# This script will build your TASTE system.\n\n"
"# You should not change this file as it was automatically generated.\n\n"
"# If you need additional preprocessing, create a file named 'user_init_pre.sh'\n"
"# and/or 'user_init_post.sh - They will never get overwritten.'\n\n"
"# If you need additional preprocessing, there are three hook files\n"
"# that you can provide and that are called dring the build:\n"
"# user_init_pre.sh, user_init_post.sh and user_init_last.sh\n"
"# These files will never get overwritten by TASTE.'\n\n"
"# Inside these files you may set some environment variables:\n"
"# C_INCLUDE_PATH=/usr/include/xenomai/analogy/:${C_INCLUDE_PATH}\n"
"# unset USE_POHIC \n\n"
......@@ -250,7 +252,7 @@ void Create_script()
case qgenc: fprintf (script, "--subQGenC ");
break;
default:
ERROR ("** Error: unsupported language (function %s)\n", fv->name);
ERROR ("[ERROR] Unsupported language (function %s)\n", fv->name);
ERROR (" -> please manually check the build-script.sh file\n");
break;
}
......
......@@ -113,9 +113,9 @@ void C_End()
which possibly creates additional functions */
FOREACH(fv, FV, get_system_ast()->functions, {
if (get_context()->gw && NULL != fv->zipfile && !get_context()->glue) {
printf ("[Information] No skeleton is generated for function \"%s\"\n"
" because source code is provided in file \"%s\"\n"
" (as specified in the interface view)\n\n",
printf ("[INFO] No skeleton is generated for function \"%s\"\n"
" because source code is provided in file \"%s\"\n"
" (as specified in the interface view)\n\n",
fv->name,
fv->zipfile
);
......
......@@ -154,7 +154,7 @@ void Process_Context_Parameters(FV *fv)
dataview_path = getDataViewPath();
if (!file_exists (dataview_path, dataview_uniq)) {
ERROR ("[Information] %s/%s not found."
ERROR ("[INFO] %s/%s not found."
" Checking for dataview-uniq.asn\n",
dataview_path, dataview_uniq);
free (dataview_uniq);
......@@ -162,7 +162,7 @@ void Process_Context_Parameters(FV *fv)
}
if (!file_exists (dataview_path, dataview_uniq)) {
ERROR ("** Error: %s/%s not found\n",
ERROR ("[ERROR] %s/%s not found\n",
dataview_path, dataview_uniq);
exit (-1);
}
......@@ -190,7 +190,7 @@ void Process_Context_Parameters(FV *fv)
}
if (!will_fail && system (command)) {
ERROR ("The command failed. Try it yourself "
ERROR ("[ERROR] The command failed. Try it yourself "
"(correct paths, access to files, etc.)\n");
exit (-1);
}
......
......@@ -34,19 +34,19 @@ void Create_New_SDL_Structure(FV * fv)
char *dataview_uniq = getASN1DataView();
char *dataview_path = getDataViewPath();
if (!file_exists (dataview_path, dataview_uniq)) {
ERROR ("[Information] %s/%s not found. Checking for dataview-uniq.asn\n", dataview_path, dataview_uniq);
ERROR ("[INFO] %s/%s not found. Checking for dataview-uniq.asn\n", dataview_path, dataview_uniq);
free (dataview_uniq);
dataview_uniq = make_string ("dataview-uniq.asn");
}
char *command = make_string("mono $(which asn1.exe) -customStg $(taste-config --prefix)/share/asn1scc/python.stg:%s/DataView.py -customStgAstVerion 4 %s/%s", path, dataview_path, dataview_uniq);
if (system(command)) {
ERROR ("** Error: Command \"%s\" failed in generation of SDL skeleton\n", command);
ERROR ("[ERROR] Command \"%s\" failed in generation of SDL skeleton\n", command);
}
free(command);
command = make_string("cp \"%s/%s\" %s/", dataview_path, dataview_uniq, path);
if (system(command)) {
ERROR ("** Error: Command \"%s\" failed in generation of SDL skeleton\n", command);
ERROR ("[ERROR] Command \"%s\" failed in generation of SDL skeleton\n", command);
}
free(command);
......
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