L4Re/idl4re

Changeset

77:67ccf1eddd3b
2019-11-03 Paul Boddie raw files shortlog changelog graph Fixed usage of ipc_message_send_error, C++ method names. Switched to using l4_snd_fpage_t as the flexpage item type. Made C++ interface operations pure virtual methods.
program.c (file) program.h (file)
     1.1 --- a/program.c	Sun Nov 03 01:54:50 2019 +0100
     1.2 +++ b/program.c	Sun Nov 03 01:57:06 2019 +0100
     1.3 @@ -161,7 +161,7 @@
     1.4      if (protocol != NULL)
     1.5      {
     1.6        fprintf(dispatcher_fp, "    case %s:\n", protocol);
     1.7 -      fprintf(dispatcher_fp, "      ipc_message_send_error(dispatch_%s(msg, obj));\n", iface->name);
     1.8 +      fprintf(dispatcher_fp, "      ipc_message_send_error(msg, dispatch_%s(msg, obj));\n", iface->name);
     1.9        fprintf(dispatcher_fp, "      break;\n\n");
    1.10      }
    1.11  
    1.12 @@ -523,18 +523,21 @@
    1.13  
    1.14    int have_init_param = (output_language == C_LANGUAGE);
    1.15  
    1.16 -  /* Indent for C++ class declarations. */
    1.17 +  /* Indent and provide a qualifier for C++ class declarations. */
    1.18  
    1.19 -  char *indent = (output_language == CPP_LANGUAGE) ? "  " : "",
    1.20 +  char *qualifier = (output_language == CPP_LANGUAGE) ? "  virtual " : "",
    1.21 +       *value_qualifier = (output_language == CPP_LANGUAGE) ? " = 0" : "",
    1.22         *init_param = have_init_param ? "void *_self" : "";
    1.23  
    1.24    /* Introduce an initial parameter for the component state. */
    1.25  
    1.26 -  fprintf(fp, "\n%slong %s(%s", indent, opname, init_param);
    1.27 +  fprintf(fp, "\n%slong %s(%s", qualifier, opname, init_param);
    1.28 +
    1.29    if (have_init_param)
    1.30      write_parameter_separator(sig->parameters, fp);
    1.31    write_parameters(sig->parameters, fp, SIGNATURE_ROLE);
    1.32 -  fputs(");\n", fp);
    1.33 +
    1.34 +  fprintf(fp, ")%s;\n", value_qualifier);
    1.35  
    1.36    free(opname);
    1.37  }
    1.38 @@ -582,7 +585,7 @@
    1.39    /* Generate the case and invocation. */
    1.40  
    1.41    fprintf(fp, "    case %s:\n", opcode);
    1.42 -  fprintf(fp, "      ipc_message_send_error(wrap_%s(msg, obj));\n", opname);
    1.43 +  fprintf(fp, "      ipc_message_send_error(msg, wrap_%s(msg, obj));\n", opname);
    1.44    fprintf(fp, "      break;\n\n");
    1.45  
    1.46    /* Generate the other cases. */
    1.47 @@ -783,7 +786,7 @@
    1.48  
    1.49    /* Invoke the actual operation using the variables. */
    1.50  
    1.51 -  write_server_function_call(param, opname, fp);
    1.52 +  write_server_function_call(param, fp, iface, sig);
    1.53  
    1.54    /* Pack the outputs into the message and perform any other housekeeping. */
    1.55  
    1.56 @@ -810,10 +813,11 @@
    1.57  
    1.58  /* Generate an invocation of the actual server operation. */
    1.59  
    1.60 -void write_server_function_call(struct parameter *param, const char *opname,
    1.61 -                                FILE *fp)
    1.62 +void write_server_function_call(struct parameter *param, FILE *fp,
    1.63 +                                struct interface *iface, struct signature *sig)
    1.64  {
    1.65 -  char *name, *addr;
    1.66 +  char *name, *addr,
    1.67 +       *opname = get_interface_operation_name(iface, sig, output_language);
    1.68  
    1.69    fputs("\n  err = ", fp);
    1.70  
    1.71 @@ -845,6 +849,10 @@
    1.72    /* Emit post-invocation details. */
    1.73  
    1.74    fputs(server_function_body_call, fp);
    1.75 +
    1.76 +  /* Free allocated strings. */
    1.77 +
    1.78 +  free(opname);
    1.79  }
    1.80  
    1.81  /* Generate a variable declaration for message word accessors. */
     2.1 --- a/program.h	Sun Nov 03 01:54:50 2019 +0100
     2.2 +++ b/program.h	Sun Nov 03 01:57:06 2019 +0100
     2.3 @@ -24,8 +24,13 @@
     2.4  #include <stdio.h>
     2.5  #include "types.h"
     2.6  
     2.7 +/* General capability type. */
     2.8 +
     2.9  #define L4_CAP_TYPE   "l4_cap_idx_t"
    2.10 -#define L4_FPAGE_TYPE "l4_fpage_t"
    2.11 +
    2.12 +/* A flexpage type that can hold extra information (such as the "hot spot"). */
    2.13 +
    2.14 +#define L4_FPAGE_TYPE "l4_snd_fpage_t"
    2.15  
    2.16  /* Output role of a parameter. */
    2.17  
    2.18 @@ -80,8 +85,8 @@
    2.19  void write_server_function_body(struct parameter *param, FILE *fp,
    2.20                                  struct interface *iface, struct signature *sig);
    2.21  
    2.22 -void write_server_function_call(struct parameter *param, const char *opname,
    2.23 -                                FILE *fp);
    2.24 +void write_server_function_call(struct parameter *param, FILE *fp,
    2.25 +                                struct interface *iface, struct signature *sig);
    2.26  
    2.27  /* Dispatcher functions. */
    2.28