-
Notifications
You must be signed in to change notification settings - Fork 25
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
Conversation
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
LGTM.
Yep, that's task 2 of #52. |
@@ -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())) |
There was a problem hiding this comment.
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.
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.
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.
Resolves (partially) go-gl/gl#2. We also need to regenerate the bindings.