1.1 --- a/client.c Wed Nov 13 17:23:17 2019 +0100
1.2 +++ b/client.c Fri Nov 15 00:40:14 2019 +0100
1.3 @@ -69,6 +69,11 @@
1.4
1.5 fputs(client_function_body_prologue, fp);
1.6
1.7 + /* Obtain a suitable endpoint reference. */
1.8 +
1.9 + if (output_language == C_LANGUAGE)
1.10 + fprintf(fp, client_function_body_endpoint_conversion_c, L4_CAP_TYPE, L4_CAP_TYPE);
1.11 +
1.12 /* Count the number of input words, items and output words. */
1.13
1.14 count_parameters(param, &input_words, &input_items, &output_words, &output_items);
2.1 --- a/declaration.c Wed Nov 13 17:23:17 2019 +0100
2.2 +++ b/declaration.c Fri Nov 15 00:40:14 2019 +0100
2.3 @@ -22,6 +22,7 @@
2.4 #include <stdlib.h>
2.5 #include "common.h"
2.6 #include "declaration.h"
2.7 +#include "templates.h"
2.8
2.9
2.10
2.11 @@ -51,19 +52,18 @@
2.12 char *opname = get_signature_operation_name(iface, sig, component, role,
2.13 output_language);
2.14
2.15 - /* Determine a suitable initial parameter for the component. */
2.16 -
2.17 - char *init_param = have_init_param ?
2.18 - (server ? "void *_self" : L4_CAP_TYPE " _endp") : "";
2.19 -
2.20 /* Introduce an initial parameter for the component state. */
2.21
2.22 - fprintf(fp, "\n%slong %s(%s", qualifier, opname, init_param);
2.23 + fprintf(fp, interface_function_signature_prologue, qualifier, opname);
2.24 +
2.25 + if (have_init_param)
2.26 + {
2.27 + fprintf(fp, "%s *_self", iface->name);
2.28 + write_parameter_separator(sig->parameters, fp);
2.29 + }
2.30
2.31 /* Emit the parameters. */
2.32
2.33 - if (have_init_param)
2.34 - write_parameter_separator(sig->parameters, fp);
2.35 write_parameters(sig->parameters, fp, SIGNATURE_ROLE);
2.36
2.37 fputs(")", fp);
3.1 --- a/dispatch.c Wed Nov 13 17:23:17 2019 +0100
3.2 +++ b/dispatch.c Fri Nov 15 00:40:14 2019 +0100
3.3 @@ -26,20 +26,12 @@
3.4
3.5
3.6
3.7 -/* Output language, set in the main program. */
3.8 -
3.9 -extern enum language output_language;
3.10 -
3.11 -
3.12 -
3.13 /* Generate dispatch function signatures. */
3.14
3.15 void write_dispatcher_signature(const char *name, enum signature_role role,
3.16 FILE *fp)
3.17 {
3.18 - const char *type = (output_language == CPP_LANGUAGE) ? name : "void";
3.19 -
3.20 - fprintf(fp, dispatch_function_signature, name, type);
3.21 + fprintf(fp, dispatch_function_signature, name, name);
3.22 fputs(get_signature_terminator(role), fp);
3.23 }
3.24
3.25 @@ -48,9 +40,7 @@
3.26 void write_handler_signature(const char *name, enum signature_role role,
3.27 FILE *fp)
3.28 {
3.29 - const char *type = (output_language == CPP_LANGUAGE) ? name : "void";
3.30 -
3.31 - fprintf(fp, handle_function_signature, name, type);
3.32 + fprintf(fp, handle_function_signature, name, name);
3.33 fputs(get_signature_terminator(role), fp);
3.34 }
3.35
4.1 --- a/interface.c Wed Nov 13 17:23:17 2019 +0100
4.2 +++ b/interface.c Fri Nov 15 00:40:14 2019 +0100
4.3 @@ -84,6 +84,12 @@
4.4 fprintf(fp, client_interface_constructor_cpp, class_name, L4_CAP_TYPE);
4.5 }
4.6
4.7 + /* Otherwise, define a type for the interface. */
4.8 +
4.9 + else
4.10 + if (!client)
4.11 + fprintf(fp, interface_type_definition_c, iface->name);
4.12 +
4.13 /* Emit signatures. */
4.14
4.15 write_signatures(iface->signatures, fp, iface,
5.1 --- a/program.c Wed Nov 13 17:23:17 2019 +0100
5.2 +++ b/program.c Fri Nov 15 00:40:14 2019 +0100
5.3 @@ -467,11 +467,10 @@
5.4
5.5 if (client_header_fp != NULL)
5.6 {
5.7 - /* Emit interface include where the type is employed by the client
5.8 + /* Emit interface include to obtain the type employed by the client
5.9 interface. */
5.10
5.11 - if (output_language == CPP_LANGUAGE)
5.12 - write_include(output_basename, "_interface.h", client_header_fp);
5.13 + write_include(output_basename, "_interface.h", client_header_fp);
5.14
5.15 write_interface_definition(iface, CLIENT_ROLE, client_header_fp);
5.16 }
6.1 --- a/server.c Wed Nov 13 17:23:17 2019 +0100
6.2 +++ b/server.c Fri Nov 15 00:40:14 2019 +0100
6.3 @@ -39,10 +39,9 @@
6.4 void write_server_signature(struct signature *sig, enum signature_role role,
6.5 FILE *fp, struct interface *iface)
6.6 {
6.7 - char *opname = get_operation_name(iface, sig),
6.8 - *type = (output_language == CPP_LANGUAGE) ? iface->name : "void";
6.9 + char *opname = get_operation_name(iface, sig);
6.10
6.11 - fprintf(fp, server_function_signature, opname, type);
6.12 + fprintf(fp, server_function_signature, opname, iface->name);
6.13 fputs(get_signature_terminator(role), fp);
6.14
6.15 free(opname);
7.1 --- a/templates.h Wed Nov 13 17:23:17 2019 +0100
7.2 +++ b/templates.h Fri Nov 15 00:40:14 2019 +0100
7.3 @@ -44,18 +44,15 @@
7.4 " ipc_message_t msg;\n" \
7.5 " long err;\n"
7.6
7.7 +#define client_function_body_endpoint_conversion_c \
7.8 +" %s _endp = (%s) _self;\n"
7.9 +
7.10 #define client_function_body_call \
7.11 "\n ipc_message_request(&msg, %s, %s);\n\n" \
7.12 " err = l4_error(msg.tag);\n" \
7.13 " if (err)\n" \
7.14 " return err;\n"
7.15
7.16 -#define client_function_signature_prologue_c \
7.17 -"\nlong %s(%s _endp"
7.18 -
7.19 -#define client_function_signature_prologue_cpp \
7.20 -"\n%slong %s("
7.21 -
7.22 #define client_interface_prologue_cpp \
7.23 " : public %s"
7.24
7.25 @@ -166,6 +163,12 @@
7.26 "};\n\n" \
7.27 "#endif /* __cplusplus */\n"
7.28
7.29 +#define interface_function_signature_prologue \
7.30 +"\n%slong %s("
7.31 +
7.32 +#define interface_type_definition_c \
7.33 +"\ntypedef void %s;\n"
7.34 +
7.35 #define expected_items_definition \
7.36 "\n#define %s_expected_items %d\n"
7.37