medit/moo/moopython/mooutils-mod.c

56 lines
1.3 KiB
C
Raw Normal View History

2005-06-22 11:20:32 -07:00
/*
2005-11-06 19:19:25 -08:00
* moopython/mooutils-mod.c
2005-06-22 11:20:32 -07:00
*
* Copyright (C) 2004-2005 by Yevgen Muntyan <muntyan@math.tamu.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* See COPYING file that comes with this distribution.
*/
#include <Python.h>
#define NO_IMPORT_PYGOBJECT
#include <pygobject.h>
#include <glib.h>
2005-11-06 19:19:25 -08:00
#include "moopython/moo-pygtk.h"
#include "moopython/mooutils-mod.h"
2005-06-22 11:20:32 -07:00
2005-11-06 19:19:25 -08:00
static char *moo_utils_module_doc = (char*)"_moo_utils module.";
2005-06-22 11:20:32 -07:00
2005-11-06 19:19:25 -08:00
gboolean
_moo_utils_mod_init (void)
{
PyObject *mod;
2005-06-22 11:20:32 -07:00
2005-11-06 19:19:25 -08:00
mod = Py_InitModule3 ((char*) "_moo_utils", _moo_utils_functions, moo_utils_module_doc);
2005-06-22 11:20:32 -07:00
2005-11-06 19:19:25 -08:00
if (!mod)
return FALSE;
2005-06-22 11:20:32 -07:00
2005-11-06 19:19:25 -08:00
_moo_utils_add_constants (mod, "MOO_");
_moo_utils_register_classes (PyModule_GetDict (mod));
if (!PyErr_Occurred ())
{
PyObject *fake_mod, *code;
code = Py_CompileString (MOO_UTILS_PY, "moo/utils.py", Py_file_input);
if (!code)
return FALSE;
fake_mod = PyImport_ExecCodeModule ((char*) "moo_utils", code);
Py_DECREF (code);
2005-06-22 11:20:32 -07:00
2005-11-06 19:19:25 -08:00
if (!fake_mod)
PyErr_Print ();
}
2005-06-22 11:20:32 -07:00
2005-11-06 19:19:25 -08:00
return PyErr_Occurred () == NULL;
2005-06-22 11:20:32 -07:00
}