Index: code/branches/console/CMakeLists.txt
===================================================================
--- code/branches/console/CMakeLists.txt	(revision 1150)
+++ code/branches/console/CMakeLists.txt	(revision 1151)
@@ -63,4 +63,5 @@
 FIND_PACKAGE(ZLIB)
 FIND_PACKAGE(Lua)
+FIND_PACKAGE(TCL)
 
 #Set the search paths for the linking
@@ -72,4 +73,5 @@
   ${Boost_LIBRARY_DIRS}
   ${Zlib_LIBRARY_DIR}
+  ${TCL_LIBRARY}
 )
 
@@ -86,4 +88,5 @@
   ${OGG_INCLUDE_DIR}
   ${Lua_INCLUDE_DIR}
+  ${TCL_INCLUDE_PATH}
 )
 
Index: code/branches/console/cmake/FindTCL.cmake
===================================================================
--- code/branches/console/cmake/FindTCL.cmake	(revision 1151)
+++ code/branches/console/cmake/FindTCL.cmake	(revision 1151)
@@ -0,0 +1,51 @@
+# - Find Tcl includes and libraries.
+# This module finds if TCL is installed and determines where the
+# include files and libraries are. It also determines what the name of
+# the library is. This code sets the following variables:
+#  TCL_LIBRARY        = path to Tcl library (tcl tcl80)
+#  TCL_INCLUDE_PATH   = path to where tcl.h can be found
+
+GET_FILENAME_COMPONENT(TCL_TCLSH_PATH "${TCL_TCLSH}" PATH)
+
+SET (TCLTK_POSSIBLE_LIB_PATHS
+  /usr/lib 
+  /usr/local/lib
+  "$ENV{ProgramFiles}/Tcl/Lib"
+  "C:/Program Files/Tcl/lib" 
+  "C:/Tcl/lib" 
+  ../libs/tcl8.5.2/win
+)
+
+FIND_LIBRARY(TCL_LIBRARY
+  NAMES tcl tcl85 tcl84 tcl8.4 tcl83 tcl8.3 tcl82 tcl8.2 tcl80 tcl8.0
+  PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
+)
+
+GET_FILENAME_COMPONENT(TCL_LIBRARY_PATH "${TCL_LIBRARY}" PATH)
+
+SET (TCLTK_POSSIBLE_INCLUDE_PATHS
+  /usr/include
+  /usr/local/include
+  /usr/include/tcl8.4
+  /usr/include/tcl8.3
+  /usr/include/tcl8.2
+  /usr/include/tcl8.0
+  "$ENV{ProgramFiles}/Tcl/include"
+  "C:/Program Files/Tcl/include"
+  C:/Tcl/include
+  ../libs/tcl8.5.2/generic
+)
+
+FIND_PATH(TCL_INCLUDE_PATH tcl.h
+  ${TCL_FRAMEWORK_INCLUDES} ${TCLTK_POSSIBLE_INCLUDE_PATHS}
+)
+
+IF(TCL_INCLUDE_PATH)
+  IF(TK_INCLUDE_PATH)
+    IF(TCL_LIBRARY)
+      IF(TK_LIBRARY)
+        SET(TCL_FOUND 1)
+      ENDIF(TK_LIBRARY)
+    ENDIF(TCL_LIBRARY)
+  ENDIF(TK_INCLUDE_PATH)
+ENDIF(TCL_INCLUDE_PATH)
Index: code/branches/console/src/CMakeLists.txt
===================================================================
--- code/branches/console/src/CMakeLists.txt	(revision 1150)
+++ code/branches/console/src/CMakeLists.txt	(revision 1151)
@@ -1,7 +1,7 @@
 INCLUDE_DIRECTORIES(.)
 INCLUDE_DIRECTORIES(orxonox)
-INCLUDE_DIRECTORIES(tolua)
 
 ADD_SUBDIRECTORY(tolua)
+ADD_SUBDIRECTORY(cpptcl)
 ADD_SUBDIRECTORY(util)
 ADD_SUBDIRECTORY(core)
Index: code/branches/console/src/core/CMakeLists.txt
===================================================================
--- code/branches/console/src/core/CMakeLists.txt	(revision 1150)
+++ code/branches/console/src/core/CMakeLists.txt	(revision 1151)
@@ -26,4 +26,5 @@
   Tickable.cc
   Script.cc
+  TclBind.cc
 )
 
@@ -33,4 +34,5 @@
   util
   tolualib
+  cpptcl
   ${Lua_LIBRARIES}
   ${OIS_LIBRARIES}
