Changeset 4039 for neercs


Ignore:
Timestamp:
Nov 25, 2009, 4:42:49 PM (10 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Replaced PyInit_neercs() by more convenient initNeercsModule()
  • get() now works as expected
Location:
neercs/trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • neercs/trunk/src/configuration.c

    r4038 r4039  
    480480char *get_window_manager(struct screen_list *screen_list)
    481481{
    482     debug("Window manager is %d\n", screen_list->wm_type);
     482    debug("Window manager is %d", screen_list->wm_type);
    483483    switch (screen_list->wm_type)
    484484    {
  • neercs/trunk/src/interpreter.c

    r4038 r4039  
    182182    Py_Initialize();
    183183   
    184     PyInit_neercs(sl);
     184    initNeercsModule(sl);
    185185   
    186186    return 0;
  • neercs/trunk/src/py_module.c

    r4038 r4039  
    3838
    3939/* FIXME : Find a way to pass a user pointer to PyModuleDef or something */
    40 struct screen_list *screen_list;
     40static struct screen_list *screen_list;
    4141
    42 static PyObject*
    43 neercs_get(PyObject *self, PyObject *args)
     42PyObject *PyInit_neercs(void);
     43
     44static PyObject *neercs_get(PyObject * self, PyObject * args)
    4445{
    4546    char *s = NULL;
    46    
    47     debug("Get using list at %p\n", screen_list);
    48    
    49     if(!PyArg_ParseTuple(args, "s", &s))
     47
     48    debug("Get using list at %p", screen_list);
     49
     50    if (!PyArg_ParseTuple(args, "s", &s))
    5051    {
    51         debug("py Can't parse\n");
     52        debug("py Can't parse");
    5253        return NULL;
    5354    }
    54     debug("py Argument : '%s'\n", s);
     55    debug("py Argument : '%s'", s);
    5556    struct config_line *c = get_config(s);
    56     debug("py config %p\n");
    57    
    58     if(c)
    59         return Py_BuildValue("s", c->get(screen_list));
    60     else 
     57    debug("py config %p");
     58
     59    if (c)
     60        return Py_BuildValue("s", c->get(screen_list));
     61    else
    6162        return Py_BuildValue("s", "Invalid");
    6263
    6364}
    6465
    65 static PyObject*
    66 neercs_version(PyObject *self, PyObject *args)
     66static PyObject *neercs_version(PyObject * self, PyObject * args)
    6767{
    68     if(!PyArg_ParseTuple(args, ":version"))
     68    if (!PyArg_ParseTuple(args, ":version"))
    6969        return NULL;
    7070    return Py_BuildValue("s", PACKAGE_VERSION);
     
    7272
    7373static PyMethodDef NeercsMethods[] = {
    74     {"version", neercs_version, METH_VARARGS,  "Return the neercs version."},
    75     {"get", neercs_get, METH_VARARGS,  "Return the specified variable's value."},
     74    {"version", neercs_version, METH_VARARGS, "Return the neercs version."},
     75    {"get", neercs_get, METH_VARARGS,
     76     "Return the specified variable's value."},
    7677    {NULL, NULL, 0, NULL}
    7778};
     
    8283};
    8384
    84 PyObject* PyInit_neercs(struct screen_list* sl)
     85PyObject *PyInit_neercs(void)
    8586{
    86     screen_list = sl;
    87     PyObject* o =  PyModule_Create(&NeercsModule);
     87    PyObject *o = PyModule_Create(&NeercsModule);
    8888    PyImport_AppendInittab("neercs", &PyInit_neercs);
    8989    return o;
    9090}
    9191
    92 
     92void initNeercsModule(struct screen_list *sl)
     93{
     94    screen_list = sl;
     95        PyInit_neercs();
     96}
    9397
    9498
  • neercs/trunk/src/py_module.h

    r4038 r4039  
    2020#include "neercs.h"
    2121
    22 PyObject* PyInit_neercs(struct screen_list* sl);
     22void initNeercsModule(struct screen_list *sl);
    2323
    2424
Note: See TracChangeset for help on using the changeset viewer.