Skip to content

Instantly share code, notes, and snippets.

@crazy2be
Created July 3, 2011 20:39
Show Gist options
  • Save crazy2be/1062583 to your computer and use it in GitHub Desktop.
Save crazy2be/1062583 to your computer and use it in GitHub Desktop.
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))
}
func (ctx *Context) newGoValueArray(ptr unsafe.Pointer, size uint) ([]*Value) {
if uintptr(ptr) == 0x00000000 {
return nil
}
goarr := make([]*Value, size)
for i := uint(0); i < size; i++ {
goarr[i] = ctx.newValue(C.JSValueRef(ptr))
ptr = unsafe.Pointer(4+uintptr(ptr))
}
return goarr
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment