| 382 | DebugCommandsService DebugCommandsServiceInstance; |
| 383 | |
| 384 | void DebugCommands::Execute(StringView command) |
| 385 | { |
| 386 | PROFILE_MEM(EngineDebug); |
| 387 | // TODO: fix missing string handle on 1st command execution (command gets invalid after InitCommands due to dotnet GC or dotnet interop handles flush) |
| 388 | String commandCopy = command; |
| 389 | command = commandCopy; |
| 390 | |
| 391 | // Preprocess command text |
| 392 | while (command.HasChars() && StringUtils::IsWhitespace(command[0])) |
| 393 | command = StringView(command.Get() + 1, command.Length() - 1); |
| 394 | while (command.HasChars() && StringUtils::IsWhitespace(command[command.Length() - 1])) |
| 395 | command = StringView(command.Get(), command.Length() - 1); |
| 396 | if (command.IsEmpty()) |
| 397 | return; |
| 398 | StringView name = command; |
| 399 | StringView args; |
| 400 | int32 argsStart = name.Find(' '); |
| 401 | if (argsStart != -1) |
| 402 | { |
| 403 | name = command.Left(argsStart); |
| 404 | args = command.Right(argsStart + 1); |
| 405 | } |
| 406 | |
| 407 | // Ensure that commands cache has been created |
| 408 | EnsureInited(); |
| 409 | ScopeLock lock(Locker); |
| 410 | |
| 411 | // Find command to run |
| 412 | for (const CommandData& cmd : Commands) |
| 413 | { |
| 414 | if (name.Length() == cmd.Name.Length() && |
| 415 | StringUtils::CompareIgnoreCase(name.Get(), cmd.Name.Get(), name.Length()) == 0) |
| 416 | { |
| 417 | cmd.Invoke(args); |
| 418 | return; |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | LOG(Error, "Unknown command '{}'", name); |
| 423 | } |
| 424 | |
| 425 | void DebugCommands::Search(StringView searchText, Array<StringView>& matches, bool startsWith) |
| 426 | { |
nothing calls this directly
no test coverage detected