buildViews builds the view data for all the views in the given result type.
(rt *expr.ResultTypeExpr, viewScope *codegen.NameScope)
| 1958 | |
| 1959 | // buildViews builds the view data for all the views in the given result type. |
| 1960 | func buildViews(rt *expr.ResultTypeExpr, viewScope *codegen.NameScope) []*ViewData { |
| 1961 | views := make([]*ViewData, len(rt.Views)) |
| 1962 | for i, view := range rt.Views { |
| 1963 | vatt := expr.AsObject(view.Type) |
| 1964 | attrs := make([]string, len(*vatt)) |
| 1965 | for j, nat := range *vatt { |
| 1966 | attrs[j] = nat.Name |
| 1967 | } |
| 1968 | views[i] = &ViewData{ |
| 1969 | Name: view.Name, |
| 1970 | Description: view.Description, |
| 1971 | Attributes: attrs, |
| 1972 | TypeVarName: viewScope.GoTypeName(&expr.AttributeExpr{Type: rt}), |
| 1973 | } |
| 1974 | } |
| 1975 | return views |
| 1976 | } |
| 1977 | |
| 1978 | // buildViewedResultType builds a viewed result type from the given result type |
| 1979 | // and projected type. |
no test coverage detected