Navigation



Ignore:
Timestamp:
Dec 20, 2010, 7:36:40 PM (13 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

dbg_interactive almost complete

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/dbg_interactive/dbg_interactive.i

    r638 r640  
    6868static int wrapper_errno;
    6969static PyObject* wrapper_errno_py;
    70 static char * wrapper_error_txt; /* if NULL, use strerror(errno) */
     70static const char * wrapper_error_txt; /* if NULL, use strerror(errno) */
    7171#define DI_ERROR(code, pycode, str) {   \
    7272        fd_log_debug("[dbg_interactive] ERROR: %s: %s\n", __PRETTY_FUNCTION__, str ? str : strerror(code)); \
     
    8888        /* Now, test for error */
    8989        if (wrapper_errno) {
    90                 char * str = wrapper_error_txt ? wrapper_error_txt : strerror(wrapper_errno);
     90                const char * str = wrapper_error_txt ? wrapper_error_txt : strerror(wrapper_errno);
    9191                PyObject * exc = wrapper_errno_py;
    9292                if (!exc) {
     
    109109 ***********************************/
    110110
    111 %apply (char *STRING, size_t LENGTH) { ( char * string, size_t len ) }; /* fd_hash */
     111%apply (char *STRING, size_t LENGTH) { ( char * string, size_t len ) };
    112112
    113113/* Generic typemap for functions that create something */
     
    119119}
    120120
     121/* Typemap to return a boolean value as output parameter */
     122%typemap(in, numinputs=0,noblock=1) int * BOOL_OUT (int temp) {
     123        $1 = &temp;
     124}
     125%typemap(argout,noblock=1) int * BOOL_OUT {
     126        PyObject * r;
     127        if (*$1)
     128                r = Py_True;
     129        else
     130                r = Py_False;
     131        Py_XINCREF(r);
     132        %append_output(r);
     133}
     134
    121135/* To allow passing callback functions defined in python */
    122136%typemap(in) PyObject *PyCb {
    123         if (!PyCallable_Check($input)) {
    124                 PyErr_SetString(PyExc_TypeError, "Need a callable object!");
    125                 SWIG_fail;
     137        if (!$input || ($input == Py_None)) {
     138                $1 = NULL;
     139        } else {
     140                if (!PyCallable_Check($input)) {
     141                        PyErr_SetString(PyExc_TypeError, "Need a callable object!");
     142                        SWIG_fail;
     143                }
     144                $1 = $input;
    126145        }
    127         $1 = $input;
    128146}
    129147
    130 
     148%{
    131149/* Forward declaration for the peers module */
    132 %{
    133150static void fd_add_cb(struct peer_info *peer, void *data);
    134151%}
     152
     153/* Overwrite declaration to apply typemaps */
     154int fd_sess_fromsid ( char * STRING, size_t LENGTH, struct session ** OUTPUT, int * BOOL_OUT);
     155
    135156
    136157/*********************************************************
     
    155176
    156177%include "peers.i"
     178%include "events.i"
     179%include "endpoints.i"
Note: See TracChangeset for help on using the changeset viewer.