Skip to content

Commit 5127136

Browse files
committed
cmd/cue/cmd: support uintptr in get go
Fixes #1305 Signed-off-by: Marcel van Lohuizen <mpvl@golang.org> Change-Id: Ib78066542f0f54bb13f507be48a9bd0ce6285741 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/536712 Unity-Result: CUEcueckoo <cueckoo@cuelang.org> TryBot-Result: CUEcueckoo <cueckoo@cuelang.org> Reviewed-by: Marcel van Lohuizen <mpvl@gmail.com>
1 parent dc2c9e0 commit 5127136

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

cmd/cue/cmd/get_go.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,6 @@ func (e *extractor) makeType(expr types.Type) (result cueast.Expr) {
10201020
}
10211021
// Check for builtin packages.
10221022
// TODO: replace these literal types with a reference to the fixed
1023-
// builtin type.
10241023
switch obj.Type().String() {
10251024
case "time.Time":
10261025
ref := e.ident(e.pkgNames[obj.Pkg().Path()].name, false)
@@ -1130,7 +1129,12 @@ func (e *extractor) makeType(expr types.Type) (result cueast.Expr) {
11301129
}
11311130

11321131
case *types.Basic:
1133-
return e.ident(x.String(), false)
1132+
switch t := x.String(); t {
1133+
case "uintptr":
1134+
return e.ident("uint64", false)
1135+
default:
1136+
return e.ident(t, false)
1137+
}
11341138

11351139
case *types.Interface:
11361140
return e.ident("_", false)

cmd/cue/cmd/testdata/script/get_go_types.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ type Foozer struct {
6363

6464
exclude int
6565

66+
Ptr uintptr
67+
6668
// Time is mapped to CUE's internal type.
6769
Time time.Time
6870

@@ -394,6 +396,7 @@ import (
394396
AnyJSON: _ @go(,json.Marshaler)
395397
AnyText: string @go(,encoding.TextMarshaler)
396398
bar?: int & >10 @go(Bar)
399+
Ptr: uint64 @go(,uintptr)
397400

398401
// Time is mapped to CUE's internal type.
399402
Time: time.Time

0 commit comments

Comments
 (0)