Home | History | Annotate | Download | only in typemaps
      1 /* ------------------------------------------------------------
      2  *  Enums mapped as integer values
      3  * ------------------------------------------------------------ */
      4 
      5 %apply int { enum SWIGTYPE };
      6 %apply const int& { const enum SWIGTYPE& };
      7 
      8 %typemap(in,fragment=SWIG_AsVal_frag(int),noblock=1) const enum SWIGTYPE& (int val, int ecode, $basetype temp) {
      9   ecode = SWIG_AsVal(int)($input, &val);
     10   if (!SWIG_IsOK(ecode)) {
     11     %argument_fail(ecode, "$type", $symname, $argnum);
     12   } else {
     13     temp = %static_cast(val,$basetype);
     14     $1 = &temp;
     15   }
     16 }
     17 
     18 %typemap(varin,fragment=SWIG_AsVal_frag(int),noblock=1) enum SWIGTYPE {
     19   if (sizeof(int) != sizeof($1)) {
     20     %variable_fail(SWIG_AttributeError,"$type", "arch, read-only $name");
     21   }  else {
     22     int ecode = SWIG_AsVal(int)($input, %reinterpret_cast(&$1,int*));
     23     if (!SWIG_IsOK(ecode)) {
     24       %variable_fail(ecode, "$type", "$name");
     25     }
     26   }
     27 }
     28 
     29