d
This commit is contained in:
23
toSwift
23
toSwift
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user