Navigation



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

Continued work on dbg_interactive.fdx

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/dbg_interactive/diwrap.i

    r621 r623  
     1/* This interface file is processed by SWIG to create a python wrapper interface to freeDiameter framework. */
     2%module diwrap
     3%begin %{
    14/*********************************************************************************************************
    25* Software License Agreement (BSD License)                                                               *
     
    3336* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                                                             *
    3437*********************************************************************************************************/
     38%}
    3539
    36 /* This interface file is processed by SWIG to create a python wrapper interface to freeDiameter framework. */
    37 %module diwrap
    3840
    39 /* Include standard types & functions used in freeDiameter headers */
    40 %include <stdint.i>
     41%init %{
     42/* TODO: How to load the proxy classes here? */
     43%}
    4144
    4245%{
     
    4649%}
    4750
     51
     52/* Include standard types & functions used in freeDiameter headers */
     53%include <stdint.i>
     54%include <cpointer.i>
     55%include <typemaps.i>
     56
    4857/* Some functions are not available through the wrapper */
    4958%ignore fd_lib_init;
    5059%ignore fd_lib_fini;
    51 %ignore fd_sess_start;
    5260
    5361/* Inline functions seems to give problems to SWIG -- just remove the inline definition */
     
    5563%enddef
    5664
    57 /* Make some global-variables read-only */
     65/* Make some global-variables read-only (mainly to avoid warnings) */
    5866%immutable fd_g_config;
    5967%immutable peer_state_str;
    6068
    61 /* Overwrite a few functions prototypes for usability */
     69/* Overwrite a few functions prototypes for usability: default parameters values, OUTPUT typemaps, ... */
    6270extern void fd_list_init ( struct fd_list * list, void * obj = NULL );
     71
     72
     73/*
     74extern int fd_dict_new ( struct dictionary * dict, enum dict_object_type type, void * data, struct dict_object * parent, struct dict_object ** OUTPUT );
     75extern int fd_dict_search ( struct dictionary * dict, enum dict_object_type type, int criteria, void * what, struct dict_object ** OUTPUT, int retval );
     76extern int fd_dict_get_error_cmd(struct dictionary * dict, struct dict_object ** OUTPUT);
     77extern int fd_dict_getval ( struct dict_object * object, void * INOUT);
     78//extern int fd_dict_gettype ( struct dict_object * object, enum dict_object_type * OUTPUT);
     79extern int fd_dict_getdict ( struct dict_object * object, struct dictionary ** OUTPUT);
     80*/
    6381
    6482
     
    6987
    7088
     89/* Some pointer types that are useful */
     90%pointer_class(int, int_ptr);
     91%pointer_class(enum dict_object_type, dict_object_type_ptr);
     92%pointer_functions(struct dict_object *, dict_object_ptr);
     93%pointer_functions(struct session *, session_ptr);
     94
     95
     96
     97
     98/* Extend some structures for usability/debug in python */
     99%extend fd_list {
     100        fd_list(void * o = NULL) {
     101                struct fd_list * li;
     102                li = (struct fd_list *) malloc(sizeof(struct fd_list));
     103                if (!li) {
     104                        fd_log_debug("Out of memory!\n");
     105                        return NULL;
     106                }
     107                fd_list_init(li, o);
     108                return li;
     109        }
     110        ~fd_list() {
     111                fd_list_unlink($self);
     112                free($self);
     113        }
     114        void dump() {
     115                fd_log_debug("list: %p\n", $self);
     116                fd_log_debug("  - next: %p\n", $self->next);
     117                fd_log_debug("  - prev: %p\n", $self->prev);
     118                fd_log_debug("  - head: %p\n", $self->head);
     119                fd_log_debug("  - o   : %p\n", $self->o);
     120        }
     121};
     122
     123%extend dict_object_type_ptr {
     124        void dump() {
     125                %#define CASE_STR(x)  case x: fd_log_debug(#x "\n"); break;
     126                switch (*$self) {
     127                        CASE_STR(DICT_VENDOR)
     128                        CASE_STR(DICT_APPLICATION)
     129                        CASE_STR(DICT_TYPE)
     130                        CASE_STR(DICT_ENUMVAL)
     131                        CASE_STR(DICT_AVP)
     132                        CASE_STR(DICT_COMMAND)
     133                        CASE_STR(DICT_RULE)
     134                        default: fd_log_debug("Invalid value (%d)", *$self); break;
     135                }
     136        }
     137}
     138
     139%inline %{
     140void session_ptr_showsid(struct session * s) {
     141        char * sid;
     142        int ret = fd_sess_getsid ( s, &sid );
     143        if (ret != 0) {
     144                fd_log_debug("Error %d\n", ret);
     145                /* throw an exception in SWIG? */
     146                return;
     147        }
     148        fd_log_debug("%s\n", sid);
     149}
     150%}
Note: See TracChangeset for help on using the changeset viewer.