Михаил Капелько 11 months ago
parent
commit
1bc0a11aeb
8 changed files with 86 additions and 42 deletions
  1. +8
    -16
      iOS/app/MMMemory.xcodeproj/project.pbxproj
  2. BIN
      iOS/app/MMMemory.xcodeproj/project.xcworkspace/xcuserdata/mk.xcuserdatad/UserInterfaceState.xcuserstate
  3. +1
    -1
      iOS/app/project.yml
  4. +1
    -1
      shared/gen
  5. +32
    -0
      shared/swift.swift
  6. +20
    -3
      toSwift
  7. +6
    -21
      будущее
  8. +18
    -0
      прошлое

+ 8
- 16
iOS/app/MMMemory.xcodeproj/project.pbxproj View File

@@ -8,13 +8,11 @@

/* Begin PBXBuildFile section */
1F083A14C69F20A6BA92A63E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F16A7DD61EF6CD4FB4E3DE25 /* AppDelegate.swift */; };
248FA3B7A82DA60E6892F821 /* memorySpace.swift in Sources */ = {isa = PBXBuildFile; fileRef = 490862345F009401FB4E1199 /* memorySpace.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 */; };
7B6D5211C387213AE05C080F /* memoryGap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9994AEAC20F4AB2DA70C9840 /* memoryGap.swift */; };
89086E3972F560A9A1A76CE4 /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C71EDBDFFDBC96F6E8E7762 /* Model.swift */; };
B19B3998FA2BA651ACB1E53C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C1742EFC5A1E818780679340 /* Assets.xcassets */; };
BE2994BF2FFF272E62883953 /* swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = D414A6174931F533B0B286E8 /* swift.swift */; };
CAFD870CA84084E45011CC23 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4E32B0495E4BCEA4EE0508D4 /* LaunchScreen.storyboard */; };
D505E64F4CD6EAEB530BF851 /* Main.Section16Buttons.swift in Sources */ = {isa = PBXBuildFile; fileRef = A38A1AA6B57483F6B44CDF78 /* Main.Section16Buttons.swift */; };
DB1010B8A246D47BEC6B3FA6 /* Main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DF762100A8EDF105B6E136D /* Main.swift */; };
@@ -23,30 +21,26 @@

