diff --git a/cmd/test-go-cpxcmpd/main.go b/cmd/test-go-cpxcmpd/main.go index 7c80377..a235b2a 100644 --- a/cmd/test-go-cpxcmpd/main.go +++ b/cmd/test-go-cpxcmpd/main.go @@ -70,13 +70,13 @@ func main() { fmt.Printf(":: file [%s] created (id=%d)\n", fname, f.ID()) // create the memory data type - dtype, err := hdf5.NewDatatypeFromValue(s1[0]) + typ, err := hdf5.NewDatatypeFromValue(s1[0]) if err != nil { - panic("could not create a dtype") + panic("could not create a typ") } // create the dataset - dset, err := f.CreateDataset(dsname, dtype, space) + dset, err := f.CreateDataset(dsname, typ, space) if err != nil { panic(err) } diff --git a/cmd/test-go-extend-ds/main.go b/cmd/test-go-extend-ds/main.go index 8034ecb..928c616 100644 --- a/cmd/test-go-extend-ds/main.go +++ b/cmd/test-go-extend-ds/main.go @@ -19,9 +19,9 @@ func main() { //RANK:= 2 //dims := []int{3, 3} // dset dimensions at creation - //maxdims:= []int{hdf5.S_UNLIMITED, hdf5.S_UNLIMITED} + //maxDims:= []int{hdf5.S_UNLIMITED, hdf5.S_UNLIMITED} - //mspace := hdf5.CreateDataspace(dims, maxdims) + //mSpace := hdf5.CreateDataspace(dims, maxDims) // create a new file f, err := hdf5.CreateFile(fname, hdf5.F_ACC_TRUNC) diff --git a/h5a_attribute.go b/h5a_attribute.go index 1710358..2dbddf9 100644 --- a/h5a_attribute.go +++ b/h5a_attribute.go @@ -22,10 +22,10 @@ func newAttribute(id C.hid_t) *Attribute { return &Attribute{Identifier{id}} } -func createAttribute(id C.hid_t, name string, dtype *Datatype, dspace *Dataspace, acpl *PropList) (*Attribute, error) { - c_name := C.CString(name) - defer C.free(unsafe.Pointer(c_name)) - hid := C.H5Acreate2(id, c_name, dtype.id, dspace.id, acpl.id, P_DEFAULT.id) +func createAttribute(id C.hid_t, name string, typ *Datatype, spc *Dataspace, acpl *PropList) (*Attribute, error) { + cName := C.CString(name) + defer C.free(unsafe.Pointer(cName)) + hid := C.H5Acreate2(id, cName, typ.id, spc.id, acpl.id, P_DEFAULT.id) if err := checkID(hid); err != nil { return nil, err } @@ -33,10 +33,10 @@ func createAttribute(id C.hid_t, name string, dtype *Datatype, dspace *Dataspace } func openAttribute(id C.hid_t, name string) (*Attribute, error) { - c_name := C.CString(name) - defer C.free(unsafe.Pointer(c_name)) + cName := C.CString(name) + defer C.free(unsafe.Pointer(cName)) - hid := C.H5Aopen(id, c_name, P_DEFAULT.id) + hid := C.H5Aopen(id, cName, P_DEFAULT.id) if err := checkID(hid); err != nil { return nil, err } @@ -68,7 +68,7 @@ func (s *Attribute) Space() *Dataspace { } // Read reads raw data from a attribute into a buffer. -func (s *Attribute) Read(data interface{}, dtype *Datatype) error { +func (s *Attribute) Read(data interface{}, typ *Datatype) error { var addr unsafe.Pointer v := reflect.ValueOf(data) @@ -88,13 +88,13 @@ func (s *Attribute) Read(data interface{}, dtype *Datatype) error { addr = unsafe.Pointer(v.UnsafeAddr()) } - rc := C.H5Aread(s.id, dtype.id, addr) + rc := C.H5Aread(s.id, typ.id, addr) err := h5err(rc) return err } // Write writes raw data from a buffer to an attribute. -func (s *Attribute) Write(data interface{}, dtype *Datatype) error { +func (s *Attribute) Write(data interface{}, typ *Datatype) error { var addr unsafe.Pointer v := reflect.Indirect(reflect.ValueOf(data)) switch v.Kind() { @@ -114,7 +114,7 @@ func (s *Attribute) Write(data interface{}, dtype *Datatype) error { addr = unsafe.Pointer(v.UnsafeAddr()) } - rc := C.H5Awrite(s.id, dtype.id, addr) + rc := C.H5Awrite(s.id, typ.id, addr) err := h5err(rc) return err } diff --git a/h5a_attribute_test.go b/h5a_attribute_test.go index 9efccb8..f24d75e 100644 --- a/h5a_attribute_test.go +++ b/h5a_attribute_test.go @@ -49,19 +49,19 @@ func TestWriteAttribute(t *testing.T) { } for name, v := range attrs { - dtype, err := NewDataTypeFromType(v.Type) + typ, err := NewDataTypeFromType(v.Type) if err != nil { t.Fatalf("NewDatatypeFromValue failed: %s\n", err) } - defer dtype.Close() + defer typ.Close() - attr, err := dset.CreateAttribute(name, dtype, scalar) + attr, err := dset.CreateAttribute(name, typ, scalar) if err != nil { t.Fatalf("CreateAttribute failed: %s\n", err) } defer attr.Close() - if err := attr.Write(v.Value, dtype); err != nil { + if err := attr.Write(v.Value, typ); err != nil { t.Fatalf("Attribute write failed: %s\n", err) } } diff --git a/h5d_dataset.go b/h5d_dataset.go index db88c7d..46f1428 100644 --- a/h5d_dataset.go +++ b/h5d_dataset.go @@ -26,18 +26,18 @@ func newDataset(id C.hid_t, typ *Datatype) *Dataset { return &Dataset{Identifier: Identifier{id}, typ: typ} } -func createDataset(id C.hid_t, name string, dtype *Datatype, dspace *Dataspace, dcpl *PropList) (*Dataset, error) { - dtype, err := dtype.Copy() // For safety +func createDataset(id C.hid_t, name string, typ *Datatype, spc *Dataspace, dcpl *PropList) (*Dataset, error) { + typ, err := typ.Copy() // For safety if err != nil { return nil, err } - c_name := C.CString(name) - defer C.free(unsafe.Pointer(c_name)) - hid := C.H5Dcreate2(id, c_name, dtype.id, dspace.id, P_DEFAULT.id, dcpl.id, P_DEFAULT.id) + cName := C.CString(name) + defer C.free(unsafe.Pointer(cName)) + hid := C.H5Dcreate2(id, cName, typ.id, spc.id, P_DEFAULT.id, dcpl.id, P_DEFAULT.id) if err := checkID(hid); err != nil { return nil, err } - return newDataset(hid, dtype), nil + return newDataset(hid, typ), nil } // Close releases and terminates access to a dataset. @@ -59,9 +59,9 @@ func (s *Dataset) Space() *Dataspace { } // ReadSubset reads a subset of raw data from a dataset into a buffer. -func (s *Dataset) ReadSubset(data interface{}, memspace, filespace *Dataspace) error { - dtype, err := s.Datatype() - defer dtype.Close() +func (s *Dataset) ReadSubset(data interface{}, memSpace, fileSpace *Dataspace) error { + typ, err := s.Datatype() + defer typ.Close() if err != nil { return err } @@ -89,14 +89,14 @@ func (s *Dataset) ReadSubset(data interface{}, memspace, filespace *Dataspace) e addr = unsafe.Pointer(v.UnsafeAddr()) } - var filespace_id, memspace_id C.hid_t = 0, 0 - if memspace != nil { - memspace_id = memspace.id + var fileSpaceID, memSpaceID C.hid_t + if memSpace != nil { + memSpaceID = memSpace.id } - if filespace != nil { - filespace_id = filespace.id + if fileSpace != nil { + fileSpaceID = fileSpace.id } - rc := C.H5Dread(s.id, dtype.id, memspace_id, filespace_id, 0, addr) + rc := C.H5Dread(s.id, typ.id, memSpaceID, fileSpaceID, 0, addr) err = h5err(rc) return err } @@ -107,9 +107,9 @@ func (s *Dataset) Read(data interface{}) error { } // WriteSubset writes a subset of raw data from a buffer to a dataset. -func (s *Dataset) WriteSubset(data interface{}, memspace, filespace *Dataspace) error { - dtype, err := s.Datatype() - defer dtype.Close() +func (s *Dataset) WriteSubset(data interface{}, memSpace, fileSpace *Dataspace) error { + typ, err := s.Datatype() + defer typ.Close() if err != nil { return err } @@ -137,14 +137,14 @@ func (s *Dataset) WriteSubset(data interface{}, memspace, filespace *Dataspace) addr = unsafe.Pointer(v.UnsafeAddr()) } - var filespace_id, memspace_id C.hid_t = 0, 0 - if memspace != nil { - memspace_id = memspace.id + var fileSpaceID, memSpaceID C.hid_t + if memSpace != nil { + memSpaceID = memSpace.id } - if filespace != nil { - filespace_id = filespace.id + if fileSpace != nil { + fileSpaceID = fileSpace.id } - rc := C.H5Dwrite(s.id, dtype.id, memspace_id, filespace_id, 0, addr) + rc := C.H5Dwrite(s.id, typ.id, memSpaceID, fileSpaceID, 0, addr) err = h5err(rc) return err } @@ -156,14 +156,14 @@ func (s *Dataset) Write(data interface{}) error { // Creates a new attribute at this location. The returned attribute // must be closed by the user when it is no longer needed. -func (s *Dataset) CreateAttribute(name string, dtype *Datatype, dspace *Dataspace) (*Attribute, error) { - return createAttribute(s.id, name, dtype, dspace, P_DEFAULT) +func (s *Dataset) CreateAttribute(name string, typ *Datatype, spc *Dataspace) (*Attribute, error) { + return createAttribute(s.id, name, typ, spc, P_DEFAULT) } // Creates a new attribute at this location. The returned // attribute must be closed by the user when it is no longer needed. -func (s *Dataset) CreateAttributeWith(name string, dtype *Datatype, dspace *Dataspace, acpl *PropList) (*Attribute, error) { - return createAttribute(s.id, name, dtype, dspace, acpl) +func (s *Dataset) CreateAttributeWith(name string, typ *Datatype, spc *Dataspace, acpl *PropList) (*Attribute, error) { + return createAttribute(s.id, name, typ, spc, acpl) } // Opens an existing attribute. The returned attribute must be closed @@ -176,11 +176,11 @@ func (s *Dataset) OpenAttribute(name string) (*Attribute, error) { // Datatype returns the HDF5 Datatype of the Dataset. The returned // datatype must be closed by the user when it is no longer needed. func (s *Dataset) Datatype() (*Datatype, error) { - dtype_id := C.H5Dget_type(s.id) - if dtype_id < 0 { + typID := C.H5Dget_type(s.id) + if typID < 0 { return nil, fmt.Errorf("couldn't open Datatype from Dataset %q", s.Name()) } - return NewDatatype(dtype_id), nil + return NewDatatype(typID), nil } // hasIllegalGoPointer returns whether the Dataset is known to have diff --git a/h5d_dataset_test.go b/h5d_dataset_test.go index 28e76dd..4340583 100644 --- a/h5d_dataset_test.go +++ b/h5d_dataset_test.go @@ -25,13 +25,13 @@ func createDataset1(t *testing.T) error { } dims := []uint{20, 5} - dspace, err := CreateSimpleDataspace(dims, dims) + spc, err := CreateSimpleDataspace(dims, dims) if err != nil { t.Fatal(err) return err } - dset, err := f.CreateDataset("dset", T_NATIVE_USHORT, dspace) + dset, err := f.CreateDataset("dset", T_NATIVE_USHORT, spc) if err != nil { t.Fatal(err) return err @@ -78,20 +78,20 @@ func TestReadSubset(t *testing.T) { t.Fatal(err) } - // get the filespace and select the subset - filespace := dset.Space() + // get the fileSpace and select the subset + fileSpace := dset.Space() offset, stride, count, block := [2]uint{5, 1}, [2]uint{1, 1}, [2]uint{5, 2}, [2]uint{1, 1} - err = filespace.SelectHyperslab(offset[:], stride[:], count[:], block[:]) + err = fileSpace.SelectHyperslab(offset[:], stride[:], count[:], block[:]) if err != nil { t.Fatal(err) } // create the memory space for the subset - dims, maxdims := [2]uint{2, 5}, [2]uint{2, 5} + dims, maxDims := [2]uint{2, 5}, [2]uint{2, 5} if err != nil { t.Fatal(err) } - memspace, err := CreateSimpleDataspace(dims[:], maxdims[:]) + memSpace, err := CreateSimpleDataspace(dims[:], maxDims[:]) if err != nil { t.Fatal(err) } @@ -104,7 +104,7 @@ func TestReadSubset(t *testing.T) { data := [10]uint16{} // read the subset - err = dset.ReadSubset(&data, memspace, filespace) + err = dset.ReadSubset(&data, memSpace, fileSpace) if err != nil { t.Fatal(err) } @@ -120,7 +120,7 @@ func TestReadSubset(t *testing.T) { data := make([]uint16, 10) // read the subset - err = dset.ReadSubset(&data, memspace, filespace) + err = dset.ReadSubset(&data, memSpace, fileSpace) if err != nil { t.Fatal(err) } @@ -142,7 +142,7 @@ func TestWriteSubset(t *testing.T) { t.Fatal(err) } mdims := []uint{2, 6} - mspace, err := CreateSimpleDataspace(mdims, nil) + mSpace, err := CreateSimpleDataspace(mdims, nil) if err != nil { t.Fatal(err) } @@ -167,7 +167,7 @@ func TestWriteSubset(t *testing.T) { data := make([]uint16, mdims[0]*mdims[1]) - if err = dset.WriteSubset(&data, mspace, fspace); err != nil { + if err = dset.WriteSubset(&data, mSpace, fspace); err != nil { t.Fatal(err) } } @@ -177,21 +177,21 @@ func TestSelectHyperslab(t *testing.T) { defer DisplayErrors(false) dims := []uint{12, 4} - dspace, err := CreateSimpleDataspace(dims, nil) + spc, err := CreateSimpleDataspace(dims, nil) if err != nil { t.Fatal(err) } offset, stride, count, block := []uint{1, 2}, []uint{2, 1}, []uint{4, 2}, []uint{1, 1} - if err = dspace.SelectHyperslab(offset, stride, count, block); err != nil { + if err = spc.SelectHyperslab(offset, stride, count, block); err != nil { t.Fatal(err) } - if err = dspace.SelectHyperslab(offset, nil, count, block); err != nil { + if err = spc.SelectHyperslab(offset, nil, count, block); err != nil { t.Fatal(err) } - if err = dspace.SelectHyperslab(offset, stride, count, nil); err != nil { + if err = spc.SelectHyperslab(offset, stride, count, nil); err != nil { t.Fatal(err) } - if err = dspace.SelectHyperslab(offset, nil, count, nil); err != nil { + if err = spc.SelectHyperslab(offset, nil, count, nil); err != nil { t.Fatal(err) } } diff --git a/h5f_file.go b/h5f_file.go index 2346557..3797f40 100644 --- a/h5f_file.go +++ b/h5f_file.go @@ -45,11 +45,11 @@ func newFile(id C.hid_t) *File { // Creates an HDF5 file. func CreateFile(name string, flags int) (*File, error) { - c_name := C.CString(name) - defer C.free(unsafe.Pointer(c_name)) + cName := C.CString(name) + defer C.free(unsafe.Pointer(cName)) // FIXME: file props - hid := C.H5Fcreate(c_name, C.uint(flags), P_DEFAULT.id, P_DEFAULT.id) + hid := C.H5Fcreate(cName, C.uint(flags), P_DEFAULT.id, P_DEFAULT.id) if err := checkID(hid); err != nil { return nil, fmt.Errorf("error creating hdf5 file: %s", err) } @@ -59,11 +59,11 @@ func CreateFile(name string, flags int) (*File, error) { // Open opens and returns an an existing HDF5 file. The returned // file must be closed by the user when it is no longer needed. func OpenFile(name string, flags int) (*File, error) { - c_name := C.CString(name) - defer C.free(unsafe.Pointer(c_name)) + cName := C.CString(name) + defer C.free(unsafe.Pointer(cName)) // FIXME: file props - hid := C.H5Fopen(c_name, C.uint(flags), P_DEFAULT.id) + hid := C.H5Fopen(cName, C.uint(flags), P_DEFAULT.id) if err := checkID(hid); err != nil { return nil, fmt.Errorf("error opening hdf5 file: %s", err) } @@ -82,10 +82,10 @@ func (f *File) ReOpen() (*File, error) { // IsHDF5 Determines whether a file is in the HDF5 format. func IsHDF5(name string) bool { - c_name := C.CString(name) - defer C.free(unsafe.Pointer(c_name)) + cName := C.CString(name) + defer C.free(unsafe.Pointer(cName)) - return C.H5Fis_hdf5(c_name) > 0 + return C.H5Fis_hdf5(cName) > 0 } // Close closes the file. @@ -99,26 +99,24 @@ func h5fclose(id C.hid_t) C.herr_t { // Flushes all buffers associated with a file to disk. func (f *File) Flush(scope Scope) error { - // herr_t H5Fflush(hid_t object_id, H5F_scope_t scope ) return h5err(C.H5Fflush(f.id, C.H5F_scope_t(scope))) } // FIXME // Retrieves name of file to which object belongs. func (f *File) FileName() string { - // ssize_t H5Fget_name(hid_t obj_id, char *name, size_t size ) sz := int(C.H5Fget_name(f.id, nil, 0)) + 1 if sz < 0 { return "" } buf := string(make([]byte, sz)) - c_buf := C.CString(buf) - defer C.free(unsafe.Pointer(c_buf)) - sz = int(C.H5Fget_name(f.id, c_buf, C.size_t(sz))) + cBuf := C.CString(buf) + defer C.free(unsafe.Pointer(cBuf)) + sz = int(C.H5Fget_name(f.id, cBuf, C.size_t(sz))) if sz < 0 { return "" } - return C.GoString(c_buf) + return C.GoString(cBuf) } @@ -126,21 +124,18 @@ var cdot = C.CString(".") // Creates a packet table to store fixed-length packets. The returned // table must be closed by the user when it is no longer needed. -func (f *File) CreateTable(name string, dtype *Datatype, chunkSize, compression int) (*Table, error) { - // hid_t H5PTcreate_fl( hid_t loc_id, const char * dset_name, hid_t dtype_id, hsize_t chunk_size, int compression ) - return createTable(f.id, name, dtype, chunkSize, compression) +func (f *File) CreateTable(name string, typ *Datatype, chunkSize, compression int) (*Table, error) { + return createTable(f.id, name, typ, chunkSize, compression) } // Creates a packet table to store fixed-length packets. The returned // table must be closed by the user when it is no longer needed. -func (f *File) CreateTableFrom(name string, dtype interface{}, chunkSize, compression int) (*Table, error) { - // hid_t H5PTcreate_fl( hid_t loc_id, const char * dset_name, hid_t dtype_id, hsize_t chunk_size, int compression ) - return createTableFrom(f.id, name, dtype, chunkSize, compression) +func (f *File) CreateTableFrom(name string, typ interface{}, chunkSize, compression int) (*Table, error) { + return createTableFrom(f.id, name, typ, chunkSize, compression) } // Opens an existing packet table. The returned table must be closed // by the user when it is no longer needed. func (f *File) OpenTable(name string) (*Table, error) { - // hid_t H5PTopen( hid_t loc_id, const char *dset_name ) return openTable(f.id, name) } diff --git a/h5g_group.go b/h5g_group.go index 7754ef5..4925ce9 100644 --- a/h5g_group.go +++ b/h5g_group.go @@ -29,12 +29,12 @@ type Group struct { // in the file. The returned group must be closed by the user when it is no // longer needed. func (g *CommonFG) CreateGroup(name string) (*Group, error) { - c_name := C.CString(name) - defer C.free(unsafe.Pointer(c_name)) + cName := C.CString(name) + defer C.free(unsafe.Pointer(cName)) - link_flags := C.hid_t(C.H5P_DEFAULT) - grp_c_flags := C.hid_t(C.H5P_DEFAULT) - hid := C.H5Gcreate2(g.id, c_name, link_flags, grp_c_flags, P_DEFAULT.id) + linkFlags := C.hid_t(C.H5P_DEFAULT) + grpCFlags := C.hid_t(C.H5P_DEFAULT) + hid := C.H5Gcreate2(g.id, cName, linkFlags, grpCFlags, P_DEFAULT.id) if err := checkID(hid); err != nil { return nil, err } @@ -44,26 +44,26 @@ func (g *CommonFG) CreateGroup(name string) (*Group, error) { // CreateDataset creates a new Dataset. The returned dataset must be // closed by the user when it is no longer needed. -func (g *CommonFG) CreateDataset(name string, dtype *Datatype, dspace *Dataspace) (*Dataset, error) { - return createDataset(g.id, name, dtype, dspace, P_DEFAULT) +func (g *CommonFG) CreateDataset(name string, typ *Datatype, spc *Dataspace) (*Dataset, error) { + return createDataset(g.id, name, typ, spc, P_DEFAULT) } // CreateDatasetWith creates a new Dataset with a user-defined PropList. // The returned dataset must be closed by the user when it is no longer needed. -func (g *CommonFG) CreateDatasetWith(name string, dtype *Datatype, dspace *Dataspace, dcpl *PropList) (*Dataset, error) { - return createDataset(g.id, name, dtype, dspace, dcpl) +func (g *CommonFG) CreateDatasetWith(name string, typ *Datatype, spc *Dataspace, dcpl *PropList) (*Dataset, error) { + return createDataset(g.id, name, typ, spc, dcpl) } // CreateAttribute creates a new attribute at this location. The returned // attribute must be closed by the user when it is no longer needed. -func (g *Group) CreateAttribute(name string, dtype *Datatype, dspace *Dataspace) (*Attribute, error) { - return createAttribute(g.id, name, dtype, dspace, P_DEFAULT) +func (g *Group) CreateAttribute(name string, typ *Datatype, spc *Dataspace) (*Attribute, error) { + return createAttribute(g.id, name, typ, spc, P_DEFAULT) } // CreateAttributeWith creates a new attribute at this location with a user-defined // PropList. The returned dataset must be closed by the user when it is no longer needed. -func (g *Group) CreateAttributeWith(name string, dtype *Datatype, dspace *Dataspace, acpl *PropList) (*Attribute, error) { - return createAttribute(g.id, name, dtype, dspace, acpl) +func (g *Group) CreateAttributeWith(name string, typ *Datatype, spc *Dataspace, acpl *PropList) (*Attribute, error) { + return createAttribute(g.id, name, typ, spc, acpl) } // Close closes the Group. @@ -78,10 +78,10 @@ func h5gclose(id C.hid_t) C.herr_t { // OpenGroup opens and returns an existing child group from this Group. // The returned group must be closed by the user when it is no longer needed. func (g *CommonFG) OpenGroup(name string) (*Group, error) { - c_name := C.CString(name) - defer C.free(unsafe.Pointer(c_name)) + cName := C.CString(name) + defer C.free(unsafe.Pointer(cName)) - hid := C.H5Gopen2(g.id, c_name, P_DEFAULT.id) + hid := C.H5Gopen2(g.id, cName, P_DEFAULT.id) if err := checkID(hid); err != nil { return nil, err } @@ -92,10 +92,10 @@ func (g *CommonFG) OpenGroup(name string) (*Group, error) { // OpenDataset opens and returns a named Dataset. The returned // dataset must be closed by the user when it is no longer needed. func (g *CommonFG) OpenDataset(name string) (*Dataset, error) { - c_name := C.CString(name) - defer C.free(unsafe.Pointer(c_name)) + cName := C.CString(name) + defer C.free(unsafe.Pointer(cName)) - hid := C.H5Dopen2(g.id, c_name, P_DEFAULT.id) + hid := C.H5Dopen2(g.id, cName, P_DEFAULT.id) if err := checkID(hid); err != nil { return nil, err } @@ -128,14 +128,14 @@ func (g *CommonFG) ObjectNameByIndex(idx uint) (string, error) { // CreateTable creates a packet table to store fixed-length packets. // The returned table must be closed by the user when it is no longer needed. -func (g *Group) CreateTable(name string, dtype *Datatype, chunkSize, compression int) (*Table, error) { - return createTable(g.id, name, dtype, chunkSize, compression) +func (g *Group) CreateTable(name string, typ *Datatype, chunkSize, compression int) (*Table, error) { + return createTable(g.id, name, typ, chunkSize, compression) } // CreateTableFrom creates a packet table to store fixed-length packets. // The returned table must be closed by the user when it is no longer needed. -func (g *Group) CreateTableFrom(name string, dtype interface{}, chunkSize, compression int) (*Table, error) { - return createTableFrom(g.id, name, dtype, chunkSize, compression) +func (g *Group) CreateTableFrom(name string, typ interface{}, chunkSize, compression int) (*Table, error) { + return createTableFrom(g.id, name, typ, chunkSize, compression) } // OpenTable opens an existing packet table. The returned table must be diff --git a/h5g_group_test.go b/h5g_group_test.go index 76374f6..b67f723 100644 --- a/h5g_group_test.go +++ b/h5g_group_test.go @@ -86,18 +86,18 @@ func TestGroup(t *testing.T) { data := 5 - dtype, err := NewDatatypeFromValue(data) + typ, err := NewDatatypeFromValue(data) if err != nil { t.Fatal(err) } dims := []uint{1} - dspace, err := CreateSimpleDataspace(dims, dims) + spc, err := CreateSimpleDataspace(dims, dims) if err != nil { t.Fatal(err) } - dset, err := g3.CreateDataset("dset", dtype, dspace) + dset, err := g3.CreateDataset("dset", typ, spc) if err != nil { t.Fatal(err) } diff --git a/h5i_identifier.go b/h5i_identifier.go index 9649db3..bf07f51 100644 --- a/h5i_identifier.go +++ b/h5i_identifier.go @@ -44,13 +44,13 @@ func (i Identifier) Name() string { return "" } buf := string(make([]byte, sz)) - c_buf := C.CString(buf) - defer C.free(unsafe.Pointer(c_buf)) - sz = int(C.H5Iget_name(i.id, c_buf, C.size_t(sz))) + cBuf := C.CString(buf) + defer C.free(unsafe.Pointer(cBuf)) + sz = int(C.H5Iget_name(i.id, cBuf, C.size_t(sz))) if sz < 0 { return "" } - return C.GoString(c_buf) + return C.GoString(cBuf) } // File returns the file associated with this Identifier. diff --git a/h5p_proplist.go b/h5p_proplist.go index 819bb60..d2811bb 100644 --- a/h5p_proplist.go +++ b/h5p_proplist.go @@ -27,8 +27,8 @@ func newPropList(id C.hid_t) *PropList { // NewPropList creates a new PropList as an instance of a property list class. // The returned proplist must be closed by the user when it is no longer needed. -func NewPropList(cls_id PropType) (*PropList, error) { - hid := C.H5Pcreate(C.hid_t(cls_id)) +func NewPropList(clsID PropType) (*PropList, error) { + hid := C.H5Pcreate(C.hid_t(clsID)) if err := checkID(hid); err != nil { return nil, err } diff --git a/h5pt_table.go b/h5pt_table.go index b94d772..97f89a5 100644 --- a/h5pt_table.go +++ b/h5pt_table.go @@ -43,30 +43,30 @@ func (t *Table) IsValid() bool { } // ReadPackets reads a number of packets from a packet table. -func (t *Table) ReadPackets(start, nrecords int, data interface{}) error { - c_start := C.hsize_t(start) - c_nrecords := C.size_t(nrecords) +func (t *Table) ReadPackets(start, nRecords int, data interface{}) error { + cStart := C.hsize_t(start) + cNRecords := C.size_t(nRecords) rv := reflect.Indirect(reflect.ValueOf(data)) rt := rv.Type() - c_data := unsafe.Pointer(nil) + var cData unsafe.Pointer switch rt.Kind() { case reflect.Array: - if rv.Len() < nrecords { + if rv.Len() < nRecords { panic(fmt.Errorf("not enough capacity in array (cap=%d)", rv.Len())) } - c_data = unsafe.Pointer(rv.Index(0).UnsafeAddr()) + cData = unsafe.Pointer(rv.Index(0).UnsafeAddr()) case reflect.Slice: - if rv.Len() < nrecords { + if rv.Len() < nRecords { panic(fmt.Errorf("not enough capacity in slice (cap=%d)", rv.Len())) } slice := (*reflect.SliceHeader)(unsafe.Pointer(rv.UnsafeAddr())) - c_data = unsafe.Pointer(slice.Data) + cData = unsafe.Pointer(slice.Data) default: panic(fmt.Errorf("unhandled kind (%s), need slice or array", rt.Kind())) } - err := C.H5PTread_packets(t.id, c_start, c_nrecords, c_data) + err := C.H5PTread_packets(t.id, cStart, cNRecords, cData) return h5err(err) } @@ -129,9 +129,9 @@ func (t *Table) Next(data interface{}) error { // NumPackets returns the number of packets in a packet table. func (t *Table) NumPackets() (int, error) { - c_nrecords := C.hsize_t(0) - err := C.H5PTget_num_packets(t.id, &c_nrecords) - return int(c_nrecords), h5err(err) + var n C.hsize_t + err := C.H5PTget_num_packets(t.id, &n) + return int(n), h5err(err) } // CreateIndex resets a packet table's index to the first packet. @@ -142,8 +142,8 @@ func (t *Table) CreateIndex() error { // SetIndex sets a packet table's index. func (t *Table) SetIndex(index int) error { - c_idx := C.hsize_t(index) - err := C.H5PTset_index(t.id, c_idx) + cIdx := C.hsize_t(index) + err := C.H5PTset_index(t.id, cIdx) return h5err(err) } @@ -157,41 +157,41 @@ func (t *Table) Type() (*Datatype, error) { return NewDatatype(hid), nil } -func createTable(id C.hid_t, name string, dtype *Datatype, chunkSize, compression int) (*Table, error) { - c_name := C.CString(name) - defer C.free(unsafe.Pointer(c_name)) +func createTable(id C.hid_t, name string, typ *Datatype, chunkSize, compression int) (*Table, error) { + cName := C.CString(name) + defer C.free(unsafe.Pointer(cName)) chunk := C.hsize_t(chunkSize) compr := C.int(compression) - hid := C.H5PTcreate_fl(id, c_name, dtype.id, chunk, compr) + hid := C.H5PTcreate_fl(id, cName, typ.id, chunk, compr) if err := checkID(hid); err != nil { return nil, err } return newPacketTable(hid), nil } -func createTableFrom(id C.hid_t, name string, dtype interface{}, chunkSize, compression int) (*Table, error) { +func createTableFrom(id C.hid_t, name string, typ interface{}, chunkSize, compression int) (*Table, error) { var err error - switch dt := dtype.(type) { + switch dt := typ.(type) { case reflect.Type: - if hdfDtype, err := NewDataTypeFromType(dt); err == nil { - return createTable(id, name, hdfDtype, chunkSize, compression) + if typ, err := NewDataTypeFromType(dt); err == nil { + return createTable(id, name, typ, chunkSize, compression) } case *Datatype: return createTable(id, name, dt, chunkSize, compression) default: - if hdfDtype, err := NewDataTypeFromType(reflect.TypeOf(dtype)); err == nil { - return createTable(id, name, hdfDtype, chunkSize, compression) + if typ, err := NewDataTypeFromType(reflect.TypeOf(typ)); err == nil { + return createTable(id, name, typ, chunkSize, compression) } } return nil, err } func openTable(id C.hid_t, name string) (*Table, error) { - c_name := C.CString(name) - defer C.free(unsafe.Pointer(c_name)) + cName := C.CString(name) + defer C.free(unsafe.Pointer(cName)) - hid := C.H5PTopen(id, c_name) + hid := C.H5PTopen(id, cName) if err := checkID(hid); err != nil { return nil, err } diff --git a/h5pt_table_test.go b/h5pt_table_test.go index 6caac06..ce1b2bf 100644 --- a/h5pt_table_test.go +++ b/h5pt_table_test.go @@ -19,13 +19,13 @@ const ( type particle struct { // Name string `hdf5:"Name"` // FIXME(TacoVox): ReadPackets seems to need an update - Vehicle_no uint8 `hdf5:"Vehicle Number"` + VehicleNo uint8 `hdf5:"Vehicle Number"` Satellites int8 `hdf5:"Satellites"` - Cars_no int16 `hdf5:"Number of Cars"` - Trucks_no int16 `hdf5:"Number of Trucks"` - Min_speed uint32 `hdf5:"Minimum Speed"` + CarsNo int16 `hdf5:"Number of Cars"` + TrucksNo int16 `hdf5:"Number of Trucks"` + MinSpeed uint32 `hdf5:"Minimum Speed"` Lati int32 `hdf5:"Latitude"` - Max_speed uint64 `hdf5:"Maximum Speed"` + MaxSpeed uint64 `hdf5:"Maximum Speed"` Longi int64 `hdf5:"Longitude"` Pressure float32 `hdf5:"Pressure"` Temperature float64 `hdf5:"Temperature"` @@ -34,7 +34,7 @@ type particle struct { // jmohep [2][2]int64 // FIXME(sbinet) } -func testTable(t *testing.T, dType interface{}, data ...interface{}) { +func testTable(t *testing.T, typ interface{}, data ...interface{}) { var table *Table typeString := reflect.TypeOf(data).String() @@ -47,7 +47,7 @@ func testTable(t *testing.T, dType interface{}, data ...interface{}) { defer os.Remove(fname) defer f.Close() - table, err = f.CreateTableFrom(tname, dType, chunkSize, compress) + table, err = f.CreateTableFrom(tname, typ, chunkSize, compress) if err != nil { t.Fatalf("CreateTableFrom struct failed for %s: %s", typeString, err) } diff --git a/h5s_dataspace.go b/h5s_dataspace.go index 2424364..ab0c455 100644 --- a/h5s_dataspace.go +++ b/h5s_dataspace.go @@ -66,24 +66,24 @@ func h5sclose(id C.hid_t) C.herr_t { // CreateSimpleDataspace creates a new simple dataspace and opens it for access. // The returned dataspace must be closed by the user when it is no longer needed. func CreateSimpleDataspace(dims, maxDims []uint) (*Dataspace, error) { - var c_dims, c_maxdims *C.hsize_t + var cDims, cMaxDims *C.hsize_t rank := C.int(0) if dims != nil { rank = C.int(len(dims)) - c_dims = (*C.hsize_t)(unsafe.Pointer(&dims[0])) + cDims = (*C.hsize_t)(unsafe.Pointer(&dims[0])) } if maxDims != nil { rank = C.int(len(maxDims)) - c_maxdims = (*C.hsize_t)(unsafe.Pointer(&maxDims[0])) + cMaxDims = (*C.hsize_t)(unsafe.Pointer(&maxDims[0])) } if len(dims) != len(maxDims) && (dims != nil && maxDims != nil) { return nil, errors.New("lengths of dims and maxDims do not match") } - hid := C.H5Screate_simple(rank, c_dims, c_maxdims) + hid := C.H5Screate_simple(rank, cDims, cMaxDims) if hid < 0 { return nil, fmt.Errorf("failed to create dataspace") } @@ -107,8 +107,8 @@ func (s *Dataspace) SetOffset(offset []uint) error { return err } - c_offset := (*C.hssize_t)(unsafe.Pointer(&offset[0])) - err := C.H5Soffset_simple(s.id, c_offset) + cOffset := (*C.hssize_t)(unsafe.Pointer(&offset[0])) + err := C.H5Soffset_simple(s.id, cOffset) return h5err(err) } @@ -124,28 +124,28 @@ func (s *Dataspace) SelectHyperslab(offset, stride, count, block []uint) error { return err } - c_offset := (*C.hsize_t)(unsafe.Pointer(&offset[0])) - c_count := (*C.hsize_t)(unsafe.Pointer(&count[0])) - var c_stride, c_block *C.hsize_t + cOffset := (*C.hsize_t)(unsafe.Pointer(&offset[0])) + cCount := (*C.hsize_t)(unsafe.Pointer(&count[0])) + var cStride, cBlock *C.hsize_t if stride != nil { - c_stride = (*C.hsize_t)(unsafe.Pointer(&stride[0])) + cStride = (*C.hsize_t)(unsafe.Pointer(&stride[0])) } if block != nil { - c_block = (*C.hsize_t)(unsafe.Pointer(&block[0])) + cBlock = (*C.hsize_t)(unsafe.Pointer(&block[0])) } - err := C.H5Sselect_hyperslab(s.id, C.H5S_SELECT_SET, c_offset, c_stride, c_count, c_block) + err := C.H5Sselect_hyperslab(s.id, C.H5S_SELECT_SET, cOffset, cStride, cCount, cBlock) return h5err(err) } // SimpleExtentDims returns dataspace dimension size and maximum size. -func (s *Dataspace) SimpleExtentDims() (dims, maxdims []uint, err error) { +func (s *Dataspace) SimpleExtentDims() (dims, maxDims []uint, err error) { rank := s.SimpleExtentNDims() dims = make([]uint, rank) - maxdims = make([]uint, rank) + maxDims = make([]uint, rank) - c_dims := (*C.hsize_t)(unsafe.Pointer(&dims[0])) - c_maxdims := (*C.hsize_t)(unsafe.Pointer(&maxdims[0])) - rc := C.H5Sget_simple_extent_dims(s.id, c_dims, c_maxdims) + cDims := (*C.hsize_t)(unsafe.Pointer(&dims[0])) + cMaxDims := (*C.hsize_t)(unsafe.Pointer(&maxDims[0])) + rc := C.H5Sget_simple_extent_dims(s.id, cDims, cMaxDims) err = h5err(C.herr_t(rc)) return } diff --git a/h5s_dataspace_test.go b/h5s_dataspace_test.go index 21670b7..04d2df1 100644 --- a/h5s_dataspace_test.go +++ b/h5s_dataspace_test.go @@ -48,13 +48,13 @@ func TestDataspace(t *testing.T) { func TestSimpleDataspace(t *testing.T) { dims := []uint{3, 3, 3} - maxdims := []uint{9, 9, 9} - ds, err := CreateSimpleDataspace(dims, maxdims) + maxDims := []uint{9, 9, 9} + ds, err := CreateSimpleDataspace(dims, maxDims) if err != nil { t.Fatal(err) } - dsDims, dsMaxdims, err := ds.SimpleExtentDims() + dsDims, dsMaxDims, err := ds.SimpleExtentDims() if err != nil { t.Fatal(err) @@ -64,8 +64,8 @@ func TestSimpleDataspace(t *testing.T) { t.Errorf("retrieved dims not equal: %v != %v", dims, dsDims) } - if !arrayEq(maxdims, dsMaxdims) { - t.Errorf("retrieved maxdims not equal: %v != %v", maxdims, dsMaxdims) + if !arrayEq(maxDims, dsMaxDims) { + t.Errorf("retrieved maxDims not equal: %v != %v", maxDims, dsMaxDims) } if ds.SimpleExtentNDims() != 3 { diff --git a/h5t_shim.go b/h5t_shim.go index 6672dce..ff506b2 100644 --- a/h5t_shim.go +++ b/h5t_shim.go @@ -262,14 +262,14 @@ var ( ) // -var h5t_VARIABLE = int(C.size_t_H5T_VARIABLE()) +var h5tVARIABLE = int(C.size_t_H5T_VARIABLE()) func makeGoStringDatatype() *Datatype { dt, err := T_C_S1.Copy() if err != nil { panic(err) } - err = dt.SetSize(h5t_VARIABLE) + err = dt.SetSize(h5tVARIABLE) if err != nil { panic(err) } diff --git a/h5t_types.go b/h5t_types.go index c8c75e8..5ba8c02 100644 --- a/h5t_types.go +++ b/h5t_types.go @@ -97,11 +97,11 @@ var ( // OpenDatatype opens a named datatype. The returned datastype must // be closed by the user when it is no longer needed. -func OpenDatatype(c CommonFG, name string, tapl_id int) (*Datatype, error) { - c_name := C.CString(name) - defer C.free(unsafe.Pointer(c_name)) +func OpenDatatype(c CommonFG, name string, taplID int) (*Datatype, error) { + cName := C.CString(name) + defer C.free(unsafe.Pointer(cName)) - id := C.H5Topen2(C.hid_t(c.id), c_name, C.hid_t(tapl_id)) + id := C.H5Topen2(C.hid_t(c.id), cName, C.hid_t(taplID)) if err := checkID(id); err != nil { return nil, err } @@ -198,14 +198,14 @@ type ArrayType struct { Datatype } -// NewArrayType creates a new ArrayType. The base_type specifies the element type +// NewArrayType creates a new ArrayType. The baseType specifies the element type // of the array and dims specify the dimensions of the array. The returned // arraytype must be closed by the user when it is no longer needed. -func NewArrayType(base_type *Datatype, dims []int) (*ArrayType, error) { - ndims := C.uint(len(dims)) - c_dims := (*C.hsize_t)(unsafe.Pointer(&dims[0])) +func NewArrayType(baseType *Datatype, dims []int) (*ArrayType, error) { + nDims := C.uint(len(dims)) + cDims := (*C.hsize_t)(unsafe.Pointer(&dims[0])) - hid := C.H5Tarray_create2(base_type.id, ndims, c_dims) + hid := C.H5Tarray_create2(baseType.id, nDims, cDims) if err := checkID(hid); err != nil { return nil, err } @@ -222,14 +222,14 @@ func (t *ArrayType) NDims() int { func (t *ArrayType) ArrayDims() []int { rank := t.NDims() dims := make([]int, rank) - hdims := make([]C.hsize_t, rank) - slice := (*reflect.SliceHeader)(unsafe.Pointer(&hdims)) - c_dims := (*C.hsize_t)(unsafe.Pointer(slice.Data)) - c_rank := int(C.H5Tget_array_dims2(t.id, c_dims)) - if c_rank != rank { + hDims := make([]C.hsize_t, rank) + slice := (*reflect.SliceHeader)(unsafe.Pointer(&hDims)) + cDims := (*C.hsize_t)(unsafe.Pointer(slice.Data)) + cRank := int(C.H5Tget_array_dims2(t.id, cDims)) + if cRank != rank { return nil } - for i, n := range hdims { + for i, n := range hDims { dims[i] = int(n) } return dims @@ -239,11 +239,11 @@ type VarLenType struct { Datatype } -// NewVarLenType creates a new VarLenType. the base_type specifies the element type +// NewVarLenType creates a new VarLenType. the baseType specifies the element type // of the VarLenType. The returned variable length type must be closed by the user // when it is no longer needed. -func NewVarLenType(base_type *Datatype) (*VarLenType, error) { - id := C.H5Tvlen_create(base_type.id) +func NewVarLenType(baseType *Datatype) (*VarLenType, error) { + id := C.H5Tvlen_create(baseType.id) if err := checkID(id); err != nil { return nil, err } @@ -284,33 +284,33 @@ func (t *Datatype) Class() TypeClass { } // MemberClass returns datatype class of compound datatype member. -func (t *CompoundType) MemberClass(mbr_idx int) TypeClass { - return TypeClass(C.H5Tget_member_class(t.id, C.uint(mbr_idx))) +func (t *CompoundType) MemberClass(mbrIDX int) TypeClass { + return TypeClass(C.H5Tget_member_class(t.id, C.uint(mbrIDX))) } // MemberName returns the name of a compound or enumeration datatype member. -func (t *CompoundType) MemberName(mbr_idx int) string { - c_name := C.H5Tget_member_name(t.id, C.uint(mbr_idx)) - defer C.free(unsafe.Pointer(c_name)) - return C.GoString(c_name) +func (t *CompoundType) MemberName(mbrIDX int) string { + cName := C.H5Tget_member_name(t.id, C.uint(mbrIDX)) + defer C.free(unsafe.Pointer(cName)) + return C.GoString(cName) } // MemberIndex returns the index of a compound or enumeration datatype member. func (t *CompoundType) MemberIndex(name string) int { - c_name := C.CString(name) - defer C.free(unsafe.Pointer(c_name)) - return int(C.H5Tget_member_index(t.id, c_name)) + cName := C.CString(name) + defer C.free(unsafe.Pointer(cName)) + return int(C.H5Tget_member_index(t.id, cName)) } // MemberOffset returns the offset of a field of a compound datatype. -func (t *CompoundType) MemberOffset(mbr_idx int) int { - return int(C.H5Tget_member_offset(t.id, C.uint(mbr_idx))) +func (t *CompoundType) MemberOffset(mbrIDX int) int { + return int(C.H5Tget_member_offset(t.id, C.uint(mbrIDX))) } // MemberType returns the datatype of the specified member. The returned // datatype must be closed by the user when it is no longer needed. -func (t *CompoundType) MemberType(mbr_idx int) (*Datatype, error) { - hid := C.H5Tget_member_type(t.id, C.uint(mbr_idx)) +func (t *CompoundType) MemberType(mbrIDX int) (*Datatype, error) { + hid := C.H5Tget_member_type(t.id, C.uint(mbrIDX)) if err := checkID(hid); err != nil { return nil, err } @@ -319,9 +319,9 @@ func (t *CompoundType) MemberType(mbr_idx int) (*Datatype, error) { // Insert adds a new member to a compound datatype. func (t *CompoundType) Insert(name string, offset int, field *Datatype) error { - cname := C.CString(name) - defer C.free(unsafe.Pointer(cname)) - return h5err(C.H5Tinsert(t.id, cname, C.size_t(offset), field.id)) + cName := C.CString(name) + defer C.free(unsafe.Pointer(cName)) + return h5err(C.H5Tinsert(t.id, cName, C.size_t(offset), field.id)) } // Pack recursively removes padding from within a compound datatype. @@ -338,17 +338,17 @@ type OpaqueDatatype struct { // SetTag tags an opaque datatype. func (t *OpaqueDatatype) SetTag(tag string) error { - ctag := C.CString(tag) - defer C.free(unsafe.Pointer(ctag)) - return h5err(C.H5Tset_tag(t.id, ctag)) + cTag := C.CString(tag) + defer C.free(unsafe.Pointer(cTag)) + return h5err(C.H5Tset_tag(t.id, cTag)) } // Tag returns the tag associated with an opaque datatype. func (t *OpaqueDatatype) Tag() string { - cname := C.H5Tget_tag(t.id) - if cname != nil { - defer C.free(unsafe.Pointer(cname)) - return C.GoString(cname) + cName := C.H5Tget_tag(t.id) + if cName != nil { + defer C.free(unsafe.Pointer(cName)) + return C.GoString(cName) } return "" } @@ -411,14 +411,14 @@ func NewDataTypeFromType(t reflect.Type) (*Datatype, error) { dt, err = T_NATIVE_HBOOL.Copy() case reflect.Array: - elem_type, err := NewDataTypeFromType(t.Elem()) + elemType, err := NewDataTypeFromType(t.Elem()) if err != nil { return nil, err } dims := getArrayDims(t) - adt, err := NewArrayType(elem_type, dims) + adt, err := NewArrayType(elemType, dims) if err != nil { return nil, err } @@ -426,12 +426,12 @@ func NewDataTypeFromType(t reflect.Type) (*Datatype, error) { dt = &adt.Datatype case reflect.Slice: - elem_type, err := NewDataTypeFromType(t.Elem()) + elemType, err := NewDataTypeFromType(t.Elem()) if err != nil { return nil, err } - sdt, err := NewVarLenType(elem_type) + sdt, err := NewVarLenType(elemType) if err != nil { return nil, err } @@ -448,23 +448,23 @@ func NewDataTypeFromType(t reflect.Type) (*Datatype, error) { n := t.NumField() for i := 0; i < n; i++ { f := t.Field(i) - var field_dt *Datatype - field_dt, err = NewDataTypeFromType(f.Type) + var ft *Datatype + ft, err = NewDataTypeFromType(f.Type) if err != nil { return nil, err } - if field_dt.goPtrPathLen > ptrPathLen { - ptrPathLen = field_dt.goPtrPathLen + if ft.goPtrPathLen > ptrPathLen { + ptrPathLen = ft.goPtrPathLen } offset := int(f.Offset + 0) - if field_dt == nil { + if ft == nil { return nil, fmt.Errorf("pb with field [%d-%s]", i, f.Name) } - field_name := string(f.Tag) - if len(field_name) == 0 { - field_name = f.Name + fieldName := string(f.Tag) + if len(fieldName) == 0 { + fieldName = f.Name } - err = cdt.Insert(field_name, offset, field_dt) + err = cdt.Insert(fieldName, offset, ft) if err != nil { return nil, fmt.Errorf("pb with field [%d-%s]: %s", i, f.Name, err) } diff --git a/h5t_types_test.go b/h5t_types_test.go index 926ffdc..d1eca78 100644 --- a/h5t_types_test.go +++ b/h5t_types_test.go @@ -110,30 +110,30 @@ func TestStructDatatype(t *testing.T) { // Test that the type can be constructed and that the number of // members is as expected. - var dtypes []*Datatype + var types []*Datatype // "Regular" value - dtype, err := NewDatatypeFromValue(test) + typ, err := NewDatatypeFromValue(test) if err != nil { t.Fatal(err) } - if dtype.hasIllegalGoPointer() { + if typ.hasIllegalGoPointer() { t.Errorf("unexpected illegal pointer for %T", test) } - dtypes = append(dtypes, dtype) + types = append(types, typ) // pointer to value - dtype, err = NewDatatypeFromValue(&test) + typ, err = NewDatatypeFromValue(&test) if err != nil { t.Fatal(err) } - if !dtype.hasIllegalGoPointer() { + if !typ.hasIllegalGoPointer() { t.Errorf("expected illegal pointer for %T", &test) } - dtypes = append(dtypes, dtype) + types = append(types, typ) - for _, dtype := range dtypes { - dt := CompoundType{*dtype} + for _, typ := range types { + dt := CompoundType{*typ} if dt.NMembers() != 3 { t.Errorf("wrong number of members: got %d, want %d", dt.NMembers(), 3) } @@ -181,9 +181,9 @@ func TestCloseBehavior(t *testing.T) { a int b float64 } - dtype, err := NewDatatypeFromValue(s) + typ, err := NewDatatypeFromValue(s) if err != nil { t.Fatal(err) } - defer dtype.Close() + defer typ.Close() } diff --git a/hdf5.go b/hdf5.go index c62dd7d..17cbe87 100644 --- a/hdf5.go +++ b/hdf5.go @@ -16,8 +16,7 @@ import ( func init() { err := h5err(C.H5open()) if err != nil { - err_str := fmt.Sprintf("pb calling H5open(): %s", err) - panic(err_str) + panic(fmt.Sprintf("pb calling H5open(): %s", err)) } } @@ -82,6 +81,6 @@ func GarbageCollect() error { // Object represents an hdf5 object. type Object interface { Name() string - Id() int + ID() int File() *File }