-
Notifications
You must be signed in to change notification settings - Fork 1
/
ue_return.go
49 lines (44 loc) · 1.19 KB
/
ue_return.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package filterue
import (
"fmt"
"github.com/apigear-io/cli/pkg/model"
"github.com/iancoleman/strcase"
)
//TODO: add test including prefix for all filters
func ToReturnString(prefix string, schema *model.Schema) (string, error) {
if schema == nil {
return "", fmt.Errorf("ToReturnString schema is nil")
}
moduleId := strcase.ToCamel(schema.Module.Name)
var text string
switch schema.KindType {
case model.TypeString:
text = "FString"
case model.TypeInt:
text = "int32"
case model.TypeFloat:
text = "float"
case model.TypeBool:
text = "bool"
case model.TypeEnum:
text = fmt.Sprintf("%sE%s%s", prefix, moduleId, schema.Type)
case model.TypeStruct:
text = fmt.Sprintf("%sF%s%s", prefix, moduleId, schema.Type)
case model.TypeInterface:
text = fmt.Sprintf("%sF%s%s*", prefix, moduleId, schema.Type)
case model.TypeNull:
text = ""
default:
return "", fmt.Errorf("unknown schema kind type: %s", schema.KindType)
}
if schema.IsArray {
text = fmt.Sprintf("TArray<%s>", text)
}
return text, nil
}
func ueReturn(prefix string, node *model.TypedNode) (string, error) {
if node == nil {
return "", fmt.Errorf("goReturn node is nil")
}
return ToReturnString(prefix, &node.Schema)
}