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

Minor code cleanup

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