Index: code/branches/console/src/core/InputBuffer.cc
===================================================================
--- code/branches/console/src/core/InputBuffer.cc	(revision 1150)
+++ code/branches/console/src/core/InputBuffer.cc	(revision 1151)
@@ -39,9 +39,17 @@
     {
         //this->bActivated_ = false;
-        this->allowedChars_ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZäöüÄÖÜ0123456789 \\\"().:,;_-+*/=!?<>[|]";
+        this->allowedChars_ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZäöüÄÖÜ0123456789 \\\"(){}[]<>.:,;_-+*/=!?|$&%^";
         this->keyboard_ = InputManager::getSingleton().getKeyboard();
         this->buffer_ = "";
 
         //this->keyboard_->setEventCallback(this);
+    }
+
+    InputBuffer::InputBuffer(const std::string allowedChars)
+    {
+        //this->bActivated_ = false;
+        this->allowedChars_ = allowedChars;
+        this->keyboard_ = InputManager::getSingleton().getKeyboard();
+        this->buffer_ = "";
     }
 /*
Index: code/branches/console/src/core/InputBuffer.h
===================================================================
--- code/branches/console/src/core/InputBuffer.h	(revision 1150)
+++ code/branches/console/src/core/InputBuffer.h	(revision 1151)
@@ -59,4 +59,5 @@
         public:
             InputBuffer();
+            InputBuffer(const std::string allowedChars);
 
             template <class T>
Index: code/branches/console/src/core/TclBind.cc
===================================================================
--- code/branches/console/src/core/TclBind.cc	(revision 1151)
+++ code/branches/console/src/core/TclBind.cc	(revision 1151)
@@ -0,0 +1,49 @@
+#include <iostream>
+#include <string>
+
+#include "ConsoleCommand.h"
+#include "Debug.h"
+#include "cpptcl/CppTcl.h"
+#include "TclBind.h"
+
+namespace orxonox
+{
+    ConsoleCommandShortcutExtern(test, AccessLevel::None);
+    ConsoleCommandShortcutExtern(tcl, AccessLevel::None);
+
+    void hello()
+    {
+        std::cout << "Hello C++/Tcl!" << std::endl;
+    }
+
+    void test()
+    {
+        Tcl::interpreter i;
+        i.def("hello", hello);
+
+        std::string script = "for {set i 0} {$i != 4} {incr i} { hello }";
+
+        i.eval(script);
+    }
+
+    std::string tcl(const std::string& tclcode)
+    {
+        try
+        {
+            static Tcl::interpreter i;
+            std::string output = i.eval(tclcode);
+            COUT(0) << "tcl> " << output << std::endl;
+            return output;
+        }
+        catch (Tcl::tcl_error const &e)
+        {
+            COUT(1) << "Error: Tcl: " << e.what() << std::endl;
+        }
+        catch (std::exception const &e)
+        {
+            COUT(1) << "Error while executing tcl: " << e.what() << std::endl;
+        }
+
+        return "";
+    }
+}
Index: code/branches/console/src/core/TclBind.h
===================================================================
--- code/branches/console/src/core/TclBind.h	(revision 1151)
+++ code/branches/console/src/core/TclBind.h	(revision 1151)
@@ -0,0 +1,11 @@
+#ifndef _TclBind_H__
+#define _TclBind_H__
+
+namespace orxonox
+{
+    void hello();
+    void test();
+    std::string tcl(const std::string& tclcode);
+}
+
+#endif /* _TclBind_H__ */
Index: code/branches/console/src/cpptcl/CMakeLists.txt
===================================================================
--- code/branches/console/src/cpptcl/CMakeLists.txt	(revision 1151)
+++ code/branches/console/src/cpptcl/CMakeLists.txt	(revision 1151)
@@ -0,0 +1,5 @@
+ADD_LIBRARY(cpptcl SHARED CppTcl.cc)
+
+TARGET_LINK_LIBRARIES(cpptcl
+  ${TCL_LIBRARY}
+)
Index: code/branches/console/src/cpptcl/CREDITS
===================================================================
--- code/branches/console/src/cpptcl/CREDITS	(revision 1151)
+++ code/branches/console/src/cpptcl/CREDITS	(revision 1151)
@@ -0,0 +1,11 @@
+I would like to thank you very much for your contributions:
+
+---
+Alexey Pakhunov provided patches with various bugfixes and enhancements.
+His patches were used in the 1.1.2 release.
+
+---
+Christoph Pesch provided a small patch for the g++ 3.2 compiler.
+
+After the 1.1.0 release, Christoph provided also a patch for newer g++ 3.4.3.
+(included in 1.1.1)
Index: code/branches/console/src/cpptcl/CppTcl.cc
===================================================================
--- code/branches/console/src/cpptcl/CppTcl.cc	(revision 1151)
+++ code/branches/console/src/cpptcl/CppTcl.cc	(revision 1151)
@@ -0,0 +1,1083 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+#include "CppTcl.h"
+#include <map>
+#include <sstream>
+#include <iterator>
+
+
+using namespace Tcl;
+using namespace Tcl::details;
+using namespace std;
+using namespace boost;
+
+
+result::result(Tcl_Interp *interp) : interp_(interp) {}
+
+result::operator bool() const
+{
+     Tcl_Obj *obj = Tcl_GetObjResult(interp_);
+
+     int val, cc;
+     cc = Tcl_GetBooleanFromObj(interp_, obj, &val);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+
+     return static_cast<bool>(val);
+}
+
+result::operator double() const
+{
+     Tcl_Obj *obj = Tcl_GetObjResult(interp_);
+
+     double val;
+     int cc = Tcl_GetDoubleFromObj(interp_, obj, &val);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+
+     return val;
+}
+
+result::operator int() const
+{
+     Tcl_Obj *obj = Tcl_GetObjResult(interp_);
+
+     int val, cc;
+     cc = Tcl_GetIntFromObj(interp_, obj, &val);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+
+     return val;
+}
+
+result::operator long() const
+{
+     Tcl_Obj *obj = Tcl_GetObjResult(interp_);
+
+     long val;
+     int cc;
+     cc = Tcl_GetLongFromObj(interp_, obj, &val);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+
+     return val;
+}
+
+result::operator string() const
+{
+     Tcl_Obj *obj = Tcl_GetObjResult(interp_);
+     return Tcl_GetString(obj);
+}
+
+result::operator object() const
+{
+     return object(Tcl_GetObjResult(interp_));
+}
+
+
+void details::set_result(Tcl_Interp *interp, bool b)
+{
+     Tcl_SetObjResult(interp, Tcl_NewBooleanObj(b));
+}
+
+void details::set_result(Tcl_Interp *interp, int i)
+{
+     Tcl_SetObjResult(interp, Tcl_NewIntObj(i));
+}
+
+void details::set_result(Tcl_Interp *interp, long i)
+{
+     Tcl_SetObjResult(interp, Tcl_NewLongObj(i));
+}
+
+void details::set_result(Tcl_Interp *interp, double d)
+{
+     Tcl_SetObjResult(interp, Tcl_NewDoubleObj(d));
+}
+
+void details::set_result(Tcl_Interp *interp, string const &s)
+{
+     Tcl_SetObjResult(interp,
+          Tcl_NewStringObj(s.data(), static_cast<int>(s.size())));
+}
+
+void details::set_result(Tcl_Interp *interp, void *p)
+{
+     ostringstream ss;
+     ss << 'p' << p;
+     string s(ss.str());
+
+     Tcl_SetObjResult(interp,
+          Tcl_NewStringObj(s.data(), static_cast<int>(s.size())));
+}
+
+void details::set_result(Tcl_Interp *interp, object const &o)
+{
+     Tcl_SetObjResult(interp, o.get_object());
+}
+
+
+void details::check_params_no(int objc, int required)
+{
+     if (objc < required)
+     {
+          throw tcl_error("Too few arguments.");
+     }
+}
+
+object details::get_var_params(Tcl_Interp *interp,
+     int objc, Tcl_Obj * CONST objv[],
+     int from, policies const &pol)
+{
+     object o;
+     if (pol.variadic_)
+     {
+          check_params_no(objc, from);
+          o.assign(objv + from, objv + objc);
+     }
+     else
+     {
+          check_params_no(objc, from + 1);
+          o.assign(objv[from]);
+     }
+
+     o.set_interp(interp);
+
+     return o;
+}
+
+
+namespace // anonymous
+{
+
+// map of polymorphic callbacks
+typedef map<string, shared_ptr<callback_base> > callback_interp_map;
+typedef map<Tcl_Interp *, callback_interp_map> callback_map;
+
+callback_map callbacks;
+callback_map constructors;
+
+// map of call policies
+typedef map<string, policies> policies_interp_map;
+typedef map<Tcl_Interp *, policies_interp_map> policies_map;
+
+policies_map call_policies;
+
+// map of object handlers
+typedef map<string, shared_ptr<class_handler_base> > class_interp_map;
+typedef map<Tcl_Interp *, class_interp_map> class_handlers_map;
+
+class_handlers_map class_handlers;
+
+
+// helper for finding call policies - returns true when found
+bool find_policies(Tcl_Interp *interp, string const &cmdName,
+     policies_interp_map::iterator &piti)
+{
+     policies_map::iterator pit = call_policies.find(interp);
+     if (pit == call_policies.end())
+     {
+          return false;
+     }
+
+     piti = pit->second.find(cmdName);
+     return piti != pit->second.end();
+}
+
+extern "C"
+int object_handler(ClientData cd, Tcl_Interp *interp,
+     int objc, Tcl_Obj * CONST objv[]);
+
+// helper function for post-processing call policies
+// for both free functions (isMethod == false)
+// and class methods (isMethod == true)
+void post_process_policies(Tcl_Interp *interp, policies &pol,
+     Tcl_Obj * CONST objv[], bool isMethod)
+{
+     // check if it is a factory
+     if (!pol.factory_.empty())
+     {
+          class_handlers_map::iterator it = class_handlers.find(interp);
+          if (it == class_handlers.end())
+          {
+               throw tcl_error(
+                    "Factory was registered for unknown class.");
+          }
+
+          class_interp_map::iterator oit = it->second.find(pol.factory_);
+          if (oit == it->second.end())
+          {
+               throw tcl_error(
+                    "Factory was registered for unknown class.");
+          }
+
+          class_handler_base *chb = oit->second.get();
+
+          // register a new command for the object returned
+          // by this factory function
+          // if everything went OK, the result is the address of the
+          // new object in the 'pXXX' form
+          // - the new command will be created with this name
+
+          Tcl_CreateObjCommand(interp,
+               Tcl_GetString(Tcl_GetObjResult(interp)),
+               object_handler, static_cast<ClientData>(chb), 0);
+     }
+
+     // process all declared sinks
+     // - unregister all object commands that envelopes the pointers
+     for (vector<int>::iterator s = pol.sinks_.begin();
+          s != pol.sinks_.end(); ++s)
+     {
+          if (isMethod == false)
+          {
+               // example: if there is a declared sink at parameter 3,
+               // and the Tcl command was:
+               // % fun par1 par2 PAR3 par4
+               // then the index 3 correctly points into the objv array
+
+               int index = *s;
+               Tcl_DeleteCommand(interp, Tcl_GetString(objv[index]));
+          }
+          else
+          {
+               // example: if there is a declared sink at parameter 3,
+               // and the Tcl command was:
+               // % $p method par1 par2 PAR3 par4
+               // then the index 3 needs to be incremented
+               // in order correctly point into the 4th index of objv array
+
+               int index = *s + 1;
+               Tcl_DeleteCommand(interp, Tcl_GetString(objv[index]));
+          }
+     }
+}
+
+// actual functions handling various callbacks
+
+// generic callback handler
+extern "C"
+int callback_handler(ClientData, Tcl_Interp *interp,
+     int objc, Tcl_Obj * CONST objv[])
+{
+     callback_map::iterator it = callbacks.find(interp);
+     if (it == callbacks.end())
+     {
+          Tcl_SetResult(interp,
+               "Trying to invoke non-existent callback (wrong interpreter?)",
+               TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     string cmdName(Tcl_GetString(objv[0]));
+     callback_interp_map::iterator iti = it->second.find(cmdName);
+     if (iti == it->second.end())
+     {
+          Tcl_SetResult(interp,
+               "Trying to invoke non-existent callback (wrong cmd name?)",
+               TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     policies_map::iterator pit = call_policies.find(interp);
+     if (pit == call_policies.end())
+     {
+          Tcl_SetResult(interp,
+               "Trying to invoke callback with no known policies",
+               TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     policies_interp_map::iterator piti;
+     if (find_policies(interp, cmdName, piti) == false)
+     {
+          Tcl_SetResult(interp,
+               "Trying to invoke callback with no known policies",
+               TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     policies &pol = piti->second;
+
+     try
+     {
+          iti->second->invoke(interp, objc, objv, pol);
+
+          post_process_policies(interp, pol, objv, false);
+     }
+     catch (exception const &e)
+     {
+          Tcl_SetResult(interp, const_cast<char*>(e.what()), TCL_VOLATILE);
+          return TCL_ERROR;
+     }
+     catch (...)
+     {
+          Tcl_SetResult(interp, "Unknown error.", TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     return TCL_OK;
+}
+
+// generic "object" command handler
+extern "C"
+int object_handler(ClientData cd, Tcl_Interp *interp,
+     int objc, Tcl_Obj * CONST objv[])
+{
+     // here, client data points to the singleton object
+     // which is responsible for managing commands for
+     // objects of a given type
+
+     class_handler_base *chb = reinterpret_cast<class_handler_base*>(cd);
+
+     // the command name has the form 'pXXX' where XXX is the address
+     // of the "this" object
+
+     string const str(Tcl_GetString(objv[0]));
+     istringstream ss(str);
+     char dummy;
+     void *p;
+     ss >> dummy >> p;
+
+     try
+     {
+          string methodName(Tcl_GetString(objv[1]));
+          policies &pol = chb->get_policies(methodName);
+
+          chb->invoke(p, interp, objc, objv, pol);
+
+          post_process_policies(interp, pol, objv, true);
+     }
+     catch (exception const &e)
+     {
+          Tcl_SetResult(interp, const_cast<char*>(e.what()), TCL_VOLATILE);
+          return TCL_ERROR;
+     }
+     catch (...)
+     {
+          Tcl_SetResult(interp, "Unknown error.", TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     return TCL_OK;
+}
+
+// generic "constructor" command
+extern "C"
+int constructor_handler(ClientData cd, Tcl_Interp *interp,
+     int objc, Tcl_Obj * CONST objv[])
+{
+     // here, client data points to the singleton object
+     // which is responsible for managing commands for
+     // objects of a given type
+
+     class_handler_base *chb = reinterpret_cast<class_handler_base*>(cd);
+
+     callback_map::iterator it = constructors.find(interp);
+     if (it == constructors.end())
+     {
+          Tcl_SetResult(interp,
+               "Trying to invoke non-existent callback (wrong interpreter?)",
+               TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     string className(Tcl_GetString(objv[0]));
+     callback_interp_map::iterator iti = it->second.find(className);
+     if (iti == it->second.end())
+     {
+          Tcl_SetResult(interp,
+               "Trying to invoke non-existent callback (wrong class name?)",
+               TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     policies_interp_map::iterator piti;
+     if (find_policies(interp, className, piti) == false)
+     {
+          Tcl_SetResult(interp,
+               "Trying to invoke callback with no known policies",
+               TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     policies &pol = piti->second;
+
+     try
+     {
+          iti->second->invoke(interp, objc, objv, pol);
+
+          // if everything went OK, the result is the address of the
+          // new object in the 'pXXX' form
+          // - we can create a new command with this name
+
+          Tcl_CreateObjCommand(interp,
+               Tcl_GetString(Tcl_GetObjResult(interp)),
+               object_handler, static_cast<ClientData>(chb), 0);
+     }
+     catch (exception const &e)
+     {
+          Tcl_SetResult(interp, const_cast<char*>(e.what()), TCL_VOLATILE);
+          return TCL_ERROR;
+     }
+     catch (...)
+     {
+          Tcl_SetResult(interp, "Unknown error.", TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     return TCL_OK;
+}
+
+} // namespace anonymous
+
+Tcl::details::no_init_type Tcl::no_init;
+
+
+policies & policies::factory(string const &name)
+{
+     factory_ = name;
+     return *this;
+}
+
+policies & policies::sink(int index)
+{
+     sinks_.push_back(index);
+     return *this;
+}
+
+policies & policies::variadic()
+{
+     variadic_ = true;
+     return *this;
+}
+
+policies Tcl::factory(string const &name)
+{
+     return policies().factory(name);
+}
+
+policies Tcl::sink(int index)
+{
+     return policies().sink(index);
+}
+
+policies Tcl::variadic()
+{
+     return policies().variadic();
+}
+
+
+class_handler_base::class_handler_base()
+{
+     // default policies for the -delete command
+     policies_["-delete"] = policies();
+}
+
+void class_handler_base::register_method(string const &name,
+     shared_ptr<object_cmd_base> ocb, policies const &p)
+{
+     methods_[name] = ocb;
+     policies_[name] = p;
+}
+
+policies & class_handler_base::get_policies(string const &name)
+{
+     policies_map_type::iterator it = policies_.find(name);
+     if (it == policies_.end())
+     {
+          throw tcl_error("Trying to use non-existent policy: " + name);
+     }
+
+     return it->second;
+}
+
+
+object::object()
+     : interp_(0)
+{
+     obj_ = Tcl_NewObj();
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(bool b)
+     : interp_(0)
+{
+     obj_ = Tcl_NewBooleanObj(b);
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(char const *buf, size_t size)
+     : interp_(0)
+{
+     obj_ = Tcl_NewByteArrayObj(
+          reinterpret_cast<unsigned char const *>(buf),
+          static_cast<int>(size));
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(double d)
+     : interp_(0)
+{
+     obj_ = Tcl_NewDoubleObj(d);
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(int i)
+     : interp_(0)
+{
+     obj_ = Tcl_NewIntObj(i);
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(long l)
+     : interp_(0)
+{
+     obj_ = Tcl_NewLongObj(l);
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(char const *s)
+     : interp_(0)
+{
+     obj_ = Tcl_NewStringObj(s, -1);
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(string const &s)
+     : interp_(0)
+{
+     obj_ = Tcl_NewStringObj(s.data(), static_cast<int>(s.size()));
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(Tcl_Obj *o, bool shared)
+     : interp_(0)
+{
+     init(o, shared);
+}
+
+object::object(object const &other, bool shared)
+     : interp_(other.get_interp())
+{
+     init(other.obj_, shared);
+}
+
+void object::init(Tcl_Obj *o, bool shared)
+{
+     if (shared)
+     {
+          obj_ = o;
+     }
+     else
+     {
+          obj_ = Tcl_DuplicateObj(o);
+     }
+     Tcl_IncrRefCount(obj_);
+}
+
+object::~object()
+{
+     Tcl_DecrRefCount(obj_);
+}
+
+object & object::assign(bool b)
+{
+     Tcl_SetBooleanObj(obj_, b);
+     return *this;
+}
+
+object & object::resize(size_t size)
+{
+     Tcl_SetByteArrayLength(obj_, static_cast<int>(size));
+     return *this;
+}
+
+object & object::assign(char const *buf, size_t size)
+{
+     Tcl_SetByteArrayObj(obj_,
+          reinterpret_cast<unsigned char const *>(buf),
+          static_cast<int>(size));
+     return *this;
+}
+
+object & object::assign(double d)
+{
+     Tcl_SetDoubleObj(obj_, d);
+     return *this;
+}
+
+object & object::assign(int i)
+{
+     Tcl_SetIntObj(obj_, i);
+     return *this;
+}
+
+object & object::assign(long l)
+{
+     Tcl_SetLongObj(obj_, l);
+     return *this;
+}
+
+object & object::assign(char const *s)
+{
+     Tcl_SetStringObj(obj_, s, -1);
+     return *this;
+}
+
+object & object::assign(string const &s)
+{
+     Tcl_SetStringObj(obj_, s.data(), static_cast<int>(s.size()));
+     return *this;
+}
+
+object & object::assign(object const &other)
+{
+     object(other).swap(*this);
+     return *this;
+}
+
+object & object::assign(Tcl_Obj *o)
+{
+     object(o).swap(*this);
+     return *this;
+}
+
+object & object::swap(object &other)
+{
+     std::swap(obj_, other.obj_);
+     std::swap(interp_, other.interp_);
+     return *this;
+}
+
+template <>
+bool object::get<bool>(interpreter &i) const
+{
+     int retVal;
+     int res = Tcl_GetBooleanFromObj(i.get(), obj_, &retVal);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return static_cast<bool>(retVal);
+}
+
+template <>
+vector<char> object::get<vector<char> >(interpreter &) const
+{
+     size_t size;
+     char const *buf = get(size);
+     return vector<char>(buf, buf + size);
+}
+
+template <>
+double object::get<double>(interpreter &i) const
+{
+     double retVal;
+     int res = Tcl_GetDoubleFromObj(i.get(), obj_, &retVal);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return retVal;
+}
+
+template <>
+int object::get<int>(interpreter &i) const
+{
+     int retVal;
+
+     int res = Tcl_GetIntFromObj(i.get(), obj_, &retVal);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return retVal;
+}
+
+template <>
+long object::get<long>(interpreter &i) const
+{
+     long retVal;
+     int res = Tcl_GetLongFromObj(i.get(), obj_, &retVal);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return retVal;
+}
+
+template <>
+char const * object::get<char const *>(interpreter &) const
+{
+     return get();
+}
+
+template <>
+string object::get<string>(interpreter &) const
+{
+     int len;
+     char const *buf = Tcl_GetStringFromObj(obj_, &len);
+     return string(buf, buf + len);
+}
+
+char const * object::get() const
+{
+     return Tcl_GetString(obj_);
+}
+
+char const * object::get(size_t &size) const
+{
+     int len;
+     unsigned char *buf = Tcl_GetByteArrayFromObj(obj_, &len);
+     size = len;
+     return const_cast<char const *>(reinterpret_cast<char *>(buf));
+}
+
+size_t object::length(interpreter &i) const
+{
+     int len;
+     int res = Tcl_ListObjLength(i.get(), obj_, &len);
+
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return static_cast<size_t>(len);
+}
+
+object object::at(interpreter &i, size_t index) const
+{
+     Tcl_Obj *o;
+     int res = Tcl_ListObjIndex(i.get(), obj_, static_cast<int>(index), &o);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+     if (o == NULL)
+     {
+          throw tcl_error("Index out of range.");
+     }
+
+     return object(o);
+}
+
+object & object::append(interpreter &i, object const &o)
+{
+     int res = Tcl_ListObjAppendElement(i.get(), obj_, o.obj_);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return *this;
+}
+
+object & object::append_list(interpreter &i, object const &o)
+{
+     int res = Tcl_ListObjAppendList(i.get(), obj_, o.obj_);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return *this;
+}
+
+object & object::replace(interpreter &i, size_t index, size_t count,
+     object const &o)
+{
+     int res = Tcl_ListObjReplace(i.get(), obj_,
+          static_cast<int>(index), static_cast<int>(count),
+          1, &(o.obj_));
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return *this;
+}
+
+object & object::replace_list(interpreter &i, size_t index, size_t count,
+     object const &o)
+{
+     int objc;
+     Tcl_Obj **objv;
+
+     int res = Tcl_ListObjGetElements(i.get(), o.obj_, &objc, &objv);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     res = Tcl_ListObjReplace(i.get(), obj_,
+          static_cast<int>(index), static_cast<int>(count),
+          objc, objv);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return *this;
+}
+
+void object::set_interp(Tcl_Interp *interp)
+{
+     interp_ = interp;
+}
+
+Tcl_Interp * object::get_interp() const
+{
+     return interp_;
+}
+
+
+interpreter::interpreter()
+{
+     interp_ =  Tcl_CreateInterp();
+     owner_ = true;
+}
+
+interpreter::interpreter(Tcl_Interp *interp, bool owner)
+{
+     interp_ =  interp;
+     owner_ = owner;
+}
+
+interpreter::~interpreter()
+{
+     if (owner_)
+     {
+          // clear all callback info belonging to this interpreter
+          clear_definitions(interp_);
+
+          Tcl_DeleteInterp(interp_);
+     }
+}
+
+void interpreter::make_safe()
+{
+     int cc = Tcl_MakeSafe(interp_);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+}
+
+result interpreter::eval(string const &script)
+{
+     int cc = Tcl_Eval(interp_, script.c_str());
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+
+     return result(interp_);
+}
+
+result interpreter::eval(istream &s)
+{
+     string str(
+          istreambuf_iterator<char>(s.rdbuf()),
+          istreambuf_iterator<char>()
+     );
+     return eval(str);
+}
+
+result interpreter::eval(object const &o)
+{
+     int cc = Tcl_EvalObjEx(interp_, o.get_object(), 0);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+
+     return result(interp_);
+}
+
+void interpreter::pkg_provide(string const &name, string const &version)
+{
+     int cc = Tcl_PkgProvide(interp_, name.c_str(), version.c_str());
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+}
+
+void interpreter::create_alias(string const &cmd,
+     interpreter &targetInterp, string const &targetCmd)
+{
+     int cc = Tcl_CreateAlias(interp_, cmd.c_str(),
+          targetInterp.interp_, targetCmd.c_str(), 0, 0);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+}
+
+void interpreter::clear_definitions(Tcl_Interp *interp)
+{
+     // delete all callbacks that were registered for given interpreter
+
+     {
+          callback_map::iterator it = callbacks.find(interp);
+          if (it == callbacks.end())
+          {
+               // no callbacks defined for this interpreter
+               return;
+          }
+
+          callback_interp_map &imap = it->second;
+          for (callback_interp_map::iterator it2 = imap.begin();
+               it2 != imap.end(); ++it2)
+          {
+               Tcl_DeleteCommand(interp, it2->first.c_str());
+          }
+
+          callbacks.erase(interp);
+     }
+
+     // delete all constructors
+
+     {
+          callback_map::iterator it = constructors.find(interp);
+          if (it == constructors.end())
+          {
+               // no callbacks defined for this interpreter
+               return;
+          }
+
+          callback_interp_map &imap = it->second;
+          for (callback_interp_map::iterator it2 = imap.begin();
+               it2 != imap.end(); ++it2)
+          {
+               Tcl_DeleteCommand(interp, it2->first.c_str());
+          }
+
+          callbacks.erase(interp);
+     }
+
+     // delete all call policies
+
+     call_policies.erase(interp);
+
+     // delete all object handlers
+     // (we have to assume that all living objects were destroyed,
+     // otherwise Bad Things will happen)
+
+     class_handlers.erase(interp);
+}
+
+void interpreter::add_function(string const &name,
+     shared_ptr<callback_base> cb, policies const &p)
+{
+     Tcl_CreateObjCommand(interp_, name.c_str(),
+          callback_handler, 0, 0);
+
+     callbacks[interp_][name] = cb;
+     call_policies[interp_][name] = p;
+}
+
+void interpreter::add_class(string const &name,
+     shared_ptr<class_handler_base> chb)
+{
+     class_handlers[interp_][name] = chb;
+}
+
+void interpreter::add_constructor(string const &name,
+     shared_ptr<class_handler_base> chb, shared_ptr<callback_base> cb,
+     policies const &p)
+{
+     Tcl_CreateObjCommand(interp_, name.c_str(),
+          constructor_handler, static_cast<ClientData>(chb.get()), 0);
+
+     constructors[interp_][name] = cb;
+     call_policies[interp_][name] = p;
+}
+
+
+int tcl_cast<int>::from(Tcl_Interp *interp, Tcl_Obj *obj)
+{
+     int res;
+     int cc = Tcl_GetIntFromObj(interp, obj, &res);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp);
+     }
+
+     return res;
+}
+
+long tcl_cast<long>::from(Tcl_Interp *interp, Tcl_Obj *obj)
+{
+     long res;
+     int cc = Tcl_GetLongFromObj(interp, obj, &res);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp);
+     }
+
+     return res;
+}
+
+bool tcl_cast<bool>::from(Tcl_Interp *interp, Tcl_Obj *obj)
+{
+     int res;
+     int cc = Tcl_GetBooleanFromObj(interp, obj, &res);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp);
+     }
+
+     return res != 0;
+}
+
+double tcl_cast<double>::from(Tcl_Interp *interp, Tcl_Obj *obj)
+{
+     double res;
+     int cc = Tcl_GetDoubleFromObj(interp, obj, &res);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp);
+     }
+
+     return res;
+}
+
+string tcl_cast<string>::from(Tcl_Interp *, Tcl_Obj *obj)
+{
+     return Tcl_GetString(obj);
+}
+
+char const * tcl_cast<char const *>::from(Tcl_Interp *, Tcl_Obj *obj)
+{
+     return Tcl_GetString(obj);
+}
+
+object tcl_cast<object>::from(Tcl_Interp *interp, Tcl_Obj *obj)
+{
+     object o(obj);
+     o.set_interp(interp);
+
+     return o;
+}
Index: code/branches/console/src/cpptcl/CppTcl.h
===================================================================
--- code/branches/console/src/cpptcl/CppTcl.h	(revision 1151)
+++ code/branches/console/src/cpptcl/CppTcl.h	(revision 1151)
@@ -0,0 +1,870 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+#ifndef CPPTCL_INCLUDED
+#define CPPTCL_INCLUDED
+
+#include <tcl.h>
+#include <string>
+#include <stdexcept>
+#include <sstream>
+#include <map>
+#include <vector>
+#include <boost/shared_ptr.hpp>
+#include <boost/bind.hpp>
+
+
+namespace Tcl
+{
+
+// exception class used for reporting all Tcl errors
+
+class tcl_error : public std::runtime_error
+{
+public:
+     explicit tcl_error(std::string const &msg)
+          : std::runtime_error(msg) {}
+     explicit tcl_error(Tcl_Interp *interp)
+          : std::runtime_error(Tcl_GetString(Tcl_GetObjResult(interp))) {}
+};
+
+// call policies
+
+struct policies
+{
+     policies() : variadic_(false) {}
+
+     policies & factory(std::string const &name);
+
+     // note: this is additive
+     policies & sink(int index);
+
+     policies & variadic();
+
+     std::string factory_;
+     std::vector<int> sinks_;
+     bool variadic_;
+};
+
+// syntax short-cuts
+policies factory(std::string const &name);
+policies sink(int index);
+policies variadic();
+
+
+class interpreter;
+class object;
+
+namespace details
+{
+
+// wrapper for the evaluation result
+class result
+{
+public:
+     result(Tcl_Interp *interp);
+     
+     operator bool() const;
+     operator double() const;
+     operator int() const;
+     operator long() const;
+     operator std::string() const;
+     operator object() const;
+
+private:
+     Tcl_Interp *interp_;
+};
+
+// helper functions used to set the result value
+
+void set_result(Tcl_Interp *interp, bool b);
+void set_result(Tcl_Interp *interp, int i);
+void set_result(Tcl_Interp *interp, long i);
+void set_result(Tcl_Interp *interp, double d);
+void set_result(Tcl_Interp *interp, std::string const &s);
+void set_result(Tcl_Interp *interp, void *p);
+void set_result(Tcl_Interp *interp, object const &o);
+
+// helper functor for converting Tcl objects to the given type
+#include "details/conversions.h"
+
+// dispatchers able to capture (or ignore) the result
+#include "details/dispatchers.h"
+
+// helper for checking for required number of parameters
+// (throws tcl_error when not met)
+void check_params_no(int objc, int required);
+
+// helper for gathering optional params in variadic functions
+object get_var_params(Tcl_Interp *interp,
+     int objc, Tcl_Obj * CONST objv[],
+     int from, policies const &pol);
+
+// the callback_base is used to store callback handlers in a polynorphic map
+class callback_base
+{
+public:
+     virtual ~callback_base() {}
+
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol) = 0;
+};
+
+
+// base class for object command handlers
+// and for class handlers
+class object_cmd_base
+{
+public:
+     // destructor not needed, but exists to shut up the compiler warnings
+     virtual ~object_cmd_base() {}
+
+     virtual void invoke(void *p, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol) = 0;
+};
+
+// base class for all class handlers, still abstract
+class class_handler_base : public object_cmd_base
+{
+public:
+     typedef std::map<std::string, policies> policies_map_type;
+
+     class_handler_base();
+
+     void register_method(std::string const &name,
+          boost::shared_ptr<object_cmd_base> ocb, policies const &p);
+
+     policies & get_policies(std::string const &name);
+
+protected:
+     typedef std::map<
+          std::string,
+          boost::shared_ptr<object_cmd_base>
+          > method_map_type;
+
+     // a map of methods for the given class
+     method_map_type methods_;
+
+     policies_map_type policies_;
+};
+
+// class handler - responsible for executing class methods
+template <class C>
+class class_handler : public class_handler_base
+{
+public:
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C * p = static_cast<C*>(pv);
+
+          if (objc < 2)
+          {
+               throw tcl_error("Too few arguments.");
+          }
+          
+          std::string methodName(Tcl_GetString(objv[1]));
+
+          if (methodName == "-delete")
+          {
+               Tcl_DeleteCommand(interp, Tcl_GetString(objv[0]));
+               delete p;
+               return;
+          }
+
+          // dispatch on the method name
+
+          method_map_type::iterator it = methods_.find(methodName);
+          if (it == methods_.end())
+          {
+               throw tcl_error("Method " + methodName + " not found.");
+          }
+
+          it->second->invoke(pv, interp, objc, objv, pol);
+     }
+};
+
+
+// factory functions for creating class objects
+#include "details/constructors.h"
+
+// actual callback envelopes
+#include "details/callbacks.h"
+
+// actual method envelopes
+#include "details/methods.h"
+
+// helper meta function for figuring appropriate constructor callback
+#include "details/metahelpers.h"
+
+
+// this class is used to provide the "def" interface for defining
+// class member functions
+
+template <class C>
+class class_definer
+{
+public:
+     class_definer(boost::shared_ptr<class_handler<C> > ch) : ch_(ch) {}
+
+     template <typename R>
+     class_definer & def(std::string const &name, R (C::*f)(),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method0<C, R>(f)), p);
+          return *this;
+     }
+
+     template <typename R>
+     class_definer & def(std::string const &name, R (C::*f)() const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method0<C, R>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1>
+     class_definer & def(std::string const &name, R (C::*f)(T1),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method1<C, R, T1>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1>
+     class_definer & def(std::string const &name, R (C::*f)(T1) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method1<C, R, T1>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2>
+     class_definer & def(std::string const &name, R (C::*f)(T1, T2),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method2<C, R, T1, T2>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2>
+     class_definer & def(std::string const &name, R (C::*f)(T1, T2) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method2<C, R, T1, T2>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3>
+     class_definer & def(std::string const &name, R (C::*f)(T1, T2, T3),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method3<C, R, T1, T2, T3>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3>
+     class_definer & def(std::string const &name, R (C::*f)(T1, T2, T3) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method3<C, R, T1, T2, T3>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4>
+     class_definer & def(std::string const &name, R (C::*f)(T1, T2, T3, T4),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method4<C, R, T1, T2, T3, T4>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method4<C, R, T1, T2, T3, T4>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5), policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method5<C, R, T1, T2, T3, T4, T5>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5) const, policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method5<C, R, T1, T2, T3, T4, T5>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6), policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method6<C, R, T1, T2, T3, T4, T5, T6>(f)),
+               p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method6<C, R, T1, T2, T3, T4, T5, T6>(f)),
+               p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6, T7),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method7<C, R,
+                    T1, T2, T3, T4, T5, T6, T7>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6, T7) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method7<C, R,
+                    T1, T2, T3, T4, T5, T6, T7>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6, T7, T8),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method8<C, R,
+                    T1, T2, T3, T4, T5, T6, T7, T8>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6, T7, T8) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method8<C, R,
+                    T1, T2, T3, T4, T5, T6, T7, T8>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8, typename T9>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6, T7, T8, T9),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method9<C, R,
+                    T1, T2, T3, T4, T5, T6, T7, T8, T9>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8, typename T9>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6, T7, T8, T9) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method9<C, R,
+                    T1, T2, T3, T4, T5, T6, T7, T8, T9>(f)), p);
+          return *this;
+     }
+
+private:
+     boost::shared_ptr<class_handler<C> > ch_;
+};
+
+} // namespace details
+
+
+// init type for defining class constructors
+template <typename T1 = void, typename T2 = void, typename T3 = void,
+          typename T4 = void, typename T5 = void, typename T6 = void,
+          typename T7 = void, typename T8 = void, typename T9 = void>
+class init {};
+
+// no_init type and object - to define classes without constructors
+namespace details
+{
+     struct no_init_type {};
+} // namespace details
+extern details::no_init_type no_init;
+
+
+// interpreter wrapper
+class interpreter
+{
+public:
+     interpreter();
+     interpreter(Tcl_Interp *, bool owner = true);
+     ~interpreter();
+     
+     void make_safe();
+     
+     Tcl_Interp * get() const { return interp_; }
+
+     // free function definitions     
+     
+     template <typename R>
+     void def(std::string const &name, R (*f)(),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback0<R>(f)), p);
+     }
+
+     template <typename R, typename T1>
+     void def(std::string const &name, R (*f)(T1),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback1<R, T1>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2>
+     void def(std::string const &name, R (*f)(T1, T2),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback2<R, T1, T2>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2, typename T3>
+     void def(std::string const &name, R (*f)(T1, T2, T3),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback3<R, T1, T2, T3>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4>
+     void def(std::string const &name, R (*f)(T1, T2, T3, T4),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback4<R, T1, T2, T3, T4>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2, typename T3,
+          typename T4, typename T5>
+     void def(std::string const &name, R (*f)(T1, T2, T3, T4, T5),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback5<R, T1, T2, T3, T4, T5>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2, typename T3,
+          typename T4, typename T5, typename T6>
+     void def(std::string const &name, R (*f)(T1, T2, T3, T4, T5, T6),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback6<R, T1, T2, T3, T4, T5, T6>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2, typename T3,
+          typename T4, typename T5, typename T6, typename T7>
+     void def(std::string const &name, R (*f)(T1, T2, T3, T4, T5, T6, T7),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback7<R,
+                    T1, T2, T3, T4, T5, T6, T7>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2, typename T3,
+          typename T4, typename T5, typename T6, typename T7, typename T8>
+     void def(std::string const &name, R (*f)(T1, T2, T3, T4, T5, T6, T7, T8),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback8<R,
+                    T1, T2, T3, T4, T5, T6, T7, T8>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2, typename T3,
+          typename T4, typename T5, typename T6, typename T7, typename T8,
+          typename T9>
+     void def(std::string const &name,
+          R (*f)(T1, T2, T3, T4, T5, T6, T7, T8, T9),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback9<R,
+                    T1, T2, T3, T4, T5, T6, T7, T8, T9>(f)), p);
+     }
+
+
+     // class definitions
+
+     template <class C>
+     details::class_definer<C> class_(std::string const &name)
+     {
+          boost::shared_ptr<details::class_handler<C> > ch(
+               new details::class_handler<C>());
+
+          add_class(name, ch);
+
+          add_constructor(name, ch,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback0<C*>(&details::construct<
+                         C, void, void, void, void, void, void, void,
+                         void, void>::doit)));
+
+          return details::class_definer<C>(ch);
+     }
+
+     template <class C, typename T1, typename T2, typename T3, typename T4,
+               typename T5, typename T6, typename T7, typename T8,
+               typename T9>
+     details::class_definer<C> class_(std::string const &name,
+          init<T1, T2, T3, T4, T5, T6, T7, T8, T9> const &,
+          policies const &p = policies())
+     {
+          typedef typename details::get_callback_type_for_construct<
+               C, T1, T2, T3, T4, T5, T6, T7, T8, T9>::type
+               callback_type;
+
+          boost::shared_ptr<details::class_handler<C> > ch(
+               new details::class_handler<C>());
+
+          add_class(name, ch);
+
+          add_constructor(name, ch,
+               boost::shared_ptr<details::callback_base>(
+                    new callback_type(&details::construct<
+                         C, T1, T2, T3, T4, T5, T6, T7, T8, T9>::doit)), p);
+
+          return details::class_definer<C>(ch);
+     }
+
+     template <class C>
+     details::class_definer<C> class_(
+          std::string const &name, details::no_init_type const &)
+     {
+          boost::shared_ptr<details::class_handler<C> > ch(
+               new details::class_handler<C>());
+
+          add_class(name, ch);
+
+          return details::class_definer<C>(ch);
+     }
+
+     // free script evaluation     
+     details::result eval(std::string const &script);
+     details::result eval(std::istream &s);
+
+     details::result eval(object const &o);
+
+     // the InputIterator should give object& or Tcl_Obj* when dereferenced
+     template <class InputIterator>
+     details::result eval(InputIterator first, InputIterator last);
+
+     // create alias from the *this interpreter to the target interpreter
+     void create_alias(std::string const &cmd,
+          interpreter &targetInterp, std::string const &targetCmd);
+
+     // register a package info (useful when defining packages)
+     void pkg_provide(std::string const &name, std::string const &version);
+
+     // helper for cleaning up callbacks in non-managed interpreters
+     static void clear_definitions(Tcl_Interp *);
+
+private:
+
+     // copy not supported
+     interpreter(const interpreter &);
+     void operator=(const interpreter &);
+
+     void add_function(std::string const &name,
+          boost::shared_ptr<details::callback_base> cb,
+          policies const &p = policies());
+
+     void add_class(std::string const &name,
+          boost::shared_ptr<details::class_handler_base> chb);
+
+     void add_constructor(std::string const &name,
+          boost::shared_ptr<details::class_handler_base> chb,
+          boost::shared_ptr<details::callback_base> cb,
+          policies const &p = policies());
+
+     Tcl_Interp *interp_;
+     bool owner_;
+};
+
+
+// object wrapper
+class object
+{
+public:
+
+     // constructors
+
+     object();
+
+     explicit object(bool b);
+     object(char const *buf, size_t size); // byte array
+     explicit object(double b);
+     explicit object(int i);
+
+     // list creation
+     // the InputIterator should give object& or Tcl_Obj* when dereferenced
+     template <class InputIterator>
+     object(InputIterator first, InputIterator last)
+          : interp_(0)
+     {
+          std::vector<Tcl_Obj*> v;
+          fill_vector(v, first, last);
+          obj_ = Tcl_NewListObj(static_cast<int>(v.size()),
+               v.empty() ? NULL : &v[0]);
+          Tcl_IncrRefCount(obj_);
+     }
+
+     explicit object(long i);
+     explicit object(char const *s);        // string construction
+     explicit object(std::string const &s); // string construction
+
+     explicit object(Tcl_Obj *o, bool shared = false);
+
+     object(object const &other, bool shared = false);
+     ~object();
+
+     // assignment
+
+     object & assign(bool b);
+     object & resize(size_t size);                  // byte array resize
+     object & assign(char const *buf, size_t size); // byte array assignment
+     object & assign(double d);
+     object & assign(int i);
+
+     // list assignment
+     // the InputIterator should give Tcl_Obj* or object& when dereferenced
+     template <class InputIterator>
+     object & assign(InputIterator first, InputIterator last)
+     {
+          std::vector<Tcl_Obj*> v;
+          fill_vector(v, first, last);
+          Tcl_SetListObj(obj_, static_cast<int>(v.size()),
+               v.empty() ? NULL : &v[0]);
+          return *this;
+     }
+
+     object & assign(long l);
+     object & assign(char const *s);        // string assignment
+     object & assign(std::string const &s); // string assignment
+     object & assign(object const &o);
+     object & assign(Tcl_Obj *o);
+
+     object & operator=(bool b)               { return assign(b); }
+     object & operator=(double d)             { return assign(d); }
+     object & operator=(int i)                { return assign(i); }
+     object & operator=(long l)               { return assign(l); }
+     object & operator=(char const *s)        { return assign(s); }
+     object & operator=(std::string const &s) { return assign(s); }
+
+     object & operator=(object const &o)      { return assign(o); }
+     object & swap(object &other);
+
+     // (logically) non-modifying members
+
+     template <typename T>
+     T get(interpreter &i) const;
+
+     char const * get() const;             // string get
+     char const * get(size_t &size) const; // byte array get
+
+     size_t length(interpreter &i) const;  // returns list length
+     object at(interpreter &i, size_t index) const;
+
+     Tcl_Obj * get_object() const { return obj_; }
+
+     // modifying members
+
+     object & append(interpreter &i, object const &o);
+     object & append_list(interpreter &i, object const &o);
+
+     // list replace
+     // the InputIterator should give Tcl_Obj* or object& when dereferenced
+     template <class InputIterator>
+     object & replace(interpreter &i, size_t index, size_t count,
+          InputIterator first, InputIterator last)
+     {
+          std::vector<Tcl_Obj*> v;
+          fill_vector(v, first, last);
+          int res = Tcl_ListObjReplace(i.get(), obj_,
+               static_cast<int>(index), static_cast<int>(count),
+               static_cast<int>(v.size()), v.empty() ? NULL : &v[0]);
+          if (res != TCL_OK)
+          {
+               throw tcl_error(i.get());
+          }
+
+          return *this;
+     }
+
+     object & replace(interpreter &i, size_t index, size_t count,
+          object const &o);
+     object & replace_list(interpreter &i, size_t index, size_t count,
+          object const &o);
+
+     // helper functions for piggy-backing interpreter info
+     void set_interp(Tcl_Interp *interp);
+     Tcl_Interp * get_interp() const;
+
+     // helper function, also used from interpreter::eval
+     template <class InputIterator>
+     static void fill_vector(std::vector<Tcl_Obj*> &v,
+          InputIterator first, InputIterator last)
+     {
+          for (; first != last; ++first)
+          {
+               object o(*first, true);
+               v.push_back(o.obj_);
+          }
+     }
+
+private:
+
+     // helper function used from copy constructors
+     void init(Tcl_Obj *o, bool shared);
+
+     Tcl_Obj *obj_;
+     Tcl_Interp *interp_;
+};
+
+// available specializations for object::get
+template <> bool         object::get<bool>(interpreter &i) const;
+template <> double       object::get<double>(interpreter &i) const;
+template <> int          object::get<int>(interpreter &i) const;
+template <> long         object::get<long>(interpreter &i) const;
+template <> char const * object::get<char const *>(interpreter &i) const;
+template <> std::string  object::get<std::string>(interpreter &i) const;
+template <>
+std::vector<char> object::get<std::vector<char> >(interpreter &i) const;
+
+// the InputIterator should give object& or Tcl_Obj* when dereferenced
+template <class InputIterator>
+details::result interpreter::eval(InputIterator first, InputIterator last)
+{
+     std::vector<Tcl_Obj*> v;
+     object::fill_vector(v, first, last);
+     int cc = Tcl_EvalObjv(interp_,
+          static_cast<int>(v.size()), v.empty() ? NULL : &v[0], 0);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+ 
+     return details::result(interp_);
+}
+
+namespace details
+{
+
+// additional callback envelopes for variadic functions
+#include "details/callbacks_v.h"
+
+// additional method envelopes for variadic methods
+#include "details/methods_v.h"
+
+} // namespace details
+
+} // namespace Tcl
+
+
+// macro for defining loadable module entry point
+// - used for extending Tcl interpreter
+
+#define CPPTCL_MODULE(name, i) void name##_cpptcl_Init(Tcl::interpreter &i); \
+     extern "C" int name##_Init(Tcl_Interp *interp) \
+     { \
+          Tcl::interpreter i(interp, false); \
+          name##_cpptcl_Init(i); \
+          return TCL_OK; \
+     } \
+     void name##_cpptcl_Init(Tcl::interpreter &i)
+
+
+#endif // CPPTCL_INCLUDED
Index: code/branches/console/src/cpptcl/LICENSE
===================================================================
--- code/branches/console/src/cpptcl/LICENSE	(revision 1151)
+++ code/branches/console/src/cpptcl/LICENSE	(revision 1151)
@@ -0,0 +1,39 @@
+Each source file contains the following notice:
+
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+The above is the shortest license I have found.
+I have copied this wording from one of the source files of the Boost library.
+
+Just to explain the above terms:
+
+1. The library is free (like in "freedom").
+
+2. You can use it for any purpose you wish. You can even sell it.
+
+3. You can modify the source files. If you do this, please feel free to add
+   your own copyright notices wherever you want, if you want.
+   You may also add more restrictive license terms.
+   You only have to keep the above notice unchanged in all source files.
+
+4. You can combine this library or its modified version with other software.
+   The license claims nothing that would affect the resulting work.
+   See point 3. if you need to make any modifications.
+
+5. You can compile this library or its modified version to the binary form.
+   The license does not affect the compiled result in any way.
+   In particular, you do not need to (but you still can) display the above
+   copyright notice to the final user, and you do not need to (but you still
+   can) inform the final user that your product was prepared with the help
+   of this library.
+
+6. Do not sue me for my (and your) mistakes and errors.
+
+As you see, this license is very permissive.
Index: code/branches/console/src/cpptcl/README
===================================================================
--- code/branches/console/src/cpptcl/README	(revision 1151)
+++ code/branches/console/src/cpptcl/README	(revision 1151)
@@ -0,0 +1,32 @@
+C++/Tcl - a C++ library for interoperability between C++ and Tcl.
+
+Copyright (C) 2004-2006, Maciej Sobczak
+
+---
+
+You should see the following directories here:
+
+- doc      - contains a short documentation for the library
+- examples - some simple examples to show C++/Tcl basics
+- test     - tests used for development - use them for regression testing
+             if you want to modify the library
+- details  - some additional code used by the library (not for client use)
+
+In addition, the following files may be of interest to you:
+
+- README   - this file
+- LICENSE  - explanation of the license terms
+- CHANGES  - the history of changes
+
+
+The C++/Tcl itself consists of these files:
+- cpptcl.h   - to be included in your own files
+- cpptcl.cc  - to be compiled and linked with your code
+
+
+In order to compile the tests and the examples you may need to change the
+compiler options to fit your particular environment (different paths to the
+Tcl headers and libs, another compiler, etc.)
+
+
+Anyway - have fun! :-)
Index: code/branches/console/src/cpptcl/details/callbacks.h
===================================================================
--- code/branches/console/src/cpptcl/details/callbacks.h	(revision 1151)
+++ code/branches/console/src/cpptcl/details/callbacks.h	(revision 1151)
@@ -0,0 +1,273 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+template <typename R>
+class callback0 : public callback_base
+{
+     typedef R (*functor_type)();
+     
+public:
+     callback0(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int, Tcl_Obj * CONST [],
+          policies const &)
+     {
+          dispatch<R>::do_dispatch(interp, f_);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1>
+class callback1 : public callback_base
+{
+     typedef R (*functor_type)(T1);
+     
+public:
+     callback1(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 2);
+          
+          dispatch<R>::template do_dispatch<T1>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2>
+class callback2 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2);
+     
+public:
+     callback2(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 3);
+          
+          dispatch<R>::template do_dispatch<T1, T2>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3>
+class callback3 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2, T3);
+     
+public:
+     callback3(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 4);
+          
+          dispatch<R>::template do_dispatch<T1, T2, T3>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4>
+class callback4 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2, T3, T4);
+     
+public:
+     callback4(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 5);
+          
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5>
+class callback5 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2, T3, T4, T5);
+     
+public:
+     callback5(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 6);
+          
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5, typename T6>
+class callback6 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6);
+     
+public:
+     callback6(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 7);
+          
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               tcl_cast<T6>::from(interp, objv[6]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5, typename T6, typename T7>
+class callback7 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7);
+     
+public:
+     callback7(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 8);
+          
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               tcl_cast<T6>::from(interp, objv[6]),
+               tcl_cast<T7>::from(interp, objv[7]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5, typename T6, typename T7, typename T8>
+class callback8 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7, T8);
+     
+public:
+     callback8(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 9);
+          
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7, T8>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               tcl_cast<T6>::from(interp, objv[6]),
+               tcl_cast<T7>::from(interp, objv[7]),
+               tcl_cast<T8>::from(interp, objv[8]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5, typename T6, typename T7, typename T8, typename T9>
+class callback9 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7, T8, T9);
+     
+public:
+     callback9(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 10);
+          
+          dispatch<R>::template do_dispatch<
+               T1, T2, T3, T4, T5, T6, T7, T8, T9>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               tcl_cast<T6>::from(interp, objv[6]),
+               tcl_cast<T7>::from(interp, objv[7]),
+               tcl_cast<T8>::from(interp, objv[8]),
+               tcl_cast<T9>::from(interp, objv[9]));
+     }
+
+private:
+     functor_type f_;
+};
Index: code/branches/console/src/cpptcl/details/callbacks_v.h
===================================================================
--- code/branches/console/src/cpptcl/details/callbacks_v.h	(revision 1151)
+++ code/branches/console/src/cpptcl/details/callbacks_v.h	(revision 1151)
@@ -0,0 +1,267 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+template <typename R>
+class callback1<R, object const &> : public callback_base
+{
+     typedef object const & T1;
+     typedef R (*functor_type)(T1);
+     enum { var_start = 1 };
+     
+public:
+     callback1(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t1 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1>(interp, f_,
+               t1);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1>
+class callback2<R, T1, object const &> : public callback_base
+{
+     typedef object const & T2;
+     typedef R (*functor_type)(T1, T2);
+     enum { var_start = 2 };
+     
+public:
+     callback2(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t2 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1, T2>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               t2);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2>
+class callback3<R, T1, T2, object const &> : public callback_base
+{
+     typedef object const & T3;
+     typedef R (*functor_type)(T1, T2, T3);
+     enum { var_start = 3 };
+     
+public:
+     callback3(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t3 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1, T2, T3>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               t3);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3>
+class callback4<R, T1, T2, T3, object const &> : public callback_base
+{
+     typedef object const & T4;
+     typedef R (*functor_type)(T1, T2, T3, T4);
+     enum { var_start = 4 };
+     
+public:
+     callback4(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t4 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               t4);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4>
+class callback5<R, T1, T2, T3, T4, object const &> : public callback_base
+{
+     typedef object const & T5;
+     typedef R (*functor_type)(T1, T2, T3, T4, T5);
+     enum { var_start = 5 };
+     
+public:
+     callback5(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t5 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               t5);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5>
+class callback6<R, T1, T2, T3, T4, T5, object const &> : public callback_base
+{
+     typedef object const & T6;
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6);
+     enum { var_start = 6 };
+     
+public:
+     callback6(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t6 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               t6);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5, typename T6>
+class callback7<R, T1, T2, T3, T4, T5, T6, object const &>
+     : public callback_base
+{
+     typedef object const & T7;
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7);
+     enum { var_start = 7 };
+     
+public:
+     callback7(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t7 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               tcl_cast<T6>::from(interp, objv[6]),
+               t7);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5, typename T6, typename T7>
+class callback8<R, T1, T2, T3, T4, T5, T6, T7, object const &>
+     : public callback_base
+{
+     typedef object const & T8;
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7, T8);
+     enum { var_start = 8 };
+     
+public:
+     callback8(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t8 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7, T8>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               tcl_cast<T6>::from(interp, objv[6]),
+               tcl_cast<T7>::from(interp, objv[7]),
+               t8);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5, typename T6, typename T7, typename T8>
+class callback9<R, T1, T2, T3, T4, T5, T6, T7, T8, object const &>
+     : public callback_base
+{
+     typedef object const & T9;
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7, T8, T9);
+     enum { var_start = 9 };
+     
+public:
+     callback9(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t9 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<
+               T1, T2, T3, T4, T5, T6, T7, T8, T9>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               tcl_cast<T6>::from(interp, objv[6]),
+               tcl_cast<T7>::from(interp, objv[7]),
+               tcl_cast<T8>::from(interp, objv[8]),
+               t9);
+     }
+
+private:
+     functor_type f_;
+};
Index: code/branches/console/src/cpptcl/details/constructors.h
===================================================================
--- code/branches/console/src/cpptcl/details/constructors.h	(revision 1151)
+++ code/branches/console/src/cpptcl/details/constructors.h	(revision 1151)
@@ -0,0 +1,88 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8, typename T9>
+struct construct
+{
+     static C * doit(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7,
+          T8 t8, T9 t9)
+     { return new C(t1, t2, t3, t4, t5, t6, t7, t8, t9); }
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8>
+struct construct<C, T1, T2, T3, T4, T5, T6, T7, T8, void>
+{
+     static C * doit(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
+     { return new C(t1, t2, t3, t4, t5, t6, t7, t8); }
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7>
+struct construct<C, T1, T2, T3, T4, T5, T6, T7, void, void>
+{
+     static C * doit(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
+     { return new C(t1, t2, t3, t4, t5, t6, t7); }
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6>
+struct construct<C, T1, T2, T3, T4, T5, T6, void, void, void>
+{
+     static C * doit(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
+     { return new C(t1, t2, t3, t4, t5, t6); }
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5>
+struct construct<C, T1, T2, T3, T4, T5, void, void, void, void>
+{
+     static C * doit(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
+     { return new C(t1, t2, t3, t4, t5); }
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4>
+struct construct<C, T1, T2, T3, T4, void, void, void, void, void>
+{
+     static C * doit(T1 t1, T2 t2, T3 t3, T4 t4)
+     { return new C(t1, t2, t3, t4); }
+};
+
+template <class C, typename T1, typename T2, typename T3>
+struct construct<C, T1, T2, T3, void, void, void, void, void, void>
+{
+     static C * doit(T1 t1, T2 t2, T3 t3)
+     { return new C(t1, t2, t3); }
+};
+
+template <class C, typename T1, typename T2>
+struct construct<C, T1, T2, void, void, void, void, void, void, void>
+{
+     static C * doit(T1 t1, T2 t2)
+     { return new C(t1, t2); }
+};
+
+template <class C, typename T1>
+struct construct<C, T1, void, void, void, void, void, void, void, void>
+{
+     static C * doit(T1 t1)
+     { return new C(t1); }
+};
+
+template <class C>
+struct construct<C, void, void, void, void, void,
+                 void, void, void, void>
+{
+     static C * doit()
+     { return new C(); }
+};
Index: code/branches/console/src/cpptcl/details/conversions.h
===================================================================
--- code/branches/console/src/cpptcl/details/conversions.h	(revision 1151)
+++ code/branches/console/src/cpptcl/details/conversions.h	(revision 1151)
@@ -0,0 +1,101 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+// helper functor for converting Tcl objects to the given type
+// (it is a struct instead of function,
+// because I need to partially specialize it)
+
+template <typename T>
+struct tcl_cast;
+
+template <typename T>
+struct tcl_cast<T*>
+{
+     static T * from(Tcl_Interp *, Tcl_Obj *obj)
+     {
+          std::string s(Tcl_GetString(obj));
+          if (s.size() == 0)
+          {
+               throw tcl_error("Expected pointer value, got empty string.");
+          }
+
+          if (s[0] != 'p')
+          {
+               throw tcl_error("Expected pointer value.");
+          }
+
+          std::istringstream ss(s);
+          char dummy;
+          void *p;
+          ss >> dummy >> p;
+
+          return static_cast<T*>(p);
+     }
+};
+
+// the following partial specialization is to strip reference
+// (it returns a temporary object of the underlying type, which
+// can be bound to the const-ref parameter of the actual function)
+
+template <typename T>
+struct tcl_cast<T const &>
+{
+     static T from(Tcl_Interp *interp, Tcl_Obj *obj)
+     {
+          return tcl_cast<T>::from(interp, obj);
+     }
+};
+
+
+// the following specializations are implemented
+
+template <>
+struct tcl_cast<int>
+{
+     static int from(Tcl_Interp *, Tcl_Obj *);
+};
+
+template <>
+struct tcl_cast<long>
+{
+     static long from(Tcl_Interp *, Tcl_Obj *);
+};
+
+template <>
+struct tcl_cast<bool>
+{
+     static bool from(Tcl_Interp *, Tcl_Obj *);
+};
+
+template <>
+struct tcl_cast<double>
+{
+     static double from(Tcl_Interp *, Tcl_Obj *);
+};
+
+template <>
+struct tcl_cast<std::string>
+{
+     static std::string from(Tcl_Interp *, Tcl_Obj *);
+};
+
+template <>
+struct tcl_cast<char const *>
+{
+     static char const * from(Tcl_Interp *, Tcl_Obj *);
+};
+
+template <>
+struct tcl_cast<object>
+{
+     static object from(Tcl_Interp *, Tcl_Obj *);
+};
Index: code/branches/console/src/cpptcl/details/dispatchers.h
===================================================================
--- code/branches/console/src/cpptcl/details/dispatchers.h	(revision 1151)
+++ code/branches/console/src/cpptcl/details/dispatchers.h	(revision 1151)
@@ -0,0 +1,181 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+// the dispatch class is used to execute the callback functor and to
+// capture its return value
+// further dispatch<void> specialization ignores the res
+
+template <typename R>
+struct dispatch
+{
+     template <class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f)
+     {
+          R res = f();
+          set_result(interp, res);
+     }
+
+     template <typename T1, class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f, T1 t1)
+     {
+          R res = f(t1);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f, T1 t1, T2 t2)
+     {
+          R res = f(t1, t2);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, typename T3, class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f,
+          T1 t1, T2 t2, T3 t3)
+     {
+          R res = f(t1, t2, t3);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4)
+     {
+          R res = f(t1, t2, t3, t4);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
+     {
+          R res = f(t1, t2, t3, t4, t5);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
+     {
+          R res = f(t1, t2, t3, t4, t5, t6);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
+     {
+          R res = f(t1, t2, t3, t4, t5, t6, t7);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8, class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
+     {
+          R res = f(t1, t2, t3, t4, t5, t6, t7, t8);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8, typename T9,
+          class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9)
+     {
+          R res = f(t1, t2, t3, t4, t5, t6, t7, t8, t9);
+          set_result(interp, res);
+     }
+};
+
+template <>
+struct dispatch<void>
+{
+     template <class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f)
+     {
+          f();
+     }
+
+     template <typename T1, class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f, T1 t1)
+     {
+          f(t1);
+     }
+
+     template <typename T1, typename T2, class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f, T1 t1, T2 t2)
+     {
+          f(t1, t2);
+     }
+
+     template <typename T1, typename T2, typename T3, class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f,
+          T1 t1, T2 t2, T3 t3)
+     {
+          f(t1, t2, t3);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4)
+     {
+          f(t1, t2, t3, t4);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
+     {
+          f(t1, t2, t3, t4, t5);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
+     {
+          f(t1, t2, t3, t4, t5, t6);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
+     {
+          f(t1, t2, t3, t4, t5, t6, t7);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8, class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
+     {
+          f(t1, t2, t3, t4, t5, t6, t7, t8);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8, typename T9,
+          class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9)
+     {
+          f(t1, t2, t3, t4, t5, t6, t7, t8, t9);
+     }
+};
Index: code/branches/console/src/cpptcl/details/metahelpers.h
===================================================================
--- code/branches/console/src/cpptcl/details/metahelpers.h	(revision 1151)
+++ code/branches/console/src/cpptcl/details/metahelpers.h	(revision 1151)
@@ -0,0 +1,86 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8,
+          typename T9>
+struct get_callback_type_for_construct
+{
+     typedef callback9<C*, T1, T2, T3, T4, T5, T6, T7, T8, T9> type;
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8>
+struct get_callback_type_for_construct<
+     C, T1, T2, T3, T4, T5, T6, T7, T8, void>
+{
+     typedef callback8<C*, T1, T2, T3, T4, T5, T6, T7, T8> type;
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7>
+struct get_callback_type_for_construct<
+     C, T1, T2, T3, T4, T5, T6, T7, void, void>
+{
+     typedef callback7<C*, T1, T2, T3, T4, T5, T6, T7> type;
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6>
+struct get_callback_type_for_construct<
+     C, T1, T2, T3, T4, T5, T6, void, void, void>
+{
+     typedef callback6<C*, T1, T2, T3, T4, T5, T6> type;
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5>
+struct get_callback_type_for_construct<
+     C, T1, T2, T3, T4, T5, void, void, void, void>
+{
+     typedef callback5<C*, T1, T2, T3, T4, T5> type;
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4>
+struct get_callback_type_for_construct<
+     C, T1, T2, T3, T4, void, void, void, void, void>
+{
+     typedef callback4<C*, T1, T2, T3, T4> type;
+};
+
+template <class C, typename T1, typename T2, typename T3>
+struct get_callback_type_for_construct<
+     C, T1, T2, T3, void, void, void, void, void, void>
+{
+     typedef callback3<C*, T1, T2, T3> type;
+};
+
+template <class C, typename T1, typename T2>
+struct get_callback_type_for_construct<
+     C, T1, T2, void, void, void, void, void, void, void>
+{
+     typedef callback2<C*, T1, T2> type;
+};
+
+template <class C, typename T1>
+struct get_callback_type_for_construct<
+     C, T1, void, void, void, void, void, void, void, void>
+{
+     typedef callback1<C*, T1> type;
+};
+
+template <class C>
+struct get_callback_type_for_construct<
+     C, void, void, void, void, void, void, void, void, void>
+{
+     typedef callback0<C*> type;
+};
Index: code/branches/console/src/cpptcl/details/methods.h
===================================================================
--- code/branches/console/src/cpptcl/details/methods.h	(revision 1151)
+++ code/branches/console/src/cpptcl/details/methods.h	(revision 1151)
@@ -0,0 +1,452 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+template <class C, typename R>
+class method0 : public object_cmd_base
+{
+     typedef R (C::*mem_type)();
+     typedef R (C::*cmem_type)() const;
+     
+public:
+     method0(mem_type f) : f_(f), cmem_(false) {}
+     method0(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int, Tcl_Obj * CONST [], policies const &)
+     {
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::do_dispatch(interp, boost::bind(cf_, p));
+          }
+          else
+          {
+               dispatch<R>::do_dispatch(interp, boost::bind(f_, p));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1>
+class method1 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1);
+     typedef R (C::*cmem_type)(T1) const;
+     
+public:
+     method1(mem_type f) : f_(f), cmem_(false) {}
+     method1(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 3);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1>(
+                    interp, boost::bind(cf_, p, _1),
+                    tcl_cast<T1>::from(interp, objv[2]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1>(
+                    interp, boost::bind(f_, p, _1),
+                    tcl_cast<T1>::from(interp, objv[2]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2>
+class method2 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2);
+     typedef R (C::*cmem_type)(T1, T2) const;
+     
+public:
+     method2(mem_type f) : f_(f), cmem_(false) {}
+     method2(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 4);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2>(
+                    interp, boost::bind(cf_, p, _1, _2),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2>(
+                    interp, boost::bind(f_, p, _1, _2),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3>
+class method3 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2, T3);
+     typedef R (C::*cmem_type)(T1, T2, T3) const;
+     
+public:
+     method3(mem_type f) : f_(f), cmem_(false) {}
+     method3(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 5);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3>(
+                    interp, boost::bind(cf_, p, _1, _2, _3),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3>(
+                    interp, boost::bind(f_, p, _1, _2, _3),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4>
+class method4 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2, T3, T4);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4) const;
+     
+public:
+     method4(mem_type f) : f_(f), cmem_(false) {}
+     method4(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 6);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5>
+class method5 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5) const;
+     
+public:
+     method5(mem_type f) : f_(f), cmem_(false) {}
+     method5(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 7);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4, _5),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4, _5),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5, typename T6>
+class method6 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6) const;
+     
+public:
+     method6(mem_type f) : f_(f), cmem_(false) {}
+     method6(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 8);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4, _5, _6),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4, _5, _6),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5, typename T6, typename T7>
+class method7 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6, T7);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6, T7) const;
+     
+public:
+     method7(mem_type f) : f_(f), cmem_(false) {}
+     method7(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 9);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4, _5, _6, _7),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4, _5, _6, _7),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5, typename T6, typename T7, typename T8>
+class method8 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6, T7, T8);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6, T7, T8) const;
+     
+public:
+     method8(mem_type f) : f_(f), cmem_(false) {}
+     method8(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 10);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8>(
+                    interp, boost::bind(cf_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    tcl_cast<T8>::from(interp, objv[9]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8>(
+                    interp, boost::bind(f_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    tcl_cast<T8>::from(interp, objv[9]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5, typename T6, typename T7, typename T8,
+     typename T9>
+class method9 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6, T7, T8, T9);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6, T7, T8, T9) const;
+     
+public:
+     method9(mem_type f) : f_(f), cmem_(false) {}
+     method9(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 11);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8, T9>(
+                    interp, boost::bind(cf_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8, _9),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    tcl_cast<T8>::from(interp, objv[9]),
+                    tcl_cast<T9>::from(interp, objv[10]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8, T9>(
+                    interp, boost::bind(f_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8, _9),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    tcl_cast<T8>::from(interp, objv[9]),
+                    tcl_cast<T9>::from(interp, objv[10]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
Index: code/branches/console/src/cpptcl/details/methods_v.h
===================================================================
--- code/branches/console/src/cpptcl/details/methods_v.h	(revision 1151)
+++ code/branches/console/src/cpptcl/details/methods_v.h	(revision 1151)
@@ -0,0 +1,451 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+template <class C, typename R>
+class method1<C, R, object const &> : public object_cmd_base
+{
+     typedef object const & T1;
+     typedef R (C::*mem_type)(T1);
+     typedef R (C::*cmem_type)(T1) const;
+     enum { var_start = 2 };
+     
+public:
+     method1(mem_type f) : f_(f), cmem_(false) {}
+     method1(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t1 = get_var_params(interp, objc, objv, var_start, pol);
+
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1>(
+                    interp, boost::bind(cf_, p, _1),
+                    t1);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1>(
+                    interp, boost::bind(f_, p, _1),
+                    t1);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1>
+class method2<C, R, T1, object const &> : public object_cmd_base
+{
+     typedef object const & T2;
+     typedef R (C::*mem_type)(T1, T2);
+     typedef R (C::*cmem_type)(T1, T2) const;
+     enum { var_start = 3 };
+     
+public:
+     method2(mem_type f) : f_(f), cmem_(false) {}
+     method2(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t2 = get_var_params(interp, objc, objv, var_start, pol);
+          
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2>(
+                    interp, boost::bind(cf_, p, _1, _2),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    t2);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2>(
+                    interp, boost::bind(f_, p, _1, _2),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    t2);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2>
+class method3<C, R, T1, T2, object const &> : public object_cmd_base
+{
+     typedef object const & T3;
+     typedef R (C::*mem_type)(T1, T2, T3);
+     typedef R (C::*cmem_type)(T1, T2, T3) const;
+     enum { var_start = 4 };
+     
+public:
+     method3(mem_type f) : f_(f), cmem_(false) {}
+     method3(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t3 = get_var_params(interp, objc, objv, var_start, pol);
+          
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3>(
+                    interp, boost::bind(cf_, p, _1, _2, _3),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    t3);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3>(
+                    interp, boost::bind(f_, p, _1, _2, _3),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    t3);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3>
+class method4<C, R, T1, T2, T3, object const &> : public object_cmd_base
+{
+     typedef object const & T4;
+     typedef R (C::*mem_type)(T1, T2, T3, T4);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4) const;
+     enum { var_start = 5 };
+     
+public:
+     method4(mem_type f) : f_(f), cmem_(false) {}
+     method4(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t4 = get_var_params(interp, objc, objv, var_start, pol);
+
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    t4);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    t4);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4>
+class method5<C, R, T1, T2, T3, T4, object const &> : public object_cmd_base
+{
+     typedef object const & T5;
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5) const;
+     enum { var_start = 6 };
+     
+public:
+     method5(mem_type f) : f_(f), cmem_(false) {}
+     method5(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t5 = get_var_params(interp, objc, objv, var_start, pol);
+
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4, _5),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    t5);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4, _5),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    t5);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5>
+class method6<C, R, T1, T2, T3, T4, T5, object const &>
+     : public object_cmd_base
+{
+     typedef object const & T6;
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6) const;
+     enum { var_start = 7 };
+     
+public:
+     method6(mem_type f) : f_(f), cmem_(false) {}
+     method6(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t6 = get_var_params(interp, objc, objv, var_start, pol);
+
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4, _5, _6),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    t6);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4, _5, _6),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    t6);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5, typename T6>
+class method7<C, R, T1, T2, T3, T4, T5, T6, object const &>
+     : public object_cmd_base
+{
+     typedef object const & T7;
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6, T7);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6, T7) const;
+     enum { var_start = 8 };
+     
+public:
+     method7(mem_type f) : f_(f), cmem_(false) {}
+     method7(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t7 = get_var_params(interp, objc, objv, var_start, pol);
+
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4, _5, _6, _7),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    t7);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4, _5, _6, _7),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    t7);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5, typename T6, typename T7>
+class method8<C, R, T1, T2, T3, T4, T5, T6, T7, object const &>
+     : public object_cmd_base
+{
+     typedef object const & T8;
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6, T7, T8);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6, T7, T8) const;
+     enum { var_start = 9 };
+     
+public:
+     method8(mem_type f) : f_(f), cmem_(false) {}
+     method8(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t8 = get_var_params(interp, objc, objv, var_start, pol);
+
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8>(
+                    interp, boost::bind(cf_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    t8);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8>(
+                    interp, boost::bind(f_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    t8);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5, typename T6, typename T7, typename T8>
+class method9<C, R, T1, T2, T3, T4, T5, T6, T7, T8, object const &>
+     : public object_cmd_base
+{
+     typedef object const & T9;
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6, T7, T8, T9);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6, T7, T8, T9) const;
+     enum { var_start = 10 };
+     
+public:
+     method9(mem_type f) : f_(f), cmem_(false) {}
+     method9(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t9 = get_var_params(interp, objc, objv, var_start, pol);
+
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8, T9>(
+                    interp, boost::bind(cf_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8, _9),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    tcl_cast<T8>::from(interp, objv[9]),
+                    t9);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8, T9>(
+                    interp, boost::bind(f_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8, _9),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    tcl_cast<T8>::from(interp, objv[9]),
+                    t9);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
Index: code/branches/console/src/orxonox/Orxonox.cc
===================================================================
--- code/branches/console/src/orxonox/Orxonox.cc	(revision 1150)
+++ code/branches/console/src/orxonox/Orxonox.cc	(revision 1151)
@@ -423,5 +423,4 @@
     ib->registerListener(console, &Testconsole::listen, true);
     ib->registerListener(console, &Testconsole::execute, '\r', false);
-    ib->registerListener(console, &Testconsole::execute, '\n', false);
     ib->registerListener(console, &Testconsole::hintandcomplete, '\t', true);
     ib->registerListener(console, &Testconsole::clear, '§', true);
@@ -433,5 +432,4 @@
     ib->registerListener(orxonoxConsole_, &InGameConsole::listen, true);
     ib->registerListener(orxonoxConsole_, &InGameConsole::execute, '\r', false);
-    ib->registerListener(orxonoxConsole_, &InGameConsole::execute, '\n', false);
     ib->registerListener(orxonoxConsole_, &InGameConsole::hintandcomplete, '\t', true);
     ib->registerListener(orxonoxConsole_, &InGameConsole::clear, '§', true);
