- Timestamp:
- Aug 26, 2010, 2:06:16 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/consolecommands3/src/libraries/core/command/CommandExecutor.cc
r7216 r7221 49 49 } 50 50 51 const CommandEvaluation& CommandExecutor::getLastEvaluation()52 {53 return CommandExecutor::getInstance().evaluation_;54 }55 56 51 bool CommandExecutor::execute(const std::string& command, bool useTcl) 57 52 { … … 216 211 CommandExecutor::getEvaluation().functionclass_ = 0; 217 212 CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().function_->getName(); 218 if (CommandExecutor::getEvaluation().function_->get ParamCount() > 0)213 if (CommandExecutor::getEvaluation().function_->getExecutor()->getParamCount() > 0) 219 214 { 220 215 CommandExecutor::getEvaluation().command_ += ' '; … … 303 298 CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation; 304 299 CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + ' ' + CommandExecutor::getEvaluation().function_->getName(); 305 if (CommandExecutor::getEvaluation().function_->get ParamCount() > 0)300 if (CommandExecutor::getEvaluation().function_->getExecutor()->getParamCount() > 0) 306 301 { 307 302 CommandExecutor::getEvaluation().command_ += ' '; … … 335 330 case CommandState::ParamPreparation: 336 331 { 337 if (CommandExecutor::getEvaluation().function_->get ParamCount() == 0 || CommandExecutor::enoughArgumentsGiven(CommandExecutor::getEvaluation().function_))332 if (CommandExecutor::getEvaluation().function_->getExecutor()->getParamCount() == 0 || CommandExecutor::enoughArgumentsGiven(CommandExecutor::getEvaluation().function_)) 338 333 { 339 334 CommandExecutor::getEvaluation().state_ = CommandState::Finished; … … 418 413 } 419 414 420 bool CommandExecutor::enoughArgumentsGiven( ConsoleCommand* command)415 bool CommandExecutor::enoughArgumentsGiven(_ConsoleCommand* command) 421 416 { 422 417 if (CommandExecutor::getEvaluation().functionclass_) 423 return (CommandExecutor::argumentsGiven() > (2 + command->get ParamCount()));424 else 425 return (CommandExecutor::argumentsGiven() > (1 + command->get ParamCount()));418 return (CommandExecutor::argumentsGiven() > (2 + command->getExecutor()->getParamCount())); 419 else 420 return (CommandExecutor::argumentsGiven() > (1 + command->getExecutor()->getParamCount())); 426 421 } 427 422 … … 441 436 void CommandExecutor::createListOfPossibleIdentifiers(const std::string& fragment) 442 437 { 438 /* 443 439 CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.clear(); 444 440 const std::string& lowercase = getLowercase(fragment); … … 447 443 if (it->first.find(lowercase) == 0 || fragment.empty()) 448 444 CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.push_back(std::pair<const std::string*, const std::string*>(&it->first, &it->second->getName())); 445 */ 449 446 } 450 447 451 448 void CommandExecutor::createListOfPossibleFunctions(const std::string& fragment, Identifier* identifier) 452 449 { 450 /* 453 451 CommandExecutor::getEvaluation().listOfPossibleFunctions_.clear(); 454 452 const std::string& lowercase = getLowercase(fragment); 455 453 if (!identifier) 456 454 { 457 for (std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMapBegin(); it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd(); ++it)455 for (std::map<std::string, _ConsoleCommand*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMapBegin(); it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd(); ++it) 458 456 if (it->first.find(lowercase) == 0 || fragment.empty()) 459 457 CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&it->first, &it->second->getName())); … … 461 459 else 462 460 { 463 for (std::map<std::string, ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMapBegin(); it != identifier->getLowercaseConsoleCommandMapEnd(); ++it)461 for (std::map<std::string, _ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMapBegin(); it != identifier->getLowercaseConsoleCommandMapEnd(); ++it) 464 462 if (it->first.find(lowercase) == 0 || fragment.empty()) 465 463 CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&it->first, &it->second->getName())); 466 464 } 467 } 468 469 void CommandExecutor::createListOfPossibleArguments(const std::string& fragment, ConsoleCommand* command, unsigned int param) 470 { 465 */ 466 } 467 468 void CommandExecutor::createListOfPossibleArguments(const std::string& fragment, _ConsoleCommand* command, unsigned int param) 469 { 470 /* 471 471 CommandExecutor::createArgumentCompletionList(command, param); 472 472 … … 486 486 } 487 487 } 488 */ 488 489 } 489 490 490 491 Identifier* CommandExecutor::getPossibleIdentifier(const std::string& name) 491 492 { 493 /* 492 494 const std::string& lowercase = getLowercase(name); 493 495 std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMap().find(lowercase); 494 496 if ((it != Identifier::getLowercaseStringIdentifierMapEnd()) && it->second->hasConsoleCommands()) 495 497 return it->second; 496 498 */ 497 499 return 0; 498 500 } 499 501 500 ConsoleCommand* CommandExecutor::getPossibleCommand(const std::string& name, Identifier* identifier) 501 { 502 _ConsoleCommand* CommandExecutor::getPossibleCommand(const std::string& name, Identifier* identifier) 503 { 504 /* 502 505 const std::string& lowercase = getLowercase(name); 503 506 if (!identifier) 504 507 { 505 std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMap().find(lowercase);508 std::map<std::string, _ConsoleCommand*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMap().find(lowercase); 506 509 if (it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd()) 507 510 return it->second; … … 509 512 else 510 513 { 511 std::map<std::string, ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMap().find(lowercase);514 std::map<std::string, _ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMap().find(lowercase); 512 515 if (it != identifier->getLowercaseConsoleCommandMapEnd()) 513 516 return it->second; 514 517 } 518 */ 515 519 return 0; 516 520 } 517 521 518 const std::string& CommandExecutor::getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param) 519 { 522 const std::string& CommandExecutor::getPossibleArgument(const std::string& name, _ConsoleCommand* command, unsigned int param) 523 { 524 /* 520 525 CommandExecutor::createArgumentCompletionList(command, param); 521 526 … … 534 539 } 535 540 } 536 541 */ 537 542 return BLANKSTRING; 538 543 } 539 544 540 void CommandExecutor::createArgumentCompletionList(ConsoleCommand* command, unsigned int param) 541 { 545 void CommandExecutor::createArgumentCompletionList(_ConsoleCommand* command, unsigned int param) 546 { 547 /* 542 548 std::string params[5]; 543 549 … … 554 560 555 561 command->createArgumentCompletionList(param, params[0], params[1], params[2], params[3], params[4]); 562 */ 556 563 } 557 564 … … 643 650 } 644 651 } 645 646 void CommandExecutor::destroyExternalCommands()647 {648 for (std::set<ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandExternals_.begin();649 it != CommandExecutor::getInstance().consoleCommandExternals_.end(); ++it)650 delete *it;651 }652 652 }
Note: See TracChangeset
for help on using the changeset viewer.