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

hdf5: mark types with pointers #35

Merged
merged 5 commits into from
Jul 2, 2018
Merged

hdf5: mark types with pointers #35

merged 5 commits into from
Jul 2, 2018

Conversation

kortschak
Copy link
Member

This is part of the marking needed to know whether data copying will be needed. Note that it currently is overly conservative, and for all practical uses it will mark everything. There is a TODO that has an approach that I think will fix that.

This is more a PR for discussion of approach, but may end up being something that we can merge.

The half of the story needed to handle a Datatype that has been returned from opening a file is not dealt with here.

Please take a look.

Updates #12.

@kortschak kortschak requested review from sbinet and donkahlero June 29, 2018 12:53
Copy link
Member

@sbinet sbinet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this LGTM

I would probably s/_hasGoPointer/hasGoPointer/ though.

func (t *Datatype) Copy() (*Datatype, error) {
return copyDatatype(t.id)
c, err := copyDatatype(t.id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps modify the signature of copyDatatype to take a *Datatype instead of C.hid_t so nobody would unadvertantly drop the _hasGoPointer value on the floor?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll do that when I make NewDatatype do the same thing with Identifier (and check where there are others that may also benefit.

Copy link
Collaborator

@donkahlero donkahlero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as well. Just a side note in the comments :)

h5t_types.go Outdated
@@ -462,7 +471,13 @@ func NewDataTypeFromType(t reflect.Type) (*Datatype, error) {
dt = &cdt.Datatype

case reflect.Ptr:
return NewDataTypeFromType(t.Elem())
dt, err = NewDataTypeFromType(t.Elem())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it is now time for us to start figuring out a way of handling H5T_STD_REF_OBJ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to file an issue for that?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable.

@kortschak
Copy link
Member Author

Any comments about pointer path counting?

@kortschak
Copy link
Member Author

I have added precise pointer chain accounting.

PTAL

}

for test := range tests {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was testing int, test is the first var in the range statement.

for test := range tests {
NewDatatypeFromValue(test)
// Test again for usage with ptrs
NewDatatypeFromValue(&test)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would have been (but wasn't) testing *interface{} which we do not handle.

Copy link
Collaborator

@donkahlero donkahlero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like your last changes! My comments are as before really just minor stuff.

h5t_types.go Outdated
@@ -17,6 +17,8 @@ import (

type Datatype struct {
Identifier

_goPtrPathLen int
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like @sbinet, I personally would name those fields w/o the underscore.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here it's OK to change to the w/o. Previously I preferred it the other way. I'll make the change.

NewDatatypeFromValue(test)
// Test again for usage with ptrs
NewDatatypeFromValue(&test)
for _, test := range tests {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well spotted!!!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to figure out why my test was not working and shoved in a print %T and only got integers.

// Test again for usage with ptrs
NewDatatypeFromValue(&test)
for _, test := range tests {
dt, _ := NewDatatypeFromValue(test.v)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to not check for the error here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll panic later if we don't succeed. I'll change it.

@kortschak
Copy link
Member Author

PTAL

And slice and array types.
Copy link
Collaborator

@donkahlero donkahlero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

n := t.NumField()
for i := 0; i < n; i++ {
f := t.Field(i)
var field_dt *Datatype = nil
var field_dt *Datatype
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you didn't wrote this in the first place, but maybe change to fieldDt? Maybe I should also open an issue for moving to Go-style Camel Case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a collection of things like this that I'd like to fix up. Please do file that issue.

@kortschak kortschak merged commit c257073 into master Jul 2, 2018
@kortschak kortschak deleted the pointer-annot branch July 2, 2018 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants