Changeset 184

Show
Ignore:
Timestamp:
08/27/07 23:29:29 (15 months ago)
Author:
zany
Message:

adding python callbacks

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/swig/client.i

    r175 r184  
    4848#if defined SWIGPERL 
    4949#elif defined SWIGPYTHON 
    50 /* http://www.swig.org/Doc1.1/HTML/Python.html#n11 */ 
     50%typemap(in) (obexftp_info_cb_t infocb, void *user_data) { 
     51        if (!PyCallable_Check($input)) { 
     52                /* should raise an exception here */ 
     53                $1 = NULL; 
     54                $2 = NULL; 
     55        } else { 
     56                Py_XINCREF($input); 
     57                $1 = proxy_info_cb; 
     58                $2 = $input; 
     59        } 
     60}; 
     61%{ 
     62static void proxy_info_cb (int evt, const char *buf, int len, void *data) { 
     63        PyObject *proc = (PyObject *)data; 
     64        /* PyObject *msg = PyString_FromStringAndSize(buf, len); */ 
     65        PyObject_CallFunction(proc, "is", evt, buf); 
     66} 
     67%}  
    5168#elif defined SWIGRUBY 
    5269%typemap(in) (obexftp_info_cb_t infocb, void *user_data) {