Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: rename Datatype into DataType #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/test-go-cpxcmpd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
6 changes: 3 additions & 3 deletions h5a.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand All @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion h5a_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
18 changes: 9 additions & 9 deletions h5d.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

Expand All @@ -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
}
2 changes: 1 addition & 1 deletion h5f.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
10 changes: 5 additions & 5 deletions h5g.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion h5g_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
8 changes: 4 additions & 4 deletions h5pt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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 {
Expand Down
Loading