PageRenderTime 18ms CodeModel.GetById 16ms app.highlight 0ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1-3-29/SWIG/Lib/typemaps/enumint.swg

#
Unknown | 28 lines | 24 code | 4 blank | 0 comment | 0 complexity | 8ce1702367c520d9b91b4be71f17132e MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
 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