Skip to content

Commit

Permalink
blas/netlib: add code to sync panic strings from blas/gonum
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-ch committed Oct 29, 2018
1 parent 57e1e4d commit b716cea
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 7 deletions.
2 changes: 1 addition & 1 deletion blas/netlib/blas.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions blas/netlib/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
// license that can be found in the LICENSE file.

//go:generate go run generate_blas.go

// Ensure changes made to netlib/blas are reflected in gonum/blas/native where relevant.
//go:generate go run generate_errors.go

/*
Package netlib provides bindings to a C BLAS library. This wrapper interface
panics when the input arguments are invalid as per the standard, for example
if a vector increment is zero. Please note that the treatment of NaN values
if a vector increment is zero. Note that the treatment of NaN values
is not specified, and differs among the BLAS implementations.
github.com/gonum/blas/blas64 provides helpful wrapper functions to the BLAS
gonum.org/v1/gonum/blas/blas64 provides helpful wrapper functions to the BLAS
interface. The rest of this text describes the layout of the data for the input types.
Please note that in the function documentation, x[i] refers to the i^th element
Note that in the function documentation, x[i] refers to the i^th element
of the vector, which will be different from the i^th element of the slice if
incX != 1.
Expand Down
31 changes: 31 additions & 0 deletions blas/netlib/errors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blas/netlib/generate_blas.go
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ func address(buf *bytes.Buffer, d binding.Declaration, p binding.Parameter) bool
return false
}

const handwritten = `// Do not manually edit this file. It was created by the generate_blas.go from {{.}}.
const handwritten = `// Code generated by "go generate gonum.org/v1/netlib/blas/netlib" from {{.}}; DO NOT EDIT.
// Copyright ©2014 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
Expand Down
70 changes: 70 additions & 0 deletions blas/netlib/generate_errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright ©2018 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build ignore

package main

import (
"fmt"
"go/ast"
"go/parser"
"go/printer"
"go/token"
"log"
"os"
"path/filepath"
)

const errorFile = "../../../gonum/blas/gonum/errors.go"

func main() {
path, err := filepath.Abs(errorFile)
if err != nil {
log.Fatalf("no absolute path for %q: %v", errorFile, err)
}

fset := token.NewFileSet()
f, err := parser.ParseFile(fset, path, nil, parser.ParseComments)
if err != nil {
log.Fatalf("failed to parse %q: %v", path, err)
}

dst := filepath.Base(errorFile)
o, err := os.Create(dst)
if err != nil {
log.Fatalf("failed to create %q: %v", dst, err)
}
defer o.Close()

fmt.Fprintln(o, header)
for _, cg := range f.Comments {
for _, c := range cg.List {
fmt.Fprintln(o, c.Text)
}
break
}
fmt.Fprintln(o, pkg)
p := printer.Config{
Mode: printer.UseSpaces | printer.TabIndent,
Tabwidth: 8,
}
// Remove comment associated with the const block.
for _, d := range f.Decls {
if d, ok := d.(*ast.GenDecl); ok {
d.Doc = nil
}
}
p.Fprint(o, fset, f.Decls)
fmt.Fprintln(o)
}

const (
header = `// Code generated by "go generate gonum.org/v1/netlib/blas/netlib”; DO NOT EDIT.
`
pkg = `
package netlib
// Copied from gonum/blas/gonum. Keep in sync.`
)

0 comments on commit b716cea

Please sign in to comment.