void _initialize_guile (void) { char *msg; install_gdb_commands (); #if HAVE_GUILE /* The Python support puts the C side in module "_gdb", leaving the Python side to define module "gdb" which imports "_gdb". There is evidently no similar convention in Guile so we skip this. */ /* scm_with_guile is the most portable way to initialize Guile. Plus we need to initialize the Guile support while in Guile mode (e.g., called from within a call to scm_with_guile). */ scm_with_guile (call_initialize_gdb_module, NULL); /* Set Guile's backtrace to match the "set guile print-stack" default. [N.B. The two settings are still separate.] But only do this after we've initialized Guile, it's nice to see a backtrace if there's an error during initialization. OTOH, if the error is that gdb/init.scm wasn't found because gdb is being run from the build tree, the backtrace is more noise than signal. Sigh. */ gdbscm_set_backtrace (0); #endif }
static int tortoise_guile_main(int argc, char *argv[]) { scm_with_guile(®ister_functions, NULL); scm_shell(argc, argv); return 0; }
int main (int argc, char *argv[]) { scm_with_guile (do_start, NULL); return 0; }
SCM guihckGuileRunExpression(guihckContext* ctx, SCM expression) { threadLocalContext.ctx = ctx; threadLocalContext.ctxRefs += 1; SCM result = scm_with_guile(runExpressionInGuile, expression); #if 0 if(result) { char* resultStr = scm_to_utf8_string(scm_object_to_string(result, SCM_UNDEFINED)); printf("RESULT: %s\n", resultStr); free(resultStr); } else { printf("RESULT: NULL\n"); } #endif threadLocalContext.ctxRefs -= 1; if(threadLocalContext.ctxRefs <= 0) { threadLocalContext.ctx = NULL; threadLocalContext.ctxRefs = 0; } return result; }
/*! \brief Initialise the Scheme API. * \ingroup guile_c_iface * \par Function Description * Registers all modules, procedures and variables exported by the * libgeda Scheme API. */ void edascm_init () { if (g_once_init_enter (&init_called)) { scm_with_guile (edascm_init_impl, NULL); g_once_init_leave (&init_called, 1); } }
static void go_deeper_into_the_stack (unsigned level) { /* The assumption is that the compiler is not smart enough to optimize this out. */ if (level > 0) go_deeper_into_the_stack (level - 1); else scm_with_guile (entry_point, NULL); }
int main (int argc, char *argv[]) { /* Invoke `scm_with_guile ()' from someplace deep into the stack. */ go_deeper_into_the_stack (100); /* Invoke it from much higher into the stack. This time, Guile is expected to update the `base' field of the current thread. */ scm_with_guile (entry_point, NULL); return 0; }
static PyObject *eval_string(PyObject *self, PyObject *args, PyObject *kwds) { PyObject *string_arg = NULL; static char *kwlist[] = { "string", NULL }; if (!PyArg_ParseTupleAndKeywords( args, kwds, "O!:eval_string", kwlist, &PyString_Type, &string_arg)) return NULL; PyObject *result = scm_with_guile( (void *(*)(void *))eval_string_wrapper, string_arg); if (result == NULL && !PyErr_Occurred()) PyErr_SetNone(guile_error); return result; }
static PyObject *lookup(PyObject *self, PyObject *args, PyObject *kwds) { const char *name_arg = NULL; static char *kwlist[] = { "name", NULL }; if (!PyArg_ParseTupleAndKeywords( args, kwds, "s:lookup", kwlist, &name_arg)) return NULL; PyObject *result = scm_with_guile( (void *(*)(void *))lookup_wrapper, (void *)name_arg); if (result == NULL && !PyErr_Occurred()) { PyErr_SetNone(guile_error); return NULL; } return result; }
static PyObject *define(PyObject *self, PyObject *args, PyObject *kwds) { const char *name_arg = NULL; PyObject *value_arg = NULL; static char *kwlist[] = { "name", "value", NULL }; if (!PyArg_ParseTupleAndKeywords( args, kwds, "sO:define", kwlist, &name_arg, &value_arg)) return NULL; struct define_data data = { name_arg, value_arg }; if (scm_with_guile((void *(*)(void *))define_wrapper, &data) == NULL) { PyErr_SetNone(guile_error); return NULL; } Py_INCREF(Py_None); return Py_None; }
SCM gdbscm_call_guile (SCM (*func) (void *), void *data, excp_matcher_func *ok_excps) { struct with_catch_data catch_data; catch_data.func = func; catch_data.data = data; catch_data.unwind_handler = scscm_recording_unwind_handler; catch_data.pre_unwind_handler = scscm_recording_pre_unwind_handler; catch_data.excp_matcher = ok_excps; catch_data.stack = SCM_BOOL_F; catch_data.catch_result = SCM_UNSPECIFIED; #if 0 scm_c_with_continuation_barrier (gdbscm_with_catch, &catch_data); #else scm_with_guile (gdbscm_with_catch, &catch_data); #endif return catch_data.catch_result; }
void _initialize_guile (void) { char *msg; install_gdb_commands (); #if HAVE_GUILE /* The Python support puts the C side in module "_gdb", leaving the Python side to define module "gdb" which imports "_gdb". There is evidently no similar convention in Guile so we skip this. */ /* PR 17185 There are problems with using libgc 7.4.0. Copy over the workaround Guile uses (Guile is working around a different problem, but the workaround is the same). */ #if (GC_VERSION_MAJOR == 7 && GC_VERSION_MINOR == 4 && GC_VERSION_MICRO == 0) /* The bug is only known to appear with pthreads. We assume any system using pthreads also uses setenv (and not putenv). That is why we don't have a similar call to putenv here. */ #if defined (HAVE_SETENV) setenv ("GC_MARKERS", "1", 1); #endif #endif /* scm_with_guile is the most portable way to initialize Guile. Plus we need to initialize the Guile support while in Guile mode (e.g., called from within a call to scm_with_guile). */ scm_with_guile (call_initialize_gdb_module, NULL); /* Set Guile's backtrace to match the "set guile print-stack" default. [N.B. The two settings are still separate.] But only do this after we've initialized Guile, it's nice to see a backtrace if there's an error during initialization. OTOH, if the error is that gdb/init.scm wasn't found because gdb is being run from the build tree, the backtrace is more noise than signal. Sigh. */ gdbscm_set_backtrace (0); #endif }
void * gdbscm_with_guile (void *(*func) (void *), void *data) { struct c_data c_data; struct with_catch_data catch_data; c_data.func = func; c_data.data = data; /* Set this now in case an exception is thrown. */ c_data.result = _("Error while executing Scheme code."); catch_data.func = scscm_safe_call_body; catch_data.data = &c_data; catch_data.unwind_handler = scscm_nop_unwind_handler; catch_data.pre_unwind_handler = scscm_printing_pre_unwind_handler; catch_data.excp_matcher = NULL; catch_data.stack = SCM_BOOL_F; catch_data.catch_result = SCM_UNSPECIFIED; scm_with_guile (gdbscm_with_catch, &catch_data); return c_data.result; }
void inner_main(void *nop, int argc, char** argv) { Config_t config; // Parse the command line arguments and store into config config = get_config(argc, argv); if (config.help) { printf("%s", USAGE_STRING); return; } // Load board and ruleset into 'world' if (world_init(&world_g, config)) { return; } // Register C primitive functions for Scheme scm_with_guile(®ister_scm_functions, NULL); // Enter main loop if (config.graphical) { main_glfw(&world_g, config.sleep_time * 1000, config.fullscreen); } else { main_curses(&world_g, config.sleep_time * 1000); } world_destroy(&world_g); }
static PyObject *load(PyObject *self, PyObject *args, PyObject *kwds) { PyObject *name_arg = NULL; static char *kwlist[] = { "name", NULL }; if (!PyArg_ParseTupleAndKeywords( args, kwds, "O:load", kwlist, &name_arg)) return NULL; if (!PyString_Check(name_arg) && !PyUnicode_Check(name_arg)) { char buf[BUFSIZ]; snprintf(buf, BUFSIZ, "load() argument 1 must be " "str or unicode, not %s", name_arg->ob_type->tp_name); PyErr_SetString(PyExc_TypeError, buf); return NULL; } PyObject *result = scm_with_guile( (void *(*)(void *))load_wrapper, name_arg); if (result == NULL && !PyErr_Occurred()) PyErr_SetNone(guile_error); return result; }
void guihckGuileRegisterFunction(const char* name, int req, int opt, int rst, scm_t_subr func) { _functionDefinition fd = {name, req, opt, rst, func}; scm_with_guile(registerFunction, &fd); }
void guihckGuileInit() { assert(sizeof(guihckElementId) <= sizeof(scm_t_uint64) && "guihckElementId type is larger than uint64!"); scm_with_guile(initGuile, NULL); }
static void *doomer_thread(void *data) { return scm_with_guile(doomer_thread_, data); }
static void* run_finalization_thread (void *arg) { return scm_with_guile (finalization_thread_proc, arg); }
int main(int argc, char* argv[]) { (void)scm_with_guile(bootstrap_main, NULL); return 0; }
void GuileTypes_registerAll() { scm_with_guile(GuileTypes_guile_registerAll, NULL); }