Добавлены свойства классов массивами
Этот коммит содержится в:
		
							родитель
							
								
									6113b6be28
								
							
						
					
					
						коммит
						1d39dfa762
					
				
					 2 изменённых файлов: 16 добавлений и 0 удалений
				
			
		|  | @ -92,6 +92,7 @@ package test | ||||||
| type device struct { | type device struct { | ||||||
|   a,b int |   a,b int | ||||||
|   c,d,e string |   c,d,e string | ||||||
|  |   g [GPIO_count]bool | ||||||
| } | } | ||||||
| ``` | ``` | ||||||
|     * Результат: |     * Результат: | ||||||
|  | @ -100,6 +101,7 @@ class device { | ||||||
| public: | public: | ||||||
|   int a,b; |   int a,b; | ||||||
|   std::string c,d,e; |   std::string c,d,e; | ||||||
|  |   bool g[GPIO_count]; | ||||||
| }; | }; | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -30,6 +30,12 @@ func optionallyAddArrayDetails(s *ast.TypeSpec) (code string) { | ||||||
| 	code += "]" | 	code += "]" | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
|  | func optionallyAddArrayDetailsArrayType(a *ast.ArrayType) (code string) { | ||||||
|  | 	code += "[" | ||||||
|  | 	code += handleArrayLen(a) | ||||||
|  | 	code += "]" | ||||||
|  | 	return | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| func handleArrayLen(a *ast.ArrayType) (code string) { | func handleArrayLen(a *ast.ArrayType) (code string) { | ||||||
| 	return handleExpr(a.Len) | 	return handleExpr(a.Len) | ||||||
|  | @ -59,6 +65,8 @@ func handleField(f *ast.Field) (code string) { | ||||||
| 		code += handleIdentExpr(t) | 		code += handleIdentExpr(t) | ||||||
| 	case *ast.FuncType: | 	case *ast.FuncType: | ||||||
| 		code += handleFuncDeclType(t) | 		code += handleFuncDeclType(t) | ||||||
|  | 	case *ast.ArrayType: | ||||||
|  | 		code += handleArray(t) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	code += " " | 	code += " " | ||||||
|  | @ -70,6 +78,12 @@ func handleField(f *ast.Field) (code string) { | ||||||
| 		code += handleIdentExpr(n) | 		code += handleIdentExpr(n) | ||||||
| 		nado_zapyatuyu = true | 		nado_zapyatuyu = true | ||||||
| 	} | 	} | ||||||
|  | 
 | ||||||
|  | 	switch t := f.Type.(type) { | ||||||
|  | 	case *ast.ArrayType: | ||||||
|  | 		code += optionallyAddArrayDetailsArrayType(t) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	code += ";\n" | 	code += ";\n" | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
|  |  | ||||||
		Загрузка…
	
	Создание таблицы
		
		Сослаться в новой задаче
	
	 Softonik
						Softonik