Exemplo n.º 1
0
int
mfc_worker::run_hack()
{
  if (w_on_launch) {
    int (*on_launch)(int, char **)= w_on_launch;
    w_on_launch = 0;
    p_mminit();
    w_pollinit();
    int result = on_launch(w_argc, w_argv);
    if (result) return result;
  }
  return CWinThread::Run();
}
Exemplo n.º 2
0
/* modified main calls mpy_on_launch instead of on_launch */
int
mpy_on_launch(int argc, char *argv[])
{
  /* codger creates yinit.c:on_launch, which calls std0.c:y_launch */
  char *txt;
  int ret;
  mpy_initialize(&argc, &argv);
  if (!mpy_size) return on_launch(argc, argv);

  /* on_launch is collective operation, because it queries filesystem
   * to find path for .i files
   */
  if (!mpy_rank) {
    long i;
    /* broadcast yLaunchDir, ySiteDir, yHomeDir, defaultPath */
    long dims[2];
    int batflag = (argc>1) && !strcmp(argv[1],"-batch");
    /* lie about arguments for startup, will put back command line later */
    ret = on_launch(batflag?2:(argc?1:0), argv);
    if (batflag) {
      if (argc > 2) {
        /* mpy_initialize already saved -batch script name */
        for (i=3 ; i<argc ; i++) argv[i-2] = argv[i];
        argc -= 2;
      } else {
        argc = 1;
      }
    }
    /* now that on_launch/y_launch done, put back true command line */
    ym_argc = argc;
    ym_argv = argv;
    dims[0] = 1;
    dims[1] = STRLEN_P_1(yLaunchDir) + STRLEN_P_1(ySiteDir)
      + STRLEN_P_1(yHomeDir) + STRLEN_P_1(y_user_dir) + STRLEN_P_1(y_gist_dir);
    ypush_check(1);  /* we are outside any interpreted function */
    txt = ypush_c(dims);
    STRCPY_TXT(yLaunchDir);
    STRCPY_TXT(ySiteDir);
    STRCPY_TXT(yHomeDir);
    STRCPY_TXT(y_user_dir);
    STRCPY_TXT(y_gist_dir);
    mpy_bcast(1);

  } else {
    extern void Y_set_site(int);
    /* need to call on_launch to initialize interpreter for mpy_bcast */
    ret = on_launch(2, mpy_fake_argv);
    mpy_bcast(1);
    txt = ygeta_c(0, (long *)0, (long *)0);
    if (!txt[0]) txt++, yLaunchDir = 0;
    else yLaunchDir = p_strcpy(txt), txt += strlen(txt)+1;
    if (!txt[0]) txt++, ySiteDir = 0;
    else ySiteDir = p_strcpy(txt), txt += strlen(txt)+1;
    if (!txt[0]) txt++, yHomeDir = 0;
    else yHomeDir = p_strcpy(txt), txt += strlen(txt)+1;
    if (!txt[0]) txt++, y_user_dir = 0;
    else y_user_dir = p_strcpy(txt);
    if (!txt[0]) txt++, y_gist_dir = 0;
    else y_gist_dir = p_strcpy(txt);
    Y_set_site(0);
  }
  yarg_drop(1);
  /* after on_launch, virtual machine initialized, startup .i files
   * (including mpy.i) are queued by name but not yet opened, and
   * batch mode has been set if -batch argv
   */

  /* replace on_include with parallel version, set parallel flag */
  ycall_on_include(mpy_on_include);
  mpy_parallel = 1;

  /* disable autoload */
  if (!mpy0_eval_auto) {
    mpy0_eval_auto = auto_ops.Eval;
    auto_ops.Eval = mpy_eval_auto;
  }

  return ret;
}