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/TclBind.cc

    r7174 r7189  
    134134        const std::string& command = stripEnclosingBraces(args.get());
    135135
    136         if (!CommandExecutor::execute(command, false))
     136        bool success;
     137        const std::string& result = CommandExecutor::query(command, &success, false);
     138        if (!success)
    137139        {
    138140            COUT(1) << "Error: Can't execute command \"" << command << "\"!" << std::endl;
    139141        }
    140142
    141         if (CommandExecutor::getLastEvaluation().hasReturnvalue())
    142             return CommandExecutor::getLastEvaluation().getReturnvalue().getString();
    143 
    144         return "";
     143        return result;
    145144    }
    146145
     
    181180    }
    182181
    183     bool TclBind::eval(const std::string& tclcode)
     182    std::string TclBind::eval(const std::string& tclcode, bool* success)
    184183    {
     184        if (success)
     185            *success = true;
     186
    185187        try
    186188        {
    187             TclBind::getInstance().interpreter_->eval(tclcode);
    188             return true;
     189            return TclBind::getInstance().interpreter_->eval(tclcode);
    189190        }
    190191        catch (Tcl::tcl_error const &e)
    191192        {   COUT(1) << "Tcl error: " << e.what() << std::endl;   }
    192193
    193         return false;
     194        if (success)
     195            *success = false;
     196        return "";
    194197    }
    195198}
Note: See TracChangeset for help on using the changeset viewer.