Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1188


Ignore:
Timestamp:
Apr 26, 2008, 2:50:04 AM (17 years ago)
Author:
landauf
Message:

removed some bugs
tcl knows now orxonox

Location:
code/branches/console/src
Files:
6 edited

Legend:

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

    r1187 r1188  
    236236            if (this->shortcut_)
    237237            {
    238                 if (this->shortcut_->evaluate(this->processedCommand_ + this->getAdditionalParameter(), this->param_, " "))
    239                 {
    240                     this->bEvaluatedParams_ = true;
    241                     this->evaluatedExecutor_ = this->shortcut_;
     238                if (this->tokens_.size() <= 1)
     239                {
     240                    if (this->shortcut_->evaluate(this->getAdditionalParameter(), this->param_, " "))
     241                    {
     242                        this->bEvaluatedParams_ = true;
     243                        this->evaluatedExecutor_ = this->shortcut_;
     244                    }
     245                }
     246                else if (this->tokens_.size() > 1)
     247                {
     248                    if (this->shortcut_->evaluate(this->tokens_.subSet(1).join() + this->getAdditionalParameter(), this->param_, " "))
     249                    {
     250                        this->bEvaluatedParams_ = true;
     251                        this->evaluatedExecutor_ = this->shortcut_;
     252                    }
    242253                }
    243254            }
     
    247258            if (this->function_)
    248259            {
    249                 if (this->function_->evaluate(this->processedCommand_ + this->getAdditionalParameter(), this->param_, " "))
    250                 {
    251                     this->bEvaluatedParams_ = true;
    252                     this->evaluatedExecutor_ = this->function_;
     260                if (this->tokens_.size() <= 2)
     261                {
     262                    if (this->function_->evaluate(this->getAdditionalParameter(), this->param_, " "))
     263                    {
     264                        this->bEvaluatedParams_ = true;
     265                        this->evaluatedExecutor_ = this->function_;
     266                    }
     267                }
     268                else if (this->tokens_.size() > 2)
     269                {
     270                    if (this->function_->evaluate(this->tokens_.subSet(2).join() + this->getAdditionalParameter(), this->param_, " "))
     271                    {
     272                        this->bEvaluatedParams_ = true;
     273                        this->evaluatedExecutor_ = this->function_;
     274                    }
    253275                }
    254276            }
     
    354376    bool CommandExecutor::execute(const std::string& command)
    355377    {
     378std::cout << "CE_execute: " << command << "\n";
    356379        if ((CommandExecutor::getEvaluation().processedCommand_ != command) || (CommandExecutor::getEvaluation().state_ == CS_Uninitialized))
    357             CommandExecutor::parse(command);
     380{std::cout << "CE_execute->parse\n";
     381            CommandExecutor::parse(command);}
    358382
    359383        return CommandExecutor::execute(CommandExecutor::getEvaluation());
     
    368392        {
    369393            (*evaluation.evaluatedExecutor_)(evaluation.param_[0], evaluation.param_[1], evaluation.param_[2], evaluation.param_[3], evaluation.param_[4]);
     394            return true;
    370395        }
    371396
     
    612637    {
    613638        CommandExecutor::parse(command, true);
     639std::cout << "1_1: " << command << std::endl;
     640        if (CommandExecutor::getEvaluation().tokens_.size() > 0)
     641        {
     642            std::string lastToken;
     643            lastToken = CommandExecutor::getEvaluation().tokens_[CommandExecutor::getEvaluation().tokens_.size() - 1];
     644            lastToken = lastToken.substr(0, lastToken.size() - 1);
     645            CommandExecutor::getEvaluation().tokens_.pop_back();
     646            CommandExecutor::getEvaluation().tokens_.append(SubString(lastToken, " "));
     647        }
     648std::cout << "1_2: " << CommandExecutor::getEvaluation().tokens_[CommandExecutor::getEvaluation().tokens_.size() - 1] << std::endl;
    614649        CommandExecutor::getEvaluation().evaluateParams();
    615650        return CommandExecutor::getEvaluation();
     
    10491084        CommandExecutor::getEvaluation().additionalParameter_ = "";
    10501085
     1086        CommandExecutor::getEvaluation().bEvaluatedParams_ = false;
     1087        CommandExecutor::getEvaluation().evaluatedExecutor_ = 0;
     1088
    10511089        CommandExecutor::getEvaluation().listOfPossibleFunctionClasses_.clear();
    10521090        CommandExecutor::getEvaluation().listOfPossibleShortcuts_.clear();
  • code/branches/console/src/core/Functor.h

    r1064 r1188  
    284284#define FUNCTOR_EVALUATE_PARAM0
    285285#define FUNCTOR_EVALUATE_PARAM1 \
    286     if (index == 0) param = (P1)param
     286    if (index == 0) { P1 temp = param; param = temp; }
    287287#define FUNCTOR_EVALUATE_PARAM2 \
    288     if (index == 0) param = (P1)param; \
    289     else if (index == 1) param = (P2)param
     288    if (index == 0) { P1 temp = param; param = temp; } \
     289    else if (index == 1) { P2 temp = param; param = temp; }
    290290#define FUNCTOR_EVALUATE_PARAM3 \
    291     if (index == 0) param = (P1)param; \
    292     else if (index == 1) param = (P2)param; \
    293     else if (index == 2) param = (P3)param
     291    if (index == 0) { P1 temp = param; param = temp; } \
     292    else if (index == 1) { P2 temp = param; param = temp; } \
     293    else if (index == 2) { P3 temp = param; param = temp; }
    294294#define FUNCTOR_EVALUATE_PARAM4 \
    295     if (index == 0) param = (P1)param; \
    296     else if (index == 1) param = (P2)param; \
    297     else if (index == 2) param = (P3)param; \
    298     else if (index == 3) param = (P4)param
     295    if (index == 0) { P1 temp = param; param = temp; } \
     296    else if (index == 1) { P2 temp = param; param = temp; } \
     297    else if (index == 2) { P3 temp = param; param = temp; } \
     298    else if (index == 3) { P4 temp = param; param = temp; }
    299299#define FUNCTOR_EVALUATE_PARAM5 \
    300     if (index == 0) param = (P1)param; \
    301     else if (index == 1) param = (P2)param; \
    302     else if (index == 2) param = (P3)param; \
    303     else if (index == 3) param = (P4)param; \
    304     else if (index == 4) param = (P5)param
     300    if (index == 0) { P1 temp = param; param = temp; } \
     301    else if (index == 1) { P2 temp = param; param = temp; } \
     302    else if (index == 2) { P3 temp = param; param = temp; } \
     303    else if (index == 3) { P4 temp = param; param = temp; } \
     304    else if (index == 4) { P5 temp = param; param = temp; }
    305305
    306306
  • code/branches/console/src/core/TclBind.cc

    r1187 r1188  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Fabian 'x3n' Landau
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
     28
    129#include <iostream>
    230#include <string>
     
    1644    }
    1745
    18     std::string Tcl_unknown(Tcl::object const &a)
     46    std::string Tcl_execute(Tcl::object const &args)
    1947    {
    2048std::cout << "1\n";
    21 std::cout << a.get() << std::endl;
    22         CommandEvaluation evaluation = CommandExecutor::evaluate(std::string(a.get()));
     49std::cout << "args: " << args.get() << std::endl;
     50        std::string command = args.get();
     51        if (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}')
     52            command = command.substr(1, command.size() - 2);
     53        CommandEvaluation evaluation = CommandExecutor::evaluate(command);
    2354std::cout << "2\n";
    24         CommandExecutor::execute(evaluation);
     55        if (!CommandExecutor::execute(evaluation))
     56            COUT(1) << "Error: Can't execute command \"" << command << "\"!" << std::endl;
    2557std::cout << "3\n";
    2658        if (evaluation.hasReturnvalue())
     
    3971            static Tcl::interpreter i;
    4072            i.def("puts", Tcl_puts, Tcl::variadic());
    41             i.def("blub", Tcl_unknown, Tcl::variadic());
     73            i.def("execute", Tcl_execute, Tcl::variadic());
     74            i.eval("proc unknown {args} { return [execute $args] }");
    4275            std::string output = i.eval(tclcode);
    43             COUT(0) << "tcl> " << output << std::endl;
     76            if (output != "")
     77                COUT(0) << "tcl> " << output << std::endl;
    4478            return output;
    4579        }
    4680        catch (Tcl::tcl_error const &e)
    4781        {
    48             COUT(1) << "Error: Tcl: " << e.what() << std::endl;
     82            COUT(1) << "tcl> Error: " << e.what() << std::endl;
    4983        }
    5084        catch (std::exception const &e)
  • code/branches/console/src/core/TclBind.h

    r1187 r1188  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Fabian 'x3n' Landau
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
     28
    129#ifndef _TclBind_H__
    230#define _TclBind_H__
     
    735{
    836    Tcl::interpreter* createNewInterpreter();
    9     void Tcl_puts(Tcl::object const &c);
    10     std::string Tcl_unknown(Tcl::object const &c);
     37    void Tcl_puts(Tcl::object const &args);
     38    std::string Tcl_execute(Tcl::object const &args);
    1139    std::string tcl(const std::string& tclcode);
    1240}
  • code/branches/console/src/orxonox/Orxonox.cc

    r1151 r1188  
    129129  {
    130130  public:
    131     static void calculate(const std::string& calculation)
     131    static float calculate(const std::string& calculation)
    132132    {
    133133      ExprParser expr(calculation);
     
    141141          std::cout << "Warning: Expression could not be parsed to the end! Remains: '"
    142142              << expr.getRemains() << "'" << std::endl;
     143        return expr.getResult();
    143144      }
    144145      else
     146      {
    145147        std::cout << "Cannot calculate expression: Parse error" << std::endl;
     148        return 0;
     149      }
    146150    }
    147151  };
  • code/branches/console/src/orxonox/objects/Ambient.h

    r1056 r1188  
    4848
    4949            static void setAmbientLightTest(const ColourValue& colour)
    50                 { Ambient::instance_s->setAmbientLight(colour); }
     50                { std::cout << "setambientlight: " << colour << std::endl; Ambient::instance_s->setAmbientLight(colour); }
    5151
    5252        private:
Note: See TracChangeset for help on using the changeset viewer.