Example #1
0
void
init_wrapper (void)
{
  Py_Initialize();
  if (atexit(Py_Finalize)) {
    fprintf(stderr,"cannot set Python finalization function\n");  // NOT COVERED BY TESTS
    exit(1);  // NOT COVERED BY TESTS
  }
  initpyscm();

  init_pysmob_type();
  init_g2p2g_smob_type();

  // The following must happen after init_g2p2g_smob_type().
  init_default_guiletopy_templates();

  SCM s_default_g2p = scm_variable_ref(scm_c_lookup("guile2python"));
  sargtemplate_default = scm_permanent_object(scm_list_2(scm_variable_ref(scm_c_lookup("g2p_list2Tuple")),s_default_g2p));
  skwtemplate_default = SCM_UNDEFINED; // guileassoc2pythondict will choose the right default.
  srestemplate_default = scm_permanent_object(scm_variable_ref(scm_c_lookup("python2guile")));

  scm_c_define_gsubr ("python-eval",1,1,0,python_eval);
  scm_c_define_gsubr ("python-apply",3,3,0,python_apply);
  scm_c_define_gsubr ("python-import",1,0,0,python_import);
  scm_c_define_gsubr ("pyguile-verbosity-set!",1,0,0,pyguile_verbosity_set);
  scm_c_define_gsubr ("pyguile-version",0,0,0,pyguile_version);
}
Example #2
0
void
gram_keydown_hook_init (void)
{
  gram_keydown_hook =
    scm_permanent_object (scm_make_hook (scm_from_unsigned_integer (2)));
  gram_keydown_hook_object =
    scm_permanent_object (scm_c_define ("keydown-hook", gram_keydown_hook));
  scm_c_export ("keydown-hook", NULL);
}
Example #3
0
void
gram_view_focus_hook_init (void)
{
  gram_view_focus_hook =
    scm_permanent_object (scm_make_hook (scm_from_unsigned_integer (2)));
  gram_view_focus_hook_object =
    scm_permanent_object (scm_c_define
                          ("view-focus-hook", gram_view_focus_hook));
  scm_c_export ("view-focus-hook", NULL);
}
Example #4
0
void
gram_output_created_hook_init (void)
{
  gram_output_created_hook =
    scm_permanent_object (scm_make_hook (scm_from_unsigned_integer (1)));
  gram_output_created_hook_object =
    scm_permanent_object (scm_c_define
                          ("output-created-hook", gram_output_created_hook));
  scm_c_export ("output-created-hook", NULL);
}
Example #5
0
void
gram_compositor_ready_hook_init (void)
{
  gram_compositor_ready_hook =
    scm_permanent_object (scm_make_hook (scm_from_unsigned_integer (0)));
  gram_compositor_ready_hook_object =
    scm_permanent_object (scm_c_define
                          ("compositor-ready-hook",
                           gram_compositor_ready_hook));
  scm_c_export ("compositor-ready-hook", NULL);
}
Example #6
0
/*! \brief Define a hook.
 * \par Function Description
 * Creates a Guile new hook with \a n_args arguments, and binds it to
 * the variable \a name, returning the newly created hook.
 *
 * \param n_args Number of arguments the hook should take.
 * \param name   Name of variable to bind the hook to.
 *
 * \return the newly-created hook.
 */
