forked from progrium/darwinkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkernel_type.go
59 lines (51 loc) · 1.2 KB
/
kernel_type.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
50
51
52
53
54
55
56
57
58
59
package typing
import (
"strings"
"unicode"
"github.com/progrium/darwinkit/generate/modules"
"github.com/progrium/darwinkit/internal/set"
)
func GetKernelType(typeName string) (Type, bool) {
for _, name := range []string{
"vector_int2",
"vector_int4",
"vector_float2",
"vector_float3",
"vector_float4",
"vector_double2",
"vector_double3",
"vector_double4",
"matrix_float2x2",
"matrix_float3x3",
"matrix_float4x4",
"matrix_float4x3",
"matrix_double4x4",
"vector_uchar16",
"pid_t",
"gid_t",
"uid_t",
} {
if typeName == name {
return &KernelType{ObjcName_: typeName}, true
}
}
return nil, false
}
type KernelType struct {
ObjcName_ string // objc type name
}
func (k *KernelType) GoImports() set.Set[string] {
return set.New("github.com/progrium/darwinkit/kernel")
}
func (k *KernelType) GoName(currentModule *modules.Module, receiveFromObjc bool) string {
r := []rune(k.ObjcName_)
r[0] = unicode.ToUpper(r[0])
name := strings.TrimSuffix(string(r), "_t")
return FullGoName(*k.DeclareModule(), name, *currentModule)
}
func (k *KernelType) ObjcName() string {
return k.ObjcName_
}
func (k *KernelType) DeclareModule() *modules.Module {
return modules.Get("kernel")
}