# HG changeset patch # User Paul Boddie # Date 1573314483 -3600 # Node ID 2a5b1d2b294c6c185a4a0bd730c70463b973d1dc # Parent df707a7e6e2943f5f311ca0d8e26c7d32c38065a Renamed the compound option to "comp" (also meaning composite or component). Added a compound name option to allow the interface name to be different from the filename prefix. diff -r df707a7e6e29 -r 2a5b1d2b294c docs/idl.1 --- a/docs/idl.1 Sat Nov 09 01:18:22 2019 +0100 +++ b/docs/idl.1 Sat Nov 09 16:48:03 2019 +0100 @@ -22,6 +22,14 @@ to, and accessed by, libraries and applications as if these things happened to be resident in the same program. .PP +Components can support one or many different interfaces by composing them into a +single compound interface, with the different interfaces and operations +distinguished using protocol and operation code (opcode) information embedded in +the invocation information for a given operation. +.B idl +supports the generation of code to select the appropriate interface when +handling invocations. +.PP The interface description or definition language (IDL) employed by .B idl is broadly similar to that used by systems such as CORBA. Indeed, a tool called @@ -75,17 +83,19 @@ configuration has been selected. .PP If the -.BR \-c ", " \-\-client ", " \-s ", " \-\-server ", " \-C " or " \-\-compound +.BR \-c ", " \-\-client ", " \-s ", " \-\-server ", " \-C ", " \-\-comp ", " +.BR \-N " or " \-\-comp-name options are not given, output is produced for client and server configurations. .PP Some options may be followed by a value, either immediately after the long form of the option and an equals sign (\fB=\fP) or in the argument that follows them: .PP .TP -.BR \-C ", " \-\-compound -Generate compound interface files, indicating the name of the compound interface -which will also be the prefix of the generated files; such files are employed by -servers to pass control to individual interfaces. +.BR \-C ", " \-\-comp +Generate compound (or composite, or component) interface files, indicating the +name of the compound interface which will also be the prefix of the generated +files; such files are employed by servers to pass control to individual +interfaces. .TP .BR \-d ", " \-\-dir Indicate the output directory for generated files. @@ -94,6 +104,12 @@ Select the programming language to be used for output; currently only .BR C " and " C++ are accepted as values for this option. +.TP +.BR \-N ", " \-\-comp-name +Select a different name for a compound (or composite, component) interface than +that indicated by the +.BR \-C " or " \-\-comp +options. .SH EXAMPLES Compile the interfaces in .IR hello.idl , @@ -216,7 +232,7 @@ .PP For server components, compound interface files can also be produced with their names chosen using the -.BR \-C " or " \-\-compound +.BR \-C " or " \-\-comp options. With a value of .I name given with these options, files of the following form are produced: @@ -226,6 +242,10 @@ mechanism to function, also to be used by the actual component implementing the interfaces. .TP +.IR name _interfaces.h +contains include statements referencing individual interfaces, needed by the +above compound interface declaration. +.TP .IR name "_server.c or " name _server.cc contains the function definitions needed to dispatch to the interfaces. .TP @@ -265,7 +285,7 @@ .PP Each individual component exporting interfaces must have dispatch functions generated using the -.BR \-C " or " \-\-compound +.BR \-C " or " \-\-comp options. The generated code is combined with the other server code generated for the individual interfaces. .PP diff -r df707a7e6e29 -r 2a5b1d2b294c main.c --- a/main.c Sat Nov 09 01:18:22 2019 +0100 +++ b/main.c Sat Nov 09 16:48:03 2019 +0100 @@ -45,6 +45,7 @@ /* Compound interface and dispatcher output. */ char *output_compound = NULL; +char *output_compound_name = NULL; int output_client = 0; int output_server = 0; @@ -116,11 +117,12 @@ /* long opt following var pointer short opt */ {"all", no_argument, NULL, 'a' }, {"client", no_argument, NULL, 'c' }, - {"compound", required_argument, NULL, 'C' }, + {"comp", required_argument, NULL, 'C' }, {"dir", required_argument, NULL, 'd' }, {"headers", no_argument, NULL, 'h' }, {"interfaces", no_argument, NULL, 'i' }, {"language", required_argument, NULL, 'l' }, + {"comp-name", required_argument, NULL, 'N' }, {"routines", no_argument, NULL, 'r' }, {"server", no_argument, NULL, 's' }, {"verbose", no_argument, NULL, 'v' }, @@ -144,7 +146,7 @@ while (1) { - option = getopt_long(argc, argv, "acC:d:hil:rsv", long_options, NULL); + option = getopt_long(argc, argv, "acC:d:hil:N:rsv", long_options, NULL); if (option == -1) break; @@ -164,9 +166,11 @@ output_selected_role = 1; break; - /* Select compound interface name and output. */ + /* Select compound interface filename prefix and output. */ case 'C': output_compound = optarg; + if (output_compound_name == NULL) + output_compound_name = output_compound; output_selected_role = 1; break; @@ -200,6 +204,14 @@ } break; + /* Select compound interface name and output. */ + case 'N': + output_compound_name = optarg; + if (output_compound == NULL) + output_compound = output_compound_name; + output_selected_role = 1; + break; + /* Generate routines (definitions). */ case 'r': output_routines = 1; diff -r df707a7e6e29 -r 2a5b1d2b294c program.c --- a/program.c Sat Nov 09 01:18:22 2019 +0100 +++ b/program.c Sat Nov 09 16:48:03 2019 +0100 @@ -33,7 +33,8 @@ /* Program state set in the main program. */ -extern char *output_prefix, *output_dir, *output_compound; +extern char *output_prefix, *output_dir, + *output_compound, *output_compound_name; extern int output_client, output_server, output_headers, output_interfaces, output_routines, @@ -173,14 +174,13 @@ if (compound_dispatch_fp != NULL) { - fprintf(compound_dispatch_fp, compound_dispatch_prologue, - output_compound, output_compound, output_compound); + fprintf(compound_dispatch_fp, compound_dispatch_prologue, output_compound); /* Write the handler function. */ write_compound_handler_signature(compound_dispatch_fp); fputs("\n", compound_dispatch_fp); - fprintf(compound_dispatch_fp, compound_handle_function, output_compound); + fprintf(compound_dispatch_fp, compound_handle_function, output_compound_name); /* Write the dispatch function. */ @@ -207,7 +207,7 @@ if (compound_interface_fp != NULL) fprintf(compound_interface_fp, compound_interface_prologue, - output_compound, output_compound); + output_compound, output_compound_name); if (compound_interfaces_fp != NULL) fputs(compound_interfaces_prologue, compound_interfaces_fp); @@ -284,7 +284,7 @@ compound_dispatch_function_signature_cpp : compound_dispatch_function_signature_c; - fprintf(fp, s, output_compound, output_compound); + fprintf(fp, s, output_compound_name, output_compound_name); } void write_compound_handler_signature(FILE *fp) @@ -293,7 +293,7 @@ compound_handle_function_signature_cpp : compound_handle_function_signature_c; - fprintf(fp, s, output_compound, output_compound); + fprintf(fp, s, output_compound_name, output_compound_name); } /* Augment a compound interface class declaration. */ @@ -317,7 +317,7 @@ if (compound_dispatch_header_fp != NULL) { fprintf(compound_dispatch_header_fp, compound_dispatch_header_epilogue, - output_compound, max_input_items); + output_compound_name, max_input_items); fclose(compound_dispatch_header_fp); }