title: how to pass enum values from TCL script to C++ class using Swig
body: <p>I am using following code </p>
  
  <p>1) File : example.i </p>
  
  <pre><code>%module example
  %{
        /* Put header files here or function declarations like below */
        #include "example.h"
  %}
  
  %include "example.h"
  </code></pre>
  
  <p>2) File example.h</p>
  
  <pre><code>enum Type {one,two};
  class myClass {
      public:
          myClass() {}
          static bool printVal(int val);
          static bool printEnum(Type val);
   };
  </code></pre>
  
  <p>3)  File example.cpp</p>
  
  <pre><code>#include  "example.h"
  #include &lt;iostream&gt;
  using namespace std;
  
  bool myClass::printVal(int val) {
      cout &lt;&lt; " Int Val = " &lt;&lt; val &lt;&lt; endl;
      return 0;
  }
  bool myClass::printEnum(type val) {
      cout &lt;&lt; " Enum Val = " &lt;&lt; val &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>Steps to compile and run </p>
  
  <pre><code>swig -c++ -tcl example.i
  g++ -c -fpic example_wrap.cxx example.cpp -I/usr/local/include
  g++ -shared example.o example_wrap.o -o example.so
  setenv LD_LIBRARY_PATH /pathtoexample.so:$LD_LIBRARY_PATH
  tclsh
  % load example.so
  %myClass_printVal 1
    Int Val = 1
  %myClass_printEnum one
   TypeError in method 'myClass_printEnum', argument 1 of type 'type'
  </code></pre>
  
  <p>I am getting TypeError if I pass enum . I know there is typemap for type conversion , but I do not know how to use typemaps to pass enum values from TCL script to c++ class . I am looking forward for help for how to pass enum values from TCL to c++ class objects using SWIG.</p>