Добавлены свойства классов массивами

Этот коммит содержится в:
Softonik 2024-02-12 05:13:03 +03:00 коммит произвёл Nobody
родитель 6113b6be28
коммит 1d39dfa762
2 изменённых файлов: 16 добавлений и 0 удалений

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

@ -92,6 +92,7 @@ package test
type device struct {
a,b int
c,d,e string
g [GPIO_count]bool
}
```
* Результат:
@ -100,6 +101,7 @@ class device {
public:
int a,b;
std::string c,d,e;
bool g[GPIO_count];
};
```

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

@ -30,6 +30,12 @@ func optionallyAddArrayDetails(s *ast.TypeSpec) (code string) {
code += "]"
return
}
func optionallyAddArrayDetailsArrayType(a *ast.ArrayType) (code string) {
code += "["
code += handleArrayLen(a)
code += "]"
return
}
func handleArrayLen(a *ast.ArrayType) (code string) {
return handleExpr(a.Len)
@ -59,6 +65,8 @@ func handleField(f *ast.Field) (code string) {
code += handleIdentExpr(t)
case *ast.FuncType:
code += handleFuncDeclType(t)
case *ast.ArrayType:
code += handleArray(t)
}
code += " "
@ -70,6 +78,12 @@ func handleField(f *ast.Field) (code string) {
code += handleIdentExpr(n)
nado_zapyatuyu = true
}
switch t := f.Type.(type) {
case *ast.ArrayType:
code += optionallyAddArrayDetailsArrayType(t)
}
code += ";\n"
return
}