Commit 73372c6d by Philipp Adolf

Format autogenerated code

parent 1c5d3401
...@@ -12,6 +12,7 @@ package main ...@@ -12,6 +12,7 @@ package main
import "C" import "C"
import ( import (
"bytes" "bytes"
"go/format"
"io/ioutil" "io/ioutil"
"log" "log"
"os" "os"
...@@ -116,7 +117,7 @@ func generate(tmpl *template.Template, data interface{}) ([]byte, error) { ...@@ -116,7 +117,7 @@ func generate(tmpl *template.Template, data interface{}) ([]byte, error) {
return nil, err return nil, err
} }
return buf.Bytes(), nil return format.Source(buf.Bytes())
} }
func writeBytes(filename string, data []byte) error { func writeBytes(filename string, data []byte) error {
......
...@@ -12,51 +12,50 @@ package opencl ...@@ -12,51 +12,50 @@ package opencl
*/ */
import "C" import "C"
import ( import (
"fmt" "fmt"
"strings" "strings"
"unsafe" "unsafe"
) )
func (p Platform) getInfoString(name string, id C.cl_platform_info) (string, error) { func (p Platform) getInfoString(name string, id C.cl_platform_info) (string, error) {
var n C.size_t var n C.size_t
if err := C.clGetPlatformInfo(p.id, id, 0, nil, &n); err != C.CL_SUCCESS { if err := C.clGetPlatformInfo(p.id, id, 0, nil, &n); err != C.CL_SUCCESS {
return "", fmt.Errorf("error getting length of platform info %s: %d", name, err) return "", fmt.Errorf("error getting length of platform info %s: %d", name, err)
} }
buf := make([]C.char, n) buf := make([]C.char, n)
if err := C.clGetPlatformInfo(p.id, id, n, unsafe.Pointer(&buf[0]), nil); err != C.CL_SUCCESS { if err := C.clGetPlatformInfo(p.id, id, n, unsafe.Pointer(&buf[0]), nil); err != C.CL_SUCCESS {
return "", fmt.Errorf("error getting platform info %s: %d", name, err) return "", fmt.Errorf("error getting platform info %s: %d", name, err)
} }
return C.GoString(&buf[0]), nil return C.GoString(&buf[0]), nil
} }
func (p Platform) dummyUseStrings() ([]string) { func (p Platform) dummyUseStrings() []string {
// a dummy function so that strings is not unused even if template space-delim is not used // a dummy function so that strings is not unused even if template space-delim is not used
return strings.Split("", "") return strings.Split("", "")
} }
func (p Platform) Profile() (string, error) { func (p Platform) Profile() (string, error) {
return p.getInfoString("Profile", C.CL_PLATFORM_PROFILE) return p.getInfoString("Profile", C.CL_PLATFORM_PROFILE)
} }
func (p Platform) Version() (string, error) { func (p Platform) Version() (string, error) {
return p.getInfoString("Version", C.CL_PLATFORM_VERSION) return p.getInfoString("Version", C.CL_PLATFORM_VERSION)
} }
func (p Platform) Name() (string, error) { func (p Platform) Name() (string, error) {
return p.getInfoString("Name", C.CL_PLATFORM_NAME) return p.getInfoString("Name", C.CL_PLATFORM_NAME)
} }
func (p Platform) Vendor() (string, error) { func (p Platform) Vendor() (string, error) {
return p.getInfoString("Vendor", C.CL_PLATFORM_VENDOR) return p.getInfoString("Vendor", C.CL_PLATFORM_VENDOR)
} }
func (p Platform) Extension() ([]string, error) { func (p Platform) Extension() ([]string, error) {
str, err := p.getInfoString("Extension", C.CL_PLATFORM_EXTENSIONS) str, err := p.getInfoString("Extension", C.CL_PLATFORM_EXTENSIONS)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return strings.Split(str, " "), nil return strings.Split(str, " "), nil
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment