diff --git a/.будущее.swp b/.будущее.swp new file mode 100644 index 0000000..539086c Binary files /dev/null and b/.будущее.swp differ diff --git a/iOS/app/MMMemory.xcodeproj/project.pbxproj b/iOS/app/MMMemory.xcodeproj/project.pbxproj index f27b9e8..46589d3 100644 --- a/iOS/app/MMMemory.xcodeproj/project.pbxproj +++ b/iOS/app/MMMemory.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ 1F083A14C69F20A6BA92A63E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F16A7DD61EF6CD4FB4E3DE25 /* AppDelegate.swift */; }; 3D03666F3BC2B1F2CBB49530 /* Main.SectionSelection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D5F2B2E3A26F03F6825608E /* Main.SectionSelection.swift */; }; + 3EA747EF132EF00B60CE3BA8 /* memorySide.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17E6ABD013AB08F7DF11C069 /* memorySide.swift */; }; 79FB208C9DADDA6179E588C3 /* Main.SectionGrid.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AC22F19366076CF4168BFBD /* Main.SectionGrid.swift */; }; 89086E3972F560A9A1A76CE4 /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C71EDBDFFDBC96F6E8E7762 /* Model.swift */; }; A8118182ABE97FA935A1A4F9 /* model.iOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3A95F2FA5C43AF82C7A97FC /* model.iOS.swift */; }; @@ -21,6 +22,7 @@ /* Begin PBXFileReference section */ 0DF762100A8EDF105B6E136D /* Main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Main.swift; sourceTree = ""; }; + 17E6ABD013AB08F7DF11C069 /* memorySide.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = memorySide.swift; sourceTree = ""; }; 4E32B0495E4BCEA4EE0508D4 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = ""; }; 6D5F2B2E3A26F03F6825608E /* Main.SectionSelection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Main.SectionSelection.swift; sourceTree = ""; }; 9AC22F19366076CF4168BFBD /* Main.SectionGrid.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Main.SectionGrid.swift; sourceTree = ""; }; @@ -34,6 +36,15 @@ /* End PBXFileReference section */ /* Begin PBXGroup section */ + 44681273C081F5991624384F /* Swift */ = { + isa = PBXGroup; + children = ( + 17E6ABD013AB08F7DF11C069 /* memorySide.swift */, + ); + name = Swift; + path = ../../shared/Swift; + sourceTree = ""; + }; 4F93BC5459F4AF4391816D4A /* shared */ = { isa = PBXGroup; children = ( @@ -73,6 +84,7 @@ children = ( 4F93BC5459F4AF4391816D4A /* shared */, 667BC26EA8068A9FA707FC02 /* src */, + 44681273C081F5991624384F /* Swift */, AE7B74413EC292E802CC5C70 /* Products */, ); sourceTree = ""; @@ -146,6 +158,7 @@ 3D03666F3BC2B1F2CBB49530 /* Main.SectionSelection.swift in Sources */, DB1010B8A246D47BEC6B3FA6 /* Main.swift in Sources */, 89086E3972F560A9A1A76CE4 /* Model.swift in Sources */, + 3EA747EF132EF00B60CE3BA8 /* memorySide.swift in Sources */, A8118182ABE97FA935A1A4F9 /* model.iOS.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/iOS/app/MMMemory.xcodeproj/project.xcworkspace/xcuserdata/mk.xcuserdatad/UserInterfaceState.xcuserstate b/iOS/app/MMMemory.xcodeproj/project.xcworkspace/xcuserdata/mk.xcuserdatad/UserInterfaceState.xcuserstate index 6b331be..8fcc543 100644 Binary files a/iOS/app/MMMemory.xcodeproj/project.xcworkspace/xcuserdata/mk.xcuserdatad/UserInterfaceState.xcuserstate and b/iOS/app/MMMemory.xcodeproj/project.xcworkspace/xcuserdata/mk.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/iOS/app/project.yml b/iOS/app/project.yml index 4cd13c3..2948c0d 100644 --- a/iOS/app/project.yml +++ b/iOS/app/project.yml @@ -8,6 +8,7 @@ targets: deploymentTarget: "16.0" sources: - path: "../src" + - path: "../../shared/Swift" - path: "../../shared/model.iOS.swift" settings: base: diff --git a/shared/Swift/memorySide.swift b/shared/Swift/memorySide.swift new file mode 100644 index 0000000..6b4fa62 --- /dev/null +++ b/shared/Swift/memorySide.swift @@ -0,0 +1,3 @@ +func memorySide() -> Float { + return 50 +} diff --git a/shared/model.iOS.swift b/shared/model.iOS.swift index 044f484..86e4a9a 100644 --- a/shared/model.iOS.swift +++ b/shared/model.iOS.swift @@ -1,7 +1,3 @@ -func memorySide() -> Float { - return 50 -} - func memorySpace() -> Float { return 20 } diff --git a/toSwift b/toSwift index 077f6bf..a4b082c 100755 --- a/toSwift +++ b/toSwift @@ -1,3 +1,41 @@ #!/usr/bin/env node -console.log("Converting to Swift"); +if (process.argv.length < 4) { + console.error("Usage: toSwift SRC DST"); + process.exit(1); +} + +var fs = require("fs"); + +let fileSrc = process.argv[2]; +let fileDst = process.argv[3]; + +let replacements = { + "function": "func", + "number": "Float", + "):": ") ->", +}; + +console.log(`Converting '${fileSrc}' to '${fileDst}'`); + +var linesDst = []; +let linesSrc = fs.readFileSync(fileSrc).toString().split(/\r?\n/); +for (let i in linesSrc) { + let ln = linesSrc[i]; + linesDst.push(convert(ln)); +} + +let contentsDst = linesDst.join("\r\n"); +fs.writeFileSync(fileDst, contentsDst); + + +// Functions making decisions. + +function convert(line) { + var result = line; + for (let src in replacements) { + let dst = replacements[src]; + result = result.replace(src, dst); + } + return result; +} diff --git a/будущее b/будущее index 73197af..c118268 100644 --- a/будущее +++ b/будущее @@ -1,8 +1,15 @@ -НАДО: -* принимать на вход в toSwift аргументы +01.06: 19.20- + * сообщать Usage +* принимать на вход в toSwift аргументы +* вывести файл построчно +* ввести словарь замен + +НАДО: +* сохранять в файл * конвертить memorySide из TS в Swift * генерить memorySide.swift * генерить остальные функции-константы +* использовать сгенеренные js и swift в проектах * ввести общую библиотеку * генерить itemPositions