MIG compiler driver

bootstrap_cmds/migcom.tproj/mig.c · 428 lines · browse source

Entry point of migcom, the Mach Interface Generator. MIG compiles a .defs subsystem into the C that implements Mach RPC: it drives generation of the header, the user-side stubs, and the server-side demultiplexer. This is the tool behind every stub in the mach/*.h headers.

parseArgs source
static void
parseArgs(int argc,char *argv[])
{
  if (argc == 2 && streql(argv[1], "-version")) {
    PrintVersion = TRUE;
    return;
  }

  while (--argc > 0)
    if ((++argv)[0][0] == '-') {
      switch (argv[0][1]) {

        case 'q':
          BeQuiet = TRUE;
          break;

        case 'Q':
          BeQuiet = FALSE;
          break;

        case 'v':
          BeVerbose = TRUE;
          break;

        case 'V':
          BeVerbose = FALSE;
          break;

        case 'r':
          UseMsgRPC = TRUE;
… more in source
main source
int
main(int argc, char *argv[])
{
  FILE *iheader = 0;
  FILE *sheader = 0;
  FILE *dheader = 0;

  set_program_name("mig");
  parseArgs(argc, argv);
  if (PrintVersion) {
    printf("%s\n", MIG_VERSION);
    fflush(stdout);
    exit(0);
  }
  init_global();
  init_type();

  LookNormal();
  (void) yyparse();

  if (mig_errors > 0)
    fatal("%d errors found. Abort.\n", mig_errors);

  more_global();

  uheader = myfopen(UserHeaderFileName, "w");
  if (!UserFilePrefix)
    user = myfopen(UserFileName, "w");
  server = myfopen(ServerFileName, "w");
  if (ServerHeaderFileName)
… more in source
myfopen source
static FILE *
myfopen(const char *name, const char *mode)
{
  const char *realname;
  FILE *file;

  if (name == strNULL)
    realname = "/dev/null";
  else
    realname = name;

  file = fopen(realname, mode);
  if (file == NULL)
    fatal("fopen(%s): %s", realname, strerror(errno));

  return file;
}
yyparse source
extern int yyparse(void);