Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 25, 2008, 12:51:29 AM (17 years ago)
Author:
landauf
Message:

some changes in commandexecutor and tclbind, but there's still a bug in the parameter evaluation

Location:
code/branches/console/src/core
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/src/core/CommandExecutor.cc

    r1149 r1187  
    270270    }
    271271
     272    bool CommandEvaluation::hasReturnvalue() const
     273    {
     274        if (this->state_ == CS_Shortcut_Params || this->state_ == CS_Shortcut_Finished)
     275        {
     276            if (this->shortcut_)
     277                return this->shortcut_->hasReturnvalue();
     278        }
     279        else if (this->state_ == CS_Function_Params || this->state_ == CS_Function_Finished)
     280        {
     281            if (this->function_)
     282                return this->function_->hasReturnvalue();
     283        }
     284
     285        return MT_null;
     286    }
     287
    272288    MultiTypeMath CommandEvaluation::getReturnvalue() const
    273289    {
  • code/branches/console/src/core/CommandExecutor.h

    r1064 r1187  
    9595            void evaluateParams();
    9696
     97            bool hasReturnvalue() const;
    9798            MultiTypeMath getReturnvalue() const;
    9899
  • code/branches/console/src/core/TclBind.cc

    r1151 r1187  
    33
    44#include "ConsoleCommand.h"
     5#include "CommandExecutor.h"
    56#include "Debug.h"
    6 #include "cpptcl/CppTcl.h"
    77#include "TclBind.h"
    88
    99namespace orxonox
    1010{
    11     ConsoleCommandShortcutExtern(test, AccessLevel::None);
    1211    ConsoleCommandShortcutExtern(tcl, AccessLevel::None);
    1312
    14     void hello()
     13    void Tcl_puts(Tcl::object const &args)
    1514    {
    16         std::cout << "Hello C++/Tcl!" << std::endl;
     15        COUT(0) << args.get() << std::endl;
    1716    }
    1817
    19     void test()
     18    std::string Tcl_unknown(Tcl::object const &a)
    2019    {
    21         Tcl::interpreter i;
    22         i.def("hello", hello);
    23 
    24         std::string script = "for {set i 0} {$i != 4} {incr i} { hello }";
    25 
    26         i.eval(script);
     20std::cout << "1\n";
     21std::cout << a.get() << std::endl;
     22        CommandEvaluation evaluation = CommandExecutor::evaluate(std::string(a.get()));
     23std::cout << "2\n";
     24        CommandExecutor::execute(evaluation);
     25std::cout << "3\n";
     26        if (evaluation.hasReturnvalue())
     27        {
     28std::cout << "4\n";
     29            return evaluation.getReturnvalue().toString();
     30        }
     31std::cout << "5\n";
     32        return "";
    2733    }
    2834
     
    3238        {
    3339            static Tcl::interpreter i;
     40            i.def("puts", Tcl_puts, Tcl::variadic());
     41            i.def("blub", Tcl_unknown, Tcl::variadic());
    3442            std::string output = i.eval(tclcode);
    3543            COUT(0) << "tcl> " << output << std::endl;
  • code/branches/console/src/core/TclBind.h

    r1151 r1187  
    22#define _TclBind_H__
    33
     4#include "cpptcl/CppTcl.h"
     5
    46namespace orxonox
    57{
    6     void hello();
    7     void test();
     8    Tcl::interpreter* createNewInterpreter();
     9    void Tcl_puts(Tcl::object const &c);
     10    std::string Tcl_unknown(Tcl::object const &c);
    811    std::string tcl(const std::string& tclcode);
    912}
Note: See TracChangeset for help on using the changeset viewer.