From 38440971f81b2ffb93a8af1b891d1ddbebe5253a Mon Sep 17 00:00:00 2001 From: Sebastien Binet Date: Thu, 10 Aug 2017 16:50:00 +0200 Subject: [PATCH] all: rename Datatype into DataType Fixes gonum/hdf5#8. --- cmd/test-go-cpxcmpd/main.go | 2 +- h5a.go | 6 +- h5a_test.go | 2 +- h5d.go | 18 +-- h5f.go | 2 +- h5g.go | 10 +- h5g_test.go | 2 +- h5pt.go | 8 +- h5t.go | 108 +++++++++--------- h5t_shim.go | 222 ++++++++++++++++++------------------ h5t_test.go | 14 +-- 11 files changed, 197 insertions(+), 197 deletions(-) diff --git a/cmd/test-go-cpxcmpd/main.go b/cmd/test-go-cpxcmpd/main.go index 4c23c9a..af7f1f3 100644 --- a/cmd/test-go-cpxcmpd/main.go +++ b/cmd/test-go-cpxcmpd/main.go @@ -70,7 +70,7 @@ func main() { fmt.Printf(":: file [%s] created (id=%d)\n", fname, f.Id()) // create the memory data type - dtype, err := hdf5.NewDatatypeFromValue(s1[0]) + dtype, err := hdf5.NewDataTypeFromValue(s1[0]) if err != nil { panic("could not create a dtype") } diff --git a/h5a.go b/h5a.go index 5a98861..b052384 100644 --- a/h5a.go +++ b/h5a.go @@ -27,7 +27,7 @@ func newAttribute(id C.hid_t) *Attribute { return d } -func createAttribute(id C.hid_t, name string, dtype *Datatype, dspace *Dataspace, acpl *PropList) (*Attribute, error) { +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) @@ -84,7 +84,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{}, dtype *DataType) error { var addr unsafe.Pointer v := reflect.ValueOf(data) @@ -110,7 +110,7 @@ func (s *Attribute) Read(data interface{}, dtype *Datatype) error { } // 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{}, dtype *DataType) error { var addr unsafe.Pointer v := reflect.Indirect(reflect.ValueOf(data)) switch v.Kind() { diff --git a/h5a_test.go b/h5a_test.go index 38ce8d1..53b35e2 100644 --- a/h5a_test.go +++ b/h5a_test.go @@ -51,7 +51,7 @@ func TestWriteAttribute(t *testing.T) { for name, v := range attrs { dtype, err := NewDataTypeFromType(v.Type) if err != nil { - t.Fatalf("NewDatatypeFromValue failed: %s\n", err) + t.Fatalf("NewDataTypeFromValue failed: %s\n", err) } defer dtype.Close() diff --git a/h5d.go b/h5d.go index b13448d..59f5f99 100644 --- a/h5d.go +++ b/h5d.go @@ -27,7 +27,7 @@ func newDataset(id C.hid_t) *Dataset { return d } -func createDataset(id C.hid_t, name string, dtype *Datatype, dspace *Dataspace, dcpl *PropList) (*Dataset, error) { +func createDataset(id C.hid_t, name string, dtype *DataType, dspace *Dataspace, dcpl *PropList) (*Dataset, error) { dtype, err := dtype.Copy() // For safety if err != nil { return nil, err @@ -68,7 +68,7 @@ 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() + dtype, err := s.DataType() defer dtype.Close() if err != nil { return err @@ -116,7 +116,7 @@ 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() + dtype, err := s.DataType() defer dtype.Close() if err != nil { return err @@ -163,12 +163,12 @@ func (s *Dataset) Write(data interface{}) error { } // Creates a new attribute at this location. -func (s *Dataset) CreateAttribute(name string, dtype *Datatype, dspace *Dataspace) (*Attribute, error) { +func (s *Dataset) CreateAttribute(name string, dtype *DataType, dspace *Dataspace) (*Attribute, error) { return createAttribute(s.id, name, dtype, dspace, P_DEFAULT) } // Creates a new attribute at this location. -func (s *Dataset) CreateAttributeWith(name string, dtype *Datatype, dspace *Dataspace, acpl *PropList) (*Attribute, error) { +func (s *Dataset) CreateAttributeWith(name string, dtype *DataType, dspace *Dataspace, acpl *PropList) (*Attribute, error) { return createAttribute(s.id, name, dtype, dspace, acpl) } @@ -177,11 +177,11 @@ func (s *Dataset) OpenAttribute(name string) (*Attribute, error) { return openAttribute(s.id, name) } -// Datatype returns the HDF5 Datatype of the Dataset -func (s *Dataset) Datatype() (*Datatype, error) { +// DataType returns the HDF5 DataType of the Dataset +func (s *Dataset) DataType() (*DataType, error) { dtype_id := C.H5Dget_type(s.id) if dtype_id < 0 { - return nil, fmt.Errorf("couldn't open Datatype from Dataset %q", s.Name()) + return nil, fmt.Errorf("couldn't open DataType from Dataset %q", s.Name()) } - return NewDatatype(dtype_id), nil + return NewDataType(dtype_id), nil } diff --git a/h5f.go b/h5f.go index 2f4507e..e4fe6ec 100644 --- a/h5f.go +++ b/h5f.go @@ -134,7 +134,7 @@ var cdot = C.CString(".") // Creates a packet table to store fixed-length packets. // hid_t H5PTcreate_fl( hid_t loc_id, const char * dset_name, hid_t dtype_id, hsize_t chunk_size, int compression ) -func (f *File) CreateTable(name string, dtype *Datatype, chunkSize, compression int) (*Table, error) { +func (f *File) CreateTable(name string, dtype *DataType, chunkSize, compression int) (*Table, error) { return createTable(f.id, name, dtype, chunkSize, compression) } diff --git a/h5g.go b/h5g.go index b4ade83..c22763a 100644 --- a/h5g.go +++ b/h5g.go @@ -43,22 +43,22 @@ func (g *CommonFG) CreateGroup(name string) (*Group, error) { } // CreateDataset creates a new Dataset. -func (g *CommonFG) CreateDataset(name string, dtype *Datatype, dspace *Dataspace) (*Dataset, error) { +func (g *CommonFG) CreateDataset(name string, dtype *DataType, dspace *Dataspace) (*Dataset, error) { return createDataset(g.id, name, dtype, dspace, P_DEFAULT) } // CreateDatasetWith creates a new Dataset with a user-defined PropList. -func (g *CommonFG) CreateDatasetWith(name string, dtype *Datatype, dspace *Dataspace, dcpl *PropList) (*Dataset, error) { +func (g *CommonFG) CreateDatasetWith(name string, dtype *DataType, dspace *Dataspace, dcpl *PropList) (*Dataset, error) { return createDataset(g.id, name, dtype, dspace, dcpl) } // CreateAttribute creates a new attribute at this location. -func (g *Group) CreateAttribute(name string, dtype *Datatype, dspace *Dataspace) (*Attribute, error) { +func (g *Group) CreateAttribute(name string, dtype *DataType, dspace *Dataspace) (*Attribute, error) { return createAttribute(g.id, name, dtype, dspace, P_DEFAULT) } // CreateAttributeWith creates a new attribute at this location with a user-defined PropList. -func (g *Group) CreateAttributeWith(name string, dtype *Datatype, dspace *Dataspace, acpl *PropList) (*Attribute, error) { +func (g *Group) CreateAttributeWith(name string, dtype *DataType, dspace *Dataspace, acpl *PropList) (*Attribute, error) { return createAttribute(g.id, name, dtype, dspace, acpl) } @@ -129,7 +129,7 @@ func (g *CommonFG) ObjectNameByIndex(idx uint) (string, error) { } // CreateTable creates a packet table to store fixed-length packets. -func (g *Group) CreateTable(name string, dtype *Datatype, chunkSize, compression int) (*Table, error) { +func (g *Group) CreateTable(name string, dtype *DataType, chunkSize, compression int) (*Table, error) { return createTable(g.id, name, dtype, chunkSize, compression) } diff --git a/h5g_test.go b/h5g_test.go index f6dbd9a..d872117 100644 --- a/h5g_test.go +++ b/h5g_test.go @@ -86,7 +86,7 @@ func TestGroup(t *testing.T) { data := 5 - dtype, err := NewDatatypeFromValue(data) + dtype, err := NewDataTypeFromValue(data) if err != nil { t.Fatal(err) } diff --git a/h5pt.go b/h5pt.go index 1b5eadc..081409b 100644 --- a/h5pt.go +++ b/h5pt.go @@ -173,15 +173,15 @@ func (t *Table) SetIndex(index int) error { } // Type returns an identifier for a copy of the datatype for a dataset. -func (t *Table) Type() (*Datatype, error) { +func (t *Table) Type() (*DataType, error) { hid := C.H5Dget_type(t.id) if err := checkID(hid); err != nil { return nil, err } - return NewDatatype(hid), nil + return NewDataType(hid), nil } -func createTable(id C.hid_t, name string, dtype *Datatype, chunkSize, compression int) (*Table, error) { +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)) @@ -201,7 +201,7 @@ func createTableFrom(id C.hid_t, name string, dtype interface{}, chunkSize, comp if hdfDtype, err := NewDataTypeFromType(dt); err == nil { return createTable(id, name, hdfDtype, chunkSize, compression) } - case *Datatype: + case *DataType: return createTable(id, name, dt, chunkSize, compression) default: if hdfDtype, err := NewDataTypeFromType(reflect.TypeOf(dtype)); err == nil { diff --git a/h5t.go b/h5t.go index 6eb1c5d..c06e445 100644 --- a/h5t.go +++ b/h5t.go @@ -16,7 +16,7 @@ import ( "unsafe" ) -type Datatype struct { +type DataType struct { Identifier } @@ -83,7 +83,7 @@ var ( } parametricTypes typeMap = typeMap{ - // Only these types can be used with CreateDatatype + // Only these types can be used with CreateDataType T_COMPOUND: _go_struct_t, T_ENUM: _go_int_t, T_OPAQUE: nil, @@ -91,8 +91,8 @@ var ( } ) -// OpenDatatype opens a named datatype. -func OpenDatatype(c CommonFG, name string, tapl_id int) (*Datatype, error) { +// OpenDataType opens a named datatype. +func OpenDataType(c CommonFG, name string, tapl_id int) (*DataType, error) { c_name := C.CString(name) defer C.free(unsafe.Pointer(c_name)) @@ -100,20 +100,20 @@ func OpenDatatype(c CommonFG, name string, tapl_id int) (*Datatype, error) { if err := checkID(id); err != nil { return nil, err } - return NewDatatype(id), nil + return NewDataType(id), nil } -// NewDatatype creates a Datatype from an hdf5 id. -func NewDatatype(id C.hid_t) *Datatype { - t := &Datatype{Identifier{id}} - runtime.SetFinalizer(t, (*Datatype).finalizer) +// NewDataType creates a DataType from an hdf5 id. +func NewDataType(id C.hid_t) *DataType { + t := &DataType{Identifier{id}} + runtime.SetFinalizer(t, (*DataType).finalizer) return t } -// CreateDatatype creates a new datatype. +// CreateDataType creates a new datatype. // class must be T_COMPUND, T_OPAQUE, T_ENUM or T_STRING. // size is the size of the new datatype in bytes. -func CreateDatatype(class TypeClass, size int) (*Datatype, error) { +func CreateDataType(class TypeClass, size int) (*DataType, error) { _, ok := parametricTypes[class] if !ok { return nil, @@ -128,22 +128,22 @@ func CreateDatatype(class TypeClass, size int) (*Datatype, error) { if err := checkID(hid); err != nil { return nil, err } - return NewDatatype(hid), nil + return NewDataType(hid), nil } -func (t *Datatype) finalizer() { +func (t *DataType) finalizer() { if err := t.Close(); err != nil { panic(fmt.Errorf("error closing datatype: %s", err)) } } -// GoType returns the reflect.Type associated with the Datatype's TypeClass -func (t *Datatype) GoType() reflect.Type { +// GoType returns the reflect.Type associated with the DataType's TypeClass +func (t *DataType) GoType() reflect.Type { return typeClassToGoType[t.Class()] } // Close releases a datatype. -func (t *Datatype) Close() error { +func (t *DataType) Close() error { if t.id == 0 { return nil } @@ -153,54 +153,54 @@ func (t *Datatype) Close() error { } // Committed determines whether a datatype is a named type or a transient type. -func (t *Datatype) Committed() bool { +func (t *DataType) Committed() bool { return C.H5Tcommitted(t.id) > 0 } // Copy copies an existing datatype. -func (t *Datatype) Copy() (*Datatype, error) { - return copyDatatype(t.id) +func (t *DataType) Copy() (*DataType, error) { + return copyDataType(t.id) } -// copyDatatype should be called by any function wishing to return -// an existing Datatype from a Dataset or Attribute. -func copyDatatype(id C.hid_t) (*Datatype, error) { +// copyDataType should be called by any function wishing to return +// an existing DataType from a Dataset or Attribute. +func copyDataType(id C.hid_t) (*DataType, error) { hid := C.H5Tcopy(id) if err := checkID(hid); err != nil { return nil, err } - return NewDatatype(hid), nil + return NewDataType(hid), nil } // Equal determines whether two datatype identifiers refer to the same datatype. -func (t *Datatype) Equal(o *Datatype) bool { +func (t *DataType) Equal(o *DataType) bool { return C.H5Tequal(t.id, o.id) > 0 } // Lock locks a datatype. -func (t *Datatype) Lock() error { +func (t *DataType) Lock() error { return h5err(C.H5Tlock(t.id)) } -// Size returns the size of the Datatype. -func (t *Datatype) Size() uint { +// Size returns the size of the DataType. +func (t *DataType) Size() uint { return uint(C.H5Tget_size(t.id)) } -// SetSize sets the total size of a Datatype. -func (t *Datatype) SetSize(sz uint) error { +// SetSize sets the total size of a DataType. +func (t *DataType) SetSize(sz uint) error { err := C.H5Tset_size(t.id, C.size_t(sz)) return h5err(err) } type ArrayType struct { - Datatype + DataType } // NewArrayType creates a new ArrayType. // base_type specifies the element type of the array. // dims specify the dimensions of the array. -func NewArrayType(base_type *Datatype, dims []int) (*ArrayType, error) { +func NewArrayType(base_type *DataType, dims []int) (*ArrayType, error) { ndims := C.uint(len(dims)) c_dims := (*C.hsize_t)(unsafe.Pointer(&dims[0])) @@ -208,7 +208,7 @@ func NewArrayType(base_type *Datatype, dims []int) (*ArrayType, error) { if err := checkID(hid); err != nil { return nil, err } - t := &ArrayType{Datatype{Identifier{hid}}} + t := &ArrayType{DataType{Identifier{hid}}} runtime.SetFinalizer(t, (*ArrayType).finalizer) return t, nil } @@ -236,17 +236,17 @@ func (t *ArrayType) ArrayDims() []int { } type VarLenType struct { - Datatype + DataType } // NewVarLenType creates a new VarLenType. // base_type specifies the element type of the VarLenType. -func NewVarLenType(base_type *Datatype) (*VarLenType, error) { +func NewVarLenType(base_type *DataType) (*VarLenType, error) { id := C.H5Tvlen_create(base_type.id) if err := checkID(id); err != nil { return nil, err } - t := &VarLenType{Datatype{Identifier{id}}} + t := &VarLenType{DataType{Identifier{id}}} runtime.SetFinalizer(t, (*VarLenType).finalizer) return t, nil } @@ -257,7 +257,7 @@ func (vl *VarLenType) IsVariableStr() bool { } type CompoundType struct { - Datatype + DataType } // NewCompoundType creates a new CompoundType. @@ -267,7 +267,7 @@ func NewCompoundType(size int) (*CompoundType, error) { if err := checkID(id); err != nil { return nil, err } - t := &CompoundType{Datatype{Identifier{id}}} + t := &CompoundType{DataType{Identifier{id}}} runtime.SetFinalizer(t, (*CompoundType).finalizer) return t, nil } @@ -278,7 +278,7 @@ func (t *CompoundType) NMembers() int { } // Class returns the TypeClass of the DataType -func (t *Datatype) Class() TypeClass { +func (t *DataType) Class() TypeClass { return TypeClass(C.H5Tget_class(t.id)) } @@ -307,16 +307,16 @@ func (t *CompoundType) MemberOffset(mbr_idx int) int { } // MemberType returns the datatype of the specified member. -func (t *CompoundType) MemberType(mbr_idx int) (*Datatype, error) { +func (t *CompoundType) MemberType(mbr_idx int) (*DataType, error) { hid := C.H5Tget_member_type(t.id, C.uint(mbr_idx)) if err := checkID(hid); err != nil { return nil, err } - return NewDatatype(hid), nil + return NewDataType(hid), nil } // Insert adds a new member to a compound datatype. -func (t *CompoundType) Insert(name string, offset int, field *Datatype) error { +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)) @@ -330,19 +330,19 @@ func (t *CompoundType) Pack() error { return h5err(C.H5Tpack(t.id)) } -type OpaqueDatatype struct { - Datatype +type OpaqueDataType struct { + DataType } // SetTag tags an opaque datatype. -func (t *OpaqueDatatype) SetTag(tag string) error { +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)) } // Tag returns the tag associated with an opaque datatype. -func (t *OpaqueDatatype) Tag() string { +func (t *OpaqueDataType) Tag() string { cname := C.H5Tget_tag(t.id) if cname != nil { defer C.free(unsafe.Pointer(cname)) @@ -351,15 +351,15 @@ func (t *OpaqueDatatype) Tag() string { return "" } -// NewDatatypeFromValue creates a datatype from a value in an interface. -func NewDatatypeFromValue(v interface{}) (*Datatype, error) { +// NewDataTypeFromValue creates a datatype from a value in an interface. +func NewDataTypeFromValue(v interface{}) (*DataType, error) { return NewDataTypeFromType(reflect.TypeOf(v)) } -// NewDatatypeFromType creates a new Datatype from a reflect.Type. -func NewDataTypeFromType(t reflect.Type) (*Datatype, error) { +// NewDataTypeFromType creates a new DataType from a reflect.Type. +func NewDataTypeFromType(t reflect.Type) (*DataType, error) { - var dt *Datatype = nil + var dt *DataType = nil var err error switch t.Kind() { @@ -416,7 +416,7 @@ func NewDataTypeFromType(t reflect.Type) (*Datatype, error) { return nil, err } - dt = &adt.Datatype + dt = &adt.DataType case reflect.Slice: elem_type, err := NewDataTypeFromType(t.Elem()) @@ -429,7 +429,7 @@ func NewDataTypeFromType(t reflect.Type) (*Datatype, error) { return nil, err } - dt = &sdt.Datatype + dt = &sdt.DataType case reflect.Struct: sz := int(t.Size()) @@ -440,7 +440,7 @@ func NewDataTypeFromType(t reflect.Type) (*Datatype, error) { n := t.NumField() for i := 0; i < n; i++ { f := t.Field(i) - var field_dt *Datatype = nil + var field_dt *DataType = nil field_dt, err = NewDataTypeFromType(f.Type) if err != nil { return nil, err @@ -458,7 +458,7 @@ func NewDataTypeFromType(t reflect.Type) (*Datatype, error) { return nil, fmt.Errorf("pb with field [%d-%s]: %s", i, f.Name, err) } } - dt = &cdt.Datatype + dt = &cdt.DataType default: // Should never happen. diff --git a/h5t_shim.go b/h5t_shim.go index 547a867..fad7888 100644 --- a/h5t_shim.go +++ b/h5t_shim.go @@ -135,134 +135,134 @@ import "C" // list of predefined hdf5 data types var ( - T_C_S1 *Datatype = NewDatatype(C._H5T_C_S1()) - T_FORTRAN_S1 *Datatype = NewDatatype(C._H5T_FORTRAN_S1()) + T_C_S1 *DataType = NewDataType(C._H5T_C_S1()) + T_FORTRAN_S1 *DataType = NewDataType(C._H5T_FORTRAN_S1()) - T_STD_I8BE *Datatype = NewDatatype(C._H5T_STD_I8BE()) - T_STD_I8LE *Datatype = NewDatatype(C._H5T_STD_I8LE()) - T_STD_I16BE *Datatype = NewDatatype(C._H5T_STD_I16BE()) - T_STD_I16LE *Datatype = NewDatatype(C._H5T_STD_I16LE()) - T_STD_I32BE *Datatype = NewDatatype(C._H5T_STD_I32BE()) - T_STD_I32LE *Datatype = NewDatatype(C._H5T_STD_I32LE()) - T_STD_I64BE *Datatype = NewDatatype(C._H5T_STD_I64BE()) - T_STD_I64LE *Datatype = NewDatatype(C._H5T_STD_I64LE()) - T_STD_U8BE *Datatype = NewDatatype(C._H5T_STD_U8BE()) - T_STD_U8LE *Datatype = NewDatatype(C._H5T_STD_U8LE()) - T_STD_U16BE *Datatype = NewDatatype(C._H5T_STD_U16BE()) - T_STD_U16LE *Datatype = NewDatatype(C._H5T_STD_U16LE()) - T_STD_U32BE *Datatype = NewDatatype(C._H5T_STD_U32BE()) - T_STD_U32LE *Datatype = NewDatatype(C._H5T_STD_U32LE()) - T_STD_U64BE *Datatype = NewDatatype(C._H5T_STD_U64BE()) - T_STD_U64LE *Datatype = NewDatatype(C._H5T_STD_U64LE()) - T_STD_B8BE *Datatype = NewDatatype(C._H5T_STD_B8BE()) - T_STD_B8LE *Datatype = NewDatatype(C._H5T_STD_B8LE()) + T_STD_I8BE *DataType = NewDataType(C._H5T_STD_I8BE()) + T_STD_I8LE *DataType = NewDataType(C._H5T_STD_I8LE()) + T_STD_I16BE *DataType = NewDataType(C._H5T_STD_I16BE()) + T_STD_I16LE *DataType = NewDataType(C._H5T_STD_I16LE()) + T_STD_I32BE *DataType = NewDataType(C._H5T_STD_I32BE()) + T_STD_I32LE *DataType = NewDataType(C._H5T_STD_I32LE()) + T_STD_I64BE *DataType = NewDataType(C._H5T_STD_I64BE()) + T_STD_I64LE *DataType = NewDataType(C._H5T_STD_I64LE()) + T_STD_U8BE *DataType = NewDataType(C._H5T_STD_U8BE()) + T_STD_U8LE *DataType = NewDataType(C._H5T_STD_U8LE()) + T_STD_U16BE *DataType = NewDataType(C._H5T_STD_U16BE()) + T_STD_U16LE *DataType = NewDataType(C._H5T_STD_U16LE()) + T_STD_U32BE *DataType = NewDataType(C._H5T_STD_U32BE()) + T_STD_U32LE *DataType = NewDataType(C._H5T_STD_U32LE()) + T_STD_U64BE *DataType = NewDataType(C._H5T_STD_U64BE()) + T_STD_U64LE *DataType = NewDataType(C._H5T_STD_U64LE()) + T_STD_B8BE *DataType = NewDataType(C._H5T_STD_B8BE()) + T_STD_B8LE *DataType = NewDataType(C._H5T_STD_B8LE()) - T_STD_B16BE *Datatype = NewDatatype(C._H5T_STD_B16BE()) - T_STD_B16LE *Datatype = NewDatatype(C._H5T_STD_B16LE()) - T_STD_B32BE *Datatype = NewDatatype(C._H5T_STD_B32BE()) - T_STD_B32LE *Datatype = NewDatatype(C._H5T_STD_B32LE()) - T_STD_B64BE *Datatype = NewDatatype(C._H5T_STD_B64BE()) - T_STD_B64LE *Datatype = NewDatatype(C._H5T_STD_B64LE()) - T_STD_REF_OBJ *Datatype = NewDatatype(C._H5T_STD_REF_OBJ()) - T_STD_REF_DSETREG *Datatype = NewDatatype(C._H5T_STD_REF_DSETREG()) + T_STD_B16BE *DataType = NewDataType(C._H5T_STD_B16BE()) + T_STD_B16LE *DataType = NewDataType(C._H5T_STD_B16LE()) + T_STD_B32BE *DataType = NewDataType(C._H5T_STD_B32BE()) + T_STD_B32LE *DataType = NewDataType(C._H5T_STD_B32LE()) + T_STD_B64BE *DataType = NewDataType(C._H5T_STD_B64BE()) + T_STD_B64LE *DataType = NewDataType(C._H5T_STD_B64LE()) + T_STD_REF_OBJ *DataType = NewDataType(C._H5T_STD_REF_OBJ()) + T_STD_REF_DSETREG *DataType = NewDataType(C._H5T_STD_REF_DSETREG()) - T_IEEE_F32BE *Datatype = NewDatatype(C._H5T_IEEE_F32BE()) - T_IEEE_F32LE *Datatype = NewDatatype(C._H5T_IEEE_F32LE()) - T_IEEE_F64BE *Datatype = NewDatatype(C._H5T_IEEE_F64BE()) - T_IEEE_F64LE *Datatype = NewDatatype(C._H5T_IEEE_F64LE()) + T_IEEE_F32BE *DataType = NewDataType(C._H5T_IEEE_F32BE()) + T_IEEE_F32LE *DataType = NewDataType(C._H5T_IEEE_F32LE()) + T_IEEE_F64BE *DataType = NewDataType(C._H5T_IEEE_F64BE()) + T_IEEE_F64LE *DataType = NewDataType(C._H5T_IEEE_F64LE()) - T_UNIX_D32BE *Datatype = NewDatatype(C._H5T_UNIX_D32BE()) - T_UNIX_D32LE *Datatype = NewDatatype(C._H5T_UNIX_D32LE()) - T_UNIX_D64BE *Datatype = NewDatatype(C._H5T_UNIX_D64BE()) - T_UNIX_D64LE *Datatype = NewDatatype(C._H5T_UNIX_D64LE()) + T_UNIX_D32BE *DataType = NewDataType(C._H5T_UNIX_D32BE()) + T_UNIX_D32LE *DataType = NewDataType(C._H5T_UNIX_D32LE()) + T_UNIX_D64BE *DataType = NewDataType(C._H5T_UNIX_D64BE()) + T_UNIX_D64LE *DataType = NewDataType(C._H5T_UNIX_D64LE()) - T_INTEL_I8 *Datatype = NewDatatype(C._H5T_INTEL_I8()) - T_INTEL_I16 *Datatype = NewDatatype(C._H5T_INTEL_I16()) - T_INTEL_I32 *Datatype = NewDatatype(C._H5T_INTEL_I32()) - T_INTEL_I64 *Datatype = NewDatatype(C._H5T_INTEL_I64()) - T_INTEL_U8 *Datatype = NewDatatype(C._H5T_INTEL_U8()) - T_INTEL_U16 *Datatype = NewDatatype(C._H5T_INTEL_U16()) - T_INTEL_U32 *Datatype = NewDatatype(C._H5T_INTEL_U32()) - T_INTEL_U64 *Datatype = NewDatatype(C._H5T_INTEL_U64()) - T_INTEL_B8 *Datatype = NewDatatype(C._H5T_INTEL_B8()) - T_INTEL_B16 *Datatype = NewDatatype(C._H5T_INTEL_B16()) - T_INTEL_B32 *Datatype = NewDatatype(C._H5T_INTEL_B32()) - T_INTEL_B64 *Datatype = NewDatatype(C._H5T_INTEL_B64()) - T_INTEL_F32 *Datatype = NewDatatype(C._H5T_INTEL_F32()) - T_INTEL_F64 *Datatype = NewDatatype(C._H5T_INTEL_F64()) + T_INTEL_I8 *DataType = NewDataType(C._H5T_INTEL_I8()) + T_INTEL_I16 *DataType = NewDataType(C._H5T_INTEL_I16()) + T_INTEL_I32 *DataType = NewDataType(C._H5T_INTEL_I32()) + T_INTEL_I64 *DataType = NewDataType(C._H5T_INTEL_I64()) + T_INTEL_U8 *DataType = NewDataType(C._H5T_INTEL_U8()) + T_INTEL_U16 *DataType = NewDataType(C._H5T_INTEL_U16()) + T_INTEL_U32 *DataType = NewDataType(C._H5T_INTEL_U32()) + T_INTEL_U64 *DataType = NewDataType(C._H5T_INTEL_U64()) + T_INTEL_B8 *DataType = NewDataType(C._H5T_INTEL_B8()) + T_INTEL_B16 *DataType = NewDataType(C._H5T_INTEL_B16()) + T_INTEL_B32 *DataType = NewDataType(C._H5T_INTEL_B32()) + T_INTEL_B64 *DataType = NewDataType(C._H5T_INTEL_B64()) + T_INTEL_F32 *DataType = NewDataType(C._H5T_INTEL_F32()) + T_INTEL_F64 *DataType = NewDataType(C._H5T_INTEL_F64()) - T_ALPHA_I8 *Datatype = NewDatatype(C._H5T_ALPHA_I8()) - T_ALPHA_I16 *Datatype = NewDatatype(C._H5T_ALPHA_I16()) - T_ALPHA_I32 *Datatype = NewDatatype(C._H5T_ALPHA_I32()) - T_ALPHA_I64 *Datatype = NewDatatype(C._H5T_ALPHA_I64()) - T_ALPHA_U8 *Datatype = NewDatatype(C._H5T_ALPHA_U8()) - T_ALPHA_U16 *Datatype = NewDatatype(C._H5T_ALPHA_U16()) - T_ALPHA_U32 *Datatype = NewDatatype(C._H5T_ALPHA_U32()) - T_ALPHA_U64 *Datatype = NewDatatype(C._H5T_ALPHA_U64()) - T_ALPHA_B8 *Datatype = NewDatatype(C._H5T_ALPHA_B8()) - T_ALPHA_B16 *Datatype = NewDatatype(C._H5T_ALPHA_B16()) - T_ALPHA_B32 *Datatype = NewDatatype(C._H5T_ALPHA_B32()) - T_ALPHA_B64 *Datatype = NewDatatype(C._H5T_ALPHA_B64()) - T_ALPHA_F32 *Datatype = NewDatatype(C._H5T_ALPHA_F32()) - T_ALPHA_F64 *Datatype = NewDatatype(C._H5T_ALPHA_F64()) + T_ALPHA_I8 *DataType = NewDataType(C._H5T_ALPHA_I8()) + T_ALPHA_I16 *DataType = NewDataType(C._H5T_ALPHA_I16()) + T_ALPHA_I32 *DataType = NewDataType(C._H5T_ALPHA_I32()) + T_ALPHA_I64 *DataType = NewDataType(C._H5T_ALPHA_I64()) + T_ALPHA_U8 *DataType = NewDataType(C._H5T_ALPHA_U8()) + T_ALPHA_U16 *DataType = NewDataType(C._H5T_ALPHA_U16()) + T_ALPHA_U32 *DataType = NewDataType(C._H5T_ALPHA_U32()) + T_ALPHA_U64 *DataType = NewDataType(C._H5T_ALPHA_U64()) + T_ALPHA_B8 *DataType = NewDataType(C._H5T_ALPHA_B8()) + T_ALPHA_B16 *DataType = NewDataType(C._H5T_ALPHA_B16()) + T_ALPHA_B32 *DataType = NewDataType(C._H5T_ALPHA_B32()) + T_ALPHA_B64 *DataType = NewDataType(C._H5T_ALPHA_B64()) + T_ALPHA_F32 *DataType = NewDataType(C._H5T_ALPHA_F32()) + T_ALPHA_F64 *DataType = NewDataType(C._H5T_ALPHA_F64()) - T_MIPS_I8 *Datatype = NewDatatype(C._H5T_MIPS_I8()) - T_MIPS_I16 *Datatype = NewDatatype(C._H5T_MIPS_I16()) - T_MIPS_I32 *Datatype = NewDatatype(C._H5T_MIPS_I32()) - T_MIPS_I64 *Datatype = NewDatatype(C._H5T_MIPS_I64()) - T_MIPS_U8 *Datatype = NewDatatype(C._H5T_MIPS_U8()) - T_MIPS_U16 *Datatype = NewDatatype(C._H5T_MIPS_U16()) - T_MIPS_U32 *Datatype = NewDatatype(C._H5T_MIPS_U32()) - T_MIPS_U64 *Datatype = NewDatatype(C._H5T_MIPS_U64()) - T_MIPS_B8 *Datatype = NewDatatype(C._H5T_MIPS_B8()) - T_MIPS_B16 *Datatype = NewDatatype(C._H5T_MIPS_B16()) - T_MIPS_B32 *Datatype = NewDatatype(C._H5T_MIPS_B32()) - T_MIPS_B64 *Datatype = NewDatatype(C._H5T_MIPS_B64()) - T_MIPS_F32 *Datatype = NewDatatype(C._H5T_MIPS_F32()) - T_MIPS_F64 *Datatype = NewDatatype(C._H5T_MIPS_F64()) + T_MIPS_I8 *DataType = NewDataType(C._H5T_MIPS_I8()) + T_MIPS_I16 *DataType = NewDataType(C._H5T_MIPS_I16()) + T_MIPS_I32 *DataType = NewDataType(C._H5T_MIPS_I32()) + T_MIPS_I64 *DataType = NewDataType(C._H5T_MIPS_I64()) + T_MIPS_U8 *DataType = NewDataType(C._H5T_MIPS_U8()) + T_MIPS_U16 *DataType = NewDataType(C._H5T_MIPS_U16()) + T_MIPS_U32 *DataType = NewDataType(C._H5T_MIPS_U32()) + T_MIPS_U64 *DataType = NewDataType(C._H5T_MIPS_U64()) + T_MIPS_B8 *DataType = NewDataType(C._H5T_MIPS_B8()) + T_MIPS_B16 *DataType = NewDataType(C._H5T_MIPS_B16()) + T_MIPS_B32 *DataType = NewDataType(C._H5T_MIPS_B32()) + T_MIPS_B64 *DataType = NewDataType(C._H5T_MIPS_B64()) + T_MIPS_F32 *DataType = NewDataType(C._H5T_MIPS_F32()) + T_MIPS_F64 *DataType = NewDataType(C._H5T_MIPS_F64()) - T_NATIVE_CHAR *Datatype = NewDatatype(C._H5T_NATIVE_CHAR()) - T_NATIVE_INT *Datatype = NewDatatype(C._H5T_NATIVE_INT()) - T_NATIVE_FLOAT *Datatype = NewDatatype(C._H5T_NATIVE_FLOAT()) - T_NATIVE_SCHAR *Datatype = NewDatatype(C._H5T_NATIVE_SCHAR()) - T_NATIVE_UCHAR *Datatype = NewDatatype(C._H5T_NATIVE_UCHAR()) - T_NATIVE_SHORT *Datatype = NewDatatype(C._H5T_NATIVE_SHORT()) - T_NATIVE_USHORT *Datatype = NewDatatype(C._H5T_NATIVE_USHORT()) - T_NATIVE_UINT *Datatype = NewDatatype(C._H5T_NATIVE_UINT()) - T_NATIVE_LONG *Datatype = NewDatatype(C._H5T_NATIVE_LONG()) - T_NATIVE_ULONG *Datatype = NewDatatype(C._H5T_NATIVE_ULONG()) - T_NATIVE_LLONG *Datatype = NewDatatype(C._H5T_NATIVE_LLONG()) - T_NATIVE_ULLONG *Datatype = NewDatatype(C._H5T_NATIVE_ULLONG()) - T_NATIVE_DOUBLE *Datatype = NewDatatype(C._H5T_NATIVE_DOUBLE()) + T_NATIVE_CHAR *DataType = NewDataType(C._H5T_NATIVE_CHAR()) + T_NATIVE_INT *DataType = NewDataType(C._H5T_NATIVE_INT()) + T_NATIVE_FLOAT *DataType = NewDataType(C._H5T_NATIVE_FLOAT()) + T_NATIVE_SCHAR *DataType = NewDataType(C._H5T_NATIVE_SCHAR()) + T_NATIVE_UCHAR *DataType = NewDataType(C._H5T_NATIVE_UCHAR()) + T_NATIVE_SHORT *DataType = NewDataType(C._H5T_NATIVE_SHORT()) + T_NATIVE_USHORT *DataType = NewDataType(C._H5T_NATIVE_USHORT()) + T_NATIVE_UINT *DataType = NewDataType(C._H5T_NATIVE_UINT()) + T_NATIVE_LONG *DataType = NewDataType(C._H5T_NATIVE_LONG()) + T_NATIVE_ULONG *DataType = NewDataType(C._H5T_NATIVE_ULONG()) + T_NATIVE_LLONG *DataType = NewDataType(C._H5T_NATIVE_LLONG()) + T_NATIVE_ULLONG *DataType = NewDataType(C._H5T_NATIVE_ULLONG()) + T_NATIVE_DOUBLE *DataType = NewDataType(C._H5T_NATIVE_DOUBLE()) //#if H5_SIZEOF_LONG_DOUBLE !=0 - T_NATIVE_LDOUBLE *Datatype = NewDatatype(C._H5T_NATIVE_LDOUBLE()) + T_NATIVE_LDOUBLE *DataType = NewDataType(C._H5T_NATIVE_LDOUBLE()) //#endif - T_NATIVE_B8 *Datatype = NewDatatype(C._H5T_NATIVE_B8()) - T_NATIVE_B16 *Datatype = NewDatatype(C._H5T_NATIVE_B16()) - T_NATIVE_B32 *Datatype = NewDatatype(C._H5T_NATIVE_B32()) - T_NATIVE_B64 *Datatype = NewDatatype(C._H5T_NATIVE_B64()) - T_NATIVE_OPAQUE *Datatype = NewDatatype(C._H5T_NATIVE_OPAQUE()) - T_NATIVE_HSIZE *Datatype = NewDatatype(C._H5T_NATIVE_HSIZE()) - T_NATIVE_HSSIZE *Datatype = NewDatatype(C._H5T_NATIVE_HSSIZE()) - T_NATIVE_HERR *Datatype = NewDatatype(C._H5T_NATIVE_HERR()) - T_NATIVE_HBOOL *Datatype = NewDatatype(C._H5T_NATIVE_HBOOL()) + T_NATIVE_B8 *DataType = NewDataType(C._H5T_NATIVE_B8()) + T_NATIVE_B16 *DataType = NewDataType(C._H5T_NATIVE_B16()) + T_NATIVE_B32 *DataType = NewDataType(C._H5T_NATIVE_B32()) + T_NATIVE_B64 *DataType = NewDataType(C._H5T_NATIVE_B64()) + T_NATIVE_OPAQUE *DataType = NewDataType(C._H5T_NATIVE_OPAQUE()) + T_NATIVE_HSIZE *DataType = NewDataType(C._H5T_NATIVE_HSIZE()) + T_NATIVE_HSSIZE *DataType = NewDataType(C._H5T_NATIVE_HSSIZE()) + T_NATIVE_HERR *DataType = NewDataType(C._H5T_NATIVE_HERR()) + T_NATIVE_HBOOL *DataType = NewDataType(C._H5T_NATIVE_HBOOL()) - T_NATIVE_INT8 *Datatype = NewDatatype(C._H5T_NATIVE_INT8()) - T_NATIVE_UINT8 *Datatype = NewDatatype(C._H5T_NATIVE_UINT8()) - T_NATIVE_INT16 *Datatype = NewDatatype(C._H5T_NATIVE_INT16()) - T_NATIVE_UINT16 *Datatype = NewDatatype(C._H5T_NATIVE_UINT16()) - T_NATIVE_INT32 *Datatype = NewDatatype(C._H5T_NATIVE_INT32()) - T_NATIVE_UINT32 *Datatype = NewDatatype(C._H5T_NATIVE_UINT32()) - T_NATIVE_INT64 *Datatype = NewDatatype(C._H5T_NATIVE_INT64()) - T_NATIVE_UINT64 *Datatype = NewDatatype(C._H5T_NATIVE_UINT64()) + T_NATIVE_INT8 *DataType = NewDataType(C._H5T_NATIVE_INT8()) + T_NATIVE_UINT8 *DataType = NewDataType(C._H5T_NATIVE_UINT8()) + T_NATIVE_INT16 *DataType = NewDataType(C._H5T_NATIVE_INT16()) + T_NATIVE_UINT16 *DataType = NewDataType(C._H5T_NATIVE_UINT16()) + T_NATIVE_INT32 *DataType = NewDataType(C._H5T_NATIVE_INT32()) + T_NATIVE_UINT32 *DataType = NewDataType(C._H5T_NATIVE_UINT32()) + T_NATIVE_INT64 *DataType = NewDataType(C._H5T_NATIVE_INT64()) + T_NATIVE_UINT64 *DataType = NewDataType(C._H5T_NATIVE_UINT64()) - T_GO_STRING *Datatype = makeGoStringDatatype() + T_GO_STRING *DataType = makeGoStringDataType() ) // var h5t_VARIABLE int64 = C.H5T_VARIABLE -func makeGoStringDatatype() *Datatype { +func makeGoStringDataType() *DataType { dt, err := T_C_S1.Copy() if err != nil { panic(err) diff --git a/h5t_test.go b/h5t_test.go index d89095e..442247e 100644 --- a/h5t_test.go +++ b/h5t_test.go @@ -10,7 +10,7 @@ import ( "time" ) -func TestSimpleDatatypes(t *testing.T) { +func TestSimpleDataTypes(t *testing.T) { // Smoke tests for the simple datatypes tests := []interface{}{ int(0), @@ -29,12 +29,12 @@ func TestSimpleDatatypes(t *testing.T) { } for test := range tests { - NewDatatypeFromValue(test) + NewDataTypeFromValue(test) } } // Test for array datatypes. Checks that the number of dimensions is correct. -func TestArrayDatatype(t *testing.T) { +func TestArrayDataType(t *testing.T) { tests := map[int]interface{}{ 1: [8]int{1, 1, 2, 3, 5, 8, 13}, 2: [2][2]int{{1, 2}, {3, 4}}, @@ -42,7 +42,7 @@ func TestArrayDatatype(t *testing.T) { } for dims, val := range tests { - dt, err := NewDatatypeFromValue(val) + dt, err := NewDataTypeFromValue(val) if err != nil { t.Fatal(err) } @@ -53,7 +53,7 @@ func TestArrayDatatype(t *testing.T) { } } -func TestStructDatatype(t *testing.T) { +func TestStructDataType(t *testing.T) { test := struct { a int32 b string @@ -65,7 +65,7 @@ func TestStructDatatype(t *testing.T) { // Test that the type can be constructed and that the number of // members is as expected. - dtype, err := NewDatatypeFromValue(test) + dtype, err := NewDataTypeFromValue(test) if err != nil { t.Fatal(err) } @@ -116,7 +116,7 @@ func TestCloseBehavior(t *testing.T) { a int b float64 } - dtype, err := NewDatatypeFromValue(s) + dtype, err := NewDataTypeFromValue(s) if err != nil { t.Fatal(err) }