1.1 --- a/docs/wiki/Servers Fri Sep 16 14:00:36 2022 +0200
1.2 +++ b/docs/wiki/Servers Fri Dec 02 00:46:33 2022 +0100
1.3 @@ -244,15 +244,11 @@
1.4 This macro invocation expands to a call to `_ipc_server_loop_for` with the
1.5 following parameters:
1.6
1.7 - * The predefined number of items expected for the `Calc` interface, generated
1.8 - automatically and provided by `Calc_expected_items`
1.9 + * The default server configuration for the `Calc` interface, generated
1.10 + automatically and provided by `config_Calc`
1.11
1.12 * The object address for the component
1.13
1.14 - * A handler function for directing requests to the component, this being
1.15 - provided by the generated `handle_Calc` function which must be cast to an
1.16 - acceptable type as indicated
1.17 -
1.18 * The named capability through which incoming messages will be received
1.19
1.20 Here, the macro casts the object address to the appropriate type. In simple
2.1 --- a/program.c Fri Sep 16 14:00:36 2022 +0200
2.2 +++ b/program.c Fri Dec 02 00:46:33 2022 +0100
2.3 @@ -1,7 +1,7 @@
2.4 /*
2.5 * Code generation from interface descriptions.
2.6 *
2.7 - * Copyright (C) 2019, 2020 Paul Boddie <paul@boddie.org.uk>
2.8 + * Copyright (C) 2019, 2020, 2022 Paul Boddie <paul@boddie.org.uk>
2.9 *
2.10 * This program is free software; you can redistribute it and/or
2.11 * modify it under the terms of the GNU General Public License as
2.12 @@ -151,8 +151,8 @@
2.13
2.14 if (conf.routines)
2.15 {
2.16 - s = (conf.language == CPP_LANGUAGE) ? server_filename_cpp :
2.17 - server_filename_c;
2.18 + s = (conf.language == CPP_LANGUAGE) ? server_filename_cpp
2.19 + : server_filename_c;
2.20 compound_dispatch_fp = get_output_file(s, compound_dirname, conf.compound);
2.21 if (compound_dispatch_fp == NULL)
2.22 return 0;
2.23 @@ -301,6 +301,12 @@
2.24 {
2.25 fputs(compound_dispatch_epilogue, compound_dispatch_fp);
2.26 fputs(END_FUNCTION, compound_dispatch_fp);
2.27 +
2.28 + /* Emit default configuration instance definition. */
2.29 +
2.30 + fprintf(compound_dispatch_fp, server_config_instance,
2.31 + conf.compound_name, conf.compound_name, conf.compound_name);
2.32 +
2.33 fclose(compound_dispatch_fp);
2.34 }
2.35
2.36 @@ -308,6 +314,12 @@
2.37 {
2.38 fprintf(compound_dispatch_header_fp, expected_items_definition,
2.39 conf.compound_name, max_input_items);
2.40 +
2.41 + /* Emit default configuration instance declaration. */
2.42 +
2.43 + fprintf(compound_dispatch_header_fp, server_config_instance_declaration,
2.44 + conf.compound_name);
2.45 +
2.46 fclose(compound_dispatch_header_fp);
2.47 }
2.48
2.49 @@ -499,6 +511,11 @@
2.50 fputs(END_FUNCTION, server_fp);
2.51
2.52 write_dispatcher(iface->signatures, server_fp, iface);
2.53 +
2.54 + /* Emit default configuration instance definition. */
2.55 +
2.56 + fprintf(server_fp, server_config_instance,
2.57 + iface->name, iface->name, iface->name);
2.58 }
2.59
2.60 /* Emit the headers. */
2.61 @@ -528,6 +545,10 @@
2.62
2.63 write_dispatcher_signature(iface->name, DECLARATION_ROLE, server_header_fp);
2.64 write_handler_signature(iface->name, DECLARATION_ROLE, server_header_fp);
2.65 +
2.66 + /* Emit default configuration instance declaration. */
2.67 +
2.68 + fprintf(server_header_fp, server_config_instance_declaration, iface->name);
2.69 }
2.70
2.71 /* The server interface is used by client and server code. */
3.1 --- a/templates.h Fri Sep 16 14:00:36 2022 +0200
3.2 +++ b/templates.h Fri Dec 02 00:46:33 2022 +0100
3.3 @@ -1,7 +1,7 @@
3.4 /*
3.5 * Template output.
3.6 *
3.7 - * Copyright (C) 2019, 2020, 2021 Paul Boddie <paul@boddie.org.uk>
3.8 + * Copyright (C) 2019, 2020, 2021, 2022 Paul Boddie <paul@boddie.org.uk>
3.9 *
3.10 * This program is free software; you can redistribute it and/or
3.11 * modify it under the terms of the GNU General Public License as
3.12 @@ -174,11 +174,19 @@
3.13
3.14 #define server_header_prologue \
3.15 "#pragma once\n\n" \
3.16 -"#include <ipc/message.h>\n"
3.17 +"#include <ipc/message.h>\n" \
3.18 +"#include <ipc/server.h>\n"
3.19
3.20 #define server_prologue \
3.21 "#include \"%s_server.h\"\n"
3.22
3.23 +#define server_config_instance_declaration \
3.24 +"\nextern ipc_server_default_config_type config_%s;\n"
3.25 +
3.26 +#define server_config_instance \
3.27 +"\nipc_server_default_config_type config_%s = {\n" \
3.28 +" %s_expected_items, (ipc_server_handler_type) handle_%s};\n"
3.29 +
3.30 /* Server wrapper function templates. */
3.31
3.32 #define server_function_signature \