/* Begin PBXFileReference section */
0DF762100A8EDF105B6E136D /* Main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Main.swift; sourceTree = "<group>"; };
17E6ABD013AB08F7DF11C069 /* memorySide.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = memorySide.swift; sourceTree = "<group>"; };
490862345F009401FB4E1199 /* memorySpace.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = memorySpace.swift; sourceTree = "<group>"; };
4E32B0495E4BCEA4EE0508D4 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
6D5F2B2E3A26F03F6825608E /* Main.SectionSelection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Main.SectionSelection.swift; sourceTree = "<group>"; };
9994AEAC20F4AB2DA70C9840 /* memoryGap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = memoryGap.swift; sourceTree = "<group>"; };
9AC22F19366076CF4168BFBD /* Main.SectionGrid.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Main.SectionGrid.swift; sourceTree = "<group>"; };
9C71EDBDFFDBC96F6E8E7762 /* Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Model.swift; sourceTree = "<group>"; };
9D774FEE86833E8A0A74387C /* App.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; };
A355A898E25602F45B88CCBA /* Main.Platform.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Main.Platform.swift; sourceTree = "<group>"; };
A38A1AA6B57483F6B44CDF78 /* Main.Section16Buttons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Main.Section16Buttons.swift; sourceTree = "<group>"; };
C1742EFC5A1E818780679340 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
D414A6174931F533B0B286E8 /* swift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = swift.swift; sourceTree = "<group>"; };
F16A7DD61EF6CD4FB4E3DE25 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXGroup section */
44681273C081F5991624384F /* Swift */ = {
4F93BC5459F4AF4391816D4A /* shared */ = {
isa = PBXGroup;
children = (
9994AEAC20F4AB2DA70C9840 /* memoryGap.swift */,
17E6ABD013AB08F7DF11C069 /* memorySide.swift */,
490862345F009401FB4E1199 /* memorySpace.swift */,
D414A6174931F533B0B286E8 /* swift.swift */,
);
name = Swift;
path = ../../shared/Swift;
name = shared;
path = ../../shared;
sourceTree = "<group>";
};
667BC26EA8068A9FA707FC02 /* src */ = {
@@ -77,8 +71,8 @@
CD7F0F0C9CA1BA5EAFD5CA09 = {
isa = PBXGroup;
children = (
4F93BC5459F4AF4391816D4A /* shared */,
667BC26EA8068A9FA707FC02 /* src */,
44681273C081F5991624384F /* Swift */,
AE7B74413EC292E802CC5C70 /* Products */,
);
sourceTree = "<group>";
@@ -152,9 +146,7 @@
3D03666F3BC2B1F2CBB49530 /* Main.SectionSelection.swift in Sources */,
DB1010B8A246D47BEC6B3FA6 /* Main.swift in Sources */,
89086E3972F560A9A1A76CE4 /* Model.swift in Sources */,
7B6D5211C387213AE05C080F /* memoryGap.swift in Sources */,
3EA747EF132EF00B60CE3BA8 /* memorySide.swift in Sources */,
248FA3B7A82DA60E6892F821 /* memorySpace.swift in Sources */,
BE2994BF2FFF272E62883953 /* swift.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};


BIN
iOS/app/MMMemory.xcodeproj/project.xcworkspace/xcuserdata/mk.xcuserdatad/UserInterfaceState.xcuserstate View File


+ 1
- 1
iOS/app/project.yml View File

@@ -8,7 +8,7 @@ targets:
deploymentTarget: "16.0"
sources:
- path: "../src"
- path: "../../shared/Swift"
- path: "../../shared/swift.swift"
settings:
base:
INFOPLIST_FILE: Info.plist

+ 1
- 1
shared/gen View File

@@ -3,5 +3,5 @@
SCRIPT_DIR=$(cd "$(dirname "$0")" ; pwd -P)

tsc $SCRIPT_DIR/typeScript.ts --outfile $SCRIPT_DIR/javaScript.js
#$SCRIPT_DIR/../toSwift $SCRIPT_DIR/typeScript.ts $SCRIPT_DIR/swift.swift
$SCRIPT_DIR/../toSwift $SCRIPT_DIR/typeScript.ts $SCRIPT_DIR/swift.swift


+ 32
- 0
shared/swift.swift View File

@@ -0,0 +1,32 @@
protocol Context {
var itemsCount: Float { get }
}
protocol Position {
var x: Float { get }
var y: Float { get }
}
func memoryGap() -> Float {
return memorySide() + memorySpace()
}
func memorySide() -> Float {
return 50
}
func memorySpace() -> Float {
return 20
}
func memoryItemPositions(c: Context) -> [Position] {
var pos: [Position] = []
for (var i = 0; i < c.itemsCount; i++) {
let row = Math.floor(i / 4)
let x = memoryGap() + (i - row * 4) * memoryGap()
let y = memoryGap() + row * memoryGap()
// @ts-ignore
pos.push(memoryCreatePosition(x, y))
}
return pos
}

+ 20
- 3
toSwift View File

@@ -39,6 +39,7 @@ function convert(line) {
result = result.replace(src, dst);
}
result = protocolReplace(result);
result = typeArrayReplace(result);
return result;
}

@@ -51,7 +52,6 @@ function protocolReplace(line) {
if (line == "}") {
isProtocol = false;
}
console.log("ИГР protocolR-1 isP/line:", isProtocol, line);
if (!isProtocol) {
return line;
}
@@ -60,7 +60,6 @@ function protocolReplace(line) {
if (isProtocol) {
result = protocolReplaceVariable(result);
}
console.log("ИГР protocolR-2 isP/line:", isProtocol, line);
return result;
}

@@ -71,8 +70,26 @@ function protocolReplaceVariable(line) {
let name = parts[0].trim();
let spaceLength = parts[0].length - name.length;
let spaces = " ".repeat(spaceLength);
//console.log("Variable. name/spaceL/parts:", name, spaceLength, parts);
return `${spaces}var ${name}: ${type} { get }`;
}
return line;
}

// func memoryItemPositions(c: Context) -> Position[] {
// var pos: Position[] = []

function typeArrayReplace(line) {
let parts = line.split(" ");
for (var i in parts) {
let part = parts[i];
if (
part != "[]" &&
part.endsWith("[]")
) {
let type = part.substring(0, part.length - 2)
let swiftType = `[${type}]`;
return line.replace(part, swiftType);
}
}
return line;
}

+ 6
- 21
будущее View File

@@ -1,25 +1,10 @@
08.06: 19:30-

* перейти на один файл ts
* перейти на один файл js
* оставить в файле ts лишь interfaces
* ввести внешние функции создания экземпляров интерфейсов в js
* web/platform.js

НАДО:
* конвертировать for loop
* конвертить Math.floor
* перейти на один файл swift
* генерить по одному файлу в shared
* в проектах ссылаться по одному файлу
* исправить ошибку tsc: cannot find name
* в shared помещать лишь функции и интерфейсы без объявления типов
* ибо дофига работы
* генерить class в Swift?
* нет struct, к сожалению
* может, стоит остановиться и на протоколах/интерфейсах?
* генерить memoryItemPositions.swift
* генерить библиотеку на основе иных replacements
* ввести общую библиотеку
* генерить itemPositions
* оптимизация
* разделить функции на разные файлы
* будет ошибка tsc: cannot find name
* ввести общую библиотеку?

* в конце: разделить функции на разные файлы
* будет ошибка tsc: cannot find name, так что придётся покумекать

+ 18
- 0
прошлое View File

@@ -1,3 +1,21 @@
08.06: 30

* перейти на один файл ts
* перейти на один файл js
* оставить в файле ts лишь interfaces
* ввести внешние функции создания экземпляров интерфейсов в js
* web/platform.js
* конвертировать Position[]
* генерить по одному файлу в shared
* в проектах ссылаться по одному файлу
* исправить ошибку tsc: cannot find name
* в shared помещать лишь функции и интерфейсы без объявления типов
* ибо дофига работы
* генерить class в Swift?
* нет struct, к сожалению
* может, стоит остановиться и на протоколах/интерфейсах?
* да

06.06: 25

* починить ^M


Loading…
Cancel
Save