static SCM
create_hook (const char *name, int n_args)
{
  SCM hook = scm_make_hook (scm_from_int (n_args));
  scm_c_define (name, hook);
  return scm_permanent_object (hook);
}
Example #7
0
static void init_env(void) {
	SCM smob;
	char *ver;
	SOURCE_HANDLE *handle;
	init_log();
	init_alsa_module();
	ver = scm_to_locale_string(scm_version());
	log_msg("Guile version %s\n", ver);
	free(ver);
	init_messaging(msg_port);
	init_time();
	init_json();
	init_scheduler();
	init_audiofile();
	if (use_jack) init_jackport();
	init_feeds();
	init_recorder();
	init_stream();
	init_source_mod();
	init_ladspa();
	init_unitgen();
	fader = (SOURCE_OBJ *)my_malloc(sizeof(SOURCE_OBJ), "main fader");
	handle = (SOURCE_HANDLE *)my_gc_malloc(sizeof(SOURCE_HANDLE), "mains",
				"mains");
	handle->body = (void *)fader;
	handle->src = fader;
	init_source(fader);
	mains_tag = scm_make_smob_type("mains", sizeof(SOURCE_OBJ));
	SCM_NEWSMOB(smob, mains_tag, handle);
	scm_c_define("mains", smob);
	if (use_jack) {
		scm_c_define("jack-client-name",
			scm_from_locale_string(client_name));
		scm_c_define_gsubr("patch-out", 2, 0, 0, patch_out);
		scm_c_define_gsubr("unpatch-out", 2, 0, 0, unpatch_out);
		}
	scm_c_define_gsubr("quit", 0, 0, 0, qmx_quit);
	scm_c_define_gsubr("db", 1, 0, 0, db20);
	scm_c_define_gsubr("period-duty-cycle", 0, 0, 0, get_duty_cycle);
	scm_permanent_object(console_display =
			scm_c_eval_string(console_display_src));
	scm_permanent_object(catch_display =
			scm_c_eval_string(catch_display_src));
	return;
	}
Example #8
0
void init_cache(void) {
	make_node_tag = scm_make_smob_type("make-node", sizeof(MAKE_NODE));
	scm_set_smob_free(make_node_tag, free_node);
	scm_set_smob_mark(make_node_tag, mark_node);
	deflate_tag = scm_make_smob_type("gzip-blob", sizeof(DEFLATE_BLOB));
	sessions_db = scm_from_locale_string("sessions");
	scm_gc_protect_object(sessions_db);
	scm_permanent_object(file_sym = scm_from_utf8_symbol("file"));
	scm_permanent_object(data_sym = scm_from_utf8_symbol("data"));
	scm_permanent_object(stamp_sym = scm_from_utf8_symbol("stamp"));
	scm_c_define_gsubr("make-doc", 2, 0, 0, make_doc);
	scm_c_define_gsubr("touch-doc", 1, 0, 1, touch_node);
	scm_c_define_gsubr("fetch-doc", 1, 0, 1, fetch_node);
	scm_c_define_gsubr("touched-doc?", 1, 0, 0, touched_node);
	scm_c_define_gsubr("gzip", 1, 0, 0, gzip);
	scm_c_define_gsubr("zdeflate", 1, 0, 0, zdeflate);
	scm_c_define_gsubr("zdeflate-size", 1, 0, 0, deflate_size);
	scm_c_define_gsubr("zdeflate?", 1, 0, 0, is_gzip);
	scm_c_define_gsubr("zinflate", 1, 0, 0, gunzip);
	log_msg("zlib version %s\n", zlibVersion());
	}
