From 7e2121865e926b7dee2d938e380721e67504a7d1 Mon Sep 17 00:00:00 2001 From: AKosylo Date: Thu, 19 Oct 2023 16:55:43 +0200 Subject: [PATCH] Arguments: WIP --- DXFeedFramework.xcodeproj/project.pbxproj | 10 ++- .../ArgumentParser.swift | 2 + Samples/PerfTestCL/Arguments.swift | 65 +++++++++++++++++++ Samples/PerfTestCL/ConnectCommand.swift | 42 +----------- Samples/PerfTestCL/DumpCommand.swift | 3 +- 5 files changed, 78 insertions(+), 44 deletions(-) rename Samples/{Utils => PerfTestCL}/ArgumentParser.swift (99%) create mode 100644 Samples/PerfTestCL/Arguments.swift diff --git a/DXFeedFramework.xcodeproj/project.pbxproj b/DXFeedFramework.xcodeproj/project.pbxproj index 6459e0e48..343f35172 100644 --- a/DXFeedFramework.xcodeproj/project.pbxproj +++ b/DXFeedFramework.xcodeproj/project.pbxproj @@ -315,6 +315,7 @@ 64D8BB452A39BB730071BC88 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 64D8BB432A39BB730071BC88 /* Main.storyboard */; }; 64D8BB472A39BB740071BC88 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 64D8BB462A39BB740071BC88 /* Assets.xcassets */; }; 64D8BB4A2A39BB740071BC88 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 64D8BB482A39BB740071BC88 /* LaunchScreen.storyboard */; }; + 64D8C9522AE17739009E4799 /* Arguments.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64D8C9512AE17739009E4799 /* Arguments.swift */; }; 64DA26B62AA1EF47005B1757 /* DXProfileIterator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64DA26B52AA1EF47005B1757 /* DXProfileIterator.swift */; }; 64DA26B82AA20095005B1757 /* NativeInstrumentProfileConnection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64DA26B72AA20095005B1757 /* NativeInstrumentProfileConnection.swift */; }; 64DA26BA2AA20AAA005B1757 /* DXInstrumentProfileConnectionState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64DA26B92AA20AAA005B1757 /* DXInstrumentProfileConnectionState.swift */; }; @@ -779,6 +780,7 @@ 64D8BB462A39BB740071BC88 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 64D8BB492A39BB740071BC88 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 64D8BB4B2A39BB740071BC88 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 64D8C9512AE17739009E4799 /* Arguments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Arguments.swift; sourceTree = ""; }; 64DA26B52AA1EF47005B1757 /* DXProfileIterator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DXProfileIterator.swift; sourceTree = ""; }; 64DA26B72AA20095005B1757 /* NativeInstrumentProfileConnection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeInstrumentProfileConnection.swift; sourceTree = ""; }; 64DA26B92AA20AAA005B1757 /* DXInstrumentProfileConnectionState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DXInstrumentProfileConnectionState.swift; sourceTree = ""; }; @@ -931,6 +933,8 @@ children = ( 64148B6E2ABB5C4A0063110E /* PerfTestCL.entitlements */, 64148B662ABB5C320063110E /* main.swift */, + 64D8C9512AE17739009E4799 /* Arguments.swift */, + 647426AC2ABC85F20012F793 /* ArgumentParser.swift */, 647426A62ABC7F080012F793 /* ConnectEventListener.swift */, 645BE8532AC3229D0028243D /* ToolsCommand.swift */, 641BDD572AC71CCE00236B78 /* LatencyTestCommand.swift */, @@ -1165,7 +1169,6 @@ 6469F8CB2A3B2F1200846831 /* MetricCell.swift */, 646D19E02A3C970700C82315 /* DXFTimer.swift */, 646979712A3B5AF60003A9BA /* Colors.xcassets */, - 647426AC2ABC85F20012F793 /* ArgumentParser.swift */, 647426AE2ABC93900012F793 /* EventCode+String.swift */, 649282E62AD54919008F0F04 /* ScheduleUtils.swift */, ); @@ -1977,6 +1980,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 64D8C9522AE17739009E4799 /* Arguments.swift in Sources */, 648BD56D2AC56A04004A3A95 /* SubscriptionUtils.swift in Sources */, 648BD56B2AC4576F004A3A95 /* HelpCommand.swift in Sources */, 649282E82AD54919008F0F04 /* ScheduleUtils.swift in Sources */, @@ -2869,7 +2873,7 @@ INFOPLIST_KEY_UIMainStoryboardFile = Main; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -2900,7 +2904,7 @@ INFOPLIST_KEY_UIMainStoryboardFile = Main; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/Samples/Utils/ArgumentParser.swift b/Samples/PerfTestCL/ArgumentParser.swift similarity index 99% rename from Samples/Utils/ArgumentParser.swift rename to Samples/PerfTestCL/ArgumentParser.swift index 8ad68a7a8..6031008ad 100644 --- a/Samples/Utils/ArgumentParser.swift +++ b/Samples/PerfTestCL/ArgumentParser.swift @@ -25,4 +25,6 @@ Cmd \(cmd) contains not enough \(cmd.count - 1) arguments. Expected \(requiredNu // 0 Arg is path to executed app return Array(cmd[1.. [String] { + let symbols = arguments[symbolPosition] + var symbolsList = [String]() + func addSymbol(str: String) { + if str.hasPrefix("ipf[") && str.hasSuffix("]") { + if let address = str.slice(from: "[", to: "]") { + let profiles = try? DXInstrumentProfileReader().readFromFile(address: address) + profiles?.forEach({ profile in + symbolsList.append(profile.symbol) + }) + } + } else { + symbolsList.append(str) + } + } + var parentheses = 0 + var tempSrting = "" + symbols.forEach { character in + switch character { + case "{", "(", "[": + parentheses += 1 + tempSrting.append(character) + case "}", ")", "]": + if parentheses > 0 { + parentheses -= 1 + } + tempSrting.append(character) + case ",": + if parentheses == 0 { + addSymbol(str: tempSrting) + tempSrting = "" + } else { + tempSrting.append(character) + } + default: + tempSrting.append(character) + } + } + + addSymbol(str: tempSrting) + return symbolsList + } +} diff --git a/Samples/PerfTestCL/ConnectCommand.swift b/Samples/PerfTestCL/ConnectCommand.swift index 8d7a303ae..15f7436e8 100644 --- a/Samples/PerfTestCL/ConnectCommand.swift +++ b/Samples/PerfTestCL/ConnectCommand.swift @@ -53,50 +53,12 @@ Where: let address = arguments[1] let types = arguments[2] - let symbols = arguments[3] - var symbolsList = [String]() - func addSymbol(str: String) { - if str.hasPrefix("ipf[") && str.hasSuffix("]") { - if let address = str.slice(from: "[", to: "]") { - let profiles = try? DXInstrumentProfileReader().readFromFile(address: address) - profiles?.forEach({ profile in - symbolsList.append(profile.symbol) - }) - } - } else { - symbolsList.append(str) - } - } - var parentheses = 0 - var tempSrting = "" - symbols.forEach { character in - switch character { - case "{", "(", "[": - parentheses += 1 - tempSrting.append(character) - case "}", ")", "]": - if parentheses > 0 { - parentheses -= 1 - } - tempSrting.append(character) - case ",": - if parentheses == 0 { - addSymbol(str: tempSrting) - tempSrting = "" - } else { - tempSrting.append(character) - } - default: - tempSrting.append(character) - } - } - - addSymbol(str: tempSrting) var time: String? if arguments.count > 4 { time = arguments[4] } - + let argumentsObj = Arguments(arguments: arguments, symbolPosition: 3) + let symbolsList = argumentsObj.parseSymbols() let listener = ConnectEventListener() subscription.createSubscription(address: address, symbols: symbolsList, diff --git a/Samples/PerfTestCL/DumpCommand.swift b/Samples/PerfTestCL/DumpCommand.swift index 523d92a3d..0a12f226f 100644 --- a/Samples/PerfTestCL/DumpCommand.swift +++ b/Samples/PerfTestCL/DumpCommand.swift @@ -40,7 +40,8 @@ class DumpCommand: ToolsCommand { } let address = arguments[1] let types = arguments[2] - let symbols = arguments[3].components(separatedBy: ",") + let argumentsObj = Arguments(arguments: arguments, symbolPosition: 3) + let symbols = argumentsObj.parseSymbols() var tapeFile: String? if let tapeIndex = arguments.firstIndex(of: "-t") {