medit/moo/mooutils/moopython.h

157 lines
6.1 KiB
C
Raw Normal View History

/*
2007-06-24 10:56:20 -07:00
* moopython.h
*
2007-06-24 10:56:20 -07:00
* Copyright (C) 2004-2007 by Yevgen Muntyan <muntyan@math.tamu.edu>
*
2007-06-24 10:56:20 -07:00
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* See COPYING file that comes with this distribution.
*/
#ifndef MOO_PYTHON_H
#define MOO_PYTHON_H
#include <glib.h>
G_BEGIN_DECLS
2007-05-22 21:59:55 -07:00
#define MOO_PY_API_VERSION 94
typedef struct _MooPyAPI MooPyAPI;
typedef struct _MooPyObject MooPyObject;
2006-11-19 22:58:10 -08:00
typedef struct _MooPyMethodDef MooPyMethodDef;
2006-11-19 22:58:10 -08:00
typedef MooPyObject* (*MooPyCFunction) (MooPyObject*, MooPyObject*);
enum {
MOO_PY_METH_VARARGS = 1 << 0,
MOO_PY_METH_KEYWORDS = 1 << 1,
MOO_PY_METH_NOARGS = 1 << 2,
MOO_PY_METH_O = 1 << 3,
MOO_PY_METH_CLASS = 1 << 4,
MOO_PY_METH_STATIC = 1 << 5
};
2007-05-22 21:59:55 -07:00
enum {
MOO_PY_RUNTIME_ERROR,
MOO_PY_TYPE_ERROR,
MOO_PY_VALUE_ERROR,
MOO_PY_NOT_IMPLEMENTED_ERROR
};
2006-11-19 22:58:10 -08:00
struct _MooPyMethodDef {
const char *ml_name;
MooPyCFunction ml_meth;
int ml_flags;
const char *ml_doc;
};
struct _MooPyAPI {
2006-11-19 22:58:10 -08:00
MooPyObject *py_none;
MooPyObject *py_true;
MooPyObject *py_false;
MooPyObject* (*incref) (MooPyObject *obj);
void (*decref) (MooPyObject *obj);
char* (*get_info) (void);
MooPyObject* (*run_simple_string) (const char *str);
MooPyObject* (*run_string) (const char *str,
2006-12-05 00:54:39 -08:00
MooPyObject *globals,
MooPyObject *locals);
2006-11-19 22:58:10 -08:00
MooPyObject* (*run_file) (void *fp,
2006-12-05 00:54:39 -08:00
const char *filename,
MooPyObject *globals,
MooPyObject *locals);
2006-11-19 22:58:10 -08:00
MooPyObject* (*run_code) (const char *str,
2006-12-05 00:54:39 -08:00
MooPyObject *globals,
MooPyObject *locals);
MooPyObject* (*create_script_dict) (const char *name);
2006-11-19 22:58:10 -08:00
MooPyObject* (*py_object_from_gobject) (gpointer gobj);
2006-12-05 00:54:39 -08:00
gpointer (*gobject_from_py_object) (MooPyObject *pyobj);
2006-11-19 22:58:10 -08:00
MooPyObject* (*dict_get_item) (MooPyObject *dict,
const char *key);
gboolean (*dict_set_item) (MooPyObject *dict,
const char *key,
MooPyObject *val);
gboolean (*dict_del_item) (MooPyObject *dict,
const char *key);
MooPyObject* (*import_exec) (const char *name,
const char *string);
2007-05-22 21:59:55 -07:00
void (*set_error) (int type,
const char *format,
...);
2006-11-19 22:58:10 -08:00
void (*py_err_print) (void);
MooPyObject* (*py_object_call_method) (MooPyObject *object,
const char *method,
const char *format,
...);
MooPyObject* (*py_object_call_function) (MooPyObject *callable,
const char *format,
...);
MooPyObject* (*py_c_function_new) (MooPyMethodDef *meth,
MooPyObject *self);
int (*py_module_add_object) (MooPyObject *mod,
const char *name,
MooPyObject *obj);
gboolean (*py_arg_parse_tuple) (MooPyObject *args,
const char *format,
...);
GSList *_free_list;
};
extern MooPyAPI *moo_py_api;
2006-11-19 22:58:10 -08:00
gboolean moo_python_init (guint version,
MooPyAPI *api);
2006-11-19 22:58:10 -08:00
void moo_python_add_data (gpointer data,
GDestroyNotify destroy);
2006-11-19 22:58:10 -08:00
MooPyObject *moo_Py_INCREF (MooPyObject *obj);
void moo_Py_DECREF (MooPyObject *obj);
#define moo_python_running() (moo_py_api != NULL)
2006-03-15 13:21:48 -08:00
#define moo_python_get_info moo_py_api->get_info
2006-03-14 12:59:07 -08:00
#define moo_python_run_simple_string moo_py_api->run_simple_string
#define moo_python_run_string moo_py_api->run_string
#define moo_python_run_file moo_py_api->run_file
2006-10-22 13:32:12 -07:00
#define moo_python_run_code moo_py_api->run_code
2006-12-05 00:54:39 -08:00
#define moo_python_create_script_dict moo_py_api->create_script_dict
2006-03-14 12:59:07 -08:00
#define moo_py_dict_get_item moo_py_api->dict_get_item
#define moo_py_dict_set_item moo_py_api->dict_set_item
#define moo_py_dict_del_item moo_py_api->dict_del_item
2006-10-22 13:32:12 -07:00
#define moo_py_import_exec moo_py_api->import_exec
2006-03-14 12:59:07 -08:00
#define moo_py_object_from_gobject moo_py_api->py_object_from_gobject
2006-12-05 00:54:39 -08:00
#define moo_gobject_from_py_object moo_py_api->gobject_from_py_object
2007-05-22 21:59:55 -07:00
#define moo_py_set_error moo_py_api->set_error
2006-11-19 22:58:10 -08:00
#define moo_PyErr_Print moo_py_api->py_err_print
#define moo_PyObject_CallMethod moo_py_api->py_object_call_method
#define moo_PyObject_CallFunction moo_py_api->py_object_call_function
#define moo_PyCFunction_New moo_py_api->py_c_function_new
#define moo_PyModule_AddObject moo_py_api->py_module_add_object
#define moo_PyArg_ParseTuple moo_py_api->py_arg_parse_tuple
#define moo_Py_None moo_py_api->py_none
#define moo_Py_True moo_py_api->py_true
#define moo_Py_False moo_py_api->py_false
G_END_DECLS
#endif /* MOO_PYTHON_H */