[go][abigen] Add NativeType method to SysType
The code in syscall/zx uses types created in that package to pass to the
Sys_zx_foo wrappers. We can't use these types in runtime signatures for
the VDSO wrappers, but we won't really need to as long as we have
compatible native types.
Change-Id: Idea840a869017d7c4eccd62ca40e01d73a71e0dc
diff --git a/src/internal/fuchsia/abigen/types.go b/src/internal/fuchsia/abigen/types.go
index 9783968..9d7e971 100644
--- a/src/internal/fuchsia/abigen/types.go
+++ b/src/internal/fuchsia/abigen/types.go
@@ -247,3 +247,83 @@
return t.goType()
}
+
+// NativeType returns a size-compatible Go native type for the SysType.
+func (t SysType) NativeType() string {
+ if t.Array {
+ return "unsafe.Pointer"
+ }
+
+ switch t.Name {
+ case zxVoid:
+ return "BAD(void)"
+ case zxAny:
+ return "uintptr"
+ case zxBool:
+ return "bool"
+ case zxUint:
+ return "uint"
+ case zxInt:
+ return "int"
+ case zxChar, zxUint8:
+ return "uint8"
+ case zxInt16:
+ return "int16"
+ case zxUint16:
+ return "uint16"
+ case zxInt32:
+ return "int32"
+ case zxUint32:
+ return "uint32"
+ case zxInt64:
+ return "int64"
+ case zxUint64:
+ return "uint64"
+ case zxUintptr:
+ return "uintptr"
+ case zxStatus:
+ return "int32"
+ case zxClock:
+ return "uint32"
+ case zxTime:
+ return "int64"
+ case zxDuration:
+ return "int64"
+ case zxKOID:
+ return "uint64"
+ case zxHandle:
+ return "uint32"
+ case zxSignals:
+ return "uint32"
+ case zxWaitItem:
+ return "uintptr"
+ case zxRights:
+ return "uint32"
+ case zxVAddr:
+ return "uintptr"
+ case zxPAddr:
+ return "uintptr"
+ case zxSize:
+ return "uint"
+ case zxProcessInfo:
+ return "uintptr"
+ case zxExceptionStatus:
+ return "uintptr"
+ case zxExceptionBehaviour:
+ return "uintptr"
+ case zxRRec:
+ return "uintptr"
+ case zxChannelCallArgs:
+ return "uintptr"
+ case zxFIFOState:
+ return "uintptr"
+ case zxSMCParameters:
+ return "uintptr"
+ case zxSMCResult:
+ return "uintptr"
+ case zxVMOption:
+ return "uint32"
+ default:
+ panic(fmt.Sprintf("UNKNOWN(%s)", t.Name))
+ }
+}