Сценарий: Преобразование fmt.Sprint() -> std::to_string()

Этот коммит содержится в:
Softonik 2024-02-13 02:22:49 +03:00 коммит произвёл Nobody
родитель 9fb0182784
коммит 1d4f9eff3d
3 изменённых файлов: 25 добавлений и 4 удалений

Просмотреть файл

@ -543,4 +543,25 @@ Serial.println("Connecting ...");
Serial.println("Connected!");
}
void loop() {}
```
Сценарий: Преобразование fmt.Sprint() -> std::to_string()
* Исходник:
```
package test
func Setup() {
a := ""
a += fmt.Sprint(5)
a += "A " + fmt.Sprint(19) + " A " + fmt.Sprint(a)
}
```
* Результат:
```
void setup();
void setup() {
std::string a="";
a+=std::to_string(5);
a+="A "+std::to_string(19)+" A "+std::to_string(a);
}
```

Просмотреть файл

@ -112,16 +112,15 @@ func handleFuncDeclType(t *ast.FuncType) string {
return code
}
func handleFuncDeclName(ident *ast.Ident) string {
code := ""
func handleFuncDeclName(ident *ast.Ident) (code string) {
if ident == nil {
return code
return
}
code += ident.Name
if val, ok := mapping[code]; ok {
code = val
}
return code
return
}
func handleFuncDeclParams(t *ast.FuncType) string {

Просмотреть файл

@ -1,6 +1,7 @@
package service
var mapping = map[string]string{
"fmt.Sprint": "std::to_string",
"digital.Low": "LOW",
"digital.High": "HIGH",
"digital.ModeInput": "INPUT",