Сценарий: Структура с неск полями, строки - std::string
Этот коммит содержится в:
родитель
53ba129d7d
коммит
b6cb81fc11
3 изменённых файлов: 23 добавлений и 4 удалений
|
@ -69,7 +69,7 @@ func handleIdentExpr(expr ast.Expr) string {
|
||||||
case "uint64":
|
case "uint64":
|
||||||
code += "unsigned long long"
|
code += "unsigned long long"
|
||||||
case "string":
|
case "string":
|
||||||
code += "char*"
|
code += "std::string"
|
||||||
default:
|
default:
|
||||||
code += ident.Name
|
code += ident.Name
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,4 +59,23 @@ class device {
|
||||||
public:
|
public:
|
||||||
int a,b;
|
int a,b;
|
||||||
};
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
Сценарий: Структура с неск полями, строки - std::string
|
||||||
|
* Исходник:
|
||||||
|
```
|
||||||
|
package test
|
||||||
|
|
||||||
|
type device struct {
|
||||||
|
a,b int
|
||||||
|
c,d,e string
|
||||||
|
}
|
||||||
|
```
|
||||||
|
* Результат:
|
||||||
|
```
|
||||||
|
class device {
|
||||||
|
public:
|
||||||
|
int a,b;
|
||||||
|
std::string c,d,e;
|
||||||
|
};
|
||||||
```
|
```
|
||||||
|
|
|
@ -49,7 +49,7 @@ var _ = Describe("Go Translator", func() {
|
||||||
const foo string = "bar"
|
const foo string = "bar"
|
||||||
`
|
`
|
||||||
expected := `
|
expected := `
|
||||||
const char* foo = "bar";
|
const std::string foo = "bar";
|
||||||
`
|
`
|
||||||
Compare(source, expected)
|
Compare(source, expected)
|
||||||
})
|
})
|
||||||
|
@ -83,7 +83,7 @@ var _ = Describe("Go Translator", func() {
|
||||||
void foo();
|
void foo();
|
||||||
|
|
||||||
void foo() {
|
void foo() {
|
||||||
const char* foo = "bar";
|
const std::string foo = "bar";
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
Compare(source, expected)
|
Compare(source, expected)
|
||||||
|
@ -99,7 +99,7 @@ var _ = Describe("Go Translator", func() {
|
||||||
void foo();
|
void foo();
|
||||||
|
|
||||||
void foo() {
|
void foo() {
|
||||||
char* foo = "bar";
|
std::string foo = "bar";
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
Compare(source, expected)
|
Compare(source, expected)
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче