1.1 --- a/server.c Sun Apr 26 22:59:15 2020 +0200
1.2 +++ b/server.c Sat Jul 04 23:24:20 2020 +0200
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * Server code generation.
1.6 *
1.7 - * Copyright (C) 2019 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2019, 2020 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -88,13 +88,21 @@
1.13 {
1.14 char *opname = get_operation_name(iface, sig);
1.15
1.16 - /* Generate a signature featuring an initiator reference and only "out" and
1.17 - "inout" parameters. */
1.18 + /* Generate a signature featuring an initiator reference (for non-synchronous
1.19 + completions) and only "out" and "inout" parameters. */
1.20 +
1.21 + int synchronous = have_attribute(sig->attributes, "sync");
1.22
1.23 - fprintf(fp, server_completion_function_signature_prologue, opname, iface->name);
1.24 + char *prologue = synchronous ?
1.25 + server_completion_synchronous_function_signature_prologue :
1.26 + server_completion_function_signature_prologue;
1.27 +
1.28 + fprintf(fp, prologue, opname, iface->name);
1.29 +
1.30 + /* Continue from the initial endpoint parameter if not synchronous. */
1.31
1.32 write_parameters(sig->parameters, fp, SIGNATURE_ROLE, COMPLETION_ROLE,
1.33 - OUT_PARAMETER, 1);
1.34 + OUT_PARAMETER, !synchronous);
1.35
1.36 fputs(")", fp);
1.37 fputs(get_signature_terminator(role), fp);
1.38 @@ -250,10 +258,16 @@
1.39
1.40 write_output_initialisation(param, fp, opname, output_words, output_items, COMPLETION_ROLE);
1.41
1.42 - /* Send the response.
1.43 + /* Send a plain reply for synchronous completions. */
1.44 +
1.45 + if (have_attribute(sig->attributes, "sync"))
1.46 + fputs(server_completion_synchronous_function_body_epilogue, fp);
1.47 +
1.48 + /* Send a response as a new message to the given endpoint.
1.49 NOTE: The label 0 is employed but an error condition could be communicated. */
1.50
1.51 - fprintf(fp, server_completion_function_body_epilogue, "0", "_endp");
1.52 + else
1.53 + fprintf(fp, server_completion_function_body_epilogue, "0", "_endp");
1.54
1.55 /* Free allocated strings. */
1.56