X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=src%2Fgacela.c;h=b9be602a9d6775897f6a89e3f1b8e8854892af64;hb=5287ad5ca5431fe53c61e2da81b1ac6d0dc6e119;hp=14a318f444743332ccf6b3913fe6096c3f1b346f;hpb=34d7fb9e3b5125539be506237fbe41854ed174bd;p=gacela.git diff --git a/src/gacela.c b/src/gacela.c index 14a318f..b9be602 100644 --- a/src/gacela.c +++ b/src/gacela.c @@ -22,45 +22,39 @@ #include "gacela_FTGL.h" static void* -register_functions (void* data) +init_gacela (void *data, int argc, char **argv) { + // Guile configuration + scm_c_eval_string ("(set-repl-prompt! \"gacela>\")"); + scm_c_eval_string ("(use-modules (ice-9 readline))"); + scm_c_eval_string ("(activate-readline)"); + scm_c_eval_string ("(use-modules (ice-9 optargs))"); + scm_c_eval_string ("(use-modules (ice-9 receive))"); + scm_c_eval_string ("(use-modules (ice-9 threads))"); + scm_c_eval_string ("(read-enable 'case-insensitive)"); + + // Bindings for C functions and structs SDL_register_functions (NULL); GL_register_functions (NULL); FTGL_register_functions (NULL); - return NULL; -} -void -load_scheme_file (char *path, char *filename) -{ - char fn[strlen (path) + 1024]; - - strcpy (fn, path); - strcat (fn, "/"); - strcat (fn, filename); - - scm_c_primitive_load (fn); + return NULL; } void load_scheme_files (char *path) { - load_scheme_file (path, "gacela.scm"); - load_scheme_file (path, "gacela_events.scm"); - load_scheme_file (path, "gacela_draw.scm"); - load_scheme_file (path, "gacela_ttf.scm"); + char load_path[strlen (path) + 1024]; + + sprintf (load_path, "(set! %%load-path (cons \"%s\" %%load-path))", path); + scm_c_eval_string (load_path); + scm_primitive_load_path (scm_from_locale_string ("gacela_loader.scm")); } int main (int argc, char *argv[]) { - scm_with_guile (®ister_functions, NULL); - scm_init_guile (); - scm_c_eval_string ("(set-repl-prompt! \"gacela>\")"); - scm_c_eval_string ("(use-modules (ice-9 readline))"); - scm_c_eval_string ("(activate-readline)"); - scm_c_eval_string ("(use-modules (ice-9 optargs))"); - scm_c_eval_string ("(use-modules (ice-9 receive))"); + scm_with_guile (&init_gacela, NULL); load_scheme_files (dirname (argv[0])); scm_shell (argc, argv); }