- Timestamp:
- Apr 26, 2008, 2:50:04 AM (17 years ago)
- Location:
- code/branches/console/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/core/CommandExecutor.cc
r1187 r1188 236 236 if (this->shortcut_) 237 237 { 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 } 242 253 } 243 254 } … … 247 258 if (this->function_) 248 259 { 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 } 253 275 } 254 276 } … … 354 376 bool CommandExecutor::execute(const std::string& command) 355 377 { 378 std::cout << "CE_execute: " << command << "\n"; 356 379 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);} 358 382 359 383 return CommandExecutor::execute(CommandExecutor::getEvaluation()); … … 368 392 { 369 393 (*evaluation.evaluatedExecutor_)(evaluation.param_[0], evaluation.param_[1], evaluation.param_[2], evaluation.param_[3], evaluation.param_[4]); 394 return true; 370 395 } 371 396 … … 612 637 { 613 638 CommandExecutor::parse(command, true); 639 std::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 } 648 std::cout << "1_2: " << CommandExecutor::getEvaluation().tokens_[CommandExecutor::getEvaluation().tokens_.size() - 1] << std::endl; 614 649 CommandExecutor::getEvaluation().evaluateParams(); 615 650 return CommandExecutor::getEvaluation(); … … 1049 1084 CommandExecutor::getEvaluation().additionalParameter_ = ""; 1050 1085 1086 CommandExecutor::getEvaluation().bEvaluatedParams_ = false; 1087 CommandExecutor::getEvaluation().evaluatedExecutor_ = 0; 1088 1051 1089 CommandExecutor::getEvaluation().listOfPossibleFunctionClasses_.clear(); 1052 1090 CommandExecutor::getEvaluation().listOfPossibleShortcuts_.clear(); -
code/branches/console/src/core/Functor.h
r1064 r1188 284 284 #define FUNCTOR_EVALUATE_PARAM0 285 285 #define FUNCTOR_EVALUATE_PARAM1 \ 286 if (index == 0) param = (P1)param286 if (index == 0) { P1 temp = param; param = temp; } 287 287 #define FUNCTOR_EVALUATE_PARAM2 \ 288 if (index == 0) param = (P1)param;\289 else if (index == 1) param = (P2)param288 if (index == 0) { P1 temp = param; param = temp; } \ 289 else if (index == 1) { P2 temp = param; param = temp; } 290 290 #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)param291 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; } 294 294 #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)param295 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; } 299 299 #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)param300 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; } 305 305 306 306 -
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 1 29 #include <iostream> 2 30 #include <string> … … 16 44 } 17 45 18 std::string Tcl_ unknown(Tcl::object const &a)46 std::string Tcl_execute(Tcl::object const &args) 19 47 { 20 48 std::cout << "1\n"; 21 std::cout << a.get() << std::endl; 22 CommandEvaluation evaluation = CommandExecutor::evaluate(std::string(a.get())); 49 std::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); 23 54 std::cout << "2\n"; 24 CommandExecutor::execute(evaluation); 55 if (!CommandExecutor::execute(evaluation)) 56 COUT(1) << "Error: Can't execute command \"" << command << "\"!" << std::endl; 25 57 std::cout << "3\n"; 26 58 if (evaluation.hasReturnvalue()) … … 39 71 static Tcl::interpreter i; 40 72 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] }"); 42 75 std::string output = i.eval(tclcode); 43 COUT(0) << "tcl> " << output << std::endl; 76 if (output != "") 77 COUT(0) << "tcl> " << output << std::endl; 44 78 return output; 45 79 } 46 80 catch (Tcl::tcl_error const &e) 47 81 { 48 COUT(1) << " Error: Tcl: " << e.what() << std::endl;82 COUT(1) << "tcl> Error: " << e.what() << std::endl; 49 83 } 50 84 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 1 29 #ifndef _TclBind_H__ 2 30 #define _TclBind_H__ … … 7 35 { 8 36 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); 11 39 std::string tcl(const std::string& tclcode); 12 40 } -
code/branches/console/src/orxonox/Orxonox.cc
r1151 r1188 129 129 { 130 130 public: 131 static voidcalculate(const std::string& calculation)131 static float calculate(const std::string& calculation) 132 132 { 133 133 ExprParser expr(calculation); … … 141 141 std::cout << "Warning: Expression could not be parsed to the end! Remains: '" 142 142 << expr.getRemains() << "'" << std::endl; 143 return expr.getResult(); 143 144 } 144 145 else 146 { 145 147 std::cout << "Cannot calculate expression: Parse error" << std::endl; 148 return 0; 149 } 146 150 } 147 151 }; -
code/branches/console/src/orxonox/objects/Ambient.h
r1056 r1188 48 48 49 49 static void setAmbientLightTest(const ColourValue& colour) 50 { Ambient::instance_s->setAmbientLight(colour); }50 { std::cout << "setambientlight: " << colour << std::endl; Ambient::instance_s->setAmbientLight(colour); } 51 51 52 52 private:
Note: See TracChangeset
for help on using the changeset viewer.