Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 19, 2010, 4:57:06 PM (14 years ago)
Author:
landauf
Message:

changed passing of the returnvalue in the command execution pipeline:

  • Functor: operator() directly returns the returnvalue of the executed function (if any, otherwise a MultiType whose null() function evaluates to true). The returnvalue is no longer stored in the Functor.
  • Executor: The same behavior of operator() like in Functor. Additionally the parse() function returns the returnvalue of the executed function instead of a boolean status. The status can be retrieved by passing a pointer to a bool to the function.
  • CommandExecutor: execute() works like before (returns only a boolean status), but added a new function query() which returns the returnvalue of the executed command. The status of query() can be retrieved by optionally passing an pointer to a bool.
  • CommandEvaluation: same as for CommandExecutor: execute() like before, added query()
  • TclBind::eval() returns the returnvalue of the evaluated tcl command. The status can also be retrieved by passing a pointer to a bool.
  • The Shell prints the returnvalue (if available) of an executed command
  • added a constructor to MultiType to directly create it from an mbool. The mbool will be converted to a bool, so it loses it's internal state.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/consolecommands3/src/libraries/core/CommandEvaluation.cc

    r6417 r7189  
    7474    bool CommandEvaluation::execute() const
    7575    {
     76        bool success;
     77        this->query(&success);
     78        return success;
     79    }
     80
     81    MultiType CommandEvaluation::query(bool* success) const
     82    {
     83        if (success)
     84            *success = false;
     85
    7686        if (!this->isValid())
    77             return false;
     87            return MT_Type::Null;
    7888
    7989        if (this->bEvaluatedParams_ && this->function_)
    8090        {
     91            if (success)
     92                *success = true;
    8193            COUT(6) << "CE_execute (evaluation): " << this->function_->getName() << ' ' << this->param_[0] << ' ' << this->param_[1] << ' ' << this->param_[2] << ' ' << this->param_[3] << ' ' << this->param_[4] << std::endl;
    82             (*this->function_)(this->param_[0], this->param_[1], this->param_[2], this->param_[3], this->param_[4]);
    83             return true;
     94            return (*this->function_)(this->param_[0], this->param_[1], this->param_[2], this->param_[3], this->param_[4]);
    8495        }
    8596
     
    90101            unsigned int startindex = this->getStartindex();
    91102            if (this->commandTokens_.size() > startindex)
    92                 return this->function_->parse(removeSlashes(this->commandTokens_.subSet(startindex).join() + this->getAdditionalParameter()));
     103                return this->function_->parse(removeSlashes(this->commandTokens_.subSet(startindex).join() + this->getAdditionalParameter()), success);
    93104            else
    94                 return this->function_->parse(removeSlashes(this->additionalParameter_));
    95         }
    96 
    97         return false;
     105                return this->function_->parse(removeSlashes(this->additionalParameter_), success);
     106        }
     107
     108        return MT_Type::Null;
    98109    }
    99110
     
    233244    }
    234245
    235     bool CommandEvaluation::hasReturnvalue() const
    236     {
    237         if (this->function_)
    238             return this->function_->hasReturnvalue();
    239 
    240         return MT_Type::Null;
    241     }
    242 
    243     MultiType CommandEvaluation::getReturnvalue() const
    244     {
    245         if (this->function_)
    246             return this->function_->getReturnvalue();
    247 
    248         return MultiType();
    249     }
    250 
    251 
    252246    unsigned int CommandEvaluation::getStartindex() const
    253247    {
Note: See TracChangeset for help on using the changeset viewer.