/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

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