Example #9
0
SWIGINTERN SCM
SWIG_Guile_Init ()
{
  static SCM swig_module;
  
  if (swig_initialized) return swig_module;
  swig_initialized = 1;

  swig_module = scm_c_resolve_module("Swig swigrun");
  if (ensure_smob_tag(swig_module, &swig_tag,
		      "swig-pointer", "swig-pointer-tag")) {
    scm_set_smob_print(swig_tag, print_swig);
    scm_set_smob_equalp(swig_tag, equalp_swig);
  }
  if (ensure_smob_tag(swig_module, &swig_collectable_tag,
		      "collectable-swig-pointer", "collectable-swig-pointer-tag")) {
    scm_set_smob_print(swig_collectable_tag, print_collectable_swig);
    scm_set_smob_equalp(swig_collectable_tag, equalp_swig);
    scm_set_smob_free(swig_collectable_tag, free_swig);
  }
  if (ensure_smob_tag(swig_module, &swig_destroyed_tag,
		      "destroyed-swig-pointer", "destroyed-swig-pointer-tag")) {
    scm_set_smob_print(swig_destroyed_tag, print_destroyed_swig);
    scm_set_smob_equalp(swig_destroyed_tag, equalp_swig);
  }
  if (ensure_smob_tag(swig_module, &swig_member_function_tag,
		      "swig-member-function-pointer", "swig-member-function-pointer-tag")) {
    scm_set_smob_print(swig_member_function_tag, print_member_function_swig);
    scm_set_smob_free(swig_member_function_tag, free_swig_member_function);
  }
  swig_make_func = scm_permanent_object(
    scm_variable_ref(scm_c_module_lookup(scm_c_resolve_module("oop goops"), "make")));
  swig_keyword = scm_permanent_object(scm_from_locale_keyword((char*) "init-smob"));
  swig_symbol = scm_permanent_object(scm_from_locale_symbol("swig-smob"));
#ifdef SWIG_INIT_RUNTIME_MODULE
  SWIG_INIT_RUNTIME_MODULE
#endif

  return swig_module;
}
Example #10
0
PyMODINIT_FUNC
initpyscm(void)
{
  PyObject *m;

  /*pyscm_PySCMType.tp_new = PyType_GenericNew;*/
  if (PyType_Ready(&pyscm_PySCMType) < 0) {
    return;  // NOT COVERED BY TESTS
  }

  /* Create the module and add the functions */
  m = Py_InitModule4("pyscm", pyscm_methods,
		     pyscm_module_documentation,
		     (PyObject*)NULL,PYTHON_API_VERSION);
  if (NULL == m) {
    return;  // NOT COVERED BY TESTS
  }

  Py_INCREF(&pyscm_PySCMType);
  PyModule_AddObject(m, "PySCM", (PyObject *)&pyscm_PySCMType);

  /* Add some symbolic constants to the module */
  //PyObject *d;
  //d = PyModule_GetDict(m);
  //ErrorObject = PyString_FromString("pyscm.error");
  //PyDict_SetItemString(d, "error", ErrorObject);

  /* Add constants here */
  // Currently, none is needed.

  /* Check for errors */
  if (PyErr_Occurred()) {
    Py_FatalError("can't initialize module pyscm");  // NOT COVERED BY TESTS
  }

  // This part initializes the Guile data structures needed
  // by this module.
  pyscm_registration_hash = scm_permanent_object(scm_c_make_hash_table(65537));
  pyscm_registration_index = 0;
}
Example #11
0
/*
 * FIXME: If we clean up at exit, removing the registered functions, we get
 * rid of the 'Leaking string [Guile] with ref_count=1' warnings. The way we
 * do this for other plugins, including Python, we deactivate the
 * plugin. However, it is not possible to finalize Guile.
 */
static SCM
scm_register_function (SCM scm_name, SCM scm_args, SCM scm_help, SCM scm_category, SCM scm_function)
{
	GnmFunc *fndef;
	GnmFuncGroup   *cat;
	GnmFuncDescriptor    desc;
	char     *help;

	SCM_ASSERT (SCM_NIMP (scm_name) && SCM_STRINGP (scm_name), scm_name, SCM_ARG1, "scm_register_function");
	SCM_ASSERT (SCM_NIMP (scm_args) && SCM_STRINGP (scm_args), scm_args, SCM_ARG2, "scm_register_function");
	SCM_ASSERT (SCM_NIMP (scm_help) && SCM_STRINGP (scm_help), scm_help, SCM_ARG3, "scm_register_function");
	SCM_ASSERT (SCM_NIMP (scm_category) && SCM_STRINGP (scm_category),
		    scm_category, SCM_ARG4, "scm_register_function");
	SCM_ASSERT (scm_procedure_p (scm_function), scm_function, SCM_ARG5, "scm_register_function");

	scm_permanent_object (scm_function);

	desc.name	= g_strdup (SCM_CHARS (scm_name));
	desc.arg_spec	= g_strdup (SCM_CHARS (scm_args));
	desc.arg_names	= NULL;
	help            = g_strdup (SCM_CHARS (scm_help));
	desc.help       = &help;
	desc.fn_args    = func_marshal_func;
	desc.fn_nodes   = NULL;
	desc.linker     = NULL;
	desc.unlinker   = NULL;
	desc.flags      = 0;
	desc.ref_notify = NULL;
	desc.impl_status = GNM_FUNC_IMPL_STATUS_UNIQUE_TO_GNUMERIC;
	desc.test_status = GNM_FUNC_TEST_STATUS_UNKNOWN;

	cat = gnm_func_group_fetch (SCM_CHARS (scm_category), NULL);
	fndef = gnm_func_add (cat, &desc, NULL);

	gnm_func_set_user_data (fndef, GINT_TO_POINTER (scm_function));

	return SCM_UNSPECIFIED;
}