Esempio n. 1
0
static int tortoise_guile_main(int argc, char *argv[])
{
	scm_with_guile(&register_functions, NULL);
	scm_shell(argc, argv);

	return 0;
}
Esempio n. 2
0
static void
inner_main (void *data, int argc, char **argv)
{
  /*
   *  To    intialize    comm     module    one    needs    to    call
   *  guile_comm_module_init  ().  This  function  does not  yet  call
   *  MPI_Init (). Instead it defines comm-init for the user to issue
   *
   *     (comm-init (command-line))
   *     ...
   *     (comm-finalize)
   *
   *  in Scheme code.
   */

  /*
   * Note  that  the names  defined  here  are  put into  the  private
   * namespace  of (guile-user)  module. If  you want  to call  any of
   * these you may need to "steal" it from there by dereferencing them
   * as e.g. (@@ (guile-user) guile-comm-module-init).
   *
   * Calling this will define comm-* gsubrs:
   */
  scm_c_define_gsubr ("guile-comm-module-init", 0, 0, 0, guile_comm_module_init);

  scm_shell (argc, argv); // never returns
}
Esempio n. 3
0
static void
inner_main (void *closure, int argc, char **argv)
{
  if (init_testing_framework () < 0)
    {
      fprintf (stderr, "Unable to instantiate JVM.\n");
      exit (1);
    }
  scm_shell (argc, argv);
}
Esempio n. 4
0
static void
inner_main(void *closure, int argc, char **argv)
{
#ifdef SWIGINIT
  SWIGINIT
#else
  SWIG_init();			/* SWIG init function */
#endif
  scm_shell(argc, argv);	/* scheme interpreter */
  /* never reached: scm_shell will perform an exit */
}
Esempio n. 5
0
static void guile_main(void* data, int argc, char** argv) {
							/* req, opt, rest */
	scm_c_define_gsubr("musicpd-server-version", 0, 0, 0, wrap_musicpd_server_version);
	scm_c_define_gsubr("musicpd-playlist-add-path", 1, 0, 0, wrap_musicpd_playlist_add_path);
	scm_c_define_gsubr("musicpd-play", 0, 1, 0, wrap_musicpd_play);
	scm_c_define_gsubr("musicpd-prev", 0, 0, 0, wrap_musicpd_prev);
	scm_c_define_gsubr("musicpd-next", 0, 0, 0, wrap_musicpd_next);
	scm_c_define_gsubr("musicpd-pause", 0, 0, 0, wrap_musicpd_pause);
	scm_c_define_gsubr("musicpd-stop", 0, 0, 0, wrap_musicpd_stop);
	scm_c_define_gsubr("musicpd-lib-version", 0, 0, 0, wrap_musicpd_lib_version);
	scm_c_define_gsubr("musicpd-connected", 0, 0, 0, wrap_musicpd_connected);
	scm_c_define_gsubr("player-version", 0, 0, 0, wrap_player_version);
	/*scm_shell(argc,argv);*/
	scm_shell(0,NULL); 
}
Esempio n. 6
0
static void
start_guile(void* closure, int argc, char **argv)
{
  scm_c_define_gsubr("get-scene-mgr",           0, 0, 0, script_ogre_get_scene_mgr);
  scm_c_define_gsubr("get-root-scene-node",     0, 0, 0, script_ogre_get_root_scene_node);
  scm_c_define_gsubr("create-light",            1, 0, 0, script_ogre_create_light);
  scm_c_define_gsubr("create-entity",           2, 0, 0, script_ogre_create_entity);
  scm_c_define_gsubr("create-child-scene-node", 2, 0, 0, script_ogre_create_child_scene_node);
  scm_c_define_gsubr("attach-object",           2, 0, 0, script_ogre_attach_object);
  scm_c_define_gsubr("set-position",            4, 0, 0, script_ogre_set_position);

   //scm_c_eval_string("(debug-set! stack 0)");
   //scm_c_eval_string("(use-modules (srfi srfi-1))");
   scm_c_define_gsubr("move", 4, 0, 0, script_move);

   init_gio();

   scm_c_eval_string("(load \"src_scm/db.scm\")");
   scm_c_eval_string("(load \"src_scm/graphics.scm\")");
   //scm_c_eval_string("(load \"src_scm/blend_format.scm\")");
   scm_c_eval_string("(load \"src_scm/ogre.scm\")");

  printf("\nSkomakare game engine...");
   /* TODO: replace this using scm_c_eval_string(). */
  /*while (1) {
    char* input = readline("\n$ ");
    //uint len = mylen(input);
    //printf("%i\n", len);
    //input[len-1] = '\0';
    //input = realloc(input, mylen(input) + 1);

    if (0 == strcmp(input, "q"))
      break;
    printf("%s", input);

    scm_c_eval_string(input));
    //printf("%s", scm_to_locale_string(scm_c_eval_string(input)));
  }*/
   scm_shell(argc, argv);
}
Esempio n. 7
0
static void
inner_main (void *closure, int argc, char **argv)
{
  /* module initializations would go here */
  scm_shell (argc, argv);
}
Esempio n. 8
0
static void
guile_shell (void *closure, int argc, char **argv)
{
	scm_shell (argc, argv);
}
Esempio n. 9
0
int main()
{
	scm_init_guile();
	scm_shell(0, NULL);
}
Esempio n. 10
0
void main_prog(void *closure, int argc, char *argv[])
{
    int i;
    int argv_index;
    char *cwd;
    gchar *str;
    gchar *filename;

    TOPLEVEL *pr_current;

    /* set default output filename */
    output_filename = g_strdup("output.net");

    argv_index = parse_commandline(argc, argv);
    cwd = g_get_current_dir();

    scm_set_program_arguments (argc, argv, NULL);

    /* this is a kludge to make sure that spice mode gets set */
    /*  Hacked by SDB to allow spice netlisters of arbitrary name
     *        as long as they begin with "spice".  For example, this spice
     *  netlister is valid: "spice-sdb".
     */
    if (guile_proc) {
        if (strncmp(guile_proc, "spice", 5) == 0) {
            netlist_mode = SPICE;
        }
    }

    libgeda_init();

    /* create log file right away */
    /* even if logging is enabled */
    s_log_init ("gnetlist");

    s_log_message("gEDA/gnetlist version %s%s.%s\n", PREPEND_VERSION_STRING,
                  PACKAGE_DOTTED_VERSION, PACKAGE_DATE_VERSION);
    s_log_message
        ("gEDA/gnetlist comes with ABSOLUTELY NO WARRANTY; see COPYING for more details.\n");
    s_log_message
        ("This is free software, and you are welcome to redistribute it under certain\n");
    s_log_message
        ("conditions; please see the COPYING file for more details.\n\n");

#if defined(__MINGW32__) && defined(DEBUG)
    fprintf(stderr, "This is the MINGW32 port.\n\n");
#endif

    /* register guile (scheme) functions */
    g_register_funcs();

    pr_current = s_toplevel_new ();

    /* Evaluate Scheme expressions that need to be run before rc files
     * are loaded. */
    scm_eval (pre_rc_list, scm_current_module ());

    g_rc_parse (pr_current, argv[0], "gnetlistrc", rc_filename);
    /* immediately setup user params */
    i_vars_set (pr_current);

    s_rename_init();

    if(list_backends) {
      gnetlist_backends(pr_current);
      exit (0);
    }

    /* Evaluate the first set of Scheme expressions before we load any
     * schematic files */
    scm_eval (pre_backend_list, scm_current_module ());

    i = argv_index;
    while (argv[i] != NULL) {
      GError *err = NULL;

      if (g_path_is_absolute(argv[i])) {
        /* Path is already absolute so no need to do any concat of cwd */
        filename = g_strdup (argv[i]);
      } else {
        filename = g_build_filename (cwd, argv[i], NULL);
      }

      if (!quiet_mode) {
        s_log_message ("Loading schematic [%s]\n", filename);
        printf ("Loading schematic [%s]\n", filename);
      }

      s_page_goto (pr_current, s_page_new (pr_current, filename));

      if (!f_open (pr_current, pr_current->page_current, filename, &err)) {
        g_warning ("%s\n", err->message);
        fprintf (stderr, "%s\n", err->message);
        g_error_free (err);
      }

      /* collect input filenames for backend use */
      input_files = g_slist_append(input_files, argv[i]);

      i++;
      g_free (filename);
    }

    /* Change back to the directory where we started.  This is done */
    /* since gnetlist is a command line utility and will deposit its output */
    /* in the current directory.  Having the output go to a different */
    /* directory will confuse the user (confused me, at first). */
    if (chdir (cwd)) {
      /* Error occured with chdir */
#warning FIME: What do we do?
    }
    /* free(cwd); - Defered; see below */

    if (argv[argv_index] == NULL) {
        fprintf (stderr, "ERROR: No schematics files specified for processing.\n");
        fprintf (stderr, "\nRun `%s --help' for more information.\n", argv[0]);
        exit (1);
    }

    g_set_project_current(pr_current);
#if DEBUG
    s_page_print_all(pr_current);
#endif

    /* Load basic gnetlist functions */
    scm_primitive_load_path (scm_from_utf8_string ("gnetlist.scm"));

    if (guile_proc) {
      SCM s_backend_path;

      /* Search for backend scm file in load path */
      str = g_strdup_printf("gnet-%s.scm", guile_proc);
      s_backend_path = scm_sys_search_load_path (scm_from_locale_string (str));
      g_free (str);

      /* If it couldn't be found, fail. */
      if (scm_is_false (s_backend_path)) {
        fprintf (stderr, "ERROR: Could not find backend `%s' in load path.\n",
                 guile_proc);
        fprintf (stderr,
                 "\nRun `%s --list-backends' for a full list of available backends.\n",
                 argv[0]);
        exit (1);
      }

      /* Load backend code. */
      scm_primitive_load (s_backend_path);

      /* Evaluate second set of Scheme expressions. */
      scm_eval (post_backend_list, scm_current_module ());
    }

    s_traverse_init();
    s_traverse_start(pr_current);

    /* Change back to the directory where we started AGAIN.  This is done */
    /* because the s_traverse functions can change the Current Working Directory. */
    if (chdir (cwd)) {
      /* Error occured with chdir */
#warning FIXME: What do we do?
    }
    g_free(cwd);

    /* Run post-traverse code. */
    scm_primitive_load_path (scm_from_utf8_string ("gnetlist-post.scm"));

    if (guile_proc) {
        /* check size here hack */
        str = g_strdup_printf ("(%s \"%s\")", guile_proc, output_filename);
        scm_c_eval_string (str);
        g_free (str);
        /* gh_eval_str_with_stack_saving_handler (input_str); */
    } else if (interactive_mode) {
        scm_c_eval_string ("(set-repl-prompt! \"gnetlist> \")");
        scm_shell (0, NULL);
    } else {
        fprintf(stderr,
                "You gave neither backend to execute nor interactive mode!\n");
    }

    gnetlist_quit();
}