Skip to content

Commit

Permalink
fix: replace -> replaceAll (#137)
Browse files Browse the repository at this point in the history
* fix: replace -> replaceAll

* fix: fix list definition

* chore: up version
  • Loading branch information
koen1711 authored Nov 8, 2024
1 parent c48b89a commit 44668c7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"dist",
"media"
],
"version": "3.2.4",
"version": "3.2.5",
"description": "Leaphy custom Blockly blocks and arduino code generator",
"name": "@leaphy-robotics/leaphy-blocks"
}
3 changes: 2 additions & 1 deletion src/generators/arduino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ export class Arduino extends Blockly.Generator {
lists.forEach((list) => {
const type = this.TYPES[types[list.id][0] || "Number"];

defLists.push(`List<${type}> ${list.name}`);
const name = list.name.replaceAll(" ", "_");
defLists.push(`List<${type}> ${name}`);
});

if (defLists.length) {
Expand Down
14 changes: 7 additions & 7 deletions src/generators/arduino/lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function getCodeGenerators(arduino: Arduino) {
const value =
arduino.valueToCode(block, "VALUE", arduino.ORDER_ATOMIC) || "0";

const name = list.name.replace(" ", "_");
const name = list.name.replaceAll(" ", "_");
return `${name}.add(${value});\n`;
};

Expand All @@ -16,14 +16,14 @@ function getCodeGenerators(arduino: Arduino) {
const index =
arduino.valueToCode(block, "INDEX", arduino.ORDER_ATOMIC) || "0";

const name = list.name.replace(" ", "_");
const name = list.name.replaceAll(" ", "_");
return `${name}.remove(${index});\n`;
};

arduino.forBlock["lists_clear"] = function (block) {
const list = listManager.getList(block.getFieldValue("LIST")) as List;

const name = list.name.replace(" ", "_");
const name = list.name.replaceAll(" ", "_");
return `${name}.clear();\n`;
};

Expand All @@ -34,7 +34,7 @@ function getCodeGenerators(arduino: Arduino) {
const index =
arduino.valueToCode(block, "INDEX", arduino.ORDER_ATOMIC) || "0";

const name = list.name.replace(" ", "_");
const name = list.name.replaceAll(" ", "_");
return `${name}.addAtIndex(${index}, ${value});\n`;
};

Expand All @@ -43,7 +43,7 @@ function getCodeGenerators(arduino: Arduino) {
const index =
arduino.valueToCode(block, "INDEX", arduino.ORDER_ATOMIC) || "0";

const name = list.name.replace(" ", "_");
const name = list.name.replaceAll(" ", "_");
return [`${name}.get(${index})`, arduino.ORDER_ATOMIC];
};

Expand All @@ -54,14 +54,14 @@ function getCodeGenerators(arduino: Arduino) {
const index =
arduino.valueToCode(block, "INDEX", arduino.ORDER_ATOMIC) || "0";

const name = list.name.replace(" ", "_");
const name = list.name.replaceAll(" ", "_");
return `${name}.remove(${index});\n${list.name}.addAtIndex(${index}, ${value});\n`;
};

arduino.forBlock["lists_length"] = function (block) {
const list = listManager.getList(block.getFieldValue("LIST")) as List;

const name = list.name.replace(" ", "_");
const name = list.name.replaceAll(" ", "_");
return [`${name}.getSize()`, arduino.ORDER_ATOMIC];
};
}
Expand Down

0 comments on commit 44668c7

Please sign in to comment.