Home | History | Annotate | Download | only in python
      1 /*
      2    adding backward compatibility macros
      3 */
      4 
      5 #define SWIG_arg(x...)     %arg(x)
      6 #define SWIG_Mangle(x...)  %mangle(x)
      7 
      8 #define SWIG_As_frag(Type...)      %fragment_name(As, Type)
      9 #define SWIG_As_name(Type...)      %symbol_name(As, Type)
     10 #define SWIG_As(Type...)     	   SWIG_As_name(Type) SWIG_AS_CALL_ARGS
     11 
     12 #define SWIG_Check_frag(Type...)   %fragment_name(Check, Type)
     13 #define SWIG_Check_name(Type...)   %symbol_name(Check, Type)
     14 #define SWIG_Check(Type...)        SWIG_Check_name(Type) SWIG_AS_CALL_ARGS
     15 
     16 %define %ascheck_methods(Code, Type...)
     17 %fragment(SWIG_As_frag(Type),"header", fragment=SWIG_AsVal_frag(Type)) {
     18 SWIGINTERNINLINE Type
     19 SWIG_As(Type)(PyObject* obj)
     20 {
     21   Type v;
     22   int res = SWIG_AsVal(Type)(obj, &v);
     23   if (!SWIG_IsOK(res)) {
     24     /*
     25       this is needed to make valgrind/purify happier.
     26      */
     27     memset((void*)&v, 0, sizeof(Type));
     28     SWIG_Error(res, "");
     29   }
     30   return v;
     31 }
     32 }
     33 
     34 %fragment(SWIG_Check_frag(Type),"header",fragment=SWIG_AsVal_frag(Type)) {
     35 SWIGINTERNINLINE int
     36 SWIG_Check(Type)(PyObject* obj)
     37 {
     38   int res = SWIG_AsVal(Type)(obj, (Type*)0);
     39   return SWIG_IsOK(res);
     40 }
     41 }
     42 %enddef
     43 
     44 %apply_checkctypes(%ascheck_methods)
     45 
     46