1.1 --- a/client.c Wed Nov 13 00:17:01 2019 +0100
1.2 +++ b/client.c Wed Nov 13 01:35:02 2019 +0100
1.3 @@ -28,6 +28,12 @@
1.4
1.5
1.6
1.7 +/* Output language, set in the main program. */
1.8 +
1.9 +extern enum language output_language;
1.10 +
1.11 +
1.12 +
1.13 /* Generate operation signature details for client use. */
1.14
1.15 void write_client_signature(struct signature *sig, enum signature_role role,
1.16 @@ -113,7 +119,8 @@
1.17
1.18 /* Send the request. */
1.19
1.20 - fprintf(fp, client_function_body_call, opcode);
1.21 + fprintf(fp, client_function_body_call, opcode,
1.22 + (output_language == CPP_LANGUAGE) ? "endpoint()" : "_endp");
1.23
1.24 /* Retrieve output parameters from the message. */
1.25
2.1 --- a/declaration.c Wed Nov 13 00:17:01 2019 +0100
2.2 +++ b/declaration.c Wed Nov 13 01:35:02 2019 +0100
2.3 @@ -40,6 +40,7 @@
2.4 int cpp = (output_language == CPP_LANGUAGE);
2.5 int have_init_param = (output_language == C_LANGUAGE);
2.6 int declaration = (role == DECLARATION_ROLE);
2.7 + int server = (component == SERVER_ROLE);
2.8
2.9 /* Indent and provide a qualifier for C++ class declarations. */
2.10
2.11 @@ -51,9 +52,8 @@
2.12
2.13 /* Determine a suitable initial parameter for the component. */
2.14
2.15 - char *init_param = have_init_param ? (component == SERVER_ROLE ?
2.16 - "void *_self" :
2.17 - L4_CAP_TYPE " _endp") : "";
2.18 + char *init_param = have_init_param ?
2.19 + (server ? "void *_self" : L4_CAP_TYPE " _endp") : "";
2.20
2.21 /* Introduce an initial parameter for the component state. */
2.22
2.23 @@ -67,10 +67,11 @@
2.24
2.25 fputs(")", fp);
2.26
2.27 - /* Add a "value" for the function, this being used to declare virtual methods
2.28 - in C++. */
2.29 + /* Add a "value" for the function, this being used to declare pure virtual
2.30 + methods in C++. The client has method definitions and therefore normal
2.31 + virtual methods. */
2.32
2.33 - if (cpp && declaration)
2.34 + if (cpp && declaration && server)
2.35 fputs(" = 0", fp);
2.36
2.37 fputs(get_signature_terminator(role), fp);
3.1 --- a/interface.c Wed Nov 13 00:17:01 2019 +0100
3.2 +++ b/interface.c Wed Nov 13 01:35:02 2019 +0100
3.3 @@ -44,6 +44,8 @@
3.4 enum component_role component, FILE *fp)
3.5 {
3.6 int input_items = get_max_input_items(iface->signatures);
3.7 + int cpp = (output_language == CPP_LANGUAGE);
3.8 + int client = (component == CLIENT_ROLE);
3.9
3.10 /* Emit include statements. */
3.11
3.12 @@ -52,18 +54,23 @@
3.13
3.14 /* Begin any namespace. */
3.15
3.16 - if (output_language == CPP_LANGUAGE)
3.17 + if (cpp)
3.18 fprintf(fp, interface_prologue_cpp, iface->name);
3.19
3.20 /* Emit signatures. */
3.21
3.22 write_signatures(iface->signatures, fp, iface,
3.23 - (component == CLIENT_ROLE) ? write_client_signature
3.24 - : write_server_interface_signature);
3.25 + client ? write_client_signature
3.26 + : write_server_interface_signature);
3.27 +
3.28 + /* Client interfaces need an endpoint access method. */
3.29 +
3.30 + if (cpp && client)
3.31 + fprintf(fp, client_interface_endpoint_method, L4_CAP_TYPE);
3.32
3.33 /* Terminate any namespace. */
3.34
3.35 - if (output_language == CPP_LANGUAGE)
3.36 + if (cpp)
3.37 fputs(interface_epilogue_cpp, fp);
3.38
3.39 fprintf(fp, expected_items_definition, iface->name, input_items);
4.1 --- a/templates.h Wed Nov 13 00:17:01 2019 +0100
4.2 +++ b/templates.h Wed Nov 13 01:35:02 2019 +0100
4.3 @@ -45,7 +45,7 @@
4.4 " long err;\n"
4.5
4.6 #define client_function_body_call \
4.7 -"\n ipc_message_request(&msg, %s, _endp);\n\n" \
4.8 +"\n ipc_message_request(&msg, %s, %s);\n\n" \
4.9 " err = l4_error(msg.tag);\n" \
4.10 " if (err)\n" \
4.11 " return err;\n"
4.12 @@ -56,9 +56,9 @@
4.13 #define client_function_signature_prologue_cpp \
4.14 "\n%slong %s("
4.15
4.16 -#define client_interface_endpoint_declaration_cpp \
4.17 +#define client_interface_endpoint_method \
4.18 "\nprotected:\n" \
4.19 -" %s _endp;\n"
4.20 +" %s endpoint() = 0;\n"
4.21
4.22 /* Compound interface dispatcher templates. */
4.23