Commit 9ae63cf5 authored by Maxime Perrotin's avatar Maxime Perrotin

Cleanup wrappers backends

parent 0f89b6d7
This diff is collapsed.
......@@ -29,30 +29,27 @@ void add_sync_PI(Interface * i)
}
/* Count the number of calling threads for this passive function */
int count = 0;
FOREACH(t, FV, i->parent_fv->calling_threads, {
(void) t; count++;});
(void) t;
count++;
});
fprintf(sync_adb,
"\t------------------------------------------------------\n");
fprintf(sync_adb, "\t-- %srotected Provided Interface \"%s\"\n",
(protected == i->rcm) ? "P" : "Unp", i->name);
fprintf(sync_adb,
"\t------------------------------------------------------\n");
fprintf(sync_ads,
"\t------------------------------------------------------\n");
fprintf(sync_ads, "\t-- %srotected Provided Interface \"%s\"\n",
(protected == i->rcm) ? "P" : "Unp", i->name);
fprintf(sync_ads,
"\t------------------------------------------------------\n");
char *header = make_string(
" ------------------------------------------------------\n"
" -- %srotected Provided Interface \"%s\"\n"
" ------------------------------------------------------\n"
" procedure %s (calling_thread: Integer%s",
(protected == i->rcm) ? "P" : "Unp",
i->name,
i->name,
(NULL != i->in || NULL != i->out) ? ";": "");
/* Declare the Ada procedure in the source and body files */
fprintf(sync_ads, "\tprocedure %s (calling_thread: integer", i->name);
fprintf(sync_adb, "\tprocedure %s (calling_thread: integer", i->name);
fprintf(sync_adb, "%s", header);
fprintf(sync_ads, "%s", header);
free(header);
if (NULL != i->in || NULL != i->out) {
fprintf(sync_ads, ";");
fprintf(sync_adb, ";");
}
/* add IN and OUT parameters */
FOREACH(p, Parameter, i->in, {
List_Ada_Param_Types_And_Names(p, &sync_ads);
......@@ -65,10 +62,10 @@ void add_sync_PI(Interface * i)
fprintf(sync_ads, ");\n");
fprintf(sync_adb, ")");
fprintf(sync_adb, " \n\tis\n");
fprintf(sync_adb, " \n is\n");
/* Declare the external C function in the body */
fprintf(sync_adb, "\t\tprocedure C_%s", i->name);
fprintf(sync_adb, " procedure C_%s", i->name);
if (NULL != i->in || NULL != i->out)
fprintf(sync_adb, "(");
......@@ -80,22 +77,22 @@ void add_sync_PI(Interface * i)
FOREACH(p, Parameter, i->out, {
List_Ada_Param_Types_And_Names(p, &sync_adb);
})
if (NULL != i->in || NULL != i->out)
fprintf(sync_adb, ")");
fprintf(sync_adb, ";\n");
/* Import the C function in the body */
fprintf(sync_adb, "\t\tpragma import (C, C_%s, \"%s_%s\");\n\n",
fprintf(sync_adb, " pragma Import (C, C_%s, \"%s_%s\");\n\n",
i->name, i->parent_fv->name, i->name);
fprintf(sync_adb, "\t\tbegin\n");
fprintf(sync_adb, " begin\n");
if (count > 1) {
fprintf(sync_adb, "\t\t\tcallinglist.push(calling_thread);\n"); /* Put the calling thread in the stack */
fprintf(sync_adb, " callinglist.push(calling_thread);\n"); /* Put the calling thread in the stack */
}
/* Call the C function in the body */
fprintf(sync_adb, "\t\t\tC_%s", i->name);
fprintf(sync_adb, " C_%s", i->name);
if (NULL != i->in || NULL != i->out)
fprintf(sync_adb, "(");
......@@ -113,14 +110,14 @@ void add_sync_PI(Interface * i)
}
fprintf(sync_adb, ";\n");
/* Remove the calling thread from the stack before returning*/
if (count > 1) {
fprintf(sync_adb, "\t\t\tcallinglist.pop;\n");
fprintf(sync_adb, " callinglist.pop;\n");
}
/* End of the procedure body */
fprintf(sync_adb, "\tend %s;\n\n", i->name);
fprintf(sync_adb, " end %s;\n\n", i->name);
}
......@@ -168,15 +165,15 @@ void Add_Protected_Interfaces(FV * fv, FILE * pro_ads, FILE * pro_adb)
fprintf(sync_adb,
"-- Protected object to guarantee mutual exclusion between the protected interfaces of the function\n\n");
fprintf(sync_ads, "protected protected_%s is\n", fv->name);
fprintf(sync_adb, "protected body protected_%s is\n", fv->name);
fprintf(sync_ads, "protected Protected_%s is\n", fv->name);
fprintf(sync_adb, "protected body Protected_%s is\n", fv->name);
FOREACH(i, Interface, fv->interfaces, {
Protected_Interface(i);
})
fprintf(sync_ads, "end protected_%s;\n", fv->name);
fprintf(sync_adb, "end protected_%s;\n", fv->name);
fprintf(sync_ads, "end Protected_%s;\n", fv->name);
fprintf(sync_adb, "end Protected_%s;\n", fv->name);
}
/* If the function has unprotected provided interfaces, add the code to support them in the wrapper file. */
......@@ -203,5 +200,4 @@ void Add_Unprotected_Interfaces(FV * fv, FILE * unpro_ads,
FOREACH(i, Interface, fv->interfaces, {
Unprotected_Interface (i);
})
}
......@@ -267,15 +267,15 @@ void add_sync_PI_to_c_wrappers(Interface * i)
/* body of the function: */
if (protected == i->rcm) {
fprintf(cfile, "\textern %staste_protected_object %s_protected;\n",
fprintf(cfile, " extern %staste_protected_object %s_protected;\n",
get_context()->aadlv2 ? "process_package__" : "",
i->parent_fv->name);
fprintf(cfile,
"\t__po_hi_protected_lock (%s_protected.protected_id);\n",
" __po_hi_protected_lock (%s_protected.protected_id);\n",
i->parent_fv->name);
}
fprintf(cfile, "\t%s_%s(", i->parent_fv->name, i->name);
fprintf(cfile, " %s_%s(", i->parent_fv->name, i->name);
FOREACH(p, Parameter, i->in, {
fprintf(cfile, "%s%s, %s_len", p == i->in->value ? "" : ", ",
......@@ -297,7 +297,7 @@ void add_sync_PI_to_c_wrappers(Interface * i)
if (protected == i->rcm) {
fprintf(cfile,
"\t__po_hi_protected_unlock (%s_protected.protected_id);\n",
" __po_hi_protected_unlock (%s_protected.protected_id);\n",
i->parent_fv->name);
}
......@@ -365,11 +365,11 @@ void add_async_PI_to_c_wrappers(Interface * i)
distant_fv = interface->distant_fv;
}
});
fprintf(cfile, "\tsync_%s_%s (",
fprintf(cfile, " sync_%s_%s (",
distant_fv,
i->distant_name);
} else {
fprintf(cfile, "\t%s_%s(", i->parent_fv->name, i->name);
fprintf(cfile, " %s_%s(", i->parent_fv->name, i->name);
}
if (NULL != i->in) {
fprintf(cfile, "buf.buffer, buf.length");
......@@ -460,11 +460,11 @@ void add_RI_to_c_wrappers(Interface * i)
*/
if (thread_runtime == i->parent_fv->runtime_nature) {
/* Current FV is a thread -> send the message to PolyORB */
fprintf(b, "\t__po_hi_request_t request;\n\n");
fprintf(b, " __po_hi_request_t request;\n\n");
/* If the message has parameters, then copy it to POHIC buffers */
if (NULL != i->in) {
fprintf(b, "\t__po_hi_copy_array"
fprintf(b, " __po_hi_copy_array"
"(&(request.vars.%s_global_outport_%s."
"%s_global_outport_%s.buffer),"
" %s, %s_len);\n",
......@@ -475,7 +475,7 @@ void add_RI_to_c_wrappers(Interface * i)
i->in->value->name, /* unique IN parameter buffer */
i->in->value->name);/* unique IN parameter size */
fprintf(b, "\trequest.vars.%s_global_outport_%s"
fprintf(b, " request.vars.%s_global_outport_%s"
".%s_global_outport_%s.length = %s_len;\n",
i->parent_fv->name, /* sending port identifier */
ri_name, /* data identifier */
......@@ -485,10 +485,10 @@ void add_RI_to_c_wrappers(Interface * i)
}
/* Also set the port number to identify the message */
fprintf(b, "\trequest.port = %s_global_outport_%s;\n",
fprintf(b, " request.port = %s_global_outport_%s;\n",
i->parent_fv->name, ri_name);
fprintf(b, "\t__po_hi_gqueue_store_out("
fprintf(b, " __po_hi_gqueue_store_out("
"%s_%s_k, %s_local_outport_%s, &request);\n",
i->parent_fv->process->identifier, /* sending node */
i->parent_fv->name,
......@@ -496,7 +496,7 @@ void add_RI_to_c_wrappers(Interface * i)
ri_name);
/* Direct invocation of RI */
fprintf(b, "\t__po_hi_send_output("
fprintf(b, " __po_hi_send_output("
"%s_%s_k, %s_global_outport_%s);\n",
i->parent_fv->process->identifier,
i->parent_fv->name,
......@@ -528,7 +528,7 @@ void add_RI_to_c_wrappers(Interface * i)
count ++;
});
if (1 == count) {
fprintf(b, "\tvm_async_%s_%s_vt(",
fprintf(b, " vm_async_%s_%s_vt(",
calltmp->value->name,
i->name);
......@@ -542,9 +542,9 @@ void add_RI_to_c_wrappers(Interface * i)
}
else if (count > 1) {
/* Several possible callers: get current thread id */
fprintf(b, "\tswitch(__po_hi_get_task_id()) {\n");
fprintf(b, " switch(__po_hi_get_task_id()) {\n");
FOREACH(caller, FV, calltmp, {
fprintf(b, "\t\tcase %s_%s_k: vm_async_%s_%s_vt(",
fprintf(b, " case %s_%s_k: vm_async_%s_%s_vt(",
caller->process->identifier,
caller->name,
caller->name,
......@@ -557,15 +557,15 @@ void add_RI_to_c_wrappers(Interface * i)
}
fprintf(b, "); break;\n");
});
fprintf(b, "\t\tdefault: break;\n");
fprintf(b, "\t}\n");
fprintf(b, " default: break;\n");
fprintf(b, " }\n");
}
}
}
else { /* Synchronous RI: direct call to remote polyorb_interface.c */
fprintf(b, "\tsync_%s_%s(",
fprintf(b, " sync_%s_%s(",
i->distant_fv,
NULL != i->distant_name ? i->distant_name : i->name);
......
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