Skip to content

Instantly share code, notes, and snippets.

@crazy2be
Created June 29, 2011 02:40
Show Gist options
  • Save crazy2be/1052853 to your computer and use it in GitHub Desktop.
Save crazy2be/1052853 to your computer and use it in GitHub Desktop.
// Given a slice of go-style Values, this function allocates a new array of c-style values and returns a pointer to the first element in the array, along with the length of the array.
func (ctx *Context) newCValueArray(val []*Value) (*C.JSValueRef, C.size_t) {
if len(val) == 0 {
return nil, 0
}
arr := make([]C.JSValueRef, len(val))
for i := 0; i < len(val); i++ {
arr[i] = val[i].ref
}
return &arr[0], C.size_t(len(arr))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment