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

Remove array support from gl.Ptr #55

Merged
merged 2 commits into from
Mar 6, 2015
Merged

Remove array support from gl.Ptr #55

merged 2 commits into from
Mar 6, 2015

Conversation

errcw
Copy link
Member

@errcw errcw commented Mar 5, 2015

Resolves (partially) go-gl/gl#2. We also need to regenerate the bindings.

Resolves go-gl/gl/issues#2 in part. We also need to regenerate the bindings.
@@ -13,7 +13,7 @@ import (
"unsafe"
)

// Ptr takes a pointer, slice, or array and returns its GL-compatible address.
// Ptr takes a pointer or slice and returns its GL-compatible address.
Copy link
Member

Choose a reason for hiding this comment

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

Can we elaborate on "pointer", pointer to what is okay? Pointer to slice? Pointer to array? Pointer to first element of slice? Pointer to first element of array?

As far as I can tell, only pointers to first elements of slices/arrays are allowed. If so, that should be clearly documented 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.

Updated.

Copy link
Member

Choose a reason for hiding this comment

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

Thank you!

@dmitshur
Copy link
Member

dmitshur commented Mar 6, 2015

LGTM.

We also need to regenerate the bindings.

Yep, that's task 2 of #52.

errcw added a commit that referenced this pull request Mar 6, 2015
Remove array support from gl.Ptr
@errcw errcw merged commit e19608d into master Mar 6, 2015
@dmitshur dmitshur deleted the ptr-array-support branch March 7, 2015 04:50
dmitshur referenced this pull request in go-gl/gl Mar 15, 2015
`go generate -tags=gen`
Regenerate all gl bindings using the new go generate directives and
latest version of glow.
Fixes #8.
Closes #2.
@@ -34,8 +35,6 @@ func Ptr(data interface{}) unsafe.Pointer {
addr = unsafe.Pointer(v.Pointer())
case reflect.Slice:
addr = unsafe.Pointer(v.Index(0).UnsafeAddr())
case reflect.Array:
addr = unsafe.Pointer(v.UnsafeAddr())
default:
panic(fmt.Sprintf("Unsupported type %s; must be a pointer, slice, or array", v.Type()))
Copy link
Member

Choose a reason for hiding this comment

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

Need to also remove "or array" here. I will do that in a PR soon.

Edit: Fixed in #72.

dmitshur added a commit that referenced this pull request Mar 6, 2016
Currently, gl.Ptr will simply not set value of adds when provided with
a pointer to a type that is not supported. That means it returns null
pointer, which is likely going to cause issues for user of gl.Ptr.
Instead of silently ignoring this, panic with a helpful error message.

Also follow up to #55 and remove mention of arrays, they are not
supported.

Fix for go-gl/gl#32.
dmitshur added a commit that referenced this pull request Mar 6, 2016
Currently, gl.Ptr will simply not set value of adds when provided with
a pointer to a type that is not supported. That means it returns null
pointer, which is likely going to cause issues for user of gl.Ptr.
Instead of silently ignoring this, panic with a helpful error message.

Also follow up to #55 and remove mention of arrays, they are not
supported.

Fix for go-gl/gl#32.
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.

None yet

2 participants